/* ==========================================================================
   JoniTax CRM — design system
   Tokens on :root (light), dark under prefers-color-scheme (guarded) and
   [data-theme="dark"]. Every component reads tokens only.
   ========================================================================== */

:root {
  color-scheme: light;

  /* surfaces & ink (teal-biased neutrals) */
  --bg: #f2f6f6;
  --surface: #ffffff;
  --surface-2: #f6f9f9;
  --surface-3: #e9f0f0;
  --border: #dbe4e4;
  --border-strong: #c3d1d1;
  --ink: #10201f;
  --ink-2: #435453;
  --muted: #5c6d6c;   /* 5.4:1 on white, 5:1 on --bg (WCAG AA for 12–14px labels) */
  --faint: #a4b3b2;   /* placeholders / decorative only, never for text that must be read */

  /* brand */
  --primary: #0f766e;
  --primary-hover: #0b5f59;
  --primary-ink: #ffffff;
  --primary-soft: #d7f0ec;
  --primary-soft-ink: #085e57;
  --accent: #d97706;
  --accent-soft: #fdefd6;
  --accent-ink: #92400e;
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --danger-soft: #fee2e2;
  --success: #15803d;
  --success-soft: #dcfce7;
  --focus: #14b8a6;

  /* semantic status tokens: <name> = strong ink, <name>-soft = pill fill */
  --c-blue: #1d4ed8;   --c-blue-soft: #dbeafe;   --c-blue-fill: #3b82f6;
  --c-amber: #b45309;  --c-amber-soft: #fef3c7;  --c-amber-fill: #f59e0b;
  --c-teal: #0f766e;   --c-teal-soft: #ccfbf1;   --c-teal-fill: #14b8a6;
  --c-purple: #6d28d9; --c-purple-soft: #ede9fe; --c-purple-fill: #8b5cf6;
  --c-yellow: #854d0e; --c-yellow-soft: #fef08a; --c-yellow-fill: #facc15;
  --c-green: #166534;  --c-green-soft: #bbf7d0;  --c-green-fill: #22c55e;
  --c-gray: #475569;   --c-gray-soft: #e2e8f0;   --c-gray-fill: #94a3b8;
  --c-red: #b91c1c;    --c-red-soft: #fecaca;    --c-red-fill: #ef4444;

  /* Excel cell fills carried over by the Drive import (same in both themes: they mirror the workbook) */
  --xl-green: #00c853; --xl-yellow: #ffd600; --xl-cyan: #00bcd4; --xl-red: #e53935;

  /* charts (validated: light #118f80 / #c47d0e) */
  --chart-1: #118f80;
  --chart-2: #c47d0e;
  --chart-grid: #e4ebeb;
  --chart-axis: #c3d1d1;

  /* geometry */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(16, 32, 31, 0.06), 0 1px 1px rgba(16, 32, 31, 0.04);
  --shadow: 0 4px 16px rgba(16, 32, 31, 0.08), 0 1px 3px rgba(16, 32, 31, 0.06);
  --shadow-lg: 0 18px 48px rgba(16, 32, 31, 0.18);
  --sidebar-w: 252px;
  --topbar-h: 62px;
  --bottombar-h: 60px;
  --gutter: 24px;
  --font: 'Heebo', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c1517;
    --surface: #132022;
    --surface-2: #182729;
    --surface-3: #1f3033;
    --border: #253b3e;
    --border-strong: #345054;
    --ink: #e6eeee;
    --ink-2: #b5c4c4;
    --muted: #7f9293;
    --faint: #5b6e70;
    --primary: #2cb5a5;
    --primary-hover: #4cc9ba;
    --primary-ink: #04211e;
    --primary-soft: #143d3a;
    --primary-soft-ink: #8ee3d7;
    --accent: #f0a93a;
    --accent-soft: #3d2c10;
    --accent-ink: #f7cf8a;
    --danger: #f87171;
    --danger-hover: #fca5a5;
    --danger-soft: #3f1d1d;
    --success: #4ade80;
    --success-soft: #14321f;
    --focus: #2dd4bf;
    --c-blue: #93c5fd;   --c-blue-soft: #1e2f4d;   --c-blue-fill: #3b82f6;
    --c-amber: #fcd34d;  --c-amber-soft: #3e2e0e;  --c-amber-fill: #f59e0b;
    --c-teal: #5eead4;   --c-teal-soft: #113a37;   --c-teal-fill: #14b8a6;
    --c-purple: #c4b5fd; --c-purple-soft: #2f2352; --c-purple-fill: #8b5cf6;
    --c-yellow: #fde047; --c-yellow-soft: #453a0a; --c-yellow-fill: #eab308;
    --c-green: #86efac;  --c-green-soft: #0f3a22;  --c-green-fill: #22c55e;
    --c-gray: #cbd5e1;   --c-gray-soft: #2b3a44;   --c-gray-fill: #64748b;
    --c-red: #fca5a5;    --c-red-soft: #46201f;    --c-red-fill: #ef4444;
    --chart-1: #209a8c;
    --chart-2: #bf8526;
    --chart-grid: #223638;
    --chart-axis: #345054;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1517;
  --surface: #132022;
  --surface-2: #182729;
  --surface-3: #1f3033;
  --border: #253b3e;
  --border-strong: #345054;
  --ink: #e6eeee;
  --ink-2: #b5c4c4;
  --muted: #7f9293;
  --faint: #5b6e70;
  --primary: #2cb5a5;
  --primary-hover: #4cc9ba;
  --primary-ink: #04211e;
  --primary-soft: #143d3a;
  --primary-soft-ink: #8ee3d7;
  --accent: #f0a93a;
  --accent-soft: #3d2c10;
  --accent-ink: #f7cf8a;
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --danger-soft: #3f1d1d;
  --success: #4ade80;
  --success-soft: #14321f;
  --focus: #2dd4bf;
  --c-blue: #93c5fd;   --c-blue-soft: #1e2f4d;   --c-blue-fill: #3b82f6;
  --c-amber: #fcd34d;  --c-amber-soft: #3e2e0e;  --c-amber-fill: #f59e0b;
  --c-teal: #5eead4;   --c-teal-soft: #113a37;   --c-teal-fill: #14b8a6;
  --c-purple: #c4b5fd; --c-purple-soft: #2f2352; --c-purple-fill: #8b5cf6;
  --c-yellow: #fde047; --c-yellow-soft: #453a0a; --c-yellow-fill: #eab308;
  --c-green: #86efac;  --c-green-soft: #0f3a22;  --c-green-fill: #22c55e;
  --c-gray: #cbd5e1;   --c-gray-soft: #2b3a44;   --c-gray-fill: #64748b;
  --c-red: #fca5a5;    --c-red-soft: #46201f;    --c-red-fill: #ef4444;
  --chart-1: #209a8c;
  --chart-2: #bf8526;
  --chart-grid: #223638;
  --chart-axis: #345054;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   Base
   ========================================================================== */

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

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

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
strong { font-weight: 700; }
small { font-size: 12.5px; }
.ltr { direction: ltr; unicode-bidi: isolate; }
/* an LTR block inside the RTL page still lines up with its right-aligned neighbours */
div.ltr, dd.ltr, p.ltr, td.ltr { text-align: end; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

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

::selection { background: var(--primary-soft); color: var(--ink); }

/* Boot splash (before app.js renders) */
.boot-splash {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  color: var(--muted);
}
.boot-logo {
  width: 48px; height: 48px; border-radius: 14px; background: var(--primary);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.6; transform: scale(0.94); } }
.noscript { padding: 24px; text-align: center; }

/* ==========================================================================
   App shell
   ========================================================================== */

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

.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 14px;
  gap: 8px;
  z-index: 30;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px; padding: 6px 8px 14px;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: none;
  box-shadow: var(--shadow-sm);
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: 0.04em; padding: 12px 12px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--ink-2); font-weight: 500; font-size: 14.5px;
  text-decoration: none; transition: background 0.12s, color 0.12s;
  min-height: 42px;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary-soft-ink); }
