:root {
  --ink: #1c2530;
  --ink-soft: #4b5768;
  --muted: #8792a2;
  --border: #e3e7ee;
  --bg: #f5f6f9;
  --surface: #ffffff;
  --brand: #2857c9;
  --brand-dark: #1d3f9c;
  --brand-soft: #eaf0ff;
  --success: #1a8a56;
  --success-soft: #e6f6ee;
  --danger: #c33636;
  --danger-soft: #fbeaea;
  --warn: #b8790c;
  --warn-soft: #fdf1de;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 37, 48, 0.06), 0 1px 8px rgba(28, 37, 48, 0.04);
}

/* Dark theme (Admin > System Settings > Appearance). Deliberately leaves
   --brand/--brand-dark/--brand-soft alone here - those are computed per
   request from the chosen highlight colour and injected inline, already
   dark-mode-aware (see deriveBrandShades in src/utils/helpers.js). */
:root[data-theme="dark"] {
  --ink: #e7eaf0;
  --ink-soft: #b8c0cd;
  --muted: #838d9c;
  --border: #333c4a;
  --bg: #12161d;
  --surface: #1b212b;
  --success: #3ecb8d;
  --success-soft: rgba(62, 203, 141, 0.16);
  --danger: #e5686b;
  --danger-soft: rgba(229, 104, 107, 0.16);
  --warn: #e0a83f;
  --warn-soft: rgba(224, 168, 63, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 8px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 650; color: var(--ink); }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }

p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.text-danger { color: var(--danger); font-weight: 700; }
.mt { margin-top: 20px; }

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

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
}

.sidebar-brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 20px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-tagline {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted);
  display: flex; align-items: center; gap: 5px;
}
.brand-version {
  font-weight: 650; background: var(--brand-soft); color: var(--brand-dark);
  border-radius: 20px; padding: 1px 6px; letter-spacing: 0;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: block; padding: 9px 12px; border-radius: 8px;
  color: var(--ink-soft); font-weight: 500; font-size: 13.5px;
}
.nav-link:hover { background: var(--bg); text-decoration: none; }
.nav-link.active { background: var(--brand-soft); color: var(--brand-dark); }
.nav-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700;
  color: var(--muted); padding: 16px 12px 6px;
}

/* Collapsible main menus (Clients, Sales, Stock, Finance, Operations, ...) -
   plain <details>/<summary> so expand/collapse works with zero JS. */
.nav-group { margin-top: 4px; }
.nav-group-summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700;
  color: var(--muted); list-style: none; user-select: none;
}
.nav-group-summary::-webkit-details-marker { display: none; }
.nav-group-summary:hover { background: var(--bg); color: var(--ink-soft); }
.nav-chevron { flex-shrink: 0; transition: transform 0.15s ease; }
.nav-group[open] > .nav-group-summary .nav-chevron { transform: rotate(180deg); }
.nav-sublinks { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 4px; }
.nav-sublink { padding-left: 24px; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar-title { font-weight: 650; font-size: 17px; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-name { font-weight: 600; }

.content { padding: 26px 28px 60px; max-width: 1100px; }

/* --- Buttons & links --- */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px; font-size: 13.5px;
  font-weight: 600; border: 1px solid transparent; cursor: pointer; text-decoration: none;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--brand-soft); color: var(--brand-dark); }
.btn-secondary:hover { background: #dde7ff; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger-soft); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.link-btn {
  background: none; border: none; color: var(--brand); cursor: pointer;
  padding: 0; font-size: inherit; font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }

/* --- Cards & layout --- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.card-narrow { max-width: 560px; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; gap: 14px; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

.quick-actions { display: flex; gap: 10px; margin-bottom: 22px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* --- Minimal, dependency-free horizontal bar chart (v13.0) - used by the
   Support Tickets Dashboard's "calls received vs missed" chart. No charting
   library anywhere else in the app, so this stays consistent with that: a
   bar is just a <div> whose width is set inline from the server-computed
   percentage. --- */
