/* Portfolio Tracker — Bento-glass dashboard
   Prefix: pt-*
   Inherits site CSS vars (--bg, --surface, --ink, --accent, --line, etc.)
   Designed for all 4 themes (paper/industrial/forest/ocean). */

.main--portfolio {
  max-width: none;
  padding: 0 0 64px;
}

.pt-live {
  width: min(1140px, calc(100% - 28px));
  margin: 0 auto;
  padding: 16px 0 0;
}

/* ── Header ── */
.pt-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 0 4px 16px;
}

.pt-header__title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.pt-header__lead {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.pt-header__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Bento Grid ── */
.pt-bento {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(12, 1fr);
}

/* ── Glass Card ── */
.pt-card {
  position: relative;
  padding: 18px 20px;
  border-radius: 14px;
  background:
    linear-gradient(
      145deg,
      color-mix(in srgb, var(--accent) 4%, var(--surface)) 0%,
      var(--surface) 100%
    );
  border: 1px solid color-mix(in srgb, var(--ink) 8%, var(--line));
  box-shadow:
    0 1px 0 color-mix(in srgb, var(--ink) 3%, transparent),
    0 4px 20px color-mix(in srgb, var(--ink) 6%, transparent);
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.pt-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, #fff 3%, transparent) 0%,
    transparent 50%
  );
}

[data-theme="paper"] .pt-card::before {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, #fff 8%, transparent) 0%,
    transparent 40%
  );
}

/* ── KPI cells ── */
.pt-kpi-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.pt-kpi {
  grid-column: auto;
  min-width: 0;
}

.pt-kpi--debt .pt-kpi__value {
  color: #c07070;
}

.pt-kpi__label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

.pt-kpi__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.pt-kpi__head .pt-kpi__label {
  margin-bottom: 0;
}

.pt-kpi__pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--ink) 6%, var(--bg));
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.pt-kpi--water .pt-water-track {
  margin-top: 8px;
}

.pt-kpi__value {
  display: block;
  font-family: var(--mono);
  font-size: clamp(18px, 3.5vw, 24px);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.pt-kpi__sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-faint);
}

.pt-kpi__sparkline {
  display: block;
  width: 64px;
  height: 20px;
  color: var(--accent);
  opacity: 0.7;
}

.pt-gain { color: var(--tw); }
.pt-loss { color: #c07070; }

.pt-change-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
}

.pt-change-pill--up {
  color: var(--tw);
  background: color-mix(in srgb, var(--tw) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--tw) 30%, var(--line));
}

.pt-change-pill--down {
  color: #c07070;
  background: color-mix(in srgb, #c07070 10%, var(--surface));
  border: 1px solid color-mix(in srgb, #c07070 25%, var(--line));
}

.pt-change-pill--neutral {
  color: var(--ink-faint);
  background: var(--surface-hover);
  border: 1px solid var(--line);
}

/* ── Chart card ── */
.pt-chart-card {
  grid-column: span 7;
  min-height: 300px;
}

.pt-chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.pt-chart-head__left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.pt-chart-modes {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: fit-content;
}

.pt-chart-mode {
  appearance: none;
  padding: 4px 10px;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.pt-chart-mode:hover {
  color: var(--ink-soft);
  background: var(--surface-hover);
}

.pt-chart-mode.is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 10%, transparent);
}

.pt-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 10px;
}

.pt-chart-legend__chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s, border-color 0.15s;
}

.pt-chart-legend__chip.is-on {
  opacity: 1;
  border-color: color-mix(in srgb, var(--chip-color, var(--accent)) 55%, var(--line));
}

.pt-chart-legend__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chip-color, var(--accent));
  flex-shrink: 0;
}

.pt-chart-container {
  position: relative;
  width: 100%;
  height: 220px;
}

.pt-chart-container.is-accounts {
  height: 300px;
}

.pt-chart-title {
  margin: 0;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.pt-range-tabs {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pt-range-tab {
  appearance: none;
  padding: 4px 10px;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.pt-range-tab:hover {
  color: var(--ink-soft);
  background: var(--surface-hover);
}

.pt-range-tab.is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 10%, transparent);
}

.pt-chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--ink-faint);
  font-size: 13px;
}

/* ── Allocation card ── */
.pt-alloc-card {
  grid-column: span 5;
  min-height: 300px;
}

