/* Design system ported from POC/billing-mockup.html (the approved mockup). Keep in sync with the mockup. */
/* ==========================================================================
   1.1 DESIGN TOKENS
   ========================================================================== */
:root {
  /* Mundrisoft brand (mundrisoft.com): blue #2070B7 is the primary colour, green #7CC34E the accent. */
  --brand: #2070b7;
  --brand-600: #2a7fcc;
  --brand-700: #185a94;
  --brand-50: #eaf3fb;
  --brand-100: #d3e6f6;
  --accent: #7cc34e;
  --accent-700: #4e8f27;   /* green dark enough for text on white */
  --accent-50: #eff8e8;
  --sidebar-bg: #0f2740;   /* deep navy from the brand blue */

  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --subtle: #9ca3af;

  /* Status colours */
  --draft: #6b7280;   --draft-bg: #f3f4f6;
  --sent: #2070b7;    --sent-bg: #eaf3fb;
  --partial: #b45309; --partial-bg: #fef3c7;
  --paid: #3f8a1f;    --paid-bg: #eaf6e1;
  --overdue: #b91c1c; --overdue-bg: #fee2e2;
  --void: #6b7280;    --void-bg: #f3f4f6;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 20px 40px -12px rgba(16,24,40,.25);
  --sidebar-w: 248px;
  --topbar-h: 60px;
}

/* ==========================================================================
   1.2 BASE
   ========================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; }
a { color: var(--brand-600); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
.mud-button-root:hover, .sb-item:hover, .dd-item:hover, .mud-nav-link:hover, .mud-menu-item:hover { text-decoration: none; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.small { font-size: 12px; }
.tnum, .amt, td.num, .kpi-value { font-variant-numeric: tabular-nums; }
.cur { font-size: 11px; color: var(--subtle); font-weight: 500; letter-spacing: .02em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; gap: 16px; }


.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ==========================================================================
   1.3 APP LAYOUT (sidebar + topbar + main)
   ========================================================================== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--sidebar-bg); color: #d1d5db;
  position: fixed; top: 0; bottom: 0; left: 0; display: flex; flex-direction: column; z-index: 30;
  transition: transform .2s ease;
}
.sb-brand { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,.06); }
.logo-mark {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #2070b7 0%, #2070b7 45%, #7cc34e 100%); font-size: 15px; flex-shrink: 0;
}
.sb-brand .name { font-weight: 600; color: #fff; font-size: 15px; line-height: 1.2; }
.sb-brand .name small { display: block; font-weight: 400; color: #9ca3af; font-size: 11px; }
.sb-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sb-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6b7280; padding: 14px 10px 6px; }
.sb-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #d1d5db; cursor: pointer;
  font-weight: 500; margin-bottom: 2px; user-select: none;
}
.sb-item i { font-size: 18px; color: #9ca3af; }
.sb-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sb-item.active { background: var(--brand); color: #fff; }
.sb-item.active i { color: #fff; }
.sb-item .count { margin-left: auto; font-size: 11px; background: rgba(255,255,255,.12); padding: 1px 7px; border-radius: 10px; }
.sb-item.active .count { background: rgba(255,255,255,.25); }
.sb-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.06); font-size: 12px; color: #6b7280; }

.main-wrap { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.main { padding: 24px; width: 100%; }
.sb-backdrop { display: none; }

/* Page header */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 220px; }
.page-head .titles p { color: var(--muted); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.breadcrumb a { color: var(--muted); }

/* ==========================================================================
   1.4 COMPONENTS
   ========================================================================== */
/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn i { font-size: 16px; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-700); }
.btn.danger { color: var(--overdue); border-color: #fecaca; }
.btn.danger:hover { background: var(--overdue-bg); }
.btn.danger-solid { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--draft-bg); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn[disabled], .btn.locked { opacity: .45; cursor: not-allowed; }
.btn.locked::after { content: "\eecd"; font-family: remixicon; font-size: 12px; } /* lock glyph */
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted);
  display: inline-grid; place-items: center; cursor: pointer; font-size: 18px;
}
.icon-btn:hover { background: var(--draft-bg); color: var(--text); }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }

/* Segmented control */
.seg { display: inline-flex; background: var(--draft-bg); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 500; color: var(--muted);
  padding: 5px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 500; white-space: nowrap; line-height: 18px;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.b-draft { color: var(--draft); background: var(--draft-bg); }
.b-sent { color: var(--sent); background: var(--sent-bg); }
.b-partial { color: var(--partial); background: var(--partial-bg); }
.b-paid { color: var(--paid); background: var(--paid-bg); }
.b-overdue { color: var(--overdue); background: var(--overdue-bg); }
.b-void { color: var(--void); background: var(--void-bg); text-decoration: line-through; }
.b-active { color: var(--paid); background: var(--paid-bg); }
.b-paused { color: var(--partial); background: var(--partial-bg); }
.b-inactive { color: var(--draft); background: var(--draft-bg); }
.b-pending { color: var(--draft); background: var(--draft-bg); }
.b-due { color: #c2410c; background: #ffedd5; }
.b-upcoming { color: var(--sent); background: var(--sent-bg); }
.b-postponed { color: #b45309; background: #fef3c7; }
.b-ended { color: var(--draft); background: var(--draft-bg); }
.progress.stacked { display: flex; }
.progress.stacked > span { border-radius: 0; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin: 0 4px 0 8px; }
.dash-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
@media (max-width: 1100px) { .dash-3 { grid-template-columns: 1fr; } }
.b-invoiced { color: var(--sent); background: var(--sent-bg); }
.b-invited { color: var(--sent); background: var(--sent-bg); }
.role-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; text-transform: uppercase; letter-spacing: .03em; }
.role-admin { background: #ede9fe; color: #6d28d9; }
.role-manager { background: #e0f2fe; color: #0369a1; }
.role-accounts { background: #fef3c7; color: #92400e; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; font-size: 12px;
  background: var(--draft-bg); color: var(--text-2); white-space: nowrap; font-weight: 500;
}
.chip .dot { width: 8px; height: 8px; border-radius: 2px; }
.cur-tag { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: var(--brand-50); color: var(--brand-700); letter-spacing: .03em; }

/* 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: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { flex: 1; }
.card-head .sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { padding: 16px 18px; }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-label i { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 16px; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 10px; letter-spacing: -0.02em; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-lines { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.kpi-lines div { display: flex; justify-content: space-between; font-size: 13px; font-variant-numeric: tabular-nums; }
.kpi-lines div span:first-child { color: var(--muted); font-size: 11px; font-weight: 600; }
.ic-indigo { background: var(--brand-50); color: var(--brand); }
.ic-blue { background: var(--sent-bg); color: var(--sent); }
.ic-green { background: var(--paid-bg); color: var(--paid); }
.ic-amber { background: var(--partial-bg); color: var(--partial); }
.ic-red { background: var(--overdue-bg); color: var(--overdue); }

/* Progress */
.progress { height: 6px; background: var(--draft-bg); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--paid); border-radius: 99px; }
.progress.brand > span { background: var(--brand-600); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab {
  padding: 10px 14px; border: 0; background: transparent; font: inherit; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; display: flex; gap: 6px; align-items: center;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.tab .count { font-size: 11px; background: var(--draft-bg); color: var(--muted); padding: 0 7px; border-radius: 10px; }
.tab.on .count { background: var(--brand-50); color: var(--brand); }

/* Tables */
.table-card { overflow: hidden; }
.toolbar { display: flex; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search { position: relative; flex: 0 1 280px; min-width: 180px; }
.search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--subtle); }
.search input { padding-left: 32px !important; }
.bulkbar { display: flex; align-items: center; gap: 8px; background: var(--brand-50); color: var(--brand-700); padding: 4px 6px 4px 12px; border-radius: 8px; font-weight: 500; font-size: 13px; }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--text); }
.table th .sort-ic { font-size: 13px; vertical-align: -2px; opacity: .5; }
.table th.sorted .sort-ic { opacity: 1; color: var(--brand); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: #fafbff; }
.table tbody tr.selected td { background: var(--brand-50); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .chk { width: 36px; padding-right: 0; }
.table .actions-cell { text-align: right; white-space: nowrap; }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border); }
.table-foot { padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.table.compact td { padding: 9px 14px; }
.cell-main { font-weight: 500; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--muted); }


/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .col-2 { grid-column: 1 / -1; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.field label.btn { display: inline-flex; margin: 0; color: var(--text-2); }
.field label.dropzone, .field label.row { display: flex; }
.field label.dropzone { flex-direction: column; align-items: center; }
.field .req { color: var(--overdue); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .err { display: none; font-size: 12px; color: var(--overdue); margin-top: 4px; }
.field.invalid .err { display: block; }
.field.invalid .input, .field.invalid input, .field.invalid select, .field.invalid textarea { border-color: #f87171 !important; box-shadow: 0 0 0 3px rgba(248,113,113,.15); }
/* (global input/select/textarea rules omitted — MudBlazor styles its own inputs; see app.css) */
.input-group { display: flex; }
.input-group > :first-child { border-radius: 8px 0 0 8px; }
.input-group > :last-child { border-radius: 0 8px 8px 0; margin-left: -1px; }
.input-group .addon { display: grid; place-items: center; padding: 0 10px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--muted); font-size: 13px; }
.form-section { margin-bottom: 22px; }
.form-section-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; display: flex; gap: 8px; align-items: center; }
.toggle { position: relative; width: 36px; height: 20px; display: inline-block; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 99px; cursor: pointer; transition: .15s; }
.toggle span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: var(--shadow-sm); }
.toggle input:checked + span { background: var(--brand-600); }
.toggle input:checked + span::before { transform: translateX(16px); }
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted);
  cursor: pointer; background: var(--surface-2); transition: border-color .12s, background .12s;
}
.dropzone:hover { border-color: var(--brand-600); background: var(--brand-50); }
.dropzone i { font-size: 24px; color: var(--brand-600); display: block; margin-bottom: 4px; }
.logo-upload { display: flex; align-items: center; gap: 14px; }
.logo-preview { width: 64px; height: 64px; border-radius: 12px; border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; background: var(--surface-2); }
.logo-preview img { max-width: 100%; max-height: 100%; }
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.radio-card { border: 1px solid var(--border-strong); border-radius: 10px; padding: 12px; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; }
.radio-card.on { border-color: var(--brand-600); background: var(--brand-50); box-shadow: 0 0 0 1px var(--brand-600); }
.radio-card i { font-size: 20px; color: var(--brand); }
.radio-card b { display: block; font-weight: 600; }
.radio-card small { color: var(--muted); font-size: 12px; }

