:root {
  --primary: #ff6b00;
  --primary-hover: #e85f00;
  --primary-pressed: #cc5500;
  --primary-soft: #fff1e6;
  --primary-glow: rgba(255, 107, 0, 0.14);
  --navy: #0b0f19;
  --charcoal: #12182a;
  --background: #fffdf8;
  --surface: #ffffff;
  --mba-cream: #fffdf8;
  --mba-cream-2: #fdf6e9;
  --mba-gold: #e89e09;
  --mba-gold-soft: rgba(232, 158, 9, 0.18);
  --mba-card-radius: 22px;
  --mba-orange: #ff6b00;
  --mba-orange-2: #ff7a00;
  --mba-orange-deep: #f45d00;
  --surface-elevated: #ffffff;
  --surface-hover: #fff8ef;
  --text: #111827;
  --text-on-light: #111827;
  --text-muted: #6b7280;
  --border: #ece4d8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;
  --shadow-sm: 0 1px 2px rgba(11, 15, 25, .04);
  --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.04), 0 12px 32px rgba(232, 158, 9, 0.08);
  --shadow-md: 0 8px 24px rgba(11, 15, 25, .08);
  --shadow-lg: 0 22px 60px rgba(11, 15, 25, .16);
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;
  --primary-ink: #9a3d00;
  --surface-muted: #fff4e8;
  --radius: var(--radius-lg);
  --shadow: var(--shadow-card);
  --bg: var(--background);
  --bg-elev: var(--surface);
  --text-soft: #1f2937;
  --muted: var(--text-muted);
  --line: var(--border);
  --line-strong: #e2d5c4;
  --primary-2: var(--primary-hover);
  --accent: var(--info);
  --danger-soft: #fee2e2;
  --warning-soft: #fef3c7;
  --success-soft: #d1fae5;
  --sidebar: #0b1220;
  --sidebar-2: #111827;
  --sidebar-text: #c9d3e4;
  --sidebar-muted: #8b97ad;
  --sidebar-active: #ffffff;
  --card: var(--surface);
  --nav-w: 264px;
  --top-h: 64px;
  --bottom-h: 72px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --motion-fast: 120ms;
  --motion-base: 180ms;
  --motion-slow: 280ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Plus Jakarta Sans", "Noto Sans", "Noto Naskh Arabic", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --type-display: clamp(28px, 2.4vw, 34px);
  --type-h1: clamp(22px, 2vw, 28px);
  --type-h2: 16px;
  --type-h3: 14px;
  --type-body: 14px;
  --type-caption: 12px;
  --type-label: 11px;
  --type-kpi: clamp(22px, 2vw, 28px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow-x: clip; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  max-width: 100%;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
img, svg, video { max-width: 100%; }
canvas { max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; max-width: 100%; }
:focus-visible { outline: 3px solid rgba(255, 106, 0, .4); outline-offset: 2px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; color: var(--text-on-light, #111827); padding: 8px 12px; z-index: 99; }

.app { display: flex; min-width: 0; max-width: 100%; min-height: 100dvh; overflow-x: clip; }
.sidebar {
  width: var(--nav-w);
  flex: 0 0 var(--nav-w);
  max-width: var(--nav-w);
  min-width: 0;
  background: linear-gradient(180deg, #0b1220 0%, #111827 55%, #162033 100%);
  color: var(--sidebar-text);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  padding: 18px 12px 14px;
  z-index: 40;
  box-shadow: 8px 0 32px rgba(5, 8, 22, 0.18);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px 16px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  background: linear-gradient(145deg, #ffd400, #ff6b00);
  border: 1px solid rgba(255, 212, 0, 0.28);
  display: grid; place-items: center; overflow: hidden; flex: none;
  box-shadow: 0 0 18px rgba(232, 158, 9, 0.28);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-name { font-weight: 800; color: #fff; letter-spacing: -.03em; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--sidebar-muted); margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow: auto; flex: 1; padding: 4px 4px 8px; overflow-anchor: none; }
html.mba-nav-restore .nav { visibility: hidden; }
.nav a, .nav summary {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 12px; color: var(--sidebar-text);
  cursor: pointer; list-style: none; font-size: 13.5px; font-weight: 600;
  position: relative; transition: background var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out);
}
.nav a:hover, .nav summary:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav a:active { transform: scale(0.985); }
.nav a.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(232, 158, 9, 0.22);
}
.nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #ffd400, #ff6b00);
  box-shadow: 0 0 0 1px var(--primary-glow);
}
.nav details { border-radius: 10px; }
.nav details > summary {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-muted);
  padding: 14px 12px 6px;
  pointer-events: none;
}
.nav details > summary .icon { display: none; }
.nav details[open] > summary { color: var(--sidebar-muted); background: transparent; }
.subnav { display: flex; flex-direction: column; padding: 0 0 4px 8px; gap: 1px; }
.subnav a {
  font-size: 14px;
  padding: 8px 12px 8px 16px;
  color: var(--sidebar-text);
  font-weight: 600;
  position: relative;
}
.subnav a:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.subnav a.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.subnav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #ffd400, #ff6b00);
}
.icon { width: 18px; height: 18px; flex: none; }
.nav > a .icon { color: var(--sidebar-muted); }
.nav > a.active .icon { color: #ffd400; }

.main { flex: 1; min-width: 0; max-width: 100%; display: flex; flex-direction: column; overflow-x: clip; }
.topbar {
  height: var(--top-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
  min-width: 0;
}
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.search {
  flex: 1; min-width: 0; max-width: 560px; position: relative; margin: 0 auto;
}
.search input {
  width: 100%; border: 1px solid var(--line); background: var(--surface-muted);
  border-radius: 12px; padding: 10px 72px 10px 40px;
  font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.12);
  background: var(--surface);
}
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); opacity: .45; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.icon-btn, .chip-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  min-height: 40px; min-width: 40px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.icon-btn:hover, .chip-btn:hover { background: var(--surface-hover); border-color: var(--line-strong); }
.top-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease;
}
.top-user:hover { border-color: var(--line-strong); }
.top-user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.top-user-meta strong {
  font-size: 13px;
  font-weight: 700;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-user-meta span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}
.top-create-wrap { position: relative; }
.top-create-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  min-height: 40px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: none;
}
.top-create-btn .icon-chevron { width: 14px; height: 14px; opacity: 0.85; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.content { padding: 0; min-width: 0; max-width: 100%; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; min-width: 0; }
.page-head > div { min-width: 0; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -.04em; line-height: 1.2; overflow-wrap: anywhere; min-width: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); overflow-wrap: anywhere; }

.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)); }
.card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
  min-width: 0; max-width: 100%;
}
.stat { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 800; letter-spacing: -.04em; min-width: 0; overflow-wrap: anywhere; }
.stat .hint { font-size: 12px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; min-height: 44px; padding: 0 16px;
  font-weight: 700; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: none; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-pressed); }
