/* =========================================================
   Trivero CRM — Design Prototype System
   Brand: Royal Indigo #4263F5 · Electric Sky #2DA9F8
   Product register: dense, fast, trustworthy.
   ========================================================= */

:root {
  --font-head: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Surfaces & text (light) */
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --surface-3: #E9EEF5;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-muted: #64748B;
  --text-2: #475569;      /* small text on tinted surfaces */
  --text-faint: #64748B;

  /* Brand */
  --primary: #4263F5;
  --primary-hover: #3151E0;
  --primary-soft: #EEF1FE;
  --primary-ink: #2E44C9;  /* text/icon on primary-soft */
  --primary-contrast: #FFFFFF;
  --secondary: #1E293B;
  --accent: #2DA9F8;

  /* Semantic */
  --success: #10B981; --success-soft: #E7F8F1; --success-ink: #047857;
  --warning: #F59E0B; --warning-soft: #FEF4E2; --warning-ink: #B45309;
  --error: #EF4444;   --error-soft: #FDECEC;   --error-ink: #B42318;
  --info: #2DA9F8;     --info-soft: #E6F5FE;    --info-ink: #0369A1;

  /* Pipeline stages */
  --stage-prospected: #64748B;
  --stage-pitched: #2DA9F8;
  --stage-approved: #4263F5;
  --stage-writing: #8B5CF6;
  --stage-submitted: #F59E0B;
  --stage-live: #10B981;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 10px 30px rgba(15,23,42,.12);

  --sidebar-w: 256px;
  --topbar-h: 64px;
}

[data-theme="dark"] {
  --bg: #0B0F19;
  --surface: #111827;
  --surface-2: #0F1626;
  --surface-3: #1A2333;
  --border: #1E293B;
  --border-strong: #334155;
  --text: #F8FAFC;
  --text-muted: #94A3B8;
  --text-2: #CBD5E1;
  --text-faint: #94A3B8;
  --primary-soft: #1B2550;
  --primary-ink: #A7B4FF;
  --secondary: #1E293B;
  --success-soft: #0C2A22; --success-ink: #6EE7B7;
  --warning-soft: #2B2110; --warning-ink: #FBBF24;
  --error-soft: #2C1618;   --error-ink: #FCA5A5;
  --info-soft: #0E2436;    --info-ink: #7DD3FC;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  --shadow: 0 1px 3px rgba(0,0,0,.45);
  --shadow-md: 0 12px 34px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
img { display: block; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand-mark { width: 28px; height: 26px; flex: 0 0 auto; }
.brand-name { font-family: var(--font-head); font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.brand-name sup { color: var(--text-faint); font-size: 9px; font-weight: 600; letter-spacing: .1em; margin-left: 4px; }

.nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.nav-group-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-faint); padding: 16px 12px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; font-size: 13.5px;
  margin-bottom: 2px;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 auto; opacity: .85; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.nav-item .count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2);
  padding: 1px 7px; border-radius: 999px;
}
.nav-item.active .count { background: var(--primary); color: #fff; }

.sidebar-foot {
  border-top: 1px solid var(--border); padding: 12px; flex: 0 0 auto;
}
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); }
.user-chip:hover { background: var(--surface-2); }
.user-meta { min-width: 0; }
.user-meta .nm { font-weight: 600; font-size: 13px; }
.user-meta .rl { font-size: 11.5px; color: var(--text-muted); }

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

.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
}
.icon-btn {
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  border-radius: var(--radius-sm); position: relative;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--error); border: 1.5px solid var(--surface); }

