/* ==========================================================
   INVOICE HERO — APP STYLES
   ========================================================== */

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

  --bg: #F3F4F9;
  --surface: #FFFFFF;
  --surface-2: #F7F8FC;
  --surface-3: #EDEFF6;
  --border: #E2E5EF;
  --border-strong: #CBD0DF;
  --ink: #0E1330;
  --ink-2: #434A69;
  --muted: #676E8C;

  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-text: #4338CA;
  --on-primary: #FFFFFF;
  --primary-soft: #EDECFD;
  --ring: rgba(79, 70, 229, .28);
  --accent: #C026D3;

  --success: #047857; --success-soft: #DDF4EA;
  --warning: #A15C07; --warning-soft: #FDF0DA;
  --danger: #BE123C;  --danger-soft: #FDE7EC; --danger-solid: #E11D48;
  --info: #1D4ED8;    --info-soft: #E3ECFD;
  --neutral: #4B5270; --neutral-soft: #ECEEF4;

  --chart-bar: #4F46E5;
  --chart-grid: #E7E9F1;

  --shadow-sm: 0 1px 2px rgba(16, 20, 50, .06);
  --shadow: 0 1px 2px rgba(16, 20, 50, .05), 0 6px 20px -6px rgba(16, 20, 50, .10);
  --shadow-lg: 0 24px 60px -12px rgba(16, 20, 50, .28);

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;

  --sidebar-w: 256px;
  --topbar-h: 60px;
  --tabbar-h: 68px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090B15; --surface: #121526; --surface-2: #171B2F; --surface-3: #1F2440;
    --border: #262B46; --border-strong: #363C60; --ink: #ECEEFA; --ink-2: #BAC0DA; --muted: #8E94B3;
    --primary: #5B54EE; --primary-hover: #6C66F2; --primary-text: #A5A1FF; --on-primary: #FFFFFF;
    --primary-soft: rgba(124, 120, 245, .16); --ring: rgba(124, 120, 245, .40); --accent: #E879F9;
    --success: #6EE7B7; --success-soft: rgba(52, 211, 153, .13);
    --warning: #FCD34D; --warning-soft: rgba(251, 191, 36, .13);
    --danger: #FDA4AF;  --danger-soft: rgba(244, 63, 94, .15); --danger-solid: #E11D48;
    --info: #93C5FD;    --info-soft: rgba(96, 165, 250, .14);
    --neutral: #B4BAD4; --neutral-soft: rgba(180, 186, 212, .12);
    --chart-bar: #7C78F5; --chart-grid: #232843;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -8px rgba(0, 0, 0, .55);
    --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #090B15; --surface: #121526; --surface-2: #171B2F; --surface-3: #1F2440;
  --border: #262B46; --border-strong: #363C60; --ink: #ECEEFA; --ink-2: #BAC0DA; --muted: #8E94B3;
  --primary: #5B54EE; --primary-hover: #6C66F2; --primary-text: #A5A1FF; --on-primary: #FFFFFF;
  --primary-soft: rgba(124, 120, 245, .16); --ring: rgba(124, 120, 245, .40); --accent: #E879F9;
  --success: #6EE7B7; --success-soft: rgba(52, 211, 153, .13);
  --warning: #FCD34D; --warning-soft: rgba(251, 191, 36, .13);
  --danger: #FDA4AF;  --danger-soft: rgba(244, 63, 94, .15); --danger-solid: #E11D48;
  --info: #93C5FD;    --info-soft: rgba(96, 165, 250, .14);
  --neutral: #B4BAD4; --neutral-soft: rgba(180, 186, 212, .12);
  --chart-bar: #7C78F5; --chart-grid: #232843;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -8px rgba(0, 0, 0, .55);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }

