/* BizTeman – recommended design: accountant workspace (dark rail + client list + client tabs),
 * owner-friendly overview, printable report. Loaded after styles.css; its tokens override the old palette. */

:root {
  --bg: #F5F4EF; --surface: #FFFFFF; --fg: #16201E; --muted: #5B6764; --line: #E2E0D8; --thead: #F8F7F3;
  --accent: #0F6B5A; --onaccent: #FFFFFF; --accent-bg: #E4F0EC;
  --ok: #1D7247; --ok-bg: #E3F1E8; --warn: #8A4C00; --warn-bg: #FBF0DC; --bad: #B0281F; --bad-bg: #FBE6E3;
  --warn-strong: #C77800; --track: #EEECE5;
  --rail: #16201E; --rail-fg: #D3DBD8; --rail-muted: #A9B6B2; --rail-on: #26312F; --rail-accent: #3FB79B;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", Inter, system-ui, sans-serif;
  --r: 14px; --r-sm: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1513; --surface: #151E1C; --fg: #E6EDEA; --muted: #9AA8A4; --line: #26322F; --thead: #121A18;
    --accent: #43C0A9; --onaccent: #06201A; --accent-bg: #163631;
    --ok: #55C78C; --ok-bg: #15322A; --warn: #E6B341; --warn-bg: #3A2F12; --bad: #F07A63; --bad-bg: #3C1E19;
    --warn-strong: #E6B341; --track: #24302D;
    --rail: #0A100F; --rail-fg: #C9D3D0; --rail-muted: #85948F; --rail-on: #1C2725;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1513; --surface: #151E1C; --fg: #E6EDEA; --muted: #9AA8A4; --line: #26322F; --thead: #121A18;
  --accent: #43C0A9; --onaccent: #06201A; --accent-bg: #163631;
  --ok: #55C78C; --ok-bg: #15322A; --warn: #E6B341; --warn-bg: #3A2F12; --bad: #F07A63; --bad-bg: #3C1E19;
  --warn-strong: #E6B341; --track: #24302D;
  --rail: #0A100F; --rail-fg: #C9D3D0; --rail-muted: #85948F; --rail-on: #1C2725;
  color-scheme: dark;
}

body { font: 14px/1.5 var(--font); font-feature-settings: "tnum" 1; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; }

