/* Workspace palettes, Customization Studio modes, and Portfolio Insights architectural layer. */

:root {
  --sidebar-active: #294fb9;
  --sidebar-active-border: #5478d9;
  --sidebar-control: #1b3a53;
  --sidebar-hover: #23445e;
  --sidebar-edge: #456277;
  --sidebar-accent: #d4e0ff;
  --color-on-accent: var(--color-canvas);
  --color-on-action: var(--color-canvas);
}

:root[data-theme="light"] {
  --color-on-accent: #ffffff;
  --color-on-action: #ffffff;
  --color-cyan: #256781;
  --alloc-color-0: #1b7f5a;
  --alloc-color-1: #23699e;
  --alloc-color-2: #68469e;
  --alloc-color-3: #9e6412;
  --alloc-color-4: #4f6460;
}

:root[data-theme="slate"] {
  color-scheme: dark;
  --color-canvas: #121920; --color-sidebar: #172c40; --color-header: #17212c;
  --color-surface: #1c2631; --color-surface-raised: #24313e; --color-surface-hover: #2c3a49; --color-surface-active: #344658;
  --color-border: #46586a; --color-border-subtle: #334454; --color-border-hover: #8094a7;
  --color-text-primary: #eef4fa; --color-text-secondary: #c4d0db; --color-text-muted: #adbccc; --color-text-dim: #a5b5c6;
  --color-accent: #a8c9ff; --color-accent-subtle: #2c4160; --color-on-accent: #121920; --color-on-action: #121920;
  --sidebar-active: #304b70; --sidebar-active-border: #7d9dc9;
  --sidebar-control: #24313e; --sidebar-hover: #2c3a49; --sidebar-edge: #46586a; --sidebar-accent: #a8c9ff;
}

:root[data-theme="forest"] {
  color-scheme: dark;
  --color-canvas: #101a17; --color-sidebar: #183228; --color-header: #15231d;
  --color-surface: #1a2924; --color-surface-raised: #22362d; --color-surface-hover: #2b4236; --color-surface-active: #365141;
  --color-border: #435e4f; --color-border-subtle: #304b3c; --color-border-hover: #82a38c;
  --color-text-primary: #eff5f0; --color-text-secondary: #c0d2c5; --color-text-muted: #a5bcb0; --color-text-dim: #a7bbb0;
  --color-accent: #b5d8ba; --color-accent-subtle: #2a4635; --color-on-accent: #101a17; --color-on-action: #101a17;
  --sidebar-active: #365f49; --sidebar-active-border: #7da98c;
  --sidebar-control: #22362d; --sidebar-hover: #2b4236; --sidebar-edge: #435e4f; --sidebar-accent: #b5d8ba;
}

:root[data-theme="meridian"] {
  color-scheme: dark;
  --color-canvas: #101720; --color-sidebar: #17283f; --color-header: #172231;
  --color-surface: #1b2635; --color-surface-raised: #253247; --color-surface-hover: #2e3e54; --color-surface-active: #394c64;
  --color-border: #465972; --color-border-subtle: #33465e; --color-border-hover: #8298b0;
  --color-text-primary: #eff2f8; --color-text-secondary: #c1ccdb; --color-text-muted: #acb9cc; --color-text-dim: #a7b7cc;
  --color-accent: #e6c687; --color-accent-subtle: #4b3d27; --color-on-accent: #101720; --color-on-action: #101720;
  --sidebar-active: #4b402d; --sidebar-active-border: #a28d61;
  --sidebar-control: #253247; --sidebar-hover: #2e3e54; --sidebar-edge: #465972; --sidebar-accent: #e6c687;
}

:root[data-theme="bordeaux"] {
  color-scheme: dark;
  --color-canvas: #1b171b; --color-sidebar: #30212a; --color-header: #231d23;
  --color-surface: #2a2329; --color-surface-raised: #372b34; --color-surface-hover: #44323e; --color-surface-active: #503d49;
  --color-border: #604c58; --color-border-subtle: #44343f; --color-border-hover: #a88b9b;
  --color-text-primary: #f7eef3; --color-text-secondary: #dcc4d0; --color-text-muted: #c1aeb9; --color-text-dim: #bfacb7;
  --color-accent: #e6b6c8; --color-accent-subtle: #503544; --color-on-accent: #1b171b; --color-on-action: #1b171b;
  --sidebar-active: #603d50; --sidebar-active-border: #a57388;
  --sidebar-control: #372b34; --sidebar-hover: #44323e; --sidebar-edge: #604c58; --sidebar-accent: #e6b6c8;
}