.pt-alloc-title {
  margin: 0 0 14px;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.pt-donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
}

.pt-donut {
  position: relative;
  width: 110px;
  height: 110px;
  flex-shrink: 0;
  border-radius: 50%;
}

.pt-donut__center {
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.pt-donut__count {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}

.pt-donut__label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 2px;
}

.pt-alloc-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.pt-alloc-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 4px;
  margin: 0 -4px;
}

.pt-alloc-legend li:hover,
.pt-alloc-legend li.is-active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.pt-alloc-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.pt-alloc-name {
  flex: 1;
  min-width: 0;
}

.pt-alloc-pct {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

/* Market colors */
.pt-market-tw { background: var(--tw); }
.pt-market-us { background: var(--us); }
.pt-market-crypto { background: #d97706; }
.pt-market-cash { background: var(--accent); }
.pt-market-other { background: var(--ink-faint); }

/* ── Holdings card (full width below) ── */
.pt-holdings-card {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
}

.pt-holdings-head {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 10px;
}

.pt-holdings-title {
  margin: 0;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.pt-holdings-note {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink-faint);
}

.pt-market-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pt-market-tab {
  appearance: none;
  padding: 5px 9px;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.pt-market-tab:hover {
  color: var(--ink-soft);
  background: var(--surface-hover);
}

.pt-market-tab.is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 10%, transparent);
}

.pt-holdings-tab-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--ink-faint);
}

.pt-holdings-tab-meta__sum {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.pt-holdings-tab-meta__sum.pt-loss {
  color: var(--red, #ef4444);
}

.pt-holdings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 10px;
  overflow-y: auto;
  max-height: min(420px, 55vh);
  padding: 2px 6px 4px 0;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--ink) 22%, transparent) transparent;
}

.pt-holdings-grid::-webkit-scrollbar {
  width: 6px;
}

.pt-holdings-grid::-webkit-scrollbar-track {
  background: transparent;
}

.pt-holdings-grid::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--ink) 22%, transparent);
  border-radius: 999px;
}

.pt-holdings-grid::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--ink) 38%, transparent);
}

.pt-holdings-grid::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

.pt-snap-lead {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-faint);
}

.pt-timeline__add {
  border-style: dashed;
  color: var(--accent);
}

.pt-holding__value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.pt-holding--debt {
  border-color: color-mix(in srgb, var(--red, #ef4444) 35%, var(--line));
}

.pt-muted {
  color: var(--ink-faint);
  font-size: 11px;
}

/* Timeline + water level */
.pt-timeline-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 14px;
  padding: 0 4px;
}

.pt-timeline-main {
  min-width: 0;
  flex: 1;
}

.pt-return-badge {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 4px 2px 2px;
  text-align: right;
}

.pt-return-badge__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.pt-return-badge__value {
  font-size: 13px;
  line-height: 1.2;
}

.pt-return-badge__value .pt-change-pill {
  font-size: 12px;
  padding: 2px 8px;
}

.pt-return-badge__sub {
  font-size: 11px;
  color: var(--ink-faint);
  max-width: 140px;
}

.pt-timeline-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}

.pt-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pt-timeline__chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pt-timeline__chip--detail::after {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
}

.pt-timeline__del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 2px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  color: var(--ink-faint);
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.pt-timeline__del:hover {
  color: #fff;
  background: #c07070;
}

.pt-holding--frozen {
  opacity: 0.92;
}

.pt-add-card--secondary {
  border-style: dashed;
  color: var(--ink-soft);
}

.pt-form-check {
  grid-column: 1 / -1;
  margin-top: 4px;
}

.pt-form-check__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}

.pt-timeline__chip:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}

.pt-timeline__chip.is-active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  border-color: var(--accent);
  color: var(--ink);
}

.pt-timeline__empty {
  margin: 0;
  font-size: 12px;
  color: var(--ink-faint);
}

.pt-water-track {
  margin-top: 10px;
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 8%, var(--line));
  overflow: hidden;
}

.pt-water-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.35s ease;
}

.pt-water-fill--ok {
  background: #34d399;
}

.pt-water-fill--low {
  background: #f59e0b;
}

.pt-water-fill--high {
  background: #3d8bfd;
}

.pt-alloc-note {
  margin: -4px 0 10px;
  font-size: 11px;
  color: var(--ink-faint);
}