.nav-item .icon { flex: none; opacity: 0.85; }
.nav-item.active .icon { opacity: 1; }
.nav-badge {
  margin-inline-start: auto; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center;
}
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  color: var(--ink); text-decoration: none; width: 100%; background: none; border: 0; text-align: start;
}
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-soft-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none;
}
.user-chip .name { font-weight: 500; font-size: 14px; line-height: 1.2; }
.user-chip .role { font-size: 12px; color: var(--muted); }
.user-chip .icon { margin-inline-start: auto; color: var(--muted); }

.main { margin-inline-start: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 25;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }

.content { padding: 24px var(--gutter) 48px; max-width: 1360px; width: 100%; margin: 0 auto; }
.page { display: flex; flex-direction: column; gap: 20px; animation: fade-in 0.18s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Global search */
.gsearch { position: relative; flex: 0 1 460px; min-width: 160px; }
.gsearch .input { padding-inline-start: 38px; height: 40px; background: var(--surface); }
.gsearch > .icon { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.gsearch-kbd {
  position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; background: var(--surface-2);
}
.gsearch-pop {
  position: absolute; top: calc(100% + 6px); inset-inline: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  overflow: hidden; max-height: 420px; overflow-y: auto;
}
.gsearch-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer; border: 0; background: none; width: 100%; text-align: start;
}
.gsearch-row:hover, .gsearch-row.active { background: var(--surface-2); }
.gsearch-row .who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.gsearch-row .who b { font-weight: 500; }
.gsearch-row .who small { color: var(--muted); }
.gsearch-empty { padding: 16px; color: var(--muted); text-align: center; font-size: 14px; }

/* Bell */
.iconbtn {
  position: relative; width: 40px; height: 40px; border-radius: 10px; border: 1px solid transparent; background: none;
  display: grid; place-items: center; color: var(--ink-2);
}
.iconbtn:hover { background: var(--surface); border-color: var(--border); color: var(--ink); }
.iconbtn.sm { width: 32px; height: 32px; border-radius: 8px; }
.iconbtn .dot {
  position: absolute; top: 5px; inset-inline-end: 5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; line-height: 1;
}

/* Mobile bottom bar + nav drawer */
.bottombar { display: none; }
.navdrawer-backdrop { display: none; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-weight: 500; font-size: 14.5px; line-height: 1; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.08s, box-shadow 0.12s;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-soft-ink); }
.btn-soft:hover { background: color-mix(in srgb, var(--primary-soft) 80%, var(--primary)); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13.5px; border-radius: 8px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15.5px; }
.btn-block { width: 100%; }
.btn .icon { flex: none; }
.btn-link { background: none; border: 0; color: var(--primary); padding: 0; height: auto; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }

