/* ═══════════════════════════════════════════════════════════════════════════
   FlatFly — design system. Mobile-first, light + dark.
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --border: #e3e9f2;
  --text: #0b1628;
  --text-2: #334155;
  --muted: #6b7a90;
  --brand: #16a34a;
  --brand-dark: #15803d;
  --blue: #2563eb;
  --navy: #0b2a6b;
  --grad: linear-gradient(135deg, #1d4ed8 0%, #0ea5a4 55%, #16a34a 100%);
  --grad-soft: linear-gradient(135deg, rgba(37,99,235,.10), rgba(22,163,74,.10));
  --green: #16a34a;   --green-bg: #dcfce7;  --green-ink: #166534;
  --red: #dc2626;     --red-bg: #fee2e2;    --red-ink: #991b1b;
  --amber: #d97706;   --amber-bg: #fef3c7;  --amber-ink: #92400e;
  --blue-bg: #dbeafe; --blue-ink: #1e40af;
  --purple: #7c3aed;  --purple-bg: #ede9fe; --purple-ink: #5b21b6;
  --pink: #db2777;    --pink-bg: #fce7f3;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 6px 20px rgba(15,23,42,.06);
  --shadow-lg: 0 20px 50px -12px rgba(15,23,42,.25);
  --r: 18px;
  --r-sm: 12px;
  --top-h: 60px;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070d1a; --surface: #0f1a2e; --surface-2: #0c1526; --surface-3: #16233b; --border: #1d2b45;
    --text: #e8eef8; --text-2: #c3cfe0; --muted: #8a9ab3;
    --green-bg: rgba(34,197,94,.14); --green-ink: #4ade80;
    --red-bg: rgba(248,113,113,.14); --red-ink: #f87171;
    --amber-bg: rgba(251,191,36,.14); --amber-ink: #fbbf24;
    --blue-bg: rgba(96,165,250,.14); --blue-ink: #93c5fd;
    --purple-bg: rgba(167,139,250,.15); --purple-ink: #c4b5fd;
    --pink-bg: rgba(244,114,182,.14);
    --grad-soft: linear-gradient(135deg, rgba(37,99,235,.18), rgba(22,163,74,.16));
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #070d1a; --surface: #0f1a2e; --surface-2: #0c1526; --surface-3: #16233b; --border: #1d2b45;
  --text: #e8eef8; --text-2: #c3cfe0; --muted: #8a9ab3;
  --green-bg: rgba(34,197,94,.14); --green-ink: #4ade80;
  --red-bg: rgba(248,113,113,.14); --red-ink: #f87171;
  --amber-bg: rgba(251,191,36,.14); --amber-ink: #fbbf24;
  --blue-bg: rgba(96,165,250,.14); --blue-ink: #93c5fd;
  --purple-bg: rgba(167,139,250,.15); --purple-ink: #c4b5fd;
  --pink-bg: rgba(244,114,182,.14);
  --grad-soft: linear-gradient(135deg, rgba(37,99,235,.18), rgba(22,163,74,.16));
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.02em; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.bold { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.green { color: var(--green-ink); } .red { color: var(--red-ink); } .amber { color: var(--amber-ink); } .blue { color: var(--blue-ink); }
.strike { text-decoration: line-through; opacity: .6; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hide { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 4px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.center { text-align: center; }
.right { text-align: right; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: 6px } .mt-2 { margin-top: 12px } .mt-3 { margin-top: 18px } .mt-4 { margin-top: 26px }
.mb-2 { margin-bottom: 12px } .mb-3 { margin-bottom: 18px }
.gap-2 { gap: 12px } .gap-1 { gap: 6px }

/* ═══ APP SHELL ═════════════════════════════════════════════════════════════ */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--top-h);
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 36px; height: 36px; border-radius: 11px; flex: none; object-fit: cover; box-shadow: var(--shadow-sm); background: var(--surface); }
.brand-name { font-weight: 800; font-size: 15.5px; line-height: 1.1; }
.brand-sub { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  display: inline-grid; place-items: center; font-size: 18px; cursor: pointer; position: relative; flex: none;
  transition: transform .15s, background .2s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn .dot {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 10.5px; font-weight: 800; display: grid; place-items: center;
  border: 2px solid var(--bg); animation: pop .4s cubic-bezier(.3,1.6,.5,1);
}
.theme-toggle .bi-sun-fill { display: none; }
:root[data-theme="dark"] .theme-toggle .bi-sun-fill { display: inline; }
:root[data-theme="dark"] .theme-toggle .bi-moon-stars-fill { display: none; }

.page { padding: 14px 14px calc(var(--nav-h) + var(--safe-b) + 28px); max-width: 1180px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; }
.page-head h1 { font-size: 22px; font-weight: 800; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.back { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); font-size: 18px; flex: none; }

/* bottom nav */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--border);
}
.bottomnav a, .bottomnav button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--muted);
  background: none; border: 0; padding: 6px 0; cursor: pointer; position: relative;
}
.bottomnav i { font-size: 21px; line-height: 1; transition: transform .2s; }
.bottomnav .active { color: var(--brand); }
.bottomnav .active i { transform: translateY(-2px); }
.bottomnav .active::after { content: ""; position: absolute; top: -1px; width: 26px; height: 3px; border-radius: 0 0 4px 4px; background: var(--grad); }
.bottomnav .fab-slot { position: relative; }
.bottomnav .fab, .fab {
  width: 58px; height: 58px; margin-top: -30px; border-radius: 20px; border: 4px solid var(--bg);
  background: var(--grad); color: #fff !important; display: grid; place-items: center; font-size: 26px;
  box-shadow: 0 10px 24px -6px rgba(22,163,74,.6); transition: transform .2s;
}
.bottomnav .fab:active, .fab:active { transform: scale(.9) rotate(90deg); }
.bottomnav .badge-dot { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 16px; height: 16px; font-size: 10px; border-radius: 8px; background: var(--red); color: #fff; display: grid; place-items: center; padding: 0 4px; }

/* desktop sidebar */
.sidebar { display: none; }
@media (min-width: 1024px) {
  .sidebar {
    display: flex; flex-direction: column; gap: 4px; position: fixed; top: 0; bottom: 0; left: 0; width: 250px; z-index: 50;
    background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; overflow-y: auto;
  }
  .sidebar .brand { padding: 4px 8px 16px; }
  .sidebar .nav-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 4px; }
  .sidebar a.nav { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; font-weight: 600; color: var(--text-2); font-size: 14px; }
  .sidebar a.nav i { font-size: 18px; width: 20px; text-align: center; }
  .sidebar a.nav:hover { background: var(--surface-3); }
  .sidebar a.nav.active { background: var(--grad-soft); color: var(--brand); }
  .with-sidebar { padding-left: 250px; }
  .bottomnav { display: none; }
  .topbar .brand.mobile-only { display: none; }
  .page { padding: 22px 28px 40px; }
}
@media (min-width: 1024px) { .mobile-only { display: none !important; } }
@media (max-width: 1023px) { .desktop-only { display: none !important; } }