:root[data-theme="porcelain"] {
  color-scheme: light;
  --color-canvas: #edf2f6; --color-sidebar: #203950; --color-header: #fbfdff;
  --color-surface: #ffffff; --color-surface-raised: #f4f7fa; --color-surface-hover: #e7edf3; --color-surface-active: #dce6f0;
  --color-border: #b8c7d3; --color-border-subtle: #d6e0e8; --color-border-hover: #678299;
  --color-text-primary: #1e2d3c; --color-text-secondary: #40556a; --color-text-muted: #52677b; --color-text-dim: #536a7d;
  --color-accent: #25508e; --color-accent-subtle: #e5edf9; --color-on-accent: #ffffff; --color-on-action: #ffffff;
  --color-positive: #196142; --color-positive-subtle: #e3efe8; --color-on-positive: #ffffff;
  --color-negative: #a82e46; --color-negative-subtle: #f9e7eb; --color-on-negative: #ffffff;
  --color-warning: #745200; --color-warning-subtle: #f6eddb;
  --color-cyan: #246482; --color-cyan-subtle: #e3eef5;
  --sidebar-active: #365a7a; --sidebar-active-border: #89a6c1;
  --sidebar-control: #2c485f; --sidebar-hover: #365a7a; --sidebar-edge: #678299; --sidebar-accent: #eef4fa;
  --alloc-color-0: #1b7f5a; --alloc-color-1: #23699e; --alloc-color-2: #68469e; --alloc-color-3: #9e6412; --alloc-color-4: #4f6460;
  --shadow-bevel: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --shadow-card: 0 1px 2px rgba(24, 38, 52, 0.05), 0 2px 6px rgba(24, 38, 52, 0.03);
  --shadow-card-hover: 0 6px 16px rgba(24, 38, 52, 0.09);
  --shadow-elevated: 0 10px 28px rgba(24, 38, 52, 0.12);
  --shadow-floating: 0 18px 46px rgba(24, 38, 52, 0.18);
  --shadow-button-tactile: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(24, 38, 52, 0.06);
}

:root[data-theme="rosso"] {
  color-scheme: dark;
  --color-canvas: #100f11; --color-sidebar: #181113; --color-header: #151316;
  --color-surface: #1b181b; --color-surface-raised: #241f24; --color-surface-hover: #2e272e; --color-surface-active: #393038;
  --color-border: #524249; --color-border-subtle: #382c31; --color-border-hover: #967882;
  --color-text-primary: #f7f1e6; --color-text-secondary: #dcd0c4; --color-text-muted: #c2b4a8; --color-text-dim: #b4a599;
  --color-accent: #f26d6d; --color-accent-subtle: #3b1619; --color-on-accent: #140b0c; --color-on-action: #140b0c;
  --color-positive: #74d4b0; --color-positive-subtle: #18362c; --color-on-positive: #100f11;
  --color-negative: #ff8e96; --color-negative-subtle: #441c22; --color-on-negative: #100f11;
  --color-warning: #ecc272; --color-warning-subtle: #3b3019;
  --color-cyan: #8fc4e0; --color-cyan-subtle: #1e313d;
  --sidebar-active: #dc2626; --sidebar-active-border: #f87171;
  --sidebar-control: #291c1f; --sidebar-hover: #362226; --sidebar-edge: #573b42; --sidebar-accent: #fff9f5;
}

:root[data-theme="rosso"] .btn-quick-add,
:root[data-theme="rosso"] #view_terminal .btn-submit-order:not(.buy-mode):not(.sell-mode),
:root[data-theme="rosso"] .btn-submit-order:not(.sell):not(.buy-mode):not(.sell-mode) {
  background: #dc2626;
  color: #fff9f5;
  border-color: #ef4444;
}
:root[data-theme="rosso"] .btn-quick-add:hover:not(:disabled),
:root[data-theme="rosso"] #view_terminal .btn-submit-order:not(.buy-mode):not(.sell-mode):hover:not(:disabled),
:root[data-theme="rosso"] .btn-submit-order:not(.sell):not(.buy-mode):not(.sell-mode):hover:not(:disabled) {
  background: #b91c1c;
  color: #fff9f5;
  border-color: #f87171;
}
:root[data-theme="rosso"] #view_terminal .kpi-card:first-child {
  border-top: 2px solid #dc2626;
  color: #f7f1e6;
}
:root[data-theme="rosso"] #view_terminal .kpi-card:first-child .kpi-label,
:root[data-theme="rosso"] #view_terminal .kpi-card:first-child .kpi-subtext {
  color: #dcd0c4;
}
:root[data-theme="rosso"] #view_terminal .kpi-card:first-child .kpi-value {
  color: #fff9f5;
}
:root[data-theme="rosso"] .dashboard-widgets > .panel:last-child {
  --color-text-primary: #f7f1e6;
  --color-text-secondary: #dcd0c4;
  --color-text-muted: #c2b4a8;
  --color-border-subtle: #4c353b;
  --color-border-hover: #967882;
  --color-positive: #74d4b0;
  --color-negative: #ff8e96;
  color: #f7f1e6;
  border-color: #4c353b;
}