/* ==========================================================================
   Forms
   ========================================================================== */

.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
/* growing textarea (AutoTextarea): one line when empty, grows with the text, never a scrollbar */
.textarea.cp-autosize { min-height: 34px; height: 34px; padding: 6px 10px; resize: none; overflow: hidden; line-height: 1.4; font-size: 14px; }
/* clients list: the agency's status text and the missing-documents line under the status pill */
.cl-raw { font-size: 12px; color: var(--muted); max-width: 260px; }
.cl-miss { display: inline-flex; align-items: center; gap: 4px; color: var(--c-red); font-size: 12px; font-weight: 500; max-width: 260px; }
.cl-miss .icon { flex: none; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.6; background: var(--surface-2); }
.input.sm, .select.sm { height: 34px; border-radius: 8px; font-size: 14px; }
.select {
  appearance: none; -webkit-appearance: none; padding-inline-end: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235c6d6c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 10px center; background-size: 16px;
}
.select.sm { padding-inline-end: 28px; } /* the chevron is 16px: leave room for labels like "חסרים מסמכים" */
input[type="date"].input { direction: ltr; text-align: end; }
input[type="number"].input, input.ltr { direction: ltr; text-align: end; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.field-label .req { color: var(--danger); margin-inline-start: 2px; }
.field-hint { font-size: 12.5px; color: var(--muted); }
.field-error { font-size: 12.5px; color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--primary); }

/* ==========================================================================
   Cards, layout helpers
   ========================================================================== */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 16px; }
.card-head .sub { color: var(--muted); font-size: 13px; }
.card-body { padding: 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid-kpi.n-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-kpi.n-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 1400px) {
  .grid-kpi.n-6 .kpi, .grid-kpi.n-5 .kpi { padding: 14px; gap: 10px; }
  .grid-kpi.n-6 .kpi-icon, .grid-kpi.n-5 .kpi-icon { width: 34px; height: 34px; }
  .grid-kpi.n-6 .kpi-label, .grid-kpi.n-5 .kpi-label { font-size: 12.5px; }
}
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border);
  color: inherit; text-decoration: none;
}
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; }
.list-item .meta { font-size: 12.5px; color: var(--muted); }
.clamp-1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ==========================================================================
   KPI
   ========================================================================== */

.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; box-shadow: var(--shadow-sm);
  min-width: 0;
}
.kpi-icon {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--primary-soft); color: var(--primary-soft-ink);
}
.kpi.tone-accent .kpi-icon { background: var(--accent-soft); color: var(--accent-ink); }
.kpi.tone-success .kpi-icon { background: var(--success-soft); color: var(--success); }
.kpi.tone-danger .kpi-icon { background: var(--danger-soft); color: var(--danger); }
.kpi.tone-neutral .kpi-icon { background: var(--surface-3); color: var(--ink-2); }
.kpi-body { min-width: 0; flex: 1; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: clamp(19px, 1.7vw, 26px); font-weight: 700; line-height: 1.15; margin-top: 2px; letter-spacing: -0.01em; direction: ltr; text-align: end; }
.kpi-value .num { display: inline; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ==========================================================================
   Pills & badges
   ========================================================================== */

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap; line-height: 1;
  background: var(--c-gray-soft); color: var(--c-gray);
}
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.pill.sm { height: 20px; padding: 0 8px; font-size: 11.5px; }
.pill.nodot::before { display: none; }
.pill-blue { background: var(--c-blue-soft); color: var(--c-blue); }
.pill-amber { background: var(--c-amber-soft); color: var(--c-amber); }
.pill-teal { background: var(--c-teal-soft); color: var(--c-teal); }
.pill-purple { background: var(--c-purple-soft); color: var(--c-purple); }
.pill-yellow { background: var(--c-yellow-soft); color: var(--c-yellow); }
.pill-green { background: var(--c-green-soft); color: var(--c-green); }
.pill-gray { background: var(--c-gray-soft); color: var(--c-gray); }
.pill-red { background: var(--c-red-soft); color: var(--c-red); }
.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11.5px; font-weight: 500;
  background: var(--surface-3); color: var(--ink-2);
}