/* ═══ CARDS & SURFACES ════════════════════════════════════════════════════ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow-sm); }
.card.pad-0 { padding: 0; overflow: hidden; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-title h3 { font-size: 16px; font-weight: 800; }
.card-title a { font-size: 13px; font-weight: 700; color: var(--brand); }
.section { margin-top: 18px; }
.section-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 22px 2px 10px; display: flex; align-items: center; justify-content: space-between; }
.section-title a { text-transform: none; letter-spacing: 0; color: var(--brand); font-size: 13px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .md-grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .md-grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (min-width: 1024px) { .lg-grid-3 { grid-template-columns: 2fr 1fr; align-items: start; } }

/* hero gradient card */
.hero-card {
  position: relative; overflow: hidden; border-radius: 24px; padding: 20px; color: #fff;
  background: var(--grad); box-shadow: 0 18px 40px -16px rgba(22,120,90,.55);
}
.hero-card::before, .hero-card::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.10); pointer-events: none;
}
.hero-card::before { width: 220px; height: 220px; right: -70px; top: -90px; animation: float 9s ease-in-out infinite; }
.hero-card::after { width: 140px; height: 140px; left: -50px; bottom: -70px; animation: float 11s ease-in-out infinite reverse; }
.hero-card > * { position: relative; z-index: 1; }
.hero-card .label { color: inherit; font-size: 12.5px; font-weight: 700; opacity: .88; letter-spacing: .02em; }
.hero-card .big { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; margin: 4px 0 2px; }
.hero-card .split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.hero-card .split > div { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.18); border-radius: 14px; padding: 10px 12px; }
.hero-card .split .v { font-size: 18px; font-weight: 800; }
.hero-card .split .k { font-size: 11.5px; opacity: .85; font-weight: 600; }
.hero-card .btn-white { background: #fff; color: #0b3b2a; }
.hero-card.paid { background: linear-gradient(135deg, #059669, #16a34a 60%, #65a30d); }
.hero-card.due { background: linear-gradient(135deg, #1d4ed8, #0ea5a4 60%, #16a34a); }

/* KPI tiles */
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s;
}
a.kpi:active, .kpi.tap:active { transform: scale(.97); }
a.kpi:hover { box-shadow: var(--shadow); }
.kpi .ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; }
.kpi .k { font-size: 12px; font-weight: 700; color: var(--muted); }
.kpi .v { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.kpi .t { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.tone-green .ico { background: var(--green-bg); color: var(--green-ink); }
.tone-red .ico { background: var(--red-bg); color: var(--red-ink); }
.tone-amber .ico { background: var(--amber-bg); color: var(--amber-ink); }
.tone-blue .ico { background: var(--blue-bg); color: var(--blue-ink); }
.tone-purple .ico { background: var(--purple-bg); color: var(--purple-ink); }
.tone-pink .ico { background: var(--pink-bg); color: var(--pink); }

/* balance formula strip */
.formula { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.formula > div { padding: 12px 8px; text-align: center; position: relative; }
.formula > div + div::before { content: attr(data-op); position: absolute; left: -9px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; border-radius: 50%; background: var(--surface-3); color: var(--muted); font-weight: 800; font-size: 12px; display: grid; place-items: center; z-index: 1; }
.formula .k { font-size: 11px; font-weight: 700; color: var(--muted); }
.formula .v { font-size: 15px; font-weight: 800; }
.formula .closing { background: var(--grad-soft); }
@media (max-width: 380px) { .formula .v { font-size: 13px; } }

/* quick tiles (icon grid) */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 4px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); text-align: center; font-size: 11.5px; font-weight: 700; color: var(--text-2); transition: transform .15s; position: relative; }
.tile:active { transform: scale(.94); }
.tile .ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 21px; }
.tile .count { position: absolute; top: 6px; right: 8px; background: var(--red); color: #fff; font-size: 10px; font-weight: 800; border-radius: 9px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(6, 1fr); } }

/* ═══ LISTS ═════════════════════════════════════════════════════════════════ */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface); position: relative; }
.list-item:last-child { border-bottom: 0; }
a.list-item:active, .list-item.tap:active { background: var(--surface-3); }
.list-item .av { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; }
.list-item .t1 { font-weight: 700; font-size: 14.5px; }
.list-item .t2 { font-size: 12.5px; color: var(--muted); }
.list-item .amt { font-weight: 800; font-size: 15px; text-align: right; white-space: nowrap; }
.av.green { background: var(--green-bg); color: var(--green-ink); }
.av.red { background: var(--red-bg); color: var(--red-ink); }
.av.amber { background: var(--amber-bg); color: var(--amber-ink); }
.av.blue { background: var(--blue-bg); color: var(--blue-ink); }
.av.purple { background: var(--purple-bg); color: var(--purple-ink); }
.av.grad { background: var(--grad); color: #fff; }

/* flat card on collect page */
.flat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 12px 12px 14px; display: flex; align-items: center; gap: 12px; transition: background .4s, border-color .4s, transform .2s; }
.flat-card .fno { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-3); display: grid; place-items: center; font-weight: 800; font-size: 13.5px; text-align: center; line-height: 1.1; flex: none; padding: 2px; word-break: break-all; }
.flat-card.is-paid { background: color-mix(in srgb, var(--green-bg) 55%, var(--surface)); border-color: color-mix(in srgb, var(--green) 30%, var(--border)); }
.flat-card.is-paid .fno { background: var(--green); color: #fff; }
.flat-card.flash { animation: flash .9s ease; }
.flat-list { display: flex; flex-direction: column; gap: 10px; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 800; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.nodot::before { display: none; }
.pill.paid, .pill.confirmed, .pill.active, .pill.resolved { background: var(--green-bg); color: var(--green-ink); }
.pill.pending, .pill.partial, .pill.inprogress { background: var(--amber-bg); color: var(--amber-ink); }
.pill.due, .pill.rejected, .pill.open { background: var(--red-bg); color: var(--red-ink); }
.pill.cancelled, .pill.closed, .pill.inactive { background: var(--surface-3); color: var(--muted); }
.pill.blue { background: var(--blue-bg); color: var(--blue-ink); }
.pill.purple { background: var(--purple-bg); color: var(--purple-ink); }
.pill.lg { font-size: 13px; padding: 6px 14px; }
.hero-card .pill { background: rgba(255,255,255,.2); color: #fff; }

/* ═══ BUTTONS ═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px;
  border-radius: 14px; border: 1px solid transparent; font-weight: 800; font-size: 14.5px; cursor: pointer; white-space: nowrap;
  transition: transform .12s, box-shadow .2s, background .2s, opacity .2s; user-select: none; text-decoration: none;
}
.btn:active { transform: scale(.96); }
.btn:disabled, .btn.loading { opacity: .6; pointer-events: none; }
.btn.loading::after { content: ""; width: 16px; height: 16px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px -8px rgba(22,163,74,.7); }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 8px 18px -8px rgba(22,163,74,.8); }
.btn-dark { background: var(--text); color: var(--bg); }
.btn-light { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-soft { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--red-bg); color: var(--red-ink); }
.btn-wa { background: #25d366; color: #fff; box-shadow: 0 8px 18px -8px rgba(37,211,102,.8); }
.btn-white { background: #fff; color: var(--navy); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-sm { height: 36px; padding: 0 13px; font-size: 13px; border-radius: 11px; }
.btn-xs { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 9px; gap: 5px; }
.btn-lg { height: 54px; font-size: 16px; border-radius: 16px; padding: 0 22px; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; }

.pay-btn { position: relative; overflow: hidden; }
.pay-btn::before { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.45) 50%, transparent 70%); transform: translateX(-100%); animation: shine 3s ease-in-out infinite; }

/* ═══ FORMS ═════════════════════════════════════════════════════════════════ */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-size: 16px; outline: none; transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
.field textarea { height: auto; min-height: 92px; padding: 12px 14px; resize: vertical; }
.field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%236b7a90' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.input-group { position: relative; }
.input-group .prefix { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-weight: 800; color: var(--muted); pointer-events: none; }
.input-group input { padding-left: 34px !important; }
.amount-input { font-size: 30px !important; font-weight: 800 !important; height: 66px !important; text-align: center; letter-spacing: -.02em; }
.amount-wrap { position: relative; }
.amount-wrap .prefix { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); font-size: 26px; font-weight: 800; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; cursor: pointer; }
.switch input { width: 44px; height: 26px; appearance: none; -webkit-appearance: none; background: var(--surface-3); border-radius: 13px; position: relative; cursor: pointer; transition: background .2s; flex: none; border: 1px solid var(--border); }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(18px); }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; font-size: 13.5px; font-weight: 600; background: var(--surface); }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.check:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--green-bg) 50%, var(--surface)); }