.chart-bars { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.chart-bar-row { display: flex; align-items: center; gap: 10px; }
.chart-bar-label { width: 110px; flex-shrink: 0; font-size: 13px; color: var(--muted); }
.chart-bar-track { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; height: 18px; overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: 6px; background: var(--brand); transition: width .3s ease; }
.chart-bar-fill.chart-bar-fill-alt { background: var(--danger); }
.chart-bar-value { width: 48px; flex-shrink: 0; text-align: right; font-weight: 600; font-size: 13px; }

/* --- Tables --- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: none; }
.row-muted { opacity: 0.55; }

/* --- Forms --- */
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 13.5px; font-family: inherit; color: var(--ink); background: var(--surface);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.search-form { display: flex; gap: 8px; }
.search-form input {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; min-width: 240px;
  color: var(--ink); background: var(--surface); font-family: inherit; font-size: 13.5px;
}
.search-form select {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px;
  color: var(--ink); background: var(--surface); font-family: inherit; font-size: 13.5px;
}
.inline-reset { display: flex; gap: 6px; margin-top: 8px; }
.inline-reset input {
  padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px;
  color: var(--ink); background: var(--surface); font-family: inherit;
}

/* --- Tag input (type + Enter to add a chip, e.g. TV model numbers) --- */
.tag-input {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface);
}
.tag-input-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 6px 3px 10px;
  background: var(--brand-soft); color: var(--brand-dark); border-radius: 20px;
  font-size: 12.5px; font-weight: 600;
}
.tag-chip-remove {
  border: none; background: none; color: inherit; cursor: pointer; font-size: 15px;
  line-height: 1; padding: 0 2px; opacity: 0.7;
}
.tag-chip-remove:hover { opacity: 1; }
.tag-input-field {
  flex: 1; min-width: 140px; border: none; outline: none; padding: 4px 2px;
  font-size: 13.5px; font-family: inherit; color: var(--ink); background: transparent;
}

/* --- Badges --- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px;
  font-weight: 650; text-transform: capitalize; background: var(--bg); color: var(--ink-soft);
}
.badge-lg { font-size: 12.5px; padding: 5px 12px; }
.badge-role { background: var(--brand-soft); color: var(--brand-dark); }
.badge-draft { background: var(--bg); color: var(--ink-soft); }
.badge-sent, .badge-unpaid, .badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-accepted, .badge-paid, .badge-delivered, .badge-approved { background: var(--success-soft); color: var(--success); }
.badge-rejected, .badge-cancelled { background: var(--danger-soft); color: var(--danger); }
.badge-so-pending { background: var(--warn-soft); color: var(--warn); }
.badge-so-in_progress { background: var(--brand-soft); color: var(--brand-dark); }
.badge-so-delivered { background: var(--success-soft); color: var(--success); }
.badge-so-cancelled { background: var(--danger-soft); color: var(--danger); }
.badge-po-draft { background: var(--bg); color: var(--ink-soft); }
.badge-po-ordered { background: var(--warn-soft); color: var(--warn); }
.badge-po-partially_received { background: var(--brand-soft); color: var(--brand-dark); }
.badge-po-received { background: var(--success-soft); color: var(--success); }
.badge-po-cancelled { background: var(--danger-soft); color: var(--danger); }
.badge-planning { background: var(--bg); color: var(--ink-soft); }
.badge-in_progress { background: var(--brand-soft); color: var(--brand-dark); }
.badge-uat { background: var(--warn-soft); color: var(--warn); }
.badge-completed { background: var(--success-soft); color: var(--success); }
.badge-todo { background: var(--bg); color: var(--ink-soft); }
.badge-done { background: var(--success-soft); color: var(--success); }
/* Deployment: per-room outcome + overall project deployment-progress badges */
.badge-not_started { background: var(--bg); color: var(--ink-soft); }
.badge-complete { background: var(--success-soft); color: var(--success); }
.badge-dnd { background: var(--bg); color: var(--ink-soft); }
.badge-fail { background: var(--danger-soft); color: var(--danger); }
/* Support Tickets: status badges ('in_progress' reuses the shared rule above) */
.badge-open { background: var(--warn-soft); color: var(--warn); }
.badge-closed { background: var(--success-soft); color: var(--success); }
/* v20.0: RMA status badges ('closed' reuses the shared rule above) */
.badge-logged { background: var(--bg); color: var(--ink-soft); }
.badge-sent_to_supplier { background: var(--warn-soft); color: var(--warn); }
.badge-replacement_received { background: var(--brand-soft); color: var(--brand-dark); }
/* Human Resource: employee employment-status badges */
.badge-probation { background: var(--warn-soft); color: var(--warn); }
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-resigned { background: var(--bg); color: var(--ink-soft); }
.badge-terminated { background: var(--danger-soft); color: var(--danger); }
/* v17.0: project stage badges (projects.stage - additive to the status
   badges above, which stay in lock-step with it) */