/* ── Studio Shape, Canvas Surface & Typography Overrides ── */
:root[data-shape="sharp"] {
  --radius-xs: 1px;
  --radius-sm: 2px;
  --radius-md: 2px;
  --radius-lg: 3px;
  --radius-xl: 4px;
  --badge-radius: 1px;
}

:root[data-shape="editorial"] {
  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --badge-radius: 4px;
}

:root[data-shape="soft"] {
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --badge-radius: var(--radius-full);
}

:root[data-surface="clean"] {
  --canvas-texture: none;
  --canvas-texture-size: auto;
}

:root[data-surface="grid"] {
  --canvas-texture:
    linear-gradient(to right, color-mix(in srgb, var(--color-border-subtle) 36%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--color-border-subtle) 36%, transparent) 1px, transparent 1px);
  --canvas-texture-size: 24px 24px;
}

:root[data-surface="dots"] {
  --canvas-texture: radial-gradient(circle, color-mix(in srgb, var(--color-border-hover) 32%, transparent) 1px, transparent 1px);
  --canvas-texture-size: 18px 18px;
}

:root[data-surface="depth"] {
  --canvas-texture:
    radial-gradient(1100px 520px at 14% -8%, color-mix(in srgb, var(--color-accent-subtle) 34%, transparent), transparent 68%),
    radial-gradient(900px 480px at 92% 108%, color-mix(in srgb, var(--color-surface-raised) 52%, transparent), transparent 72%);
  --canvas-texture-size: 100% 100%;
}

:root[data-font="technical"] {
  --font-heading-resolved: var(--font-display);
  --font-body-resolved: var(--font-sans);
}

:root[data-font="editorial"] {
  --font-heading-resolved: 'Newsreader', 'Instrument Serif', Georgia, serif;
  --font-body-resolved: var(--font-sans);
}
:root[data-font="editorial"] .view-title-group h1,
:root[data-font="editorial"] .insights-section-heading h2,
:root[data-font="editorial"] .modal-title {
  font-family: var(--font-heading-resolved);
  letter-spacing: -.02em;
}

:root[data-font="mono"] {
  --font-heading-resolved: var(--font-mono);
  --font-body-resolved: var(--font-mono);
}
:root[data-font="mono"] body,
:root[data-font="mono"] .view-title-group h1,
:root[data-font="mono"] .insights-section-heading h2,
:root[data-font="mono"] .panel-title,
:root[data-font="mono"] .nav-item {
  font-family: var(--font-body-resolved);
}
:root[data-font="mono"] .view-title-group h1 {
  font-family: var(--font-heading-resolved);
  letter-spacing: -.03em;
}

