/* ==========================================================================
   FinanceApp — PHP web edition
   One stylesheet, no build step. Colours are tokens on :root and are
   redefined for dark mode, so every component below is theme-agnostic.
   ========================================================================== */

:root {
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --bg:         #f3f5fa;
  --surface:    #ffffff;
  --surface-2:  #f7f9fc;
  --surface-3:  #eef1f7;
  --border:     #e3e7ef;
  --border-2:   #d4dae6;
  --text:       #0d1526;
  --muted:      #556079;
  --faint:      #8b94a8;

  /* Logo blue and logo red sit at the 600 step. */
  --brand:      #0140a6;
  --brand-700:  #013589;
  --brand-800:  #042c6d;
  --brand-ink:  #0140a6;
  --brand-50:   #eef4fd;
  --brand-100:  #d8e5fa;
  --brand-200:  #b3cbf4;
  --accent:     #de030b;
  --accent-700: #ba0409;
  --accent-50:  #fef2f2;
  --accent-100: #fde3e3;

  --pos:        #0e7a47;
  --pos-50:     #e8f6ee;
  --pos-100:    #c9ebd8;
  --neg:        #c4161c;
  --neg-50:     #fdeeee;
  --neg-100:    #f9d3d4;
  --warn:       #a85b06;
  --warn-50:    #fff5e5;
  --warn-100:   #fde4bb;
  --orange:     #c2410c;

  --series-1:   #0140a6;
  --series-2:   #d97706;
  --series-3:   #0e7a47;
  --series-4:   #7c3aed;
  --series-5:   #0891b2;
  --series-6:   #db2777;

  --shadow-sm:  0 1px 2px rgb(13 21 38 / .05);
  --shadow:     0 1px 2px rgb(13 21 38 / .04), 0 6px 18px -6px rgb(13 21 38 / .10);
  --shadow-lg:  0 2px 4px rgb(13 21 38 / .05), 0 18px 40px -12px rgb(13 21 38 / .22);
  --ring:       0 0 0 3px rgb(1 64 166 / .18);

  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  18px;
  --sidebar-w:  268px;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg:         #080e1b;
  --surface:    #0f1729;
  --surface-2:  #131d33;
  --surface-3:  #1a2640;
  --border:     #1f2c47;
  --border-2:   #2a3a5c;
  --text:       #e8edf6;
  --muted:      #a0abc3;
  --faint:      #6f7b95;

  --brand:      #2f6fe0;
  --brand-700:  #255bc0;
  --brand-800:  #1c4799;
  --brand-ink:  #7ea6f2;
  --brand-50:   #0f2047;
  --brand-100:  #16305f;
  --brand-200:  #23468a;
  --accent:     #ef3b40;
  --accent-700: #d72a30;
  --accent-50:  #2a0e12;
  --accent-100: #46161b;

  --pos:        #3fbf7f;
  --pos-50:     #0c2a1d;
  --pos-100:    #134430;
  --neg:        #f2686c;
  --neg-50:     #2d1014;
  --neg-100:    #4a1a20;
  --warn:       #f0a640;
  --warn-50:    #2b1d08;
  --warn-100:   #46300f;
  --orange:     #fb8a4f;

  --series-1:   #5b8ef0;
  --series-2:   #f0a640;
  --series-3:   #3fbf7f;
  --series-4:   #a78bfa;
  --series-5:   #38bdf8;
  --series-6:   #f472b6;

  --shadow-sm:  0 1px 2px rgb(0 0 0 / .4);
  --shadow:     0 1px 2px rgb(0 0 0 / .35), 0 8px 24px -10px rgb(0 0 0 / .6);
  --shadow-lg:  0 18px 44px -14px rgb(0 0 0 / .75);
  --ring:       0 0 0 3px rgb(91 142 240 / .30);

  color-scheme: dark;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.015em; }
p { margin: 0; }

img { max-width: 100%; display: block; }

.ico { width: 18px; height: 18px; flex-shrink: 0; }
.ico-sm { width: 15px; height: 15px; flex-shrink: 0; }
.ico-lg { width: 24px; height: 24px; flex-shrink: 0; }