/* chip pickers */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; margin: 0 -14px; padding-left: 14px; padding-right: 14px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface); font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap; color: var(--text-2); transition: all .15s;
}
.chip i { font-size: 15px; }
.chip:active { transform: scale(.95); }
.chip.on { border-color: var(--brand); background: var(--brand); color: #fff; box-shadow: 0 6px 14px -6px rgba(22,163,74,.7); }
.chip .n { background: var(--surface-3); color: var(--text-2); border-radius: 8px; padding: 0 6px; font-size: 11px; min-width: 20px; text-align: center; }
.chip.on .n { background: rgba(255,255,255,.25); color: #fff; }
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 4px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--surface); font-size: 11px; font-weight: 700; text-align: center; cursor: pointer; line-height: 1.2; color: var(--text-2); transition: all .15s; }
.cat i { font-size: 20px; color: var(--muted); transition: color .15s; }
.cat.on { border-color: var(--brand); background: color-mix(in srgb, var(--green-bg) 60%, var(--surface)); color: var(--green-ink); }
.cat.on i { color: var(--brand); }
.cat:active { transform: scale(.94); }
@media (min-width: 720px) { .cat-grid { grid-template-columns: repeat(7, 1fr); } }

/* segmented tabs */
.seg { display: flex; background: var(--surface-3); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button, .seg a { flex: 1; height: 38px; border: 0; background: transparent; border-radius: 11px; font-weight: 800; font-size: 13px; color: var(--muted); cursor: pointer; display: grid; place-items: center; transition: all .2s; }
.seg .on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.upload { display: flex; align-items: center; gap: 12px; padding: 14px; border: 2px dashed var(--border); border-radius: 14px; cursor: pointer; background: var(--surface-2); }
.upload i { font-size: 24px; color: var(--brand); }
.upload input { display: none; }
.upload .preview { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; }

.search { position: relative; }
.search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 40px !important; height: 46px; }