/* ── Dark Sidebar & Studio Controls ── */
.app-sidebar { background: var(--color-sidebar); color: var(--color-text-primary); color-scheme: dark; --color-surface: var(--color-sidebar); --color-text-primary: #f3f7fa; --color-text-secondary: #d6e1e9; --color-text-muted: #b7cad8; --color-text-dim: #a6bdce; --color-accent-subtle: var(--sidebar-active); --color-surface-raised: var(--sidebar-control); --color-surface-hover: var(--sidebar-hover); --color-border: var(--sidebar-edge); --color-accent: var(--sidebar-accent); }
.app-sidebar .studio-appearance summary,
.app-sidebar .studio-preferences label,
.app-sidebar .studio-motion { color: var(--color-text-primary); }
.app-sidebar .studio-appearance summary span,
.app-sidebar .studio-note { color: var(--color-text-muted); }
.studio-preferences select option { background: var(--color-sidebar); color: #f3f7fa; }
.nav-item.active { background: var(--sidebar-active); border-color: var(--sidebar-active-border); color: var(--sidebar-accent); }
#view_terminal .kpi-card:first-child { background: var(--color-sidebar); }
.dashboard-widgets > .panel:last-child { --color-surface: var(--color-sidebar); background: var(--color-sidebar); }
.btn-submit-order, #view_terminal .btn-submit-order { color: var(--color-on-action); }
.btn-submit-order.buy-mode, #view_terminal .btn-submit-order.buy-mode { background: var(--color-positive); color: var(--color-on-positive, var(--color-on-action)); }
.btn-submit-order:hover { filter: brightness(0.95); border-color: var(--color-accent); }
.btn-submit-order.sell-mode, #view_terminal .btn-submit-order.sell-mode { background: var(--color-negative); color: var(--color-on-negative, var(--color-on-action)); }

.studio-appearance { margin: 18px 4px 12px; padding-top: 14px; border-top: 1px solid var(--color-border); }
.studio-appearance summary { cursor: pointer; font-size: 12px; min-height: 40px; padding: 8px; border-radius: var(--radius-sm); }
.studio-appearance summary span { display: block; color: var(--color-text-muted); font-size: 11px; margin-top: 4px; }
.studio-appearance summary:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.theme-controls { display: grid; grid-template-columns: 1fr 1fr; margin: 8px 0; padding: 0; border: 0; gap: 6px; }
.theme-controls button { min-height: 36px; font-size: 11.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-option-btn[aria-pressed="true"] { border-color: var(--color-accent); }
.studio-note { color: var(--color-text-muted); padding: 0 8px 12px; font-size: 11px; }
.studio-preferences { display: grid; gap: 8px; padding: 10px 6px; font-size: 12px; }
.studio-preferences select { width: 100%; min-height: 38px; background: var(--color-surface-raised); color: var(--color-text-primary); }
.studio-segmented { display: flex; flex-wrap: wrap; gap: 4px; }
.studio-chip-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.studio-segmented button,
.studio-chip-grid button { flex: 1 1 auto; min-height: 32px; padding: 4px 6px; font-size: 10.5px; min-width: 0; white-space: nowrap; background: var(--color-surface-raised); color: var(--color-text-secondary); border: 1px solid var(--color-border); border-radius: var(--radius-xs); }
.studio-segmented button.active,
.studio-segmented button[aria-pressed="true"],
.studio-chip-grid button.active,
.studio-chip-grid button[aria-pressed="true"] { background: var(--sidebar-active); color: var(--sidebar-accent); border-color: var(--sidebar-active-border); }

.studio-motion, .insights-filter { display: flex; gap: 8px; align-items: center; min-height: 40px; }
.studio-motion input, .insights-filter input { width: 16px; height: 16px; padding: 0; accent-color: var(--color-accent); }

.workspace-refresh { display: inline-flex; gap: 8px; align-items: center; }
.workspace-refresh[aria-busy="true"] svg { animation: refresh-turn 1s linear infinite; }
@keyframes refresh-turn { to { transform: rotate(360deg); } }
.chart-fit-toolbar { display: flex; justify-content: flex-end; padding: 8px 20px 0; }
.chart-fit-toolbar button { min-height: 32px; }

/* ── Portfolio Insights Structural Base ── */
.insights-header { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px; }
.insights-actions { display: flex; gap: 8px; align-items: center; }
.insights-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; border-block: 1px solid var(--color-border); margin-bottom: 24px; padding: 20px 0; }
.insights-summary > div { display: grid; gap: 12px; }
.insights-summary span { font-size: 12px; color: var(--color-text-muted); }
.insights-summary strong { font-size: 32px; font-weight: 500; }
.insights-summary p { grid-column: 1/-1; font-size: 12px; color: var(--color-text-muted); }
.insights-chart-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; }
.insights-chart-grid .panel-header { gap: 12px; flex-wrap: wrap; }
.instrument-volume-row { margin-bottom: 24px; }
.instrument-volume-row > div:first-child, .protection-summary > div:first-child { display: flex; gap: 16px; justify-content: space-between; font-size: 13px; margin-bottom: 12px; }
.instrument-volume-row strong { font-weight: 500; }
.volume-rail { height: 8px; background: var(--color-border-subtle); border-radius: var(--radius-xs); overflow: hidden; }
.volume-rail i { display: block; height: 100%; background: var(--color-accent); transform-origin: left; }
@keyframes volume-arrive { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.protection-summary { padding-block: 8px 20px; }
.protection-summary p { margin-top: 12px; font-size: 12px; color: var(--color-text-muted); }
.protection-rail { display: flex; height: 12px; overflow: hidden; border-radius: var(--radius-xs); background: var(--color-border-subtle); }
.coverage-set { background: var(--color-positive); }
.coverage-missing { background: var(--color-warning); }
.coverage-unknown { background: var(--color-text-muted); }
.coverage-text-set { color: var(--color-positive); }
.coverage-text-missing { color: var(--color-warning); }
.coverage-text-unknown { color: var(--color-text-muted); }
.insights-disclosure { font-size: 12px; line-height: 1.65; color: var(--color-text-muted); margin: 16px 0 28px; max-width: 980px; }
.insights-position-panel .panel-header { flex-wrap: wrap; gap: 12px; }
.insights-position-panel caption { text-align: left; padding: 16px 20px; color: var(--color-text-muted); font-size: 12px; }
.insights-account-section { margin-top: 32px; }
.insights-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.insights-section-heading h2 { font: 400 28px/1.2 var(--font-display); margin-bottom: 12px; }
.insights-section-heading p { color: var(--color-text-muted); font-size: 12px; max-width: 680px; }

.desk-map { position: relative; display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 16px; }
.desk-map::before { content: ''; position: absolute; top: 40px; left: 5%; right: 5%; height: 1px; background: var(--color-border-hover); }
.desk-map-node { position: relative; display: grid; gap: 12px; padding: 20px 16px; text-align: left; background: var(--color-surface); border-radius: var(--radius-xl); min-width: 0; transition: transform .2s, border-color .2s; }
.desk-map-node:hover { transform: translateY(-2px); border-color: var(--color-accent); }
.desk-map-index { color: var(--color-accent); font-size: 20px; }
.desk-map-node strong { font-weight: 500; font-size: 13px; overflow-wrap: anywhere; }
.desk-map-node > span:not(.desk-map-index) { font-size: 11px; color: var(--color-text-muted); overflow-wrap: anywhere; }
.desk-map-node .desk-map-action { padding-top: 8px; color: var(--color-accent); }

:root[data-density="compact"] .pro-table td { padding-block: 10px; }
:root[data-density="compact"] .widget-body { padding: 16px; }
:root[data-density="compact"] .insights-summary { gap: 12px; padding-block: 16px; }
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
:root[data-motion="reduced"] .desk-map-node:hover { transform: none; }

@media(max-width:1200px) { .desk-map { grid-template-columns: repeat(3,minmax(0,1fr)); } .desk-map::before { display: none; } }
@media(max-width:960px) { .insights-chart-grid { grid-template-columns: 1fr; } .workspace-refresh span { display: none; } }

/* Portfolio Insights: compact instrument panel, refined independently of other pages. */
#view_insights { --font-display: var(--font-sans); }
#view_insights .view-title-group h1 { font: 600 32px/1.15 var(--font-display); letter-spacing: -.035em; margin-bottom: 8px; }
#view_insights .insights-section-heading h2 { font: 600 22px/1.25 var(--font-display); letter-spacing: -.02em; }
#view_insights .insights-header { position: relative; border: 0; padding-bottom: 0; margin-bottom: 20px; }
#view_insights .insights-summary { grid-template-columns: repeat(4,minmax(0,1fr)); border: 0; padding: 0; gap: 12px; margin-bottom: 20px; }
#view_insights .insights-summary > div { min-width: 0; min-height: 104px; gap: 6px; align-content: start; padding: 14px 16px; background: var(--color-surface); border: 1px solid var(--color-border-subtle); border-radius: var(--radius-lg); transition: border-color .18s; }
#view_insights .insights-summary > div:first-child { border-top-color: var(--color-accent); }
#view_insights .insights-summary > div:hover, #view_insights .insights-summary > div:focus-within { border-color: var(--color-border-hover); }
#view_insights .insights-summary strong { min-width: 0; font: 500 30px/1.15 var(--font-sans); font-variant-numeric: tabular-nums; letter-spacing: -.025em; overflow-wrap: anywhere; }
#view_insights .insights-summary small { color: var(--color-text-muted); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
#view_insights .insights-summary p { grid-column: 1/-1; margin: 0; overflow-wrap: anywhere; }
#view_insights #insights_largest_share { color: var(--color-accent); }
#view_insights #insights_largest_symbol { color: var(--color-text-secondary); }
#insights_largest_symbol { color: var(--color-text-muted); }
#insights_largest_share { color: var(--color-accent); }

#view_insights .snapshot-explainer { position: relative; font-size: 12px; }
#view_insights .snapshot-explainer > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text-secondary); background: var(--color-surface); cursor: pointer; font-size: 12px; font-weight: 600; list-style: none; transition: background .18s, border-color .18s; }
#view_insights .snapshot-explainer > summary::-webkit-details-marker { display: none; }
#view_insights .snapshot-explainer > summary::after { content: ''; width: 6px; height: 6px; flex: 0 0 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform .18s var(--ease-out); }
#view_insights .snapshot-explainer[open] > summary::after { transform: rotate(225deg); }
#view_insights .snapshot-explainer > summary:hover, #view_insights .snapshot-explainer[open] > summary { background: var(--color-surface-hover); border-color: var(--color-border-hover); color: var(--color-text-primary); }
#view_insights .snapshot-explainer > summary:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
#view_insights .snapshot-explainer-body { position: absolute; z-index: 20; right: 0; top: calc(100% + 8px); width: min(380px,calc(100vw - 32px)); max-height: 300px; overflow: auto; padding: 16px; border: 1px solid var(--color-border-hover); border-radius: var(--radius-lg); background: var(--color-surface); color: var(--color-text-secondary); font-size: 12px; line-height: 1.65; box-shadow: var(--shadow-floating); }
#view_insights .snapshot-explainer-body p { margin: 0 0 12px; line-height: 1.65; color: var(--color-text-secondary); }
#view_insights .snapshot-explainer-body p:last-child { margin-bottom: 0; }
.snapshot-explainer-body p { margin: 12px 0 0; line-height: 1.65; color: var(--color-text-secondary); }

#view_insights .insights-chart-grid { grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); align-items: start; }
#view_insights .panel-title { font-size: 14px; font-weight: 600; }
#view_insights .widget-body { padding: 24px; }
.composition-overview { display: flex; align-items: center; gap: 24px; margin-bottom: 28px; }
.insights-donut { width: 144px; height: 144px; flex: 0 0 144px; border-radius: 50%; display: grid; place-items: center; }
.insights-donut > div { width: 112px; height: 112px; border-radius: 50%; background: var(--color-surface); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px; }
.insights-donut strong { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.insights-donut span { font-size: 11px; color: var(--color-text-muted); }
.composition-overview > p { font-size: 14px; font-weight: 500; margin: 0; }
.composition-overview > p > span, .composition-overview small { display: block; color: var(--color-text-muted); font-size: 12px; line-height: 1.5; margin-top: 8px; font-weight: 400; }
.instrument-key { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; }
#view_insights .instrument-volume-row { margin-bottom: 20px; }
#view_insights .volume-rail { height: 10px; }
#view_insights .protection-summary { display: flex; align-items: center; gap: 20px; padding: 0 0 24px; }
#view_insights .protection-summary > .protection-dial { width: 96px; height: 96px; flex: 0 0 96px; display: grid; place-items: center; justify-content: center; border-radius: 50%; background: conic-gradient(var(--color-positive) 0 var(--dial-set, 0%),var(--color-warning) var(--dial-set, 0%) var(--dial-known, 0%),var(--color-text-muted) var(--dial-known, 0%) 100%); margin: 0; }
.protection-dial > span { width: 76px; height: 76px; display: grid; place-items: center; border-radius: 50%; background: var(--color-surface); color: var(--color-text-primary); font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; }
#view_insights .protection-summary > .protection-detail { display: grid; gap: 8px; margin: 0; font-size: 13px; }
.protection-detail > .mono-num { font-size: 12px; color: var(--color-text-secondary); }
#view_insights .protection-summary p { margin: 0; line-height: 1.6; }
.coverage-key { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11px; color: var(--color-text-muted); margin: 0; }
.coverage-key > span { display: inline-flex; align-items: center; gap: 6px; }
.coverage-key i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }
:root[data-density="compact"] #view_insights .widget-body { padding: 16px; }

.chart-empty { display: grid; justify-items: center; gap: 16px; text-align: center; padding: 12px 0; min-height: 240px; align-content: center; }
.chart-empty-ring { width: 104px; height: 104px; display: grid; place-items: center; border: 8px solid var(--color-border-subtle); border-radius: 50%; color: var(--color-text-muted); font-size: 28px; font-weight: 500; }
.chart-empty strong { font-size: 14px; font-weight: 500; }
.chart-empty p { margin: 0; max-width: 300px; color: var(--color-text-muted); font-size: 12px; line-height: 1.6; }

/* Reveals introduce received charts; movement never represents connection or market activity. */
#view_insights.active { animation: none; }
#view_insights .insights-chart-grid > .panel { min-width: 0; transition: border-color .2s var(--ease-out); }
#view_insights .insights-chart-grid > .panel:hover, #view_insights .insights-chart-grid > .panel:focus-within { border-color: var(--color-border-hover); }
#view_insights.active .insights-chart-grid > .panel { animation: insights-panel-arrive .42s var(--ease-out) both; }
#view_insights.active .insights-chart-grid > .panel:nth-child(2) { animation-delay: .07s; }
#view_insights.active .insights-donut { animation: insights-ring-reveal .6s var(--ease-out) both; }
#view_insights.active .protection-dial { animation: insights-ring-reveal .6s .08s var(--ease-out) both; }
#view_insights.active .volume-rail i { animation: volume-arrive .55s .08s var(--ease-out) both; }
#view_insights:not(.active) .insights-donut { animation: none; }
#view_insights:not(.active) .protection-dial, #view_insights:not(.active) .volume-rail i, #view_insights:not(.active) .insights-chart-grid > .panel { animation: none; }
@keyframes insights-panel-arrive { from { opacity: .45; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes insights-ring-reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }

#view_insights .insights-guide { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 20px; }
#view_insights .insights-guide a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--color-border-subtle); border-radius: var(--radius-sm); color: var(--color-text-secondary); font-size: 12px; text-decoration: none; transition: background .18s, border-color .18s, color .18s; }
#view_insights .insights-guide a:hover { background: var(--color-surface-hover); border-color: var(--color-border-hover); color: var(--color-text-primary); }
#view_insights .insights-guide a:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
#insights_charts, #insights_details, #insights_desks { scroll-margin-top: 16px; }
#view_insights .insights-chart-hint { margin: 0; padding: 12px 24px 0; color: var(--color-text-muted); font-size: 12px; line-height: 1.6; }

#view_insights button.instrument-volume-row { display: block; width: 100%; min-width: 0; min-height: 44px; padding: 12px; margin: 0 0 8px; text-align: left; color: var(--color-text-primary); background: transparent; border: 1px solid transparent; border-radius: var(--radius-md); font-weight: 400; box-shadow: none; transition: background .18s, border-color .18s, transform .18s var(--ease-out); }
#view_insights .instrument-volume-row > span:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 10px; font-size: 13px; }
#view_insights .instrument-volume-row strong { overflow-wrap: anywhere; }
#view_insights .instrument-volume-row .mono-num { color: var(--color-text-secondary); font-size: 12px; }
#view_insights .instrument-volume-row > .volume-rail { display: block; margin: 0; }
#view_insights .instrument-volume-row:hover { background: var(--color-surface-hover); border-color: var(--color-border-subtle); }
#view_insights .instrument-volume-row.is-selected, #view_insights .instrument-volume-row[aria-pressed="true"] { background: var(--color-accent-subtle); border-color: var(--color-accent); }
#view_insights .instrument-volume-row:focus-visible, #view_insights .desk-map-node:focus-visible, #view_insights .insight-filter-clear:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
#view_insights .instrument-volume-row:active, #view_insights .desk-map-node:active { transform: translateY(1px); background: var(--color-surface-active); }
#view_insights .insight-filter-clear { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; margin: 0 0 12px; padding: 8px 12px; border-color: var(--color-accent); background: var(--color-accent-subtle); color: var(--color-text-primary); text-align: left; overflow-wrap: anywhere; }
#view_insights .insight-filter-clear:hover { background: var(--color-surface-hover); }

#view_insights .desk-map-node { width: 100%; border: 1px solid var(--color-border); align-content: start; transition: transform .18s var(--ease-out), border-color .18s, background .18s; }
#view_insights .desk-map-node:hover { background: var(--color-surface-raised); border-color: var(--color-accent); }
#view_insights .desk-map-node .desk-snapshot-count { color: var(--color-text-primary); font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
#view_insights .desk-map-node .desk-snapshot-lots { color: var(--color-text-secondary); font-size: 12px; font-variant-numeric: tabular-nums; }
#view_insights .desk-volume-rail { display: block; height: 5px; border-radius: var(--radius-xs); overflow: hidden; background: var(--color-border-subtle); }
#view_insights .desk-volume-fill { display: block; height: 100%; background: var(--color-accent); }

:root[data-motion="reduced"] #view_insights button:hover, :root[data-motion="reduced"] #view_insights button:active { transform: none; }

/* ── Risk Lab & Legacy Evidence Controls ── */
.risk-lab-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; margin: 20px 0; }
.risk-lab-grid .panel { min-width: 0; }
.legacy-action-panel, .legacy-history-panel, .legacy-shield-panel { margin-bottom: 20px; }
.legacy-action-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; padding: 20px; }
.legacy-action-grid button { min-height: 44px; }
.legacy-danger { border-color: var(--color-negative); color: var(--color-negative); }
.lab-form { display: flex; gap: 16px; flex-wrap: wrap; align-items: end; padding: 20px; }
.lab-form label { display: grid; gap: 8px; font-size: 12px; color: var(--color-text-secondary); min-width: 0; max-width: 100%; flex: 1 1 160px; }
.lab-form label:has(textarea) { flex: 1 1 100%; }
.lab-form input { width: 100%; min-width: 0; }
.lab-form input, .lab-form textarea { max-width: 100%; min-height: 40px; }
.lab-form textarea { width: 100%; min-height: 96px; resize: vertical; padding: 12px; background: var(--color-surface); color: var(--color-text-primary); border: 1px solid var(--color-border); border-radius: var(--radius-sm); font: 13px/1.6 var(--font-sans); }
.lab-form textarea:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
.lab-form p, .lab-form details { flex-basis: 100%; font-size: 12px; line-height: 1.6; margin: 0; }
.lab-form summary, .lab-format summary { cursor: pointer; min-height: 32px; }
.lab-form pre, .lab-format pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }
.lab-result { display: block; padding: 0 20px 20px; line-height: 1.7; font-size: 13px; color: var(--color-text-secondary); }
.lab-chart { padding: 0 20px; }
.lab-chart svg { width: 100%; height: auto; overflow: visible; }
.lab-chart text { fill: var(--color-text-muted); font: 11px var(--font-sans); }
.lab-line { stroke: var(--color-accent); stroke-width: 2.5; fill: none; }
.lab-axis { stroke: var(--color-border); fill: none; }
.lab-band { fill: var(--color-accent); fill-opacity: .16; }
.widget-footnote { line-height: 1.6; }
.legacy-action-panel > .widget-footnote, .risk-lab-grid .widget-footnote, .legacy-history-panel > .widget-footnote { padding: 0 20px 20px; }
.lab-subheading { font: 500 14px var(--font-sans); padding: 20px; }
.lab-waterfall { display: flex; align-items: end; gap: 12px; padding: 20px; overflow-x: auto; }
.lab-waterfall > div { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 60px; }
.lab-waterfall span { display: block; width: 24px; }
.lab-waterfall small { font: 11px var(--font-mono); font-variant-numeric: tabular-nums; }
.lab-up { background: var(--color-positive); }
.lab-down { background: var(--color-negative); }
.legacy-log { margin: 0 20px 20px; padding: 20px; background: var(--color-canvas); color: var(--color-text-secondary); border-radius: var(--radius-md); border: 1px solid var(--color-border-subtle); max-height: 380px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.8 var(--font-mono); }
.lab-format { padding: 0 20px 20px; font-size: 12px; }
.legacy-action-dialog { background: var(--color-surface); color: var(--color-text-primary); border: 1px solid var(--color-border-hover); border-radius: var(--radius-xl); box-shadow: var(--shadow-floating); padding: 28px; max-width: min(540px,calc(100vw - 32px)); margin: auto; }
.legacy-action-dialog::backdrop { background: rgba(8, 11, 15, .72); }
.legacy-action-dialog h2 { font: 600 22px var(--font-sans); margin: 0 0 16px; }
.legacy-action-dialog p { line-height: 1.7; margin-bottom: 16px; }
.legacy-action-dialog > div { display: flex; gap: 12px; justify-content: end; }

