/* ==========================================================================
   Nave — design system & layout
   Mobile-first. Breakpoints: 640px (tablet), 1024px (desktop), 1360px (wide).
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --brand: #0E2A47;
  --brand-2: #163B63;
  --brand-ink: #0A1F35;
  --gold: #C9A227;
  --gold-2: #E2BE4C;
  --gold-soft: #FBF4DC;
  --bg: #F3F5F9;
  --bg-2: #EAEEF5;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #EEF2F7;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F1B2D;
  --muted: #5B6B82;
  --subtle: #8190A6;
  --ok: #15803D;   --ok-soft: #DCFCE7;
  --warn: #B45309; --warn-soft: #FEF3C7;
  --danger: #B91C1C; --danger-soft: #FEE2E2;
  --info: #1D4ED8; --info-soft: #DBEAFE;
  --violet: #6D28D9; --violet-soft: #EDE9FE;
  --chart-1: #1D4ED8; --chart-2: #C9A227; --chart-3: #15803D; --chart-4: #B91C1C; --chart-5: #6D28D9;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(15, 27, 45, .05);
  --shadow-2: 0 1px 2px rgba(15, 27, 45, .04), 0 8px 24px rgba(15, 27, 45, .07);
  --shadow-3: 0 24px 64px rgba(15, 27, 45, .28);
  --sidebar-w: 272px;
  --topbar-h: 64px;
  --tabbar-h: 66px;
  --focus: 0 0 0 3px rgba(29, 78, 216, .28);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1322;
    --bg-2: #0F1A2C;
    --surface: #131F33;
    --surface-2: #17263E;
    --surface-3: #1C2F4C;
    --border: #243552;
    --border-strong: #33476A;
    --text: #E6ECF5;
    --muted: #9AA9C0;
    --subtle: #7487A3;
    --ok-soft: rgba(34, 197, 94, .16);
    --warn-soft: rgba(245, 158, 11, .16);
    --danger-soft: rgba(239, 68, 68, .16);
    --info-soft: rgba(59, 130, 246, .18);
    --violet-soft: rgba(139, 92, 246, .18);
    --gold-soft: rgba(201, 162, 39, .14);
    --ok: #4ADE80; --warn: #FBBF24; --danger: #F87171; --info: #60A5FA;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, .35);
    --chart-1: #60A5FA; --chart-2: #E2BE4C; --chart-3: #4ADE80; --chart-4: #F87171; --chart-5: #A78BFA;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1322;
  --bg-2: #0F1A2C;
  --surface: #131F33;
  --surface-2: #17263E;
  --surface-3: #1C2F4C;
  --border: #243552;
  --border-strong: #33476A;
  --text: #E6ECF5;
  --muted: #9AA9C0;
  --subtle: #7487A3;
  --ok-soft: rgba(34, 197, 94, .16);
  --warn-soft: rgba(245, 158, 11, .16);
  --danger-soft: rgba(239, 68, 68, .16);
  --info-soft: rgba(59, 130, 246, .18);
  --violet-soft: rgba(139, 92, 246, .18);
  --gold-soft: rgba(201, 162, 39, .14);
  --ok: #4ADE80; --warn: #FBBF24; --danger: #F87171; --info: #60A5FA;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, .35);
  --chart-1: #60A5FA; --chart-2: #E2BE4C; --chart-3: #4ADE80; --chart-4: #F87171; --chart-5: #A78BFA;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  background-image: radial-gradient(1200px 500px at 110% -10%, rgba(201, 162, 39, .07), transparent 60%);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 1.6rem; letter-spacing: -.02em; line-height: 1.2; }
h2 { font-size: 1.05rem; letter-spacing: -.01em; }
h3 { font-size: .95rem; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 18px; height: 18px; flex: none; }
.muted-text { color: var(--muted); font-size: .92rem; }
.sub { display: block; color: var(--muted); font-size: .8rem; font-weight: 400; margin-top: 2px; }
.mono { font-family: var(--mono); font-size: .85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--ok); font-weight: 600; }
.down { color: var(--danger); font-weight: 600; }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.big-line { font-size: 1.1rem; font-weight: 600; }
.sub-title { font-size: .95rem; margin: 18px 0 8px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.back-link .ico { transform: rotate(180deg); width: 16px; height: 16px; }

/* ---------- App shell ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; gap: 14px; padding: 18px 14px 14px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-ink) 100%);
  color: #DCE6F2; overflow-y: auto; transform: translateX(-100%); transition: transform .25s ease;
}
body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-3); }
.scrim { position: fixed; inset: 0; background: rgba(5, 12, 24, .5); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .25s; }
body.nav-open .scrim { opacity: 1; pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 0; }
.brand strong { display: block; color: #fff; font-size: 1.15rem; letter-spacing: -.01em; }
.brand small { display: block; color: #9FB3CC; font-size: .74rem; line-height: 1.3; }
.brand-logo { border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); }
.church-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .08); }
.church-chip strong { display: block; color: #fff; font-size: .9rem; line-height: 1.2; }
.church-chip small { color: #9FB3CC; font-size: .75rem; }
.nav { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.nav-title { display: block; padding: 0 10px 6px; color: #7F97B5; font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 1px 0;
  border-radius: 10px; color: #CFDBEA; font-size: .93rem; font-weight: 500;
}
.nav-item .ico { opacity: .85; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-item.active { background: linear-gradient(90deg, rgba(201, 162, 39, .22), rgba(201, 162, 39, .06)); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold-2); }
.nav-item.active .ico { color: var(--gold-2); opacity: 1; }
.nav-item span { flex: 1; }
.nav-badge { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.sidebar-foot { margin-top: auto; padding: 8px 10px 0; color: #6F87A5; font-size: .75rem; }

.main-wrap { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .grow { flex: 1; min-width: 0; }
.topbar-title { min-width: 0; }
.topbar-title strong { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title small { display: block; color: var(--muted); font-size: .78rem; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-brand { display: none; align-items: center; gap: 8px; font-weight: 700; }
.topbar-brand img { border-radius: 9px; }
.topbar-search { display: none; }
.content { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 22px 20px 40px; outline: none; }
.is-setup .sidebar, .is-setup .topbar, .is-setup .tabbar, .is-setup .scrim { display: none !important; }
.is-setup .content { max-width: none; padding: 0; }
.is-setup .main-wrap { margin-left: 0 !important; }
.bell { position: relative; }
.bell .nav-badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; font-size: .66rem; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tab-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; color: var(--subtle); font-size: .7rem; font-weight: 600; padding: 6px 2px;
}
.tab-item .ico { width: 22px; height: 22px; }
.tab-item.active { color: var(--brand); }
:root[data-theme="dark"] .tab-item.active, :root:not([data-theme="light"]) .tab-item.active { color: var(--gold-2); }
.tab-item:hover { text-decoration: none; }

/* ---------- Page chrome ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { color: var(--muted); margin-top: 4px; font-size: .95rem; max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.card + .card, .grid-2 + .card, .card + .grid-2 { margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }
.grid-2 > .card { margin-top: 0; min-width: 0; }
.grid-2 .card { min-width: 0; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-1); min-width: 0; overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-head h2 { font-size: 1rem; }
.card-head p { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.card-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-body { padding: 14px 18px 18px; }
.card-head + .card-body { padding-top: 12px; }
.card.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.card.danger-zone .card-head { padding-bottom: 16px; align-items: center; }
.card.danger-zone .card-head p { max-width: 60ch; }

/* KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.kpi {
  --tone: var(--brand); --tone-soft: var(--surface-3);
  position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 14px 14px 13px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-1); color: var(--text); overflow: hidden; transition: transform .15s, box-shadow .15s, border-color .15s;
}
a.kpi:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.kpi::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--tone); opacity: .9; }
.kpi.tone-brand { --tone: var(--brand-2); --tone-soft: var(--surface-3); }
.kpi.tone-gold { --tone: var(--gold); --tone-soft: var(--gold-soft); }
.kpi.tone-ok { --tone: var(--ok); --tone-soft: var(--ok-soft); }
.kpi.tone-warn { --tone: var(--warn); --tone-soft: var(--warn-soft); }
.kpi.tone-danger { --tone: var(--danger); --tone-soft: var(--danger-soft); }
.kpi.tone-info { --tone: var(--info); --tone-soft: var(--info-soft); }
.kpi.tone-muted { --tone: var(--subtle); --tone-soft: var(--surface-3); }
.kpi-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.kpi-ico { width: 30px; height: 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; background: var(--tone-soft); color: var(--tone); flex: none; }
.kpi-ico .ico { width: 16px; height: 16px; }
.kpi-label { color: var(--muted); font-size: .8rem; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: clamp(1.15rem, 2.2vw, 1.55rem); font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { color: var(--muted); font-size: .78rem; line-height: 1.35; }

/* Quick actions */
.quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.quick-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: .9rem; min-width: 0;
}
.quick-item > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-item > .ico:first-child { color: var(--brand-2); }
.quick-item > .ico:last-child { color: var(--subtle); width: 16px; height: 16px; }
.quick-item:hover { border-color: var(--gold); text-decoration: none; background: var(--gold-soft); }

