/* ─── Portfolio Success Lab Design System ─────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;

  /* Core palette */
  --bg-deep:       #0b0e14;
  --bg-base:       #0f1219;
  --bg-elevated:   #161a24;
  --bg-surface:    #1c2030;
  --bg-glass:      rgba(22, 26, 36, 0.72);
  --bg-glass-2:    rgba(28, 32, 48, 0.55);

  /* Text */
  --text-primary:   #e8ecf4;
  --text-secondary: #8892a8;
  --text-muted:     #5c6478;
  --text-accent:    #6dd4c8;

  /* Accents */
  --teal:         #34d1b6;
  --teal-dim:     #1a8a76;
  --teal-glow:    rgba(52, 209, 182, 0.18);
  --cyan:         #56c8e8;
  --blue:         #5b8def;
  --indigo:       #7c6cf0;
  --coral:        #f06060;
  --coral-dim:    #c04848;
  --amber:        #f0a848;
  --emerald:      #3ccf8e;

  /* Borders */
  --border:       rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.10);
  --border-focus: rgba(52, 209, 182, 0.45);

  /* Shadows */
  --shadow-sm:    0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md:    0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg:    0 16px 48px rgba(0, 0, 0, 0.45);
  --shadow-glow:  0 0 24px rgba(52, 209, 182, 0.08);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* ─── Reset ──────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text-primary);
  background: var(--bg-deep);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 20% 10%, rgba(52, 209, 182, 0.04) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(91, 141, 239, 0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

h1, h2, p {
  margin: 0;
}

/* ─── Typography ─────────────────────────────────────────────────── */

h1 {
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--teal) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

.eyebrow {
  margin-bottom: 0.15rem;
  color: var(--teal);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ─── Buttons ────────────────────────────────────────────────────── */

button {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.82rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover {
  border-color: var(--border-focus);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-glow);
}

.primary-button {
  border: 1px solid var(--teal);
  color: var(--bg-deep);
  background: linear-gradient(135deg, var(--teal) 0%, var(--emerald) 100%);
  font-weight: 750;
  box-shadow: 0 4px 16px rgba(52, 209, 182, 0.25);
}

.primary-button:hover {
  background: linear-gradient(135deg, #2ec4a6 0%, #33b87a 100%);
  box-shadow: 0 6px 24px rgba(52, 209, 182, 0.35);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(0);
}

.ghost-button {
  padding: 0.35rem 0.55rem;
  background: transparent;
  border-color: transparent;
  color: var(--teal);
}

.ghost-button:hover {
  background: var(--teal-glow);
  border-color: var(--teal-dim);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.82rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  text-decoration: none;
  transition: all 0.2s ease;
}

.button-link:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-glow);
}

/* ─── Shared Control Rows ────────────────────────────────────────── */

.button-row,
.inline-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* ─── Panels (Glassmorphism) ─────────────────────────────────────── */

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: var(--shadow-md);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.panel:hover {
  border-color: var(--border-light);
}

.panel.wide {
  overflow-x: auto;
  overflow-y: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.panel-heading.compact {
  border-top: 1px solid var(--border);
}

.panel > label,
.panel > .control-grid,
.panel > .button-row,
.panel > textarea,
.panel > details,
.data-note,
.assumption-note,
.strategy-summary,
.one-off-list,
.asset-table,
.table-wrap {
  margin: 0.85rem 1rem;
}

/* ─── Setup Groups ───────────────────────────────────────────────── */

.setup-group {
  margin: 0 1rem;
  padding: 0.75rem 0 0.5rem;
  border-top: 1px solid var(--border);
}

.setup-group:first-child {
  border-top: none;
  padding-top: 0.5rem;
}

.setup-group > label,
.setup-group > .control-grid,
.setup-group > .button-row,
.setup-group > details {
  margin-top: 0.55rem;
}

.setup-group-label {
  margin: 0 0 0.3rem;
  color: var(--text-accent);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Forms ──────────────────────────────────────────────────────── */

label {
  display: grid;
  gap: 0.3rem;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
}

label small,
.data-note,
.assumption-note,
.table-note {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem;
  color: var(--text-primary);
  background: var(--bg-base);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(52, 209, 182, 0.12);
}

textarea {
  min-height: 140px;
  resize: vertical;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}

.segmented {
  grid-template-columns: auto minmax(150px, 1fr);
  align-items: center;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.72rem;
}

.span-full {
  grid-column: 1 / -1;
}

.span-full:empty {
  display: none;
}

.check-row,
.file-control {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
}

.check-row input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--teal);
}

.file-control input {
  min-width: 0;
}

/* ─── Advanced Details ───────────────────────────────────────────── */

.advanced {
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}

.advanced summary {
  color: var(--teal);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  transition: color 0.2s;
}

.advanced summary:hover {
  color: var(--cyan);
}

.advanced .control-grid {
  margin-top: 0.75rem;
}

/* ─── Strategy Summary ───────────────────────────────────────────── */

.strategy-summary {
  border: 1px solid rgba(52, 209, 182, 0.15);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  color: var(--text-accent);
  background: rgba(52, 209, 182, 0.05);
  font-size: 0.78rem;
  font-weight: 600;
}

.assumption-note {
  margin: 0;
  border-left: 3px solid rgba(52, 209, 182, 0.34);
  padding: 0.05rem 0 0.05rem 0.65rem;
}

.audit-list {
  display: grid;
  gap: 0.65rem;
  margin: 0;
}

.audit-list > div {
  display: grid;
  grid-template-columns: minmax(120px, 0.28fr) 1fr;
  gap: 0.8rem;
  align-items: start;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.65rem;
}

.audit-list > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.audit-list dt {
  color: var(--text-accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.audit-list dd {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.76rem;
  line-height: 1.45;
}

/* ─── Status Bar ─────────────────────────────────────────────────── */

.status {
  min-height: 2rem;
  border: 1px solid rgba(52, 209, 182, 0.2);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.85rem;
  color: var(--teal);
  background: rgba(52, 209, 182, 0.06);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.import-status {
  margin: 0.85rem 0.95rem;
}

/* ─── KPI Cards ──────────────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 0.75rem;
}

.kpi {
  position: relative;
  min-height: 88px;
  border-radius: var(--radius-md);
  padding: 0.85rem;
  background: var(--bg-elevated);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
}

.kpi::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  padding: 1px;
  background: linear-gradient(135deg, rgba(52, 209, 182, 0.3), rgba(91, 141, 239, 0.15), rgba(124, 108, 240, 0.1));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow), var(--shadow-md);
}

.kpi span {
  display: block;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi strong {
  display: block;
  margin-top: 0.35rem;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(1rem, 2vw, 1.4rem);
  font-weight: 700;
  line-height: 1.1;
}

/* ─── Charts & Sankey ────────────────────────────────────────────── */

.visual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.results-grid {
  display: grid;
  grid-template-columns: minmax(580px, 1.35fr) minmax(420px, 0.9fr);
  gap: 1rem;
  align-items: start;
}

.sankey,
.chart {
  display: block;
  width: 100%;
  min-height: 380px;
}

.sankey {
  width: max(100%, 980px);
  min-height: 560px;
}

.chart {
  min-height: 320px;
}

/* ─── Action Panel ───────────────────────────────────────────────── */

.action-panel {
  border-color: rgba(52, 209, 182, 0.12);
  background: linear-gradient(180deg, rgba(52, 209, 182, 0.04) 0%, var(--bg-glass) 100%);
}

.action-panel .panel-heading {
  background: rgba(52, 209, 182, 0.03);
}

/* ─── Sankey Styles (Ribbon-based) ────────────────────────────────── */

.sankey-bg {
  fill: #0c1018;
  rx: 14;
}

.flow-ribbon {
  opacity: 0.65;
  transition: opacity 0.25s ease;
}

.flow-ribbon:hover {
  opacity: 1;
}

.flow-node {
  transition: filter 0.2s ease;
}

.flow-node:hover {
  filter: brightness(1.3) drop-shadow(0 0 6px rgba(255,255,255,0.15));
}

.flow-node-name {
  font-family: 'Inter', sans-serif;
  pointer-events: none;
}

.flow-node-value {
  pointer-events: none;
}

.axis-label,
.chart-label {
  fill: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
}

.text-halo {
  fill: none;
  stroke: var(--bg-base);
  stroke-linejoin: round;
  stroke-width: 5px;
}

/* ─── Tables ─────────────────────────────────────────────────────── */

.asset-table,
.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
}

.sticky-x-scroll {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: none;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 2px;
  margin-top: 0.2rem;
  border-top: 1px solid var(--border);
  background: var(--bg-base);
}

.sticky-x-scroll.is-needed {
  display: flex;
}

.sticky-x-scroll.is-fixed {
  position: fixed;
  bottom: 0;
  z-index: 10;
  margin-top: 0;
  border: 1px solid var(--border-light);
  border-bottom: 0;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
}

.sticky-x-scroll-track {
  flex: 1 1 auto;
  height: 100%;
  overflow-x: scroll;
  overflow-y: hidden;
  scrollbar-color: var(--text-secondary) var(--bg-elevated);
}

/* Keep the horizontal scrollbar painted — macOS hides overlay scrollbars. */
.sticky-x-scroll-track::-webkit-scrollbar {
  height: 12px;
}
.sticky-x-scroll-track::-webkit-scrollbar-track {
  background: var(--bg-elevated);
  border-radius: 6px;
}
.sticky-x-scroll-track::-webkit-scrollbar-thumb {
  background: var(--text-secondary);
  border-radius: 6px;
  border: 2px solid var(--bg-elevated);
}
.sticky-x-scroll-track::-webkit-scrollbar-thumb:hover {
  background: var(--text-primary);
}

.sticky-x-scroll-spacer {
  height: 1px;
}

.table-scroll-arrow {
  flex: 0 0 auto;
  width: 24px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  cursor: pointer;
}
.table-scroll-arrow:hover:not(:disabled) {
  background: var(--border-light);
}
.table-scroll-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  font-family: 'JetBrains Mono', monospace;
}

th,
td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--text-muted);
  background: var(--bg-elevated);
  font-family: 'Inter', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

tbody tr:hover {
  background: rgba(52, 209, 182, 0.04);
}

.action-confidence {
  display: inline-flex;
  width: max-content;
  max-width: 260px;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--border-light);
  border-radius: 7px;
  padding: 0.13rem 0.34rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.25;
  white-space: normal;
}
.action-confidence strong {
  color: var(--text-primary);
  font-size: 0.66rem;
  text-transform: uppercase;
}
.action-confidence span {
  color: var(--text-muted);
  font-weight: 600;
}
.action-confidence[data-level="cpa-review-recommended"] {
  border-color: rgba(240, 168, 72, 0.48);
}
.action-confidence[data-level="assumption-sensitive"] {
  border-color: rgba(91, 141, 239, 0.48);
}
.action-confidence[data-level="input-limited"] {
  border-color: rgba(52, 209, 182, 0.42);
}
.action-confidence[data-level="out-of-model"] {
  border-color: rgba(240, 96, 96, 0.5);
}

