/* Layout: tokens, then fonts and base, then shell (sidebar >= 760px, bottom tab bar below), components, per-view pieces. */

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #14181f;
  --surface: #1b2029;
  --surface-2: #222833;
  --line: #2a313c;
  --text: #e3e6eb;
  --muted: #8d96a5;
  --accent: #d2a64a;
  --on-accent: #14181f;
  --up: #3fb68b;
  --down: #e36458;
  --r: 6px;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --tabbar-h: 56px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    color-scheme: light;
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #eef0f3;
    --line: #dde1e7;
    --text: #1a1f27;
    --muted: #5d6675;
    --accent: #94701f;
    --on-accent: #ffffff;
    --up: #1c8660;
    --down: #c0433a;
  }
}
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --line: #dde1e7;
  --text: #1a1f27;
  --muted: #5d6675;
  --accent: #94701f;
  --on-accent: #ffffff;
  --up: #1c8660;
  --down: #c0433a;
}

/* ---------- fonts (self-hosted IBM Plex, OFL) ---------- */
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-cyrillic-500-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-cyrillic-600-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-mono-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-mono-cyrillic-500-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--muted); text-transform: none; margin: 16px 0 8px; }
p { margin: 0 0 8px; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 1px 6px; word-break: break-all; }
ul, ol { margin: 0; padding-left: 20px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--up); }
.neg { color: var(--down); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 500; }
.r { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -48px; background: var(--accent); color: var(--on-accent); padding: 8px 12px; border-radius: var(--r); z-index: 100; }
.skip:focus { top: 8px; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 20px; background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; padding: 0 8px; }
.brand img { border-radius: 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 10px; border-radius: var(--r); color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a[aria-current='page'] { background: var(--surface); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav svg, .tabbar svg, .icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.account-select { flex: 0 1 260px; min-width: 0; }
#account-kind { flex: none; }
#theme-toggle { margin-left: auto; }
#theme-toggle .fillme { fill: currentColor; }
#view { padding: 20px 24px 48px; max-width: 1240px; outline: none; }
.tabbar { display: none; }

/* ---------- controls ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input[type='text'], input[type='number'], input[type='password'], input[type='date'], input[type='time'], input[type='file'], select, textarea {
  width: 100%; min-height: 40px; padding: 7px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--text);
}
textarea { resize: vertical; min-height: 88px; line-height: 1.45; }
input[type='file'] { padding: 6px; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[aria-invalid='true'] { border-color: var(--down); }
select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--r); font-weight: 500; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--down); }
.btn-block { width: 100%; }
.icon-btn { min-width: 40px; padding: 0; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: 12.5px; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); }
.field.check { flex-direction: row; align-items: center; gap: 10px; min-height: 40px; align-self: end; }
.field.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: start; }
.form-row.map { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.save-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 20px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg-btn, .tag { min-height: 40px; min-width: 40px; padding: 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; font-weight: 500; }
.seg-btn[aria-pressed='true'], .tag[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.tag-edit { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: var(--r); padding-left: 10px; background: var(--surface); min-height: 40px; }
.tag-x { min-width: 40px; min-height: 40px; background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; }
.tag-x:hover { color: var(--down); }
.tag-add { display: flex; gap: 8px; margin-top: 12px; max-width: 460px; }

.chip { display: inline-block; padding: 2px 8px; border: 1px solid var(--line); border-radius: var(--r); font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.chip.kind-real { color: var(--up); border-color: var(--up); }
.chip.kind-prop { color: var(--accent); border-color: var(--accent); }
.chip.kind-demo { color: var(--muted); }

.notice { border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: var(--r); background: var(--surface); margin: 12px 0; }
.notice p { margin: 0 0 4px; }
.notice ul { margin-top: 4px; }
.notice-error { border-left-color: var(--down); color: var(--text); }
.notice-ok { border-left-color: var(--up); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--r); opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s; z-index: 60; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- page pieces ---------- */
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; }
.big { font-size: 24px; font-weight: 500; }
.back { display: inline-block; margin-bottom: 8px; color: var(--muted); text-decoration: none; min-height: 28px; }
.back:hover { color: var(--text); }
.panel { background: var(--surface); border: 1px solid var(--line); padding: 16px; margin-bottom: 16px; min-width: 0; }
.panel-title { margin-bottom: 12px; }
.loading { padding: 24px 0; }
.empty { border: 1px dashed var(--line); padding: 28px 24px; max-width: 640px; }
.empty h2 { font-size: 17px; margin-bottom: 8px; }
.empty-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.steps { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.empty-line { color: var(--muted); padding: 16px 0; margin: 0; }
.more-link, .more-btn { margin-top: 12px; display: inline-flex; }
.more-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.more-list a { display: flex; align-items: center; min-height: 52px; padding: 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--text); text-decoration: none; font-weight: 500; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid-2 > .panel { margin-bottom: 0; }
.grid-2.top { margin-bottom: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-main > .panel { margin-bottom: 0; }
.grid-main, .grid-2 { margin-bottom: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); margin-bottom: 16px; }
.kpi { background: var(--surface); padding: 12px 14px; min-width: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 20px; font-weight: 500; margin-top: 2px; overflow-wrap: anywhere; }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.dl { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); column-gap: 24px; }
.dl.dl-2 { grid-template-columns: 1fr; }
.dl-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.dl-row dt { color: var(--muted); }
.dl-row dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

.chart-box { height: 280px; width: 100%; position: relative; }
.chart-box.tall { height: 420px; }

.meters { display: flex; flex-direction: column; gap: 16px; }
.meter-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.meter-title { font-weight: 500; }
.meter-value { font-size: 13px; }
.meter { height: 8px; background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; background: var(--muted); }
.meter-fill.warn { background: var(--accent); }
.meter-fill.bad { background: var(--down); }
.meter-fill.good { background: var(--up); }
.meter-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl thead th { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl tbody th { font-weight: 500; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tr.dim td, .tbl tr.dim th { color: var(--muted); }
.tbl td a { text-decoration: none; color: var(--text); }
.tbl td a:hover { color: var(--accent); }
.side { font-size: 12.5px; font-weight: 500; }
.side-buy { color: var(--up); }
.side-sell { color: var(--down); }
.bar-cell { min-width: 120px; }
.span-2 { grid-column: 1 / -1; }
.bar-cell > .num { display: block; font-size: 13px; }
.bar { position: relative; height: 6px; background: var(--line); margin: 4px 0 3px; }
.bar-zero { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--muted); }
.bar-fill { position: absolute; top: 0; bottom: 0; }
.bar-fill.pos { background: var(--up); }
.bar-fill.neg { background: var(--down); }

.heat { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; }
.heat-cell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; padding: 2px 0; border: 1px solid var(--line); border-radius: 0; background: var(--surface); cursor: pointer; }
.heat-cell.pos { background: color-mix(in srgb, var(--up) calc(var(--i) * 55%), var(--surface)); }
.heat-cell.neg { background: color-mix(in srgb, var(--down) calc(var(--i) * 55%), var(--surface)); }
.heat-h { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }
.heat-n { font-size: 11px; font-family: var(--mono); }
.heat-detail { margin-top: 10px; min-height: 21px; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; align-items: end; }
.reset-btn { align-self: end; }
.filters-box > summary { cursor: pointer; font-weight: 600; min-height: 28px; list-style-position: inside; }
.filters-box[open] > summary { margin-bottom: 12px; }

/* ---------- calendar ---------- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cal-title { display: flex; flex-direction: column; align-items: center; text-align: center; }
.cal-title strong { font-size: 16px; }
.cal-title span { font-size: 12.5px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) 130px; gap: 2px; }
.cal-dow { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 0; }
.cal-cell { display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; min-height: 76px; padding: 6px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 0; text-align: left; min-width: 0; }
button.cal-cell { cursor: pointer; }
.cal-cell.out { background: transparent; border-color: transparent; }
.cal-cell.empty { color: var(--muted); }
.cal-cell.pos { background: color-mix(in srgb, var(--up) calc(var(--i) * 34%), var(--surface)); }
.cal-cell.neg { background: color-mix(in srgb, var(--down) calc(var(--i) * 34%), var(--surface)); }
.cal-cell.picked { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-day { font-size: 11.5px; color: var(--muted); }
.cal-pnl { font-size: 14px; font-weight: 500; align-self: center; }
.cal-cell.pos .cal-pnl { color: var(--up); }
.cal-cell.neg .cal-pnl { color: var(--down); }
.cal-n { font-size: 11px; color: var(--muted); align-self: flex-end; }
.cal-week { display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--bg); font-size: 13px; font-weight: 500; min-height: 76px; }
.cal-week-l { display: none; color: var(--muted); font-weight: 400; margin-right: 6px; font-family: var(--sans); }

/* ---------- settings ---------- */
.sess-row { display: grid; grid-template-columns: 1.1fr 1.4fr 0.8fr 0.8fr auto; gap: 12px; align-items: end; margin-bottom: 12px; }
.prio { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; max-width: 360px; }
.prio li { display: flex; align-items: center; gap: 6px; }
.prio li span { flex: 1; }
.tag-edit span { padding-right: 4px; }
.acc { border-top: 1px solid var(--line); padding: 14px 0; }
.acc:first-child { border-top: 0; padding-top: 0; }
.acc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login-brand { justify-content: center; margin-bottom: 20px; font-size: 17px; }
.login-card { display: flex; flex-direction: column; gap: 16px; padding: 24px; margin: 0; }
.code-input { font-family: var(--mono); letter-spacing: 0.3em; font-size: 18px; text-align: center; }

/* ---------- phone ---------- */
@media (max-width: 759.98px) {
  .app { display: block; }
  .sidebar { display: none; }
  body { font-size: 15px; }
  .topbar { padding: calc(10px + env(safe-area-inset-top)) 12px 10px; gap: 8px; }
  .account-select { flex: 1 1 auto; }
  #view { padding: 16px 12px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
  input[type='text'], input[type='number'], input[type='password'], input[type='date'], input[type='time'], input[type='file'], select, textarea { min-height: 44px; font-size: 16px; }
  .btn, .seg-btn, .tag, .tag-edit, .tag-x { min-height: 44px; }
  .icon-btn { min-width: 44px; }
  h1 { font-size: 20px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tabbar-h); color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 500; }
  .tabbar a[aria-current='page'] { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
  #toast { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); }
  .panel { padding: 12px; }
  .grid-2, .grid-main { grid-template-columns: minmax(0, 1fr); }
  .grid-2 > .panel, .grid-main > .panel { margin-bottom: 0; }
  .grid-2, .grid-main { gap: 12px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 18px; }
  .chart-box { height: 220px; }
  .chart-box.tall { height: 320px; }
  .dl { grid-template-columns: 1fr; }
  .form-row, .form-row.map, .filters { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .sess-row { grid-template-columns: 1fr 1fr; }
  .sess-row .sess-del { grid-column: 1 / -1; }
  .heat { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .heat-cell { min-height: 48px; }

  /* tables become card lists (breakdown tables stay compact tables) */
  .tbl:not(.brk) thead { display: none; }
  .tbl:not(.brk), .tbl:not(.brk) tbody { display: block; }
  .tbl:not(.brk) tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .tbl:not(.brk) tr:hover { background: transparent; }
  .tbl:not(.brk) td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; overflow-wrap: anywhere; }
  .tbl:not(.brk) td.r { text-align: left; }
  .tbl:not(.brk) td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-family: var(--sans); }
  .tbl:not(.brk) td:first-child { grid-column: span 2; order: -2; }
  .tbl:not(.brk) td:first-child a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 500; }
  .tbl:not(.brk) td:last-child { order: -1; text-align: right; }
  .tbl:not(.brk) td:last-child::before { text-align: right; }
  .tbl-wrap { overflow-x: visible; }

  .brk thead { display: none; }
  .brk, .brk tbody { display: block; }
  .brk tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .brk tr:hover { background: transparent; }
  .brk th, .brk td { display: block; padding: 0; border: 0; text-align: left; }
  .brk th.lbl { grid-column: 1 / 3; grid-row: 1; overflow-wrap: anywhere; }
  .brk .bar-cell { display: contents; }
  .brk .bar-cell > .num { grid-column: 3; grid-row: 1; text-align: right; }
  .brk .bar-cell > .bar { grid-column: 1 / -1; grid-row: 2; margin: 4px 0 6px; }
  .brk td.r { text-align: left; grid-row: 3; font-size: 13px; }
  .brk tr.dim td.r { display: none; }
  .brk td.r::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-family: var(--sans); }

  .cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
  .cal-wk-h { display: none; }
  .cal-cell { min-height: 56px; padding: 4px; align-items: center; }
  .cal-day { align-self: flex-start; font-size: 10.5px; }
  .cal-pnl { font-size: 12px; }
  .cal-n { display: none; }
  .cal-week { grid-column: 1 / -1; min-height: 32px; justify-content: flex-end; padding: 0 10px; margin-bottom: 6px; }
  .cal-week-l { display: inline; }
  .cal-week.none { display: none; }
}

@media (min-width: 760px) and (max-width: 1040px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .grid-2 { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