/* Getting started */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.steps a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.steps a:hover { text-decoration: none; border-color: var(--gold); }
.steps .ico { color: var(--brand-2); }
.steps span { flex: 1; }
.steps .ico:last-child { color: var(--subtle); }

/* Lists: alerts, activity */
.alert-list, .activity, .chip-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.alert-list a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); }
.alert-list a:hover { text-decoration: none; border-color: var(--border-strong); }
.alert-list strong { display: block; font-size: .92rem; }
.alert-list small { display: block; color: var(--muted); font-size: .8rem; }
.alert-list > li > a > div { flex: 1; min-width: 0; }
.alert-list > li > a > .ico { color: var(--subtle); width: 16px; height: 16px; }
.alert-list .btn { margin-left: auto; }
.sev-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--info); box-shadow: 0 0 0 4px var(--info-soft); }
.sev-high .sev-dot { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.sev-medium .sev-dot { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.sev-low .sev-dot { background: var(--info); box-shadow: 0 0 0 4px var(--info-soft); }
.sev-high > a { border-left: 3px solid var(--danger) !important; }
.sev-medium > a { border-left: 3px solid var(--warn) !important; }
.sev-low > a { border-left: 3px solid var(--info) !important; }
.activity li { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px dashed var(--border); }
.activity li:last-child { border-bottom: 0; }
.activity strong { display: block; font-size: .9rem; }
.activity small { color: var(--muted); font-size: .78rem; }
.act { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 7px; border-radius: 6px; background: var(--surface-3); color: var(--muted); min-width: 64px; text-align: center; }
.act-create { background: var(--ok-soft); color: var(--ok); }
.act-update { background: var(--info-soft); color: var(--info); }
.act-delete { background: var(--danger-soft); color: var(--danger); }
.act-import, .act-settings { background: var(--violet-soft); color: var(--violet); }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-list li a { display: inline-block; padding: 5px 11px; border-radius: 999px; background: var(--surface-3); color: var(--text); font-size: .85rem; }

/* Notices & empties */
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; margin: 14px 0 0; background: var(--info-soft); color: var(--text); font-size: .92rem; }
.notice .ico { color: var(--info); margin-top: 2px; }
.notice.warn { background: var(--warn-soft); }
.notice.warn .ico { color: var(--warn); }
.empty { text-align: center; padding: 34px 18px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty h3 { font-size: 1rem; }
.empty p { color: var(--muted); max-width: 46ch; font-size: .92rem; }
.empty .btn { margin-top: 10px; }
.empty-ico { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--brand-2); margin-bottom: 6px; }
.empty-ico .ico { width: 26px; height: 26px; }

/* Flow & facts */
.flow { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: 10px; }
.flow li { counter-increment: step; display: grid; grid-template-columns: 30px 1fr; gap: 2px 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.flow li:last-child { border-bottom: 0; }
.flow li::before { content: counter(step); grid-row: span 2; width: 30px; height: 30px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--gold-soft); color: var(--brand-2); font-weight: 800; }
.flow strong { font-size: .92rem; }
.flow span { color: var(--muted); font-size: .88rem; }
.facts { display: grid; grid-template-columns: minmax(120px, 36%) 1fr; gap: 0; margin: 0; }
.facts dt, .facts dd { padding: 9px 0; border-bottom: 1px solid var(--border); margin: 0; font-size: .92rem; }
.facts dt { color: var(--muted); padding-right: 10px; }
.facts dd { font-weight: 500; overflow-wrap: anywhere; }
.facts dt:nth-last-child(2), .facts dd:last-child { border-bottom: 0; }
.note-block { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.note-block p { white-space: pre-wrap; margin-top: 4px; font-size: .92rem; }
.integrity { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; }
.integrity strong { display: block; }
.integrity small { color: var(--muted); }
.integrity.good { background: var(--ok-soft); color: var(--ok); }
.integrity.bad { background: var(--danger-soft); color: var(--danger); }
.integrity.good small, .integrity.bad small { color: var(--muted); }
.change-list { margin: 0; padding: 0; list-style: none; font-size: .8rem; color: var(--muted); }
.change-list li { margin-bottom: 2px; }
.change-list b { color: var(--text); font-weight: 600; }

/* ---------- Badges, avatars, progress ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 650; white-space: nowrap; background: var(--surface-3); color: var(--muted); line-height: 1.4; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.gold { background: var(--gold-soft); color: #8A6A0B; }
:root:not([data-theme="light"]) .badge.gold { color: var(--gold-2); }
:root[data-theme="dark"] .badge.gold { color: var(--gold-2); }
.badge.ministry { background: var(--violet-soft); color: var(--violet); }
.badge.muted { background: var(--surface-3); color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; font-size: .78rem; font-weight: 700; letter-spacing: .02em; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 30px; height: 30px; font-size: .7rem; }
.avatar-xl { width: 88px; height: 88px; font-size: 1.6rem; border: 3px solid var(--gold-soft); box-shadow: var(--shadow-2); }
.person-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person-cell > span:last-child { min-width: 0; }
.person-cell strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.person-cell small { color: var(--muted); font-size: .8rem; }
.progress { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 6px; min-width: 70px; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--chart-1), var(--chart-3)); transition: width .4s ease; }
.progress.ok span { background: var(--ok); }
.progress.warn span { background: var(--warn); }
.progress.over span { background: var(--danger); }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; margin-bottom: 5px; }
.hbar-top strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar { height: 9px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.hbar span { display: block; height: 100%; border-radius: inherit; }
.hbar .s1, .bar.s1, .line.s1, .dot.s1, .sw.s1 { --c: var(--chart-1); }
.hbar .s2, .bar.s2, .line.s2, .dot.s2, .sw.s2 { --c: var(--chart-2); }
.hbar .s3, .bar.s3, .line.s3, .dot.s3, .sw.s3 { --c: var(--chart-3); }
.hbar .s4, .bar.s4, .line.s4, .dot.s4, .sw.s4 { --c: var(--chart-4); }
.hbar .s5, .bar.s5, .line.s5, .dot.s5, .sw.s5 { --c: var(--chart-5); }
.hbar span { background: var(--c, var(--chart-1)); }
.budget-list { display: grid; gap: 14px; }
.budget-top { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; }
.budget-top span { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Charts ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--subtle); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--c, var(--chart-1)); transition: opacity .15s; }
.chart .bar:hover { opacity: .8; }
.chart .line { fill: none; stroke: var(--c, var(--chart-1)); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--surface); stroke: var(--c, var(--chart-1)); stroke-width: 2.2; }
.chart .area { fill: var(--chart-1); opacity: .10; }
.chart-total { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: .82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--chart-1)); display: inline-block; }

/* ---------- Toolbar, tabs, segmented, period ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 14px 18px 0; }
.search { position: relative; flex: 1 1 240px; min-width: 0; display: block; }
.search input { width: 100%; padding: 10px 12px 10px 38px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface-2); }
.search .search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--subtle); display: flex; }
.search .search-ico .ico { width: 17px; height: 17px; }
.search.big input { padding: 13px 14px 13px 42px; font-size: 1rem; }
.select-wrap { display: inline-block; }
.select-wrap select { padding: 9px 34px 9px 12px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface-2); appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; max-width: 100%; }
.result-count { color: var(--muted); font-size: .82rem; padding: 10px 18px 0; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 4px; margin: 18px 0 0; background: var(--surface-3); border-radius: 14px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: .92rem; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.tab-count { font-size: .72rem; background: var(--surface-3); padding: 1px 7px; border-radius: 999px; }
.tab-body { margin-top: 16px; display: grid; gap: 16px; }
.tab-body > .card { margin-top: 0; }
.tab-body > .kpi-grid { margin-top: 0; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-3); gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg button { border: 0; background: transparent; padding: 7px 11px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: .85rem; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.period-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 4px; }
.period-seg { max-width: 100%; }
.period-label { color: var(--muted); font-size: .85rem; }
.custom-range { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.custom-range label { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.custom-range input { padding: 7px 10px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-2); }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
table.data th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
table.data.dense td, table.data.dense th { padding: 9px 12px; }
table.data th.num, table.data td.num { text-align: right; }
table.data tr.is-link { cursor: pointer; }
table.data td.row-actions { width: 1%; white-space: nowrap; text-align: right; }
table.data td strong { font-weight: 600; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; margin-left: 2px; vertical-align: middle;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.icon-btn.ok:hover { color: var(--ok); background: var(--ok-soft); }
.icon-btn .ico { width: 17px; height: 17px; }
.line-x { width: 34px; height: 34px; flex: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  min-height: 40px; padding: 9px 16px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 650; font-size: .92rem; line-height: 1; transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn .ico { width: 17px; height: 17px; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, var(--brand-2), var(--brand)); color: #fff; box-shadow: 0 6px 16px rgba(14, 42, 71, .22); }
.btn-primary:hover { filter: brightness(1.08); text-decoration: none; }
.btn-gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #241A00; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.07); }
.btn-sm { min-height: 32px; padding: 6px 11px; font-size: .84rem; border-radius: 10px; }
.btn-lg { min-height: 50px; padding: 13px 22px; font-size: 1rem; border-radius: 14px; }
.file-btn { position: relative; }
.file-btn input { position: absolute; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 6px; }
.sticky-actions { position: sticky; bottom: 76px; z-index: 5; background: color-mix(in srgb, var(--bg) 90%, transparent); padding: 10px 0; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form select { padding: 9px 12px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface-2); }
.lists-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.lists-grid .field textarea { min-height: 120px; }
.settings-form { display: grid; gap: 16px; }

/* ---------- Forms ---------- */
.form { display: block; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label, .field > .field-label { font-size: .86rem; font-weight: 650; color: var(--text); }
.field-label { display: block; font-size: .86rem; font-weight: 650; }
.req { color: var(--danger); }
.help { color: var(--subtle); font-size: .8rem; line-height: 1.4; }
.field-error { color: var(--danger); font-size: .8rem; font-weight: 550; min-height: 0; }
.field-error:empty { display: none; }
.field input:not([type=checkbox]):not([type=file]), .field select, .field textarea, .lines input {
  width: 100%; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--border-strong);
  background: var(--surface); font-size: .95rem; min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .lines input:focus, .search input:focus { outline: none; border-color: var(--info); box-shadow: var(--focus); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field:has(.field-error:not(:empty)) input, .field:has(.field-error:not(:empty)) select, .field:has(.field-error:not(:empty)) textarea { border-color: var(--danger); }
.check-field { justify-content: flex-start; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: .93rem; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-2); flex: none; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; padding: 10px; border: 1px solid var(--border-strong); border-radius: 11px; max-height: 220px; overflow-y: auto; background: var(--surface-2); }
.check-grid .check { padding: 6px 8px; border-radius: 8px; }
.check-grid .check:hover { background: var(--surface-3); }
.heading-field .field-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-top: 8px; border-top: 1px dashed var(--border); }
.form-alert { padding: 11px 13px; border-radius: 11px; background: var(--danger-soft); color: var(--danger); font-size: .9rem; font-weight: 550; margin-bottom: 14px; }
.photo-input { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.photo-preview { width: 76px; height: 76px; border-radius: 18px; overflow: hidden; background: var(--surface-3); color: var(--subtle); display: flex; align-items: center; justify-content: center; border: 1px dashed var(--border-strong); }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-preview .ico { width: 30px; height: 30px; }
.photo-input > div { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.lines { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface-2); }
.lines-head, .line-row { display: flex; gap: 6px; align-items: center; }
.lines-head { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 0 2px; }
.lines-head span { min-width: 0; }
.lines-head .lines-x { flex: 0 0 34px; }
.lines-body { display: flex; flex-direction: column; gap: 6px; }
.line-row input { min-width: 0; }
.lines .btn { align-self: flex-start; }
.lines input { padding: 9px 10px !important; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(5, 12, 24, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); opacity: 0; transition: opacity .18s ease; }
.modal-backdrop.open { opacity: 1; }
.modal-backdrop.closing { opacity: 0; }
.modal { width: 100%; max-width: 640px; max-height: calc(100dvh - 40px); display: flex; flex-direction: column; background: var(--surface); color: var(--text); border-radius: 20px; border: 1px solid var(--border); box-shadow: var(--shadow-3); transform: translateY(12px) scale(.98); transition: transform .2s ease; overflow: hidden; }
.modal-backdrop.open .modal { transform: none; }
.modal-sm { max-width: 440px; }
.modal-md { max-width: 640px; }
.modal-lg { max-width: 920px; }
.modal-sheet { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 6px; }
.modal-head h2 { font-size: 1.12rem; }
.modal-body { padding: 10px 20px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.roll-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.roll-tools .search { flex: 1 1 220px; }
.roll-tools .search input { padding: 9px 12px 9px 36px; }
.roll-count { font-weight: 650; color: var(--ok); font-size: .9rem; white-space: nowrap; }
.roll-actions { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.roll-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; max-height: 52vh; overflow-y: auto; padding: 4px; }
.roll-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--border); cursor: pointer; background: var(--surface); min-width: 0; }
.roll-row:hover { border-color: var(--border-strong); }
.roll-row:has(input:checked) { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.roll-row input { width: 18px; height: 18px; accent-color: var(--ok); flex: none; }
.roll-name { display: flex; flex-direction: column; min-width: 0; }
.roll-name strong { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roll-name small { color: var(--muted); font-size: .76rem; }
.roll-row .avatar { flex: none; }
.roll-replace { margin-top: 12px; }
.sub-title + .chip-list { margin-bottom: 4px; }

/* Search results & sheet */
.search-results { margin-top: 14px; display: grid; gap: 14px; max-height: 60vh; overflow-y: auto; }
.result-group h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-bottom: 6px; }
.result { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--text); border: 1px solid transparent; }
.result:hover, .result:focus-visible { background: var(--surface-2); border-color: var(--border); text-decoration: none; }
.result > span { flex: 1; min-width: 0; }
.result strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result small { color: var(--muted); font-size: .8rem; }
.result-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex: none; margin: 0 6px; }
.result .ico { color: var(--subtle); width: 16px; height: 16px; }
.sheet-wrap { display: grid; gap: 8px; }
.sheet-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 12px 0 4px; }
.sheet-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sheet-link { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-weight: 600; }
.sheet-link .ico { color: var(--brand-2); }
.sheet-link:hover { text-decoration: none; border-color: var(--gold); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 200; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 420px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; background: var(--brand-ink); color: #fff; box-shadow: var(--shadow-3); font-size: .92rem; font-weight: 550; animation: toast-in .22s ease; transition: opacity .3s, transform .3s; width: 100%; }
.toast .ico { color: var(--gold-2); }
.toast.danger .ico { color: #FCA5A5; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Empty/guide, profile, reports, setup, theme ---------- */
.profile-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.profile-id { flex: 1; min-width: 200px; }
.profile-id h1 { font-size: 1.5rem; }
.profile-id .muted-text { margin-top: 6px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.profile-actions { display: flex; gap: 8px; }
.profile-grid { margin-top: 16px; }
.profile-grid > .card { margin-top: 0; }

.report-picker { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; margin: 14px 0 0; scrollbar-width: thin; }
.report-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: .88rem; white-space: nowrap; }
.report-chip .ico { width: 16px; height: 16px; color: var(--brand-2); }
.report-chip:hover { border-color: var(--gold); }
.report-chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.report-chip.on .ico { color: var(--gold-2); }
.report-card { margin-top: 14px; }
.report-head .card-actions { justify-content: flex-end; }
.report-head p { font-weight: 550; }
.print-head { display: none; }
.print-kpis { margin-top: 0; }
#report-print .notice { margin-bottom: 14px; }
#report-print .empty { padding: 26px 10px; }

.setup { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(900px 500px at 15% -10%, rgba(201, 162, 39, .18), transparent 60%), linear-gradient(180deg, var(--brand) 0%, var(--brand-ink) 100%); }
.setup-card { width: 100%; max-width: 720px; background: var(--surface); color: var(--text); border-radius: 24px; padding: 28px 26px; box-shadow: var(--shadow-3); }
.setup-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.setup-brand img { border-radius: 16px; box-shadow: var(--shadow-2); }
.setup-brand p { color: var(--muted); margin-top: 4px; font-size: .95rem; }
.setup-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.setup .form-grid { gap: 16px; }

.theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.theme-card { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 16px; border: 2px solid var(--border); background: var(--surface-2); color: var(--text); text-align: left; }
.theme-card.on { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.theme-swatch { height: 72px; border-radius: 10px; border: 1px solid var(--border); display: block; }
.theme-swatch.light { background: linear-gradient(135deg, #fff 50%, #E2E8F0 50%); }
.theme-swatch.dark { background: linear-gradient(135deg, #131F33 50%, #0B1322 50%); }
.theme-swatch.system { background: linear-gradient(135deg, #fff 49%, #0B1322 51%); }

/* ---------- Responsive ---------- */
/* Phones (default): content gutter 16px, bottom tab bar, stacked tables */
@media (max-width: 639.98px) {
  body { font-size: 15px; }
  .content { padding: 16px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 14px; gap: 8px; height: 56px; }
  .topbar-brand { display: inline-flex; }
  .topbar-title { display: none; }
  .topbar .icon-btn { width: 40px; height: 40px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .quick { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 1.35rem; }
  .card-head, .card-body { padding-left: 14px; padding-right: 14px; }
  .toolbar { padding-left: 14px; padding-right: 14px; }
  .result-count { padding-left: 14px; }
  .tab-body { gap: 14px; }
  .facts { grid-template-columns: 1fr; }
  .facts dt { padding-bottom: 0; border-bottom: 0; margin-top: 8px; }
  .facts dd { padding-top: 2px; }
  .sheet-links { grid-template-columns: 1fr 1fr; }
  .theme-options { grid-template-columns: 1fr; }
  .period-bar { gap: 8px; }
  .period-seg { width: 100%; }
  .period-seg .seg { width: 100%; }
  .period-seg .seg button { flex: 1 1 auto; padding: 8px 9px; }
  .period-label { width: 100%; }
  .card-actions { width: 100%; }
  .report-head .card-actions { justify-content: flex-start; }
  .report-head .card-actions .btn { flex: 1 1 auto; }
  .profile-head { padding: 14px; }
  .profile-actions { width: 100%; }
  .profile-actions .btn { flex: 1; }
  .person-cell strong { max-width: 200px; }
  .roll-list { grid-template-columns: 1fr; }
  .lines-head { display: none; }
  .line-row { flex-wrap: wrap; background: var(--surface); padding: 8px; border-radius: 10px; border: 1px solid var(--border); }
  .line-row input { flex: 1 1 100% !important; }
  .line-row input[type=number] { flex: 1 1 30% !important; }
  .line-row .line-x { margin-left: auto; }

  /* Stacked "cards" for data tables */
  .table-wrap { overflow: visible; }
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  table.data tbody tr:last-child { border-bottom: 0; }
  table.data td { border: 0; padding: 4px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: right; min-height: 0; }
  table.data td::before { content: attr(data-label); color: var(--muted); font-size: .76rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; text-align: left; flex: 0 0 auto; max-width: 42%; }
  table.data td:first-child { display: block; text-align: left; padding-bottom: 6px; }
  table.data td:first-child::before { display: none; }
  table.data td.row-actions { display: flex; justify-content: flex-end; width: 100%; padding-top: 6px; }
  table.data td.row-actions::before { display: none; }
  table.data td.hide-sm, table.data td.hide-md { display: none; }
  table.data tbody tr:hover td { background: none; }
  table.data tbody tr:hover { background: var(--surface-2); }
  table.data tr.is-link { cursor: pointer; }
  table.data tfoot { display: block; }
  table.data tfoot tr { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 12px 14px; background: var(--surface-2); }
  table.data tfoot td { display: block; width: auto; padding: 0; background: none; }
  table.data tfoot td::before { content: attr(data-label); display: block; font-size: .7rem; color: var(--muted); text-transform: uppercase; }
  table.data td .progress { min-width: 0; margin-top: 4px; }
  .sev-card .card-head { padding-bottom: 0; }
  .search { flex-basis: 100%; }
  .select-wrap { flex: 1 1 calc(50% - 4px); }
  .select-wrap select { width: 100%; }
  .toolbar .select-wrap { min-width: 0; }

  /* Modals become bottom sheets */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal, .modal-sm, .modal-md, .modal-lg, .modal-sheet { max-width: none; width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; transform: translateY(40px); }
  .modal-backdrop.open .modal { transform: none; }
  .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1 1 auto; }
  .modal-body { padding-left: 16px; padding-right: 16px; }
  .modal-head { padding-left: 16px; padding-right: 16px; }
  .modal-head h2 { font-size: 1.05rem; }

  .sticky-actions { bottom: calc(var(--tabbar-h) + 8px + env(safe-area-inset-bottom)); }
  .setup-card { padding: 22px 18px; border-radius: 20px; }
  .setup-brand { gap: 12px; }
  .setup-brand h1 { font-size: 1.3rem; }
  .setup-actions .btn { width: 100%; }
}

/* Tablet: collapsible sidebar (drawer) */
@media (min-width: 640px) {
  .topbar-brand { display: inline-flex; }
  .topbar .topbar-brand { display: none; }
  .topbar-search { display: inline-flex; }
  .content { padding: 24px 24px 48px; }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabbar { display: none; }
  .modal-backdrop { padding: 24px; }
  .sheet-links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .roll-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticky-actions { bottom: 12px; }
  .table-wrap::-webkit-scrollbar { height: 8px; }
}
@media (min-width: 640px) and (max-width: 1023.98px) {
  .topbar-brand { display: none; }
  .topbar .icon-btn.nav-toggle { display: inline-flex; }
  .content { padding-bottom: 40px; }
}
/* Desktop: fixed sidebar */
@media (min-width: 1024px) {
  body.nav-open .sidebar { transform: none; box-shadow: none; }
  .sidebar { transform: none; }
  .main-wrap { margin-left: var(--sidebar-w); }
  .scrim { display: none; }
  .topbar-brand { display: none; }
  .nav-toggle { display: none !important; }
  .content { padding: 28px 32px 56px; }
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .quick { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .quick-item { flex-direction: column; text-align: center; justify-content: center; padding: 14px 10px; gap: 8px; }
  .quick-item > span { white-space: normal; }
  .quick-item > .ico:last-child { display: none; }
  .quick-item > .ico:first-child { width: 22px; height: 22px; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search { flex: 0 1 300px; }
  .toolbar .select-wrap { min-width: 160px; }
  .tab-body > .card:only-child { margin-top: 0; }
  .topbar-search { display: inline-flex; }
  .topbar-search { position: relative; }
  .modal-backdrop { padding: 24px; }
  .sheet-links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1360px) {
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .content { padding-left: 40px; padding-right: 40px; }
}

/* Hide desktop-only helpers on phones */
@media (max-width: 1023.98px) {
  .topbar .icon-btn.nav-toggle { display: inline-flex; }
}
.nav-toggle { display: none; }
@media (min-width: 640px) and (max-width: 1023.98px) { .nav-toggle { display: inline-flex; } }
@media (max-width: 639.98px) { .nav-toggle { display: inline-flex; } }

/* ---------- Print: the report only ---------- */
@media print {
  @page { margin: 14mm 12mm; }
  body { background: #fff !important; color: #000; font-size: 11pt; }
  .sidebar, .topbar, .tabbar, .scrim, .toasts, .no-print, .page-head, .period-bar, .report-picker, .toolbar, .modal-backdrop { display: none !important; }
  .main-wrap { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  .report-card { box-shadow: none; border: 0; margin: 0; }
  .report-card .card-head { display: none; }
  .report-card .card-body { padding: 0; }
  .print-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #0E2A47; padding-bottom: 8px; margin-bottom: 14px; }
  .print-brand { display: flex; align-items: center; gap: 10px; }
  .print-brand img { display: block; }
  .print-meta { text-align: right; display: flex; flex-direction: column; font-size: 9.5pt; }
  .print-kpis { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; gap: 6px !important; margin-bottom: 12px; }
  .print-kpis .kpi { box-shadow: none; padding: 8px; }
  .print-kpis .kpi-ico { display: none; }
  .kpi::after { display: none; }
  .table-wrap { overflow: visible !important; }
  table.data { font-size: 9pt; }
  table.data th, table.data td { padding: 5px 6px !important; border-bottom: 1px solid #ddd !important; }
  table.data thead { display: table-header-group !important; }
  table.data tr { display: table-row !important; }
  table.data td { display: table-cell !important; }
  table.data td::before { display: none !important; }
  table.data thead th { background: #f3f5f9 !important; color: #000 !important; }
  tr { break-inside: avoid; }
}
