/* Stitch reference: Marine Quantitative Terminal. */
:root {
  --header-h: 60px;
  --sidebar-w: 248px;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #e6e8eb;
  --bg: #f7f9fc;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --panel-soft: #f2f4f7;
  --line: #e0e3e6;
  --line-strong: #c3c5d9;
  --text: #191c1e;
  --muted: #606574;
  --faint: #969aa6;
  --primary: #0052ff;
  --primary-strong: #003ec7;
  --primary-soft: #dde5ff;
  --accent: #0052ff;
  --accent-hover: #003ec7;
  --accent-soft: #dde5ff;
  --positive: #27a670;
  --positive-soft: #e5f5ed;
  --danger: #eb4d5c;
  --danger-soft: #ffebed;
  --warning: #e79600;
  --warning-soft: #fff3d9;
  --teal: #007f76;
  --teal-soft: #d9f5f1;
  --sidebar: #f2f4f7;
  --sidebar-panel: #e6e8eb;
  --sidebar-line: #e0e3e6;
  --sidebar-label: #737688;
  --sidebar-text: #434656;
  --shadow: none;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --surface: #17191d;
  --surface-2: #202329;
  --surface-3: #2a2e35;
  --bg: #111317;
  --panel: #17191d;
  --panel-strong: #1b1e23;
  --panel-soft: #202329;
  --line: #30343b;
  --line-strong: #464b55;
  --text: #f1f3f6;
  --muted: #a9afba;
  --faint: #747b88;
  --primary: #86a5ff;
  --primary-strong: #b7c4ff;
  --primary-soft: #26365f;
  --accent: #86a5ff;
  --accent-hover: #b7c4ff;
  --accent-soft: #26365f;
  --positive: #50c993;
  --positive-soft: #17392d;
  --danger: #ff7c88;
  --danger-soft: #472329;
  --warning: #f2b94b;
  --warning-soft: #40331a;
  --teal: #4dd7ca;
  --teal-soft: #143a36;
  --sidebar: #15171b;
  --sidebar-panel: #22252b;
  --sidebar-line: #30343b;
  --sidebar-label: #858c98;
  --sidebar-text: #c1c6cf;
  color-scheme: dark;
}