/* Overlays: modal + drawer */
.overlay { position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 100; display: flex; animation: fade .15s ease; }
.overlay.center { align-items: center; justify-content: center; padding: 24px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: calc(100vh - 48px); display: flex; flex-direction: column; animation: pop .18s ease; }
.modal.lg { max-width: 760px; }
.modal.sm { max-width: 420px; }
.modal-head, .drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3, .drawer-head h3 { flex: 1; font-size: 16px; }
.modal-body, .drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot, .drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 14px 14px; }
.drawer { margin-left: auto; height: 100%; width: 100%; max-width: 560px; background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s ease; }
.drawer.wide { max-width: 760px; }
.drawer-foot { border-radius: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }

/* Toasts */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #111827; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: 420px; animation: pop .2s ease; font-size: 13px;
}
.toast i { font-size: 18px; }
.toast.success i { color: #4ade80; } .toast.error i { color: #f87171; } .toast.info i { color: #93c5fd; }

/* Dropdown menus */
.dd { position: relative; }
.dd-menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 220px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; display: none;
}
.dd.open .dd-menu { display: block; }
.dd-menu.left { left: 0; right: auto; }
.dd-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-size: 13px; }
.dd-item:hover { background: var(--surface-2); }
.dd-item.on { background: var(--brand-50); color: var(--brand-700); font-weight: 500; }
.dd-item i { font-size: 16px; color: var(--muted); }
.dd-item.danger { color: var(--overdue); } .dd-item.danger i { color: var(--overdue); }
.dd-item.disabled { opacity: .45; pointer-events: none; }
.dd-sep { height: 1px; background: var(--border); margin: 6px 0; }
.dd-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--subtle); padding: 6px 10px 4px; }