.pt-alloc-liability .pt-alloc-pct {
  color: #c07070;
}

.pt-alloc-swatch--debt {
  background: repeating-linear-gradient(
    -45deg,
    #ef4444,
    #ef4444 2px,
    transparent 2px,
    transparent 4px
  );
  border: 1px solid #ef4444;
}

/* ── Holding card ── */
.pt-holding {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pt-holding:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 8%, transparent);
}

.pt-holding__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.pt-holding__identity {
  flex: 1;
  min-width: 0;
}

.pt-holding__symbol {
  display: inline-block;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.pt-holding__market-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pt-holding__market-badge--tw {
  color: var(--tw);
  background: color-mix(in srgb, var(--tw) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--tw) 30%, var(--line));
}

.pt-holding__market-badge--us {
  color: var(--us);
  background: color-mix(in srgb, var(--us) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--us) 30%, var(--line));
}

.pt-holding__market-badge--crypto {
  color: #d97706;
  background: color-mix(in srgb, #d97706 12%, var(--surface));
  border: 1px solid color-mix(in srgb, #d97706 30%, var(--line));
}

.pt-holding__market-badge--cash {
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
}

.pt-holding__name {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pt-holding__details {
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.5;
}

.pt-holding__details strong {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--ink-soft);
}

.pt-holding__sep {
  color: var(--ink-faint);
  opacity: 0.7;
}

.pt-holding__gain-bar {
  height: 4px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}

.pt-holding__gain-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.pt-holding__gain-fill--up { background: var(--tw); }
.pt-holding__gain-fill--down { background: #c07070; }

.pt-holding__actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.pt-holding__btn {
  appearance: none;
  padding: 4px 10px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface-hover);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.pt-holding__btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.pt-holding__btn--danger:hover {
  color: #c07070;
  border-color: #c07070;
}

/* ── Add holding card ── */
.pt-add-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--ink-faint);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.pt-add-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── Add form (modal overlay) ── */
.pt-form-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.pt-form-overlay[hidden] { display: none !important; }

.pt-form-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--ink) 40%, transparent);
  backdrop-filter: blur(4px);
}

.pt-form-panel {
  position: relative;
  width: min(480px, 100%);
  padding: 28px 24px 24px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 16px 48px color-mix(in srgb, var(--ink) 20%, transparent);
  animation: pt-form-in 0.22s ease-out;
}

@keyframes pt-form-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.pt-form-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--surface-hover);
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.pt-form-close:hover {
  color: var(--ink);
  background: var(--accent-dim);
}

.pt-form-title {
  margin: 0 0 18px;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.pt-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.pt-form-grid--full {
  grid-column: 1 / -1;
}

.pt-form-label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

.pt-form-input,
.pt-form-select,
.pt-form-textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pt-form-textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.45;
}

.pt-form-input:focus,
.pt-form-select:focus,
.pt-form-textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.pt-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.pt-form-status {
  margin-top: 10px;
  font-size: 13px;
}

.pt-form-status--err {
  color: #c07070;
}

/* ── Login gate ── */
.pt-gate {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-radius: 12px;
  background: var(--accent-dim);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  font-size: 14px;
  color: var(--ink-soft);
}

.pt-gate a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.pt-gate a:hover {
  text-decoration: underline;
}

.pt-gate[hidden] { display: none !important; }

/* ── Empty state ── */
.pt-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-faint);
  font-size: 15px;
}

.pt-empty-state__icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.pt-empty-state__lead {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-soft);
}

