/* ==========================================================================
   Nasiya — design system
   Tokens → base → layout → components → pages → utilities
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #f1f3f6;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e4e7ec;
  --line-2: #eef0f3;

  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-ink: #ffffff;
  --brand-soft: #eef2ff;
  --brand-line: #c7d2fe;

  --ok: #047857;  --ok-solid: #059669;  --ok-soft: #ecfdf5;  --ok-line: #a7f3d0;
  --warn: #b45309; --warn-solid: #d97706; --warn-soft: #fffbeb; --warn-line: #fde68a;
  --bad: #b91c1c;  --bad-solid: #dc2626;  --bad-soft: #fef2f2;  --bad-line: #fecaca;
  --grey: #475569; --grey-soft: #f1f5f9;
  --info: #1d4ed8; --info-soft: #eff6ff;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, .08), 0 2px 6px -2px rgba(15, 23, 42, .05);
  --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, .25);
  --ring: 0 0 0 3px rgba(79, 70, 229, .22);

  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 20px;
  --nav-h: 64px; --side-w: 264px; --top-h: 60px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* dark: follows the OS unless the user picked a theme; data-theme="dark" forces it */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0d14; --surface: #111621; --surface-2: #0e131c; --surface-3: #171d2a;
    --ink: #e6e9ef; --ink-2: #c3cad6; --muted: #8b95a7; --faint: #5d6778; --line: #1f2633; --line-2: #19202b;
    --brand: #818cf8; --brand-hover: #a5b4fc; --brand-ink: #0b1020; --brand-soft: rgba(129, 140, 248, .13); --brand-line: rgba(129, 140, 248, .35);
    --ok: #34d399; --ok-solid: #10b981; --ok-soft: rgba(16, 185, 129, .12); --ok-line: rgba(16, 185, 129, .3);
    --warn: #fbbf24; --warn-solid: #f59e0b; --warn-soft: rgba(245, 158, 11, .12); --warn-line: rgba(245, 158, 11, .3);
    --bad: #f87171; --bad-solid: #ef4444; --bad-soft: rgba(239, 68, 68, .12); --bad-line: rgba(239, 68, 68, .3);
    --grey: #a3adbd; --grey-soft: rgba(148, 163, 184, .12); --info: #60a5fa; --info-soft: rgba(96, 165, 250, .12);
    --shadow-xs: none; --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, .55); --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
    --ring: 0 0 0 3px rgba(129, 140, 248, .3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0d14; --surface: #111621; --surface-2: #0e131c; --surface-3: #171d2a;
  --ink: #e6e9ef; --ink-2: #c3cad6; --muted: #8b95a7; --faint: #5d6778; --line: #1f2633; --line-2: #19202b;
  --brand: #818cf8; --brand-hover: #a5b4fc; --brand-ink: #0b1020; --brand-soft: rgba(129, 140, 248, .13); --brand-line: rgba(129, 140, 248, .35);
  --ok: #34d399; --ok-solid: #10b981; --ok-soft: rgba(16, 185, 129, .12); --ok-line: rgba(16, 185, 129, .3);
  --warn: #fbbf24; --warn-solid: #f59e0b; --warn-soft: rgba(245, 158, 11, .12); --warn-line: rgba(245, 158, 11, .3);
  --bad: #f87171; --bad-solid: #ef4444; --bad-soft: rgba(239, 68, 68, .12); --bad-line: rgba(239, 68, 68, .3);
  --grey: #a3adbd; --grey-soft: rgba(148, 163, 184, .12); --info: #60a5fa; --info-soft: rgba(96, 165, 250, .12);
  --shadow-xs: none; --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, .55); --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
  --ring: 0 0 0 3px rgba(129, 140, 248, .3);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; font: 15px/1.5 var(--font); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
h1, h2, h3 { color: var(--ink); letter-spacing: -.015em; }
h1 { font-size: 1.5rem; line-height: 1.25; font-weight: 700; margin: 0; }
h2 { font-size: 1.05rem; font-weight: 650; margin: 1.5rem 0 .65rem; }
h3 { font-size: .95rem; font-weight: 600; margin: 1rem 0 .5rem; }
b, strong { font-weight: 600; }
code { font: 500 .9em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-3); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
::selection { background: var(--brand-soft); }
:focus-visible { outline: none; box-shadow: var(--ring); }
.ico { flex: none; display: inline-block; vertical-align: middle; }