.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.brand { color: var(--brand-ink); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ── App shell ────────────────────────────────────────────────────────────── */

.shell { min-height: 100vh; display: flex; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  height: 72px; padding: 0 22px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand img { height: 30px; width: auto; }
:root[data-theme="dark"] .sidebar-brand img,
:root[data-theme="dark"] .auth-logo img { background: #fff; border-radius: 6px; padding: 3px 6px; height: 34px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 18px 14px; }

.nav-label {
  margin: 18px 10px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint);
}
.nav-label:first-child { margin-top: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--brand-50); color: var(--brand-ink); }
.nav-item.active .ico { color: var(--brand-ink); }
.nav-item .lock { margin-left: auto; color: var(--faint); }
.nav-item .count {
  margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 99px;
  background: var(--surface-3); color: var(--muted); font-size: 12px; text-align: center;
}
.nav-item.active .count { background: var(--brand-100); color: var(--brand-ink); }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); }

.plan-chip {
  display: block; padding: 14px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-800), var(--brand) 70%);
  color: #fff;
}
.plan-chip:hover { text-decoration: none; filter: brightness(1.06); }
.plan-chip small { display: block; opacity: .75; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.plan-chip strong { display: block; margin-top: 2px; font-size: 15px; }
.plan-chip span { display: block; margin-top: 6px; font-size: 12px; opacity: .85; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: 72px; padding: 0 32px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 15px; font-weight: 700; color: var(--muted); }
.topbar-spacer { flex: 1; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  cursor: pointer; transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); }

.lang-switch { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-3); }
.lang-switch a {
  padding: 5px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 700; color: var(--muted);
}
.lang-switch a:hover { text-decoration: none; color: var(--text); }
.lang-switch a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 4px 4px; border-radius: 12px;
  border: 1px solid transparent; background: none; color: var(--text); cursor: pointer; font: inherit;
}
.user-btn:hover { background: var(--surface); border-color: var(--border); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 15px;
}
.avatar-lg { width: 64px; height: 64px; border-radius: 16px; font-size: 28px; }
.user-btn .who { text-align: left; line-height: 1.2; }
.user-btn .who strong { display: block; font-size: 13px; }
.user-btn .who small { color: var(--faint); font-size: 12px; }

.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; z-index: 50;
  padding: 6px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: none;
}
.dropdown.open { display: block; }
.dropdown a, .dropdown button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--text); font: 600 14px var(--font); text-align: left; cursor: pointer;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-3); text-decoration: none; }
.dropdown .danger { color: var(--neg); }
.dropdown hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

.menu-btn { display: none; }
.scrim { display: none; }

.page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 32px; }
.page-narrow { max-width: 760px; }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; z-index: 35; background: rgb(8 14 27 / .45); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; height: 64px; }
  .page { padding: 20px 16px 40px; }
  .user-btn .who { display: none; }
}

/* ── Banner & flash ───────────────────────────────────────────────────────── */

.site-banner { display: flex; align-items: center; gap: 10px; padding: 9px 32px; font-size: 13px; font-weight: 600; }
.site-banner.info { background: var(--brand); color: #fff; }
.site-banner.warning { background: #f59e0b; color: #3a2200; }
.site-banner.critical { background: var(--accent); color: #fff; }
.site-banner button { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .8; }

.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 600;
  animation: toast-in .25s ease;
}
.toast .ico { margin-top: 1px; }
.toast.success .ico { color: var(--pos); }
.toast.error .ico { color: var(--neg); }
.toast.info .ico { color: var(--brand-ink); }
.toast button { margin-left: auto; background: none; border: 0; color: var(--faint); cursor: pointer; padding: 0; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px; font-size: 14px; font-weight: 600;
}
.alert.error { background: var(--neg-50); color: var(--neg); border: 1px solid var(--neg-100); }
.alert.info { background: var(--brand-50); color: var(--brand-ink); border: 1px solid var(--brand-100); }
.alert.warn { background: var(--warn-50); color: var(--warn); border: 1px solid var(--warn-100); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 11px;
  border: 1px solid transparent; cursor: pointer;
  font: 700 14px var(--font); white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.busy { opacity: .6; pointer-events: none; }

.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 0 rgb(255 255 255 / .12) inset, 0 6px 14px -6px rgb(1 64 166 / .55); }
.btn-primary:hover { background: var(--brand-700); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 6px 14px -6px rgb(222 3 11 / .5); }
.btn-accent:hover { background: var(--accent-700); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-ink); }
.btn-soft { background: var(--brand-50); color: var(--brand-ink); }
.btn-soft:hover { background: var(--brand-100); }
.btn-danger-soft { background: var(--neg-50); color: var(--neg); }
.btn-danger-soft:hover { background: var(--neg-100); }
.btn-danger { background: var(--surface); color: var(--neg); border-color: var(--neg-100); }
.btn-danger:hover { background: var(--neg-50); }
.btn-white { background: #fff; color: var(--brand-800); }
.btn-white:hover { background: #eef4fd; }
.btn-glass { background: rgb(255 255 255 / .14); color: #fff; border-color: rgb(255 255 255 / .22); }
.btn-glass:hover { background: rgb(255 255 255 / .24); }

.btn-sm { height: 34px; padding: 0 12px; border-radius: 9px; font-size: 13px; }
.btn-lg { height: 50px; padding: 0 24px; font-size: 15px; border-radius: 13px; }
.btn-block { width: 100%; }

.link-btn {
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--brand-ink); font: 700 12px var(--font);
}
.link-btn:hover { text-decoration: underline; }

/* ── Page header ──────────────────────────────────────────────────────────── */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.page-head h1 { font-size: 28px; font-weight: 800; }
.page-head p { margin-top: 6px; color: var(--muted); max-width: 640px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 10px; }

.crumbs { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--faint); }
.crumbs a { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }

.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-ink); }

