:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #ffffff;
  --surface-2: #f3f3f0;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7d7b75;
  --line: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --brand: #1265af;
  --brand-soft: #e3eef8;
  --brand-ink: #0d4f8a;
  --accent-red: #ec1d26;
  --series: #1265af;
  --hero: #1265af;
  --series-dim: #9dc1e2;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 8px 24px rgba(11, 11, 11, 0.06);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242422;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --line: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --brand: #3987e5;
  --brand-soft: #14283f;
  --brand-ink: #8fbdf2;
  --series: #3987e5;
  --hero: #14457a;
  --series-dim: #24507f;
  --good-ink: #0ca30c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --line: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --brand: #3987e5;
    --brand-soft: #14283f;
    --brand-ink: #8fbdf2;
    --series: #3987e5;
  --hero: #14457a;
    --series-dim: #24507f;
    --good-ink: #0ca30c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brandrow { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; }
.brandrow img { width: 34px; height: 34px; }
.brandrow b { display: block; font-size: 14px; line-height: 1.15; }
.brandrow span { font-size: 11px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 550; }
.nav svg { width: 17px; height: 17px; flex: none; }
.nav:hover { background: var(--surface-2); color: var(--ink); }
.nav.on { background: var(--brand-soft); color: var(--brand-ink); }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 650; background: var(--surface-2); color: var(--ink-2); border-radius: 999px; padding: 1px 7px; }
.nav.on .count { background: var(--surface); }
.side .grow { flex: 1; }
.side .foot { padding: 8px; font-size: 12px; color: var(--muted); }
.main { min-width: 0; }
.demo { background: var(--brand-soft); color: var(--brand-ink); font-size: 12.5px; padding: 7px 28px; display: flex; gap: 12px; align-items: center; }
.demo button { margin-left: auto; }
.top { display: flex; align-items: center; gap: 10px; padding: 20px 28px 6px; }
.top .sub { color: var(--muted); font-size: 13px; }
.top .actions { margin-left: auto; display: flex; gap: 8px; }
.page { padding: 14px 28px 60px; display: grid; gap: 16px; }

