/* Static Inter weights — NOT the variable font. The variable font (100–900
   range) is expensive to rasterise in software-rendered Chromium (WSL) and
   causes navigation freezes; static weights render as plain glyphs. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/Inter-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/Inter-Medium.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/Inter-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/Inter-Bold.woff2') format('woff2');
}

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --sidebar: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.12);
  --accent: #2080c0;
  --accent-ink: #0d5b96;
  --accent-soft: rgba(32, 128, 192, 0.12);
  --accent-grad: linear-gradient(135deg, #4a9bd6 0%, #1767a5 100%);
  --success: #2080c0;
  --danger: #ff3b30;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="spacex"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --sidebar: #161617;
  --text: #f5f5f7;
  --text-2: #98989d;
  --text-3: #86868b;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: #4a9bd6;
  --accent-ink: #9cc8ec;
  --accent-soft: rgba(74, 155, 214, 0.18);
  --success: #2080c0;
  --danger: #ff453a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
  font-size: 15px;
  letter-spacing: -0.01em;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px;
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: var(--sidebar);
  overflow: hidden;
  /* NOTE: no backdrop-filter here. A blur(20px) on this full-height fixed
     element was re-composited on every navigation and could stall Chromium's
     GPU compositor on Windows (the reported "freeze, F5 to recover"). The
     backdrop behind the sidebar is a flat page background, so the blur was
     doing nothing visually anyway — removing it changes nothing pixel-wise. */
  border-right: 1px solid var(--border);
  z-index: 10;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 10px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px;
  box-shadow: 0 4px 12px rgba(32, 128, 192, 0.3);
  flex-shrink: 0;
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-logo { width: 100%; height: auto; max-height: 56px; object-fit: contain; display: block; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.sidebar nav { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 4px 8px 0; }
.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 2px 0;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg { width: 18px; height: 18px; stroke-width: 1.7; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-section {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3); padding: 18px 12px 5px; margin-top: 6px;
}

.sidebar-foot { padding: 12px 4px 0; border-top: 1px solid var(--border); flex-shrink: 0; }
.nav-item.small { font-size: 13px; color: var(--text-3); }
.sidebar-version {
  margin-top: 10px; padding: 10px 12px 4px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-3); letter-spacing: 0.02em;
}

/* ---------- Content ---------- */
.content { margin-left: 250px; flex: 1; padding: 28px 40px 108px; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.topbar h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-clock {
  display: inline-flex; align-items: baseline; gap: 7px;
  color: var(--text-2); font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
}
.topbar-clock .clock-dot { color: var(--text-3); font-weight: 400; }
.beta-badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: #b45309;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.38);
  padding: 3px 10px; border-radius: 999px; line-height: 1;
}

/* Test/discovery scrolling notice — sits between the page title and the BETA badge */
.demo-marquee {
  flex: 1; min-width: 0; overflow: hidden; white-space: nowrap;
  margin: 0 22px; padding: 7px 14px;
  background: rgba(220, 38, 38, 0.07);
  border: 1px solid rgba(220, 38, 38, 0.20);
  border-radius: 8px;
}
.demo-marquee__track {
  display: inline-block; white-space: nowrap;
  will-change: transform;
  animation: demo-marquee-scroll 40s linear infinite;
}
.demo-marquee__item {
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.04em;
  color: #b91c1c; padding-right: 72px;
}
.demo-marquee__sep { opacity: 0.45; padding: 0 12px; font-weight: 400; }
[data-theme="spacex"] .demo-marquee__item { color: #f87171; }
@keyframes demo-marquee-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.theme-toggle {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle:active { transform: scale(0.92); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="spacex"] .theme-toggle .icon-sun, [data-theme="retro"] .theme-toggle .icon-sun { display: none; }
[data-theme="spacex"] .theme-toggle .icon-moon, [data-theme="retro"] .theme-toggle .icon-moon { display: block; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 8px; }
.card p { color: var(--text-2); font-size: 14px; line-height: 1.6; }
.card.wide { padding: 0; overflow: hidden; }
.card.wide > h2, .card.wide > p { padding: 24px 22px 0; }
.card.wide > p { padding-top: 6px; padding-bottom: 22px; }

/* ---------- Hero / intro ---------- */
.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -80px; top: -80px;
  width: 260px; height: 260px; border-radius: 50%;
  /* soft glow via a radial fade — NO filter/blur, which can stall Chromium's
     GPU compositor on Windows/WSL (the reported freeze) */
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: 0.12;
}
.hero h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.04em; margin-bottom: 8px; }
.hero p { color: var(--text-2); max-width: 560px; line-height: 1.6; }
.hero .eyebrow {
  display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--accent-ink); background: var(--accent-soft);
  padding: 4px 10px; border-radius: 20px; margin-bottom: 14px;
}

