:root {
  --ink: #15222B; --muted: #5E6B75; --line: #E3E8EC; --bg: #F5F7F8; --card: #FFFFFF;
  --brand: #0F4C5C; --brand-ink: #FFFFFF; --accent: #E8871E; --good: #1E8A5B; --warn: #C98A00; --bad: #C62828;
  --chip: #EEF2F4; --radius: 14px; --tab-h: 62px; --font: -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Gujarati", "Noto Sans Devanagari", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--font); -webkit-text-size-adjust: 100%; }
body { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 17px; margin: 0 0 8px; } h3 { font-size: 15px; margin: 0 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
#app { max-width: 720px; margin: 0 auto; padding: 0 14px 20px; }
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(10px + env(safe-area-inset-top)) 0 8px; display: flex; align-items: center; gap: 10px; }
.topbar .back { background: none; border: 0; font-size: 22px; padding: 4px 8px 4px 0; }
.topbar .grow { flex: 1; }
#offline { position: fixed; left: 0; right: 0; top: 0; z-index: 30; background: var(--warn); color: #1F1600; font-size: 13px; font-weight: 600; text-align: center; padding: 6px 12px; }
#offline[hidden] { display: none; }
body.is-offline { padding-top: 30px; }
body.is-offline .topbar { top: 30px; }
.bell { position: relative; background: none; border: 0; font-size: 20px; padding: 4px 6px; cursor: pointer; line-height: 1; }
.bell .badge { position: absolute; top: -2px; right: -4px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; min-width: 16px; height: 16px; padding: 0 4px; display: inline-grid; place-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.card.tight { padding: 8px 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .big { font-size: 20px; font-weight: 700; } .mono { font-variant-numeric: tabular-nums; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow > .ellipsis { display: block; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 14px; font-weight: 600; min-height: 44px; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.good { background: var(--good); color: #fff; border-color: var(--good); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.icon-btn { background: none; border: 0; font-size: 22px; padding: 4px 8px; }
.fab { position: fixed; right: 18px; bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: #fff; border: 0; font-size: 28px; box-shadow: 0 6px 18px rgba(0,0,0,.2); z-index: 6; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--chip); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.good { background: #E3F4EA; color: var(--good); } .chip.warn { background: #FFF3D6; color: #8A5B00; } .chip.bad { background: #FDE3E3; color: var(--bad); } .chip.brand { background: #E1EEF1; color: var(--brand); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips .chip { padding: 8px 12px; font-size: 14px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.chips .chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.list .item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.list .item:first-child { border-top: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #E1EEF1; color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.kpi .v { font-size: 20px; font-weight: 700; } .kpi .l { font-size: 12px; color: var(--muted); }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.field { padding: 8px 0; border-top: 1px solid var(--line); }
.field:first-child { border-top: 0; }
.field .k { font-size: 12px; color: var(--muted); } .field .v { font-size: 15px; font-weight: 600; word-break: break-word; }
.conf { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }
.conf.high { background: var(--good); } .conf.medium { background: var(--warn); } .conf.low { background: var(--bad); }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); transition: width .4s; }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 10px 0; }
.empty { text-align: center; color: var(--muted); padding: 24px 10px; }
.search { position: relative; }
.search input { padding-left: 36px; }
.search:before { content: "\1F50D"; position: absolute; left: 12px; top: 12px; font-size: 14px; opacity: .6; }
#tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); display: flex; z-index: 7; }
#tabs button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
#tabs button .ic { font-size: 20px; line-height: 1; }
#tabs button.on { color: var(--brand); }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); background: #15222B; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: 90vw; font-size: 14px; }
#toast.err { background: var(--bad); }
#sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 15; display: flex; align-items: flex-end; }
.sheet-card { background: var(--card); width: 100%; max-width: 720px; margin: 0 auto; border-radius: 18px 18px 0 0; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.login { max-width: 420px; margin: 12vh auto 0; }
.logo { width: 56px; height: 56px; border-radius: 14px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 26px; }
.evidence { font-size: 12px; color: var(--muted); background: var(--chip); padding: 6px 8px; border-radius: 8px; margin-top: 4px; white-space: pre-wrap; }
.tabs2 { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.tabs2 button { flex: 1; background: none; border: 0; padding: 10px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs2 button.on { color: var(--brand); border-bottom-color: var(--brand); }
.menu .item { padding: 14px 0; font-size: 16px; }
.menu .item .ic { width: 28px; text-align: center; }
#print-area { display: none; }
@media print {
  body { background: #fff; padding: 0; } #app, #tabs, #toast, #sheet, .fab { display: none !important; }
  #print-area { display: block; font: 12px/1.4 Georgia, serif; color: #000; }
  .doc-head { display: flex; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 10px; }
  table.rpt { width: 100%; border-collapse: collapse; } table.rpt th, table.rpt td { border: 1px solid #000; padding: 4px 6px; font-size: 11px; } table.rpt th { background: #E9E5DB; }
  @page { size: A4 portrait; margin: 12mm; }
}
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Dark theme (system preference, or chosen in More → Appearance) ---------- */
:root[data-theme="dark"] { --chip-strong: #2C3942; --ink: #E8EEF2; --muted: #9AA8B2; --line: #263038; --bg: #0F1418; --card: #161D23; --chip: #202A32; --brand: #2A7D93; --accent: #F0953A; --good: #3DBA7E; --warn: #E0A030; --bad: #E05A5A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chip-strong: #2C3942; --ink: #E8EEF2; --muted: #9AA8B2; --line: #263038; --bg: #0F1418; --card: #161D23; --chip: #202A32; --brand: #2A7D93; --accent: #F0953A; --good: #3DBA7E; --warn: #E0A030; --bad: #E05A5A; } }
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background: var(--card); color: var(--ink); color-scheme: dark; }
:root[data-theme="dark"] .avatar, :root[data-theme="dark"] .chip.brand { background: #1F3A44; color: #9FD3E2; }
:root[data-theme="dark"] .chip.good { background: #173A2A; color: #7FE0AE; } :root[data-theme="dark"] .chip.warn { background: #3E2F10; color: #F3C66B; } :root[data-theme="dark"] .chip.bad { background: #44201F; color: #F59A9A; }
:root[data-theme="dark"] #toast { background: #E8EEF2; color: #0F1418; } :root[data-theme="dark"] #toast.err { background: var(--bad); color: #fff; }
:root[data-theme="dark"] .evidence { background: #202A32; }
:root[data-theme="dark"] .topbar { background: var(--bg); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) input, :root:not([data-theme="light"]) select, :root:not([data-theme="light"]) textarea { background: var(--card); color: var(--ink); color-scheme: dark; }
  :root:not([data-theme="light"]) .avatar, :root:not([data-theme="light"]) .chip.brand { background: #1F3A44; color: #9FD3E2; }
  :root:not([data-theme="light"]) .chip.good { background: #173A2A; color: #7FE0AE; } :root:not([data-theme="light"]) .chip.warn { background: #3E2F10; color: #F3C66B; } :root:not([data-theme="light"]) .chip.bad { background: #44201F; color: #F59A9A; }
  :root:not([data-theme="light"]) #toast { background: #E8EEF2; color: #0F1418; } :root:not([data-theme="light"]) #toast.err { background: var(--bad); color: #fff; }
  :root:not([data-theme="light"]) .evidence { background: #202A32; }
}
.btn.primary, .btn.accent, .btn.good, .chips .chip.on, .fab { color: #fff !important; }

/* ---------- Desktop: left navigation, wide two-column screens, centred sheets ---------- */
@media (min-width: 900px) {
  body { padding-bottom: 24px; }
  #tabs { top: 0; bottom: 0; right: auto; width: 232px; height: auto; flex-direction: column; justify-content: flex-start; padding: 18px 12px; gap: 4px; border-top: 0; border-right: 1px solid var(--line); }
  #tabs::before { content: "PolicyBook"; display: block; font-weight: 800; font-size: 20px; color: var(--brand); padding: 6px 12px 16px; }
  #tabs button { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 15px; padding: 10px 12px; border-radius: 10px; width: 100%; }
  #tabs button .ic { font-size: 18px; width: 22px; text-align: center; }
  #tabs button.on { background: var(--chip); }
  #app { margin-left: 232px; max-width: none; padding: 8px 32px 32px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-content: start; }
  #app > * { grid-column: 1 / -1; min-width: 0; }
  #app > .card:has(.field):not(:has(.list)):not(:has(.grid2)):not(:has(table)):not(:has(svg)) { grid-column: auto; }   /* field groups sit side by side */
  #app[data-view="today"] > .card.tight:has(h3) { grid-column: auto; }                                                  /* today's lists in two columns */
  #app[data-view="more"] > .card.tight.menu { max-width: 720px; }
  body.noauth #app { margin-left: 0; display: block; }
  #app > .login { margin: 12vh auto 0; width: 420px; }
  .topbar { padding-top: 18px; }
  .topbar h1 { font-size: 24px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .fab { right: 32px; bottom: 32px; }
  #sheet { align-items: center; justify-content: center; }
  .sheet-card { width: 560px; border-radius: 18px; max-height: 86vh; }
  #toast { bottom: 32px; }
  .list .item { padding: 12px 6px; border-radius: 8px; }
  .list .item:hover { background: var(--chip); }
  #app > .chips { overflow: visible; flex-wrap: wrap; }
  .actions { grid-template-columns: repeat(auto-fit, minmax(150px, max-content)); }
  .actions .btn { white-space: nowrap; padding-left: 18px; padding-right: 18px; }
}
@media (min-width: 1400px) { #app { padding: 8px 48px 48px; max-width: 1280px; } }

/* ---------- charts (web/js/charts.js) ---------- */
.grid2c { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 600px) { .grid2c { grid-template-columns: 1fr 1fr; gap: 0 12px; } }
.hbars { display: grid; gap: 8px; }
.hb-l { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; } .hb-l .ellipsis { max-width: 70%; }
.hb-t { height: 10px; background: var(--chip); border-radius: 999px; overflow: hidden; margin-top: 3px; }
.hb-f { height: 100%; border-radius: 999px; transition: width .4s ease; }
.hb-s { margin-top: 2px; }
.up { color: var(--good); font-weight: 600; } .down { color: var(--bad); font-weight: 600; }
.donut { display: flex; align-items: center; gap: 14px; }
.legend { display: grid; gap: 4px; font-size: 13px; min-width: 0; flex: 1; }
.legend.row { display: flex; }
.lg { display: flex; align-items: center; gap: 6px; min-width: 0; } .lg i { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; } .lg b { margin-left: auto; }
.legend.row .lg b { margin-left: 4px; }
.sharebar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--chip); margin: 6px 0 8px; } .sharebar i { display: block; height: 100%; }
.columns text { font-family: inherit; }
.ygrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ym { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; cursor: pointer; } .ym.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; }
.ym-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.ym-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.ym-g i { display: block; aspect-ratio: 1; border-radius: 3px; background: var(--chip); }
.ym-g i.pad { background: transparent; }
.ym-g i.l1 { background: #9FD3E2; } .ym-g i.l2 { background: #2A7D93; } .ym-g i.l3 { background: var(--accent); }
.ym-g i.done { background: var(--good); } .ym-g i.today { outline: 2px solid var(--ink); outline-offset: -2px; }
.kpi .l .up, .kpi .l .down { font-size: 11px; }
.stage-row { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 6px; scrollbar-width: none; } .stage-row::-webkit-scrollbar { display: none; }
.stage { flex: none; min-width: 92px; padding: 8px 10px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); cursor: pointer; } .stage.on { border-color: var(--brand); background: var(--chip); }
.stage .n { font-size: 18px; font-weight: 700; } .stage .k { font-size: 11px; color: var(--muted); }
.quiz-opt { display: block; width: 100%; text-align: left; margin: 6px 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 15px; cursor: pointer; }
.quiz-opt.right { border-color: var(--good); background: #E3F4EA; color: #14532D; } .quiz-opt.wrong { border-color: var(--bad); background: #FDE3E3; color: #7F1D1D; }
.timer { height: 6px; background: var(--chip); border-radius: 999px; overflow: hidden; margin: 8px 0 12px; } .timer i { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }
.week { display: flex; gap: 6px; } .week i { flex: 1; height: 26px; border-radius: 8px; background: var(--chip); display: grid; place-items: center; font-size: 10px; color: var(--muted); font-style: normal; } .week i.ok { background: var(--good); color: #fff; } .week i.no { background: var(--bad); color: #fff; }
.finding { border-left: 4px solid var(--brand); padding: 8px 10px; border-radius: 8px; background: var(--chip); margin: 6px 0; } .finding.growth { border-color: var(--good); } .finding.risk { border-color: var(--bad); } .finding.concentration { border-color: var(--warn); } .finding.action { border-color: var(--accent); } .finding.money { border-color: #7B6CF0; }
.finding .k { font-size: 10px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.lgd { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.cmp { overflow-x: auto; } .cmp table { border-collapse: collapse; width: 100%; font-size: 12.5px; } .cmp th, .cmp td { padding: 6px 8px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; } .cmp th { font-size: 13px; } .cmp th.on, .cmp td.on { background: var(--chip); } .cmp td:first-child { color: var(--muted); min-width: 160px; } .cmp td.muted { color: var(--muted); }
.meter { height: 8px; background: var(--chip); border-radius: 999px; overflow: hidden; } .meter i { display: block; height: 100%; background: var(--good); }
.split { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--chip); } .split i { display: block; height: 100%; }
@media (min-width: 900px) { .ygrid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 600px) and (max-width: 899px) { .ygrid { grid-template-columns: repeat(3, 1fr); } }
:root[data-theme="dark"] .quiz-opt.right { background: #173A2A; color: #7FE0AE; } :root[data-theme="dark"] .quiz-opt.wrong { background: #44201F; color: #F59A9A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .quiz-opt.right { background: #173A2A; color: #7FE0AE; } :root:not([data-theme="light"]) .quiz-opt.wrong { background: #44201F; color: #F59A9A; } }

/* ---------- Interaction layer (ux.js): palette, skeletons, transitions, pull-to-refresh, feedback ---------- */
kbd { font: 600 11px/1 var(--font); padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 2px; background: var(--card); color: var(--muted); }
#palette { position: fixed; inset: 0; z-index: 60; background: rgba(10, 20, 26, .42); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: flex-start; padding: calc(10vh + env(safe-area-inset-top)) 12px 12px; animation: fadeIn .14s ease-out; }
.pal-card { width: 100%; max-width: 640px; background: var(--card); border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,.28); overflow: hidden; animation: popIn .18s cubic-bezier(.2,.9,.3,1.2); }
.pal-in { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.pal-in input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 17px; padding: 0; min-height: 0; }
#pal-list { max-height: min(60vh, 460px); overflow-y: auto; padding: 6px; }
.pal-group { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 10px 4px; }
.pal-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; cursor: pointer; }
.pal-item.on { background: var(--chip); }
.pal-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--chip); color: var(--brand); flex: 0 0 30px; }
.pal-item.on .pal-ic { background: var(--brand); color: var(--brand-ink); }
.pal-status, .pal-understood { padding: 14px 12px; color: var(--muted); font-size: 14px; }
.pal-understood { padding: 8px 12px 0; font-size: 12px; }
.pal-foot { display: flex; gap: 16px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
@media (max-width: 600px) { .pal-foot { display: none; } #palette { padding-top: calc(8px + env(safe-area-inset-top)); } .pal-in kbd { display: none; } }
body.pal-open { overflow: hidden; }

/* search entry on Today */
.searchbar { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; margin: 2px 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: 15px; text-align: left; cursor: text; transition: border-color .15s, box-shadow .15s; }
.searchbar:hover { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent); }
.searchbar span.grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* sidebar search button (desktop); hidden in the phone tab bar */
#tabs #tabs-search { display: none; }
@media (min-width: 900px) {
  #tabs #tabs-search { display: flex; align-items: center; margin: 0 0 10px; border: 1px solid var(--line); background: var(--card); color: var(--muted); }
  #tabs #tabs-search kbd { margin-left: auto; }
}

/* skeleton while a screen loads */
.skel { padding-top: calc(16px + env(safe-area-inset-top)); }
.sk { border-radius: 10px; background: linear-gradient(90deg, var(--chip) 0%, color-mix(in srgb, var(--chip) 55%, var(--card)) 50%, var(--chip) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.sk-title { height: 26px; width: 42%; margin-bottom: 16px; }
.sk-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.sk-tile { height: 64px; }
.sk-line { height: 52px; margin-bottom: 10px; }
@media (max-width: 600px) { .sk-row { grid-template-columns: repeat(2, 1fr); } }

/* screen transition */
#app.enter > * { animation: riseIn .22s cubic-bezier(.2,.8,.2,1) both; }
#app.enter > *:nth-child(2) { animation-delay: .02s; } #app.enter > *:nth-child(3) { animation-delay: .04s; } #app.enter > *:nth-child(4) { animation-delay: .06s; } #app.enter > *:nth-child(n+5) { animation-delay: .08s; }

/* pull to refresh */
#ptr { position: fixed; top: calc(env(safe-area-inset-top)); left: 50%; margin-left: -20px; width: 40px; height: 40px; border-radius: 50%; background: var(--card); box-shadow: 0 4px 14px rgba(0,0,0,.18); z-index: 40; opacity: 0; transform: translateY(-50px); display: grid; place-items: center; transition: opacity .15s; pointer-events: none; }
#ptr span { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--brand); transition: transform .2s; }
#ptr.ready span { transform: rotate(180deg); border-top-color: var(--good); }
#ptr.spin span { animation: spin .7s linear infinite; }

/* feedback: presses, hover lift on desktop, focus rings for keyboard users */
.btn, .chip, .item, #tabs button { transition: transform .08s ease, background-color .15s, border-color .15s, box-shadow .15s; }
.btn:active, .chip:active, #tabs button:active { transform: scale(.97); }
.list .item:active { background: var(--chip); }
@media (hover: hover) and (min-width: 900px) {
  .list .item:hover { background: var(--chip); }
  .card.tight:has(.item[data-nav]):hover { box-shadow: 0 6px 22px rgba(15, 30, 40, .07); }
  .kpi { transition: transform .15s, box-shadow .15s; } .kpi:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15, 30, 40, .08); }
}
:focus-visible { outline: 2.5px solid color-mix(in srgb, var(--brand) 70%, var(--accent)); outline-offset: 2px; border-radius: 8px; }
.shortcuts .row { padding: 8px 0; border-bottom: 1px solid var(--line); }

@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
#sheet:not([hidden]) .sheet-card { animation: sheetUp .22s cubic-bezier(.2,.8,.2,1); }
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
#toast:not([hidden]) { animation: popIn .18s ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
.greet { font-size: 15px; margin: 0 0 8px; }
@media (max-width: 600px) { .searchbar kbd { display: none; } }

/* ---- cut 10: phone layout and contrast fixes ---- */
/* two-column forms and bar lists shrink on a 375px phone instead of scrolling sideways */
.grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid2 > *, .grid2 input, .grid2 select, .grid2 textarea { min-width: 0; max-width: 100%; }
.hbars > *, .hb, .hb-l { min-width: 0; }
.hb-l .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* white text on buttons meets 4.5:1 in light and dark (the brand orange and green stay for chips, bars and icons) */
.btn.accent, .fab { background: #B35C00; border-color: #B35C00; }
.btn.good { background: #187A50; border-color: #187A50; }
:root[data-theme="dark"] #tabs button.on { color: #7CC4D6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #tabs button.on { color: #7CC4D6; } }