/* ---------- Boot splash ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-mark { width: 52px; height: 52px; border-radius: 16px; background: linear-gradient(135deg, var(--primary), var(--accent)); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.88); opacity: .7; } }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -0.03em; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center; background: linear-gradient(135deg, #4F46E5, #C026D3); box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .7); }
.brand-mark svg { width: 18px; height: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 650; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .08s, box-shadow .15s;
  text-decoration: none !important; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 18px -8px var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.btn-danger { background: var(--danger-solid); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn-soft { background: var(--primary-soft); color: var(--primary-text); }
.btn-soft:hover:not(:disabled) { filter: brightness(.97); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-lg { height: 50px; padding: 0 24px; font-size: 15px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.btn .spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .hint.error { color: var(--danger); }
.field .hint.ok { color: var(--success); }
.input, .select, .textarea {
  width: 100%; min-width: 0; height: 44px; padding: 0 14px;
  font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, background .15s;
  appearance: none; -webkit-appearance: none;
}
.textarea { height: auto; min-height: 84px; padding: 11px 14px; resize: vertical; line-height: 1.45; }
.select {
  padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%23878DAA' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .8; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.input[readonly] { background: var(--surface-2); }
.input.invalid { border-color: var(--danger-solid); }
input[type="date"].input { padding-right: 8px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 40px; }
.input-group > svg { position: absolute; left: 13px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.input-suffix { position: relative; }
.input-suffix .input { padding-right: 36px; }
.input-suffix span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }

.grid { display: grid; gap: 14px; }
.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)); }
.span-2 { grid-column: span 2; }
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: auto; }
}

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14px; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { position: relative; width: 42px; height: 24px; border-radius: 99px; background: var(--border-strong); transition: background .2s; flex: none; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 4px var(--ring); }

/* Segmented control */
.segmented { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface-3); border-radius: 12px; }
.segmented button { border: 0; background: transparent; height: 34px; padding: 0 14px; border-radius: 9px; font-weight: 650; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.segmented button { display: inline-flex; align-items: center; gap: 6px; }
.segmented button svg { width: 16px; height: 16px; }

/* Chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip .count { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); }
.chip.active .count { background: rgba(255, 255, 255, .18); color: inherit; }
.chips-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips-scroll::-webkit-scrollbar { display: none; }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; text-transform: capitalize; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-draft { background: var(--neutral-soft); color: var(--neutral); }
.pill-sent { background: var(--info-soft); color: var(--info); }
.pill-paid { background: var(--success-soft); color: var(--success); }
.pill-overdue { background: var(--danger-soft); color: var(--danger); }
.pill-void { background: var(--neutral-soft); color: var(--muted); text-decoration: line-through; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 7px; font-size: 11px; font-weight: 700; letter-spacing: .02em; background: var(--primary-soft); color: var(--primary-text); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 16px; font-weight: 750; }
.card-head .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 22px; }
.section-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); flex: none; }
.section-icon svg { width: 18px; height: 18px; }
.card-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
@media (max-width: 640px) {
  .card { border-radius: var(--radius); }
  .card-pad, .card-body { padding: 16px; }
  .card-head { padding: 14px 16px; }
}

/* ---------- App shell ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar .brand { padding: 4px 10px 18px; }
.sidebar .btn-new { margin: 0 4px 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 16px 12px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 11px;
  font-weight: 600; font-size: 14px; color: var(--ink-2); text-decoration: none;
}
.nav a svg { width: 20px; height: 20px; flex: none; opacity: .85; }
.nav a:hover { background: var(--surface-3); color: var(--ink); }
.nav a.active { background: var(--primary-soft); color: var(--primary-text); }
.nav a.active svg { opacity: 1; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); }
.user-chip .who { min-width: 0; flex: 1; }
.user-chip .who strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 750; font-size: 14px; color: #fff; background: linear-gradient(135deg, #4F46E5, #C026D3); }

.main { min-width: 0; }
.page { max-width: 1240px; margin: 0 auto; padding: 32px 36px 56px; }
.page-narrow { max-width: 880px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.035em; }
.page-head p { color: var(--muted); margin-top: 6px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 18px; }

.topbar, .tabbar { display: none; }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    position: sticky; top: 0; z-index: 40; height: var(--topbar-h); padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--border);
  }
  .topbar .brand { font-size: 17px; }
  .topbar .brand-mark { width: 30px; height: 30px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--border);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 100%;
    border: 0; background: none; font-size: 11px; font-weight: 650; color: var(--muted); text-decoration: none; cursor: pointer;
  }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .active { color: var(--primary-text); }
  .tabbar .fab { position: relative; }
  .tabbar .fab span.fab-btn {
    width: 52px; height: 52px; margin-top: -22px; border-radius: 18px; display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, #4F46E5, #C026D3); box-shadow: 0 10px 24px -8px rgba(79, 70, 229, .8);
  }
  .tabbar .fab span.fab-btn svg { width: 24px; height: 24px; }
  .page { padding: 20px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 18px; align-items: flex-start; }
  .page-head h1 { font-size: 24px; }
}

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { position: relative; padding: 20px; overflow: hidden; }
.stat .stat-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; color: var(--muted); }
.stat .stat-label svg { width: 16px; height: 16px; }
.stat .stat-value { margin-top: 10px; font-size: 28px; font-weight: 800; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.stat .stat-foot { margin-top: 4px; font-size: 13px; color: var(--muted); }
.stat-hero { color: #fff; border: 0; background: radial-gradient(120% 140% at 100% 0%, #C026D3 0%, #6D28D9 38%, #4338CA 70%, #312E81 100%); box-shadow: 0 18px 40px -18px rgba(79, 70, 229, .8); }
.stat-hero .stat-label, .stat-hero .stat-foot { color: rgba(255, 255, 255, .82); }
.stat-hero::after { content: ''; position: absolute; right: -40px; bottom: -60px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .stats { gap: 10px; }
  .stat { padding: 14px; }
  .stat .stat-value { font-size: 21px; }
  .stat .stat-foot { font-size: 12px; }
}

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; margin-top: 18px; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Chart ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--chart-bar); pointer-events: none; }
.chart .bar-hit { fill: transparent; cursor: pointer; }
.chart .bar-hit:hover + .bar, .chart .bar.hover { filter: brightness(1.15); }
.chart-tip {
  position: absolute; pointer-events: none; transform: translate(-50%, -100%); margin-top: -10px;
  padding: 8px 10px; border-radius: 10px; background: var(--ink); color: var(--surface);
  font-size: 12px; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow); opacity: 0; transition: opacity .12s;
}
.chart-tip strong { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.chart-tip.show { opacity: 1; }

/* ---------- Lists / tables ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 22px; border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
.list-row:first-child { border-top: 0; }
a.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .amount { font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; }
@media (max-width: 640px) { .list-row { padding: 12px 16px; } }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }
.table .right { text-align: right; }
.table .strong { font-weight: 700; }
.table th:first-child, .table td:first-child { padding-left: 22px; }
.table th:last-child, .table td:last-child { padding-right: 22px; }

/* Invoice list: table on desktop, cards on mobile */
.inv-cards { display: none; }
@media (max-width: 760px) {
  .inv-table { display: none; }
  .inv-cards { display: flex; flex-direction: column; }
}
.inv-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 14px 16px; border-top: 1px solid var(--border); color: inherit; text-decoration: none !important; }
.inv-card:first-child { border-top: 0; }
.inv-card:active { background: var(--surface-2); }
.inv-card .c-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-card .c-total { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.inv-card .c-meta { font-size: 13px; color: var(--muted); }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.toolbar .input-group { flex: 1 1 260px; }
@media (max-width: 640px) { .toolbar { padding: 14px 16px; } }

.summary-strip { display: flex; gap: 28px; flex-wrap: wrap; padding: 14px 22px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: 13px; color: var(--muted); }
.summary-strip strong { color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; margin-left: 6px; }
@media (max-width: 640px) { .summary-strip { gap: 6px 18px; padding: 12px 16px; } }

/* ---------- Empty & skeleton ---------- */
.empty { text-align: center; padding: 56px 24px; }
.empty .empty-art { width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 22px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.empty .empty-art svg { width: 36px; height: 36px; }
.empty h3 { font-size: 18px; font-weight: 750; }
.empty p { color: var(--muted); margin: 6px auto 20px; max-width: 360px; }
.skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Menus ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: pop .14s ease-out;
}
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 10px; border: 0; border-radius: 9px; background: none; font-size: 14px; font-weight: 600; color: var(--ink); text-align: left; cursor: pointer; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--surface-3); }
.menu svg { width: 17px; height: 17px; color: var(--muted); }
.menu .danger, .menu .danger svg { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------- Modal & sheet ---------- */
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 10, 24, .55); backdrop-filter: blur(4px); animation: fade .15s ease-out; }
.modal {
  position: relative; width: 100%; max-width: 560px; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-lg); animation: rise .2s cubic-bezier(.2, .9, .3, 1.2);
}
.modal-wide { max-width: 940px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 18px; font-weight: 750; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } }
@media (max-width: 640px) {
  .modal-root { place-items: end stretch; padding: 0; }
  .modal { max-width: none; max-height: 92vh; border-radius: 22px 22px 0 0; animation: slideup .24s cubic-bezier(.2, .9, .3, 1); padding-bottom: env(safe-area-inset-bottom); }
  .modal-body { padding: 16px; }
  .modal-head, .modal-foot { padding: 14px 16px; }
  .modal-foot .btn { flex: 1; }
}
@keyframes slideup { from { transform: translateY(100%); } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px; padding: 12px 16px;
  border-radius: 14px; background: var(--ink); color: var(--surface); font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-lg); animation: rise .2s ease-out; pointer-events: auto;
}
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.success svg { color: #34D399; }
.toast.error svg { color: #FB7185; }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: all .2s; }
@media (max-width: 960px) {
  .toasts { left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); align-items: center; }
  .toast { width: 100%; max-width: 420px; }
  body.no-tabbar .toasts { bottom: 20px; }
}

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-art {
  position: relative; overflow: hidden; padding: 44px; display: flex; flex-direction: column; justify-content: space-between; color: #fff;
  background: radial-gradient(90% 70% at 90% 10%, rgba(192, 38, 211, .55), transparent 60%),
              radial-gradient(80% 60% at 0% 100%, rgba(59, 130, 246, .45), transparent 60%),
              linear-gradient(160deg, #1E1B4B 0%, #312E81 45%, #4C1D95 100%);
}
.auth-art .brand { color: #fff; }
.auth-art h2 { font-size: clamp(30px, 3.2vw, 44px); font-weight: 800; letter-spacing: -0.04em; max-width: 520px; line-height: 1.08; }
.auth-art .lede { margin-top: 14px; font-size: 16px; color: rgba(255, 255, 255, .8); max-width: 440px; }
.auth-feats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.auth-feats span { padding: 7px 12px; border-radius: 99px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16); font-size: 13px; font-weight: 600; }
.auth-mock { position: relative; height: 330px; margin: 28px 0; }
.auth-mock .mock-page {
  position: absolute; left: 50%; top: 0; width: 800px; transform-origin: top center; border-radius: 10px; overflow: hidden;
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, .6); pointer-events: none;
}
.auth-mock .mock-page.back { transform: translateX(-38%) rotate(6deg) scale(.36); opacity: .55; top: 24px; }
.auth-mock .mock-page.front { transform: translateX(-58%) rotate(-3deg) scale(.42); }
.auth-mock .float-card {
  position: absolute; right: 6%; bottom: 8px; padding: 12px 16px; border-radius: 16px; color: #0E1330;
  background: rgba(255, 255, 255, .96); box-shadow: 0 20px 40px -12px rgba(0, 0, 0, .5); display: flex; align-items: center; gap: 12px;
  animation: floaty 5s ease-in-out infinite;
}
.auth-mock .float-card .dot { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: #DDF4EA; color: #047857; }
.auth-mock .float-card small { display: block; color: #676E8C; font-size: 12px; font-weight: 600; }
.auth-mock .float-card strong { font-size: 17px; font-variant-numeric: tabular-nums; }
@keyframes floaty { 50% { transform: translateY(-8px); } }
.auth-foot { font-size: 13px; color: rgba(255, 255, 255, .6); }

.auth-panel { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 410px; }
.auth-card .brand { display: none; margin-bottom: 28px; }
.auth-card h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.035em; }
.auth-card .sub { color: var(--muted); margin: 8px 0 28px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-card .row-between { display: flex; justify-content: space-between; align-items: center; }
.divider { display: flex; align-items: center; gap: 14px; margin: 22px 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.guest-cta { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px; border: 1px dashed var(--border-strong); color: var(--ink); text-decoration: none !important; transition: border-color .15s, background .15s; }
.guest-cta:hover { border-color: var(--primary); background: var(--primary-soft); }
.guest-cta .section-icon { background: var(--surface-3); color: var(--ink-2); }
.guest-cta strong { display: block; font-size: 14px; }
.guest-cta span { font-size: 13px; color: var(--muted); }
.guest-cta > svg { margin-left: auto; width: 18px; height: 18px; color: var(--muted); }
.auth-switch { margin-top: 24px; text-align: center; color: var(--muted); font-size: 14px; }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 14px; font-weight: 550; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-info { background: var(--info-soft); color: var(--info); }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: none; border-radius: 8px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.pw-toggle svg { width: 18px; height: 18px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 2px; }
.pw-meter i { height: 4px; border-radius: 4px; background: var(--surface-3); }
.pw-meter[data-score="1"] i:nth-child(-n+1) { background: var(--danger-solid); }
.pw-meter[data-score="2"] i:nth-child(-n+2) { background: #F59E0B; }
.pw-meter[data-score="3"] i:nth-child(-n+3) { background: #10B981; }
.pw-meter[data-score="4"] i:nth-child(-n+4) { background: #10B981; }

@media (max-width: 960px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
  .auth-panel { justify-content: flex-start; padding: 36px 20px 40px; }
  .auth-card .brand { display: flex; }
  .auth-card h1 { font-size: 26px; }
}

/* ---------- Editor ---------- */
.editor-bar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 12px 36px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--border);
}
.editor-bar .title { min-width: 0; flex: 1; }
.editor-bar h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.03em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 10px; }
.editor-bar .sub { font-size: 13px; color: var(--muted); }
.editor-bar .actions { display: flex; gap: 8px; align-items: center; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr); gap: 24px; max-width: 1480px; margin: 0 auto; padding: 24px 36px 64px; align-items: start; }
.editor-form { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.editor-preview { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.preview-head .label { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; color: var(--muted); }
.preview-frame { position: relative; border-radius: 14px; overflow: hidden; background: #fff; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.preview-frame .preview-scale { width: 800px; transform-origin: top left; }
.mobile-switch { display: none; }

@media (max-width: 1180px) {
  .editor { grid-template-columns: minmax(0, 1fr); padding: 18px 16px 120px; }
  .editor-preview { position: static; display: none; }
  .editor.show-preview .editor-form { display: none; }
  .editor.show-preview .editor-preview { display: flex; }
  .editor-bar { padding: 10px 16px; }
  .mobile-switch { display: flex; justify-content: center; padding: 12px 16px 0; }
}
@media (max-width: 960px) {
  .editor-bar { top: var(--topbar-h); }
  .editor-bar h1 { font-size: 17px; }
  .editor-bar .sub { display: none; }
  .editor-bar .actions .hide-sm { display: none; }
}
.editor-dock { display: none; }
@media (max-width: 1180px) {
  .editor-dock {
    display: flex; gap: 10px; position: fixed; left: 0; right: 0; z-index: 45;
    bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
  }
  .editor-dock .btn { flex: 1; }
  .editor-dock .total { display: flex; flex-direction: column; justify-content: center; min-width: 0; flex: 1; }
  .editor-dock .total small { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
  .editor-dock .total strong { font-size: 18px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body.editing .tabbar { display: none; }
  body.editing .toasts { bottom: calc(86px + env(safe-area-inset-bottom)); }
}

/* Template picker */
.tpl-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tpl { position: relative; border: 2px solid var(--border); border-radius: 14px; padding: 6px; background: var(--surface-2); cursor: pointer; text-align: left; transition: border-color .15s, transform .15s; }
.tpl:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.tpl.active { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.tpl-thumb { position: relative; aspect-ratio: 8.5 / 7; overflow: hidden; border-radius: 8px; background: #fff; }
.tpl-thumb > div { position: absolute; top: 0; left: 0; width: 800px; transform-origin: top left; pointer-events: none; }
.tpl-name { display: block; padding: 8px 4px 2px; font-size: 13px; font-weight: 700; }
.tpl .check { position: absolute; top: 12px; right: 12px; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; display: none; place-items: center; }
.tpl.active .check { display: grid; }
.tpl .check svg { width: 14px; height: 14px; }
@media (max-width: 1400px) and (min-width: 1181px) { .tpl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .tpl-grid { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 4px 16px 8px; scrollbar-width: none; }
  .tpl-grid::-webkit-scrollbar { display: none; }
  .tpl { flex: 0 0 42%; scroll-snap-align: start; }
}

/* Party picker (business/client) */
.picker { display: flex; gap: 8px; align-items: center; }
.picker .select { flex: 1; }
.collapsible-toggle { border: 0; background: none; padding: 0; color: var(--primary-text); font-weight: 650; font-size: 13px; cursor: pointer; }

/* Logo choices */
.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.logo-opt { position: relative; height: 72px; padding: 10px; border-radius: 12px; border: 2px solid var(--border); background: #fff; display: grid; place-items: center; cursor: pointer; transition: border-color .15s; }
.logo-opt:hover { border-color: var(--border-strong); }
.logo-opt.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.logo-opt img { max-width: 100%; max-height: 48px; object-fit: contain; }
.logo-opt.none, .logo-opt.upload { background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 650; flex-direction: column; gap: 4px; display: flex; align-items: center; justify-content: center; }
.logo-opt.upload { border-style: dashed; }
.logo-opt svg { width: 20px; height: 20px; }
.logo-opt .del { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--danger-solid); color: #fff; display: none; place-items: center; cursor: pointer; }
.logo-opt:hover .del { display: grid; }
.logo-opt .del svg { width: 12px; height: 12px; }
@media (hover: none) { .logo-opt .del { display: grid; } }

/* Line items */
.items-head, .item-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 130px 120px 40px; gap: 10px; align-items: center; }
.items-head { padding: 0 2px 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.items-head .right, .item-row .item-amount { text-align: right; }
.item-row { padding: 6px 0; }
.item-row .item-amount { font-weight: 700; font-variant-numeric: tabular-nums; padding-right: 4px; overflow: hidden; text-overflow: ellipsis; }
.item-row .input { height: 42px; }
.item-row .item-num { text-align: right; font-variant-numeric: tabular-nums; }
.item-row .m-label { display: none; }
.items-list { display: flex; flex-direction: column; }
.item-row .drag { display: none; }
@media (max-width: 640px) {
  .items-head { display: none; }
  .items-list { gap: 10px; }
  .item-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; grid-template-areas: "desc desc del" "qty rate rate" "amt amt amt"; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); gap: 8px; }
  .item-row .c-desc { grid-area: desc; }
  .item-row .c-qty { grid-area: qty; }
  .item-row .c-rate { grid-area: rate; }
  .item-row .item-amount { grid-area: amt; display: flex; justify-content: space-between; padding: 4px 2px 0; border-top: 1px dashed var(--border); }
  .item-row .c-del { grid-area: del; }
  .item-row .m-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
  .item-row .item-amount .m-label { margin: 0; align-self: center; }
}

.totals { margin-left: auto; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; }
.totals .row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.totals .row.grand { padding-top: 12px; border-top: 1px solid var(--border); font-size: 20px; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; }
.tax-line { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tax-line .input-suffix { width: 130px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 640px) { .split { grid-template-columns: minmax(0, 1fr); } .totals { max-width: none; } }

.quick-dates { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.quick-dates button { height: 26px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-size: 12px; font-weight: 650; color: var(--ink-2); cursor: pointer; }
.quick-dates button:hover { border-color: var(--primary); color: var(--primary-text); }

/* Combobox (client search) */
.combo { position: relative; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 50; max-height: 280px; overflow-y: auto; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
.combo-item { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: none; text-align: left; cursor: pointer; }
.combo-item:hover, .combo-item.active { background: var(--surface-3); }
.combo-item strong { display: block; font-size: 14px; }
.combo-item span { font-size: 12px; color: var(--muted); }
.combo-empty { padding: 12px; font-size: 13px; color: var(--muted); }

/* ---------- Invoice view page ---------- */
.view-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.view-side { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 16px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 14px; }
.kv:first-child { border-top: 0; padding-top: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) {
  .view-grid { grid-template-columns: minmax(0, 1fr); }
  .view-side { position: static; order: -1; }
}

/* ---------- Client & business cards ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.entity { display: flex; flex-direction: column; gap: 14px; padding: 20px; transition: border-color .15s, box-shadow .15s, transform .15s; }
.entity:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.entity-top { display: flex; gap: 12px; align-items: flex-start; }
.entity-top .grow { flex: 1; min-width: 0; }
.entity-top h3 { font-size: 16px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-top p { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-logo { width: 56px; height: 56px; border-radius: 14px; border: 1px solid var(--border); background: #fff; display: grid; place-items: center; padding: 6px; flex: none; }
.entity-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.entity-logo.initials { background: var(--primary-soft); color: var(--primary-text); font-weight: 800; font-size: 18px; border: 0; }
.entity-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.entity-stats div { min-width: 0; }
.entity-stats small { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.entity-stats strong { display: block; font-size: 14px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-actions { display: flex; gap: 8px; margin-top: auto; }
.entity-actions .btn:first-child { flex: 1; }
.entity-lines { font-size: 13px; color: var(--ink-2); white-space: pre-line; }

/* ---------- Taxes ---------- */
.tax-hero { display: grid; grid-template-columns: minmax(0, 1.2fr) repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .tax-hero { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.quarters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .quarters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .quarters { grid-template-columns: minmax(0, 1fr); } }
.quarter { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.quarter.current { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.quarter-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.quarter-top h3 { font-size: 18px; font-weight: 800; }
.quarter-top p { font-size: 12px; color: var(--muted); }
.quarter .big { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.quarter .rows .kv { padding: 7px 0; font-size: 13px; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 99px; background: var(--success); transition: width .4s; }
:root[data-theme="dark"] .progress i { background: #10B981; }
.disclaimer { font-size: 12px; color: var(--muted); line-height: 1.55; }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.settings-nav { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 600; font-size: 14px; text-decoration: none; }
.settings-nav a:hover { background: var(--surface-3); }
@media (max-width: 960px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } .settings-nav { display: none; } }
.theme-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.theme-pick button { padding: 12px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface-2); cursor: pointer; font-weight: 650; font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.theme-pick button.active { border-color: var(--primary); }
.theme-pick .sw { width: 100%; height: 44px; border-radius: 9px; border: 1px solid var(--border); }

/* ---------- Guest mode ---------- */
.guest-bar {
  position: sticky; top: 0; z-index: 41; display: flex; align-items: center; gap: 12px; padding: 10px 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.guest-bar .spacer { flex: 1; }
.guest-note { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 16px; background: linear-gradient(120deg, var(--primary-soft), color-mix(in srgb, var(--accent) 10%, transparent)); border: 1px solid var(--border); }
.guest-note .grow { flex: 1; min-width: 0; }
.guest-note strong { display: block; font-size: 14px; }
.guest-note span { font-size: 13px; color: var(--ink-2); }
@media (max-width: 640px) {
  .guest-bar { padding: 8px 12px; gap: 6px; }
  .guest-bar .brand .brand-mark { width: 30px; height: 30px; }
  .guest-bar nav { margin-left: 0 !important; }
  .guest-bar .hide-sm { display: none; }
  .guest-note { flex-direction: column; align-items: stretch; text-align: left; }
}
body.guest .editor-bar { top: 57px; }

/* ---------- Ads (guest only) ---------- */
.ad-slot { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--border-strong); }
.ad-slot::before { content: 'Advertisement'; position: absolute; top: 6px; left: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.ad-slot ins { display: block; width: 100%; }
.ad-slot.filled { background: transparent; border-color: transparent; }
.ad-banner { min-height: 100px; }
.ad-rect { min-height: 260px; }
.ad-side { min-height: 280px; }
@media (max-width: 1180px) { .ad-side { display: none; } }

/* ---------- Misc ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary-text); font-weight: 650; cursor: pointer; font-size: 14px; }
.link-btn:hover { text-decoration: underline; }
.dropzone-over { outline: 3px dashed var(--primary); outline-offset: 4px; }
.pdf-stage { position: fixed; left: 0; top: 0; width: 800px; z-index: -1; pointer-events: none; }
@media print { .shell > :not(.main), .editor-bar, .editor-form { display: none !important; } }
