/* ==========================================================================
   AlgorMetrics Commercial Hub — design system
   Same brand as the public website: navy #0A2F5A + teal #0BA88F,
   Space Grotesk headings, DM Sans body. Navy sidebar, light work area.
   ========================================================================== */

:root {
  /* Brand */
  --navy-950: #041427;
  --navy-900: #061E3B;
  --navy-800: #0A2F5A;
  --navy-700: #123E70;
  --navy-600: #164275;
  --teal: #0BA88F;
  --teal-strong: #08907B;
  --teal-ink: #067A68;

  /* Status */
  --green: #0E9F6E;   --green-bg: #E7F6EF;
  --blue: #2563EB;    --blue-bg: #EAF1FE;
  --amber: #B45309;   --amber-bg: #FEF3E2;
  --violet: #6D28D9;  --violet-bg: #F1EBFD;
  --rose: #E11D48;    --rose-bg: #FDECEF;

  /* Surfaces & text */
  --bg: #F4F7FA;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --line: #E3E9F0;
  --line-strong: #CFD8E3;
  --ink: #0B1A2E;
  --ink-2: #334155;
  --muted: #5B6B80;

  /* Legacy token names still referenced by view templates */
  --surface-bg: var(--bg);
  --surface-card: var(--surface);
  --surface-card-hover: var(--surface-2);
  --surface-input: var(--surface);
  --surface-border: var(--line);
  --surface-border-subtle: var(--line);
  --text-primary: var(--ink);
  --text-secondary: var(--ink-2);
  --text-muted: var(--muted);
  --text-highlight: var(--navy-900);
  --teal-500: var(--teal-ink);
  --teal-600: var(--teal);
  --teal-700: var(--teal-strong);
  --teal-subtle: #E6F6F2;
  --teal-glow: rgba(11, 168, 143, 0.2);
  --blue-500: var(--blue);
  --blue-600: var(--blue);
  --blue-subtle: var(--blue-bg);
  --purple-500: var(--violet);
  --purple-subtle: var(--violet-bg);
  --amber-500: var(--amber);
  --amber-subtle: var(--amber-bg);
  --rose-500: var(--rose);
  --rose-subtle: var(--rose-bg);
  --emerald-500: var(--green);
  --emerald-subtle: var(--green-bg);

  /* Type */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'DM Sans', system-ui, sans-serif; /* numbers use tabular figures instead of a code font */

  /* Shape & depth */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(11, 26, 46, 0.05);
  --shadow-md: 0 1px 2px rgba(11, 26, 46, 0.04), 0 4px 16px -6px rgba(11, 26, 46, 0.08);
  --shadow-lg: 0 24px 60px -20px rgba(4, 20, 39, 0.35);
  --sidebar-width: 256px;
  --header-h: 72px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
h1, h2, h3, .card-title, .kpi-value, .brand-name { font-family: var(--font-display); letter-spacing: -0.01em; }
a { color: inherit; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.ic { flex-shrink: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ==========================================================================
   Shell
   ========================================================================== */
.app-container { display: flex; min-height: 100vh; }

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--navy-900);
  color: #C9D5E3;
  z-index: 50;
  transition: transform 0.3s var(--ease);
}
.sidebar-header { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; }
.brand-emblem {
  width: 40px; height: 40px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 10px; background: #FFFFFF;
}
.brand-emblem img { width: 28px; height: 30px; object-fit: contain; }
.brand-info { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 17px; font-weight: 700; color: #FFFFFF; }
.brand-name span { color: #5FE0C8; }
.brand-subtitle { font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: #8EA3BC; margin-top: 3px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav-section-title { padding: 18px 12px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #6F86A3; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 40px; padding: 8px 12px;
  border-radius: var(--radius-md);
  color: #C9D5E3; text-decoration: none;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #FFFFFF; }
.nav-item.active { background: rgba(95, 224, 200, 0.12); color: #FFFFFF; font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--teal); }
.nav-item.active svg { color: #5FE0C8; opacity: 1; }
.nav-item .badge {
  margin-left: auto; min-width: 22px; padding: 1px 7px;
  border-radius: var(--radius-full); text-align: center;
  font-size: 11.5px; font-weight: 600;
  background: rgba(255, 255, 255, 0.08); color: #C9D5E3;
}
.nav-item.active .badge { background: var(--teal); color: #FFFFFF; }

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.sidebar-status-box { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-md); background: rgba(255, 255, 255, 0.04); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #34D399; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); flex-shrink: 0; }
.status-text { font-size: 12px; color: #8EA3BC; line-height: 1.35; min-width: 0; }
.status-text strong { display: block; color: #E3EBF5; font-weight: 600; }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 4px 2px; font-size: 12px; color: #8EA3BC; min-width: 0; }
.sidebar-user .avatar { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; background: var(--teal); color: #FFFFFF; font: 700 12px var(--font-display); }
.sidebar-user .who { min-width: 0; display: grid; }
.sidebar-user strong { color: #E3EBF5; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Main column */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: var(--header-h);
  padding: 14px 32px;
  background: rgba(244, 247, 250, 0.86);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.view-title-group { min-width: 0; }
.view-title-group .crumb { font-size: 12px; color: var(--muted); font-weight: 500; }
.view-title-group h1 { font-size: 20px; font-weight: 700; color: var(--navy-900); line-height: 1.25; }
.view-title-group p { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.app-header .menu-toggle { display: none; }

.currency-picker { display: flex; padding: 3px; gap: 2px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--line); }
.currency-btn { border: 0; background: transparent; padding: 6px 10px; border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; transition: background-color 0.15s, color 0.15s; }
.currency-btn:hover { color: var(--ink); }
.currency-btn.active { background: var(--navy-800); color: #FFFFFF; }

.view-viewport { flex: 1; padding: 28px 32px 48px; max-width: 1440px; width: 100%; }
.view-panel { display: none; }
.view-panel.active { display: block; animation: viewIn 0.25s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 8px 14px;
  border-radius: var(--radius-md); border: 1px solid transparent;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 600; line-height: 1.2;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--navy-800); color: #FFFFFF; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--navy-700); }
.btn-accent { background: var(--teal-strong); color: #FFFFFF; }
.btn-accent:hover { background: var(--teal-ink); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: #B5C2D1; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(11, 26, 46, 0.05); color: var(--ink); }
.btn-blue { background: var(--teal-strong); color: #FFFFFF; }
.btn-blue:hover { background: var(--teal-ink); }
.btn-outline-teal { background: var(--surface); color: var(--teal-ink); border-color: #9ED9CC; }
.btn-outline-teal:hover { background: var(--teal-subtle); }
.btn-danger { background: var(--surface); color: var(--rose); border-color: #F5C2CD; }
.btn-danger:hover { background: var(--rose-bg); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }
.btn-icon-only { width: 32px; min-height: 32px; padding: 0; border-radius: var(--radius-sm); }
.btn-icon-only.danger { color: var(--rose); }
.btn-icon-only.danger:hover { background: var(--rose-bg); border-color: #F5C2CD; }

/* ==========================================================================
   Cards, sections, page headers
   ========================================================================== */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-md);
}
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 15.5px; font-weight: 600; color: var(--navy-900); }
.card-title .ic { color: var(--teal-ink); }
.card-subtitle { margin-top: 2px; font-size: 13px; color: var(--muted); font-weight: 400; }
.card.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-header { padding: 20px 24px 0; }
.card-footer { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

.section-gap { margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.grid-dash { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; margin-bottom: 20px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar .spacer { flex: 1; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); line-height: 1.55; }
.callout .ic { color: var(--teal-ink); margin-top: 2px; }
.callout code { font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; font-size: 12px; background: #EEF2F6; padding: 1px 5px; border-radius: 4px; }
.callout.warn { background: var(--rose-bg); border-color: #F5C2CD; }
.callout.warn .ic { color: var(--rose); }
.danger-card { border-color: #F5C2CD; }
.danger-card .card-title, .danger-card .card-title .ic { color: var(--rose); }

/* Segmented tabs (admin panel, ledger filters) */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin-bottom: 20px; width: fit-content; max-width: 100%; border-radius: 12px; background: #E9EEF4; }
.tab { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background-color 0.15s, color 0.15s, box-shadow 0.15s; }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--surface); color: var(--navy-900); box-shadow: var(--shadow-sm); }
.tab .count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: rgba(11, 26, 46, 0.07); font-size: 11.5px; text-align: center; }
.tab.active .count { background: var(--teal-subtle); color: var(--teal-ink); }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-full); font-size: 11.5px; font-weight: 600; background: #EEF2F6; color: var(--ink-2); }
.badge-status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-downloaded { background: var(--green-bg); color: var(--green); }
.badge-issued { background: var(--blue-bg); color: var(--blue); }
.badge-draft { background: var(--amber-bg); color: var(--amber); }
.badge-accepted { background: var(--violet-bg); color: var(--violet); }
.badge-private { background: var(--navy-800); color: #FFFFFF; }

/* ==========================================================================
   KPIs
   ========================================================================== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-card { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-title { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi-icon-box { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--teal-subtle); color: var(--teal-ink); }
.kpi-icon-box.blue { background: var(--blue-bg); color: var(--blue); }
.kpi-icon-box.green { background: var(--green-bg); color: var(--green); }
.kpi-icon-box.navy { background: #E8EEF6; color: var(--navy-800); }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--navy-900); line-height: 1.2; }
.kpi-value small { font-size: 15px; font-weight: 500; color: var(--muted); }
.kpi-sub { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi-sub .highlight-green, .trend-up { color: var(--green); font-weight: 600; }

/* Charts */
.chart-box { height: 240px; position: relative; }
.chart-bar rect { transition: opacity 0.15s; }
.chart-bar:hover rect { opacity: 0.8; }
.donut-wrap { display: flex; align-items: center; justify-content: space-around; gap: 16px; padding: 8px 0 4px; }
.donut { position: relative; width: 132px; height: 132px; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center strong { font: 700 24px var(--font-display); color: var(--navy-900); }
.donut-center span { font-size: 11px; color: var(--muted); font-weight: 500; }
.legend { display: grid; gap: 10px; font-size: 13px; }
.legend-row { display: flex; align-items: center; gap: 10px; }
.legend-row .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend-row .lbl { color: var(--ink-2); min-width: 84px; }
.legend-row strong { color: var(--navy-900); font-weight: 600; }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  padding: 10px 12px; text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.data-table td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table th:first-child, .data-table td:first-child { padding-left: 20px; }
.data-table th:last-child, .data-table td:last-child { padding-right: 20px; }
.data-table tbody tr { transition: background-color 0.12s; }
.data-table tbody tr:hover { background: #F9FBFD; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .right { text-align: right; }
.data-table .center { text-align: center; }
.data-table .nowrap { white-space: nowrap; }
.cell-ref { font-weight: 600; color: var(--teal-ink); white-space: nowrap; }
.cell-ref a { text-decoration: none; }
.cell-ref a:hover { text-decoration: underline; }
.cell-primary { font-weight: 600; color: var(--ink); }
.cell-secondary { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.cell-amount { font-weight: 600; color: var(--navy-900); white-space: nowrap; }
.cell-truncate { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.client-cell { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.avatar-sm { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; background: #E8EEF6; color: var(--navy-800); font: 700 11.5px var(--font-display); }
.table-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 13px; color: var(--muted); }
.table-foot strong { color: var(--navy-900); }

.empty-state { display: grid; justify-items: center; gap: 6px; padding: 48px 24px; text-align: center; }
.empty-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: #EEF2F6; color: var(--muted); margin-bottom: 6px; }
.empty-title { font: 600 15px var(--font-display); color: var(--navy-900); }
.empty-text { font-size: 13px; color: var(--muted); max-width: 36ch; }

/* ==========================================================================
   Forms
   ========================================================================== */
.form-group { margin-bottom: 16px; min-width: 0; }
.form-grid { display: grid; gap: 0 16px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.form-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.form-hint { margin-top: 5px; font-size: 12px; color: var(--muted); }
.form-input, .form-select, .form-textarea {
  width: 100%; min-height: 40px;
  padding: 8px 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-md);
  font-family: var(--font-sans); font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-textarea { resize: vertical; line-height: 1.5; }
.form-input::placeholder, .form-textarea::placeholder { color: #94A3B8; }
.form-input:hover, .form-select:hover, .form-textarea:hover { border-color: #B5C2D1; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(11, 168, 143, 0.16); }
.form-input[readonly] { background: var(--surface-2); color: var(--muted); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .form-input { padding-left: 38px; }
.form-section-title { margin: 6px 0 12px; font: 600 13px var(--font-display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* Calculator line items */
.line-items { display: grid; gap: 12px; }
.line-item { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.line-item .idx { font: 600 13px var(--font-display); color: var(--muted); padding-top: 9px; }
.line-item .row-1 { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: start; margin-bottom: 8px; }
.line-item .row-2 { display: grid; grid-template-columns: minmax(110px, 1.1fr) minmax(64px, 0.6fr) minmax(110px, 1.2fr) minmax(76px, 0.8fr) auto; gap: 10px; align-items: end; margin-top: 10px; }
.line-item .row-2 .form-label { font-size: 12px; margin-bottom: 4px; }
.line-item .amount { text-align: right; padding-bottom: 9px; }
.line-item .amount small { display: block; font-size: 12px; color: var(--muted); }
.line-item .amount strong { font: 700 16px var(--font-display); color: var(--navy-900); }
.line-item .title-input { font-weight: 600; }

/* Calculator summary */
.summary-card { position: sticky; top: calc(var(--header-h) + 20px); }
.summary-rows { display: grid; gap: 10px; font-size: 13.5px; }
.summary-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--ink-2); }
.summary-row span:last-child { font-weight: 600; color: var(--ink); }
.summary-row.discount span:last-child { color: var(--amber); }
.summary-total { margin-top: 14px; padding: 16px; border-radius: 12px; background: var(--navy-900); color: #C9D5E3; }
.summary-total small { font-size: 12.5px; }
.summary-total strong { display: block; margin-top: 2px; font: 700 26px var(--font-display); color: #FFFFFF; }
.summary-total .note { margin-top: 4px; font-size: 12px; color: #5FE0C8; }
.split-list { display: grid; gap: 8px; margin: 16px 0 18px; }
.split-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); font-size: 13px; }
.split-item .lbl { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.split-item .sw { width: 8px; height: 8px; border-radius: 2px; }
.split-item strong { font-weight: 600; color: var(--navy-900); white-space: nowrap; }
.action-stack { display: grid; gap: 8px; }
.action-stack hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* Templates gallery */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.tpl-card { display: flex; flex-direction: column; gap: 14px; transition: border-color 0.15s, box-shadow 0.15s; }
.tpl-card:hover { border-color: #B5C2D1; box-shadow: 0 1px 2px rgba(11, 26, 46, 0.04), 0 12px 28px -12px rgba(11, 26, 46, 0.18); }
.tpl-head { display: flex; align-items: flex-start; gap: 14px; }
.tpl-icon { width: 44px; height: 44px; flex-shrink: 0; border-radius: 11px; display: grid; place-items: center; background: var(--teal-subtle); color: var(--teal-ink); }
.tpl-card.private .tpl-icon { background: var(--navy-800); color: #5FE0C8; }
.tpl-name { font: 600 16px var(--font-display); color: var(--navy-900); line-height: 1.3; }
.tpl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; }
.tpl-path { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.tpl-desc { font-size: 13.5px; color: var(--ink-2); line-height: 1.6; }
.tpl-features { list-style: none; display: grid; gap: 6px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.tpl-features li { display: flex; gap: 8px; font-size: 13px; color: var(--ink-2); }
.tpl-features .ic { color: var(--teal-ink); margin-top: 2px; }
.tpl-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }

/* ==========================================================================
   Modal & toasts
   ========================================================================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(4, 20, 39, 0.55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-box { width: 100%; max-width: 900px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); transform: translateY(8px) scale(0.98); transition: transform 0.2s var(--ease); }
.modal-overlay.active .modal-box { transform: none; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-header h3 { font: 600 16px var(--font-display); color: var(--navy-900); }
.modal-close-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 22px; cursor: pointer; }
.modal-close-btn:hover { background: #EEF2F6; color: var(--ink); }
.modal-body { flex: 1; overflow-y: auto; }

.toast-container { position: fixed; right: 24px; bottom: 24px; z-index: 2000; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 12px;
  background: var(--navy-900); color: #E3EBF5;
  box-shadow: var(--shadow-lg); font-size: 13.5px; line-height: 1.45;
  animation: toastIn 0.3s var(--ease);
  transition: opacity 0.3s, transform 0.3s;
}
.toast .ic { margin-top: 1px; }
.toast.success .ic { color: #34D399; }
.toast.warning .ic { color: #FBBF24; }
.toast.info .ic { color: #7DD3FC; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ==========================================================================
   Responsive
   ========================================================================== */
.sidebar-scrim { display: none; }

@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr) 320px; }
  .line-item .row-2 { grid-template-columns: 1fr 1fr 1fr 1fr; }
  .line-item .row-2 .amount { grid-column: 1 / -1; text-align: left; padding: 6px 0 0; display: flex; justify-content: space-between; align-items: baseline; }
}

@media (max-width: 1080px) {
  .grid-main, .grid-dash, .grid-2 { grid-template-columns: 1fr; }
  .summary-card { position: static; }
  .header-right .hide-md { display: none; }
}

@media (max-width: 900px) {
  .app-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .app-sidebar.mobile-open { transform: none; }
  .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(4, 20, 39, 0.45); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
  .sidebar-scrim.show { opacity: 1; pointer-events: auto; }
  .app-header .menu-toggle { display: inline-flex; }
  .app-header { padding: 12px 16px; }
  .view-viewport { padding: 20px 16px 40px; }
  .view-title-group p { display: none; }
  .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .header-right .currency-picker, .header-right .hide-sm { display: none; }
  .view-title-group h1 { font-size: 18px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 20px; }
  .kpi-icon-box { display: none; }
  .card { padding: 18px 16px; }
  .card-flush > .card-header { padding: 18px 16px 0; }
  .card-header { flex-wrap: wrap; }
  .form-grid.cols-2, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .form-input, .form-select, .form-textarea { font-size: 16px; min-height: 44px; } /* 16px stops iOS zooming into fields */
  .btn { min-height: 44px; }
  .btn-sm, .btn-icon-only { min-height: 40px; }
  .btn-icon-only { width: 40px; }
  .tabs { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; }
  .line-item { grid-template-columns: 1fr; padding: 14px; }
  .line-item .idx { padding: 0; }
  .line-item .row-2 { grid-template-columns: 1fr 1fr; }
  .tpl-grid { grid-template-columns: 1fr; }
  .donut-wrap { flex-direction: column; }
  .toast-container { right: 16px; left: 16px; bottom: 16px; width: auto; }

  /* tables become stacked cards on phones */
  .data-table.stack thead { display: none; }
  .data-table.stack, .data-table.stack tbody, .data-table.stack tr, .data-table.stack td { display: block; width: 100%; }
  .data-table.stack tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .data-table.stack td { padding: 4px 0; border: 0; text-align: left; }
  .data-table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 1px; }
  .data-table.stack .row-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 8px; }
  .data-table.stack .cell-truncate { max-width: none; white-space: normal; }
}

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

/* ==========================================================================
   Staff sign-in gate (js/auth.js)
   ========================================================================== */
body.auth-locked .app-container,
body.auth-locked .modal-overlay { display: none !important; }

.auth-gate {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center; padding: 16px; overflow-y: auto;
  background:
    radial-gradient(60% 50% at 85% 0%, rgba(11, 168, 143, 0.28), transparent 70%),
    radial-gradient(50% 50% at 0% 100%, rgba(22, 66, 117, 0.6), transparent 70%),
    var(--navy-950);
}
.auth-gate[hidden], .auth-gate [hidden] { display: none !important; }
.auth-card { width: min(420px, 100%); padding: 32px; border-radius: 18px; background: var(--surface); box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.6); animation: authIn 0.5s var(--ease) both; }
@keyframes authIn { from { opacity: 0; transform: translateY(14px); } }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-brand img { width: 40px; height: 44px; }
.auth-brand .brand-name { font-size: 18px; color: var(--navy-900); }
.auth-brand .brand-name span { color: var(--teal); }
.auth-brand .brand-subtitle { color: var(--muted); }
.auth-card h1 { font: 700 22px var(--font-display); color: var(--navy-900); margin-bottom: 6px; }
.auth-lead { font-size: 14px; color: var(--muted); line-height: 1.55; margin-bottom: 22px; }
.auth-card .form-group { margin-bottom: 14px; }
.auth-card .form-input { min-height: 46px; font-size: 15px; }
.auth-message { margin-bottom: 14px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.45; }
.auth-message[data-type="error"] { background: var(--rose-bg); color: #9F1239; }
.auth-message[data-type="success"] { background: var(--teal-subtle); color: var(--teal-ink); }
.auth-submit { width: 100%; min-height: 48px; font-size: 15px; }
.auth-submit:disabled { cursor: progress; }
.auth-submit.is-loading span::after { content: "…"; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 18px; }
.auth-link { padding: 6px 0; border: 0; background: none; font-size: 13.5px; font-weight: 600; color: var(--teal-ink); text-decoration: none; cursor: pointer; }
.auth-link:hover { text-decoration: underline; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ==========================================================================
   Website messages inbox (js/enquiries.js)
   ========================================================================== */
.enq-list { display: grid; gap: 14px; }
.enq { padding: 18px 20px; }
.enq.is-new { border-left: 3px solid var(--blue); }
.enq__head { display: flex; align-items: center; gap: 12px; }
.enq__who { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.enq__meta { display: grid; justify-items: end; gap: 4px; flex-shrink: 0; }
.enq__type { display: inline-block; margin-top: 12px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: #EEF2F6; color: var(--ink-2); }
.enq__message { margin-top: 12px; color: var(--ink); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.enq__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.enq__actions .danger { margin-left: auto; }
@media (max-width: 640px) {
  .enq__head { flex-wrap: wrap; }
  .enq__meta { justify-items: start; width: 100%; grid-auto-flow: column; justify-content: space-between; align-items: center; }
}