.search {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px; width: 340px; max-width: 42vw;
  color: var(--text-2);
}
.search svg { width: 16px; height: 16px; }
.search input { border: 0; background: transparent; outline: none; color: var(--text); width: 100%; font-size: 13.5px; }
.search kbd { font-family: var(--font-body); font-size: 11px; color: var(--text-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }
.topbar .spacer { flex: 1; }

.content { padding: 26px 28px 64px; max-width: 1440px; width: 100%; }

/* Page header */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .titles { min-width: 0; }
.page-head h1 { font-size: 22px; font-weight: 800; }
.page-head p { margin: 4px 0 0; color: var(--text-muted); font-size: 13.5px; }
.page-head .actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.crumbs { display: flex; gap: 7px; align-items: center; font-size: 12px; color: var(--text-faint); margin-bottom: 8px; }
.crumbs a:hover { color: var(--primary-hover); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: 13.5px; font-weight: 600;
  background: var(--surface); color: var(--text); white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: var(--primary-contrast); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { border-color: var(--border-strong); background: var(--surface); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn-danger { background: #DC2626; color: #fff; }
.btn-block { width: 100%; }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge .g { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success { background: var(--success-soft); color: var(--success-ink); }
.badge.warning { background: var(--warning-soft); color: var(--warning-ink); }
.badge.error   { background: var(--error-soft); color: var(--error-ink); }
.badge.info    { background: var(--info-soft); color: var(--info-ink); }
.badge.primary { background: var(--primary-soft); color: var(--primary-ink); }

/* stage badges */
.badge[data-stage="prospected"] { background: color-mix(in srgb, var(--stage-prospected) 14%, transparent); color: var(--stage-prospected); }
.badge[data-stage="pitched"]    { background: color-mix(in srgb, var(--stage-pitched) 14%, transparent); color: var(--info-ink); }
.badge[data-stage="approved"]   { background: var(--primary-soft); color: var(--primary-ink); }
.badge[data-stage="writing"]    { background: color-mix(in srgb, var(--stage-writing) 14%, transparent); color: #7C3AED; }
.badge[data-stage="submitted"]  { background: var(--warning-soft); color: var(--warning-ink); }
.badge[data-stage="live"]       { background: var(--success-soft); color: var(--success-ink); }
[data-theme="dark"] .badge[data-stage="prospected"] { color: #CBD5E1; }
[data-theme="dark"] .badge[data-stage="pitched"] { color: #7DD3FC; }
[data-theme="dark"] .badge[data-stage="writing"] { color: #C4B5FD; }
[data-theme="dark"] .badge[data-stage="submitted"] { color: #FBBF24; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px; }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat .label { font-size: 12.5px; color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
.stat .label svg { width: 15px; height: 15px; color: var(--text-faint); }
.stat .val { font-family: var(--font-head); font-size: 27px; font-weight: 800; letter-spacing: -0.02em; margin-top: 8px; }
.stat .delta { font-size: 12px; font-weight: 600; margin-top: 6px; display: inline-flex; align-items: center; gap: 5px; }
.delta.up { color: var(--success-ink); } .delta.down { color: var(--error-ink); }
.stat .spark { margin-top: 10px; }

/* ---------- Table ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-muted); font-weight: 600; font-size: 12.5px; padding: 6px 12px; border-radius: var(--radius-xs); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-2); background: var(--surface-2);
  padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
thead th .th-inner { display: inline-flex; align-items: center; gap: 5px; }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.num { font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--text-muted); }
.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex: 0 0 auto; }
.avatar.sq { border-radius: var(--radius-xs); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions button { width: 30px; height: 30px; border: 0; background: transparent; border-radius: var(--radius-xs); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; }
.row-actions button:hover { background: var(--surface-3); color: var(--text); }
.row-actions svg { width: 16px; height: 16px; }
.check { width: 16px; height: 16px; accent-color: var(--primary); }

.pagination { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.pagination .pages { margin-left: auto; display: flex; gap: 4px; }
.pagination .pages button { min-width: 32px; height: 32px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-xs); color: var(--text-muted); font-weight: 600; font-size: 12.5px; }
.pagination .pages button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .pages button:hover:not(.on) { background: var(--surface-2); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; }
.input, .select, textarea {
  width: 100%; height: 40px; padding: 0 12px; font-size: 13.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 90px; }
.input:focus, .select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input::placeholder { color: var(--text-faint); }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kcol { flex: 0 0 288px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 260px); }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.kcol-head .dot { width: 9px; height: 9px; border-radius: 50%; }
.kcol-head .nm { font-weight: 700; font-size: 13px; }
.kcol-head .cnt { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--text-2); background: var(--surface-3); border-radius: 999px; padding: 1px 8px; }
.kcol-body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; box-shadow: var(--shadow-sm); cursor: grab; }
.kcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.kcard .dom { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.kcard .dom svg { width: 14px; height: 14px; color: var(--text-faint); }
.kcard .anchor { font-size: 12px; color: var(--text-2); margin-top: 6px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-xs); padding: 5px 7px; }
.kcard .metrics { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.metric { font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--surface-2); border-radius: var(--radius-xs); padding: 2px 7px; }
.metric b { color: var(--text); }
.kcard .kfoot { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--border); }
.kcard .kfoot .avatar { width: 24px; height: 24px; font-size: 10px; }
.kcard .kfoot .date { margin-left: auto; font-size: 11px; color: var(--text-faint); }
.kadd { border: 1px dashed var(--border-strong); background: transparent; color: var(--text-muted); border-radius: var(--radius-sm); padding: 9px; font-weight: 600; font-size: 12.5px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.kadd:hover { background: var(--surface); color: var(--primary-hover); border-color: var(--primary); }

/* ---------- Simple charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bars .bar .fill { width: 100%; max-width: 42px; border-radius: 6px 6px 0 0; background: var(--primary); }
.bars .bar .fill.alt { background: var(--accent); }
.bars .bar .lbl { font-size: 11px; color: var(--text-muted); }

.donut-wrap { display: flex; align-items: center; gap: 22px; }
.legend { display: flex; flex-direction: column; gap: 10px; }
.legend .li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend .li .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend .li b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* progress */
.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--primary); }

/* ---------- Lists ---------- */
.feed { display: flex; flex-direction: column; }
.feed .item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.feed .item:last-child { border-bottom: 0; }
.feed .item .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: 0 0 auto; }
.feed .item .txt { font-size: 13px; }
.feed .item .time { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; font-weight: 600; font-size: 13.5px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--primary-hover); border-bottom-color: var(--primary); }

/* ---------- Utilities ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-main { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-16 { margin-bottom: 16px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-weight: 600; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* icons */
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.ic.fill { fill: currentColor; stroke: none; }
.ic.sm { width: 15px; height: 15px; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-side {
  background:
    radial-gradient(1200px 600px at 20% 0%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 55%),
    var(--secondary);
  color: #E2E8F0; padding: 48px; display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.auth-side .logo-lg { width: 150px; filter: drop-shadow(0 8px 24px rgba(0,0,0,.35)); }
.auth-side h2 { color: #fff; font-size: 30px; max-width: 420px; margin-top: auto; letter-spacing: -0.02em; }
.auth-side p { color: #CBD5E1; max-width: 400px; margin-top: 12px; font-size: 14px; }
.auth-side .points { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; }
.auth-side .points .pt { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: #E2E8F0; }
.auth-side .points .pt svg { width: 18px; height: 18px; color: var(--accent); }
.auth-side .foot { margin-top: 32px; font-size: 12px; color: #94A3B8; }
.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--surface); }
.auth-form { width: 100%; max-width: 380px; }
.auth-form .brand { border: 0; padding: 0; height: auto; margin-bottom: 28px; }
.auth-form h1 { font-size: 24px; font-weight: 800; }
.auth-form .lead { color: var(--text-muted); margin: 6px 0 26px; font-size: 13.5px; }
.auth-alt { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-muted); }
.auth-alt a, .link { color: var(--primary-hover); font-weight: 600; }

/* ---------- Portal (client-facing) ---------- */
.portal-top { background: var(--surface); border-bottom: 1px solid var(--border); height: 64px; display: flex; align-items: center; gap: 16px; padding: 0 28px; position: sticky; top: 0; z-index: 20; }
.portal-top .brand { border: 0; height: auto; padding: 0; }
.portal-tabs { display: flex; gap: 4px; margin-left: 20px; }
.portal-tabs a { padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13.5px; color: var(--text-muted); }
.portal-tabs a.on { background: var(--primary-soft); color: var(--primary-ink); }
.portal-main { max-width: 1180px; margin: 0 auto; padding: 28px; }

/* ---------- Modal (static preview) ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-md); width: 100%; max-width: 520px; border: 1px solid var(--border); }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Invoice ---------- */
.invoice { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; box-shadow: var(--shadow-sm); max-width: 860px; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 24px; border-bottom: 2px solid var(--border); }
.inv-head h2 { font-size: 26px; }
.inv-meta { text-align: right; font-size: 13px; }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 24px 0; }
.inv-total-row { display: flex; justify-content: flex-end; }
.inv-totals { width: 280px; }
.inv-totals .tr { display: flex; justify-content: space-between; padding: 8px 0; font-size: 13.5px; }
.inv-totals .tr.total { border-top: 2px solid var(--border); margin-top: 6px; padding-top: 12px; font-size: 17px; font-weight: 800; font-family: var(--font-head); }

/* ---------- Responsive ---------- */
.menu-toggle { display: none; }
.backdrop { display: none; }

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-main { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-md); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 35; }
  .search { width: 200px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 620px) {
  .content { padding: 18px 16px 56px; }
  .stats { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 19px; }
  .search { display: none; }
  .inv-parties { grid-template-columns: 1fr; }
  .invoice { padding: 22px; }
}