/* ---------- Metrics ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.metric { text-align: left; padding: 24px; }
.metric-value { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.metric-label { color: var(--text-2); font-size: 13px; margin-top: 6px; font-weight: 500; }
.metric .metric-icon { color: var(--accent); margin-bottom: 14px; }
.metric .metric-icon svg { width: 24px; height: 24px; stroke-width: 1.6; }

/* ---------- Facts ---------- */
.facts { display: flex; gap: 44px; flex-wrap: wrap; padding: 26px; }
.fact { display: flex; flex-direction: column; }
.fact-num { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.fact-label { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.fact-sub { color: var(--text-2); font-size: 12px; margin-top: 2px; opacity: 0.85; }

/* ---------- Dashboard ---------- */
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
a.metric-link { text-decoration: none; color: var(--text); transition: transform 0.15s ease, border-color 0.15s ease; }
a.metric-link:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
a.metric-link:hover .metric-value { color: var(--accent); }
.facts a.fact { text-decoration: none; }
.facts a.fact:hover .fact-label { color: var(--accent); }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.dashboard-grid .card { margin-bottom: 0; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }


/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.count-badge {
  background: var(--surface-2); color: var(--text-2);
  font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--border);
}
.toolbar-left { display: flex; align-items: center; gap: 8px; }
.count-badge.credit-warn { color: #b91c1c; background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.35); }

/* ---------- Credit-control badges (customer list) ---------- */
.credit-badge {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; line-height: 1.4; white-space: nowrap;
}
.credit-badge.stop { color: #b91c1c; background: rgba(239,68,68,0.13); border: 1px solid rgba(239,68,68,0.4); }
.credit-badge.over { color: #dc2626; background: rgba(239,68,68,0.10); border: 1px solid rgba(239,68,68,0.32); }
.credit-badge.near { color: #b45309; background: rgba(245,158,11,0.14); border: 1px solid rgba(245,158,11,0.38); }
.credit-badge.warn { color: #3730a3; background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.36); }
.credit-danger { color: var(--danger); font-weight: 700; }

/* ---------- Modal overlay (credit check) ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.62);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-card {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 28px 30px; max-width: 460px; width: 100%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}
.modal-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 14px; }
.modal-card p { font-size: 14px; line-height: 1.6; margin-bottom: 10px; }
.modal-card .muted { color: var(--text-2); font-size: 13px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.cust-warn-keys { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
/* The modal reuses the F-key pill classes, but theme blocks hardcode .fk-label
   (e.g. #000) that's unreadable on the modal card. Re-skin them with the modal's
   surface/text variables so F3/Esc read correctly in every theme. */
.cust-warn-keys .fk-key {
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 12px;
}
.cust-warn-keys .fk-key:hover { background: var(--border-strong); color: var(--text); }
.cust-warn-keys .fk-badge {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: none;
}
.cust-warn-keys .fk-label { color: var(--text); }
.search { display: flex; gap: 8px; }
.search input {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 14px; font-size: 14px; min-width: 240px;
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search button {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 8px 18px; font-weight: 600;
  font-size: 14px; cursor: pointer; transition: opacity 0.15s ease, transform 0.1s ease;
}
.search button:hover { opacity: 0.9; }
.search button:active { transform: scale(0.97); }
.search select,
.search input[type="date"] {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 13px;
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search select:focus,
.search input[type="date"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filter-clear { align-self: center; font-size: 13px; color: var(--text-2); text-decoration: none; white-space: nowrap; }
.filter-clear:hover { color: var(--danger); text-decoration: underline; }

/* ---------- Sortable table headers ---------- */
th.sortable { padding: 0; }
th.sortable a.sort-link {
  display: flex; align-items: center; gap: 5px;
  padding: 12px 22px;
  color: inherit; text-decoration: none; cursor: pointer; white-space: nowrap;
}
th.sortable a.sort-link:hover { color: var(--text); text-decoration: none; }
th.sortable.sorted a.sort-link { color: var(--accent); }
th.sortable.num a.sort-link { justify-content: flex-end; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--text-3);
  padding: 12px 22px; border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 22px; border-bottom: 1px solid var(--border); color: var(--text); }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
tfoot td { padding: 14px 22px; border-top: 1px solid var(--border-strong); font-size: 14px; font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--text-3); padding: 32px; text-align: center; }
.hint { color: var(--text-2); font-size: 13px; padding: 16px 22px; }

/* ---------- Batch labels (certificate screen) ---------- */
.batch-labels {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  background: var(--surface-2);
}
.batch-labels-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.batch-labels-head .muted { font-weight: 400; color: var(--text-2); font-size: 12px; }
.batch-label-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
}
.batch-label-row:first-of-type { border-top: none; }
.batch-label-ref { flex: 1; font-size: 14px; }

/* ---------- Hidden one-off checkbox (toggled by F3, no visible tick box) ---------- */
.one-off-hidden { display: none; }

/* ---------- Invoice jobs (delivery-note selection screen) ---------- */
.inv-date-row { display: flex; align-items: center; gap: 10px; padding: 14px 22px 0; }
.inv-date-row label { font-weight: 600; }
.inv-date-row input { width: 140px; }
.hint-note { color: var(--text-2); font-size: 13px; }
.sel-col { text-align: center; width: 48px; }
.sel-check { display: none; }
.sel-marker { font-weight: 700; color: var(--accent); }
tr.sel-on td { background: var(--accent-soft, rgba(32,128,192,0.10)); }

/* ---------- Pagination ---------- */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 14px 22px; border-top: 1px solid var(--border);
}
.page-meta { color: var(--text-3); font-size: 13px; font-weight: 500; }
.page-nav { display: flex; gap: 6px; }
.page-btn {
  display: inline-flex; align-items: center;
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 500;
  text-decoration: none; transition: background 0.15s ease;
}
.page-btn:hover { background: var(--surface-2); text-decoration: none; }
.page-btn.disabled { color: var(--text-3); opacity: 0.55; pointer-events: none; }

/* ---------- Buttons / links ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  text-decoration: none; color: var(--accent); font-weight: 600; font-size: 13px;
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.75; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Invoice detail ---------- */
.invoice-head {
  display: flex; justify-content: space-between; gap: 24px;
  padding: 26px; border-bottom: 1px solid var(--border);
  font-size: 14px; line-height: 1.7;
}
.invoice-head .to { color: var(--text-2); }
.invoice-head strong { color: var(--text); font-weight: 600; }
.invoice-meta { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }
.invoice-meta strong { color: var(--text); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Buttons ---------- */
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 10px;
  padding: 9px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  box-shadow: 0 2px 6px rgba(32, 128, 192, 0.3);
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover { opacity: 0.9; text-decoration: none; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary svg { width: 15px; height: 15px; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 8px 16px; font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: background 0.15s ease;
}
.btn-ghost:hover { background: var(--surface-2); text-decoration: none; }
.btn-ghost.danger { color: var(--danger); }

.row-actions { display: flex; gap: 6px; }
.row-actions a { font-size: 13px; font-weight: 500; }
.row-actions a:hover { text-decoration: underline; }

/* ---------- Toolbar actions ---------- */
.toolbar-actions { display: flex; gap: 10px; }
.muted { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.audit-change { font-size: 12.5px; color: var(--text-2); }
.audit-change strong { color: var(--text); }
.undo-btn { color: var(--danger); border-color: rgba(220,38,38,0.35); }
.undo-btn:hover { background: rgba(220,38,38,0.08); border-color: var(--danger); }

/* ---------- Forms ---------- */
.form-card { max-width: 1120px; margin: 0 auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-label-row { display: flex; align-items: center; gap: 7px; position: relative; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.help-toggle { width: 17px; height: 17px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); font-size: 11px; font-weight: 700; line-height: 1; padding: 0; cursor: pointer; }
.help-toggle:hover { border-color: var(--accent); color: var(--accent); }
.help-pop { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 300; width: 380px; max-width: 92vw; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: 0 24px 60px rgba(0,0,0,0.30); padding: 16px 20px; }
.help-pop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.help-pop-head strong { font-size: 14px; color: var(--text); }
.help-close { border: 0; background: transparent; font-size: 20px; line-height: 1; color: var(--text-2); cursor: pointer; padding: 0 2px; }
.help-close:hover { color: var(--text); }
.help-pop-body { font-size: 13px; line-height: 1.75; color: var(--text); }
.form-field input, .form-field select, .form-field textarea {
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 10px 14px; font-size: 15px; font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-error { color: var(--danger); font-size: 13px; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; }

/* ---------- Flash messages ---------- */
.messages { margin-bottom: 20px; }
.flash {
  position: relative;
  padding: 12px 44px 12px 16px; border-radius: 10px; font-size: 14px;
  margin-bottom: 8px; border: 1px solid var(--border);
  background: var(--surface-2);
}
.flash.success { border-color: rgba(52, 199, 89, 0.4); background: rgba(52, 199, 89, 0.1); color: var(--success); }
.flash.error { border-color: rgba(255, 59, 48, 0.4); background: rgba(255, 59, 48, 0.12); color: var(--danger); }
.flash-close {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; font-size: 20px; line-height: 1;
  color: inherit; opacity: 0.55; cursor: pointer; padding: 2px 6px; border-radius: 4px;
}
.flash-close:hover { opacity: 1; }

/* ---------- Certificate of Conformity ---------- */
.cert-doc { max-width: 980px; margin: 0 auto; padding: 36px 40px; }
.cert-letterhead { text-align: center; margin-bottom: 28px; }
.cert-logo { font-size: 22px; font-weight: 800; letter-spacing: 0.04em; color: var(--accent); }
.cert-logo-img { height: 60px; width: auto; display: block; margin: 0 auto; }
.cert-dept { font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-2); margin-top: 4px; }
.cert-rule { height: 2px; background: var(--accent-grad); width: 80px; margin: 14px auto 0; border-radius: 2px; }
.cert-title { text-align: center; font-size: 22px; font-weight: 700; letter-spacing: 0.05em; margin-bottom: 24px; }
.cert-body p { color: var(--text-2); line-height: 1.7; margin-bottom: 18px; }
.cert-fields { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.cert-fields td { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.cert-fields td:first-child { color: var(--text-2); width: 40%; }
.cert-notes { white-space: pre-line; }
.cert-lines th, .cert-lines td { padding: 10px 12px; }
.cert-lines { font-size: 13px; }
.cert-lines th { white-space: normal; line-height: 1.3; }
.cert-sign { text-align: center; margin-top: 40px; }
.cert-sign-line { width: 220px; border-top: 1px solid var(--border-strong); margin: 0 auto 8px; }
.cert-sign { color: var(--text-2); font-size: 13px; }
.cert-footer { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; font-size: 11px; color: var(--text-3); letter-spacing: 0.05em; }

/* ---------- line table in order form ---------- */
.line-table th, .line-table td { padding: 10px 12px; }
.line-table input, .line-table select {
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 8px 10px; font-size: 14px; width: 100%;
  background: var(--surface); color: var(--text);
}
.line-desc { min-width: 240px; }
.line-table input:focus, .line-table select:focus { outline: none; border-color: #ff5555; background: #aaaaaa; color: #000000; box-shadow: none; }

/* checkbox focus — a red outline ring (the grey reverse-video bar doesn't show on a checkbox) */
.line-table input[type=checkbox]:focus,
.form-field input[type=checkbox]:focus {
  outline: 2px solid #ff5555; outline-offset: 2px;
}

/* number inputs in line tables: drop the up/down spinner (reads as a "slider"),
   give qty/price a tidy fixed width instead of 100% */
.line-table input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.line-table input[type=number]::-webkit-outer-spin-button,
.line-table input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.line-table td.num input { width: 84px; }

/* multi-line delivery note table — keep batch/date fields tidy widths */
.delivery-lines input.batch-in { width: 120px; }
.delivery-lines input.date-in { width: 130px; }
.delivery-lines input.qty-in { width: 96px; }
.delivery-hint { padding: 14px 22px; border-left: 3px solid var(--accent); background: var(--surface-2); }
.delivery-hint strong { color: var(--text); }
.th-hint { font-weight: 400; font-size: 11px; color: var(--text-2); }

/* seal-spec detail row under each line item (Material · Bought in · OD · ID ·
   Profile · Height · Other size · Type) — keeps the core line table narrow so
   it never needs a horizontal scrollbar */
.line-table tr.seal-row td { padding: 2px 12px 12px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.seal-spec { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-end; padding: 6px 0 2px; }
.seal-field { display: flex; flex-direction: column; gap: 3px; }
.seal-field > label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; color: var(--text-3); }
.line-table .seal-spec input, .line-table .seal-spec select { width: auto; min-width: 74px; padding: 6px 8px; font-size: 13px; }
.line-table .seal-spec input[type=checkbox] { width: 16px; height: 16px; min-width: 0; padding: 0; }
.seal-field.seal-buy { flex-direction: row; align-items: center; gap: 8px; }
.seal-field.seal-buy > label { text-transform: none; }

/* ---------- Dynamic formset rows ---------- */
.del-col { text-align: center; width: 38px; white-space: nowrap; }
.del-check { display: none; }
.remove-row {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-3); cursor: pointer; font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.remove-row:hover { color: var(--danger); background: var(--surface-2); border-color: var(--danger); }

/* ================= Auth (login / logout) — clean & professional ================= */
.auth-body {
  display: block; /* override global `body { display: flex }` so the login fills the viewport */
  margin: 0;
  min-height: 100vh;
  background: #000000;
  color: #ffffff;
  letter-spacing: 0;
}
.login-wrap { min-height: 100vh; display: flex; overflow: hidden; }

/* ---------- left brand panel ---------- */
.login-brand {
  flex: 1 1 42%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1000px 620px at 18% -10%, rgba(255,255,255,0.06), transparent 55%),
    #08080a;
  border-right: 1px solid rgba(255,255,255,0.06);
  color: #fff;
  padding: 48px;
}
.login-brand-inner { max-width: 560px; width: 100%; }
.brand-wordmark {
  font-size: 60px;
  font-weight: 600;
  letter-spacing: 0.22em;
  line-height: 1.05;
  margin: 0;
  background: linear-gradient(180deg, #ffffff 0%, #a7a7b0 55%, #7f7f8a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-sub {
  margin-top: 24px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: #9ca3af;
}

/* ---------- right panel / card ---------- */
.login-panel {
  flex: 1 1 58%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px; background: #000;
}
.login-card {
  background: #101013; border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px; padding: 44px 46px; width: 100%; max-width: 460px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
}
.login-card h1 { font-size: 28px; font-weight: 600; margin-bottom: 8px; letter-spacing: -0.3px; }
.login-sub { color: #6b7280; margin-bottom: 28px; font-size: 15px; }
.login-card form { display: flex; flex-direction: column; gap: 16px; }

.field-group { display: flex; flex-direction: column; }
.login-card input[type="text"],
.login-card input[type="password"],
.login-card input[type="email"] {
  padding: 16px 18px; border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px; background: #0a0a0c; color: #fff;
  outline: none; font-size: 16px; width: 100%; font-family: inherit;
  transition: border-color .15s ease;
}
.login-card input::placeholder { color: #6b7280; }
.login-card input:focus { border-color: #fff; }

.login-error-box {
  color: #ff5a5f; font-size: 14px; text-align: left; margin-bottom: 16px;
  padding: 12px 14px; border-radius: 10px;
  background: rgba(255,90,95,0.1); border: 1px solid rgba(255,90,95,0.3);
}

.auth-btn {
  margin-top: 6px; padding: 16px; font-size: 16px;
  background: #fff; color: #000; border: none; border-radius: 10px;
  cursor: pointer; font-weight: 600; width: 100%; letter-spacing: 0.02em;
  font-family: inherit;
  transition: background .15s ease, transform .05s ease;
}
.auth-btn:hover { background: #d9d9dc; }
.auth-btn:active { transform: translateY(1px); }
.auth-btn:disabled { opacity: .55; cursor: default; }

.login-foot { margin-top: 24px; color: #6b7280; font-size: 13px; }

/* Sign-in button spinner (GPU-safe: transform rotate only) */
.auth-btn.loading { opacity: 0.85; cursor: progress; }
.auth-btn.loading::after {
  content: ""; display: inline-block; width: 15px; height: 15px;
  margin-left: 10px; vertical-align: -2px;
  border: 2px solid rgba(0, 0, 0, 0.35);
  border-top-color: #000; border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .login-brand { display: none; }
}

/* Dashboard entrance — GPU-safe: opacity only (no transform/animation that can
   stall the WSL Chromium compositor on navigation). */
.page-enter { animation: page-in 0.3s ease both; }
@keyframes page-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- User menu (topbar) ---------- */
.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 13px 4px 4px;
  cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text);
  transition: background 0.15s ease;
}
.user-chip:hover { background: var(--surface-2); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 210px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-md); padding: 6px;
  display: none; z-index: 50;
}
.user-menu:hover .user-dropdown, .user-menu:focus-within .user-dropdown { display: block; }
.user-dropdown .user-dropdown-name {
  padding: 8px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
  font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-dropdown a, .user-dropdown button {
  display: flex; width: 100%; text-align: left; align-items: center;
  padding: 9px 12px; border-radius: 8px; font-size: 14px; font-weight: 500;
  color: var(--text); text-decoration: none; background: none; border: none; cursor: pointer; font-family: inherit;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--surface-2); text-decoration: none; }
.user-dropdown button.danger { color: var(--danger); }

/* ---------- Brand mark (sharp bird) ---------- */
.brand-mark svg { width: 22px; height: 22px; }

/* ---------- Checkbox fields ---------- */
.form-field input[type="checkbox"] {
  width: 16px; height: 16px; padding: 0; border: none;
  accent-color: var(--accent); cursor: pointer; flex-shrink: 0;
}
.check-label {
  display: flex; align-items: center; gap: 9px;
  font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer;
}
.guide-toggle {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-2); user-select: none; white-space: nowrap;
}
.guide-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.guide-toggle .track {
  width: 38px; height: 21px; border-radius: 999px; background: var(--border-strong);
  position: relative; transition: background 0.18s ease; flex-shrink: 0;
}
.guide-toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.18s ease;
}
.guide-toggle input:checked + .track { background: var(--accent); }
.guide-toggle input:checked + .track::after { transform: translateX(17px); }
.guide-toggle input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }
.module-checks ul {
  list-style: none; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 6px 16px; margin-top: 2px;
}
.module-checks li { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text); font-weight: 500; }

/* ---------- User permission grid ---------- */
.perm-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 20px; margin-top: 4px; }
.perm-col { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); }
.perm-head { margin: 0 0 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-2); }
.perm-col .module-checks ul { grid-template-columns: 1fr; }
.level-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; }
@media (max-width: 820px) { .perm-cols { grid-template-columns: 1fr; } }

/* ---------- Document template editor ---------- */
.editor-wrap { display: flex; gap: 20px; align-items: flex-start; }
.editor-canvas-col { flex: 1; min-width: 0; overflow: auto; }
.editor-side { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; }
.doc-canvas { background: #fff; color: #1a1a1a; border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 2px 16px rgba(0,0,0,0.08); position: relative; font-family: 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }
.doc-canvas::before {
  /* Printable-area guide — laser printers can't print to the paper edge, so this
     light-blue dashed line marks the safe boundary (~5mm inset). Visible only in the
     editor/preview; hidden when printing. */
  content: "";
  position: absolute;
  inset: 19px;
  border: 1px dashed rgba(32, 128, 192, 0.5);
  pointer-events: none;
}
.doc-canvas.guide-off::before { display: none; }  /* user toggled the printable-area guide off */
.doc-el { position: absolute; cursor: move; padding: 4px 6px; border: 1px dashed transparent; line-height: 1.25; overflow: hidden; box-sizing: border-box; font-family: inherit; }
.print-stage .doc-el { padding: 0 4px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }  /* tight, no padding in the printed/PDF document */
.doc-el:hover { border-color: var(--accent); background: rgba(59,130,246,0.05); }
.doc-el.selected { border: 1px solid var(--accent); background: rgba(59,130,246,0.08); }
.doc-logo { border: 1px dashed #ccc; background: #f5f5f5; color: #999; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.doc-logo.has-logo { background: transparent; border-color: transparent; }  /* real logo: no grey box/border */
.doc-field { color: #1a1a1a; }  /* black in the final printed document */
.editor-wrap .doc-field, .preview-page .doc-field { color: #0b6bcb; }  /* blue = dynamic-field indicator in the editor/preview only */
.logo-placeholder { font-size: 12px; }
.doc-el.blocked { border: 1px dashed #9ca3af; padding-top: 12px; }
.block-tag {
  position: absolute; top: 0; left: 0; font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.3px; color: #6b7280; background: #eef2f7; padding: 0 4px; pointer-events: none;
}
.editor-tools { display: flex; flex-direction: column; gap: 10px; }
.editor-tool-row { display: flex; gap: 8px; }
.editor-tool-row .btn-ghost { flex: 1; padding: 9px 4px; white-space: nowrap; }
.editor-tools > #upload-logo { width: 100%; }
.editor-tools .prop-row label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.editor-tools .prop-row select {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 9px; font-size: 13px; background: var(--surface); color: var(--text);
}
.editor-tools .prop-row select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.editor-actions { display: flex; flex-direction: column; gap: 8px; }
.editor-actions .btn-primary, .editor-actions .btn-ghost { width: 100%; }
.editor-actions form { display: flex; }
.editor-actions form .btn-ghost { width: 100%; }
.editor-props { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.prop-row { display: flex; flex-direction: column; gap: 4px; }
.prop-row.two { flex-direction: row; gap: 8px; }
.prop-row.two > div { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.prop-row label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.prop-row input, .prop-row select, .prop-row textarea {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 9px; font-size: 13px; background: var(--surface); color: var(--text);
}
.prop-row input:focus, .prop-row select:focus, .prop-row textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.preview-page { padding: 20px; background: var(--surface-2); border-radius: var(--radius); display: flex; justify-content: center; overflow: auto; }
.preview-page .doc-canvas { box-shadow: 0 4px 20px rgba(0,0,0,0.12); }
.preview-page .doc-el { cursor: default; }
.preview-page .doc-el:hover { border-color: transparent; background: transparent; }
@media (max-width: 900px) { .editor-wrap { flex-direction: column; } .editor-side { width: 100%; } }

/* ---------- Financial reports ---------- */
.report-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.report-meta { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.report-meta input {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 12px; font-size: 14px; width: 118px;
  background: var(--surface); color: var(--text); font-variant-numeric: tabular-nums;
}
.report-meta input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.seg { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-left: auto; }
.seg a { padding: 7px 16px; font-size: 13px; font-weight: 600; color: var(--text-2); text-decoration: none; }
.seg a:hover { background: var(--surface-2); text-decoration: none; }
.seg a.active { background: var(--accent); color: #fff; }
.report-body { padding: 4px 22px 22px; }
.sec-row td {
  background: var(--surface-2); font-weight: 700; letter-spacing: 0.03em;
  text-transform: uppercase; font-size: 12px; color: var(--text-2);
}
tr.net td { border-top: 2px solid var(--border-strong); font-size: 16px; font-weight: 700; padding-top: 16px; }
tr.net td.num { color: var(--accent-ink); }
.bs-cols { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.bs-col { flex: 1 1 320px; min-width: 0; }
.report-note { color: var(--text-2); font-size: 13px; line-height: 1.55; padding: 0 22px 20px; }
.final-head { padding: 24px 22px 6px; }
.final-head h3 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.final-head .sub { color: var(--text-2); font-size: 13px; margin-top: 4px; line-height: 1.6; }
.final-head .sub .sep { margin: 0 8px; color: var(--text-3); }

/* ---------- Document print (letterhead + live line-items table) ---------- */
.print-stage { padding: 24px 24px 72px; background: var(--surface-2); display: block; }
.print-stage .doc-canvas { margin: 0 auto 24px; }
.print-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.print-toolbar .hint { color: var(--text-2); font-size: 13px; font-weight: 500; margin-right: auto; }
.doc-lines { font-family: 'Inter', 'Segoe UI', Roboto, Arial, sans-serif; color: #1a1a1a; font-variant-numeric: tabular-nums; }
.doc-lines th, .doc-lines td {
  padding: 3px 8px; text-align: left; vertical-align: top;
  color: #1a1a1a;        /* stay dark on the white A4 sheet even in dark mode */
  text-transform: none;  /* override global `thead th { text-transform: uppercase }` */
  letter-spacing: normal;
}
.doc-lines th { font-weight: 700; font-size: 11px; border-top: 1px solid #000; border-bottom: 1px solid #000; }
.doc-lines td { font-size: 11px; border-bottom: 1px solid #e4e4e4; }
.doc-lines th.right, .doc-lines td.right { text-align: right; }
.doc-lines th.center, .doc-lines td.center { text-align: center; }
.doc-lines tfoot td { border-top: none; border-bottom: none; font-weight: 400; color: #1a1a1a; }
.doc-lines tfoot td.totals-value { text-align: right; }
.doc-lines tfoot tr.totals-first td { border-top: 1px solid #000; }
.doc-lines tfoot tr.totals-total td { font-weight: 700; }
.doc-lines tbody tr:last-child td { border-bottom: none; }

/* ---------- Print ---------- */
@media print {
  .doc-canvas::before { display: none; }  /* hide the printable-area guide on paper */
  .doc-logo { background: transparent !important; border-color: transparent !important; }  /* never print the logo placeholder box */
  .no-print, .print-toolbar, .sidebar, .topbar, .messages { display: none !important; }
  body { display: block !important; min-height: 0 !important; background: #fff !important; }
  .print-stage { padding: 0; margin: 0; background: #fff; display: block; }
  .doc-canvas { box-shadow: none !important; border: none !important; border-radius: 0 !important; margin: 0 auto !important; }
  @page { size: A4; margin: 0; }
}

/* ---------- Type-ahead autocomplete ---------- */
.ac-dropdown {
  position: absolute; z-index: 1100;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14); display: none;
  max-height: 300px; overflow-y: auto; min-width: 260px;
}
.ac-item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 12px; cursor: pointer; font-size: 13px; line-height: 1.3;
}
.ac-item:hover, .ac-item:focus { background: var(--accent-soft, #eef5fb); }
.ac-name { flex: 1; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-acc { color: var(--accent); font-weight: 600; flex-shrink: 0; }
.ac-town { color: var(--text-2); font-size: 12px; flex-shrink: 0; }

/* ---------- Business performance ---------- */
.card.perf-chart-card { display: flex; flex-direction: column; padding: 20px 22px 22px; overflow: visible; }
.perf-chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.perf-chart-heading { min-width: 0; }
.perf-chart-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.35; }
.perf-chart-sub { margin: 3px 0 0; font-size: 12px; color: var(--text-2); line-height: 1.5; }
.perf-chart-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 14px; border-radius: 7px; cursor: pointer; transition: all .18s ease; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-sm); }

.perf-tool-btn { border: 1px solid var(--border); background: transparent; color: var(--text-2); font: inherit; font-size: 11px; font-weight: 700; letter-spacing: .03em; padding: 7px 11px; border-radius: 7px; cursor: pointer; transition: all .18s ease; }
.perf-tool-btn:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-2); }

.perf-back { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 600; padding: 0 0 12px; cursor: pointer; }
.perf-back:hover { text-decoration: underline; }

.perf-years { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.perf-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all .18s ease; }
.perf-chip .perf-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.perf-chip:hover { border-color: var(--border-strong); color: var(--text); }
.perf-chip.active { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.perf-chip:not(.active) { opacity: .5; }
.perf-chip:not(.active) .perf-dot { filter: grayscale(1); }

.perf-chart-wrap { position: relative; height: 320px; }

/* Top customers ranking */
.card.perf-top-card { display: block; padding: 20px 22px; overflow: hidden; }
.perf-top-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.perf-top-head h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.35; }
.perf-top-head a { font-size: 12.5px; font-weight: 600; color: var(--accent); text-decoration: none; }
.perf-top-head a:hover { text-decoration: underline; }
.perf-top-list { list-style: none; margin: 0; padding: 0; }
.perf-top-list li { border-top: 1px solid var(--border); }
.perf-top-list li:first-child { border-top: 0; }
.perf-top-list a { display: flex; align-items: center; gap: 14px; padding: 10px 4px; text-decoration: none; color: var(--text); transition: background .15s ease; }
.perf-top-list a:hover { background: var(--surface-2); }
.perf-top-rank { flex: none; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 700; }
.perf-top-list li:nth-child(1) .perf-top-rank { background: var(--accent); color: #fff; }
.perf-top-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.perf-top-val { flex: none; font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.perf-top-empty { border-top: 0 !important; padding: 12px 4px; color: var(--text-2); font-size: 13px; }

.fact-sub.delta { font-weight: 650; }
.delta-up { color: #16a34a; }
.delta-down { color: #dc2626; }

/* ---------- Keyboard-first: F-key command bar ---------- */
.phx-fkeybar {
  position: fixed;
  left: 250px;
  right: 0;
  bottom: 0;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.05);
  z-index: 60;
  font-size: 12px;
  user-select: none;
}

/* Field hint line — shows the active field's name/description above the F-key bar */
.phx-field-hint {
  position: fixed; left: 0; right: 0; bottom: 46px;
  height: 26px; display: flex; align-items: center;
  padding: 0 18px;
  background: #000; color: #ffffff;
  border-top: 1px solid #ff5555;
  font-family: 'Plex Mono', 'Courier New', Consolas, monospace;
  font-size: 13px; z-index: 59;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  user-select: none;
}
.phx-field-hint:empty { display: none; }
/* The field-status line reads as a stray label ("Company name", "Company Reg No")
   with a red rule above the F-key bar on every form — the field's label is already
   right above each input, so the status line is redundant and disabled globally. */
#phx-field-hint { display: none !important; }

.fk-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.fk-key:hover:not(.fk-disabled) { background: var(--surface-2); color: var(--text); }
.fk-key.fk-disabled { opacity: .3; cursor: default; }
.fk-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  box-shadow: 0 1px 0 var(--border-strong);
}
.fk-esc {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-3);
  font-size: 11.5px;
}
.fk-esc::before {
  content: "Esc";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 700;
}

/* Row highlight for arrow-key list navigation */
tr.kb-active td,
tr.kb-active th { background: var(--accent-soft); }
[data-kb-item].kb-active { background: var(--accent-soft); }

/* Sidebar number jump badges (assigned by keyboard.js) */
.sidebar nav a.nav-item { position: relative; }
.nav-num {
  margin-left: auto;
  min-width: 17px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 3px;
  flex: none;
}
.nav-item:hover .nav-num,
.nav-item.active .nav-num { color: var(--accent); border-color: var(--accent); }

/* Help overlay (F1 / ?) */
.phx-help {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center; justify-content: center;
  z-index: 300;
}
.phx-help.open { display: flex; }
.phx-help-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  max-width: 440px; width: calc(100% - 48px);
  max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.phx-help-inner h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.phx-help-inner ul { list-style: none; margin: 0; padding: 0; }
.phx-help-inner li {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 0; border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.phx-help-inner li:last-child { border-bottom: 0; }
.phx-help-inner kbd {
  flex: none; min-width: 34px; text-align: center;
  padding: 2px 8px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  font-family: inherit; font-size: 12px; font-weight: 700;
  color: var(--text);
}
.phx-help-inner li span { color: var(--text-2); }

/* Autocomplete keyboard highlight */
.ac-dropdown .ac-item.ac-active { background: var(--accent-soft); }

/* ============ Legacy-style screen chrome (v1.26.23) ============ */
/* Body is now a vertical stack (topbar -> titlebar -> content), no sidebar. */
body { display: block; }

.content {
  margin-left: 0;
  width: 100%;
  padding: 20px 40px 108px;
  min-width: 0;
}

.phx-fkeybar { left: 0; }

/* Top brand bar (sticky) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 0; margin: 0; border: 0;
  text-decoration: none; color: inherit; flex-shrink: 0;
}
.brand-logo { max-height: 40px; }

/* Screen title bar */
.titlebar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 40px 16px;
}
.titlebar h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; }
.crumb { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.crumb a { color: var(--text-2); text-decoration: none; }
.crumb a:hover { color: var(--accent); }

/* Main menu screen */
.menu-screen { max-width: 760px; margin: 0 auto; }
.menu-list { display: flex; flex-direction: column; gap: 5px; }
.menu-item {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-decoration: none; color: var(--text);
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.menu-item:hover { border-color: var(--accent); background: var(--surface-2); }
.menu-item.kb-active { border-color: var(--accent); background: var(--accent-soft); }
.menu-item.disabled { opacity: .45; cursor: default; }
.menu-item.disabled:hover { border-color: var(--border); background: var(--surface); }
.submenu-item.disabled { opacity: .45; cursor: default; }
.submenu-item.disabled:hover { background: transparent; }
.submenu-item.disabled .submenu-item-label em { font-style: italic; opacity: .8; }
.menu-num {
  flex: none; width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 700; font-size: 16px;
  box-shadow: 0 2px 6px rgba(32, 128, 192, 0.25);
}
.menu-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.menu-label { font-weight: 600; font-size: 15px; }
.menu-desc { font-size: 12.5px; color: var(--text-2); }
.menu-chev { flex: none; width: 18px; height: 18px; color: var(--text-3); }
.menu-lock { flex: none; width: 16px; height: 16px; color: var(--text-3); }

/* Live-operations status strip under the main menu */
.menu-status {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 22px;
}
.menu-status-item {
  display: flex; flex-direction: column; gap: 3px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-decoration: none; color: var(--text);
  transition: border-color .15s ease;
}
.menu-status-item:hover { border-color: var(--accent); }
.ms-label { font-size: 12px; color: var(--text-2); }
.ms-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Three-column sub-menu (bordered boxes, like the legacy screen) */
.submenu {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 1000px;
  margin: 0 auto;
}
.submenu-col {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.submenu-col-head {
  padding: 10px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-2);
}
.submenu-list { list-style: none; margin: 0; padding: 6px 0; }
.submenu-list li { margin: 0; }
.submenu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  color: var(--text); text-decoration: none; font-size: 14px;
  transition: background .12s ease;
}
.submenu-item:hover { background: var(--surface-2); }
.submenu-item.kb-active { background: var(--accent-soft); }
.submenu-num {
  flex: none; width: 22px; text-align: right;
  color: var(--text-3); font-weight: 600; font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.submenu-item:hover .submenu-num, .submenu-item.kb-active .submenu-num { color: var(--accent-ink); }
.submenu-item-label { flex: 1; min-width: 0; }

/* The empty-state card used by module_menu */
.submenu .card.empty { max-width: 960px; margin: 0 auto; }

@media (max-width: 900px) {
  .submenu { grid-template-columns: 1fr; }
  .content { padding: 16px 20px 108px; }
  .titlebar { padding: 18px 20px 12px; }
}



/* ================= RETRO DOS TERMINAL THEME ================= */
/* Faithful to the legacy Clipper app: blue title bar, blue section
   headings, red box borders, light-grey reverse-video highlight, light-grey
   text on black. Monospace + larger, filling the screen. */

@font-face { font-family: 'Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/IBMPlexMono-400.woff2') format('woff2'); }
@font-face { font-family: 'Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/IBMPlexMono-500.woff2') format('woff2'); }
@font-face { font-family: 'Plex Mono'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/IBMPlexMono-700.woff2') format('woff2'); }

:root {
  --bg: #000000;
  --surface: #000000;
  --surface-2: #181818;
  --sidebar: #000000;
  --text: #aaaaaa;
  --text-2: #8a8a8a;
  --text-3: #5a5a5a;
  --border: #555555;
  --border-strong: #7a7a7a;
  --accent: #2080c0;
  --accent-ink: #2080c0;
  --accent-soft: rgba(32, 128, 192, 0.16);
  --accent-grad: #2080c0;
  --success: #2080c0;
  --danger: #ff5555;
  --shadow-sm: none;
  --shadow-md: none;
  --radius: 0px;
  --radius-sm: 0px;
}

body {
  font-family: 'Plex Mono', 'Courier New', Consolas, 'Lucida Console', monospace;
  font-size: 18px;
  background: #000;
  color: var(--text);
  letter-spacing: 0;
}

/* ---- Black top title bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  min-height: 80px;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 20px;
  background: #000000;
  color: #2080c0;
  border-bottom: 1px solid #1c1c1c;
  font-size: 16px;
}
.topbar .brand { display: inline-flex; align-items: center; gap: 0; padding: 0; margin: 0; border: 0; text-decoration: none; color: #2080c0; }
.topbar .brand-name { font-size: 18px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: #2080c0; }
.topbar .brand-sub { display: none; }
.topbar .brand-mark { display: none; }
.topbar .brand-logo { max-height: 60px; width: auto; }
.topbar-clock { color: #2080c0; font-weight: 400; }
.topbar-clock .clock-dot { color: #2080c0; }
.beta-badge { color: #2080c0; background: transparent; border: 1px solid #2080c0; }
.user-chip { color: #2080c0; border-color: rgba(32,128,192,0.5); }
.user-chip .user-avatar { background: #2080c0; color: #ffffff; }

/* ---- Black screen title bar ---- */
.titlebar {
  display: flex; align-items: center; justify-content: center;
  position: relative;
  gap: 16px;
  max-width: 100%; margin: 0;
  padding: 6px 16px;
  background: #000000;
  color: #ffffff;
  border-bottom: 1px solid #1c1c1c;
}
.titlebar h1 { font-size: 20px; font-weight: 700; color: #ffffff; letter-spacing: 0.04em; text-align: center; text-transform: uppercase; }
.crumb, .crumb a { color: #2080c0; }
.crumb { position: absolute; right: 16px; }

/* ---- Content ---- */
.content { padding: 12px 24px 56px; max-width: none; }

/* ---- Boxed main menu (red border, blue title) ---- */
.menu-box {
  border: 5px double #ff5555;
  background: #000;
  max-width: 820px;
  margin: 0 auto;
}
.menu-box-title {
  background: #2080c0; color: #fff;
  padding: 5px 12px; text-align: center;
  font-weight: 700; font-size: 18px; letter-spacing: 0.06em; text-transform: uppercase;
}
.menu-list { padding: 8px 14px; gap: 0; }
.menu-item {
  display: block; padding: 7px 8px;
  color: #aaaaaa; text-decoration: none; font-size: 19px; line-height: 1.25;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.menu-item .menu-num { color: #ff5555; font-weight: 700; font-size: inherit; background: transparent; box-shadow: none; border-radius: 0; min-width: 2ch; height: auto; display: inline-block; text-align: right; margin-right: 14px; padding: 0; }
.menu-item .menu-label { font-size: inherit; }
.menu-item:hover { background: #222222; }
.menu-item.kb-active { background: #aaaaaa; color: #000000; }
.menu-item.kb-active .menu-num { color: #000000; }
.menu-item.disabled { color: #5a5a5a; }
.menu-item.disabled .menu-num { color: #5a5a5a; }
.menu-item.disabled:hover { background: transparent; }

/* ---- Sub-menu: three red boxes with black headings ---- */
.submenu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: none; margin: 0 auto; }
.submenu-col { border: 5px double #ff5555; background: #000; border-radius: 0; overflow: hidden; }
.submenu-col-head {
  background: #000000; color: #fff;
  padding: 5px 10px; text-align: center;
  font-size: 16px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  border-bottom: 1px solid #1c1c1c;
}
.submenu-list { list-style: none; margin: 0; padding: 8px 0; }
.submenu-list li { margin: 0; }
.submenu-item { display: flex; align-items: baseline; gap: 10px; padding: 6px 14px; color: #aaaaaa; text-decoration: none; font-size: 18px; text-transform: uppercase; letter-spacing: 0.03em; }
.submenu-item:hover { background: #222222; }
.submenu-item.kb-active { background: #aaaaaa; color: #000; }
.submenu-num { flex: none; width: 24px; text-align: right; color: #ffffff; font-weight: 700; font-size: inherit; }
.submenu-item.kb-active .submenu-num { color: #000; }

/* ---- Status strip ---- */
.menu-status {
  max-width: 820px; margin: 10px auto 0;
  display: flex; flex-wrap: wrap; gap: 8px 28px;
  padding-top: 8px; border-top: 1px solid #555;
}
.menu-status-item { display: inline-flex; gap: 10px; color: #8a8a8a; text-decoration: none; font-size: 15px; border: none; padding: 0; }
.menu-status-item:hover { color: #ffffff; }
.ms-value { color: #ffffff; font-weight: 700; }

/* ---- F-key footer (reverse video light bar) ---- */
.phx-fkeybar {
  background: #aaaaaa; color: #000000;
  height: 42px; padding: 0 14px;
  border-top: none; box-shadow: none;
  font-size: 15px;
}
.fk-key { color: #000000; padding: 4px 10px; }
.fk-key:hover { background: #cccccc; }
.fk-badge { background: #000000; color: #aaaaaa; border: 1px solid #000; box-shadow: none; font-weight: 700; }
.fk-label { color: #000000; }
.fk-esc { color: #000000; }
.fk-esc::before { background: #000000; color: #aaaaaa; border-color: #000; }

/* ---- Data screens: cards/tables/buttons inherit the retro palette ---- */
.card { background: #000; border: 1px solid #555; border-radius: 0; box-shadow: none; }
.card h2 { color: #ffffff; }
.card.wide { padding: 0; }
table { color: var(--text); }
th { color: #ffffff; }
.btn-primary { background: #2080c0; color: #ffffff; border: none; border-radius: 0; }
.btn-ghost { background: transparent; color: #aaaaaa; border: 1px solid #555; border-radius: 0; }
a { color: #2080c0; }
.nav-num { color: #5a5a5a; border-color: #555; }

/* ---- Retro form fields (red = borders, white text, black bg) ---- */
.form-field input, .form-field select, .form-field textarea {
  background: #000; color: #ffffff; border: 1px solid #ff5555; border-radius: 0;
  padding: 7px 10px; font-size: 16px; font-family: inherit;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none; border-color: #ff5555; background: #aaaaaa; color: #000000; box-shadow: none;
}
.form-field label { color: #ffffff; }

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

/* ============ FULL-SCREEN RESPONSIVE (fill the monitor) ============ */
/* Fonts + spacing scale with viewport width so the retro screen uses the
   whole browser window and re-sizes with the monitor. */
body { font-size: clamp(15px, 1.5vw, 24px); }
.topbar { font-size: clamp(14px, 1.3vw, 20px); padding: clamp(8px, 0.8vw, 12px) clamp(14px, 1.5vw, 28px); }
.topbar .brand-name { font-size: clamp(16px, 1.6vw, 26px); }
.titlebar { padding: clamp(4px, 0.6vw, 10px) clamp(12px, 1.5vw, 28px); }
.titlebar h1 { font-size: clamp(17px, 1.8vw, 28px); }
.content { padding: clamp(14px, 2vw, 36px); padding-bottom: 72px; }

.menu-box { max-width: 940px; width: 100%; margin: 0 auto; }
.menu-item { font-size: clamp(19px, 2vw, 32px); line-height: 1.15; padding: clamp(3px, 0.4vw, 7px) clamp(10px, 1.1vw, 18px); }
.menu-status { max-width: none; font-size: clamp(13px, 1.2vw, 18px); gap: clamp(6px, 1.5vw, 30px); }

.submenu { gap: clamp(8px, 1.2vw, 20px); }
.submenu-col-head { font-size: clamp(13px, 1.25vw, 19px); padding: clamp(3px, 0.45vw, 7px); }
.submenu-item { font-size: clamp(14px, 1.35vw, 21px); padding: clamp(3px, 0.4vw, 7px) clamp(10px, 1.3vw, 24px); }
.submenu-num { width: clamp(20px, 2.2vw, 40px); }

.phx-fkeybar { height: clamp(38px, 5vw, 56px); font-size: clamp(13px, 1.2vw, 18px); }
.phx-field-hint { bottom: clamp(38px, 5vw, 56px); }
.fk-badge { min-width: clamp(22px, 2vw, 34px); height: clamp(20px, 2vw, 32px); font-size: clamp(11px, 1vw, 16px); }

/* ============ SPACEX THEME (data-theme="dark") ============ */
/* Same retro layout, but skinned like SpaceX: pure black, white text,
   red accent, clean Inter sans, subtle borders + rounding. */
[data-theme="spacex"] {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #141414;
  --sidebar: #0a0a0a;
  --text: #ffffff;
  --text-2: #9ca3af;
  --text-3: #6b7280;
  --border: #1f2937;
  --border-strong: #374151;
  --accent: #e82127;
  --accent-ink: #ff4d52;
  --accent-soft: rgba(232, 33, 39, 0.14);
  --accent-grad: #e82127;
  --success: #2080c0;
  --danger: #e82127;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.55);
  --radius: 10px;
  --radius-sm: 8px;
}
[data-theme="spacex"] body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: -0.01em;
  background: #000;
  color: #fff;
}
[data-theme="spacex"] .topbar { background: #000; border-bottom: 1px solid #1f2937; }
[data-theme="spacex"] .topbar .brand-name { color: #fff; text-transform: uppercase; letter-spacing: 0.14em; }
[data-theme="spacex"] .topbar-clock { color: #9ca3af; }
[data-theme="spacex"] .user-chip { color: #fff; }
[data-theme="spacex"] .titlebar { background: #000; border-bottom: 1px solid #1f2937; }
[data-theme="spacex"] .titlebar h1 { color: #fff; }
[data-theme="spacex"] .crumb a { color: #9ca3af; }
[data-theme="spacex"] .menu-box { border: 1px solid #1f2937; background: #0a0a0a; }
[data-theme="spacex"] .menu-item { color: #d1d5db; }
[data-theme="spacex"] .menu-item:hover { background: #141414; }
[data-theme="spacex"] .menu-item.kb-active { background: #e82127; color: #fff; }
[data-theme="spacex"] .menu-item .menu-num { color: #e82127; }
[data-theme="spacex"] .menu-item.kb-active .menu-num { color: #fff; }
[data-theme="spacex"] .menu-item.disabled { color: #4b5563; }
[data-theme="spacex"] .submenu-col { border: 1px solid #1f2937; background: #0a0a0a; border-radius: 10px; }
[data-theme="spacex"] .submenu-col-head { background: #111; color: #fff; border-bottom: 1px solid #1f2937; }
[data-theme="spacex"] .submenu-item { color: #d1d5db; }
[data-theme="spacex"] .submenu-item:hover { background: #141414; }
[data-theme="spacex"] .submenu-item.kb-active { background: #e82127; color: #fff; }
[data-theme="spacex"] .submenu-num { color: #e82127; }
[data-theme="spacex"] .submenu-item.kb-active .submenu-num { color: #fff; }
[data-theme="spacex"] .menu-status { border-top-color: #1f2937; }
[data-theme="spacex"] .menu-status-item { color: #9ca3af; }
[data-theme="spacex"] .ms-value { color: #fff; }
[data-theme="spacex"] .phx-fkeybar { background: #0a0a0a; color: #d1d5db; border-top: 1px solid #1f2937; box-shadow: none; }
[data-theme="spacex"] .fk-key { color: #d1d5db; }
[data-theme="spacex"] .fk-key:hover { background: #141414; }
[data-theme="spacex"] .fk-badge { background: #1f2937; color: #fff; border-color: #374151; }
[data-theme="spacex"] .fk-label { color: #d1d5db; }
[data-theme="spacex"] .fk-esc { color: #6b7280; }
[data-theme="spacex"] .fk-esc::before { background: #1f2937; color: #fff; border-color: #374151; }
[data-theme="spacex"] .card { background: #0a0a0a; border: 1px solid #1f2937; border-radius: 10px; box-shadow: var(--shadow-sm); }
[data-theme="spacex"] .card h2 { color: #fff; }
[data-theme="spacex"] th { color: #fff; }
[data-theme="spacex"] .btn-primary { background: #e82127; color: #fff; border-radius: 8px; }
[data-theme="spacex"] a { color: #e82127; }
[data-theme="spacex"] .nav-num { color: #6b7280; border-color: #374151; }

/* Theme toggle button — retro text button (retro theme only; the light/dark
   themes use the circular sun/moon icon button defined near the top). */
[data-theme="retro"] .theme-toggle {
  font: inherit; font-size: 13px; font-weight: 700; letter-spacing: 0.08em;
  color: #ffffff;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 0;
  padding: 4px 10px;
  cursor: pointer;
  text-transform: uppercase;
}
[data-theme="retro"] .theme-toggle:hover { background: rgba(255,255,255,0.12); }

/* ============ LIGHT THEME (data-theme="swan") — light version of the retro console ============ */
/* Same layout + mono font as the dark look, just light colours + red accent. */
[data-theme="swan"] {
  --bg: #e8e8e8;
  --surface: #ffffff;
  --surface-2: #f2f2f2;
  --sidebar: #ffffff;
  --text: #1a1a1a;
  --text-2: #4a4a4a;
  --text-3: #7a7a7a;
  --border: #c8c8c8;
  --border-strong: #9a9a9a;
  --accent: #d00000;
  --accent-ink: #b00000;
  --accent-soft: rgba(208, 0, 0, 0.10);
  --accent-grad: #d00000;
  --success: #2080c0;
  --danger: #d00000;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.10);
  --radius: 0px;
  --radius-sm: 0px;
}

[data-theme="swan"] body { background: var(--bg); color: var(--text); }

/* topbar — light bar, swan blue text */
[data-theme="swan"] .topbar { background: #ffffff; color: #2080c0; border-bottom: 1px solid var(--border); }
[data-theme="swan"] .topbar .brand { color: #2080c0; }
[data-theme="swan"] .topbar .brand-name { color: #2080c0; }
[data-theme="swan"] .topbar-clock { color: #2080c0; }
[data-theme="swan"] .topbar-clock .clock-dot { color: #2080c0; }
[data-theme="swan"] .beta-badge { color: #2080c0; border-color: #2080c0; }
[data-theme="swan"] .user-chip { color: #2080c0; border-color: rgba(32,128,192,0.5); }
[data-theme="swan"] .user-chip .user-avatar { background: #2080c0; color: #ffffff; }
[data-theme="swan"] .theme-toggle { color: #2080c0; border-color: var(--border-strong); }
[data-theme="swan"] .theme-toggle:hover { background: var(--accent-soft); }

/* titlebar matches the background */
[data-theme="swan"] .titlebar { background: #e8e8e8; color: #1a1a1a; border-bottom: 1px solid var(--border); }
[data-theme="swan"] .titlebar h1 { color: #000000; }
[data-theme="swan"] .crumb, [data-theme="swan"] .crumb a { color: #2080c0; }

/* menu box — red double border, bg matches page, black text */
[data-theme="swan"] .menu-box { border: 5px double #d00000; background: #e8e8e8; }
[data-theme="swan"] .menu-item { color: #000000; }
[data-theme="swan"] .menu-item .menu-num { color: #d00000; background: transparent; box-shadow: none; }
[data-theme="swan"] .menu-item:hover { background: #dcdcdc; }
[data-theme="swan"] .menu-item.kb-active { background: #9a9a9a; color: #000000; }
[data-theme="swan"] .menu-item.kb-active .menu-num { color: #000000; }
[data-theme="swan"] .menu-item.disabled { color: #999999; }

/* status strip */
[data-theme="swan"] .menu-status { border-top-color: var(--border); }
[data-theme="swan"] .menu-status-item { color: var(--text-2); }
[data-theme="swan"] .menu-status-item:hover { color: #000000; }
[data-theme="swan"] .ms-value { color: #000000; }

/* sub-menu — red double border, headings match background */
[data-theme="swan"] .submenu-col { border: 5px double #d00000; background: #e8e8e8; }
[data-theme="swan"] .submenu-col-head { background: #e8e8e8; color: #000000; border-bottom: 1px solid var(--border); }
[data-theme="swan"] .submenu-item { color: #000000; }
[data-theme="swan"] .submenu-item:hover { background: #dcdcdc; }
[data-theme="swan"] .submenu-item.kb-active { background: #9a9a9a; color: #000; }
[data-theme="swan"] .submenu-num { color: #d00000; }
[data-theme="swan"] .submenu-item.kb-active .submenu-num { color: #000; }

/* F-key bar — light reverse bar */
[data-theme="swan"] .phx-fkeybar { background: #d0d0d0; color: #000000; box-shadow: none; border-top: none; }
[data-theme="swan"] .fk-key { color: #000000; }
[data-theme="swan"] .fk-key:hover { background: #c0c0c0; }
[data-theme="swan"] .fk-badge { background: #000000; color: #e0e0e0; border-color: #000; box-shadow: none; }
[data-theme="swan"] .fk-label { color: #000000; }
[data-theme="swan"] .fk-esc { color: #000000; }
[data-theme="swan"] .fk-esc::before { background: #000000; color: #e0e0e0; border-color: #000; }

/* cards / tables / buttons / links */
[data-theme="swan"] .card { background: #ffffff; border: 1px solid var(--border-strong); border-radius: 0; box-shadow: none; }
[data-theme="swan"] .card h2 { color: #1a1a1a; }
[data-theme="swan"] th { color: #1a1a1a; }
[data-theme="swan"] .btn-primary { background: #d00000; color: #ffffff; border-radius: 0; }
[data-theme="swan"] .btn-ghost { color: #4a4a4a; border-color: var(--border-strong); }
[data-theme="swan"] a { color: #d00000; }
[data-theme="swan"] .nav-num { color: #7a7a7a; border-color: var(--border-strong); }

/* form fields — light, red border, blue label */
[data-theme="swan"] .form-field input, [data-theme="swan"] .form-field select, [data-theme="swan"] .form-field textarea {
  background: #ffffff; color: #1a1a1a; border: 1px solid #d00000; border-radius: 0;
}
[data-theme="swan"] .form-field input:focus, [data-theme="swan"] .form-field select:focus, [data-theme="swan"] .form-field textarea:focus {
  border-color: #2080c0; background: #ffffff; box-shadow: none; outline: none;
}
[data-theme="swan"] .form-field label { color: #2080c0; }

/* ===== Legacy screen layout — faithful field grid (Orders / job entry) ===== */
.legacy-form { max-width: none; margin: 0 auto; }

/* Field-name labels uppercase (keyboard-first console look). */
.lf label, .form-field > label { text-transform: uppercase; letter-spacing: 0.02em; }

/* F-key bar navigation pills (↑↓ ←→ Enter Esc) — display-only, same style. */
.fk-nav { pointer-events: none; }

/* Retro form preview — black bg, white field text, red = borders (?retro=1). */
.retro-form, .retro-form .legacy-panel, .retro-form .card { background: #000; }
.retro-form .legacy-panel, .retro-form .card { border: 4px double #ff5555; }
.retro-form .lf label { color: #ffffff; }
.retro-form .lf input, .retro-form .lf select, .retro-form .lf textarea,
.retro-form .legacy-lines input, .retro-form .legacy-lines select { color: #fff; background: #000; border-color: #ff5555; }
.retro-form .legacy-lines th, .retro-form .card h2 { color: #ffffff; }
.legacy-panel {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.legacy-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.2fr 0.95fr;
  gap: 12px 26px;
  font-family: 'Plex Mono', 'Courier New', Consolas, monospace;
  font-size: 13px;
}
.lf { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.lf label {
  flex: 0 0 112px;
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap;
}
.lf input, .lf select {
  flex: 1 1 auto;
  min-width: 0;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-strong);
  border-radius: 0;
  padding: 2px 2px 4px;
}
.lf input:focus, .lf select:focus { outline: none; border-bottom-color: var(--accent); }
.lf textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 58px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 8px 10px;
  resize: vertical;
}
.lf textarea:focus { outline: none; border-color: var(--accent); }
.lf-notes { grid-column: 1 / -1; align-items: flex-start; margin-top: 6px; }
.lf input:disabled { color: var(--text-2); border-bottom-style: dotted; cursor: default; }
.lf-empty { min-height: 1px; }
.lf-value {
  flex: 1;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border-strong);
  padding: 2px 2px 4px;
}
.legacy-lines th { font-family: 'Plex Mono', monospace; font-size: 12px; }
.legacy-lines td.line-no { color: var(--text-2); }
.legacy-lines input { font-family: 'Plex Mono', monospace; font-size: 13px; }
.legacy-add { padding: 12px 16px; border-top: 1px solid var(--border); }

/* ===== Retro input forms — red = borders, white text, black bg ===== */
.legacy-form .legacy-panel { border: 4px double #ff5555; border-radius: 0; }
.legacy-form .lf label { color: #ffffff; font-size: 16px; }
.legacy-form .lf input, .legacy-form .lf select, .legacy-form .lf textarea,
.legacy-form .lf-value { color: #ffffff; font-size: 16px; }
.legacy-form .lf input, .legacy-form .lf select { border-bottom-color: #ff5555; }
.legacy-form .lf textarea { border-color: #ff5555; }
.legacy-form .lf input:focus, .legacy-form .lf select:focus { border-bottom-color: #ff5555; background: #aaaaaa; color: #000000; }
.legacy-form .lf textarea:focus { border-color: #ff5555; background: #aaaaaa; color: #000000; box-shadow: none; }
.legacy-form .lf input:disabled { color: #6a6a6a; }
.legacy-form .legacy-lines th, .legacy-form .line-table th { color: #ffffff; }
.legacy-form .line-table input, .legacy-form .line-table select,
.legacy-form .legacy-lines input, .legacy-form .legacy-lines select { color: #ffffff; border-color: #ff5555; }
.legacy-form .line-table td { color: #ffffff; }
.legacy-form .seal-spec label, .legacy-form .seal-field > label { color: #ffffff; }
.legacy-form .legacy-add { border-top-color: #ff5555; }
.legacy-form .legacy-add .btn-ghost { color: #ffffff; border-color: #ff5555; }

/* Card-based forms (invoice / enquiry / PO) — standard card border + white heading. */
.form-card .card { border: 1px solid #555; border-radius: 0; }
.form-card .card h2 { color: #ffffff; }
@media (max-width: 860px) { .legacy-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .legacy-grid { grid-template-columns: 1fr; } }