/* ── Cards ────────────────────────────────────────────────────────────────── */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 22px; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; margin-bottom: 16px; }
.card-sub { margin: -10px 0 16px; font-size: 13px; color: var(--muted); }

.section-card { overflow: hidden; }
.section-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.section-head h3 { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 800; }
.section-head .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--brand); }
.section-head .hint { margin-top: 2px; font-size: 12px; color: var(--muted); }
.section-head .total { text-align: right; }
.section-head .total small { display: block; font-size: 11px; color: var(--faint); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.section-head .total strong { font-size: 18px; font-weight: 800; }
.section-head .right { display: flex; align-items: center; gap: 14px; }
.section-body { padding: 18px 20px; }

.tone-brand .dot { background: var(--series-1); }
.tone-amber .dot { background: var(--series-2); }
.tone-orange .dot { background: var(--orange); }
.tone-navy .dot { background: var(--brand-800); }
.tone-green .dot { background: var(--pos); }

/* ── Forms ────────────────────────────────────────────────────────────────── */

.field { display: block; }
.field + .field { margin-top: 16px; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}

.input, .select, textarea.input {
  width: 100%; height: 44px; padding: 0 13px;
  border: 1px solid var(--border-2); border-radius: 11px;
  background: var(--surface); color: var(--text);
  font: 500 15px var(--font); font-variant-numeric: tabular-nums;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--faint); }
.input:hover, .select:hover { border-color: var(--faint); }
.input:focus, .select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%238b94a8' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input-sm, .select-sm { height: 38px; font-size: 14px; border-radius: 9px; }

.affix { position: relative; display: flex; align-items: center; }
.affix .pre, .affix .suf { position: absolute; font-size: 14px; font-weight: 600; color: var(--faint); pointer-events: none; }
.affix .pre { left: 13px; }
.affix .suf { right: 13px; }
.affix.has-pre .input { padding-left: 28px; }
.affix.has-suf .input { padding-right: 48px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}

.readout { padding: 12px 14px; border-radius: 11px; background: var(--surface-2); border: 1px dashed var(--border-2); }
.readout small { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.readout strong { display: block; margin-top: 2px; font-size: 18px; font-weight: 800; }
.readout .line { margin-top: 2px; font-size: 12px; color: var(--muted); }
.readout.brand { background: var(--brand-50); border: 1px solid var(--brand-100); }
.readout.brand strong { color: var(--brand-ink); }

.subline { margin-top: 7px; font-size: 12px; color: var(--muted); }
.subline b { color: var(--text); font-weight: 700; }

.check-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }

/* Line items */
.items { display: flex; flex-direction: column; gap: 8px; }
.item-head, .item-row { display: grid; gap: 8px; align-items: center; grid-template-columns: minmax(0, 1fr) 150px 34px; }
.item-head.typed, .item-row.typed { grid-template-columns: 165px minmax(0, 1fr) 150px 34px; }
.item-head { padding: 0 2px 2px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.item-head span:nth-last-child(2) { text-align: right; }
.item-row .affix .input { text-align: right; }
.remove-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 0; cursor: pointer;
  background: transparent; color: var(--faint); font-size: 20px; line-height: 1;
}
.remove-btn:hover { background: var(--neg-50); color: var(--neg); }
.items-empty { padding: 18px; text-align: center; border: 1px dashed var(--border-2); border-radius: 12px; color: var(--faint); font-size: 14px; }
.add-row { margin-top: 12px; }
@media (max-width: 640px) {
  .item-head { display: none; }
  .item-row, .item-row.typed { grid-template-columns: minmax(0, 1fr) 34px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; }
  .item-row > :not(.remove-btn) { grid-column: 1; }
  .item-row .remove-btn { grid-column: 2; grid-row: 1; }
}

.kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--border); }
.kv span { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.kv strong { font-weight: 700; }
.kv.total { border-top: 1px solid var(--border-2); padding-top: 12px; }
.kv.total span { color: var(--text); font-weight: 700; }

.exp-line { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.exp-line + .exp-line { margin-top: 10px; }
.exp-line .label { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; }
.exp-line .side { min-width: 92px; text-align: right; font-size: 13px; font-weight: 700; }
@media (max-width: 640px) { .exp-line { grid-template-columns: 1fr; gap: 6px; } .exp-line .side { text-align: left; } }

/* Help tip */
.tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--faint);
  font: 800 10px/1 var(--font); cursor: help; text-transform: none; letter-spacing: 0;
}
.tip:hover, .tip.on { color: var(--brand-ink); border-color: var(--brand); }
.tip-pop {
  position: absolute; z-index: 120; max-width: 300px;
  padding: 11px 13px; border-radius: 11px;
  background: #0d1526; color: #f1f4fa; box-shadow: var(--shadow-lg);
  font: 500 13px/1.5 var(--font); text-transform: none; letter-spacing: 0;
}
:root[data-theme="dark"] .tip-pop { background: #e8edf6; color: #0d1526; }

/* ── Layout grids ─────────────────────────────────────────────────────────── */

.split { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.split > .col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.sticky { position: sticky; top: 92px; }
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .sticky { position: static; }
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .grid-4, .grid-2 { grid-template-columns: 1fr; } }

.form-actions {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; gap: 10px; padding: 14px 0 4px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.form-actions .btn-primary { flex: 1; }

/* ── Figures ──────────────────────────────────────────────────────────────── */

.hero-fig {
  position: relative; overflow: hidden;
  padding: 22px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--surface);
}
.hero-fig::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, currentColor 0%, transparent 70%); opacity: .07; pointer-events: none;
}
.hero-fig .lbl { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hero-fig .val { margin-top: 8px; font-size: 38px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.hero-fig .cap { margin-top: 8px; font-size: 13px; color: var(--muted); }
.hero-fig.positive { background: var(--pos-50); border-color: var(--pos-100); color: var(--pos); }
.hero-fig.negative { background: var(--neg-50); border-color: var(--neg-100); color: var(--neg); }
.hero-fig.positive .val { color: var(--pos); }
.hero-fig.negative .val { color: var(--neg); }

.stat { padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); position: relative; overflow: hidden; }
.stat .lbl { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stat .val { margin-top: 6px; font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.stat .sub { margin-top: 2px; font-size: 12px; color: var(--faint); }
.stat.bar::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--brand)); }
.stat.hl { background: var(--brand-50); border-color: var(--brand-100); }
.stat.hl .val { color: var(--brand-ink); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.lg { padding: 7px 14px; font-size: 14px; }
.b-excellent, .b-free, .b-positive { background: var(--pos-50); color: var(--pos); }
.b-good, .b-healthy, .b-brand { background: var(--brand-50); color: var(--brand-ink); }
.b-fair, .b-not_free { background: var(--warn-50); color: var(--warn); }
.b-poor { background: #fff1e8; color: var(--orange); }
:root[data-theme="dark"] .b-poor { background: #2c1508; }
.b-negative { background: var(--neg-50); color: var(--neg); }
.b-muted { background: var(--surface-3); color: var(--muted); }

.meter { padding: 22px; }
.meter .top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.meter .val { font-size: 34px; font-weight: 800; letter-spacing: -.03em; }
.meter .track { position: relative; height: 12px; margin-top: 14px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter .fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand-700), var(--brand)); transition: width .4s ease; }
.meter .fill.done { background: linear-gradient(90deg, #0b6a3d, var(--pos)); }
.meter .ticks { position: relative; height: 18px; margin-top: 4px; font-size: 11px; color: var(--faint); }
.meter .ticks span { position: absolute; transform: translateX(-50%); }
.meter .mark { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--surface); opacity: .9; }
.meter .cap { margin-top: 6px; font-size: 13px; color: var(--muted); }

.alloc .bar { display: flex; height: 16px; margin: 6px 0 16px; border-radius: 99px; overflow: hidden; background: var(--surface-3); }
.alloc .bar span { height: 100%; transition: width .3s ease; }
.alloc .legend { display: flex; flex-direction: column; gap: 10px; }
.alloc .legend div { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; font-size: 13px; }
.alloc .legend i { width: 12px; height: 12px; border-radius: 4px; }
.alloc .legend b { font-weight: 700; }
.alloc .legend em { font-style: normal; color: var(--faint); min-width: 48px; text-align: right; }

.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font: 600 11px var(--font); fill: var(--faint); }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 4; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 50%; }
.donut-wrap { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 18px; align-items: center; }
@media (max-width: 480px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } }

.status-pills { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }

/* ── Record list ──────────────────────────────────────────────────────────── */

.records { display: flex; flex-direction: column; gap: 14px; }
.record {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) auto; gap: 20px; align-items: center;
  padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); transition: box-shadow .2s, border-color .2s, transform .2s;
}
.record:hover { box-shadow: var(--shadow); border-color: var(--border-2); }
.record.just-saved { border-color: var(--pos); box-shadow: 0 0 0 3px var(--pos-50); }
.record .who { display: flex; align-items: center; gap: 14px; min-width: 0; }
.record .who h3 { font-size: 16px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record .who h3 a { color: inherit; }
.record .who p { font-size: 13px; color: var(--faint); margin-top: 2px; }
.tile-ico {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 46px; height: 46px; border-radius: 13px;
  background: var(--brand-50); color: var(--brand-ink);
}
.record .figs { display: flex; flex-wrap: wrap; gap: 8px 28px; align-items: center; }
.record .fig strong { display: block; font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.record .fig small { font-size: 12px; color: var(--faint); font-weight: 600; }
.record .acts { display: flex; gap: 8px; }
.record .acts form { margin: 0; }
@media (max-width: 1100px) {
  .record { grid-template-columns: 1fr; }
}

.empty {
  padding: 64px 24px; text-align: center;
  border: 2px dashed var(--border-2); border-radius: var(--radius-lg); background: var(--surface);
}
.empty .tile-ico { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 16px; }
.empty h3 { font-size: 18px; font-weight: 800; }
.empty p { margin: 6px auto 20px; max-width: 420px; color: var(--muted); }

/* ── Dashboard ────────────────────────────────────────────────────────────── */

.welcome {
  position: relative; overflow: hidden;
  padding: 30px; border-radius: 22px;
  background: radial-gradient(1200px 400px at 100% 0%, rgb(255 255 255 / .14), transparent 60%),
              linear-gradient(135deg, #031d4d 0%, #0140a6 55%, #1e5fc4 100%);
  color: #fff;
}
.welcome::after {
  content: ""; position: absolute; right: -60px; bottom: -80px; width: 280px; height: 280px; border-radius: 50%;
  border: 40px solid rgb(255 255 255 / .06);
}
.welcome .row { position: relative; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; }
.welcome h1 { font-size: 28px; font-weight: 800; }
.welcome p { margin-top: 6px; opacity: .85; }
.welcome .avatar { width: 56px; height: 56px; border-radius: 16px; font-size: 22px; background: rgb(255 255 255 / .16); }

.kpis { margin: 20px 0 30px; }
.kpi { padding: 18px; display: flex; gap: 14px; align-items: center; }
.kpi .tile-ico { width: 44px; height: 44px; }
.kpi small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi strong { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.kpi em { display: block; font-style: normal; font-size: 12px; color: var(--faint); }

.tool-card { display: flex; flex-direction: column; padding: 24px; transition: transform .2s, box-shadow .2s; }
.tool-card.on:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tool-card.off { background: var(--surface-2); }
.tool-card .top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.tool-card.on .tile-ico { background: var(--brand); color: #fff; box-shadow: 0 8px 18px -8px rgb(1 64 166 / .6); }
.tool-card.off .tile-ico { background: var(--surface-3); color: var(--faint); }
.tool-card h3 { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.tool-card p { flex: 1; color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.tool-card .meta { font-size: 12px; color: var(--faint); font-weight: 600; margin-bottom: 14px; }

.cta-band {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px;
  margin-top: 24px; padding: 26px;
}
.cta-band .lead { display: flex; gap: 16px; align-items: flex-start; }
.cta-band h3 { font-size: 18px; font-weight: 800; }
.cta-band p { margin-top: 4px; color: var(--muted); font-size: 14px; }
.cta-band .tile-ico.red { background: var(--accent-50); color: var(--accent); }
.cta-band .tile-ico.ok { background: var(--brand); color: #fff; }

/* ── Plans ────────────────────────────────────────────────────────────────── */

.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; align-items: stretch; }
.plan {
  position: relative; display: flex; flex-direction: column;
  padding: 26px 24px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.plan.featured { border: 2px solid var(--accent); box-shadow: var(--shadow); }
.plan.current { border: 2px solid var(--brand); box-shadow: var(--shadow); }
.plan .ribbon {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  padding: 4px 12px; border-radius: 99px; white-space: nowrap;
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #fff;
  background: var(--accent);
}
.plan.current .ribbon { background: var(--brand); }
.plan h3 { font-size: 20px; font-weight: 800; }
.plan h3 small { font-size: 13px; font-weight: 600; color: var(--faint); margin-left: 4px; }
.plan .angle { min-height: 42px; margin-top: 6px; font-size: 13px; color: var(--muted); font-style: italic; }
.plan .price { margin-top: 18px; display: flex; align-items: baseline; gap: 6px; }
.plan .price strong { font-size: 40px; font-weight: 800; letter-spacing: -.03em; }
.plan .price span { font-size: 13px; color: var(--muted); font-weight: 600; }
.plan .equiv { margin-top: 2px; font-size: 12px; font-weight: 700; color: var(--accent); }
.plan .trial { margin-top: 10px; align-self: flex-start; }
.plan ul { list-style: none; margin: 20px 0 22px; padding: 0; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.plan li { display: flex; gap: 9px; font-size: 14px; color: var(--muted); }
.plan li .ico { color: var(--brand-ink); margin-top: 2px; width: 16px; height: 16px; }
.plan .note { margin-top: 10px; text-align: center; font-size: 12px; color: var(--faint); }
.picker { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.picker .ph { display: flex; justify-content: space-between; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pick {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px;
  border: 1px solid var(--border-2); cursor: pointer; font-size: 14px; font-weight: 600;
  transition: border-color .15s, background .15s;
}
.pick:hover { border-color: var(--brand-200); }
.pick input { accent-color: var(--brand); width: 16px; height: 16px; margin: 0; }
.pick:has(input:checked) { border-color: var(--brand); background: var(--brand-50); color: var(--brand-ink); }
.unlocked { margin: 18px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--brand-50); border: 1px solid var(--brand-100); }
.unlocked small { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-ink); }
.unlocked div { font-weight: 700; font-size: 14px; }

/* ── Auth & guest pages ───────────────────────────────────────────────────── */

.guest-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 32px; }
.guest-top .actions { display: flex; align-items: center; gap: 10px; }
.auth-logo img { height: 34px; width: auto; }
@media (max-width: 640px) { .guest-top { padding: 14px 16px; } .guest-top .hide-sm { display: none; } }

.auth {
  min-height: calc(100vh - 80px);
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
}
.auth-art {
  position: relative; overflow: hidden; margin: 0 0 24px 24px; border-radius: 26px;
  padding: 48px; display: flex; flex-direction: column; justify-content: flex-end; color: #fff;
  background: radial-gradient(800px 500px at 0% 0%, rgb(255 255 255 / .14), transparent 60%),
              linear-gradient(150deg, #031d4d, #0140a6 60%, #2563eb);
}
.auth-art::before {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgb(255 255 255 / .06) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / .06) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: linear-gradient(to bottom, #000, transparent 80%);
}
.auth-art > * { position: relative; }
.auth-art h2 { font-size: 34px; font-weight: 800; max-width: 440px; }
.auth-art p { margin-top: 12px; max-width: 440px; opacity: .85; }
.auth-art .mini { margin-top: 28px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 520px; }
.auth-art .mini div { padding: 14px; border-radius: 14px; background: rgb(255 255 255 / .1); border: 1px solid rgb(255 255 255 / .16); backdrop-filter: blur(6px); }
.auth-art .mini .ico { margin-bottom: 8px; }
.auth-art .mini b { display: block; font-size: 13px; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px 24px 56px; }
.auth-box { width: 100%; max-width: 420px; }
.auth-box h1 { font-size: 30px; font-weight: 800; }
.auth-box > p { margin: 8px 0 28px; color: var(--muted); }
.auth-box .alt { margin-top: 22px; text-align: center; font-size: 14px; color: var(--muted); }
.auth-box form .btn { margin-top: 22px; }
@media (max-width: 960px) { .auth { grid-template-columns: 1fr; } .auth-art { display: none; } }

/* Landing */
.land-hero { max-width: 1200px; margin: 0 auto; padding: 56px 32px 40px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; }
.land-hero h1 { font-size: clamp(34px, 5vw, 56px); font-weight: 800; letter-spacing: -.035em; line-height: 1.05; }
.land-hero h1 span { background: linear-gradient(90deg, var(--brand), #3b82f6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.land-hero .lead { margin-top: 18px; font-size: 17px; color: var(--muted); max-width: 540px; }
.land-hero .cta { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 12px; }
.land-hero .tagline { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 18px; padding: 6px 12px; border-radius: 99px; background: var(--brand-50); color: var(--brand-ink); font-size: 13px; font-weight: 700; }
.mock { padding: 22px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.mock .bars { display: flex; align-items: flex-end; gap: 10px; height: 140px; margin-top: 18px; }
.mock .bars span { flex: 1; border-radius: 8px 8px 3px 3px; background: linear-gradient(to top, var(--brand), #5b8ef0); opacity: .9; }
.land-section { max-width: 1200px; margin: 0 auto; padding: 48px 32px; }
.land-section .head { text-align: center; max-width: 640px; margin: 0 auto 32px; }
.land-section .head h2 { font-size: 32px; font-weight: 800; }
.land-section .head p { margin-top: 10px; color: var(--muted); }
.feature-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 28px; }
.land-foot { border-top: 1px solid var(--border); padding: 28px 32px; text-align: center; color: var(--faint); font-size: 13px; }
@media (max-width: 900px) { .land-hero { grid-template-columns: 1fr; padding: 32px 16px; } .land-section { padding: 36px 16px; } }

/* Help */
.faq-search { position: relative; margin-bottom: 22px; }
.faq-search .ico { position: absolute; left: 14px; top: 13px; color: var(--faint); }
.faq-search .input { padding-left: 42px; height: 48px; }
.faq-sec + .faq-sec { margin-top: 26px; }
.faq-sec h2 { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-ink); margin-bottom: 12px; }
details.faq { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
details.faq + details.faq { margin-top: 8px; }
details.faq summary { list-style: none; cursor: pointer; padding: 15px 18px; font-weight: 700; display: flex; justify-content: space-between; gap: 12px; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; color: var(--faint); font-size: 18px; line-height: 1; }
details.faq[open] summary::after { content: "–"; }
details.faq p { padding: 0 18px 16px; color: var(--muted); font-size: 14px; }

/* Gate & error */
.gate { max-width: 560px; margin: 40px auto; text-align: center; padding: 40px 32px; }
.gate .tile-ico { width: 68px; height: 68px; border-radius: 20px; margin: 0 auto 18px; }
.gate h1 { font-size: 24px; font-weight: 800; }
.gate p { margin: 10px 0 24px; color: var(--muted); }
.big-code { font-size: 64px; font-weight: 800; letter-spacing: -.04em; color: var(--brand-ink); }

.profile-head { display: flex; align-items: center; gap: 18px; padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.profile-head h2 { font-size: 20px; font-weight: 800; }
.profile-head p { color: var(--muted); }
.profile-head .tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--faint); }

.divider { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-2 { margin-bottom: 12px; }
.gap-2 { gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.center { text-align: center; }
.hidden { display: none !important; }

@media print {
  .sidebar, .topbar, .form-actions, .toasts, .site-banner { display: none !important; }
  .main { margin: 0; }
}

/* Theme toggle shows the theme you would switch to. */
.i-sun, .i-moon { display: inline-flex; }
:root[data-theme="dark"] .i-moon { display: none; }
:root:not([data-theme="dark"]) .i-sun { display: none; }

.kv span:has(small) { flex-direction: column; align-items: flex-start; gap: 0; }
.kv span small { font-size: 11px; font-weight: 500; }

.alloc .legend span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-wrap .legend em { display: none; }
@media (max-width: 1280px) and (min-width: 1101px) { .donut-wrap { grid-template-columns: 1fr; justify-items: stretch; } .donut-wrap .chart { max-width: 160px; margin: 0 auto; } }