/* Topbar parts */
.acct-switch { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); cursor: pointer; font: inherit; font-weight: 500; color: var(--text); }
.acct-switch .dot, .dd-item .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.gsearch { position: relative; flex: 1; max-width: 420px; }
.gsearch > i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--subtle); }
.gsearch input { padding-left: 34px; background: var(--surface-2); }
.gsearch kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--subtle); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; background: #fff; font-family: inherit; }
.gs-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; max-height: 420px; overflow-y: auto; }
.gs-results .dd-item .meta { margin-left: auto; font-size: 12px; color: var(--muted); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.user-chip:hover { background: var(--surface-2); border-color: var(--border); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 12px; color: #fff; flex-shrink: 0; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; border-radius: 14px; }
.user-chip .who { line-height: 1.2; }
.user-chip .who b { display: block; font-size: 13px; font-weight: 600; }
.mobile-only { display: none; }

/* Lists / feed */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; }
.feed { position: relative; padding: 6px 18px 12px; }
.feed-item { display: flex; gap: 12px; padding: 10px 0; position: relative; }
.feed-item:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 38px; bottom: -4px; width: 2px; background: var(--border); }
.feed-ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; flex-shrink: 0; }
.feed-item .txt { font-size: 13px; color: var(--text-2); }
.feed-item .txt b { color: var(--text); font-weight: 600; }
.feed-item .when { font-size: 12px; color: var(--subtle); margin-top: 2px; }