.btn-dark { background: var(--text); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--text-on-light, #111827); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

.table-wrap, .table-responsive { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; min-width: 0; max-width: 100%; }
table.data { width: 100%; border-collapse: collapse; min-width: 640px; }
table.table { width: 100%; border-collapse: collapse; min-width: 560px; }
table.table th, table.table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
table.table td:not(.num) { overflow-wrap: anywhere; word-break: break-word; }
table.data th, table.data td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
table.data td:not(.num) { overflow-wrap: anywhere; word-break: break-word; }
table.data td.num, table.data th.num { white-space: nowrap; }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; }
.badge-paid { background: var(--success-soft); color: #065f46; }
.badge-partial { background: var(--warning-soft); color: #92400e; }
.badge-unpaid, .badge-overdue { background: var(--danger-soft); color: #991b1b; }
.badge-issued { background: #e0e7ff; color: #3730a3; }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field[hidden],
[hidden] { display: none !important; }
.field label { font-size: 13px; font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0; border: 1px solid var(--line-strong); border-radius: 12px; background: #fff;
  min-height: 44px; padding: 10px 12px;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:disabled, .field select:disabled, .field textarea:disabled {
  opacity: .7; cursor: not-allowed; background: var(--surface-muted);
}
.check {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; font-weight: 600;
}
.check input { width: auto; max-width: none; }
.help { color: var(--muted); font-size: 12px; }
.error { color: var(--danger); font-size: 13px; }
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; }
.alert-success { background: var(--success-soft); color: #065f46; }
.alert-error { background: var(--danger-soft); color: #991b1b; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }

.list-cards { display: none; }
.mobile-only { display: none; }
.desktop-only { display: block; }
.menu-btn { display: none; }

.drawer-backdrop { display: none; }
.bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  grid-template-columns: repeat(5, 1fr);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); font-weight: 700; text-align: center; line-height: 1.2; max-width: 100%; overflow-wrap: anywhere; padding: 0 2px; transition: color var(--motion-fast, 120ms) ease; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav .nav-fab {
  width: 48px; height: 48px; margin: -18px auto 0; border-radius: var(--radius-pill, 999px);
  background: var(--primary); color: #fff !important; box-shadow: 0 10px 22px rgba(255, 107, 0, .28);
  display: grid; place-items: center; font-size: 24px; line-height: 1; font-weight: 700;
  transition: transform var(--motion-fast, 120ms) ease, background var(--motion-fast, 120ms) ease;
}
.bottom-nav .nav-fab:active { transform: scale(0.96); background: var(--primary-pressed, #cc5500); }
.bottom-nav .nav-fab span { display: none; }

.auth-shell, .public-shell, .install-shell { min-height: 100dvh; }
.auth-shell {
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1000px 500px at 10% -10%, rgba(20,184,166,.18), transparent 50%),
    radial-gradient(800px 400px at 100% 0%, rgba(37,99,235,.16), transparent 45%),
    #f8fafc;
}
.auth-card { width: min(440px, 100%); background: #fff; border-radius: 24px; padding: 28px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); color: var(--text, #0f172a); }
.auth-card:has(#onboardForm),
.auth-card-light { width: min(960px, 100%); }
.btn[hidden],
[hidden].btn { display: none !important; }
.auth-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.auth-brand { padding: 0; }
.auth-lang { padding: 0; flex-shrink: 0; }
html[data-theme="dark"] .auth-shell {
  background:
    radial-gradient(1000px 500px at 10% -10%, rgba(20,184,166,.12), transparent 50%),
    radial-gradient(800px 400px at 100% 0%, rgba(37,99,235,.12), transparent 45%),
    var(--background, #0b0f19);
}
.tmpl-tile {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1.5px solid var(--border, #d0d7e2);
  border-radius: 14px;
  padding: 16px;
  background: var(--surface, #ffffff);
  color: var(--text, #0f172a);
  cursor: pointer;
  min-height: 88px;
  font-weight: 700;
}
.tmpl-tile input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.tmpl-tile:has(input:checked),
.tmpl-tile.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.22);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface, #fff));
}
.onboard-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}
.onboard-steps span {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-muted, #eef2f7);
  color: var(--text-muted, #475569);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border, #d0d7e2);
}
.onboard-steps span.on {
  background: color-mix(in srgb, var(--primary) 14%, #fff);
  color: var(--text, #0f172a);
  border-color: color-mix(in srgb, var(--primary) 40%, #fff);
}
html[data-theme="dark"] .onboard-steps span {
  background: var(--surface-muted);
  color: var(--text-muted);
  border-color: var(--border);
}
html[data-theme="dark"] .onboard-steps span.on {
  background: color-mix(in srgb, var(--primary) 22%, var(--surface));
  color: var(--text);
}
#onboardForm .field label,
#onboardForm h3 {
  color: var(--text, #0f172a);
}
#onboardForm select,
#onboardForm input,
#onboardForm textarea {
  color: var(--text, #0f172a);
  background: var(--surface, #fff);
  border-color: var(--border, #d0d7e2);
}
.otp-boxes { display: flex; gap: 8px; justify-content: center; }
.otp-boxes input { width: 46px; height: 52px; text-align: center; font-size: 22px; font-weight: 800; border-radius: 12px; border: 1px solid var(--line-strong); }

.hero {
  padding: 72px 20px 40px; max-width: 1120px; margin: 0 auto;
}
.hero h1 { font-size: clamp(36px, 6vw, 64px); letter-spacing: -.05em; line-height: 1.05; margin: 0 0 16px; }
.hero p { font-size: 18px; color: var(--text-soft); max-width: 640px; }
.public-nav { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; max-width: 1120px; margin: 0 auto; }
.steps { display: grid; gap: 12px; }
.step-pills { display: flex; gap: 8px; margin-bottom: 18px; }
.step-pills span { width: 28px; height: 6px; border-radius: 99px; background: var(--line); }
.step-pills span.on { background: var(--primary); }

.invoice-items { display: grid; gap: 12px; }
.item-row {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 90px) minmax(0, 110px) minmax(0, 90px) minmax(0, 140px) 40px; gap: 8px; align-items: end;
}
.totals { display: grid; gap: 8px; max-width: min(360px, 100%); margin-left: auto; min-width: 0; }
.totals div { display: flex; justify-content: space-between; gap: 16px; }
.totals .grand { font-size: 20px; font-weight: 800; border-top: 1px solid var(--line); padding-top: 8px; }

.modal {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none; place-items: center; z-index: 60; padding: 16px;
  overflow: auto;
}
.modal.open { display: grid; }
.modal .card {
  width: min(520px, 100%);
  max-width: 100%;
  max-height: min(90dvh, 100%);
  overflow: auto;
}

.skeleton { background: linear-gradient(90deg, #eee, #f7f7f7, #eee); background-size: 200% 100%; animation: shine 1.2s infinite; border-radius: 8px; height: 14px; }
@keyframes shine { to { background-position: -200% 0; } }
.fade-up { animation: fadeUp .35s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

[dir="rtl"] .search input { padding: 10px 40px 10px 14px; }
[dir="rtl"] .search svg { left: auto; right: 14px; }
[dir="rtl"] .totals { margin-left: 0; margin-right: auto; }
[dir="rtl"] .item-row { direction: rtl; }
[dir="rtl"] .content { text-align: right; }
[dir="rtl"] .page-head { flex-direction: row-reverse; }
[dir="rtl"] .form .field input,
[dir="rtl"] .form .field select,
[dir="rtl"] .form .field textarea { text-align: right; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 1200px) {
  .item-row { grid-template-columns: 1fr 1fr; }
  .invoice-workspace { grid-template-columns: minmax(0, 1fr); }
  .finance-kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); transition: transform .22s ease; }
  .sidebar.open { transform: none; }
  .drawer-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .menu-btn { display: inline-flex; }
}

@media (max-width: 768px) {
  .content:not(:has(.dash)) { padding: 16px 14px 110px; }
  .grid-2, .grid-3, .grid-4, .finance-kpis { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .desktop-only { display: none; }
  .mobile-only, .list-cards { display: block; }
  .bottom-nav { display: grid; }
  .page-head h1 { font-size: 24px; }
  table.data { min-width: 0; }
}
@media (max-width: 560px) {
  .item-row { grid-template-columns: 1fr; }
}

.invoice-paper { max-width: 900px; margin: 0 auto; background: #fff; padding: 32px; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .invoice-paper { box-shadow: none; padding: 0; }
}

/* Dark mode */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --bg-elev: #111827;
  --text: #f8fafc;
  --text-soft: #cbd5e1;
  --muted: #94a3b8;
  --line: #1f2937;
  --line-strong: #374151;
  --sidebar: #030712;
  --sidebar-2: #0b1220;
}
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .icon-btn,
html[data-theme="dark"] .chip-btn {
  background-color: var(--surface, #111827);
  color: var(--text);
}
html[data-theme="dark"] .field input:disabled,
html[data-theme="dark"] .field select:disabled,
html[data-theme="dark"] .field textarea:disabled {
  background-color: var(--surface-muted, #1b2438);
  color: var(--muted);
}
html[data-theme="dark"] .sidebar {
  background: linear-gradient(180deg, #0b1220 0%, #111827 55%, #162033 100%);
  border-color: rgba(255, 255, 255, 0.06);
}
html[data-theme="dark"] .topbar { background: #111827; border-color: #1f2937; }
html[data-theme="dark"] .nav a.active,
html[data-theme="dark"] .subnav a.active { background: rgba(255, 255, 255, 0.08); color: #fff; }
html[data-theme="dark"] .sidebar-plan { background: rgba(255, 255, 255, 0.05); border-color: rgba(232, 158, 9, 0.22); }
html[data-theme="dark"] .country-chip { background: #1B2438; border-color: #273049; color: #CBD5E1; }
html[data-theme="dark"] .top-user { background: #151C2E; border-color: #273049; }
html[data-theme="dark"] .search input { background: #1B2438; }
html[data-theme="dark"] table.data th { background: #0f172a; }

.toast-root { position: fixed; right: 16px; left: auto; bottom: 16px; z-index: 80; display: grid; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.toast { padding: 12px 14px; border-radius: 12px; background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: .25s ease; }
.toast.show { opacity: 1; transform: none; }
.toast-success { border-color: #059669; }
.toast-error { border-color: #dc2626; }
.toast-warning { border-color: #d97706; }

.command-palette { position: fixed; inset: 0; z-index: 90; display: grid; place-items: start center; padding: 8vh 16px 16px; }
.command-palette[hidden] { display: none; }
.command-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.5); }
.command-panel { position: relative; width: min(560px, 100%); max-height: min(80dvh, 640px); padding: 0; overflow: auto; }
.command-panel input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; background: transparent; }
.command-item { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.command-item:hover { background: var(--primary-soft); color: var(--text-on-light, #111827); }
.quick-create-menu a:hover { background: var(--primary-soft); }

.quick-create-wrap { position: relative; }
.quick-create-menu { display: none; position: absolute; right: 0; top: calc(100% + 8px); min-width: min(200px, calc(100vw - 24px)); max-width: calc(100vw - 24px); background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; z-index: 40; }
.quick-create-menu.open { display: grid; }
.quick-create-menu a { padding: 10px 14px; }
.quick-create-menu a:hover { background: rgba(13,148,136,.08); }
.fab-create { width: 40px; height: 40px; padding: 0; border-radius: 12px; }
.search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 50;
  max-height: 360px; overflow: auto; padding: 8px;
  background: var(--surface, #fff); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
}
.search-group { padding: 6px 4px 10px; border-bottom: 1px solid var(--line); }
.search-group:last-child { border-bottom: 0; }
.search-group strong {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 4px 8px 6px;
}
.search-group a {
  display: block; padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600;
}
.search-group a:hover { background: var(--primary-soft, #fff7ed); color: var(--primary); }
.sticky-summary { position: sticky; top: calc(var(--top-h) + 12px); }
@media (max-width: 768px) {
  .fab-create { position: fixed; right: 16px; bottom: calc(var(--bottom-h) + 12px); z-index: 34; width: 52px; height: 52px; border-radius: 50%; box-shadow: var(--shadow-lg); }
  .quick-create-menu { right: 16px; bottom: calc(var(--bottom-h) + 72px); top: auto; }
  .command-palette { display: none !important; }
}
.btn.loading { opacity: .7; pointer-events: none; }
.notif-dot {
  position: relative;
}
.notif-dot[data-count]::after {
  content: attr(data-count);
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 99px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 800; display: grid; place-items: center;
}

.mkt-badge { display:inline-block; background:rgba(255,106,0,.15); color:#ffb27a; border:1px solid rgba(255,106,0,.35); border-radius:999px; padding:6px 12px; font-size:12px; font-weight:700; letter-spacing:.04em; text-transform:uppercase; margin-bottom:16px; }
.inv-preview { background:#fff; color:var(--navy); border-radius:var(--radius-xl); box-shadow:var(--shadow-lg); padding:20px; min-height:280px; }
.inv-preview-bar { display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; font-weight:700; }
.inv-preview-items { margin-top:16px; border-top:1px solid var(--border); }
.inv-preview-items div { display:flex; justify-content:space-between; padding:10px 0; }
.mkt-steps { display:grid; gap:8px; padding-left:18px; color:#c9d3e4; }
.live-paper { background:#fff; border:1px solid var(--border); border-radius:14px; padding:16px; min-height:220px; font-size:13px; }
.live-paper h4 { margin:0 0 8px; }
.wa-cta { background:#25d366; color:#fff; border:0; }
.invoice-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.totals.sticky-summary { max-width: none; margin: 0; }
.invoice-sticky-bar {
  display: none;
  position: sticky; bottom: calc(var(--bottom-h) + 8px); z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 10px 12px; box-shadow: var(--shadow-lg);
  justify-content: space-between; align-items: center; gap: 12px;
}
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.quick-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.quick-actions a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; }
.quick-actions a:hover { border-color: var(--primary); color: var(--primary); }
.dash-welcome { font-size: 13px; color: var(--text-muted); margin: 0 0 6px; }
.card:hover { transform: translateY(-1px); transition: transform .18s ease, box-shadow .18s ease; }
.ai-log { display: grid; gap: 12px; min-height: 240px; }
.ai-bubble { padding: 12px 14px; border-radius: 14px; background: var(--surface-muted); }
.ai-bubble.user { background: var(--primary-soft); margin-left: 12%; }
.ai-bubble.assistant { margin-right: 12%; }

/* Billu floating assistant */
.billu-root { position: fixed; right: 18px; bottom: calc(var(--bottom-h) + 16px); z-index: 55; font-size: 14px; }
.billu-fab {
  display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer;
  padding: 10px 14px 10px 10px; border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), #ff8a3d); color: #fff;
  box-shadow: 0 12px 28px rgba(255, 107, 0, .35); font-weight: 700;
  transition: transform .18s ease, box-shadow .18s ease;
}
.billu-fab:hover { background: var(--primary-hover); transform: translateY(-1px) scale(1.02); }
.billu-root.is-open .billu-panel { animation: billuOpen .22s ease; }
@keyframes billuOpen { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.billu-fab-face {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.2); font-size: 18px;
}
.billu-fab-label { padding-right: 4px; }
.billu-panel {
  position: absolute; right: 0; bottom: calc(100% + 12px);
  width: min(380px, calc(100vw - 24px)); height: min(560px, calc(100vh - var(--bottom-h) - 96px));
  display: flex; flex-direction: column; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.billu-panel[hidden] { display: none !important; }
.billu-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 12px 10px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 10%, var(--surface)), var(--surface));
}
.billu-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.billu-avatar {
  width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center;
  background: var(--primary-soft); font-size: 20px; flex-shrink: 0;
}
.billu-brand strong { display: block; font-size: 15px; line-height: 1.2; }
.billu-tagline { display: block; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.billu-head-actions { display: flex; align-items: center; gap: 4px; }
.billu-badge {
  font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-ink);
}
.billu-icon-btn {
  width: 32px; height: 32px; border-radius: 10px; border: 1px solid transparent; background: transparent;
  color: var(--text-muted); cursor: pointer; font-size: 16px; line-height: 1;
}
.billu-icon-btn:hover { background: var(--surface-hover); border-color: var(--line); color: var(--text); }
.billu-quick {
  display: flex; gap: 6px; padding: 8px 10px; overflow-x: auto; border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.billu-chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface-muted); color: var(--text);
  border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 650; cursor: pointer; white-space: nowrap;
}
.billu-chip:hover { border-color: var(--primary); color: var(--primary); }
.billu-log { flex: 1; overflow: auto; padding: 12px; display: grid; gap: 10px; align-content: start; background: var(--bg, var(--surface-muted)); }
.billu-msg { display: grid; gap: 4px; max-width: 92%; }
.billu-msg--user { margin-left: auto; text-align: right; }
.billu-msg--assistant { margin-right: auto; }
.billu-msg-role { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.billu-msg-body {
  padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  white-space: pre-wrap; word-break: break-word; text-align: left; line-height: 1.45;
}
.billu-msg--user .billu-msg-body { background: var(--primary-soft); border-color: transparent; }
.billu-msg-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.billu-link {
  display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 12px; font-weight: 700; color: var(--primary);
}
.billu-confirm-btn { font-size: 12px; padding: 6px 12px; }
.billu-typing { display: inline-flex; gap: 4px; align-items: center; min-height: 18px; }
.billu-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
  animation: billu-bounce 1s infinite ease-in-out;
}
.billu-typing span:nth-child(2) { animation-delay: .15s; }
.billu-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes billu-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-4px); opacity: 1; }
}
.billu-form {
  display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--surface);
}
.billu-form input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  background: var(--bg, #fff); color: var(--text);
}
.billu-form input:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
.billu-send { flex-shrink: 0; }

@media (max-width: 720px) {
  .billu-root { right: 12px; bottom: calc(var(--bottom-h) + 12px); }
  .billu-fab-label { display: none; }
  .billu-fab { padding: 10px; border-radius: 50%; }
  .billu-panel {
    position: fixed; left: 8px; right: 8px; bottom: calc(var(--bottom-h) + 8px);
    width: auto; height: min(70vh, 520px); border-radius: 16px;
  }
  .billu-root.is-open .billu-fab { display: none; }
}

html[data-theme="dark"] .billu-msg-body { background: #111827; }
html[data-theme="dark"] .billu-chip { background: #111827; }


.mkt { background: #0b0f19; color: #e8eef9; }
.mkt a { color: inherit; }
.mkt-nav {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 20px; max-width: 1200px; margin: 0 auto; position: sticky; top: 0; z-index: 40;
  background: rgba(11,15,25,.86); backdrop-filter: blur(16px);
}
.mkt-nav .links { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; font-size: 14px; font-weight: 600; color: #c5d0e3; }
.mkt-nav .links a:hover { color: #fff; }
.mkt-hero { max-width: 1200px; margin: 0 auto; padding: 48px 20px 32px; display: grid; grid-template-columns: 1.05fr .95fr; gap: 32px; align-items: center; animation: mktReveal .55s ease both; }
.mkt-hero h1 { font-size: clamp(36px, 6vw, 64px); letter-spacing: -.05em; line-height: 1.05; margin: 0 0 16px; }
.mkt-hero h1 em { color: var(--primary); font-style: normal; }
.mkt-hero p { color: #b7c3d8; font-size: 18px; max-width: 560px; }
@keyframes mktReveal { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.mkt-nav { animation: mktReveal .4s ease both; }
.mkt-pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0; }
.mkt-pills span { border: 1px solid rgba(255,255,255,.14); border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700; color: #dce5f5; }
.mkt-ctas { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.mkt-preview { border-radius: 24px; overflow: hidden; border: 1px solid rgba(255,255,255,.1); box-shadow: var(--shadow-lg); background: #12182a; }
.mkt-preview img { display: block; width: 100%; height: auto; }
.mkt-section { max-width: 1200px; margin: 0 auto; padding: 48px 20px; }
.mkt-section h2 { font-size: clamp(28px, 4vw, 40px); letter-spacing: -.04em; margin: 0 0 8px; }
.mkt-muted { color: #9aa8c0; }
.mkt-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; margin-top: 22px; }
.mkt-card { background: #151c2e; border: 1px solid rgba(255,255,255,.08); border-radius: 18px; padding: 18px; transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.mkt-card:hover { transform: translateY(-2px); border-color: rgba(255,106,0,.35); box-shadow: 0 12px 28px rgba(0,0,0,.25); }
.mkt-card h3 { margin: 0 0 6px; }
.mkt-light { background: #f4f6fb; color: var(--text); }
.mkt-light .mkt-muted { color: var(--text-muted); }
.mkt-price { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.mkt-price .card { padding: 22px; }
.mkt-price .featured { border: 2px solid var(--primary); box-shadow: 0 16px 40px rgba(255,106,0,.18); }
.mkt-faq details { background: #151c2e; border-radius: 14px; padding: 12px 16px; margin-bottom: 8px; }
.mkt-footer { max-width: 1200px; margin: 0 auto; padding: 28px 20px 40px; color: #8b97ad; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  width: 100%;
  max-width: 960px;
  margin: 16px auto 8px;
}
.country-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 92px;
  border: 1.5px solid var(--border, #d0d7e2);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface, #ffffff);
  color: var(--text, #0f172a);
  text-align: left;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease, transform .15s ease;
}
.country-tile strong {
  color: var(--text, #0f172a);
  font-size: 14px;
  line-height: 1.35;
}
.country-tile .help {
  color: var(--text-muted, #475569);
  font-size: 12px;
  font-weight: 600;
  margin: 0;
  opacity: 1;
}
.country-tile:hover {
  border-color: var(--primary);
  background: var(--surface-hover, #fff7f0);
  transform: translateY(-1px);
}
.country-tile:focus-visible {
  outline: 3px solid rgba(255, 106, 0, 0.35);
  outline-offset: 2px;
}
.country-tile.selected,
.tmpl-tile.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.22);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface, #fff));
}
.country-tile.selected::after {
  content: '';
  align-self: flex-end;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: auto;
}
.category-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  box-sizing: border-box;
  min-width: 0;
  min-height: 170px;
  height: 100%;
  margin: 0;
  padding: 24px 20px 20px;
  border: 2px solid #d0d7e2;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  color: #0f172a;
  text-align: center;
  cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease, transform 180ms ease;
}
.category-card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  width: 100%;
}
.category-card-check {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ff6a00;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
  display: none;
  box-shadow: 0 2px 6px rgba(255, 106, 0, 0.35);
}
.category-card-icon {
  display: flex;
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  max-width: 56px;
  max-height: 56px;
  flex: 0 0 56px;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: #fff7ed;
  color: #ff6a00;
}
.category-card-icon svg,
.category-card svg,
svg.category-card-svg {
  display: block;
  width: 48px;
  height: 48px;
  max-width: 48px;
  max-height: 48px;
  flex: none;
}
.category-card-name,
.category-card-desc {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.category-card-name {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  color: #0f172a;
}
.category-card-desc {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: #64748b;
}
.category-card:hover {
  border-color: #fb923c;
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
}
.category-card:focus-within {
  outline: 3px solid rgba(255, 106, 0, 0.28);
  outline-offset: 2px;
}
.category-card.selected,
.category-card:has(.category-radio:checked) {
  border-color: #ff6a00;
  background: #fff7ed;
  box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.22), 0 8px 20px rgba(255, 106, 0, 0.12);
}
.category-card.selected .category-card-check,
.category-card:has(.category-radio:checked) .category-card-check {
  display: block;
}
.category-card.selected .category-card-icon,
.category-card:has(.category-radio:checked) .category-card-icon {
  background: #ffedd5;
  color: #c2410c;
}
.onboard-category-step:not([hidden]) {
  display: flex;
  flex-direction: column;
}
.onboard-category-lead {
  margin: 0 0 4px;
}
.tmpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
/* .tmpl-tile base styles defined near .auth-card */
#countrySearch {
  width: 100%;
  min-height: 44px;
  border: 1.5px solid var(--border, #d0d7e2);
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--surface, #fff);
  color: var(--text, #0f172a);
  margin-bottom: 12px;
}
#countrySearch:focus {
  outline: 3px solid rgba(255, 106, 0, 0.25);
  border-color: var(--primary);
}
#countryPreview {
  background: var(--surface-muted, #f1f5f9);
  border: 1px solid var(--border);
  color: var(--text);
}
@media (max-width: 720px) {
  .country-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .category-grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .country-grid { grid-template-columns: 1fr; }
}
html[data-theme="dark"] .country-tile,
html[data-theme="dark"] .tmpl-tile {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="dark"] .category-card {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="dark"] .category-card-name { color: var(--text); }
html[data-theme="dark"] .category-card-desc { color: var(--text-muted); }
html[data-theme="dark"] .category-card.selected,
html[data-theme="dark"] .category-card:has(.category-radio:checked) {
  background: color-mix(in srgb, var(--primary) 16%, var(--surface));
  border-color: var(--primary);
}
html[data-theme="dark"] .country-tile strong { color: var(--text); }
html[data-theme="dark"] .country-tile .help { color: var(--text-muted); }
html[data-theme="dark"] .country-tile:hover {
  background: var(--surface-muted);
}
html[data-theme="dark"] #countrySearch {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
@media (max-width: 960px) {
  .mkt-hero, .mkt-grid, .mkt-price { grid-template-columns: 1fr; }
  .mkt-nav .links { display: none; }
  .invoice-workspace { grid-template-columns: 1fr; }
  .invoice-sticky-bar { display: flex; }
}
html[data-theme="dark"] {
  --background: #0b0f19;
  --surface: #151c2e;
  --surface-muted: #1b2438;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: #273049;
  --bg: #0b0f19;
  --bg-elev: #151c2e;
}
.invoice-workspace { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(0, 400px); gap: 16px; align-items: start; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.sidebar-biz {
  padding: 0 8px 14px;
  margin: 0 2px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.firm-switcher { position: relative; width: 100%; min-width: 0; }
.firm-switcher-summary {
  list-style: none; cursor: pointer; display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 16px; align-items: center; gap: 10px;
  min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
  color: var(--text);
  transition: border-color var(--motion-fast) var(--ease-out), box-shadow var(--motion-fast) var(--ease-out), background var(--motion-fast) var(--ease-out);
}
.sidebar .firm-switcher-summary {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.sidebar .firm-switcher-cat { color: var(--sidebar-muted); }
.sidebar .firm-switcher-chevron { color: var(--sidebar-muted); }
.sidebar .firm-switcher-name { color: #fff; }
.firm-switcher-summary:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.firm-switcher[open] > .firm-switcher-summary {
  border-color: rgba(255, 107, 0, 0.35);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.firm-switcher-summary::-webkit-details-marker { display: none; }
.firm-switcher-avatar {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; overflow: hidden;
  background: var(--primary-soft); color: var(--primary-ink);
  font-weight: 800; font-size: 14px; letter-spacing: -.02em;
  border: 1px solid rgba(255, 107, 0, 0.12);
}
.firm-switcher-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.firm-switcher-copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.firm-switcher-name, .firm-switcher-item-name {
  display: block; font-size: 13px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; letter-spacing: -.02em;
}
.firm-switcher-cat, .firm-switcher-item-cat {
  display: inline-flex; align-items: center; width: fit-content; max-width: 100%;
  font-size: 11px; color: var(--muted); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.firm-switcher-item-cat {
  padding: 1px 7px; border-radius: var(--radius-pill);
  background: var(--surface-muted); border: 1px solid var(--line); margin-top: 3px;
}
.firm-switcher-chevron {
  width: 16px; height: 16px; color: var(--muted);
  transition: transform var(--motion-base) var(--ease-out);
}
.firm-switcher[open] .firm-switcher-chevron { transform: rotate(180deg); }
.firm-switcher-menu {
  position: absolute; z-index: 50; left: 0; right: 0; margin-top: 8px; padding: 8px;
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-elev, #fff);
  box-shadow: var(--shadow-lg); display: grid; gap: 2px; min-width: 0;
  animation: mbaFirmMenuIn var(--motion-base) var(--ease-out);
}
.firm-switcher-menu-label {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding: 6px 10px 8px;
}
.firm-switcher-item {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) 18px; align-items: center; gap: 10px;
  width: 100%; min-width: 0; padding: 8px 10px; border: 0; background: transparent; text-align: left;
  border-radius: var(--radius-md); color: inherit; text-decoration: none; cursor: pointer; font: inherit;
  transition: background var(--motion-fast) var(--ease-out);
}
.firm-switcher-item:hover { background: var(--surface-hover); }
.firm-switcher-item.is-active {
  background: var(--primary-soft);
}
.firm-switcher-item.is-active .firm-switcher-item-name { color: var(--primary-ink); }
.firm-switcher-item-check {
  width: 18px; height: 18px; color: var(--primary); opacity: 0;
}
.firm-switcher-item.is-active .firm-switcher-item-check { opacity: 1; }
.firm-switcher-item-body { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.firm-switcher-action {
  display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--primary);
  grid-template-columns: 1fr; margin-top: 2px;
}
.firm-switcher-action + .firm-switcher-action { margin-top: 0; }
.firm-switcher-divider {
  height: 1px; background: var(--line); margin: 6px 4px;
}
@keyframes mbaFirmMenuIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .firm-switcher-menu { animation: none; }
  .firm-switcher-chevron { transition: none; }
}
.topbar-firm { min-width: 0; max-width: min(280px, 42vw); margin-right: 8px; }
.topbar-firm .firm-switcher-summary {
  padding: 4px 8px; background: var(--surface-muted);
}
.topbar-firm .firm-switcher-avatar { width: 28px; height: 28px; font-size: 12px; border-radius: 8px; }
.topbar-firm .firm-switcher-menu { min-width: min(300px, 86vw); }
.firm-switcher.is-compact .firm-switcher-summary { grid-template-columns: 28px minmax(0, 1fr) 14px; gap: 8px; }
.dash-add-firm { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.firms-table .firm-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.firms-table .inline-form { display: inline; }
.firms-table .is-active-firm { background: #fff7ed; }
.firm-name { display: inline-block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
html[data-theme="dark"] .firm-switcher-summary {
  background: linear-gradient(180deg, #151C2E 0%, #1B2438 100%);
}
html[data-theme="dark"] .firm-switcher-item.is-active { background: rgba(255, 107, 0, 0.12); }
html[data-theme="dark"] .firm-switcher-item-cat { background: #1B2438; border-color: #273049; }
@media (max-width: 900px) {
  .topbar-title { display: none; }
  .topbar-firm { max-width: min(220px, 48vw); }
}
@media (min-width: 901px) {
  .topbar-firm { display: none; }
}
.sidebar-plan {
  margin: 8px 10px 12px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(232, 158, 9, 0.22);
  box-shadow: 0 0 24px rgba(232, 158, 9, 0.12);
}
.sidebar-plan strong {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 4px;
  color: #fff;
}
.sidebar-plan span {
  display: block;
  font-size: 12px;
  color: var(--sidebar-muted);
  margin-bottom: 10px;
}
.sidebar-plan .btn {
  width: 100%;
  min-height: 36px;
  font-size: 13px;
  background: linear-gradient(135deg, #ffd400, #e89e09);
  color: #111;
  border: 0;
  box-shadow: 0 0 18px rgba(232, 158, 9, 0.35);
}
.nav a.nav-cta { display: none; }
.sidebar-foot { padding: 12px 10px 8px; border-top: 1px solid rgba(255, 255, 255, 0.08); display: grid; gap: 8px; margin-top: auto; }
.sidebar-foot a { display: flex; align-items: center; gap: 8px; color: var(--sidebar-muted); font-size: 13px; font-weight: 600; padding: 6px 8px; border-radius: 8px; }
.sidebar-foot a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.lang-row { display: flex; gap: 8px; padding: 0 8px; }
.lang-row a {
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid transparent;
}
.lang-row a:hover,
.lang-row a.active { color: #ffd400; background: rgba(255, 255, 255, 0.06); }
.btn-logout { background: transparent; border: 0; color: var(--sidebar-muted); text-align: left; cursor: pointer; padding: 4px 8px; font-weight: 700; font-size: 13px; }
.btn-logout:hover { color: #fff; }
.lang-row a.active,
.lang-row a[aria-current="true"] {
  color: #ffd400;
  background: rgba(232, 158, 9, 0.12);
  border-color: rgba(232, 158, 9, 0.28);
}
.lang-row a:focus-visible {
  outline: 2px solid #ffd400;
  outline-offset: 2px;
}
.crumb { display: none; }
.country-chip {
  display: flex; gap: 6px; align-items: center; margin: 0 10px 12px;
  padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.05);
  font-size: 11px; font-weight: 700; color: var(--sidebar-text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.content:not(:has(.dash)) { padding: 22px 22px 96px; }
.search kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 10px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; background: var(--surface); }
.kpi-link { text-decoration: none; color: inherit; }
.kpi-link:hover { border-color: var(--primary); }
.finance-kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.finance-period-note { margin: -8px 0 16px; }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.table-actions .btn { min-height: 36px; padding: 0 10px; font-size: 13px; }
.empty-hero { padding: 56px 24px; }
.empty-mark { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px; background: linear-gradient(135deg, var(--primary), #ffb27a); }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.row-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; min-width: 0; }
.toolbar label { min-width: 0; }
.toolbar input, .toolbar select { min-height: 44px; border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; background: var(--surface); min-width: 0; max-width: 100%; }

/* List search / filter / sort toolbar */
.list-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center;
  margin-bottom: 16px; padding: 14px 16px;
}
.list-toolbar-main {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1 1 280px;
}
.list-toolbar-main input[type="search"],
.list-toolbar-main input[type="text"],
.list-toolbar-main input[type="date"],
.list-toolbar-main select {
  min-height: 42px; border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 12px; background: var(--surface); font: inherit; color: var(--text);
}
.list-toolbar-main input[type="search"] { flex: 1 1 12rem; min-width: 0; }
.list-toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; }
.list-toolbar-chips { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--surface-muted); border: 1px solid var(--line); color: var(--text-soft);
}
.filter-chip-toggle { cursor: pointer; user-select: none; }
.filter-chip-toggle input { margin: 0; }
.filter-chip-toggle:has(input:checked) {
  background: var(--primary-soft); border-color: var(--primary); color: var(--text-on-light, #111827);
}
.sort-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: inherit; text-decoration: none; font-weight: 700; white-space: nowrap;
}
.sort-link:hover { color: var(--primary); }
.sort-link-icon {
  width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-bottom: 5px solid var(--text-muted); opacity: .35; margin-left: 2px;
}
.sort-link.is-active { color: var(--primary); }
.sort-link.is-asc .sort-link-icon { opacity: 1; border-bottom-color: var(--primary); border-top: 0; }
.sort-link.is-desc .sort-link-icon {
  opacity: 1; border-bottom: 0; border-top: 5px solid var(--primary);
}
.action-menu { position: relative; }
.action-menu summary { cursor: pointer; list-style: none; font-weight: 700; }
.action-panel { position: absolute; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); min-width: 180px; z-index: 20; padding: 6px; display: grid; }
.action-panel a, .action-panel button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer; font: inherit; }
.action-panel a:hover, .action-panel button:hover { background: var(--primary-soft); }
.list-card { display: block; margin-bottom: 10px; }
.mobile-sheet { display: none; }
html[data-theme="dark"] .card,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .live-paper,
html[data-theme="dark"] .auth-card { background: var(--surface); }
html[data-theme="dark"] .btn-ghost { background: var(--surface); color: var(--text); }
@media (max-width: 960px) {
  .top-create-wrap { display: none; }
  .top-user-meta { display: none; }
  .search kbd { display: none; }
  .topbar-title { display: none; }
  .invoice-workspace { grid-template-columns: 1fr; }
}
.admin-sidebar { background: linear-gradient(180deg, #0b0f19, #1a1020); }
.admin-h2 { margin: 22px 0 10px; font-size: 16px; }
.admin-kpi { margin-bottom: 8px; }
.admin-app .content { max-width: 1200px; }
@media (max-width: 860px) {
  .admin-app { display: block; }
  .admin-sidebar { width: 100%; position: relative; }
  .admin-sidebar .nav { display: flex; flex-wrap: wrap; gap: 6px; }
  .admin-sidebar .nav a { padding: 8px 10px; }
}
.onboard-steps { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 18px; }
.onboard-steps span { font-size: 12px; font-weight: 700; color: var(--text-muted); padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); }
.onboard-steps span.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.rupee-callout {
  display: inline-flex; align-items: baseline; gap: 10px; margin: 18px 0;
  padding: 12px 16px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,106,0,.2), rgba(255,106,0,.05));
  border: 1px solid rgba(255,106,0,.4); color: #fff;
}
.rupee-callout strong { font-size: 42px; letter-spacing: -.05em; color: var(--primary); }
.paper-preview {
  background: #fff; color: #0b0f19; border-radius: 20px; padding: 22px;
  box-shadow: var(--shadow-lg); min-height: 280px;
}
.paper-preview header { display: flex; justify-content: space-between; border-bottom: 2px solid #0b0f19; padding-bottom: 12px; margin-bottom: 12px; }
.paper-logo { font-weight: 800; color: var(--primary); }
.paper-preview table { width: 100%; font-size: 13px; }
.paper-preview footer { display: flex; justify-content: space-between; margin-top: 16px; font-weight: 700; }
.mkt-ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.25); }
.rupee-inline { font-size: 22px; font-weight: 800; color: var(--primary); }
.mkt-faq { display: grid; gap: 10px; max-width: 800px; }
.top-country {
  display: flex; gap: 6px; align-items: center;
  padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.ws-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.ws-head h1 { margin: 0; }
.ws-head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.ws-section { margin-bottom: 0; }
.ws-section h3 { margin: 0 0 10px; font-size: 15px; }
.ws-section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ws-editor { display: grid; gap: 12px; }
.invoice-workspace .ws-section.card { padding: 14px; }
.ws-preview { position: sticky; top: 80px; }
.ws-preview-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.invoice-workspace.preview-hidden { grid-template-columns: 1fr; }
.invoice-workspace.preview-hidden .ws-preview { display: none; }
.item-row {
  display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(6, minmax(0, 1fr)) auto;
  gap: 8px; align-items: end; padding: 12px; border: 1px solid var(--border);
  border-radius: 14px; margin-bottom: 10px; background: var(--surface);
  min-width: 0;
}
.item-row.item-row--retail {
  grid-template-columns: minmax(0, 1.6fr) repeat(5, minmax(0, 1fr)) auto;
}
.item-row.item-row--retail.item-row--hsn {
  grid-template-columns: minmax(0, 1.4fr) repeat(6, minmax(0, 1fr)) auto;
}
.item-row.item-row--electronics {
  grid-template-columns: minmax(0, 1.3fr) repeat(6, minmax(0, 1fr)) minmax(0, 1.1fr) auto;
}
.item-row.item-row--pharmacy {
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.1fr) repeat(5, minmax(0, 1fr)) auto;
}
.item-row > * { min-width: 0; max-width: 100%; }
.item-row .item-serial-field[hidden],
.item-row .item-batch-field[hidden] { display: none !important; }
.btn-sm { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.a4-live {
  background: #fff; color: #0b0f19; border-radius: 4px; padding: 22px 20px;
  box-shadow: var(--shadow-lg); min-height: 480px; font-size: 12px;
}
.a4-live header { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px solid #0b0f19; padding-bottom: 10px; }
.a4-live h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.a4-items { width: 100%; border-collapse: collapse; margin: 12px 0; }
.a4-items th, .a4-items td { text-align: left; padding: 6px 4px; border-bottom: 1px solid #e5e7eb; }
.a4-foot { display: flex; justify-content: space-between; gap: 16px; }
.tot-line { display: flex; justify-content: space-between; gap: 24px; }
.tot-line.grand { font-size: 16px; margin-top: 6px; }
.a4-live.tpl-classic { font-family: Georgia, serif; }
.a4-live.tpl-minimal { box-shadow: none; border: 1px solid #e5e7eb; }
.a4-live.tpl-professional { border-top: 8px solid #0f766e; }
.a4-live.tpl-retail { border-left: 8px solid var(--primary); }
.a4-live.tpl-premium { background: linear-gradient(#fff, #fff7f0); }
.stock-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.stock-badge { font-size: 11px; font-weight: 800; padding: 4px 8px; border-radius: 999px; margin-right: 8px; }
.stock-ok { background: var(--success-soft); color: #047857; }
.stock-low { background: var(--warning-soft); color: #b45309; }
.stock-out { background: var(--danger-soft); color: #b91c1c; }
.amt-debit { color: var(--danger); }
.amt-credit { color: var(--success); }
.signup-hero h2 { margin: 0 0 8px; letter-spacing: -.03em; }
.signup-hero { margin-bottom: 8px; }
.signup-form .field { margin-bottom: 14px; }
.signup-form label { font-weight: 600; }
.signup-form input:focus {
  outline: 3px solid rgba(255, 106, 0, 0.22);
  border-color: var(--primary);
}
.signup-form input:invalid:not(:placeholder-shown):not(:focus) {
  border-color: #dc2626;
}
.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
  min-width: 0;
}
.password-field input { width: 100%; }
.password-toggle {
  min-width: 64px;
  border: 1px solid var(--border, #d0d7e2);
  border-radius: 10px;
  background: var(--surface-muted, #f1f5f9);
  color: var(--text, #0f172a);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  padding: 0 12px;
}
.password-toggle:hover { border-color: var(--primary); color: var(--primary); }
.password-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.signup-submit.is-loading,
.signup-submit:disabled {
  opacity: 0.72;
  cursor: wait;
  pointer-events: none;
}
.signup-footer { margin-top: 16px; text-align: center; }
.alert-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
html[data-theme="dark"] .alert-success {
  background: #052e1c;
  color: #a7f3d0;
  border-color: #065f46;
}
html[data-theme="dark"] .alert-error {
  background: #450a0a;
  color: #fecaca;
  border: 1px solid #7f1d1d;
}
html[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #1e293b, #334155, #1e293b);
  background-size: 200% 100%;
}
html[data-theme="dark"] .pager-size select,
html[data-theme="dark"] .pager-page:not(.is-current) {
  background: #fff;
  color: var(--text-on-light, #111827);
  color-scheme: light;
}
html[data-theme="dark"] .action-panel a:hover,
html[data-theme="dark"] .action-panel button:hover {
  color: var(--text-on-light, #111827);
}

/* RTL adaptations */
[dir="rtl"] .sidebar { text-align: right; }
[dir="rtl"] .nav a,
[dir="rtl"] .subnav a { flex-direction: row-reverse; }
[dir="rtl"] .brand { flex-direction: row-reverse; }
[dir="rtl"] .topbar { flex-direction: row-reverse; }
[dir="rtl"] .lang-row { flex-direction: row-reverse; }
[dir="rtl"] .field label { text-align: right; }
[dir="rtl"] .password-field { direction: rtl; }
[dir="rtl"] .country-tile { text-align: right; }
[dir="rtl"] .country-tile.selected::after { align-self: flex-start; }
[dir="rtl"] .category-card-check { right: auto; left: 10px; }
[dir="rtl"] table.data th,
[dir="rtl"] table.data td { text-align: right; }
[dir="rtl"] .btn-block { text-align: center; }
@media (max-width: 1024px) {
  [dir="rtl"] .sidebar { left: auto; right: 0; transform: translateX(105%); }
  [dir="rtl"] .sidebar.open { transform: none; }
}
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 8px; }
.pager-meta { margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.pager-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pager-pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pager-page { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 700; color: var(--text-on-light, #111827); text-decoration: none; }
.pager-page.is-current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager-btn { min-height: 40px; padding: 0 12px; }
.pager-btn.is-disabled { opacity: .45; pointer-events: none; }
.pager-size select { min-height: 40px; border-radius: 10px; border: 1px solid var(--line); padding: 0 8px; background: #fff; color: var(--text-on-light, #111827); color-scheme: light; }
@media (max-width: 720px) {
  .pager { flex-direction: column; align-items: stretch; }
  .pager-controls { justify-content: space-between; }
  .pager-page { min-width: 36px; min-height: 36px; }
}
.chip-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 8px 12px; cursor: pointer; }
.chip-btn:hover { border-color: var(--primary); }
.ai-bubble { padding: 10px 12px; border-radius: 12px; margin: 8px 0; max-width: 90%; }
.ai-bubble.user { background: var(--primary-soft); margin-left: auto; color: var(--text-on-light, #111827); }
.ai-bubble.assistant { background: var(--surface-muted); }
.notif-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.notif-row.unread { background: var(--primary-soft); margin: 0 -16px; padding: 12px 16px; color: var(--text-on-light, #111827); }
html[data-theme="dark"] .a4-live { background: #fff; color: #0b0f19; }
html[data-theme="dark"] .top-country { background: #111827; }
@media (max-width: 960px) {
  .top-country { display: none; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .ws-preview { position: static; display: none; }
  .ws-preview.open { display: block; }
  .ws-head-actions .btn-primary { display: none; }
}
@media (max-width: 1200px) {
  .finance-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .toast-root { bottom: calc(16px + var(--bottom-h)); }
  .content:not(:has(.dash)) { padding: 16px 14px 110px; }
  .finance-kpis { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .item-row { grid-template-columns: 1fr; }
}

/* Smart phone-first customer fields */
.smart-customer { margin: 0; }
.smart-customer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}
.field-span { grid-column: 1 / -1; }
.smart-customer-phone-row { display: flex; gap: 8px; align-items: stretch; }
.smart-customer-cc { width: 92px; flex: 0 0 92px; }
.smart-customer-phone-input,
.smart-customer-name-input { width: 100%; }
.smart-customer-name-wrap { position: relative; }
.smart-customer-suggest {
  position: absolute;
  z-index: 40;
  left: 0; right: 0; top: calc(100% + 4px);
  max-height: 240px;
  overflow: auto;
  padding: 6px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  background: var(--surface);
}
.smart-customer-suggest-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}
.smart-customer-suggest-item:hover,
.smart-customer-suggest-item:focus {
  background: var(--primary-soft);
  outline: none;
}
.smart-customer-suggest-item strong { font-size: 14px; color: var(--text); }
.smart-customer-suggest-item span { font-size: 12px; color: var(--text-muted); }
.smart-customer-status {
  min-height: 1.2em;
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.smart-customer-status[data-kind="found"] { color: var(--success); }
.smart-customer-status[data-kind="new"],
.smart-customer-status[data-kind="dirty"] { color: var(--warning); }
.smart-customer-status[data-kind="searching"] { color: var(--text-muted); }
@media (max-width: 720px) {
  .smart-customer-grid { grid-template-columns: 1fr; }
}