html { letter-spacing: 0; }
body { background: var(--bg); color: var(--text); font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif; font-size: 13px; line-height: 1.5; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { transition: border-color .16s ease, background-color .16s ease, color .16s ease, opacity .16s ease; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid color-mix(in srgb, var(--primary) 32%, transparent); outline-offset: 1px; }
svg.lucide { width: 17px; height: 17px; stroke-width: 1.85; }

.topbar {
  height: var(--header-h);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar .brand {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  padding: 0 20px;
  border-right: 1px solid var(--line);
}
.topbar .brand-mark { width: 34px; height: 34px; border-radius: 4px; background: transparent; }
.topbar .brand-name { color: var(--primary-strong); font-size: 16px; font-weight: 800; }
.topbar .brand-name small { color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: 1px; }
.market-strip { height: 100%; padding-left: 14px; }
.market-strip > span { min-width: 156px; height: 100%; padding: 0 15px; border-right: 0; }
.market-strip > span > img { width: 19px; height: 19px; }
.market-strip b { color: var(--muted); font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; font-weight: 650; }
.market-strip strong, .market-strip small { font-family: Consolas, "SFMono-Regular", monospace; font-variant-numeric: tabular-nums; }
.market-strip strong { font-size: 12px; }
.market-strip small { font-size: 11px; }
.market-strip small.up { color: var(--positive); }
.market-strip small.down { color: var(--danger); }
.top-actions { gap: 7px; padding-right: 18px; }
.connection { min-height: 34px; display: inline-flex; align-items: center; margin-right: 6px; padding: 0 11px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); font-size: 11px; }
.connection i { width: 7px; height: 7px; margin-right: 7px; box-shadow: none; }
.icon-button { position: relative; width: 36px; height: 36px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--muted); }
.icon-button:hover { border-color: var(--line); background: var(--surface-2); color: var(--text); }
.language-button { width: 45px; gap: 3px; }
.language-button span { font-size: 10px; font-weight: 750; }
.profile-button { height: 36px; max-width: 270px; padding: 0 12px; border-color: var(--line); border-radius: 4px; background: var(--primary); color: #fff; }
.profile-button:hover { background: var(--primary-strong); }
.profile-button b { max-width: 200px; color: inherit; font-size: 11px; }
.profile-button svg { width: 14px; height: 14px; }

.sidebar {
  top: var(--header-h);
  width: var(--sidebar-w);
  padding: 0 8px 10px;
  border-right: 1px solid var(--sidebar-line);
  background: var(--sidebar);
}
.sidebar-brand-panel { display: grid; justify-items: center; padding: 20px 12px 17px; border-bottom: 1px solid var(--sidebar-line); text-align: center; }
.sidebar-brand-mark { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 10px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.sidebar-brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-brand-panel strong { color: var(--primary-strong); font-size: 16px; }
.sidebar-brand-panel small { margin-top: 4px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: 1px; }
.sidebar nav { min-height: 0; padding: 10px 0; overflow-y: auto; gap: 2px; }
.sidebar nav p { margin: 13px 12px 5px; color: var(--sidebar-label); font-size: 9px; font-weight: 750; letter-spacing: .8px; }
.sidebar nav p:first-child { margin-top: 2px; }
.sidebar nav button {
  height: 42px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 9px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--sidebar-text);
}
.sidebar nav button svg { width: 18px; height: 18px; }
.sidebar nav button span { font-size: 12px; font-weight: 600; }
.sidebar nav button:hover { border-color: transparent; background: var(--sidebar-panel); color: var(--text); }
.sidebar nav button.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.sidebar nav button.active::before { display: none; }
.side-foot { padding: 10px 8px 0; border-top: 1px solid var(--sidebar-line); }
.side-foot span { font-size: 9px; }
.side-foot strong { margin-top: 3px; font-family: Consolas, monospace; font-size: 11px; }
.side-foot button { width: 34px; height: 34px; display: grid; place-items: center; border-color: var(--line); border-radius: 4px; color: var(--muted); }
.side-foot button:hover { background: var(--surface); color: var(--danger); }

.content { margin-left: var(--sidebar-w); padding: calc(var(--header-h) + 24px) 26px 42px; }
.content > * { max-width: 1600px; }
.page-head { min-height: 58px; margin-bottom: 18px; }
.page-head h1 { font-family: "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 26px; font-weight: 750; }
.page-head p { margin-top: 5px; font-size: 13px; }
.eyebrow { color: var(--primary); font-family: Consolas, monospace; font-size: 9px; letter-spacing: 1.2px; }
.dashboard-statuses { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.system-chip { min-height: 34px; display: inline-flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); color: var(--muted); font-size: 11px; }
.system-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--positive); }
.system-chip.offline i { background: var(--warning); }

.metric, .panel, .strategy-card { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: none; }
.panel { padding: 18px; }
.metrics { gap: 12px; }
.dashboard-metrics { grid-template-columns: repeat(12, minmax(0, 1fr)); margin-bottom: 12px; }
.dashboard-metrics .metric { grid-column: span 2; min-height: 122px; display: flex; flex-direction: column; justify-content: center; padding: 18px; }
.dashboard-metrics .metric:first-child { grid-column: span 4; justify-content: space-between; }
.metric::after { display: none; }
.metric span { font-size: 12px; font-weight: 600; }
.metric strong { margin-top: 10px; font-family: Consolas, "SFMono-Regular", monospace; font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; }
.dashboard-metrics .metric:first-child strong { font-size: clamp(30px, 2.5vw, 40px); }
.metric strong small { font-size: 11px; }
.metric footer { margin-top: 8px; font-size: 10px; }
.metric-head i { display: none; }