/* Empty state */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty i { font-size: 40px; color: var(--border-strong); display: block; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* Banners */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 13px; border: 1px solid; }
.banner i { font-size: 18px; margin-top: 1px; }
.banner.info { background: var(--sent-bg); border-color: #bfdbfe; color: #1e40af; }
.banner.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.banner.neutral { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.banner .grow { flex: 1; }

/* Key/value */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); font-weight: 500; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
.stat-row > div { padding: 14px 18px; border-right: 1px solid var(--border); }
.stat-row > div:last-child { border-right: 0; }
.stat-row .lbl { font-size: 12px; color: var(--muted); }
.stat-row .val { font-size: 18px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.attach { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.attach i { color: #dc2626; font-size: 18px; }

/* ==========================================================================
   1.5 SCREEN-SPECIFIC
   ========================================================================== */
/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--surface); }
.login-art { background: linear-gradient(150deg, #0f2740 0%, #2070b7 60%, #3f8fcf 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.login-art::after { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(255,255,255,.06); right: -120px; bottom: -120px; }
.login-art h2 { font-size: 30px; line-height: 1.2; margin-top: auto; max-width: 440px; font-weight: 700; }
.login-art p { color: #d3e6f6; margin-top: 12px; max-width: 420px; }
.login-art ul { list-style: none; padding: 0; margin: 28px 0 auto; display: grid; gap: 12px; }
.login-art li { display: flex; gap: 10px; align-items: center; color: #eaf3fb; }
.login-art li i { width: 28px; height: 28px; border-radius: 8px; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-box { width: 100%; max-width: 380px; }
.login-box h1 { font-size: 24px; margin-top: 28px; }
.demo-roles { margin-top: 22px; padding: 14px; border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface-2); }
.demo-roles .seg { width: 100%; margin-top: 8px; } .demo-roles .seg button { flex: 1; }

/* Dashboard */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 16px; }
.acct-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
.acct-card { padding: 16px 18px; border-right: 1px solid var(--border); }
.acct-card:last-child { border-right: 0; }
.acct-card .head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.acct-logo { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.acct-logo.lg { width: 48px; height: 48px; border-radius: 12px; font-size: 17px; }
.acct-card .line { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.acct-card .line > span:first-child { color: var(--muted); }
.acct-card .line > :last-child { text-align: right; }

/* Invoice editor */
.editor { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.editor .preview-pane { position: sticky; top: calc(var(--topbar-h) + 16px); }
.preview-scroll { max-height: calc(100vh - var(--topbar-h) - 110px); overflow: auto; background: #e5e7eb; padding: 16px; border-radius: 0 0 var(--radius) var(--radius); }
.preview-scale { transform-origin: top left; }
.lines-table td { padding: 6px 6px; vertical-align: top; border-bottom: 1px solid var(--border); }
.lines-table th { padding: 8px 6px; }
.lines-table input, .lines-table select { height: 34px; }
.lines-table .desc { margin-top: 4px; height: 30px; font-size: 12px; width: 100%; }
.totals { margin-left: auto; width: 100%; max-width: 320px; font-size: 13px; }
.totals .t-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; font-variant-numeric: tabular-nums; }
.totals .t-row.grand { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 16px; font-weight: 700; }
.sticky-foot { position: sticky; bottom: 0; background: rgba(245,246,250,.92); backdrop-filter: blur(6px); padding: 12px 0; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--border); margin-top: 16px; z-index: 5; }

/* Invoice detail */
.inv-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.doc-frame { background: #e5e7eb; border-radius: var(--radius); padding: 24px; overflow-x: auto; }
.status-ribbon { font-size: 12px; }

/* Templates gallery */
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tpl-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.tpl-card:hover { box-shadow: var(--shadow); }
.tpl-card.on { border-color: var(--brand-600); box-shadow: 0 0 0 2px var(--brand-600); }
.tpl-thumb { height: 230px; background: #e5e7eb; overflow: hidden; position: relative; padding: 14px; }
.tpl-thumb .preview-scale { position: absolute; top: 14px; left: 50%; }
.tpl-card .meta { padding: 12px 14px; display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch { width: 28px; height: 28px; border-radius: 8px; cursor: pointer; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }

/* Masters */
.masters-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.masters-nav { padding: 8px; position: sticky; top: calc(var(--topbar-h) + 16px); }
.mn-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); cursor: pointer; font-weight: 500; font-size: 13px; }
.mn-item:hover { background: var(--surface-2); text-decoration: none; }
.mn-item.on { background: var(--brand-50); color: var(--brand-700); }
.mn-item i { font-size: 17px; color: var(--muted); }
.mn-item.on i { color: var(--brand); }
.mn-item .grow { flex: 1; }
.mn-item .count { font-size: 11px; background: var(--draft-bg); color: var(--muted); padding: 0 7px; border-radius: 10px; }
@media (max-width: 960px) { .masters-layout { grid-template-columns: 1fr; } .masters-nav { position: static; } }

/* Permissions matrix */
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix .yes { color: var(--paid); font-size: 18px; }
.matrix .no { color: var(--border-strong); font-size: 18px; }
.matrix .grp td { background: var(--surface-2); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; }

/* Milestones */
.ms-table td { vertical-align: middle; }
.alloc { font-size: 12px; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); display: flex; justify-content: space-between; margin-top: 8px; }
.alloc.bad { background: var(--overdue-bg); color: var(--overdue); }
.alloc.good { background: var(--paid-bg); color: var(--paid); }

/* Denied */
.denied { text-align: center; padding: 80px 20px; }
.denied i { font-size: 48px; color: var(--border-strong); }

/* ==========================================================================
   1.6 RESPONSIVE (desktop-first, down to tablet)
   ========================================================================== */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .inv-layout { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .dash-grid, .editor { grid-template-columns: 1fr; }
  .editor .preview-pane { position: static; }
  .tpl-grid { grid-template-columns: repeat(2, 1fr); }
  .user-chip .who { display: none; }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  body.sb-open .sidebar { transform: none; }
  body.sb-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
  .main-wrap { margin-left: 0; }
  .mobile-only { display: inline-grid; }
  .topbar { padding: 0 14px; }
  .main { padding: 16px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .acct-cards { grid-template-columns: 1fr; }
  .acct-card { border-right: 0; border-bottom: 1px solid var(--border); }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .acct-switch .lbl { display: none; }
  .gsearch kbd { display: none; }
}
@media (max-width: 640px) {
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr; }
  .tpl-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr; }
  .stat-row > div { border-right: 0; border-bottom: 1px solid var(--border); }
}