/* ═══ SHEETS (bottom sheet modal) ══════════════════════════════════════════ */
.sheet-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(2,8,23,.5); opacity: 0; pointer-events: none; transition: opacity .25s; backdrop-filter: blur(2px); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 26px 26px 0 0; padding: 8px 18px calc(22px + var(--safe-b));
  transform: translateY(105%); transition: transform .32s cubic-bezier(.2,.9,.3,1); box-shadow: var(--shadow-lg);
}
.sheet::before { content: ""; display: block; width: 42px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 12px; }
.sheet.open { transform: none; }
/* Closed sheets must never catch clicks (on tablet/desktop they sit centred at opacity 0). */
.sheet:not(.open) { visibility: hidden; pointer-events: none; transition: transform .32s cubic-bezier(.2,.9,.3,1), opacity .2s, visibility 0s .32s; }
.sheet.open { visibility: visible; pointer-events: auto; }
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet h3 { font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.sheet .sheet-sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: 50%; width: 520px; border-radius: 24px; transform: translate(-50%, 60%) scale(.96); opacity: 0; transition: transform .25s, opacity .2s; }
  .sheet.open { transform: translate(-50%, 50%); opacity: 1; }
  .sheet::before { display: none; }
}
.qa-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.qa { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 6px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 700; font-size: 12.5px; text-align: center; }
.qa .ico { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; font-size: 23px; }
.qa:active { transform: scale(.95); }