.asset-table input,
.asset-table select {
  min-width: 88px;
  padding: 0.38rem 0.45rem;
  font-size: 0.78rem;
}

.asset-table select[data-field="accountType"] {
  min-width: 120px;
}

.asset-table select[data-field="assetClass"] {
  min-width: 105px;
}

.asset-table input[data-field="name"] {
  min-width: 180px;
}

.asset-table button,
.one-off-list button {
  padding: 0.32rem 0.45rem;
  font-size: 0.75rem;
}

/* ─── One-Off Items ──────────────────────────────────────────────── */

.one-off-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.one-off-item strong {
  display: block;
  color: var(--text-primary);
}

.one-off-item span {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

/* ─── Asset & State Badges ───────────────────────────────────────── */

.asset-total,
.empty-state {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.positive {
  color: var(--emerald);
  font-weight: 700;
}

.negative {
  color: var(--coral);
  font-weight: 700;
}

.selected-row {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
  background: rgba(52, 209, 182, 0.06) !important;
}

.disabled-row {
  cursor: wait;
  opacity: 0.62;
}

tr[data-year-index],
tr[data-backtest-index],
tr[data-scenario] {
  cursor: pointer;
}

/* ─── Pinnable Table Container ───────────────────────────────────── */

.pinnable-table-wrap {
  max-height: 80vh;
  overflow: auto;
  resize: vertical;
  position: relative;
}

.pinnable-table-wrap::after {
  content: '⋮⋮';
  position: sticky;
  bottom: 0;
  left: 50%;
  display: block;
  width: 40px;
  margin: 0 auto;
  padding: 0 0 2px;
  color: var(--text-muted);
  font-size: 10px;
  text-align: center;
  letter-spacing: 2px;
  pointer-events: none;
  opacity: 0.5;
}

/* Pinned column cells */
.pinned-col {
  position: sticky !important;
  z-index: 2 !important;
  background: var(--bg-elevated) !important;
}

/* Pinned header cells need higher z-index (sticky in both X and Y) */
th.pinned-col {
  z-index: 4 !important;
}

/* Shadow separator on the last pinned column */
.pinned-col-last::after {
  content: '';
  position: absolute;
  top: 0;
  right: -6px;
  bottom: 0;
  width: 6px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.15), transparent);
  pointer-events: none;
}