/* ==========================================================================
   Table
   ========================================================================== */

.table-wrap {
  overflow: auto; max-height: var(--table-max-h, none);
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
.table-wrap.flush { border: 0; border-radius: 0; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: 12.5px; text-align: start;
  padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }
.table th .th-inner { display: inline-flex; align-items: center; gap: 4px; }
.table th .sort-ind { opacity: 0.35; }
.table th.sorted { color: var(--ink); }
.table th.sorted .sort-ind { opacity: 1; color: var(--primary); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table tbody tr.clickable:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.table .align-end, .table td.align-end, .table th.align-end { text-align: end; }
.table .align-center { text-align: center; }
.table td.num, .table .num { font-variant-numeric: tabular-nums; }
.table tfoot td { background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--border); }
.table-empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.table .cell-main { font-weight: 500; color: var(--ink); white-space: nowrap; }
.table .cell-sub { font-size: 12.5px; color: var(--muted); }

.skeleton {
  display: inline-block; height: 14px; width: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton.w-30 { width: 30%; } .skeleton.w-50 { width: 50%; } .skeleton.w-70 { width: 70%; }
.skeleton.h-lg { height: 28px; }

/* ==========================================================================
   Pagination / Tabs
   ========================================================================== */

.pagination { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); }
.pagination .pages { display: flex; gap: 4px; }
.pagination .pg {
  min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--ink-2);
  display: grid; place-items: center; font-variant-numeric: tabular-nums;
}
.pagination .pg:hover { background: var(--surface-3); }
.pagination .pg.active { background: var(--primary); color: var(--primary-ink); }
.pagination .pg:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .ellipsis { padding: 0 4px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 10px 14px; color: var(--muted); font-weight: 500; font-size: 14.5px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { background: var(--surface-3); color: var(--ink-2); border-radius: 999px; font-size: 11.5px; padding: 1px 7px; }
.tab[aria-selected="true"] .count { background: var(--primary-soft); color: var(--primary-soft-ink); }

/* ==========================================================================
   Modal / Drawer
   ========================================================================== */

.overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(6, 18, 20, 0.5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade 0.15s ease-out;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: pop 0.18s ease-out;
  border: 1px solid var(--border);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal.size-sm { max-width: 420px; }
.modal.size-lg { max-width: 860px; }
.modal.size-xl { max-width: 1100px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-start; gap: 10px; flex-wrap: wrap; }

.overlay.drawer-overlay { align-items: stretch; justify-content: flex-end; padding: 0; }
.drawer {
  background: var(--surface); width: 100%; max-width: 520px; height: 100%; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: slide-in 0.2s ease-out; border-inline-start: 1px solid var(--border);
}
.drawer.size-lg { max-width: 760px; }
.drawer.size-sm { max-width: 400px; }
@keyframes slide-in { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer .modal-body { padding-bottom: 32px; }

/* ==========================================================================
   Toasts
   ========================================================================== */

.toasts {
  position: fixed; inset-inline-end: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 200;
  display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); font-size: 14px; animation: toast-in 0.2s ease-out;
  border-inline-start: 4px solid var(--primary);
}
.toast.error { border-inline-start-color: #ef4444; }
.toast.success { border-inline-start-color: #22c55e; }
.toast.info { border-inline-start-color: #60a5fa; }
.toast .icon { flex: none; margin-top: 1px; }
.toast .txt { flex: 1; }
.toast .close { background: none; border: 0; color: inherit; opacity: 0.7; padding: 0; line-height: 1; min-width: 28px; min-height: 28px; display: grid; place-items: center; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Misc components
   ========================================================================== */

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 40px 20px; color: var(--muted); }
.empty .icon { color: var(--faint); }
.empty h3 { color: var(--ink); font-weight: 500; }
.empty .hint { font-size: 14px; max-width: 360px; }
.empty .action { margin-top: 8px; }

.spinner {
  width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--border-strong); border-top-color: var(--primary);
  animation: spin 0.7s linear infinite; display: inline-block;
}
.spinner.lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; padding: 40px; }

.filedrop {
  border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 22px 16px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); background: var(--surface-2);
  transition: border-color 0.12s, background 0.12s; cursor: pointer;
}
.filedrop:hover, .filedrop.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-soft-ink); }
.filedrop.disabled { opacity: 0.5; pointer-events: none; }
.filedrop .filedrop-title { color: var(--ink); font-weight: 500; }
.filedrop .filedrop-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.filedrop .camera-btn { display: none; }