.badge-intake { background: var(--bg); color: var(--ink-soft); }
.badge-scheduled { background: var(--warn-soft); color: var(--warn); }
.badge-installing { background: var(--brand-soft); color: var(--brand-dark); }
.badge-uat_handover { background: var(--warn-soft); color: var(--warn); }

/* v19.0: Help Desk - queue_state badges ('in_progress'/'pending'/'closed'
   reuse the shared rules above since the labels line up), priority badges,
   and SLA-target-status badges (own sla- prefix so they don't collide with
   the generic badge-pending rule above, which means something different). */
.badge-new { background: var(--bg); color: var(--ink-soft); }
.badge-awaiting_customer { background: var(--warn-soft); color: var(--warn); }
.badge-resolved { background: var(--success-soft); color: var(--success); }
.badge-P1, .badge-P2 { background: var(--danger-soft); color: var(--danger); }
.badge-P3 { background: var(--warn-soft); color: var(--warn); }
.badge-P4, .badge-P5 { background: var(--bg); color: var(--ink-soft); }
.sla-met { background: var(--success-soft); color: var(--success); }
.sla-breached { background: var(--danger-soft); color: var(--danger); }
.sla-at_risk { background: var(--warn-soft); color: var(--warn); }
.sla-paused { background: var(--bg); color: var(--ink-soft); }
.sla-pending { background: var(--brand-soft); color: var(--brand-dark); }
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.filter-row .btn-active { background: var(--brand); color: #fff; }

/* v17.0: project-page stage bar - six fixed steps, filled up to and
   including the project's current stage, with 'cancelled' shown as a
   one-off banner instead (a cancelled project didn't "reach" any stage). */
.stage-bar { display: flex; gap: 4px; margin: 10px 0 4px; }
.stage-step { flex: 1; text-align: center; }
.stage-step .stage-step-bar { height: 6px; border-radius: 4px; background: var(--bg); margin-bottom: 6px; }
.stage-step.done .stage-step-bar, .stage-step.current .stage-step-bar { background: var(--brand); }
.stage-step-label { font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.stage-step.current .stage-step-label { color: var(--brand-dark); }

/* v17.0: headline figures row (rooms complete %, tasks done, target finish) */
.headline-row { display: flex; gap: 14px; margin: 14px 0; flex-wrap: wrap; }
.headline-tile {
  flex: 1; min-width: 150px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px;
}
.headline-tile .headline-value { font-size: 22px; font-weight: 700; color: var(--ink); }
.headline-tile .headline-label { font-size: 12px; color: var(--ink-soft); font-weight: 600; margin-top: 2px; }

/* Deployment outcome mini chart (Project Delivery page summary card) - a
   small stacked bar + legend showing the complete/DND/fail/pending split,
   reusing the same colours as the badges above so the two stay visually
   consistent. */
.mini-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--bg); margin: 10px 0 8px; }
.mini-bar-seg { height: 100%; }
.mini-bar-seg.complete { background: var(--success); }
.mini-bar-seg.dnd { background: var(--ink-soft); }
.mini-bar-seg.fail { background: var(--danger); }
.mini-bar-seg.pending { background: var(--warn); }
.mini-bar-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-soft); }
.mini-bar-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.mini-bar-legend .dot.complete { background: var(--success); }
.mini-bar-legend .dot.dnd { background: var(--ink-soft); }
.mini-bar-legend .dot.fail { background: var(--danger); }
.mini-bar-legend .dot.pending { background: var(--warn); }

