/* KerkKas v2 — calm ledger UI. Light first, dark follows the phone. */
:root {
  --bg: #F3F5F7; --surface: #FFFFFF; --sunk: #E9EDF1; --line: #D6DDE3;
  --fg: #13202B; --muted: #5A6B7A; --faint: #8796A3;
  --accent: #0E6A86; --accent-fg: #FFFFFF; --accent-soft: #DCEEF4;
  --seal: #9A6A0E; --seal-soft: #F7EDD7;
  --good: #1F7A4D; --good-soft: #DFF2E7; --warn: #A45B00; --warn-soft: #FBEBD5;
  --bad: #B4362B; --bad-soft: #F9E0DC;
  --shadow: 0 1px 2px rgba(19,32,43,.06), 0 4px 16px rgba(19,32,43,.05);
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F161C; --surface: #162029; --sunk: #1D2933; --line: #2A3946;
    --fg: #E6EDF2; --muted: #9AACBA; --faint: #6F8292;
    --accent: #5BB8D4; --accent-fg: #0B1A21; --accent-soft: #16384A;
    --seal: #E3B556; --seal-soft: #3A2E14;
    --good: #5CC48F; --good-soft: #143224; --warn: #E9A04A; --warn-soft: #3A2810;
    --bad: #F07A6E; --bad-soft: #3D1A17;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 16px;
  line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-mark, .logo {
  width: 52px; height: 52px; border-radius: 14px; background: var(--accent); color: var(--accent-fg);
  display: grid; place-items: center; font-weight: 800; font-size: 26px; letter-spacing: -.02em;
}
.logo.sm { width: 34px; height: 34px; font-size: 18px; border-radius: 10px; }

/* ---------- layout */
.app { min-height: 100vh; }
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.main { padding: 0 16px calc(var(--nav-h) + 96px + env(safe-area-inset-bottom, 0px)); max-width: 760px; width: 100%; margin: 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; display: flex; align-items: center; gap: 12px;
}
.topbar .titles { min-width: 0; flex: 1; }
.topbar h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; min-width: 40px; height: 40px;
  display: inline-grid; place-items: center; cursor: pointer; padding: 0 12px; font-size: 14px; font-weight: 600;
}
.back { font-size: 20px; padding: 0; width: 40px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
}
.nav a {
  display: grid; justify-items: center; gap: 2px; text-decoration: none; color: var(--muted);
  font-size: 12px; font-weight: 600; padding: 6px 0; border-radius: 12px;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.on { color: var(--accent); }
.nav .side-only { display: none; }
.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); z-index: 31;
  background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 999px; padding: 14px 18px;
  font-weight: 700; display: flex; gap: 8px; align-items: center; box-shadow: 0 6px 20px rgba(14,106,134,.35);
  text-decoration: none; font-size: 15px;
}
.fab svg { width: 20px; height: 20px; }

@media (min-width: 960px) {
  .shell { grid-template-columns: 240px 1fr; }
  .main { padding: 8px 40px 60px; max-width: 980px; margin: 0; }
  .topbar { padding: 22px 40px 14px; }
  .nav {
    position: sticky; top: 0; height: 100vh; border-top: 0; border-right: 1px solid var(--line);
    grid-template-columns: 1fr; grid-auto-rows: min-content; align-content: start; gap: 4px; padding: 22px 14px;
  }
  .nav a { grid-template-columns: 24px 1fr; justify-items: start; align-items: center; gap: 12px; font-size: 15px; padding: 10px 12px; }
  .nav a.on { background: var(--accent-soft); }
  .nav .brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; font-weight: 800; font-size: 18px; }
  .nav .side-only { display: grid; }
  .nav .side-sep { height: 1px; background: var(--line); margin: 10px 8px; }
  .fab { display: none; }
  .content-wide { max-width: none; }
}
.nav .brand { display: none; }
@media (min-width: 960px) { .nav .brand { display: flex; } }