.phone-link { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.phone-link .tel { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; color: var(--ink); }
.phone-link .wa { color: #25d366; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; }
.phone-link .wa:hover { background: var(--surface-3); }
.phone-link .tel:hover { text-decoration: underline; }

.money { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.money.neg { color: var(--danger); }
.money.muted { color: var(--muted); }

/* YearGrid */
.yeargrid { display: flex; gap: 6px; flex-wrap: wrap; }
.yeargrid.strip { flex-wrap: nowrap; gap: 3px; }
.ycell {
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--ink-2);
  min-width: 78px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; text-align: start; cursor: pointer;
  transition: transform 0.08s, box-shadow 0.12s, border-color 0.12s; flex: 1 1 0;
}
.ycell:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.ycell.active { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent); }
.ycell .y { font-weight: 700; font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.ycell .s { font-size: 12px; }
.ycell .a { font-size: 12.5px; font-variant-numeric: tabular-nums; direction: ltr; text-align: end; color: var(--ink); font-weight: 500; }
.ycell.st-open { background: var(--surface-2); }
.ycell.st-missing_docs { background: var(--c-red-soft); border-color: transparent; color: var(--c-red); }
.ycell.st-in_progress { background: var(--c-blue-soft); border-color: transparent; color: var(--c-blue); }
.ycell.st-submitted { background: var(--c-yellow-soft); border-color: transparent; color: var(--c-yellow); }
.ycell.st-received { background: var(--c-green-soft); border-color: transparent; color: var(--c-green); }
.ycell.st-no_refund, .ycell.st-not_relevant { background: var(--c-gray-soft); border-color: transparent; color: var(--c-gray); opacity: 0.8; }
.ycell.st-none { background: transparent; border-style: dashed; color: var(--muted); }
.ycell.st-none .y { color: var(--ink-2); font-weight: 500; }
.ymini {
  width: 12px; height: 18px; border-radius: 3px; background: var(--surface-3); flex: none; border: 1px solid transparent;
}
.ymini.st-none { background: transparent; border-color: var(--border); }
.ymini.st-missing_docs { background: var(--c-red-fill); }
.ymini.st-in_progress { background: var(--c-blue-fill); }
.ymini.st-submitted { background: var(--c-yellow-fill); }
.ymini.st-received { background: var(--c-green-fill); }
.ymini.st-open { background: var(--c-gray-soft); border-color: var(--border); }
.ymini.st-no_refund, .ymini.st-not_relevant { background: var(--c-gray-fill); opacity: 0.6; }
/* Excel fill colour of the year cell (Drive import, SPEC-DRIVE §A): a 3px bar along the bottom edge */
.ycell, .ymini { position: relative; overflow: hidden; }
.ycell[class*="cc-"]::after, .ymini[class*="cc-"]::after { content: ''; position: absolute; inset-inline: 0; bottom: 0; height: 3px; pointer-events: none; }
.cc-green::after { background: var(--xl-green); }
.cc-yellow::after { background: var(--xl-yellow); }
.cc-cyan::after { background: var(--xl-cyan); }
.cc-red::after { background: var(--xl-red); }
.xl-swatch { display: inline-block; width: 10px; height: 14px; border-radius: 3px; flex: none; vertical-align: -2px; border: 1px solid rgba(0,0,0,0.12); }
.xl-swatch.cc-green { background: var(--xl-green); }
.xl-swatch.cc-yellow { background: var(--xl-yellow); }
.xl-swatch.cc-cyan { background: var(--xl-cyan); }
.xl-swatch.cc-red { background: var(--xl-red); }

/* Agency fee-rule editor (Agencies drawer) */
.fee-tiers { display: flex; flex-direction: column; gap: 8px; }
.fee-tier { display: grid; grid-template-columns: 66px minmax(90px, 1fr) 18px minmax(64px, 100px) auto; gap: 8px; align-items: center; }
.fee-tier .fee-tier-label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.fee-tier .fee-tier-arrow { color: var(--muted); text-align: center; }
.fee-tier-err { font-size: 12.5px; color: var(--danger); }
.fee-example { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-soft-ink); }
.fee-example b { font-size: 15px; }
.fee-example .more { font-size: 12.5px; opacity: 0.85; display: flex; gap: 6px 14px; flex-wrap: wrap; }
.drive-id { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.drive-id .input { flex: 1; min-width: 0; }

/* Bars chart */
.bars { width: 100%; }
.bars svg { width: 100%; height: auto; display: block; overflow: visible; }
.bars .bar { transition: opacity 0.12s; }
.bars .bar-hit { fill: transparent; cursor: default; }
.bars .bar-hit:hover + .bar-group .bar, .bars g.slot:hover .bar { opacity: 0.85; }
.bars text { font-family: var(--font); fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.bars .val { fill: var(--ink-2); font-weight: 500; }
.bars .grid line { stroke: var(--chart-grid); stroke-width: 1; }
.bars .axis { stroke: var(--chart-axis); stroke-width: 1; }
.bars-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.bars-legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-inline-end: 6px; vertical-align: -1px; }
.bars-tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); padding: 6px 10px; border-radius: 8px; font-size: 12.5px;
  box-shadow: var(--shadow); white-space: nowrap; z-index: 5; transform: translate(-50%, calc(-100% - 8px));
}
.bars-tip b { font-weight: 700; }
.bars-wrap { position: relative; }
.bars-table { margin-top: 10px; font-size: 13px; }
.bars-table summary { cursor: pointer; color: var(--muted); }