/* --- Notifications --- */
.notif-bell { position: relative; display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 8px; color: var(--ink-soft); font-weight: 600; font-size: 13px; }
.notif-bell:hover { background: var(--bg); text-decoration: none; }
.notif-count { background: var(--danger); color: #fff; border-radius: 20px; padding: 1px 7px; font-size: 11px; font-weight: 700; margin-left: 5px; }
.notif-count.kpi-count { background: var(--brand); }
.notif-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--brand-soft); border-radius: 8px; padding: 10px 12px; margin-bottom: 4px; border-bottom: none; }

/* --- Detail list --- */
.detail-list { display: grid; grid-template-columns: 110px 1fr; row-gap: 8px; column-gap: 10px; margin: 0 0 16px; }
.detail-list dt { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.detail-list dd { margin: 0; }

/* --- Proposal item builder --- */
.item-table th, .item-table td { padding: 6px 8px; }
.item-table input, .item-table select { padding: 6px 8px; font-size: 13px; }
.row-total { font-weight: 600; white-space: nowrap; }

.totals-box {
  display: flex; gap: 28px; justify-content: flex-end; padding: 14px 0 4px; margin-top: 8px;
  border-top: 1px solid var(--border);
}
.totals-box > div { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.totals-box span { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.totals-box strong { font-size: 16px; }

/* --- Alerts --- */
.alert { padding: 11px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }

/* --- Auth --- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 34px; width: 100%; max-width: 380px; }
.auth-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.auth-title { font-size: 19px; margin-bottom: 18px; }

/* --- Link box (share link) --- */
.link-box { display: flex; gap: 8px; align-items: center; }
.link-box input { flex: 1; padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; color: var(--ink-soft); background: var(--bg); }

/* --- Signature --- */
.signature-preview { max-width: 320px; border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: #fff; }
.sig-canvas { width: 100%; max-width: 600px; height: 180px; border: 1.5px dashed var(--border); border-radius: 8px; background: #fff; touch-action: none; cursor: crosshair; display: block; margin-bottom: 6px; }

/* --- Public client-facing page --- */
.public-body { background: var(--bg); }
.public-shell { max-width: 780px; margin: 0 auto; padding: 30px 20px 60px; }
.public-header { display: flex; align-items: center; gap: 8px; margin-bottom: 22px; }
.public-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px 34px; }
.public-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 6px; }
.public-footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 24px; }

hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* --- Document header (invoices) --- */
.doc-header { display: flex; align-items: flex-start; justify-content: space-between; }
.doc-header-right { text-align: right; }

/* --- Print --- */
@media print {
  .no-print, .sidebar, .topbar { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; max-width: none; }
  .printable { box-shadow: none; border: none; }
  body { background: #fff; }
}

/* --- Proposal Templates: cover page + repeating content-page background ---
   Applied on the internal proposal view and the public client-facing
   signing page when a proposal has a format_template_id set (see
   proposal_templates table). Follows the app's existing "Print / Save PDF"
   browser-print convention (window.print()), no PDF library involved -
   background-size:100% <page-height> repeat-y is the closest a plain CSS
   background can get to "one image per printed page" without CSS Paged
   Media, which browsers don't support well enough to rely on. */
.proposal-cover-page {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: var(--bg);
  min-height: 297mm;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  margin-bottom: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.proposal-cover-page-inner {
  background: rgba(255, 255, 255, 0.85);
  padding: 28px 36px;
  border-radius: 10px;
  max-width: 520px;
}
.proposal-cover-page-inner h1 { font-size: 32px; margin-bottom: 8px; color: #1c2530; }
.proposal-cover-page-inner p { color: #4b5768; margin-bottom: 4px; }
.proposal-content-pages {
  background-repeat: repeat-y;
  background-size: 100% 297mm;
  background-position: top center;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
@media print {
  .proposal-cover-page { border: none; page-break-after: always; }
}

/* --- Proposal Templates: style engine (font / accent colour / layout) ---
   v9.1: a template can also choose a font stack, an accent colour, and a
   layout preset that change how a proposal's printed/PDF output looks,
   layered on top of the cover/background image engine above. Font and
   layout are a small curated set of static classes (there's no external
   font loading anywhere in this app, and we're keeping it that way - see
   src/utils/proposalStyles.js); accent colour is per-template, so it's
   injected per-request as a small scoped <style> block defining
   --prop-accent(-dark/-soft) custom properties on a per-template
   "proposal-style-<id>" class (same derive-shades approach the System
   Settings brand colour already uses - see deriveBrandShades in
   utils/helpers.js), and the generic [class*="proposal-style-"] rules below
   just consume those custom properties wherever relevant. Content and
   section order are never touched by any of this - only appearance. See
   proposals/view.ejs and public/proposal.ejs for where these classes are
   applied. */
.proposal-font-modern-sans { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.proposal-font-classic-serif { font-family: Georgia, "Times New Roman", Times, serif; }
.proposal-font-elegant-serif { font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif; }
.proposal-font-rounded-sans { font-family: "Trebuchet MS", "Century Gothic", Futura, sans-serif; }
.proposal-font-minimal-mono { font-family: "Courier New", Courier, monospace; }

[class*="proposal-style-"] .proposal-cover-page-inner h1,
[class*="proposal-style-"] .public-card-header h1 { color: var(--prop-accent-dark, inherit); }
[class*="proposal-style-"] .totals-box strong { color: var(--prop-accent-dark, inherit); }
[class*="proposal-style-"] .table th { color: var(--prop-accent-dark, var(--muted)); background: var(--prop-accent-soft, transparent); }

.proposal-layout-modern.card, .proposal-layout-modern.public-card { padding: 34px 40px; }
.proposal-layout-modern .table th { text-transform: none; font-size: 12.5px; border-bottom: 2px solid var(--prop-accent, var(--brand)); }
.proposal-layout-modern .table td { border-bottom: 1px solid rgba(0, 0, 0, 0.06); }
.proposal-layout-modern .doc-header { margin-bottom: 18px; }
.proposal-layout-modern .public-card-header h1, .proposal-layout-modern .proposal-cover-page-inner h1 { font-weight: 400; letter-spacing: 0.01em; }
.proposal-layout-modern .totals-box { border-top: none; padding-top: 18px; }

.proposal-layout-compact.card, .proposal-layout-compact.public-card { padding: 14px 18px; }
.proposal-layout-compact .table th, .proposal-layout-compact .table td { padding: 5px 8px; font-size: 12.5px; }
.proposal-layout-compact .totals-box { padding: 8px 0 2px; gap: 16px; margin-top: 4px; }
.proposal-layout-compact .public-card-header h1 { font-size: 21px; }
.proposal-layout-compact .doc-header { margin-bottom: 6px; }
.proposal-layout-compact p { margin-bottom: 6px; }

/* --- Proposal Templates: format sections (Executive Summary, Problem
   Statement, Proposed Solution, Qualifications, Timeline & Milestones,
   Pricing and Terms, Acceptance) - v9.2. Only appears at all when a
   template actually has section content; see proposals/view.ejs and
   public/proposal.ejs. */
.proposal-section-block { margin: 22px 0; }
.proposal-section-heading { font-size: 15.5px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.proposal-section-body { white-space: pre-wrap; }
.proposal-section-attachment { margin-top: 8px; font-size: 13px; }

/* Human Resource: Organization Chart - a plain recursive nested-list tree,
   no charting library. Children indent and get a connecting rule so the
   reporting lines stay readable without needing SVG/canvas. */
.org-chart-root, .org-chart-children { list-style: none; margin: 0; padding: 0 0 0 28px; }
.org-chart-root { padding-left: 0; overflow-x: auto; }
.org-chart-node { position: relative; padding: 10px 0 0; }
.org-chart-children { border-left: 2px solid var(--border); }
.org-chart-card {
  display: inline-block; background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; margin-bottom: 4px;
}
.org-chart-card a { font-weight: 650; }
.update-list { list-style: none; padding: 0; margin: 0 0 16px; }
.update-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.update-list li:last-child { border-bottom: none; }
.milestone-list { list-style: none; padding: 0; margin: 0; }
.milestone-list li { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.milestone-list li:last-child { border-bottom: none; }
.milestone-list .milestone-date { color: var(--muted); white-space: nowrap; }

.acceptance-block { margin-top: 10px; }
.acceptance-line { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 22px; font-size: 13px; color: var(--muted); }
.acceptance-line .acceptance-line-fill { flex: 1; border-bottom: 1px solid var(--ink-soft); height: 1px; }

/* Shown only when printed/saved as PDF - used for the blank
   signature/name/date lines on the public signing page's "sent" (not yet
   signed) state, since the interactive canvas signature pad above it is
   itself marked .no-print (you can't draw into a static PDF). */
.print-only { display: none; }
@media print {
  .print-only { display: block; }
}

/* --- Employee Portal: mobile responsiveness ---
   The rest of the app's two responsive rules above (.two-col, .stat-grid)
   are generic and already help here; these add a small-phone breakpoint and
   fix the few patterns the portal uses that don't wrap gracefully on their
   own: a horizontal pill nav, tables, and multi-field forms with a
   trailing submit button in the same row. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll .table { min-width: 480px; }

@media (max-width: 600px) {
  .public-shell { padding: 16px 12px 40px; }
  .public-header { flex-wrap: wrap; gap: 10px; }
  .public-card { padding: 18px 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .field-row { flex-wrap: wrap; gap: 10px; }
  .field-row .field { flex: 1 1 100%; min-width: 0; }
  .totals-box { flex-wrap: wrap; gap: 14px; justify-content: flex-start; }
}

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* --- Knowledge Base (v12.0) --- */
.kb-subcat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.kb-subcat-list li { padding: 2px 0; }

.kb-editor { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.kb-editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.kb-editor-toolbar .btn { padding: 5px 9px; }
.kb-editor-body {
  min-height: 220px; padding: 14px 16px; font-size: 13.5px; color: var(--ink);
  background: var(--surface);
}
.kb-editor-body:focus { outline: none; }
.kb-editor-body p { margin: 0 0 10px; }
.kb-editor-body ul, .kb-editor-body ol { margin: 0 0 10px; padding-left: 22px; }
.kb-editor-body blockquote {
  margin: 0 0 10px; padding: 6px 14px; border-left: 3px solid var(--border); color: var(--ink-soft);
}

/* Read-only rendering of a saved subject's body - same tag set the editor
   produces and the server allows through sanitizeKbHtml. */
.kb-subject-body h3, .kb-subject-body h4 { margin-top: 18px; }
.kb-subject-body h3:first-child, .kb-subject-body h4:first-child { margin-top: 0; }
.kb-subject-body p { margin: 0 0 12px; }
.kb-subject-body ul, .kb-subject-body ol { margin: 0 0 12px; padding-left: 24px; }
.kb-subject-body blockquote {
  margin: 0 0 14px; padding: 8px 16px; border-left: 3px solid var(--border); color: var(--ink-soft);
}

/* The portal's top pill nav (layout-portal.ejs): scroll horizontally
   instead of wrapping to several lines, which pushed page content down
   awkwardly on narrow phones. */
@media (max-width: 600px) {
  .public-shell > nav {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .public-shell > nav .btn { flex-shrink: 0; }
}