/* ---------- blocks */
.stack { display: grid; gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); min-width: 0;
}
.card.flat { box-shadow: none; }
.card h2, .h2 { font-size: 17px; margin: 0 0 4px; letter-spacing: -.01em; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 2px 8px; }
.section-title h2 { font-size: 15px; margin: 0; }
.big { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.mid { font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .grid4 { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 960px) { .cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.stat .v { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.stat .k { font-size: 12px; color: var(--muted); }
.in { color: var(--good); } .out { color: var(--bad); }

/* job card */
.job { border: 1.5px solid var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.job .eyebrow { color: var(--accent); font-weight: 700; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
.job h2 { font-size: 20px; margin: 6px 0 4px; }
.progress { height: 6px; background: var(--sunk); border-radius: 99px; overflow: hidden; margin: 10px 0 2px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* seal */
.seal { display: flex; gap: 14px; align-items: center; background: var(--seal-soft); border: 1.5px solid var(--seal); }
.seal .ring {
  flex: 0 0 48px; height: 48px; border-radius: 50%; border: 2.5px solid var(--seal); color: var(--seal);
  display: grid; place-items: center; position: relative;
}
.seal .ring svg { width: 24px; height: 24px; }
.seal .ring::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; border: 1px dashed var(--seal); opacity: .5; }
.seal b { display: block; font-size: 16px; }
.seal.pending { background: var(--sunk); border-color: var(--line); }
.seal.pending .ring { border-color: var(--faint); color: var(--faint); }
.seal.broken { background: var(--bad-soft); border-color: var(--bad); }
.seal.broken .ring { border-color: var(--bad); color: var(--bad); }

/* buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 999px;
  padding: 12px 18px; font-weight: 650; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; text-decoration: none; min-height: 46px; font-size: 15px;
}
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.seal-btn { background: var(--seal); color: #fff; border-color: var(--seal); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 7px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* pills / chips */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.seal { background: var(--seal-soft); color: var(--seal); border: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-size: 14px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* lists */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.item:last-child { border-bottom: 0; }
.item.tap { cursor: pointer; }
.item.tap:hover { background: var(--sunk); }
.item .t { font-weight: 600; overflow-wrap: anywhere; }
.item .m { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.item .a { text-align: right; font-weight: 650; white-space: nowrap; }
.item.flag { background: var(--warn-soft); }
.list-head { padding: 10px 14px; background: var(--sunk); font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }

/* stepper */
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 2px; }
.stepper div { border-top: 3px solid var(--line); padding-top: 6px; font-size: 12px; color: var(--faint); font-weight: 600; }
.stepper .done { border-color: var(--good); color: var(--good); }
.stepper .now { border-color: var(--accent); color: var(--accent); }

/* checks */
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; }
.check .dot { flex: 0 0 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.check .dot.ok { background: var(--good-soft); color: var(--good); }
.check .dot.no { background: var(--bad-soft); color: var(--bad); }
.check .dot.wait { background: var(--sunk); color: var(--faint); }

/* forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px; min-height: 48px;
}
.input:focus { outline: none; border-color: var(--accent); }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.checkbox input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); }
.err { color: var(--bad); font-size: 14px; min-height: 20px; }
.hint { font-size: 13px; color: var(--muted); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: min(420px, 100%); padding: 26px 22px; }
.auth h1 { font-size: 26px; margin: 14px 0 4px; letter-spacing: -.02em; }

/* drop */
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 30px 16px; text-align: center; cursor: pointer;
  background: var(--surface); display: grid; gap: 6px; justify-items: center;
}
.drop.drag, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { width: 36px; height: 36px; color: var(--accent); }

/* review card */
.review { display: grid; gap: 14px; }
.review .rawbox { background: var(--sunk); border-radius: 12px; padding: 12px; font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.review .amount { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.review-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }

/* charts */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: 14px; }
.bar-row .track { grid-column: 1 / -1; height: 8px; background: var(--sunk); border-radius: 99px; overflow: hidden; }
.bar-row .track svg { display: block; width: 100%; height: 8px; }

/* vra */
.qa { display: grid; gap: 10px; }
.bubble { padding: 12px 14px; border-radius: 16px; max-width: 92%; overflow-wrap: anywhere; }
.bubble.q { justify-self: end; background: var(--accent); color: var(--accent-fg); border-bottom-right-radius: 4px; }
.bubble.a { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.askbar { display: flex; gap: 8px; }
.askbar .input { flex: 1; }

/* sheet (modal) */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(8,14,18,.45); z-index: 50; display: grid; align-items: end; }
@media (min-width: 640px) { .sheet-backdrop { place-items: center; } }
.sheet {
  background: var(--surface); width: 100%; max-width: 520px; border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  max-height: 90vh; overflow: auto; margin: 0 auto;
}
@media (min-width: 640px) { .sheet { border-radius: 20px; } }
.sheet h2 { margin: 4px 0 12px; font-size: 19px; }

/* toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom, 0px));
  background: var(--fg); color: var(--bg); padding: 12px 18px; border-radius: 12px; z-index: 60; font-weight: 600; max-width: 90vw;
}
.toast.bad { background: var(--bad); color: #fff; }

.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.center { display: grid; place-items: center; padding: 40px 0; }
.mt { margin-top: 12px; } .mt2 { margin-top: 20px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
code.key { font-family: var(--mono); font-size: 12px; background: var(--sunk); padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere; }

/* print: board pack only */
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  .nav, .fab, .topbar .iconbtn, .no-print, #toast { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .card, .list, .stat { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  .topbar { position: static; padding: 0 0 10px; background: #fff; }
}
.col { min-width: 0; }
.btn svg { width: 20px; height: 20px; flex: 0 0 auto; }
.iconbtn svg { width: 20px; height: 20px; }
a.iconbtn, a.chip, a.card { text-decoration: none; color: inherit; }
a.card { display: block; }
.stat .v { white-space: nowrap; font-size: clamp(14px, 4vw, 17px); overflow-wrap: normal; }
@media (min-width: 960px) {
  .main { max-width: 1180px; }
  .cols > .stack:first-child .grid4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1280px) { .cols > .stack:first-child .grid4 { grid-template-columns: repeat(4, 1fr); } }
.grid3 .stat .v { font-size: clamp(12px, 3.4vw, 17px); }
.chips:not(.scroll) .chip { white-space: normal; text-align: left; max-width: 100%; }