/* Status breakdown */
.hbar-row { display: grid; grid-template-columns: minmax(120px, 160px) 1fr 44px; gap: 12px; align-items: center; font-size: 14px; padding: 6px 0; }
.hbar-track { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 999px; }
.hbar-count { text-align: end; font-variant-numeric: tabular-nums; font-weight: 500; }

/* Activity timeline */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.tl-item:last-child { border-bottom: 0; }
.tl-icon {
  width: 32px; height: 32px; border-radius: 9px; background: var(--surface-3); color: var(--ink-2); display: grid; place-items: center; flex: none;
}
.tl-icon.t-note { background: var(--c-purple-soft); color: var(--c-purple); }
.tl-icon.t-status, .tl-icon.t-year { background: var(--c-blue-soft); color: var(--c-blue); }
.tl-icon.t-document { background: var(--c-teal-soft); color: var(--c-teal); }
.tl-icon.t-payment { background: var(--c-green-soft); color: var(--c-green); }
.tl-icon.t-notification { background: var(--c-amber-soft); color: var(--c-amber); }
.tl-icon.t-login { background: var(--surface-3); }
.tl-body { flex: 1; min-width: 0; }
.tl-text { font-size: 14px; }
.tl-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.tl-meta a { color: var(--primary); }

/* Filters bar */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters .f-search { flex: 1 1 240px; position: relative; }
.filters .f-search .input { padding-inline-start: 36px; }
.filters .f-search .icon { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.filters .select { width: auto; min-width: 140px; flex: 0 1 auto; }
.filters-more { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding-top: 12px; border-top: 1px dashed var(--border); margin-top: 12px; }
.filters-more .field { flex: 1 1 150px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 12.5px;
  background: var(--primary-soft); color: var(--primary-soft-ink); border: 0;
}

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 600px at 100% -10%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 60%),
  radial-gradient(800px 500px at 0% 110%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
  var(--bg);
}
.login-card { width: 100%; max-width: 400px; padding: 32px 28px; display: flex; flex-direction: column; gap: 18px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.login-brand .brand-mark { width: 56px; height: 56px; border-radius: 16px; font-size: 24px; }
.login-brand h1 { font-size: 22px; }
.login-brand p { color: var(--muted); font-size: 14px; }
.login-foot { text-align: center; font-size: 12.5px; color: var(--muted); }

/* Notifications */
.notif { display: flex; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.notif:last-child { border-bottom: 0; }
.notif.unread { background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); }
.notif .n-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 8px; flex: none; }
.notif .n-dot.read { background: transparent; border: 1px solid var(--border-strong); }
.notif .n-body { flex: 1; min-width: 0; }
.notif .n-title { font-weight: 500; }
.notif .n-text { color: var(--ink-2); font-size: 14px; margin-top: 2px; white-space: pre-line; }
.notif .n-meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }

/* Profile */
.theme-toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; }
.theme-toggle button {
  background: none; border: 0; padding: 0 14px; height: 38px; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-weight: 500; font-size: 14px;
}
.theme-toggle button + button { border-inline-start: 1px solid var(--border-strong); }
.theme-toggle button.active { background: var(--primary-soft); color: var(--primary-soft-ink); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.hero-num { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }

/* Coming soon fallback */
.soon { padding: 60px 20px; text-align: center; color: var(--muted); }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-kpi.n-6, .grid-kpi.n-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 899px) {
  :root { --gutter: 16px; --topbar-h: 58px; }
  .sidebar { display: none; }
  .main { margin-inline-start: 0; padding-bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom, 0px)); }
  .topbar .menu-btn { display: grid; }
  .topbar { gap: 8px; }
  .topbar .hide-mobile { display: none; }
  .gsearch { flex: 1 1 auto; }
  .gsearch-kbd { display: none; }
  .content { padding: 16px var(--gutter) 32px; }
  .page-head h1 { font-size: 21px; }
  .grid-2, .grid-3, .grid-4, .grid-main { grid-template-columns: minmax(0, 1fr); }
  .grid-kpi, .grid-kpi.n-6, .grid-kpi.n-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-kpi.n-5 > :last-child { grid-column: 1 / -1; }
  .kpi { padding: 14px; gap: 10px; }
  .kpi-value { font-size: 22px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .card-pad, .card-body { padding: 16px; }
  .card-head { padding: 14px 16px; }
  .list-item, .tl-item, .notif { padding-inline: 16px; }
  .kv { grid-template-columns: 110px 1fr; }
  .btn { min-height: 42px; }
  .iconbtn.sm { width: 40px; height: 40px; }
  .phone-link .wa { width: 40px; height: 40px; }
  .pagination .pg { min-width: 40px; min-height: 40px; }
  /* toasts sit above the bottom bar instead of covering "התראות" / "תפריט" */
  .toasts { bottom: calc(var(--bottombar-h) + 12px + env(safe-area-inset-bottom, 0px)); }
  /* the clients list is a card list on phones (see views/Clients.js); the top-bar search drives it */
  .filters .f-search { display: none; }
  .modal { max-height: calc(100vh - 16px); border-radius: 14px; }
  .overlay { padding: 8px; align-items: flex-end; }
  .drawer { max-width: 100%; }
  .filedrop .camera-btn { display: inline-flex; }
  .hbar-row { grid-template-columns: minmax(90px, 120px) 1fr 40px; }

  .bottombar {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--bottombar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .bottombar a, .bottombar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 11px; color: var(--muted); text-decoration: none; background: none; border: 0; font-weight: 500; position: relative;
  }
  .bottombar a.active { color: var(--primary); }
  .bottombar .fab {
    width: 46px; height: 46px; border-radius: 14px; background: var(--primary); color: var(--primary-ink);
    display: grid; place-items: center; margin-top: -18px; box-shadow: var(--shadow);
  }
  .bottombar .dot {
    position: absolute; top: 6px; inset-inline-end: calc(50% - 20px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
    background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center;
  }

  .navdrawer-backdrop {
    display: block; position: fixed; inset: 0; z-index: 90; background: rgba(6, 18, 20, 0.5); animation: fade 0.15s ease-out;
  }
  .navdrawer {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: min(300px, 86vw); z-index: 95;
    background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; padding: 16px 14px; gap: 8px; overflow-y: auto;
    animation: nav-in 0.2s ease-out;
  }
  @keyframes nav-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
}

@media (max-width: 480px) {
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions .btn { flex: 1; }
  .filters .select { min-width: 0; flex: 1 1 45%; }
  /* import wizard stepper: only the current step keeps its label so all three fit on one line */
  .imp-steps { flex-wrap: nowrap; }
  .imp-steps li:not(.active) { padding-inline-end: 6px; }
  .imp-steps li:not(.active) > span:last-child { display: none; }
}

@media print {
  .sidebar, .topbar, .bottombar, .toasts { display: none !important; }
  .main { margin: 0; }
}

/* ---- one-time welcome tour ---- */
.welcome-overlay { z-index: 1200; background: rgba(15, 118, 110, 0.28); backdrop-filter: blur(4px); }
.welcome-modal { max-width: 640px; width: calc(100% - 32px); padding: 0; overflow: hidden; }
.welcome-hero { background: linear-gradient(135deg, #0f766e, #14b8a6); color: #fff; padding: 30px 28px 26px; text-align: center; }
.welcome-smile { font-size: 56px; line-height: 1; margin-bottom: 8px; animation: welcome-pop 0.6s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes welcome-pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.welcome-title { margin: 0 0 8px; font-size: 26px; font-weight: 700; }
.welcome-sub { margin: 0; font-size: 15.5px; line-height: 1.6; opacity: 0.95; }
.welcome-steps { padding: 18px 24px 4px; display: grid; gap: 10px; }
.welcome-step { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.welcome-step-icon { font-size: 26px; line-height: 1; flex: 0 0 auto; padding-top: 2px; }
.welcome-step-title { font-weight: 700; margin-bottom: 2px; }
.welcome-step-text { color: var(--muted); font-size: 14px; line-height: 1.55; }
.welcome-note { margin: 12px 24px 0; padding: 10px 14px; border-radius: 10px; background: #fff7e6; color: #7c4a03; font-size: 14px; }
:root:not([data-theme="light"]) .welcome-note { background: rgba(251, 191, 36, 0.12); color: #fcd34d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .welcome-note { background: rgba(251, 191, 36, 0.12); color: #fcd34d; } }
.welcome-actions { padding: 18px 24px 24px; display: flex; justify-content: center; }
.welcome-actions .btn-lg { font-size: 17px; padding: 12px 28px; border-radius: 12px; }
@media (max-width: 600px) { .welcome-hero { padding: 24px 18px 20px; } .welcome-title { font-size: 22px; } .welcome-steps { padding: 14px 14px 0; } .welcome-modal { max-height: 92vh; overflow: auto; } }

/* ---- welcome tour: motion ---- */
.welcome-overlay { animation: welcome-fade 0.35s ease-out both; }
@keyframes welcome-fade { from { opacity: 0; } to { opacity: 1; } }
.welcome-modal { animation: welcome-rise 0.55s cubic-bezier(.2,1.2,.3,1) both; }
@keyframes welcome-rise { from { opacity: 0; transform: translateY(28px) scale(0.96); } to { opacity: 1; transform: none; } }
.welcome-hero { position: relative; overflow: hidden; background: linear-gradient(120deg, #0f766e, #14b8a6, #0ea5e9, #0f766e); background-size: 300% 300%; animation: welcome-gradient 9s ease-in-out infinite; }
@keyframes welcome-gradient { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
.welcome-blob { position: absolute; border-radius: 50%; background: rgba(255,255,255,0.14); filter: blur(2px); pointer-events: none; }
.welcome-blob.b1 { width: 160px; height: 160px; top: -60px; right: -40px; animation: welcome-float 7s ease-in-out infinite; }
.welcome-blob.b2 { width: 110px; height: 110px; bottom: -40px; left: 12%; animation: welcome-float 9s ease-in-out infinite reverse; }
.welcome-blob.b3 { width: 70px; height: 70px; top: 20%; left: -20px; animation: welcome-float 6s ease-in-out infinite 1s; }
@keyframes welcome-float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(14px, -18px) scale(1.08); } }
.welcome-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.welcome-confetti i { position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px; opacity: 0; animation-name: welcome-confetti-fall; animation-timing-function: ease-in; animation-iteration-count: 1; animation-fill-mode: forwards; }
@keyframes welcome-confetti-fall { 0% { opacity: 0; transform: translateY(0) rotate(0deg); } 8% { opacity: 1; } 100% { opacity: 0; transform: translateY(240px) rotate(540deg); } }
.welcome-hero .welcome-smile { position: relative; display: inline-block; animation: welcome-bounce 1.1s cubic-bezier(.3,1.6,.4,1) both; }
@keyframes welcome-bounce { 0% { transform: scale(0.2) rotate(-20deg); opacity: 0; } 60% { transform: scale(1.15) rotate(6deg); opacity: 1; } 80% { transform: scale(0.96) rotate(-2deg); } 100% { transform: scale(1) rotate(0); } }
.welcome-wave { position: absolute; right: -34px; bottom: -4px; font-size: 30px; transform-origin: 70% 70%; animation: welcome-wave 1.6s ease-in-out 0.9s 3; }
@keyframes welcome-wave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(18deg); } 50% { transform: rotate(-10deg); } 75% { transform: rotate(14deg); } }
.welcome-title { position: relative; animation: welcome-up 0.6s ease-out 0.35s both; }
.welcome-sub { position: relative; animation: welcome-up 0.6s ease-out 0.5s both; }
@keyframes welcome-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.welcome-step { animation: welcome-slide 0.5s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes welcome-slide { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.welcome-step-icon { display: inline-block; animation: welcome-icon-pop 0.5s cubic-bezier(.3,1.6,.4,1) both; animation-delay: inherit; }
@keyframes welcome-icon-pop { from { transform: scale(0.4); } to { transform: scale(1); } }
.welcome-actions .btn-lg { animation: welcome-up 0.5s ease-out 1.3s both, welcome-glow 2.4s ease-in-out 2s infinite; }
@keyframes welcome-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(15,118,110,0.35); } 50% { box-shadow: 0 0 0 10px rgba(15,118,110,0); } }
@media (prefers-reduced-motion: reduce) { .welcome-overlay, .welcome-modal, .welcome-hero, .welcome-blob, .welcome-confetti i, .welcome-smile, .welcome-wave, .welcome-title, .welcome-sub, .welcome-step, .welcome-step-icon, .welcome-actions .btn-lg { animation: none !important; opacity: 1; transform: none; } .welcome-confetti { display: none; } }
