/* HR Desk — calm, dark-first UI (light theme included). Tokens first, components after. */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0D10; --surface: #14181D; --surface-2: #1B2027; --surface-3: #232933; --border: #262C35; --border-strong: #343C48;
  --text: #F2F4F7; --muted: #9AA4B2; --faint: #6B7482;
  --accent: #4C8DFF; --accent-strong: #6EA2FF; --accent-text: #0B0D10; --accent-soft: rgba(76,141,255,.14);
  --ok: #34D399; --ok-soft: rgba(52,211,153,.14); --warn: #FBBF24; --warn-soft: rgba(251,191,36,.14);
  --bad: #F87171; --bad-soft: rgba(248,113,113,.14); --info: #A5B4FC; --info-soft: rgba(165,180,252,.13);
  --shadow: 0 10px 30px rgba(0,0,0,.45); --card-shadow: none;
  --code-P: rgba(52,211,153,.16); --code-A: rgba(248,113,113,.22); --code-L: rgba(251,191,36,.20); --code-H: rgba(154,164,178,.16);
  --code-HW: rgba(76,141,255,.22); --code-LV: rgba(165,180,252,.22);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F6F7F9; --surface: #FFFFFF; --surface-2: #F0F2F5; --surface-3: #E7EAEE; --border: #E3E6EB; --border-strong: #CDD2DA;
  --text: #101418; --muted: #5B6572; --faint: #8A929E;
  --accent: #1F5FE0; --accent-strong: #1A50BF; --accent-text: #FFFFFF; --accent-soft: rgba(31,95,224,.10);
  --ok: #0E7A4F; --ok-soft: rgba(14,122,79,.10); --warn: #8A5A00; --warn-soft: rgba(196,135,0,.13);
  --bad: #C0292B; --bad-soft: rgba(192,41,43,.10); --info: #4338CA; --info-soft: rgba(67,56,202,.09);
  --shadow: 0 12px 32px rgba(16,20,24,.16); --card-shadow: 0 1px 2px rgba(16,20,24,.06);
  --code-P: rgba(14,122,79,.12); --code-A: rgba(192,41,43,.16); --code-L: rgba(196,135,0,.18); --code-H: rgba(91,101,114,.12);
  --code-HW: rgba(31,95,224,.14); --code-LV: rgba(67,56,202,.13);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.right { text-align: right; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.hide { display: none !important; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------- layout */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px; border-right: 1px solid var(--border); background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #8AB4FF); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .5px; }
.brand b { display: block; font-size: 15px; letter-spacing: .2px; }
.brand small { color: var(--muted); font-size: 12px; display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; font-size: 14px; }
.nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--surface-2); color: var(--text); }
.nav a.on .i { color: var(--accent); }
.nav .badge { margin-left: auto; }
.side .foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
.who { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.main { min-width: 0; padding: 24px 32px 48px; }
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.top h1 { font-size: 22px; font-weight: 600; letter-spacing: -.2px; margin: 0; }
.top .sub { color: var(--muted); font-size: 13px; }
.top .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mtop, .tabbar { display: none; }

/* ---------- cards & KPIs */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; box-shadow: var(--card-shadow); }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card h2 .i { color: var(--muted); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1200px) and (min-width: 861px) { .g5.kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.split { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
.kpi { position: relative; overflow: hidden; }
.kpi .label { font-size: 11px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kpi .value { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: clamp(20px, 2.1vw, 30px); font-weight: 600; letter-spacing: -.5px; margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .value small { font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.kpi .hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.kpi .glow { position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--accent-soft); filter: blur(6px); }
.kpi.clickable { cursor: pointer; transition: border-color .15s; }
.kpi.clickable:hover { border-color: var(--border-strong); }
.hero { padding: 26px 26px 22px; background: radial-gradient(120% 140% at 100% 0%, var(--accent-soft), transparent 55%), var(--surface); }
.hero .big:not(.btn) { font-size: 44px; font-weight: 600; letter-spacing: -1px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.status-line { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }

/* ---------- buttons, chips, inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.ok { color: var(--ok); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 0; width: 38px; }
.btn.big { min-height: 52px; font-size: 16px; border-radius: 14px; padding: 0 20px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--muted); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.badge { min-width: 20px; height: 20px; border-radius: 10px; background: var(--accent); color: var(--accent-text); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; padding: 0 6px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 500; }
.filters button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
label.f { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }
label.f > span { display: block; margin-bottom: 6px; }
input.in, select.in, textarea.in { width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); font-size: 15px; }
textarea.in { min-height: 80px; resize: vertical; }
input.in:focus, select.in:focus, textarea.in:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.form { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .full { grid-column: 1 / -1; }
.form h3 { grid-column: 1 / -1; margin: 8px 0 -4px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--faint); font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; color: var(--muted); cursor: pointer; font-weight: 500; font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.month { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.month span { min-width: 120px; text-align: center; font-weight: 600; font-size: 14px; }
.month button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.month button:hover { background: var(--surface-2); color: var(--text); }

/* ---------- tables */
.tablewrap { overflow: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); max-width: 100%; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.t th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover td { background: var(--surface-2); }
table.t tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border); }
.name-cell { min-width: 170px; }
.name-cell b { display: block; font-weight: 600; }
.name-cell span { color: var(--muted); font-size: 12px; }
/* attendance grid */
table.att { font-size: 12px; }
table.att th, table.att td { padding: 6px 4px; text-align: center; border-right: 1px solid var(--border); }
table.att th:first-child, table.att td:first-child { position: sticky; left: 0; z-index: 3; background: var(--surface); text-align: left; padding-left: 12px; min-width: 170px; }
table.att th:first-child { z-index: 4; background: var(--surface-2); }
table.att th.we { color: var(--faint); }
table.att td.c { cursor: pointer; font-weight: 600; min-width: 32px; }
table.att td.c:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.code-P { background: var(--code-P); } .code-A { background: var(--code-A); color: var(--bad); } .code-L { background: var(--code-L); color: var(--warn); }
.code-WO, .code-H { background: var(--code-H); color: var(--faint); } .code-HW { background: var(--code-HW); color: var(--accent); }
.code-LV, .code-LWP { background: var(--code-LV); color: var(--info); } .code-HD { background: var(--code-L); }
.code-ND { color: var(--faint); } td.short { box-shadow: inset 0 -3px 0 var(--warn); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
/* employee-wise attendance summary */
.attbar { display: flex; min-width: 90px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.attbar i { display: block; height: 100%; }
.b-ok { background: var(--ok); } .b-warn { background: var(--warn); } .b-info { background: var(--info); } .b-bad { background: var(--bad); }
.strip { display: flex; gap: 2px; }
.strip i { display: block; width: 5px; height: 18px; border-radius: 2px; background: var(--surface-3); flex: none; }
.s-P { background: var(--ok) !important; } .s-L, .s-HD { background: var(--warn) !important; } .s-A { background: var(--bad) !important; }
.s-LV, .s-LWP { background: var(--info) !important; } .s-HW { background: var(--accent) !important; } .s-WO, .s-H { background: var(--surface-3) !important; }
.s-ND { background: transparent !important; box-shadow: inset 0 0 0 1px var(--border); } .s-NE { background: transparent !important; }
.s-short.s-P, .s-short.s-L { background: linear-gradient(to top, var(--warn) 0 38%, var(--ok) 38%) !important; }
.legend span i.s-P, .legend span i.s-WO, .legend span i.s-HW { width: 6px; height: 14px; }
table.attsum td { padding-top: 12px; padding-bottom: 12px; }
table.attsum td.lead { min-width: 250px; }
table.attsum .name-cell b { white-space: nowrap; }
table.attsum .avatar { width: 34px; height: 34px; font-size: 12px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; }

/* ---------- checks list (claims) */
.checks { display: flex; flex-direction: column; gap: 8px; }
.ck { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.ck .i { margin-top: 2px; }
.ck.fail .i { color: var(--bad); } .ck.warn .i { color: var(--warn); } .ck.pass .i { color: var(--ok); } .ck.info .i { color: var(--muted); }
.ck b { display: block; font-size: 13px; }
.billview { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: grid; place-items: center; min-height: 260px; }
.billview img { max-width: 100%; max-height: 70vh; display: block; }
.billview iframe { width: 100%; height: 70vh; border: 0; background: #fff; }
.compare { display: grid; grid-template-columns: auto 1fr 1fr; gap: 6px 14px; font-size: 14px; }
.compare .h { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.riskbar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.riskbar i { display: block; height: 100%; }

/* ---------- sheets, toasts, misc */
.scrim { position: fixed; inset: 0; background: rgba(5,7,10,.62); backdrop-filter: blur(2px); z-index: 50; display: flex; justify-content: flex-end; animation: fade .15s; }
.sheet { width: min(640px, 100%); height: 100%; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; animation: slide .2s ease-out; box-shadow: var(--shadow); }
.sheet.wide { width: min(1040px, 100%); }
.sheet header { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.sheet header h3 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; }
.sheet .body { padding: 20px; overflow: auto; flex: 1; }
.sheet footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow); max-width: min(560px, 92vw); animation: fade .15s; }
.toast.bad { background: var(--bad); color: #fff; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .i { width: 36px; height: 36px; stroke-width: 1.4; color: var(--faint); margin-bottom: 10px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.skeleton { height: 120px; border-radius: 14px; background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.note { border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--muted); }
.note b { color: var(--text); }
.note.warn { border-color: transparent; background: var(--warn-soft); color: var(--text); }
.list { display: flex; flex-direction: column; }
.list .item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list .item:last-child { border-bottom: 0; }
.todo .item { color: var(--text); }
.todo .item:hover { text-decoration: none; }
.todo .item .i { color: var(--warn); }
.kpi .value .i { width: 30px; height: 30px; color: var(--accent); }
.todo .item.done { color: var(--muted); }
.todo .item.done .i { color: var(--ok); }
.steps { counter-reset: s; display: grid; gap: 12px; }
.step { display: flex; gap: 14px; }
.step::before { counter-increment: s; content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { font-size: 11px; color: var(--faint); text-align: center; text-transform: uppercase; letter-spacing: .6px; }
.cal .day { aspect-ratio: 1 / 1; border-radius: 10px; background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 13px; }
.cal .day small { font-size: 10px; font-weight: 700; margin-top: 2px; }
.cal .day.code-P { background: var(--code-P); } .cal .day.code-A { background: var(--code-A); } .cal .day.code-L, .cal .day.code-HD { background: var(--code-L); }
.cal .day.code-HW { background: var(--code-HW); } .cal .day.code-LV, .cal .day.code-LWP { background: var(--code-LV); }
.cal .day.code-WO, .cal .day.code-H { background: var(--code-H); } .cal .day.code-ND { background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.cal .day.short { box-shadow: inset 0 -3px 0 var(--warn); }
.cal .day[data-day]:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
/* punching */
.clock { font-size: 34px; font-weight: 600; letter-spacing: -.5px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.btn.outbtn { background: var(--surface-3); border-color: var(--border-strong); }
.camwrap { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; max-height: 56vh; margin: 0 auto; width: 100%; max-width: 420px; }
.camwrap video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.camring { position: absolute; left: 50%; top: 44%; width: 58%; aspect-ratio: 3 / 4; transform: translate(-50%, -50%); border: 2px dashed rgba(255,255,255,.55); border-radius: 50%; pointer-events: none; }
.camhint { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; color: #fff; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.punchgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.pcard { padding: 0; overflow: hidden; }
.pcard .pimg { display: flex; gap: 2px; background: var(--bg); height: 170px; }
.pcard .pimg img { flex: 1; min-width: 0; object-fit: cover; height: 100%; }
.pcard .pimg .noimg { flex: 1; display: grid; place-items: center; color: var(--faint); font-size: 12px; }
.pcard .pbody { padding: 12px 14px; }
.pw { font-family: ui-monospace, Consolas, monospace; font-size: 20px; letter-spacing: 1px; padding: 12px 16px; background: var(--surface-2); border-radius: 10px; user-select: all; }
pre.ocr { white-space: pre-wrap; font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; max-height: 260px; overflow: auto; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(80% 60% at 50% 0%, var(--accent-soft), transparent 70%), var(--bg); }
.login .card { width: min(400px, 100%); padding: 28px; }
.login h1 { font-size: 24px; margin: 14px 0 4px; letter-spacing: -.3px; }
.camera { border: 2px dashed var(--border-strong); border-radius: 16px; padding: 22px; text-align: center; cursor: pointer; background: var(--surface-2); }
.camera:hover { border-color: var(--accent); }
.camera img { max-width: 100%; max-height: 260px; border-radius: 10px; }

/* ---------- phone */
@media (max-width: 860px) {
  body { font-size: 16px; }
  .shell { display: block; }
  .side { display: none; }
  .main { padding: 12px 16px calc(88px + env(safe-area-inset-bottom)); }
  .mtop { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
  .mtop b { font-size: 16px; flex: 1; }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px; font-size: 11px; color: var(--muted); font-weight: 500; position: relative; }
  .tabbar a .i { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--accent); }
  .tabbar a .badge { position: absolute; top: 4px; left: 54%; height: 16px; min-width: 16px; font-size: 10px; }
  .top h1 { font-size: 20px; }
  .top .actions { margin-left: 0; width: 100%; }
  .g2, .g3, .g4, .split { grid-template-columns: minmax(0, 1fr); }
  .g4.kpis, .g5.kpis, .keep2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 24px; }
  .hero .big:not(.btn) { font-size: 36px; }
  .form { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px; border-radius: 16px; }
  .scrim { align-items: flex-end; }
  .sheet, .sheet.wide { width: 100%; height: 92vh; border-radius: 20px 20px 0 0; border-left: 0; border-top: 1px solid var(--border); animation: up .22s ease-out; }
  @keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td { display: block; width: 100%; }
  table.t.cards tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  table.t.cards td { border: 0; padding: 2px 0; text-align: left; display: flex; justify-content: space-between; gap: 12px; }
  table.t.cards td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: 13px; font-weight: 500; }
  table.t.cards td.lead { font-size: 16px; padding-bottom: 6px; }
  table.t.cards tfoot { display: block; } table.t.cards tfoot tr { display: block; }
  .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .hide-m { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { .side, .mtop, .tabbar, .top .actions { display: none !important; } .shell { display: block; } }