/* Even row backgrounds for pinned cells */
tbody tr:nth-child(even) .pinned-col {
  background: color-mix(in srgb, var(--bg-elevated) 94%, white 6%) !important;
}

/* Hover background for pinned cells */
tbody tr:hover .pinned-col {
  background: color-mix(in srgb, var(--bg-elevated) 88%, var(--teal) 12%) !important;
}

/* Selected row pinned cells */
.selected-row .pinned-col {
  background: color-mix(in srgb, var(--bg-elevated) 90%, var(--teal) 10%) !important;
}

/* ─── Pin Toggle Button ──────────────────────────────────────────── */

.pin-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
  vertical-align: middle;
  flex-shrink: 0;
}

th:hover .pin-toggle {
  opacity: 0.7;
}

.pin-toggle:hover {
  opacity: 1 !important;
  color: var(--teal);
  background: var(--teal-glow);
  box-shadow: none;
  transform: none;
}

.pin-toggle.is-pinned {
  opacity: 0.85;
  color: var(--teal);
}

.pin-toggle.is-locked {
  opacity: 0.5;
  color: var(--text-muted);
  cursor: default;
}

.pin-toggle.is-locked:hover {
  background: transparent;
  color: var(--text-muted);
}

th .pin-toggle {
  position: relative;
  top: 0;
}