/* ---------- utilities ---------- */
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.xs { font-size: .76rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; white-space: normal; }
.grow { flex: 1 1 0; min-width: 0; }
.stack > * + * { margin-top: .85rem; }
.stack.tight > * + * { margin-top: .5rem; }
.grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.filters { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid > * { margin: 0 !important; min-width: 0; }
@media (max-width: 640px) {
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid.stats .stat { padding: 13px; }
  .grid.stats .stat .v { font-size: 1.05rem; }
  .grid.stats .stat.hero { grid-column: 1 / -1; }
  .grid.stats .stat.hero .v { font-size: 1.45rem; }
  .grid.stats .stat .tile { display: none; }
  .grid.stats .stat.hero .tile { display: grid; }
}
.pre { white-space: pre-wrap; word-break: break-word; }
.divider { height: 1px; background: var(--line); margin: 1rem 0; border: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ==========================================================================
   Layout: sidebar (desktop) · topbar · bottom nav (mobile)
   ========================================================================== */
.app { display: flex; min-height: 100vh; }
.side { display: none; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 18px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }

.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top-h);
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line-2);
}
.topbar .crumb { font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .crumb span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 50%, #7c3aed 100%); box-shadow: 0 4px 12px -4px rgba(79, 70, 229, .6);
}
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: .72rem; letter-spacing: 0; }

/* sidebar */
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: .68rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 14px 12px 5px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 7px 12px; border-radius: 9px; color: var(--ink-2);
  font-weight: 500; font-size: .92rem; position: relative; transition: background .15s, color .15s;
}
.nav-item .ico { color: var(--muted); transition: color .15s; }
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item:hover .ico { color: var(--ink-2); }
.nav-item.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item.on .ico { color: var(--brand); }
.nav-item .count { margin-left: auto; }
.count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--bad-solid); color: #fff; font-size: .7rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.count.warn { background: var(--warn-solid); }

.side-foot { flex: none; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; min-width: 0; }
.user-chip .meta { min-width: 0; flex: 1; }
.user-chip .name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .role { font-size: .75rem; color: var(--muted); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: .85rem; letter-spacing: .02em;
}

/* bottom nav (mobile) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
}
.bottom-nav a, .bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font: 500 .68rem var(--font); background: none; border: 0; cursor: pointer; position: relative;
}
.bottom-nav a::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; border-radius: 0 0 2px 2px; background: transparent; transition: background .2s; }
.bottom-nav .on { color: var(--brand); font-weight: 600; }
.bottom-nav .on::before { background: var(--brand); }
.bottom-nav .count { position: absolute; top: 6px; left: calc(50% + 4px); height: 17px; min-width: 17px; font-size: .62rem; padding: 0 4px; }

@media (min-width: 1024px) {
  .side {
    display: flex; flex-direction: column; width: var(--side-w); flex: none; position: sticky; top: 0; height: 100vh;
    padding: 18px 14px 12px; overflow: hidden; background: var(--surface); border-right: 1px solid var(--line);
  }
  .side .side-nav { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; }
  .side .brand { padding: 2px 8px 10px; }
  .bottom-nav, .topbar .mobile-only { display: none; }
  .main { padding: 28px 32px 48px; }
  .topbar { padding: 0 32px; }
}
@media (max-width: 1023.98px) { .desktop-only { display: none !important; } }

/* page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .titles { min-width: 0; }
.page-head .sub { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 500; color: var(--muted); margin-bottom: 10px; }
.back:hover { color: var(--ink); }

/* ==========================================================================
   Components
   ========================================================================== */

