/* Workspace design system. Chart geometry and dialog behavior live in styles.css;
   this file owns the application shell, surfaces, typography and responsive layout. */
:root, body:not(.dark-mode) {
  --app-bg: #f5f6f8;
  --surface-1: #fff;
  --surface-2: #f5f7fa;
  --surface-raised: #fff;
  --text-1: #243047;
  --text-2: #778196;
  --separator: #e5e9f0;
  --ink: var(--text-1);
  --muted: var(--text-2);
  --line: var(--separator);
  --panel: var(--surface-1);
  --accent: #355fd1;
  --blue: #355fd1;
  --control-blue: #355fd1;
  --control-blue-hover: #284eb4;
  --profit: #c35359;
  --loss-color: #208679;
}
body.dark-mode {
  --app-bg: #111722;
  --surface-1: #192230;
  --surface-2: #222e3e;
  --surface-raised: #202b3b;
  --text-1: #e4eaf5;
  --text-2: #a0aec2;
  --separator: #303d50;
  --ink: var(--text-1);
  --muted: var(--text-2);
  --line: var(--separator);
  --panel: var(--surface-1);
  --accent: #8cabfa;
  --blue: #8cabfa;
  --control-blue: #8cabfa;
  --control-blue-hover: #a4bcfa;
  --profit: #ed969c;
  --loss-color: #68c9b7;
}
body, body.dark-mode {
  background: var(--app-bg);
  color: var(--text-1);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body *, body *::before, body *::after { font-synthesis: none; }
button, input, select, textarea { font-family: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, a { transition: background-color .14s, border-color .14s, color .14s; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--control-blue); outline-offset: 3px;
}
button:disabled { cursor: wait; opacity: .55; }
.app-shell { overflow: visible; display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 100dvh; }
body .topbar {
  position: sticky; top: 0; width: 208px; height: 100dvh; min-height: 0;
  display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch;
  padding: 32px 18px; gap: 48px; color: var(--text-1); background: var(--surface-1);
  border: 0; border-right: 1px solid var(--separator); box-shadow: none; backdrop-filter: none;
}
.brand-lockup { gap: 11px; padding: 0 8px; }
body .brand-mark { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px; background: #355fd1; box-shadow: none; color: #fff; font-size: 15px; font-weight: 700; }
body .topbar .kicker { font-size: 9px; color: var(--text-2); letter-spacing: .18em; font-weight: 600; margin: 0 0 5px; }
body .topbar h1 { font-size: 19px; font-weight: 600; letter-spacing: .02em; }
body .topbar nav { display: flex; flex-direction: column; gap: 7px; width: 100%; }
body .topbar nav a { display: flex; align-items: center; justify-content: flex-start; gap: 13px; height: 46px; padding: 0 14px; color: var(--text-2); font-size: 13px; font-weight: 500; border: 1px solid transparent; border-radius: 7px; background: transparent; box-shadow: none; }
body .topbar nav a.active { color: var(--control-blue); background: color-mix(in srgb, var(--control-blue) 9%, transparent); }
body .topbar nav a:hover { color: var(--text-1); background: var(--surface-2); }
.nav-index { font-size: 10px; letter-spacing: .06em; opacity: .65; font-variant-numeric: tabular-nums; }
body .topbar nav a[href="#trade-entry"] { margin-top: 18px; color: var(--control-blue); border-color: var(--separator); }
.nav-foot { margin-top: auto; padding: 0 8px; font-size: 11px; color: var(--text-2); }
.nav-foot small { display: block; font-size: 8px; letter-spacing: .1em; margin-top: 9px; }
.nav-foot-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #208679; margin-right: 5px; }
body main { width: 100%; max-width: 1600px; min-width: 0; margin: 0 auto; padding: 0 36px 40px; gap: 0; display: block; }
body .statusbar { position: static; display: flex; justify-content: space-between; align-items: center; min-height: 84px; margin: 0 0 30px; padding: 16px 0; gap: 16px; border: 0; border-bottom: 1px solid var(--separator); border-radius: 0; background: transparent; box-shadow: none; backdrop-filter: none; }
.statusbar .kicker { display: none; }
.statusbar strong { font-size: 12px; font-weight: 500; color: var(--text-2); }
.status-actions { gap: 9px; }
body .status-actions > span, body .account-button { background: transparent; border: 0; box-shadow: none; font-size: 11px; font-weight: 500; padding: 0 6px; }
body .status-actions .storage-label, body .account-button small { display: none; }
body .account-button { height: 34px; color: var(--text-1); }
body .account-dot { width: 25px; height: 25px; background: var(--surface-2); color: var(--control-blue); font-size: 10px; box-shadow: none; }
body .icon-button { width: 34px; height: 34px; border: 1px solid var(--separator); border-radius: 7px; color: var(--text-2); background: var(--surface-1); box-shadow: none; font-size: 17px; }
body .band { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; backdrop-filter: none; }
body .section-head { margin-bottom: 24px; padding: 0; border: 0; align-items: center; gap: 20px; }
.kicker { font-size: 10px; color: var(--text-2); letter-spacing: .16em; font-weight: 600; margin-bottom: 8px; }
body h2 { font-size: clamp(22px, 2vw, 29px); font-weight: 600; letter-spacing: -.035em; line-height: 1.4; }
body h3 { font-size: 15px; font-weight: 600; }
.section-description { margin: 8px 0 0; font-size: 12px; color: var(--text-2); line-height: 1.7; }
body .portfolio-profile-bar.compact { background: transparent; border: 0; padding: 0; gap: 8px; box-shadow: none; }
body .portfolio-profile-bar.compact .portfolio-current { display: none; }
body .profile-select-button, body .portfolio-picker-toggle, body .benchmark-select-button { height: 36px; border-radius: 7px; background: var(--surface-1); border: 1px solid var(--separator); box-shadow: none; color: var(--text-1); font-size: 11px; font-weight: 500; }
body .profile-select-button em { font-weight: 600; }
body .metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin: 0 0 24px; padding: 4px 6px; border: 1px solid var(--separator); border-radius: 12px; background: var(--surface-1); overflow: hidden; }
body .metrics article { min-width: 0; min-height: 98px; padding: 20px 18px; background: transparent; border: 0; border-radius: 0; box-shadow: none; }
body .metrics article:nth-child(-n+5) { border-bottom: 1px solid var(--separator); }
body .metrics article::after { display: none; }
body .metrics article > span { font-size: 11px; color: var(--text-2); font-weight: 500; }
body .metrics strong { display: block; margin-top: 10px; font-size: clamp(18px, 1.7vw, 27px); letter-spacing: -.04em; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
body .metrics article:first-child strong { color: var(--text-1); }
body .chart:not(.chart-dark), body .annual-panel { background: var(--surface-1); border: 1px solid var(--separator); border-radius: 12px; box-shadow: none; padding: 22px; }
body .compare-head { min-height: 40px; margin-bottom: 20px; gap: 15px; align-items: center; }
body .compare-head strong { font-size: 14px; font-weight: 600; }
body .compare-head small, body .compare-legend { font-size: 10px; color: var(--text-2); font-weight: 500; }
body .compare-stage { height: auto; min-height: 0; border: 0; border-radius: 0; background: transparent; }
body .compare-chart { display: block; width: 100%; height: auto; max-height: 420px; aspect-ratio: 1040 / 450; }
body .compare-floating-tools { position: static; background: var(--surface-2); border: 0; border-radius: 6px; box-shadow: none; }
body .compare-floating-tools button { width: auto; height: 30px; min-width: 30px; white-space: nowrap; padding: 0 6px; font-size: 12px; font-weight: 500; }
body .annual-panel { margin-top: 22px; }
body .annual-card { background: var(--surface-1); border-radius: 8px; box-shadow: none; border-color: var(--separator); }
body .annual-card strong, body .annual-card dd { font-weight: 600; font-variant-numeric: tabular-nums; }
body .strategy-list { gap: 12px; }
body .strategy-card:not(.expanded) { display: block; min-width: 0 !important; width: 100%; padding: 20px 22px; border: 1px solid var(--separator); border-radius: 10px; background: var(--surface-1); box-shadow: none; transition: border-color .14s; }
body .strategy-card:not(.expanded):hover { border-color: var(--control-blue); transform: none; box-shadow: none; }
body .strategy-title { color: var(--text-1); background: transparent; border: 0; height: auto; padding: 0; }
body .strategy-card:not(.expanded) .strategy-name strong { font-size: 14px; font-weight: 600; }
body .strategy-card:not(.expanded) .title-quote { gap: 9px; margin-top: 6px; }
body .strategy-card:not(.expanded) .title-quote b { font-size: 12px; font-weight: 600; }
body .strategy-card:not(.expanded) .title-quote i, body .strategy-card:not(.expanded) .title-quote small { font-size: 10px; font-weight: 400; }
body .strategy-card:not(.expanded) .strategy-compact { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)) !important; min-width: 0 !important; background: transparent; border-left: 0; margin-top: 18px; gap: 18px; padding-top: 14px; border-top: 1px solid var(--separator); }
body .strategy-compact b { font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
body .strategy-compact em { font-size: 10px; font-weight: 400; color: var(--text-2); }
body .instrument-tabs { margin-bottom: 18px; }
body .status-tab { background: transparent; color: var(--text-2); border: 1px solid transparent; border-radius: 6px; font-size: 12px; font-weight: 500; }
body .status-tab.active { background: var(--surface-1); border-color: var(--separator); color: var(--control-blue); }
body .plan-form { background: var(--surface-1); border: 1px solid var(--separator); border-radius: 12px; padding: 24px; gap: 20px; }
body .field > span { font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 7px; }
body input, body select, body textarea { background: var(--surface-1); border: 1px solid var(--separator); border-radius: 7px; color: var(--text-1); font-size: 13px; box-shadow: none; }
body input:not([type="checkbox"]):not([type="file"]), body select { height: 40px; }
body button { border-radius: 7px; font-weight: 500; box-shadow: none; }
body .table-wrap { border: 1px solid var(--separator); border-radius: 10px; background: var(--surface-1); }
body th { background: var(--surface-2); color: var(--text-2); font-weight: 500; font-size: 11px; }
body td { font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
body .stress-summary article { background: var(--surface-1); border-color: var(--separator); border-radius: 9px; box-shadow: none; }
body .floating-scrim, body .auth-scrim { backdrop-filter: none; background: rgba(17, 26, 44, .36); }
body .instrument-modal, body .review-modal, body #trade-entry.page-view, body .auth-modal { border: 1px solid var(--separator); border-radius: 14px; background: var(--surface-raised); box-shadow: 0 20px 80px #111a4426; animation: none; backdrop-filter: none; }
body #trade-entry.page-view { padding: 24px; }
body #trade-entry .plan-form { padding: 18px; }
body .instrument-modal-head, body .instrument-modal-kpis, body .instrument-modal-tabs { background: var(--surface-raised); border-color: var(--separator); }
body .auth-modal-login { max-width: 820px; }
body .auth-brand-panel { background: #253b68; padding: 36px; }
body .auth-brand-panel h2 { font-size: 27px; color: #fff; }
body .auth-brand-panel p { font-size: 13px; }
body .auth-form-panel { padding: 36px; background: var(--surface-raised); }
body .auth-form-panel h2 { font-size: 25px; }
.loading-chart { padding: 12px 0; }
.loading-chart p { font-size: 12px; color: var(--text-2); }
.loading-chart-grid { height: 220px; margin-top: 24px; background: repeating-linear-gradient(to bottom, transparent 0, transparent 54px, var(--separator) 55px, transparent 56px); }
@media (min-width: 861px) and (max-width: 1180px) {
  .app-shell { grid-template-columns: 174px minmax(0, 1fr); }
  body .topbar { width: 174px; padding: 28px 12px; }
  body main { padding: 0 24px 32px; }
  body .metrics article { padding: 18px 12px; }
  body .section-head { align-items: flex-start; flex-wrap: wrap; }
}
@media (max-width: 860px) {
  body .topbar { width: 100% !important; height: auto; padding: 14px 16px 0 !important; gap: 16px; border-right: 0; border-bottom: 1px solid var(--separator); overflow: visible; }
  .brand-lockup { padding: 0; }
  body .topbar h1 { font-size: 17px; }
  body .topbar nav { flex-direction: row; justify-content: space-between; gap: 2px; padding-bottom: 8px; }
  body .topbar nav a { height: 40px; padding: 0 8px; font-size: 12px; flex: 0 0 auto; border-radius: 5px; }
  body .topbar nav a[href="#trade-entry"] { margin: 0; border-color: transparent; }
  .nav-index, .nav-foot { display: none; }
  body main { padding: 0 16px 28px !important; overflow: visible; }
  body .statusbar { min-height: 54px; padding: 10px 0; margin: 0 0 22px !important; flex-direction: row; }
  .statusbar > div:first-child { display: none; }
  body .status-actions { width: 100%; gap: 8px; overflow: visible; flex-wrap: wrap; }
  body .status-actions #app-version { margin-right: auto; }
  body .status-actions #quote-health { max-width: 138px; font-size: 10px; padding: 0; }
  body .section-head { gap: 18px; margin-bottom: 20px; flex-direction: column; align-items: stretch; }
  body h2 { font-size: 25px; }
  body .section-description { font-size: 12px; }
  body .portfolio-profile-bar.compact { justify-content: flex-start; flex-wrap: wrap; }
  body .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; margin-bottom: 16px; padding: 0 5px; }
  body .metrics article { min-height: 82px; padding: 16px 13px; border-bottom: 1px solid var(--separator); }
  body .metrics article:nth-last-child(-n+2) { border-bottom: 0; }
  body .metrics strong { font-size: 22px; margin-top: 8px; }
  body .metrics article > span { font-size: 11px; }
  body .chart:not(.chart-dark), body .annual-panel { padding: 16px 12px; border-radius: 10px; }
  body .compare-head { flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
  body .compare-chart { width: 100%; height: 260px !important; min-height: 0 !important; max-height: none; aspect-ratio: auto; }
  body .compare-stage { height: 260px !important; min-height: 0 !important; }
  body .compare-floating-tools { margin-left: auto; }
  body .strategy-card:not(.expanded) { display: block; min-width: 0 !important; width: 100%; padding: 17px 14px; }
  body .strategy-card:not(.expanded) .strategy-compact { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 14px; margin-top: 14px; }
  body .strategy-card:not(.expanded) .title-quote { flex-wrap: wrap; }
  body .strategy-compact b { font-size: 16px; }
  body .quote-form { justify-content: flex-start; }
  body .plan-form { padding: 18px 14px; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  body .plan-form > button { grid-column: 1 / -1; min-height: 42px; }
  body #trade-entry.page-view { padding: 18px 14px; max-height: calc(100dvh - 24px); }
  body .auth-form-panel { padding: 28px 22px; }
  body .auth-brand-panel { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
/* Remove legacy fixed-width instrument rows and neon chart surfaces. */
body .strategy-card::before { display: none; }
body .strategy-card:not(.expanded) .strategy-title { min-height: 0; padding: 0; border-radius: 0; background: transparent; }
body .strategy-card:not(.expanded) .title-quote { display: flex; flex-wrap: wrap; }
body .strategy-card:not(.expanded) .strategy-compact span { min-height: 0; padding: 0; border: 0; }
body .strategy-card:not(.expanded) .strategy-compact b { font-size: 14px; }
body .strategy-card:not(.expanded) .strategy-compact em { white-space: normal; }
body .chart-dark { color: var(--text-1); background: var(--surface-1); border: 1px solid var(--separator); border-radius: 10px; box-shadow: none; }
body .chart-dark .review-title { color: var(--text-1); font-weight: 600; text-align: left; }
body .review-title::before, body .review-title::after { content: none; }
body .chart-dark .review-toolbar { color: var(--text-2); background: transparent; }
body .chart-dark .review-toolbar button { color: var(--text-2); background: var(--surface-1); border: 1px solid var(--separator); }
body .chart-dark .review-toolbar button.active { color: var(--control-blue); background: var(--surface-2); }
body .chart-dark .chart-stats article { background: var(--surface-2); border: 1px solid var(--separator); border-radius: 7px; box-shadow: none; }
body .chart-stats span { color: var(--text-2); font-weight: 400; }
body .chart-stats strong { color: var(--text-1); font-weight: 600; }
body .chart-dark svg text { fill: var(--text-2); }
body .chart-dark svg .grid-line { stroke: var(--separator); }
body .instrument-modal-kpis article { border-radius: 7px; }
body .instrument-modal-kpis strong, body .instrument-modal-quote strong { font-weight: 600; }
body .instrument-modal-kpis article span, body .instrument-modal-quote small { font-weight: 400; }
body #trade-entry > .section-head { display: flex !important; flex-direction: row; align-items: center; }
body #trade-entry .plan-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 860px) {
  body .portfolio-profile-bar.compact { display: flex; }
  body .profile-dropdown { flex: 1; }
  body .portfolio-picker-toggle { flex: 0 0 auto; }
  body .compare-head { display: flex !important; }
  body .compare-head > div:first-child { width: 100%; }
  body .compare-head .compare-legend { width: auto; }
  body .compare-head .benchmark-dropdown { width: 100%; }
  body .compare-head .compare-floating-tools { width: auto; margin-left: auto; }
  body #trade-entry .plan-form { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  body .chart-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
body .instrument-modal .chart-dark, body .review-modal .chart-dark { background: var(--surface-1); }
body:not(.dark-mode) .instrument-modal .chart-dark .review-title,
body:not(.dark-mode) .review-modal .chart-dark .review-title,
body:not(.dark-mode) .instrument-modal .chart-dark .review-toolbar,
body:not(.dark-mode) .review-modal .chart-dark .review-toolbar { color: var(--text-1); }
body .reference-line { filter: none; stroke: var(--profit) !important; stroke-width: 1.5 !important; }
body .reference-label { fill: var(--profit) !important; stroke: var(--surface-1); stroke-width: 2; font-weight: 600; }
body .chart-stage { background: transparent; border-color: var(--separator); }
body .compare-head > div:first-child { flex: none; }
@media (max-width: 860px) {
  body .compare-head { display: grid !important; grid-template-columns: minmax(0, 1fr) auto; }
  body .compare-head > div:first-child { grid-column: 1 / -1; height: auto; min-height: 0; }
  body .compare-head .compare-legend { grid-column: 1 / -1; }
  body .compare-head .benchmark-dropdown { width: 100%; }
  body .compare-head .benchmark-select-button { min-width: 0; width: 100%; padding: 0 8px; height: 36px; }
  body .compare-head .benchmark-select-button > span { display: none; }
  body .compare-chart { padding: 0; }
}
body .instrument-modal .chart-stage,
body .review-modal .chart-stage { background: var(--surface-1); }
body .chart-dark .review-legend, body .chart-dark .chart-title { color: var(--text-2); }
body .instrument-modal .chart-with-sidebar { min-width: 0; grid-template-columns: minmax(0, 1fr) 210px; }
body .review-modal .chart-with-sidebar { min-width: 0; grid-template-columns: minmax(0, 1fr) 210px; }
body .instrument-modal-tabs button { color: var(--text-1); background: var(--surface-2); }
body .instrument-modal-tabs button.active { color: #fff; background: #355fd1; }
/* A filtered ancestor traps position:fixed menus inside the chart on iOS/Chrome. */
body .chart, body .annual-panel, body .metrics article,
body .portfolio-inline-picker, body .benchmark-multi, body .profile-menu,
body .compare-floating-tools { backdrop-filter: none; }
body.dark-mode .topbar, body.dark-mode .statusbar { background: transparent; }
body.dark-mode .topbar { background: var(--surface-1); }
body.dark-mode .metrics article { background: transparent; }
body.dark-mode .profile-select-button, body.dark-mode .portfolio-picker-toggle,
body.dark-mode .benchmark-select-button, body.dark-mode .icon-button,
body.dark-mode input, body.dark-mode select, body.dark-mode .compare-floating-tools button {
  color: var(--text-1); background: var(--surface-2); border-color: var(--separator);
}
body.dark-mode .account-button { color: var(--text-1); background: transparent; }
body.dark-mode .profile-select-button em, body.dark-mode .benchmark-select-button em { color: var(--text-1); }
body .compare-chart .strategy-path { stroke: var(--profit) !important; }
body .review-legend { color: var(--text-2); }
.history-notice { margin: 0 0 12px; color: var(--text-2); font-size: 12px; }
.history-notice button, .chart-loading button { margin-left: 8px; height: 32px; }
body .review-toolbar [data-toggle-markers][aria-pressed="true"] { background: var(--surface-2); color: var(--control-blue); }
body .trade-pin text { font-size: 10px; font-weight: 600; stroke: var(--surface-1); stroke-width: 2px; paint-order: stroke; }
body .trade-pin circle { stroke-width: 1px; }
body .chart-tooltip { max-width: min(220px, calc(100% - 8px)); pointer-events: none; }
body .chart-dark .marker-legend, body .chart-dark .marker-legend span { color: var(--text-2); }
body .marker-legend { flex-wrap: wrap; gap: 8px 14px; }
body .marker-legend span { white-space: nowrap; }
body .marker-legend span:last-child { white-space: normal; }