/* ─── Sortable column headers ────────────────────────────────────── */

th.is-sortable {
  cursor: pointer;
  user-select: none;
}

th.is-sortable:hover {
  color: var(--teal);
}

.sort-indicator {
  display: inline-block;
  margin-left: 4px;
  font-size: 9px;
  line-height: 1;
  color: var(--text-muted);
  opacity: 0.35;
  vertical-align: middle;
  transition: opacity 0.15s ease, color 0.15s ease;
}

th.is-sortable:hover .sort-indicator {
  opacity: 0.8;
}

.sort-indicator.is-active {
  color: var(--teal);
  opacity: 1;
}

/* ─── Scrollbar Styling ──────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-surface);
  border-radius: 4px;
  border: 2px solid var(--bg-base);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Chart Tooltips ─────────────────────────────────────────────── */

.chart-tooltip {
  position: absolute;
  z-index: 20;
  min-width: 160px;
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: rgba(15, 18, 25, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.5;
}

.chart-tt-year {
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.chart-tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.chart-tt-row strong {
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

.chart-tt-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chart-tt-muted {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
}

.dist-bar {
  transition: opacity 0.15s ease;
}

/* ─── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .visual-grid,
  .results-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .audit-list > div {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .chart {
    min-height: 280px;
  }

  .sankey {
    width: max(100%, 1100px);
    min-height: 500px;
  }
}

/* The editable holdings table has 10 columns and is ~1184px wide, so on a
   phone it forces horizontal scrolling to reach Price/Basis/Yield. Reflow each
   holding row into a stacked card where every field is full-width and labeled
   from the td's data-label (emitted by renderAssetTable in app.mjs). Mirrors
   the read-only action-plan reflow in redesign.css. */
@media (max-width: 640px) {
  .asset-table { overflow-x: visible; }
  .asset-table table,
  .asset-table thead,
  .asset-table tbody,
  .asset-table tr,
  .asset-table td { display: block; width: auto; }
  .asset-table thead { position: absolute; left: -9999px; }
  .asset-table tbody { display: flex; flex-direction: column; gap: 0.6rem; }
  .asset-table tr {
    border: 1px solid var(--border-light, var(--border));
    border-radius: 10px;
    padding: 0.55rem 0.7rem 0.65rem;
  }
  .asset-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0;
    border: 0;
  }
  /* Render the column name as an inline label before each field. */
  .asset-table td::before {
    content: attr(data-label);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary, var(--text-muted));
  }
  /* Cells with no label (the Remove button) span full width. */
  .asset-table td[data-label=""] { grid-template-columns: 1fr; }
  .asset-table td[data-label=""]::before { content: none; }
  /* [data-field] raises specificity to (0,2,2) so this beats the wide
     per-field min-widths set elsewhere (e.g. input[data-field="name"] at
     min-width:180px, specificity (0,2,1)) — otherwise the name field alone
     pushes the card past the viewport. */
  .asset-table td input[data-field],
  .asset-table td select[data-field] {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .asset-table td[data-label=""] button { width: 100%; }
}

/* ─── Animations ─────────────────────────────────────────────────── */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.panel {
  animation: fadeInUp 0.4s ease both;
}

.kpi {
  animation: fadeInUp 0.35s ease both;
}

.kpi:nth-child(2) { animation-delay: 0.05s; }
.kpi:nth-child(3) { animation-delay: 0.1s; }
.kpi:nth-child(4) { animation-delay: 0.15s; }
.kpi:nth-child(5) { animation-delay: 0.2s; }