@media(max-width:1100px) { #view_insights .insights-chart-grid { grid-template-columns: 1fr; } #view_insights .insights-summary { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media(max-width:900px) { .risk-lab-grid { grid-template-columns: 1fr; } .legacy-action-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media(max-width:640px) {
  .insights-summary { gap: 12px; }
  .insights-summary strong { font-size: 24px; }
  .insights-chart-grid { gap: 16px; }
  .desk-map { grid-template-columns: 1fr; }
  .insights-section-heading { display: block; }
  .insights-section-heading > span { display: block; margin-top: 12px; }
  .insights-filter, .theme-controls button, .chart-fit-toolbar button { min-height: 44px; }
  .insights-actions { flex-wrap: wrap; }
  #view_insights .view-title-group h1 { font-size: 28px; }
  #view_insights .widget-body { padding: 20px; }
  .composition-overview { gap: 16px; }
  .insights-donut { width: 120px; height: 120px; flex-basis: 120px; }
  .insights-donut > div { width: 92px; height: 92px; }
  #view_insights .insights-summary { gap: 12px; }
  #view_insights .insights-summary strong { font-size: 26px; }
  #view_insights .composition-overview { flex-wrap: wrap; }
  #view_insights .instrument-volume-row > span:first-child { flex-wrap: wrap; }
  #view_insights .protection-summary { gap: 16px; flex-wrap: wrap; }
  #view_insights .insights-chart-hint { padding-inline: 20px; }
  #view_insights .insights-guide { gap: 8px; }
  #view_insights .insights-header .snapshot-explainer { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  .desk-map-node:hover { transform: none; }
  #view_insights *, #view_insights *::before, #view_insights *::after { animation: none !important; transition: none !important; clip-path: none !important; }
  #view_insights button:hover, #view_insights button:active { transform: none; }
}
