:root {
  --bg: #f4f6fa; --card: #ffffff; --ink: #0f1b33; --muted: #5d6b85; --line: #e3e8f0;
  --brand: #0f1b33; --accent: #1d9e6f; --accent-soft: #e3f6ee;
  --warn: #b7791f; --warn-soft: #fdf3e1; --bad: #c0392b; --bad-soft: #fbe9e7;
  --info-soft: #e8eefb; --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1222; --card: #141d31; --ink: #e8edf6; --muted: #98a5bd; --line: #26324a;
    --brand: #e8edf6; --accent: #3ddc97; --accent-soft: #123528;
    --warn: #f0b955; --warn-soft: #3a2c12; --bad: #ff7a6b; --bad-soft: #3d1a17; --info-soft: #1a2643;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0b1222; --card: #141d31; --ink: #e8edf6; --muted: #98a5bd; --line: #26324a;
    --brand: #e8edf6; --accent: #3ddc97; --accent-soft: #123528;
    --warn: #f0b955; --warn-soft: #3a2c12; --bad: #ff7a6b; --bad-soft: #3d1a17; --info-soft: #1a2643;
    color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.splash { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* layout */
.shell { max-width: 760px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 0 calc(84px + env(safe-area-inset-bottom, 0px)); }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); padding: 14px 0 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.top .who { font-size: 13px; color: var(--muted); }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--card);
  border-top: 1px solid var(--line); display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom); }
.nav a { flex: 1; max-width: 190px; text-align: center; padding: 10px 4px 12px; font-size: 12px;
  color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a .ico { display: block; font-size: 20px; line-height: 1.2; }
.nav a.on { color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--bad);
  color: #fff; font-size: 11px; line-height: 18px; margin-left: 4px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card h2 { font-size: 16px; margin: 0 0 10px; }
.card h3 { font-size: 14px; margin: 0 0 6px; }
.hero { background: var(--brand); color: var(--bg); border: 0; }
.hero .label { opacity: .75; font-size: 13px; }
.hero .big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 6px; }
.hero .row { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; opacity: .9; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }

/* KPI rows */
.kpi { padding: 12px 0; border-top: 1px solid var(--line); }
.kpi:first-of-type { border-top: 0; }
.kpi .name { font-weight: 600; font-size: 14px; }
.bar { height: 8px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 8px 0 4px; position: relative; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 6px; }
.bar > b { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); opacity: .3; border-radius: 6px; }
.bar > u { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: .5; }

/* pills */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.approved { background: var(--accent-soft); color: var(--accent); }
.pill.rejected { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--muted); }

/* forms */
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
input, select, textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); font-size: 16px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; cursor: pointer;
  border-radius: 10px; padding: 12px 16px; font-weight: 600; background: var(--accent); color: #fff; text-decoration: none; }
.btn.block { width: 100%; margin-top: 16px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }
.fab { position: fixed; right: calc(18px + env(safe-area-inset-right, 0px)); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 11;
  border-radius: 28px; padding: 14px 20px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.has { border-color: var(--accent); color: var(--ink); }
.thumb { max-width: 100%; max-height: 220px; border-radius: 10px; display: block; margin-top: 8px; }

/* lists & tables */
.item { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.tablewrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.tabs button { border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 6px 12px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.tabs button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }

/* auth */
.auth { max-width: 400px; margin: 0 auto; padding-block: 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.auth .logo { width: 52px; height: 52px; }
.auth h1 { font-size: 24px; margin: 14px 0 4px; }
.notice { background: var(--info-soft); border-radius: 10px; padding: 12px; font-size: 13px; margin: 12px 0; }
.error { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 12px; }

#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, 94vw); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(5, 10, 20, .55); }
dialog .dlg { padding: 18px; max-height: 85vh; overflow-y: auto; }

.show-sm { display: none; }
@media (max-width: 600px) { .hide-sm { display: none; } .show-sm { display: block; } }

body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