/* card */
.card, .stat, .list-item .meta { overflow-wrap: anywhere; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-xs); }
.card + .card { margin-top: 10px; }
.card.link:not(.row) { display: block; }
.card.link { color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
.card.link:hover { border-color: var(--brand-line); box-shadow: var(--shadow-md); color: inherit; }
.card.flat { box-shadow: none; background: var(--surface-2); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title { font-weight: 650; font-size: .98rem; display: flex; align-items: center; gap: 8px; }
.card-title .ico { color: var(--muted); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 1.6rem 0 .75rem; }
.section-title h2 { margin: 0; }

/* list rows inside a card */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-xs); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; color: inherit; border-top: 1px solid var(--line-2); transition: background .12s; }
.list-item:first-child { border-top: 0; }
a.list-item:hover, .list-item.clickable:hover { background: var(--surface-2); color: inherit; cursor: pointer; }
.list-item .main-col { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .meta { color: var(--muted); font-size: .82rem; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .end { text-align: right; flex: none; }
.list-item .chev { color: var(--faint); }

/* icon tile */
.tile { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand); }
.tile.sm { width: 32px; height: 32px; border-radius: 9px; }
.tile.ok { background: var(--ok-soft); color: var(--ok); }
.tile.warn { background: var(--warn-soft); color: var(--warn); }
.tile.bad { background: var(--bad-soft); color: var(--bad); }
.tile.grey { background: var(--grey-soft); color: var(--grey); }
.tile.info { background: var(--info-soft); color: var(--info); }

/* stat */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-xs); position: relative; min-width: 0; }
.stat .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.stat .l { color: var(--muted); font-size: .8rem; font-weight: 500; }
.stat .v { font-size: 1.32rem; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; word-break: break-word; line-height: 1.25; }
.stat .hint { color: var(--muted); font-size: .76rem; margin-top: 4px; }
.stat.ok .v { color: var(--ok); }
.stat.warn { border-color: var(--warn-line); background: linear-gradient(180deg, var(--warn-soft), var(--surface) 70%); }
.stat.bad { border-color: var(--bad-line); background: linear-gradient(180deg, var(--bad-soft), var(--surface) 70%); }
.stat.bad .v { color: var(--bad); }
.stat.hero { background: linear-gradient(135deg, #4f46e5, #7c3aed); border-color: transparent; color: #fff; }
.stat.hero .l, .stat.hero .hint { color: rgba(255, 255, 255, .78); }
.stat.hero .tile { background: rgba(255, 255, 255, .16); color: #fff; }

/* banner (alert) — icon comes from CSS so every banner gets one */
.banner {
  display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; border-radius: var(--r); padding: 12px 14px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); font-weight: 500; font-size: .9rem; margin: 0;
}
.banner::before { content: ""; flex: none; width: 18px; height: 18px; margin-top: 1px; background: currentColor; -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
.banner > * { min-width: 0; }
.banner.row.between > :first-child, .banner > span:first-of-type { flex: 1; }
a.banner:hover { filter: brightness(.98); }
.banner { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E"); }
.banner.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 11.08V12a10 10 0 1 1-5.93-9.14'/%3E%3Cpath d='m9 11 3 3L22 4'/%3E%3C/svg%3E"); }
.banner.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E"); }
.banner.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E"); }
.banner .btn { margin-left: auto; }

/* empty / loading */
.empty { text-align: center; color: var(--muted); padding: 36px 16px; border: 1px dashed var(--line); border-radius: var(--r-lg); background: var(--surface); font-size: .9rem; }
.empty .tile { margin: 0 auto 12px; width: 48px; height: 48px; border-radius: 14px; background: var(--surface-3); color: var(--muted); }
.empty .empty-title { color: var(--ink); font-weight: 600; margin-bottom: 2px; }
.spin { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--muted); font-size: .9rem; }
.spin::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.skeleton { border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* form */
label.f { display: block; min-width: 0; }
label.f > span { display: block; font-size: .82rem; font-weight: 550; color: var(--ink-2); margin-bottom: 6px; }
label.f > span b { color: var(--bad-solid); font-weight: 600; }
input, select, textarea {
  width: 100%; font: inherit; font-size: .94rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--muted)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; padding: 0; margin: 0; accent-color: var(--brand); box-shadow: none; flex: none; cursor: pointer; }
input[type=date] { min-width: 0; }
.input-icon { position: relative; }
.input-icon > .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon > input { padding-left: 38px; }
.date-input { position: relative; }
.date-input > input:first-child { padding-right: 42px; }
.date-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.date-btn:hover { background: var(--surface-3); color: var(--ink); }
.date-native { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.chk { display: flex; align-items: flex-start; gap: 10px; padding: 4px 0; font-size: .9rem; color: var(--ink-2); cursor: pointer; line-height: 1.4; }
.chk input { margin-top: 1px; }
.err { color: var(--bad); font-size: .82rem; margin-top: 5px; display: flex; gap: 6px; align-items: center; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }

/* buttons */
.btn {
  --b-bg: var(--surface); --b-fg: var(--ink); --b-line: var(--line);
  font: 600 .9rem var(--font); letter-spacing: -.005em; border-radius: 10px; border: 1px solid var(--b-line);
  background: var(--b-bg); color: var(--b-fg); padding: 9px 15px; min-height: 42px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; white-space: nowrap;
  box-shadow: var(--shadow-xs); transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); color: var(--b-fg); border-color: color-mix(in srgb, var(--line) 60%, var(--muted)); }
.btn:active { transform: translateY(1px); }
.btn.primary { --b-bg: var(--brand); --b-fg: var(--brand-ink); --b-line: var(--brand); box-shadow: 0 1px 2px rgba(79, 70, 229, .25), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.ok { --b-bg: var(--ok-solid); --b-fg: #fff; --b-line: var(--ok-solid); }
.btn.ok:hover { background: color-mix(in srgb, var(--ok-solid) 88%, #000); }
.btn.danger { --b-bg: var(--surface); --b-fg: var(--bad); --b-line: var(--bad-line); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.ghost { --b-bg: transparent; --b-line: transparent; --b-fg: var(--ink-2); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.soft { --b-bg: var(--brand-soft); --b-fg: var(--brand); --b-line: transparent; box-shadow: none; }
.btn.soft:hover { background: color-mix(in srgb, var(--brand-soft) 70%, var(--brand) 12%); }
.btn.block { width: 100%; }
.btn.lg { min-height: 48px; font-size: .95rem; border-radius: 12px; }
.btn.sm { min-height: 34px; padding: 5px 11px; font-size: .84rem; border-radius: 9px; gap: 6px; }
.btn.icon { padding: 0; width: 40px; min-height: 40px; }
.btn.icon.sm { width: 34px; min-height: 34px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600;
  white-space: nowrap; line-height: 1.6; border: 1px solid transparent; vertical-align: middle;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.chip.grey { background: var(--grey-soft); color: var(--grey); border-color: var(--line); }
.chip.blue { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-line); }
.chip.plain::before { display: none; }

/* tabs: segmented control */
.tabs { display: flex; gap: 2px; padding: 3px; overflow-x: auto; background: var(--surface-3); border: 1px solid var(--line-2); border-radius: 11px; width: fit-content; max-width: 100%; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none; border: 0; background: transparent; color: var(--muted); border-radius: 8px; padding: 6px 13px;
  font: 550 .85rem var(--font); cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-xs); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); }

/* key/value details */
.kv { display: grid; grid-template-columns: minmax(110px, 160px) 1fr; gap: 10px 16px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; } }

/* progress */
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--ok-solid), #34d399); transition: width .4s var(--ease); }

/* neutral entry */
.entry { position: relative; padding-left: 18px; overflow: hidden; }
.entry::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--warn-solid); }
.entry.over::before { background: var(--bad-solid); }
.entry.over { border-color: var(--bad-line); }
.entry.approved::before { background: var(--ok-solid); }
.entry.rejected::before { background: var(--faint); }
.entry.rejected { opacity: .78; }
.entry .amount { font-size: 1.1rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.lines { margin-top: 12px; font-size: .86rem; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 4px 12px; }
.lines div { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px dashed var(--line); }
.lines div:first-child { border-top: 0; }
.lines b { font-variant-numeric: tabular-nums; }
.bulkbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); margin-bottom: 12px; }

/* wizard */
.steps { display: flex; gap: 6px; margin-bottom: 18px; counter-reset: step; }
.step { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; font-size: .76rem; font-weight: 550; color: var(--faint); }
.step::before { content: ""; height: 4px; border-radius: 999px; background: var(--line); transition: background .25s; }
.step.on { color: var(--brand); }
.step.on::before { background: var(--brand); }
.step.done { color: var(--ink-2); }
.step.done::before { background: var(--brand); opacity: .55; }
@media (max-width: 520px) { .step span { display: none; } }
.pick { cursor: pointer; border: 1.5px solid var(--line); transition: border-color .15s, background .15s, box-shadow .15s; }
.pick:hover { border-color: var(--brand-line); }
.pick.sel { border-color: var(--brand); background: var(--brand-soft); box-shadow: var(--ring); }
.wizard-foot { display: flex; align-items: center; gap: 8px; padding-top: 16px; margin-top: 8px; border-top: 1px solid var(--line); }

/* modal */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade .15s ease-out;
}
.modal {
  background: var(--surface); width: 100%; max-width: 560px; border-radius: var(--r-xl) var(--r-xl) 0 0; border: 1px solid var(--line);
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); animation: up .2s var(--ease);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
@media (min-width: 640px) { .overlay { align-items: center; padding: 24px; } .modal { border-radius: var(--r-xl); padding: 22px 24px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { opacity: 0; transform: translateY(16px) scale(.985); } }

/* toast */
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px;
  max-width: 440px; width: max-content; box-shadow: var(--shadow-lg); pointer-events: auto; font-size: .9rem; font-weight: 500; animation: up .2s var(--ease);
}
.toast .ico { margin-top: 1px; color: #34d399; }
.toast.bad { background: var(--bad-solid); color: #fff; }
.toast.bad .ico { color: #fff; }
@media (min-width: 1024px) { .toasts { left: auto; right: 24px; bottom: 24px; align-items: flex-end; } }

/* menu sheet (mobile) */
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.menu-grid a { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px; border-radius: 14px; color: var(--ink-2); font-size: .78rem; font-weight: 550; text-align: center; position: relative; border: 1px solid var(--line); background: var(--surface-2); }
.menu-grid a.on { border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand); }
.menu-grid .count { position: absolute; top: 8px; right: 8px; }

/* misc */
.copy-box { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 12px; font-size: .88rem; color: var(--ink-2); line-height: 1.55; }
.amount-lg { font-size: 1.6rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.dot-sep::before { content: "·"; margin: 0 6px; color: var(--faint); }

/* ==========================================================================
   Login
   ========================================================================== */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.auth-aside { display: none; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { margin-bottom: 28px; }
.auth-card h1 { font-size: 1.6rem; }
.auth-card .sub { color: var(--muted); margin: 6px 0 24px; }
@media (min-width: 960px) {
  .auth { grid-template-columns: minmax(420px, 1fr) 1fr; }
  .auth-aside {
    display: flex; flex-direction: column; justify-content: space-between; padding: 48px; color: #fff; position: relative; overflow: hidden;
    background: radial-gradient(1200px 600px at -10% -10%, #6366f1 0%, transparent 55%), radial-gradient(800px 500px at 110% 110%, #7c3aed 0%, transparent 55%), #1e1b4b;
  }
  .auth-aside .brand { color: #fff; }
  .auth-aside .brand small { color: rgba(255, 255, 255, .7); }
  .auth-aside h2 { color: #fff; font-size: 2rem; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 14px; max-width: 460px; }
  .auth-aside p { color: rgba(255, 255, 255, .78); max-width: 440px; margin: 0; }
  .feature { display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; color: rgba(255, 255, 255, .88); font-size: .92rem; }
  .feature .tile { background: rgba(255, 255, 255, .12); color: #fff; }
  .feature b { color: #fff; display: block; }
}

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
  .side, .bottom-nav, .topbar, .btn, .tabs, .toasts, .page-head .actions { display: none !important; }
  .main { max-width: none; padding: 0; }
  body, .card, .stat, .tbl-wrap { background: #fff !important; box-shadow: none !important; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