/* controls */
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 7px 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.link { border: 0; background: none; color: var(--brand-ink); padding: 0; }
.btn:disabled { opacity: 0.5; cursor: default; }
input, select, textarea { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 7px 9px; min-width: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .nav:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form .wide { grid-column: 1 / -1; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.card > header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card > header .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.tiles { display: grid; grid-template-columns: 1.3fr repeat(4, 1fr); gap: 16px; }
.tile .label { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 4px; }
.tile .note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.hero { background: var(--hero); border-color: var(--hero); color: #fff; }
.tile.hero .label, .tile.hero .note { color: rgba(255, 255, 255, 0.85); }
.tile.hero .value { font-size: 52px; line-height: 1; margin-top: 8px; }

/* status */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.chip.good i { background: var(--good); }
.chip.warning i { background: var(--warning); }
.chip.serious i { background: var(--serious); }
.chip.critical i { background: var(--critical); }
.chip.brand i { background: var(--brand); }
.alert { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); align-items: flex-start; cursor: pointer; }
.alert:first-of-type { border-top: 0; }
.alert .ico { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: var(--muted); }
.alert.critical .ico { background: var(--critical); }
.alert.serious .ico { background: var(--serious); }
.alert.warning .ico { background: var(--warning); color: #3b2a00; }
.alert.info .ico { background: var(--brand); }
.alert b { display: block; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }

/* tables and lists */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.scroll { overflow-x: auto; }
.row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row .time { width: 48px; font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; flex: none; }
.row .what { min-width: 0; flex: 1; }
.row .what b { display: block; }
.meter { height: 8px; border-radius: 4px; background: var(--brand-soft); overflow: hidden; min-width: 80px; }
.meter span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }

/* schedule board */
.board { display: grid; grid-template-columns: 84px repeat(7, minmax(120px, 1fr)); gap: 6px; min-width: 980px; }
.board .head { font-size: 12px; font-weight: 650; color: var(--ink-2); padding: 4px 6px; }
.board .head.today { color: var(--brand-ink); }
.board .crew { font-size: 12px; font-weight: 650; padding: 8px 6px; color: var(--ink-2); }
.board .cell { background: var(--surface-2); border-radius: 8px; padding: 6px; display: grid; gap: 6px; align-content: start; min-height: 64px; }
.board .cell.today { outline: 1.5px solid var(--brand); outline-offset: -1px; }
.job { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: 7px; padding: 6px 8px; font-size: 12px; cursor: pointer; text-align: left; width: 100%; }
.job:hover { box-shadow: var(--shadow); }
.job b { display: block; font-size: 12.5px; }
.job.done { border-left-color: var(--good); opacity: 0.8; }
.job.reclean { border-left-color: var(--critical); }
.job.progress { border-left-color: var(--warning); }

/* kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 12px; }
.col { background: var(--surface-2); border-radius: 12px; padding: 10px; display: grid; gap: 10px; align-content: start; }
.col > h3 { display: flex; justify-content: space-between; color: var(--ink-2); padding: 2px 4px; }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 6px; }
.q .amount { font-size: 18px; font-weight: 650; }
.inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* payroll */
.sheet input { width: 46px; padding: 4px; text-align: center; border-radius: 6px; }
.sheet th, .sheet td { padding: 4px 3px; text-align: center; }
.sheet td:first-child, .sheet th:first-child { text-align: left; padding-left: 8px; white-space: nowrap; position: sticky; left: 0; background: var(--surface); }
.sheet .wkend { background: var(--surface-2); }
.ded { width: 68px; text-align: right; padding: 4px 6px; }
.payrun th, .payrun td { padding-left: 6px; padding-right: 6px; }
.check { display: flex; gap: 10px; padding: 7px 0; align-items: flex-start; }
.check .mark { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; background: var(--good); }
.check.bad .mark { background: var(--critical); }
tfoot td { font-weight: 650; border-top: 2px solid var(--axis); }

/* chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .bar { fill: var(--series-dim); }
.chart .bar.today { fill: var(--series); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .hit:focus + .bar { filter: brightness(0.92); }
.chart text { fill: var(--muted); font-size: 11px; }
.chart text.val { fill: var(--ink); font-weight: 650; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--page); border-radius: 8px; padding: 6px 9px; font-size: 12px; transform: translate(-50%, -100%); white-space: nowrap; opacity: 0; transition: opacity 0.1s; }
.tip.on { opacity: 1; }

/* assistant */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 100vw; background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; transform: translateX(105%); transition: transform 0.18s ease; z-index: 20; }
.drawer.open { transform: none; }
.drawer header { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer header .btn { margin-left: auto; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 10px; align-content: start; }
.msg { max-width: 88%; padding: 9px 12px; border-radius: 12px; white-space: pre-wrap; }
.msg.user { justify-self: end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { background: var(--surface-2); border-bottom-left-radius: 4px; }
.proposal { border: 1px solid var(--brand); border-radius: 12px; padding: 12px; display: grid; gap: 8px; background: var(--brand-soft); }
.proposal dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12.5px; }
.proposal dt { color: var(--ink-2); }
.proposal dd { margin: 0; font-weight: 600; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.ask { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.ask input { flex: 1; }

/* dialogs, login, toast */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 20px; background: var(--surface); color: var(--ink); width: min(560px, 92vw); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog h2 { margin-bottom: 14px; font-size: 17px; }
dialog .end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 28px; display: grid; gap: 14px; text-align: center; }
.login img { width: 64px; margin: 0 auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--page); padding: 9px 14px; border-radius: 10px; font-weight: 600; z-index: 40; }
.err { color: var(--critical); font-weight: 600; }
.empty { color: var(--muted); padding: 14px 0; text-align: center; }
.statement { border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; break-inside: avoid; }

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile.hero { grid-column: 1 / -1; }
  .grid2 { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; align-items: center; }
  .brandrow { padding: 0 8px 0 4px; }
  .brandrow div, .side .grow, .side .foot, .nav .count { display: none; }
  .nav { white-space: nowrap; }
  .top, .page, .demo { padding-left: 14px; padding-right: 14px; }
  .top { flex-wrap: wrap; }
  .kanban, .form { grid-template-columns: 1fr; }
}
@media print {
  .side, .top, .demo, .drawer, .noprint { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  dialog { position: static; border: 0; box-shadow: none; width: 100%; }
}