.pt-empty-state__hint {
  margin: 0;
  font-size: 13px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .pt-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pt-kpi-row .pt-kpi:nth-child(5) {
    grid-column: 1 / -1;
  }
  .pt-chart-card,
  .pt-holdings-card,
  .pt-alloc-card {
    grid-column: 1 / -1;
  }
  .pt-alloc-card {
    min-height: 0;
  }
  .pt-timeline-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .pt-return-badge {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    text-align: left;
  }
  .pt-holdings-grid {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 640px) {
  .main--portfolio {
    padding-bottom: max(40px, env(safe-area-inset-bottom));
  }

  .pt-live {
    width: min(100% - 16px, 1140px);
    padding-top: 8px;
  }

  .pt-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 0 0 12px;
  }

  .pt-header__title {
    font-size: 22px;
  }

  .pt-header__lead {
    font-size: 12px;
    line-height: 1.45;
  }

  .pt-header__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .pt-header__actions .btn-secondary {
    width: 100%;
    justify-content: center;
    text-align: center;
    padding: 10px 12px;
    font-size: 13px;
  }

  .pt-gate {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.45;
  }

  .pt-bento {
    gap: 8px;
  }

  .pt-card {
    padding: 14px;
    border-radius: 12px;
  }

  /* KPI: compact 2×2 + full-width water */
  .pt-kpi-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .pt-kpi__label {
    font-size: 9px;
    margin-bottom: 4px;
  }

  .pt-kpi__value {
    font-size: 17px;
  }

  .pt-kpi__sub {
    font-size: 11px;
    margin-top: 4px;
    line-height: 1.3;
  }

  .pt-kpi--water {
    grid-column: 1 / -1;
  }

  /* Timeline: swipe row */
  .pt-timeline-label {
    margin-bottom: 6px;
  }

  .pt-timeline {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 2px;
    margin: 0 -2px;
    padding-left: 2px;
    padding-right: 2px;
  }

  .pt-timeline::-webkit-scrollbar {
    display: none;
  }

  .pt-timeline__chip {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 12px;
  }

  .pt-return-badge {
    padding: 0;
  }

  .pt-return-badge__value .pt-change-pill {
    font-size: 13px;
  }

  /* Chart controls */
  .pt-chart-head {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 10px;
  }

  .pt-chart-head__left {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .pt-chart-title {
    font-size: 12px;
  }

  .pt-range-tabs,
  .pt-chart-modes {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }

  .pt-range-tabs::-webkit-scrollbar,
  .pt-chart-modes::-webkit-scrollbar {
    display: none;
  }

  .pt-range-tab,
  .pt-chart-mode {
    flex: 0 0 auto;
    padding: 6px 10px;
  }

  .pt-chart-container {
    height: 200px;
  }

  .pt-chart-container.is-accounts {
    height: 260px;
  }

  .pt-chart-legend {
    gap: 6px;
    margin-bottom: 8px;
  }

  .pt-chart-legend__chip {
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Alloc: donut + legend side-by-side (no tall empty stack) */
  .pt-alloc-title {
    margin-bottom: 4px;
  }

  .pt-alloc-note {
    display: none;
  }

  .pt-donut-wrap {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .pt-donut {
    width: 88px;
    height: 88px;
    flex-shrink: 0;
  }

  .pt-donut__center {
    inset: 16px;
  }

  .pt-donut__count {
    font-size: 15px;
  }

  .pt-donut__label {
    font-size: 8px;
  }

  .pt-alloc-legend {
    gap: 0;
  }

  .pt-alloc-legend li {
    padding: 5px 4px;
    margin: 0;
    font-size: 12px;
    min-height: 32px;
    gap: 6px;
  }

  .pt-alloc-pct {
    font-size: 12px;
  }

  /* Holdings */
  .pt-holdings-head {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 8px;
  }

  .pt-holdings-note {
    display: none;
  }

  .pt-market-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
    box-sizing: border-box;
  }

  .pt-market-tabs::-webkit-scrollbar {
    display: none;
  }

  .pt-market-tab {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 12px;
  }

  .pt-holdings-tab-meta {
    font-size: 12px;
    margin-bottom: 8px;
  }

  .pt-holdings-grid {
    gap: 8px;
    grid-template-columns: 1fr;
    max-height: none;
    overflow: visible;
  }

  .pt-holding {
    padding: 12px;
  }

  .pt-holding__symbol {
    font-size: 14px;
  }

  .pt-holding__value {
    font-size: 15px;
  }

  .pt-holding__actions {
    margin-top: 8px;
    gap: 8px;
  }

  .pt-holding__btn {
    min-height: 36px;
    padding: 6px 12px;
  }

  .pt-add-card {
    min-height: 48px;
    font-size: 14px;
  }

  /* Forms: near full-bleed */
  .pt-form-panel {
    width: min(100vw - 16px, 480px);
    max-height: min(92vh, 720px);
    padding: 18px 16px 16px;
    border-radius: 14px;
  }

  .pt-form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .pt-form-actions {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .pt-form-actions .btn-primary,
  .pt-form-actions .btn-secondary {
    width: 100%;
    justify-content: center;
  }
}