/* ═══ TOAST ═════════════════════════════════════════════════════════════════ */
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + var(--safe-b) + 12px); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
@media (min-width: 1024px) { .toasts { bottom: 24px; left: auto; right: 24px; align-items: flex-end; } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 460px; width: 100%;
  background: #0b1628; color: #fff; padding: 12px 14px; border-radius: 16px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg);
  animation: toastIn .35s cubic-bezier(.2,1.2,.4,1);
}
:root[data-theme="dark"] .toast { background: #1e2d4a; }
.toast i { font-size: 20px; }
.toast.ok i { color: #4ade80; } .toast.err i { color: #f87171; }
.toast button { margin-left: auto; background: rgba(255,255,255,.14); border: 0; color: #fff; font-weight: 800; padding: 6px 12px; border-radius: 10px; cursor: pointer; }
.toast.out { animation: toastOut .25s forwards; }

/* ═══ CHARTS ════════════════════════════════════════════════════════════════ */
.ring { position: relative; width: 120px; height: 120px; flex: none; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 11; stroke-linecap: round; }
.ring .track { stroke: var(--surface-3); }
.ring .bar { stroke: url(#ringGrad); stroke-dasharray: 0 999; transition: stroke-dasharray 1.4s cubic-bezier(.2,.8,.2,1); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .lbl b { font-size: 24px; font-weight: 800; display: block; line-height: 1; }
.ring .lbl span { font-size: 11px; color: var(--muted); font-weight: 700; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.bars .m { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.bars .b { width: 42%; max-width: 18px; border-radius: 6px 6px 3px 3px; height: 0; transition: height 1.1s cubic-bezier(.2,.8,.2,1); position: relative; }
.bars .b.in { background: linear-gradient(180deg, #22c55e, #15803d); }
.bars .b.out { background: linear-gradient(180deg, #fb7185, #e11d48); }
.bars .lab { font-size: 10.5px; font-weight: 700; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; font-weight: 700; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.stack { display: flex; height: 12px; border-radius: 8px; overflow: hidden; background: var(--surface-3); }
.stack span { height: 100%; width: 0; transition: width 1.2s cubic-bezier(.2,.8,.2,1); }
.hbar { display: flex; flex-direction: column; gap: 10px; }
.hbar .r { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; font-weight: 700; }
.hbar .track { grid-column: 1 / -1; height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.hbar .fill { height: 100%; width: 0; border-radius: 6px; background: var(--grad); transition: width 1.2s cubic-bezier(.2,.8,.2,1); }

/* status legend rows */
.status-row { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 700; font-size: 14px; }
.status-row .sw { width: 12px; height: 12px; border-radius: 50%; }
.status-row .n { margin-left: auto; font-size: 18px; font-weight: 800; }
.status-row:active { transform: scale(.98); }

/* notice cards */
.notice { display: flex; gap: 12px; padding: 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--border); }
.notice .em { width: 44px; height: 44px; border-radius: 14px; background: var(--grad-soft); display: grid; place-items: center; font-size: 22px; flex: none; }
.notice.pinned { border-color: color-mix(in srgb, var(--amber) 45%, var(--border)); background: color-mix(in srgb, var(--amber-bg) 35%, var(--surface)); }
.notice .body { white-space: pre-line; font-size: 14px; color: var(--text-2); margin-top: 4px; }

.wa-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--r); background: linear-gradient(135deg, #25d366, #128c7e); color: #fff; box-shadow: 0 14px 30px -14px rgba(18,140,126,.8); }
.wa-card i { font-size: 30px; }
.wa-card b { font-size: 15px; display: block; }
.wa-card span { font-size: 12.5px; opacity: .92; }

.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; font-weight: 600; font-size: 13.5px; }
.banner.warn { background: var(--amber-bg); color: var(--amber-ink); }
.banner.info { background: var(--blue-bg); color: var(--blue-ink); }
.banner.err { background: var(--red-bg); color: var(--red-ink); }
.banner.ok { background: var(--green-bg); color: var(--green-ink); }
.banner i { font-size: 20px; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .em { font-size: 46px; margin-bottom: 8px; animation: bob 3s ease-in-out infinite; }
.empty b { color: var(--text); display: block; font-size: 16px; margin-bottom: 4px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 800; padding: 11px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl tfoot td { font-weight: 800; background: var(--surface-2); }

.receipt { max-width: 440px; margin: 0 auto; background: var(--surface); border-radius: 22px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); }
.receipt .top { background: var(--grad); color: #fff; padding: 22px; text-align: center; }
.receipt .tick { width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center; margin: 0 auto 10px; font-size: 32px; animation: pop .6s cubic-bezier(.3,1.6,.5,1); }
.receipt .lines { padding: 18px 22px; }
.receipt .ln { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.receipt .ln span:first-child { color: var(--muted); }
.receipt .ln b { text-align: right; }

.avatar { width: 38px; height: 38px; border-radius: 12px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.kbd { font-family: ui-monospace, monospace; background: var(--surface-3); padding: 2px 8px; border-radius: 8px; font-weight: 700; letter-spacing: .08em; }

/* ═══ ANIMATION ═════════════════════════════════════════════════════════════ */
.reveal { opacity: 0; transform: translateY(14px); animation: fadeUp .55s cubic-bezier(.2,.8,.2,1) forwards; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes fadeUp { to { opacity: 1; transform: none; } }
@keyframes float { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-14px, 12px); } }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shine { 0%, 60% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes toastIn { from { transform: translateY(20px) scale(.95); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(20px); opacity: 0; } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes flash { 0% { transform: scale(1); } 30% { transform: scale(1.03); box-shadow: 0 0 0 6px color-mix(in srgb, var(--green) 25%, transparent); } 100% { transform: scale(1); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.5); } 70% { box-shadow: 0 0 0 12px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }
.pulse { animation: pulse 2s infinite; }
.confetti { position: fixed; top: -10px; width: 9px; height: 14px; z-index: 300; pointer-events: none; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .8; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } .reveal { opacity: 1; transform: none; } }

@media print {
  .topbar, .bottomnav, .sidebar, .no-print, .toasts { display: none !important; }
  .with-sidebar { padding: 0 !important; }
  body { background: #fff; }
  .page { padding: 0; }
}
