/* ==========================================================================
   Bharat Miles · Hub reporting desk
   Typeface: Poppins (self-hosted). Light theme by default, dark theme on toggle.
   ========================================================================== */

@font-face { font-family: "Poppins"; font-style: normal; font-weight: 300; font-display: swap; src: url("fonts/poppins-latin-300-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/poppins-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/poppins-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/poppins-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/poppins-latin-700-normal.woff2") format("woff2"); }

:root {
  --font: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --brand: #f15a22;
  --brand-2: #ff8a4c;
  --brand-deep: #d9480f;
  --navy: #0b1b36;
  --navy-2: #12284d;

  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --line: #e4e9f2;
  --line-2: #d6deea;
  --ink: #0f1d38;
  --ink-2: #3f4d68;
  --muted: #7a89a4;

  /* chart series (validated for colour-blind separation) */
  --c1: #2563eb;
  --c2: #f15a22;
  --c3: #7c3aed;
  --good: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --grid: #e9edf4;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 29, 56, .04), 0 1px 1px rgba(15, 29, 56, .03);
  --shadow: 0 1px 2px rgba(15, 29, 56, .04), 0 12px 32px -12px rgba(15, 29, 56, .12);
  --shadow-lg: 0 24px 60px -20px rgba(11, 27, 54, .35);
  --sidebar: linear-gradient(180deg, #0b1b36 0%, #0a1830 60%, #08142a 100%);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #070f1f;
  --surface: #0e1a30;
  --surface-2: #0b162a;
  --surface-3: #13213b;
  --line: #1b2a46;
  --line-2: #24375a;
  --ink: #e9eef8;
  --ink-2: #b4c0d6;
  --muted: #7d8dab;
  --c1: #4f86f7;
  --c2: #ea5a20;
  --c3: #9670f0;
  --good: #22c55e;
  --bad: #f05252;
  --warn: #f59e0b;
  --grid: #18263f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 16px 40px -18px rgba(0, 0, 0, .6);
  --sidebar: linear-gradient(180deg, #08132a 0%, #060f22 100%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-deep); }
img { max-width: 100%; display: block; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.45rem, 2.2vw, 1.85rem); font-weight: 600; line-height: 1.2; letter-spacing: -.02em; }
h2 { font-size: 1rem; font-weight: 600; letter-spacing: -.01em; }
strong, b { font-weight: 600; }
small { font-size: .78rem; }
.ic { width: 18px; height: 18px; flex: 0 0 auto; }
.muted { color: var(--muted); }
.block { display: block; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 18px; }
.mb { margin-bottom: 18px; }
.good { color: var(--good) !important; }
.bad { color: var(--bad) !important; }
.strong { font-weight: 600; color: var(--ink); }
.eyebrow { color: var(--brand); letter-spacing: .14em; text-transform: uppercase; font-size: .7rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.eyebrow .ic { width: 14px; height: 14px; }
.eyebrow.light { color: #ffc6aa; }
.logo-d { display: none; }
[data-theme="dark"] .logo-l { display: none; }
[data-theme="dark"] .logo-d { display: block; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  background: linear-gradient(135deg, var(--brand-2), var(--brand) 55%, var(--brand-deep));
  color: #fff; font-weight: 500; font-size: .9rem; cursor: pointer; white-space: nowrap;
  box-shadow: 0 8px 20px -8px rgba(241, 90, 34, .65), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.btn:hover { color: #fff; transform: translateY(-1px); filter: brightness(1.04); box-shadow: 0 12px 26px -10px rgba(241, 90, 34, .75); }
.btn:active { transform: translateY(0); }
.btn .ic { width: 17px; height: 17px; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { border-color: var(--line-2); background: var(--surface-2); color: var(--ink); }
.btn.glass { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .22); box-shadow: none; backdrop-filter: blur(8px); }
.btn.danger { background: var(--bad); box-shadow: none; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: .8rem; border-radius: 10px; gap: 6px; }
.btn.sm .ic { width: 15px; height: 15px; }
.btn.lg { min-height: 50px; font-size: .95rem; border-radius: 14px; }
.btn.full { width: 100%; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); position: relative; list-style: none;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line-2); color: var(--ink); }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn.sm .ic { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.icon-btn em, .sidebar a em {
  position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: .68rem; font-style: normal; font-weight: 600; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.flip .ic, .bar > a:first-child .ic { transform: rotate(180deg); }

/* ---------- Forms ---------- */
.field { display: block; margin: 0 0 14px; min-width: 0; }
.field > span { display: block; font-size: .78rem; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.field input, .field select, .field textarea, .search input, .range-pop input {
  width: 100%; min-height: 44px; padding: 9px 13px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.field textarea { min-height: 110px; resize: vertical; }
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a89a4' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 38px; }
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus, .cell:focus {
  border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent);
}
.field input::placeholder, .field textarea::placeholder, .search input::placeholder { color: var(--muted); }
.icon-field > div { position: relative; }
.icon-field > div > .ic { position: absolute; left: 13px; top: 13px; color: var(--muted); }
.icon-field input { padding-left: 42px; }
.peek { position: absolute; right: 6px; top: 6px; width: 34px; height: 32px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 8px; display: grid; place-items: center; }
.peek:hover { color: var(--ink); background: var(--surface-3); }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: .86rem; color: var(--ink-2); margin: 6px 0 12px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.form-card > h2 { margin-bottom: 16px; }
.row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.cell { width: 110px; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; background: var(--surface); text-align: right; outline: none; }

/* ---------- Toasts & notes ---------- */
.banner, .note {
  display: flex; gap: 10px; align-items: flex-start; border-radius: 14px; padding: 12px 16px; margin: 0 0 18px;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm); font-size: .88rem;
}
.banner .ic, .note .ic { margin-top: 2px; }
.banner.ok { border-color: color-mix(in srgb, var(--good) 35%, transparent); background: color-mix(in srgb, var(--good) 8%, var(--surface)); }
.banner.ok .ic { color: var(--good); }
.banner.error { border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.banner.error .ic { color: var(--bad); }
.note { background: color-mix(in srgb, var(--brand) 7%, var(--surface)); border-color: color-mix(in srgb, var(--brand) 25%, transparent); color: var(--ink-2); }
.note .ic { color: var(--brand); }
.toast {
  position: fixed; top: 18px; right: 18px; z-index: 60; display: flex; gap: 10px; align-items: center; max-width: min(420px, calc(100vw - 36px));
  background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); animation: drop .35s ease;
}
.toast.error .ic { color: #ff8a8a; }
.toast.ok .ic { color: #6ee7a8; }
.demo { border-radius: 14px; padding: 12px 14px; margin: 14px 0; background: var(--surface-2); border: 1px dashed var(--line-2); color: var(--ink-2); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 10px; font-size: .72rem; font-weight: 500;
  background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand-deep);
}
[data-theme="dark"] .badge { color: #ffa77d; }
.badge.soft { background: var(--surface-3); color: var(--ink-2); }
.badge.green { background: color-mix(in srgb, var(--good) 13%, transparent); color: var(--good); }
.badge.amber { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.badge.red { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }

/* ==========================================================================
   Sign-in
   ========================================================================== */
.guest { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; background: var(--bg); }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; padding: 44px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  background:
    radial-gradient(700px 420px at 105% 105%, rgba(241, 90, 34, .55), transparent 60%),
    radial-gradient(500px 360px at -10% -10%, rgba(37, 99, 235, .35), transparent 60%),
    linear-gradient(150deg, #0b1b36 0%, #12284d 55%, #1b2f58 100%);
}
.route-lines { position: absolute; inset: 0; opacity: .45; pointer-events: none; }
.route-lines svg { width: 100%; height: 100%; }
.route-lines path { fill: none; stroke: rgba(255, 255, 255, .22); stroke-width: 1.4; stroke-dasharray: 6 8; animation: dash 30s linear infinite; }
.route-lines circle { fill: #ff8a4c; }
.hero-logo { width: 220px; position: relative; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .3)); }
.hero-copy { position: relative; max-width: 520px; }
.hero-copy h1 { font-size: clamp(2.2rem, 3.6vw, 3.25rem); font-weight: 600; letter-spacing: -.03em; margin: 12px 0 22px; line-height: 1.08; }
.hero-copy ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.hero-copy li { display: flex; gap: 10px; align-items: center; font-size: 1rem; color: rgba(255, 255, 255, .86); }
.hero-copy li .ic { color: #ff9a66; }
.hero-stats { position: relative; display: flex; gap: 12px; flex-wrap: wrap; }
.hero-stats span { flex: 1 1 140px; padding: 14px 16px; border-radius: 16px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .12); backdrop-filter: blur(10px); font-size: .78rem; color: rgba(255, 255, 255, .7); }
.hero-stats strong { display: block; font-size: 1.05rem; color: #fff; }
.auth-side { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card {
  position: relative; width: min(440px, 100%); padding: 34px 32px; border-radius: 26px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: rise .5s ease;
}
.auth-logo { width: 150px; margin: 0 auto 18px; }
.auth-card h2 { font-size: 1.6rem; font-weight: 600; letter-spacing: -.02em; }
.auth-card > p.muted { margin: 4px 0 20px; }
.auth-card .row { margin: 2px 0 18px; font-size: .86rem; }
.auth-card .row .check { margin: 0; }
.role-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 14px; background: var(--surface-3); margin-bottom: 18px; }
.role-tabs button { display: flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); font-weight: 500; cursor: pointer; transition: all .2s ease; }
.role-tabs button.on { background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; box-shadow: 0 8px 18px -8px rgba(241, 90, 34, .7); }
.auth-foot { display: flex; gap: 8px; align-items: center; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.auth-foot .ic { width: 15px; height: 15px; }
.theme-mini { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); display: grid; place-items: center; cursor: pointer; }

/* ==========================================================================
   App shell
   ========================================================================== */
.app { display: flex; }
.nav-toggle, .backdrop { display: none; }
.sidebar {
  position: sticky; top: 0; height: 100vh; width: 264px; flex: 0 0 264px; background: var(--sidebar); color: #fff;
  padding: 22px 16px 16px; display: flex; flex-direction: column; overflow-y: auto; z-index: 30;
  border-right: 1px solid rgba(255, 255, 255, .04);
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 6px; }
.brand { display: block; padding: 2px 8px 18px; margin-bottom: 6px; border-bottom: 1px solid rgba(255, 255, 255, .07); }
.brand img { width: 158px; }
.nav-title { margin: 18px 12px 8px; font-size: .66rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: rgba(255, 255, 255, .38); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 12px;
  color: rgba(255, 255, 255, .7); font-size: .88rem; font-weight: 400; transition: background .18s ease, color .18s ease;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar nav a.active {
  color: #fff; font-weight: 500;
  background: linear-gradient(135deg, rgba(255, 138, 76, .95), rgba(241, 90, 34, .95));
  box-shadow: 0 10px 24px -10px rgba(241, 90, 34, .8), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.sidebar nav a em { position: static; margin-left: auto; box-shadow: none; }
.side-user {
  margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 16px;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .07);
}
.side-user form { margin-left: auto; }
.side-user .who { min-width: 0; }
.side-user .who strong { display: block; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who small { color: rgba(255, 255, 255, .5); }
.logout { width: 34px; height: 34px; border-radius: 10px; border: 0; background: transparent; color: rgba(255, 255, 255, .6); display: grid; place-items: center; cursor: pointer; }
.logout:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.avatar {
  position: relative; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #2b4c85, #1b3a6b); color: #fff; font-size: .8rem; font-weight: 600; letter-spacing: .02em;
}
.avatar i { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; background: #22c55e; border: 2px solid #0b1b36; }
.avatar.sm { width: 32px; height: 32px; border-radius: 10px; font-size: .7rem; background: color-mix(in srgb, var(--c1) 14%, var(--surface)); color: var(--c1); }
.avatar.sm.sq { color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, var(--surface)); }
.avatar.sm .ic { width: 16px; height: 16px; }
.avatar.lg { width: 48px; height: 48px; border-radius: 14px; font-size: .95rem; }

.workspace { flex: 1; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; min-height: 70px; padding: 12px 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.menu-btn, .top-logo { display: none; }
.top-logo img { height: 34px; width: auto; }
.search { position: relative; flex: 1; max-width: 520px; }
.search .ic { position: absolute; left: 14px; top: 12px; color: var(--muted); }
.search input { padding-left: 42px; background: var(--surface); }
.today { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink-2); font-size: .84rem; white-space: nowrap; }
.today .ic { width: 16px; height: 16px; color: var(--muted); }
#theme-toggle .ic:last-child, .theme-mini .ic:last-child { display: none; }
[data-theme="dark"] #theme-toggle .ic:first-child, [data-theme="dark"] .theme-mini .ic:first-child { display: none; }
[data-theme="dark"] #theme-toggle .ic:last-child, [data-theme="dark"] .theme-mini .ic:last-child { display: block; }
.pop { position: relative; }
.pop summary { list-style: none; cursor: pointer; }
.pop summary::-webkit-details-marker { display: none; }
.profile summary { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 10px 0 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.profile summary .avatar { width: 34px; height: 34px; border-radius: 10px; }
.profile summary > .ic { width: 16px; height: 16px; color: var(--muted); }
.who { display: flex; flex-direction: column; line-height: 1.2; }
.who strong { font-size: .84rem; }
.who small { color: var(--muted); font-size: .72rem; }
.pop-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: min(360px, 88vw); padding: 8px; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); animation: drop .2s ease;
}
.pop-panel.narrow { width: 220px; }
.pop-panel form { margin: 0; }
.pop-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: .86rem; }
.pop-item { display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 10px; border-radius: 12px; color: var(--ink); border: 0; background: transparent; text-align: left; cursor: pointer; }
.pop-item:hover { background: var(--surface-2); color: var(--ink); }
.pop-item > span:nth-child(2) { flex: 1; min-width: 0; }
.pop-item strong { display: block; font-size: .84rem; }
.pop-item small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pop-item time { font-size: .7rem; color: var(--muted); white-space: nowrap; }
.pop-item.unread strong::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); margin-left: 6px; vertical-align: middle; }
.dot-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); flex: 0 0 auto; }
.dot-ic .ic { width: 16px; height: 16px; }
.pad { padding: 12px 10px; }

.page { padding: 28px 28px 56px; max-width: 1560px; animation: rise .4s ease; }
.intro { display: flex; justify-content: space-between; gap: 18px; align-items: flex-end; margin-bottom: 22px; }
.intro > div:first-child > p:not(.eyebrow) { color: var(--muted); max-width: 70ch; margin-top: 6px; }
.intro h1 { margin-top: 4px; }
.intro-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.tabbar { display: none; }

/* ---------- Toolbars & range picker ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 18px; }
.toolbar .field { margin: 0; min-width: 180px; flex: 0 1 220px; }
.toolbar .btn { min-height: 44px; }
.stepper { display: flex; gap: 6px; }
.range { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); overflow-x: auto; max-width: 100%; }
.seg button, .seg a { border: 0; background: transparent; height: 34px; padding: 0 13px; border-radius: 9px; color: var(--ink-2); font-size: .8rem; font-weight: 500; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; }
.seg button:hover, .seg a:hover { color: var(--ink); background: var(--surface-2); }
.seg .on { background: var(--navy); color: #fff !important; }
[data-theme="dark"] .seg .on { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg.small button, .seg.small a { height: 30px; padding: 0 11px; font-size: .76rem; }
.range-custom { position: relative; }
.range-custom summary { list-style: none; display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: .82rem; font-weight: 500; box-shadow: var(--shadow-sm); }
.range-custom summary::-webkit-details-marker { display: none; }
.range-custom summary .ic { width: 16px; height: 16px; color: var(--muted); }
.range-pop { position: absolute; z-index: 15; top: calc(100% + 8px); left: 0; display: flex; gap: 10px; align-items: flex-end; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); }
.range-pop label { font-size: .74rem; color: var(--muted); display: grid; gap: 4px; }

/* ==========================================================================
   Cards, KPIs and panels
   ========================================================================== */
.panel-card {
  position: relative; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.panel-card.flush { padding: 0; overflow: hidden; }
.panel-card.flush > .panel-head { padding: 20px 20px 0; margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.panel-head p { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.panel-head > .ic { color: var(--muted); transition: transform .2s ease; }
details.panel-card > summary { list-style: none; cursor: pointer; margin: 0; }
details.panel-card > summary::-webkit-details-marker { display: none; }
details.panel-card[open] > summary { margin-bottom: 14px; }
details.panel-card[open] > summary > .ic { transform: rotate(180deg); }
details.panel-card.flush > summary { padding: 20px; }
details.panel-card.flush[open] > summary { padding-bottom: 6px; }
.panel-card.feature { background: radial-gradient(900px 300px at 10% -40%, color-mix(in srgb, var(--c1) 9%, transparent), transparent 70%), var(--surface); }
.empty-state { display: grid; place-items: center; gap: 10px; text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state > .ic { width: 34px; height: 34px; color: var(--line-2); }

.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.main-side { grid-template-columns: minmax(0, 1fr) 360px; }
.grid.side-main { grid-template-columns: 360px minmax(0, 1fr); }
.grid.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 18px; align-content: start; min-width: 0; }

.kpis { display: grid; gap: 16px; margin-bottom: 18px; }
.kpis.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpis.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi {
  --tone: var(--c1); position: relative; overflow: hidden; min-width: 0; padding: 18px 18px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .2s ease, box-shadow .2s ease;
}
.kpi:hover { transform: translateY(-2px); }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--tone); opacity: .85; }
.tone-c1 { --tone: var(--c1); } .tone-c2 { --tone: var(--c2); } .tone-c3 { --tone: var(--c3); } .tone-good { --tone: var(--good); } .tone-bad { --tone: var(--bad); }
.kpi-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.kpi-head p { color: var(--ink-2); font-size: .8rem; font-weight: 500; }
.kpi-icon { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 12px; display: grid; place-items: center; color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent); }
.kpi-icon .ic { width: 19px; height: 19px; }
.kpi-value { font-size: clamp(1.35rem, 1.9vw, 1.7rem); font-weight: 600; letter-spacing: -.02em; margin: 6px 0 8px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value small { font-size: .9rem; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .74rem; color: var(--muted); position: relative; z-index: 1; }
.delta { display: inline-flex; align-items: center; gap: 2px; padding: 2px 7px 2px 5px; border-radius: 999px; font-weight: 600; font-size: .72rem; }
.delta .ic { width: 13px; height: 13px; stroke-width: 2.4; }
.delta.up { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.delta.down { color: var(--bad); background: color-mix(in srgb, var(--bad) 11%, transparent); }
.delta.flat { color: var(--ink-2); background: var(--surface-3); padding: 2px 8px; }
.spark { display: block; width: calc(100% + 36px); height: 34px; margin: 10px -18px -16px; }

/* ---------- Hero (owner) ---------- */
.hero-panel {
  position: relative; overflow: hidden; display: flex; justify-content: space-between; gap: 24px; align-items: center; margin-bottom: 18px;
  padding: 26px 30px; border-radius: 22px; color: #fff; box-shadow: var(--shadow-lg);
  background: radial-gradient(600px 260px at 100% 0%, rgba(241, 90, 34, .5), transparent 60%), radial-gradient(500px 260px at 0% 120%, rgba(37, 99, 235, .35), transparent 60%), linear-gradient(135deg, #0b1b36, #15305c);
}
.hero-text h1 { color: #fff; margin: 6px 0; }
.hero-text p:not(.eyebrow) { color: rgba(255, 255, 255, .72); max-width: 62ch; }
.hero-form { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.hero-form label { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 6px 0 12px; border-radius: 10px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .2); }
.hero-form label .ic { width: 16px; height: 16px; color: #ffc6aa; }
.hero-form select { background: transparent; border: 0; color: #fff; outline: none; font-size: .84rem; cursor: pointer; }
.hero-form select option { color: #0f1d38; }
.ring { position: relative; width: 132px; height: 132px; flex: 0 0 auto; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke: rgba(255, 255, 255, .14); stroke-width: 10; }
.ring circle.val { stroke: #ff8a4c; stroke-linecap: round; filter: drop-shadow(0 0 8px rgba(255, 138, 76, .5)); }
.ring div { text-align: center; }
.ring strong { display: block; font-size: 1.6rem; line-height: 1; }
.ring span { font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: rgba(255, 255, 255, .65); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.table-wrap.bare, .panel-card .table-wrap { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .72rem; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; background: var(--surface-2); white-space: nowrap; }
td { font-size: .86rem; color: var(--ink-2); }
td strong { color: var(--ink); }
tbody tr { transition: background .15s ease; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.unread td { background: color-mix(in srgb, var(--brand) 5%, transparent); }
tfoot tr { background: linear-gradient(90deg, var(--brand-2), var(--brand) 55%, var(--brand-deep)); }
tfoot td { font-weight: 600; color: #fff; background: transparent; border: 0; }
th.num, td.num { text-align: right; white-space: nowrap; }
td.wrap { min-width: 220px; white-space: normal; }
td.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions.end { justify-content: flex-end; flex-wrap: nowrap; }
td.actions { display: table-cell; white-space: nowrap; text-align: right; }
td.actions > * { display: inline-flex; vertical-align: middle; margin: 2px 0 2px 6px; }
td .btn { min-height: 34px; padding: 0 12px; font-size: .8rem; border-radius: 10px; gap: 6px; box-shadow: none; }
td .btn .ic { width: 15px; height: 15px; }
table.wide { min-width: 1060px; }
.actions form { margin: 0; }
.actions.bar { margin-bottom: 16px; }
.grow { flex: 1; }
.person { display: inline-flex; gap: 10px; align-items: center; color: inherit; }
.person strong { display: block; font-size: .86rem; line-height: 1.25; }
.person small { display: block; color: var(--muted); }
a.person:hover strong { color: var(--brand); }
.meter { display: inline-block; width: 70px; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; vertical-align: middle; margin-right: 8px; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--good); }
.meter.mid i { background: var(--warn); }
.meter.bad i { background: var(--bad); }
.meter-num { font-size: .8rem; color: var(--ink); }
td:has(.meter) { white-space: nowrap; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 4px; color: var(--muted); font-size: .84rem; }
.entry td { padding-top: 10px; padding-bottom: 10px; }
.mini-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.mini-stats span { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: .82rem; color: var(--ink-2); box-shadow: var(--shadow-sm); }
.mini-stats b { color: var(--ink); }
.mini-stats .ic { width: 16px; height: 16px; color: var(--muted); }
.mini-stats .good .ic, .mini-stats .good b { color: var(--good); }
.mini-stats .bad .ic, .mini-stats .bad b { color: var(--bad); }

/* ---------- People cards ---------- */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 22px; }
.person-card { padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .2s ease; }
.person-card:hover { transform: translateY(-2px); }
.person-card.off { opacity: .65; }
.pc-top { display: flex; gap: 12px; align-items: center; }
.pc-top > div { flex: 1; min-width: 0; }
.pc-top strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-top small { color: var(--muted); }
.person-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.person-card dt { font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.person-card dd { margin: 2px 0 0; font-weight: 600; font-size: .9rem; }
.person-card dd small { color: var(--muted); font-weight: 400; }
.person-card dd.sm { font-size: .74rem; font-weight: 500; }
.pc-actions { display: flex; gap: 8px; }
.pc-actions form { margin: 0; }

/* ---------- Lists ---------- */
.summary-list, .feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.summary-list li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px dashed var(--line); }
.summary-list li:last-child { border-bottom: 0; }
.summary-list span:nth-child(2) { flex: 1; color: var(--ink-2); font-size: .86rem; }
.summary-list b { font-size: 1rem; }
.feed li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed li > span:nth-child(2) { flex: 1; min-width: 0; }
.feed strong { display: block; font-size: .84rem; font-weight: 500; color: var(--ink); line-height: 1.35; }
.feed small { color: var(--muted); }
.feed time { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.feed .kpi-icon { width: 34px; height: 34px; border-radius: 10px; }
.feed .kpi-icon .ic { width: 16px; height: 16px; }

/* ==========================================================================
   Charts
   ========================================================================== */
.chart-area, .chart-cols { position: relative; display: grid; grid-template-columns: 46px minmax(0, 1fr); grid-template-rows: var(--h, 280px) auto; column-gap: 8px; }
.ca-y { position: relative; grid-row: 1; }
.ca-y span { position: absolute; right: 0; transform: translateY(50%); font-size: .7rem; color: var(--muted); white-space: nowrap; }
.ca-plot, .cc-plot { position: relative; grid-row: 1; grid-column: 2; }
.ca-grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed var(--grid); }
.ca-grid.base { border-top: 1px solid var(--line-2); }
.ca-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ca-line { fill: none; stroke-width: 2.4; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.ca-line.dash { stroke-width: 1.8; stroke-dasharray: 5 5; opacity: .9; }
.ca-fill { animation: fade .8s ease; }
.ca-dot { position: absolute; width: 10px; height: 10px; margin: 0 0 -5px -5px; border-radius: 50%; background: var(--surface); border: 2.4px solid var(--tone); box-shadow: 0 0 0 2px var(--surface); z-index: 2; pointer-events: none; transition: transform .15s ease; }
.ca-dot.hot { transform: scale(1.35); }
.ca-val { position: absolute; transform: translate(-50%, -14px); font-size: .7rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; pointer-events: none; z-index: 2; text-shadow: 0 0 3px var(--surface), 0 0 3px var(--surface); }
.ca-pill { position: absolute; transform: translate(-82%, -38px); padding: 3px 9px; border-radius: 8px; background: var(--c1); color: #fff; font-size: .72rem; font-weight: 600; white-space: nowrap; z-index: 3; pointer-events: none; box-shadow: 0 6px 16px -6px var(--c1); }
.ca-xhair { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--line-2); display: none; z-index: 1; pointer-events: none; }
.ca-hit { position: absolute; top: 0; bottom: 0; z-index: 4; cursor: crosshair; }
.ca-x, .cc-x { position: relative; grid-column: 2; height: 26px; margin-top: 8px; }
.ca-x span { position: absolute; transform: translateX(-50%); font-size: .7rem; color: var(--muted); white-space: nowrap; }
.chart-empty { display: grid; place-items: center; gap: 8px; min-height: 200px; color: var(--muted); text-align: center; border: 1px dashed var(--line-2); border-radius: 14px; font-size: .84rem; }
.chart-empty .ic { width: 28px; height: 28px; color: var(--line-2); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: .78rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 14px; height: 4px; border-radius: 4px; background: var(--tone); }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--tone) 0 4px, transparent 4px 7px); }

.cc-plot { display: flex; align-items: flex-end; gap: 4%; padding: 0 2%; }
.cc-group { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; z-index: 1; border-radius: 8px; cursor: default; }
.cc-group:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.cc-bar { position: relative; flex: 1; max-width: 34px; min-height: 2px; border-radius: 6px 6px 2px 2px; background: var(--tone); animation: grow .7s cubic-bezier(.2, .8, .2, 1); transform-origin: bottom; }
.cc-bar.soft { opacity: .38; }
.cc-bar em { position: absolute; left: 50%; top: -20px; transform: translateX(-50%); font-style: normal; font-size: .7rem; font-weight: 600; color: var(--ink); white-space: nowrap; }
.cc-x { display: flex; gap: 4%; padding: 0 2%; height: auto; }
.cc-x span { flex: 1; min-width: 0; text-align: center; font-size: .68rem; line-height: 1.25; color: var(--muted); overflow-wrap: anywhere; }

.hbars { display: grid; gap: 12px; }
.hbar { display: grid; grid-template-columns: minmax(64px, 96px) 1fr auto; gap: 12px; align-items: center; font-size: .82rem; }
.hbar-label { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: inherit; background: var(--tone); animation: widen .8s cubic-bezier(.2, .8, .2, 1); transform-origin: left; }
.hbar strong { font-size: .82rem; text-align: right; }

.donut-wrap { display: grid; grid-template-columns: 170px 1fr; gap: 20px; align-items: center; }
.donut-wrap.stack { grid-template-columns: 1fr; justify-items: center; }
.donut { position: relative; width: 170px; aspect-ratio: 1; }
.donut-wrap.stack .donut { width: 190px; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-track { fill: none; stroke: var(--surface-3); stroke-width: 15; }
.donut-seg { fill: none; stroke-width: 15; cursor: pointer; transition: stroke-width .2s ease; animation: fade .8s ease; }
.donut-seg:hover { stroke-width: 18; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center strong { font-size: 1.45rem; font-weight: 600; letter-spacing: -.02em; }
.donut-center span { font-size: .72rem; color: var(--muted); }
.donut-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; width: 100%; }
.donut-legend li { display: flex; align-items: center; gap: 10px; font-size: .84rem; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--tone); flex: 0 0 auto; }
.donut-legend span { flex: 1; color: var(--ink); min-width: 0; }
.donut-legend small { display: block; color: var(--muted); }
.donut-legend b { font-size: .8rem; color: var(--ink-2); }
.pay-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.pay-strip span { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: .7rem; color: var(--muted); }
.pay-strip b { display: block; font-size: .86rem; color: var(--ink); margin-top: 2px; white-space: nowrap; }
.pay-strip .pay { background: color-mix(in srgb, var(--good) 11%, transparent); }
.pay-strip .pay b { color: var(--good); }

.tip {
  position: fixed; z-index: 80; pointer-events: none; min-width: 150px; padding: 10px 12px; border-radius: 12px;
  background: #0b1b36; color: #fff; font-size: .78rem; box-shadow: var(--shadow-lg); border: 1px solid rgba(255, 255, 255, .08);
}
.tip strong { display: block; margin-bottom: 6px; font-size: .78rem; color: rgba(255, 255, 255, .75); font-weight: 500; }
.tip div { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.tip i { width: 8px; height: 8px; border-radius: 2px; }
.tip b { margin-left: auto; padding-left: 14px; font-weight: 600; }

/* ==========================================================================
   Billing statement (PDF layout)
   ========================================================================== */
.statement { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.st-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 24px 28px; border-bottom: 1px solid var(--line); background: linear-gradient(135deg, var(--surface-2), var(--surface)); }
.st-brand img { width: 170px; }
.st-ref { text-align: right; display: grid; justify-items: end; gap: 4px; }
.st-ref strong { font-size: 1.2rem; letter-spacing: -.01em; }
.st-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.st-meta div { background: var(--surface); padding: 14px 28px; }
.st-meta span { display: block; font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.st-meta strong { font-size: .9rem; }
.st-title { padding: 22px 28px 14px; font-size: 1.05rem; }
.st-title span { padding: 4px 12px; border-radius: 8px; background: color-mix(in srgb, #facc15 32%, transparent); color: var(--ink); }
.st-table { margin: 0 28px; border: 1px solid var(--line) !important; border-radius: 14px !important; }
.st-table table { min-width: 1000px; }
.st-table th, .st-table td { padding: 9px 9px; font-size: .75rem; border-right: 1px solid var(--line); }
.st-table th:last-child, .st-table td:last-child { border-right: 0; }
.st-table th { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--ink); white-space: normal; line-height: 1.25; }
.st-table tr.groups th { text-transform: uppercase; letter-spacing: .1em; font-size: .64rem; text-align: center; color: #fff; padding: 7px; }
.st-table .g-party { background: color-mix(in srgb, #f59e0b 16%, var(--surface)); }
.st-table .g-del { background: color-mix(in srgb, #16a34a 13%, var(--surface)); }
.st-table .g-rate { background: color-mix(in srgb, #2563eb 12%, var(--surface)); }
.st-table .g-amt { background: color-mix(in srgb, #f15a22 13%, var(--surface)); }
.st-table tr.groups .g-party { background: #d97706; }
.st-table tr.groups .g-del { background: #15803d; }
.st-table tr.groups .g-rate { background: #1d4ed8; }
.st-table tr.groups .g-amt { background: #e0531f; }
.st-table td { color: var(--ink); font-weight: 500; }
.st-bottom { display: grid; grid-template-columns: 1fr 380px; gap: 24px; padding: 24px 28px; align-items: start; }
.st-visual { display: grid; gap: 18px; }
.funnel { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); font-size: .8rem; }
.funnel span { display: block; color: var(--muted); font-size: .7rem; }
.funnel i { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.funnel em { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--c1), var(--good)); }
.st-totals { display: grid; gap: 0; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); }
.st-totals > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.st-totals span { color: var(--ink-2); font-size: .86rem; }
.st-totals b { font-size: 1.05rem; }
.st-totals .pay { background: linear-gradient(135deg, #0b1b36, #1b3a6b); border: 0; }
.st-totals .pay span { color: rgba(255, 255, 255, .75); }
.st-totals .pay b { color: #fff; font-size: 1.35rem; }
.st-totals p { padding: 12px 18px; font-size: .74rem; color: var(--muted); background: var(--surface-2); }
.st-totals.compact { margin: 16px 0; }
.st-totals.compact > div { padding: 11px 14px; }
.st-foot { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding: 14px 28px; border-top: 1px solid var(--line); font-size: .72rem; color: var(--muted); background: var(--surface-2); }

.calc.sticky { position: sticky; top: 90px; align-self: start; }
.calc-table { min-width: 0; }
.calc .muted.center { margin-top: 10px; font-size: .76rem; }
.ref { white-space: nowrap; }
.calc-table th, .calc-table td { padding: 8px 4px; font-size: .8rem; background: transparent; }
.calc-table th { text-transform: none; letter-spacing: 0; }
.key { display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--tone); margin-right: 8px; }
.calc-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; gap: 2px; background: var(--surface-3); margin-top: 6px; }
.calc-bar i { display: block; height: 100%; width: 0; transition: width .3s ease; }
.calc-bar .c1 { background: var(--c1); } .calc-bar .c2 { background: var(--c2); } .calc-bar .c3 { background: var(--c3); }
.check-sum > div { min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 13px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--line-2); font-size: .82rem; font-weight: 500; }
.check-sum.ok > div { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); background: color-mix(in srgb, var(--good) 8%, transparent); }
.check-sum.bad > div { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: color-mix(in srgb, var(--bad) 7%, transparent); }

/* ==========================================================================
   Motion
   ========================================================================== */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes widen { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes dash { to { stroke-dashoffset: -400; } }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1360px) {
  .kpis.five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.three-col { grid-template-columns: 1fr 1fr; }
  .grid.three-col > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 1180px) {
  .grid.main-side, .grid.side-main { grid-template-columns: 1fr; }
  .calc.sticky { position: static; }
  .kpis.four { grid-template-columns: 1fr 1fr; }
  .st-bottom { grid-template-columns: 1fr; }
  .today { display: none; }
}
@media (max-width: 1024px) {
  .guest { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-side { min-height: 100vh; background: radial-gradient(600px 300px at 100% 0%, rgba(241, 90, 34, .18), transparent 60%), var(--bg); }
}
@media (max-width: 900px) {
  .app { display: block; padding-bottom: 76px; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; width: min(86vw, 300px); transform: translateX(-105%); transition: transform .28s ease; box-shadow: var(--shadow-lg); }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(5, 12, 26, .55); backdrop-filter: blur(2px); }
  .nav-toggle:checked ~ .backdrop { display: block; }
  .menu-btn { display: inline-grid; }
  .top-logo { display: block; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .search { display: none; }
  .top-logo { margin-right: auto; }
  .profile .who, .profile summary > .ic { display: none; }
  .profile summary { padding: 0 4px; }
  .page { padding: 18px 14px 40px; }
  .intro { flex-direction: column; align-items: stretch; }
  .intro-actions .btn { flex: 1; }
  .kpis.five, .kpis.four, .grid.two, .grid.three-col { grid-template-columns: 1fr 1fr; }
  .grid.three-col > :last-child { grid-column: auto; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .hero-panel { flex-direction: column; align-items: flex-start; padding: 22px; }
  .ring { align-self: center; }
  .st-meta { grid-template-columns: 1fr 1fr; }
  .st-head, .st-title, .st-bottom, .st-foot, .st-meta div { padding-left: 18px; padding-right: 18px; }
  .st-table { margin: 0 18px; }
  .tabbar {
    position: fixed; z-index: 40; left: 10px; right: 10px; bottom: 10px; display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 6px; border-radius: 20px; background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line);
    box-shadow: var(--shadow-lg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); padding-bottom: calc(6px + env(safe-area-inset-bottom) / 2);
  }
  .tabbar a, .tabbar label { display: grid; justify-items: center; gap: 2px; padding: 7px 2px; border-radius: 14px; color: var(--muted); font-size: .66rem; font-weight: 500; cursor: pointer; }
  .tabbar .ic { width: 20px; height: 20px; }
  .tabbar a.active { color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
}
@media (max-width: 560px) {
  body { font-size: 13.5px; }
  .kpis.five, .kpis.four, .grid.two, .grid.three-col { grid-template-columns: 1fr; }
  .kpis.five { grid-template-columns: 1fr 1fr; }
  .kpis.five .kpi:first-child { grid-column: 1 / -1; }
  .kpi { padding: 14px; }
  .spark { width: calc(100% + 28px); margin: 8px -14px -14px; }
  .kpi-icon { width: 32px; height: 32px; border-radius: 10px; }
  .kpi-foot > span:last-child { display: none; }
  .panel-card { padding: 16px; }
  .chart-area, .chart-cols { grid-template-columns: 36px minmax(0, 1fr); column-gap: 4px; }
  .chart-area { --h: 220px !important; }
  .ca-val { display: none; }
  .ca-x span:nth-child(even):not(:last-child) { display: none; }
  .cc-x span { font-size: .6rem; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .pay-strip { grid-template-columns: 1fr; }
  .toolbar .field { flex: 1 1 100%; }
  .range .seg { width: 100%; }
  .auth-card { padding: 28px 22px; }
  .today, #theme-toggle { display: none; }
  .tip { max-width: 70vw; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   Print — statements and monthly reports print like the PDF
   ========================================================================== */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  :root, [data-theme="dark"] { --bg: #fff; --surface: #fff; --surface-2: #f7f8fa; --surface-3: #eef1f5; --line: #d9dee7; --line-2: #c9d0dc; --ink: #0f1d38; --ink-2: #3f4d68; --muted: #6b7890; --c1: #2563eb; --c2: #f15a22; --c3: #7c3aed; --good: #16a34a; --bad: #dc2626; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; box-shadow: none !important; animation: none !important; }
  .sidebar, .topbar, .tabbar, .no-print, .banner, .toolbar, .range, .intro-actions, .tip, .backdrop { display: none !important; }
  body, .app, .workspace, .page { display: block; background: #fff; padding: 0; margin: 0; max-width: none; }
  .logo-l { display: block !important; } .logo-d { display: none !important; }
  .panel-card, .kpi, .statement { break-inside: avoid; border-color: #d9dee7; }
  .grid.main-side { grid-template-columns: 1fr 1fr; }
  .st-table { margin: 0 12px; overflow: visible; }
  .st-table table { min-width: 0; }
  .st-table th, .st-table td { padding: 6px; font-size: 9px; }
  .st-bottom { grid-template-columns: 1fr 320px; padding: 12px 20px; gap: 16px; }
  .statement { break-inside: auto; border-radius: 12px; }
  .st-head { padding: 12px 20px; }
  .st-brand img { width: 130px; }
  .st-meta div { padding: 8px 20px; }
  .st-title { padding: 12px 20px 8px; font-size: .95rem; }
  .st-table { margin: 0 20px; }
  .donut { width: 120px; }
  .st-visual { gap: 10px; }
  .st-totals > div { padding: 9px 14px; }
  .st-foot { padding: 8px 20px; }
  .table-wrap { overflow: visible; }
  table { min-width: 0; }
}