.dashboard-stage { grid-template-columns: minmax(0, 2fr) minmax(290px, 1fr); gap: 12px; margin-bottom: 12px; }
.dashboard-main-panel { min-height: 420px; background: var(--surface); }
.dashboard-main-panel::before { display: none; }
.panel-header { align-items: center; }
.panel-header h2 { font-size: 17px; }
.panel-header p { font-size: 11px; }
.period-tabs { gap: 5px; padding: 0; border: 0; background: transparent; }
.period-tabs button { min-width: 42px; height: 32px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--muted); font-size: 11px; }
.period-tabs button.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); box-shadow: none; }
.chart-summary { margin-top: 12px; }
.chart-summary strong { font-family: Consolas, monospace; font-size: 25px; }
.chart-summary span { font-size: 11px; }
.dashboard-chart { height: 330px; margin-top: 4px; }
.dashboard-side-stack { display: grid; gap: 12px; align-content: start; }
.dashboard-side-stack > .panel { min-height: 0; }
.dashboard-side-stack h2 { margin: 0; font-size: 17px; }
.dashboard-side-stack .panel-header { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.dashboard-side-stack .panel-header > strong { font-family: Consolas, monospace; font-size: 25px; }
.dashboard-exchange-stack { gap: 14px; }
.realtime-line { padding: 0; border: 0; background: transparent; }
.realtime-line span { font-size: 12px; }
.realtime-line small { font-size: 10px; }
.realtime-line i { height: 6px; border-radius: 3px; }
.realtime-line:nth-child(2) b { background: var(--teal); }
.realtime-line:nth-child(3) b { background: var(--muted); }
.dashboard-feed { gap: 0; max-height: 165px; overflow: hidden; }
.event-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 9px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.event-card time { grid-column: 2; grid-row: 1 / 3; align-self: center; font-family: Consolas, monospace; font-size: 10px; }
.event-card p { grid-column: 1; margin: 0; font-size: 11px; }
.event-card strong { color: var(--positive); font-size: 11px; }

.strategy-table-panel { padding: 0; overflow: hidden; }
.strategy-table-panel > .panel-header { min-height: 66px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--bg); }
.table-tools { display: flex; align-items: center; gap: 7px; }
.table-search { position: relative; min-width: 240px; }
.table-search svg { position: absolute; top: 9px; left: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.table-search input { width: 100%; height: 36px; min-height: 36px; padding: 6px 10px 6px 34px; border-radius: 4px; font-size: 12px; }
.table-tools select { width: auto; min-width: 106px; height: 36px; min-height: 36px; padding: 6px 29px 6px 10px; border-radius: 4px; font-size: 12px; }
.strategy-table-panel .table-wrap { margin: 0; border: 0; }
th { height: 43px; padding: 9px 13px; background: var(--bg); color: var(--muted); font-size: 11px; font-weight: 650; text-transform: none; }
td { height: 50px; padding: 9px 13px; color: var(--text); font-size: 12px; }
tbody tr:hover { background: var(--surface-2); }
.table-footer { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.table-footer button { border: 0; background: transparent; color: var(--primary); font-weight: 700; }

.primary, .secondary, .button-row button { min-height: 38px; padding: 7px 13px; border-radius: 4px; font-size: 12px; }
.primary { background: var(--primary); border-color: var(--primary); }
.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.secondary, .button-row button { background: var(--surface); border-color: var(--line); }
input, select, textarea { border-color: var(--line-strong); border-radius: 4px; background: var(--surface); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 14%, transparent); }
.content label, .app-dialog label { font-size: 12px; }
.content input, .content select, .content textarea { min-height: 38px; font-size: 12px; }
.panel > h2, .profit-panel-header h2 { font-size: 17px; }
.panel > p, .profit-panel-header p { font-size: 11px; }
.badge, .status-badge, .side-badge { min-height: 24px; padding: 3px 7px; font-size: 10px; }
.strategy-name strong { font-size: 12px; }
.strategy-name small { font-size: 10px; }
.strategy-card h3, .account-identity h3 { font-size: 15px; }
.strategy-meta, .strategy-card dt, .account-identity p, .account-stat span { font-size: 10px; }
.strategy-card dd, .account-stat strong { font-size: 12px; }
.help-tip { width: 16px; height: 16px; font-size: 10px; }
.profit-total, .profit-view-switch button, .profit-quick-ranges button, .profit-calendar-summary, .profit-weekdays span, .profit-calendar-day > span, .profit-calendar-day > strong, .profit-calendar-day > small { font-size: 11px; }
.profit-filter-bar label { font-size: 11px; }
.profit-calendar-day { min-height: 98px; }
.app-dialog { font-size: 13px; }
.app-dialog strong { font-size: 17px; }
.app-dialog p, .app-toast p { font-size: 12px; }
.app-toast strong { font-size: 13px; }
.badge, .status-badge, .side-badge { border-radius: 3px; }
.notice { border-radius: 4px; }
.empty-state { border-radius: 4px; }
.strategy-card { border-radius: 6px; }
.strategy-card:hover { border-color: var(--line-strong); box-shadow: none; }
.account-card, .account-setup, .profit-workspace, .strategy-estimate-panel, .strategy-market-info { border-radius: 6px; box-shadow: none; }
.app-dialog { border-radius: 7px; }
.app-toast { border-radius: 5px; }

@media (max-width: 1180px) {
  .dashboard-metrics .metric:first-child { grid-column: span 6; }
  .dashboard-metrics .metric { grid-column: span 3; }
  .dashboard-stage { grid-template-columns: minmax(0, 1.6fr) minmax(270px, 1fr); }
  .market-strip > span { min-width: 128px; padding-inline: 10px; }
}

@media (max-width: 900px) and (min-width: 761px) {
  :root { --sidebar-w: 216px; }
  .sidebar-brand-panel strong { font-size: 13px; }
  .sidebar nav button { padding-inline: 9px; }
  .sidebar nav button span { font-size: 12px; }
  .dashboard-stage { grid-template-columns: 1fr; }
  .dashboard-side-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .connection { display: none; }
}

@media (max-width: 760px) {
  :root { --header-h: 58px; --sidebar-w: 280px; }
  .topbar { min-height: var(--header-h); padding: 7px 10px 6px; }
  .topbar .brand { width: auto; min-width: 0; height: 36px; padding: 0 6px 0 0; border-right: 0; }
  .topbar .brand-name { display: flex; font-size: 13px; line-height: 1.15; }
  .topbar .brand-name small { display: block; margin-top: 2px; font-size: 7px; letter-spacing: .7px; }
  .market-strip { display: none; }
  .top-actions { height: 38px; gap: 4px; padding-right: 0; }
  .connection, #lang-btn { display: none; }
  .mobile-nav-button { display: grid; order: -1; }
  .profile-button { max-width: 102px; padding-inline: 8px; }
  .profile-button b { max-width: 62px; }
  .sidebar { top: var(--header-h); width: min(86vw, 300px); min-width: min(86vw, 300px); padding-bottom: 10px; }
  .sidebar-brand-panel { grid-template-columns: 38px 1fr; justify-items: start; gap: 0 10px; padding: 13px 12px; text-align: left; }
  .sidebar-brand-mark { grid-row: 1 / 3; width: 38px; height: 38px; margin: 0; }
  .sidebar-brand-panel strong { align-self: end; font-size: 14px; }
  .sidebar-brand-panel small { align-self: start; }
  .content { margin-left: 0; padding: calc(var(--header-h) + 17px) 14px 28px; }
  .page-head { margin-bottom: 14px; }
  .page-head h1 { font-size: 23px; }
  .page-head p { font-size: 12px; }
  .dashboard-statuses { justify-content: flex-start; margin-top: 12px; }
  .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-metrics .metric:first-child, .dashboard-metrics .metric { grid-column: span 1; min-height: 106px; }
  .dashboard-metrics .metric:first-child { grid-column: 1 / -1; }
  .dashboard-metrics .metric:first-child strong { font-size: 29px; }
  .dashboard-stage { grid-template-columns: 1fr; }
  .dashboard-main-panel { min-height: 350px; }
  .dashboard-chart { height: 255px; }
  .dashboard-side-stack { grid-template-columns: 1fr; }
  .strategy-table-panel > .panel-header { align-items: stretch; flex-direction: column; }
  .table-tools { width: 100%; }
  .table-search { min-width: 0; flex: 1; }
  .strategy-table-panel table { min-width: 760px; }
  .table-footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 420px) {
  .dashboard-metrics { grid-template-columns: 1fr 1fr; }
  .dashboard-metrics .metric { min-height: 100px; padding: 14px; }
  .metric strong { font-size: 23px; }
  .dashboard-metrics .metric:first-child strong { font-size: 28px; }
  .panel { padding: 14px; }
  .period-tabs button { min-width: 34px; padding-inline: 5px; }
  .system-chip:last-child { display: none; }
}