/* ---------- shell: rail | client list | stage ---------- */
.app { display: flex; min-height: 100vh; align-items: stretch; }
.rail {
  flex: 0 0 216px; background: var(--rail); color: var(--rail-fg); padding: 18px 12px;
  display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; box-sizing: border-box;
}
.rail .logo { display: flex; justify-content: flex-start; align-items: center; gap: 8px; padding: 4px 10px 6px; color: #FFFFFF; text-decoration: none; font: 700 18px var(--display); width: auto; }
.rail .logo i { width: 24px; height: 24px; border-radius: 7px; background: var(--rail-accent); display: inline-block; }
.rail .org { padding: 2px 10px 16px; font-size: 12px; color: var(--rail-muted); border: 0; background: transparent; }
.rail-links { display: flex; flex-direction: column; gap: 2px; }
.rail a { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 10px; border-radius: 8px; color: var(--rail-fg); text-decoration: none; }
.rail a:hover { background: var(--rail-on); }
.rail a.on { background: var(--rail-on); color: #FFFFFF; font-weight: 600; }
.rail .cnt { font-size: 12px; color: var(--rail-muted); }
.rail .due { font-size: 12px; background: #B0281F; color: #FFFFFF; padding: 1px 7px; border-radius: 999px; }
.rail .sec { font: 600 11px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--rail-muted); padding: 14px 10px 6px; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.theme-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; font-size: 12px; color: var(--rail-muted); }
.rail .theme-select { border: 1px solid #3A4744; border-radius: 8px; padding: 4px 8px; background: transparent; color: var(--rail-fg); font-size: 12px; }
#user-menu { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; color: var(--rail-fg); font-size: 12px; }
#user-menu .um-name { color: #FFFFFF; }
#user-menu .um-role { color: var(--rail-muted); }
#user-menu .btn { background: transparent; color: var(--rail-fg); border-color: #3A4744; }

.clients { flex: 0 0 316px; width: 316px; min-width: 0; overflow: hidden; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; box-sizing: border-box; }
.clients-head { padding: 16px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.client-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.client-row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 16px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); text-align: left; color: var(--fg); }
.client-row:hover { background: var(--thead); }
.client-row[aria-current="true"] { background: var(--accent-bg); box-shadow: inset 3px 0 0 var(--accent); }
.client-row .sc { flex: 0 0 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font: 700 15px var(--display); }
.client-row .nm { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.client-row .nm b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-row .nm small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-row .dl { font: 600 12px var(--font); white-space: nowrap; }
.sc.ok { background: var(--ok-bg); color: var(--ok); } .sc.warn { background: var(--warn-bg); color: var(--warn); }
.sc.bad { background: var(--bad-bg); color: var(--bad); } .sc.na { background: var(--thead); color: var(--muted); }
.client-empty { padding: 20px 16px; color: var(--muted); font-size: 13px; }

.stage { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.banner { position: sticky; top: 0; }
main.content { padding: 22px 28px 48px; gap: 18px; max-width: 1240px; width: 100%; box-sizing: border-box; }

/* ---------- client header + tabs ---------- */
.chead { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.chead .crumb { font-size: 13px; }
.chead h1 { font: 700 26px/1.2 var(--display); margin: 2px 0 4px; }
.chead .meta { font-size: 13px; color: var(--muted); }
.ctabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); }
.ctabs a { padding: 10px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.ctabs a:hover { color: var(--fg); }
.ctabs a.on { color: var(--fg); font-weight: 600; border-bottom-color: var(--accent); }

.btn { font: 600 13px var(--font); min-height: 40px; padding: 0 14px; border-radius: var(--r-sm); justify-content: center; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 12px; }
.card { border-radius: var(--r); }
.pill { font: 600 12px/1 var(--font); padding: 5px 10px; }
.input, .select { border-radius: 8px; min-height: 40px; padding: 0 12px; background: var(--surface); }
.lbl { font-size: 12px; color: var(--muted); }

/* ---------- overview ---------- */
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 24px; display: flex; flex-wrap: wrap; gap: 28px; }
.hero-score { flex: 0 0 190px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.hero-score .grade { font: 700 15px var(--display); padding: 5px 12px; border-radius: 999px; }
.hero-score small { font-size: 13px; color: var(--muted); }
.hero-main { flex: 999 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.eyebrow { font: 600 12px var(--font); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.hero-main h2 { font: 700 28px/1.15 var(--display); }
.hero-main p { color: var(--muted); max-width: 66ch; }
.hero-main h3 { font: 600 15px var(--font); margin-top: 6px; }
.todos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.todo { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--thead); }
.todo .txt { flex: 1 1 260px; min-width: 0; }
.todo .gain { font: 600 13px var(--font); color: var(--ok); background: var(--ok-bg); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.prio { font: 700 12px var(--font); color: var(--accent); background: var(--accent-bg); padding: 4px 8px; border-radius: 6px; }
.pillar-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.pcard .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pcard h3 { font: 600 15px var(--font); }
.pcard p { font-size: 13px; color: var(--muted); }
.bar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; }
.row2 { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
.row2 > .grow { flex: 999 1 420px; min-width: 0; }
.row2 > .side { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.panel h3 { font: 600 15px var(--font); }
.panel .note { font-size: 12px; color: var(--muted); }
.advice { background: var(--accent-bg); border-color: transparent; }
.advice h4 { font: 700 17px var(--display); margin: 0; }
.dates { display: flex; flex-direction: column; gap: 10px; }
.date { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.date .when { flex: 0 0 66px; text-align: center; font: 600 12px var(--font); padding: 6px 0; border-radius: 8px; background: var(--thead); }
.date .when.urgent { background: var(--bad-bg); color: var(--bad); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kv div small { display: block; font-size: 12px; color: var(--muted); }
.kv div b { font: 700 20px var(--display); }

/* ---------- generic tab content ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat small { font-size: 12px; color: var(--muted); }
.stat b { font: 700 24px/1.2 var(--display); }
.stat span { font-size: 12px; color: var(--muted); }
.statusline { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-top: 1px solid var(--line); }
.statusline:first-child { border-top: 0; }
.statusline .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.statusline .body small { color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { min-height: 38px; padding: 0 12px; border: 0; background: var(--surface); color: var(--fg); font: 600 13px var(--font); }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.forecast { position: relative; height: 180px; display: flex; align-items: flex-end; gap: 10px; border-bottom: 1px solid var(--fg); padding: 0 4px; }
.forecast i { flex: 1; border-radius: 3px 3px 0 0; display: block; }
.forecast .buffer { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--bad); }
.forecast .buffer span { position: absolute; right: 4px; top: -20px; font-size: 12px; color: var(--bad); background: var(--surface); padding: 0 4px; }
.forecast-x { display: flex; gap: 10px; padding: 0 4px; }
.forecast-x span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.draft { white-space: pre-wrap; margin: 0; font: 13px/1.55 var(--font); padding: 14px 16px; background: var(--thead); border-radius: 10px; overflow-wrap: anywhere; }
.qrbox { width: 112px; height: 112px; display: grid; place-items: center; background: #FFFFFF; border-radius: 6px; padding: 6px; box-sizing: border-box; }
.qrbox img, .qrbox canvas { width: 100px; height: 100px; }

/* ---------- owner view ---------- */
.owner { max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; width: 100%; }
.owner .ohead { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.owner .card-o { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; gap: 14px; align-items: center; }
.owner .step { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.owner .step b.n { font: 700 14px var(--display); color: var(--accent); }
.owner .btn { min-height: 48px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .clients { flex-basis: 260px; }
}
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .rail { position: static; height: auto; flex: none; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 12px; gap: 4px; }
  .rail .org, .rail .sec, .theme-row { display: none; }
  .rail-links { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; flex: 1 1 100%; order: 3; }
  .rail a { white-space: nowrap; min-height: 40px; }
  .rail-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .rail-foot a { display: none; }
  .clients { display: none; }
  main.content { padding: 16px 16px 40px; }
  .hero { padding: 16px; gap: 16px; }
  .hero-score { flex-basis: 100%; }
  .hero-main h2 { font-size: 22px; }
  .chead h1 { font-size: 22px; }
  .ctabs { flex-wrap: nowrap; overflow-x: auto; }
}
@media print {
  .rail, .clients, .banner { display: none !important; }
}
