/* ══════════════════════════════════════════════════════════════════════════
   Corebalt Back Office — shared design system (docs/platform/ui-style.md).
   Soft neutral canvas, white panels, fine borders, high-contrast text; brand blue only for the primary
   action and meaningful states; navy rail. Every colour is a token below, so the light and dark themes
   are one set of rules. Every page styles itself through these shared classes (.card, table, button,
   input, .pill, .toolbar, .row ...): restyling here restyles the whole back office.
   Theme: follows the system; <html data-theme="light|dark"> (the top bar's switch) overrides it.
   ══════════════════════════════════════════════════════════════════════════ */
:root {
  color-scheme: light;
  --bg: #F4F5F7;           /* content canvas */
  --bg-sunken: #F9FAFB;    /* table header, inset panels */
  --panel: #FFFFFF;
  --panel-hover: #F7F8FA;
  --line: #E2E5EA;         /* card / table border */
  --line-soft: #EDEFF2;    /* row dividers */
  --ink: #111827;          /* headings */
  --ink-2: #273142;        /* body */
  --muted: #5F6B7A;
  --muted-2: #8A94A3;
  --accent: #2F6FE4;       /* Corebalt blue, primary actions */
  --accent-strong: #2560CC;
  --accent-deep: #1F51AE;
  --accent-soft: #EBF2FE;
  --accent-ring: rgba(47,111,228,0.22);
  --on-accent: #FFFFFF;
  --coral: #E8674A;        /* badges, unread dots */
  --sidebar: #16223f;      /* brand navy rail */
  --sidebar-hover: #1f2d50;
  --sidebar-fg: #EEF3FB;
  --sidebar-text: #B4C0D6;
  --sidebar-muted: #8fa1c0;
  --sidebar-line: rgba(140,160,200,0.26);
  --input-line: #D3D8DF;
  --danger: #B42318;
  --danger-soft: #FEF1F0;
  --danger-line: #F7D2CE;
  --ok: #1A7F37;
  --ok-soft: #E8F5EC;
  --warn: #8A5A00;
  --warn-soft: #FDF4E1;
  --info: #2F6FE4;
  --info-soft: #EBF2FE;
  --ok-line: #A9D8B6;
  --warn-line: #EBCB8B;
  --info-line: #B6CDF6;
  --violet: #6D4BC0;       /* a fourth state where three are taken (a walk-in beside booked / confirmed / done) */
  --violet-soft: #F1ECFA;
  --violet-line: #C9B8EA;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-btn: 0 1px 1px rgba(17,24,39,0.08);
  --shadow-pop: 0 12px 32px rgba(17,24,39,0.16);
  --scrim: rgba(17,24,39,0.45);
  /* legacy aliases kept so any older rule or inline reference still resolves */
  --navy: #16223f;
  --navy-2: #1f2d50;
}

/* Dark: the same tokens, night values. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1217; --bg-sunken: #12171E; --panel: #161C24; --panel-hover: #1B222C;
  --line: #29313C; --line-soft: #212832;
  --ink: #EDF1F5; --ink-2: #D2D9E1; --muted: #98A3B1; --muted-2: #77818E;
  --accent: #4B86F0; --accent-strong: #5C93F3; --accent-deep: #7AA8F6; --accent-soft: rgba(75,134,240,0.16);
  --accent-ring: rgba(75,134,240,0.35); --on-accent: #FFFFFF;
  --coral: #F07A5F;
  --sidebar: #0B111C; --sidebar-hover: #16203A; --sidebar-line: rgba(140,160,200,0.18);
  --input-line: #343E4B;
  --danger: #F2827A; --danger-soft: rgba(242,130,122,0.12); --danger-line: rgba(242,130,122,0.30);
  --ok: #5CC77E; --ok-soft: rgba(92,199,126,0.13);
  --warn: #E4B04F; --warn-soft: rgba(228,176,79,0.14);
  --info: #7AA8F6; --info-soft: rgba(75,134,240,0.16);
  --ok-line: rgba(92,199,126,0.35); --warn-line: rgba(228,176,79,0.38); --info-line: rgba(122,168,246,0.38);
    --violet: #B8A2F0; --violet-soft: rgba(184,162,240,0.14); --violet-line: rgba(184,162,240,0.36);
  --shadow-btn: none; --shadow-pop: 0 12px 32px rgba(0,0,0,0.5); --scrim: rgba(0,0,0,0.6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0E1217; --bg-sunken: #12171E; --panel: #161C24; --panel-hover: #1B222C;
    --line: #29313C; --line-soft: #212832;
    --ink: #EDF1F5; --ink-2: #D2D9E1; --muted: #98A3B1; --muted-2: #77818E;
    --accent: #4B86F0; --accent-strong: #5C93F3; --accent-deep: #7AA8F6; --accent-soft: rgba(75,134,240,0.16);
    --accent-ring: rgba(75,134,240,0.35); --on-accent: #FFFFFF;
    --coral: #F07A5F;
    --sidebar: #0B111C; --sidebar-hover: #16203A; --sidebar-line: rgba(140,160,200,0.18);
    --input-line: #343E4B;
    --danger: #F2827A; --danger-soft: rgba(242,130,122,0.12); --danger-line: rgba(242,130,122,0.30);
    --ok: #5CC77E; --ok-soft: rgba(92,199,126,0.13);
    --warn: #E4B04F; --warn-soft: rgba(228,176,79,0.14);
    --info: #7AA8F6; --info-soft: rgba(75,134,240,0.16);
    --ok-line: rgba(92,199,126,0.35); --warn-line: rgba(228,176,79,0.38); --info-line: rgba(122,168,246,0.38);
    --violet: #B8A2F0; --violet-soft: rgba(184,162,240,0.14); --violet-line: rgba(184,162,240,0.36);
    --shadow-btn: none; --shadow-pop: 0 12px 32px rgba(0,0,0,0.5); --scrim: rgba(0,0,0,0.6);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Segoe UI', 'Segoe UI Variable', system-ui, -apple-system, 'Inter', sans-serif;
  font-size: 13.5px; line-height: 1.45; color: var(--ink-2); background: var(--bg); -webkit-font-smoothing: antialiased; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
h1 { font-size: 20px; font-weight: 650; color: var(--ink); letter-spacing: -0.2px; margin: 0 0 6px; }
h2 { font-size: 15px; font-weight: 650; color: var(--ink); margin: 18px 0 8px; }
h3 { font-size: 13.5px; font-weight: 650; color: var(--ink); margin: 14px 0 6px; }
p { margin: 0 0 10px; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@keyframes cbPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.32; } }

.layout { display: flex; min-height: 100vh; }

/* ═══════════ Sidebar (navy rail) ═══════════ */
.sidebar { width: 236px; flex: none; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 12px 0 10px; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 2px 16px 12px; }
.sidebar .brand .logo { width: 24px; height: 24px; object-fit: contain; }
.sidebar .brand .logo-plate, .sidebar .brand > img.logo { display: inline-flex; align-items: center;
  justify-content: center; width: 34px; height: 34px; background: var(--sidebar-hover);
  border-radius: var(--radius); flex: 0 0 auto; padding: 5px; }
.sidebar .brand .logo-plate .logo { width: 100%; height: 100%; }
.sidebar .brand .brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0;
  font-size: 14px; font-weight: 650; color: var(--sidebar-fg); }
.sidebar .brand .biz { font-size: 11.5px; font-weight: 500; color: var(--sidebar-muted); margin-top: 1px; }
.sidebar nav { display: flex; flex-direction: column; gap: 1px; padding: 0 8px; overflow-y: auto; flex: 1; }

/* Collapsible group: native <details>; <summary> = clickable header. */
.sidebar nav .nav-group-wrap { border-radius: var(--radius-sm); }
.sidebar nav .nav-group { list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 600; color: var(--sidebar-muted); }
.sidebar nav .nav-group::-webkit-details-marker { display: none; }
.sidebar nav .nav-group:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.sidebar nav details[data-nav-active="true"] > .nav-group { color: var(--sidebar-fg); }
.sidebar nav .nav-ico { display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 16px; width: 16px; height: 16px; opacity: 0.9; }
.sidebar nav .nav-ico svg { width: 16px; height: 16px; }
.sidebar nav .nav-group-title { flex: 1; white-space: nowrap; }
.sidebar nav .nav-caret { width: 10px; height: 10px; margin-left: 4px; opacity: 0.7; flex: none;
  background: no-repeat center/10px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M4 2.5 7.5 6 4 9.5' stroke='%23B9C6DE' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  transition: transform .15s ease; }
.sidebar nav details[open] > .nav-group .nav-caret { transform: rotate(90deg); }
.sidebar nav .nav-group .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--coral);
  flex: none; animation: cbPulse 2.4s ease-in-out infinite; }
.sidebar nav details[open] > .nav-group .dot { display: none; }

.sidebar nav .nav-group-items { display: flex; flex-direction: column; gap: 1px; padding: 2px 0 6px; }
.sidebar nav a { color: var(--sidebar-text); height: 31px; padding: 0 10px 0 36px; border-radius: var(--radius-sm);
  font-size: 13px; display: flex; align-items: center; justify-content: space-between; position: relative; }
.sidebar nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-fg); text-decoration: none; }
.sidebar nav a.active { background: var(--sidebar-hover); color: var(--sidebar-fg); font-weight: 600; }
.sidebar nav a.active::before { content: ""; position: absolute; left: 22px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px; background: #6FA0FF; }
.sidebar nav a .badge { display: inline-flex; align-items: center; justify-content: center;
  min-width: 19px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--coral);
  color: #2A130D; font-size: 10.5px; font-weight: 700; }

/* Rail status card + sign out */
.sidebar .rail-status { margin: 10px 12px 6px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--sidebar-hover); border: 1px solid var(--sidebar-line); }
.sidebar .rail-status .row1 { display: flex; align-items: center; gap: 8px; font-size: 12px;
  font-weight: 600; color: var(--sidebar-fg); }
.sidebar .rail-status .live { width: 7px; height: 7px; border-radius: 50%; background: #4FBF7E;
  animation: cbPulse 2s ease-in-out infinite; }
.sidebar .rail-status .sub { font-size: 11.5px; color: var(--sidebar-muted); margin-top: 4px; line-height: 1.45; }
.sidebar .logout { padding: 8px 12px 2px; }
.sidebar .logout button { width: 100%; background: transparent; color: var(--sidebar-text);
  border: 1px solid var(--sidebar-line); border-radius: var(--radius-sm); padding: 8px; height: 34px; cursor: pointer;
  font-size: 13px; font-weight: 600; box-shadow: none; }
.sidebar .logout button:hover { color: #fff; border-color: var(--accent); background: var(--sidebar-hover); }

/* ═══════════ Main column + topbar ═══════════ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar { flex: none; height: 50px; display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar .where { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .where b { color: var(--ink); font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .userchip { display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 4px 0 12px;
  border-radius: 99px; background: var(--panel); border: 1px solid var(--line); flex: none; }
.topbar .userchip .name { font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.topbar .userchip .avatar { width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(140deg,#4D8BFF,#16223f); display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 10px; font-weight: 700; }
/* The theme switch (light / dark / follow the system). */
.topbar .theme-switch { width: 30px; height: 30px; padding: 0; border-radius: 99px; background: var(--panel);
  color: var(--muted); border: 1px solid var(--line); box-shadow: none; flex: none; }
.topbar .theme-switch:hover { background: var(--panel-hover); color: var(--ink); }
.topbar .theme-switch svg { width: 15px; height: 15px; }

/* Which department these screens are for. Shown only where there is a real choice to make. */
.topbar .areapick { display: flex; align-items: center; gap: 7px; flex: none; margin: 0; }
.topbar .areapick label { font-size: 12px; color: var(--muted); margin: 0; font-weight: 500; }
.topbar .areapick select { height: 30px; padding: 0 26px 0 10px; font-size: 12.5px; font-weight: 600;
  border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }

/* Content */
.content { flex: 1; min-width: 0; overflow: auto; padding: 20px 24px 28px; }

/* ═══════════ Tables ═══════════ */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--ink-2); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); font-size: 13px;
  font-variant-numeric: tabular-nums; vertical-align: middle; }
th { background: var(--bg-sunken); color: var(--muted); font-weight: 600; font-size: 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--panel-hover); }
td.num, th.num, td.n, th.n { text-align: right; white-space: nowrap; }
.inactive td { color: var(--muted); }
tfoot td, tr.total td { font-weight: 650; background: var(--bg-sunken); }

/* ═══════════ Cards / forms / buttons ═══════════ */
.toolbar { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 14px; font-weight: 650; color: var(--ink); margin: 0 0 10px; }
.card > :last-child { margin-bottom: 0; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 5px; }
input, select, textarea { padding: 7px 10px; height: 36px; border: 1px solid var(--input-line);
  border-radius: var(--radius-sm); font: inherit; font-size: 13.5px; color: var(--ink-2); background: var(--panel);
  width: 100%; max-width: 340px; outline: none; font-variant-numeric: tabular-nums; }
textarea { height: auto; min-height: 72px; }
select[multiple], select[size]:not([size="1"]) { height: auto; min-height: 96px; padding: 4px; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--bg-sunken); color: var(--muted); }
input[type=checkbox], input[type=radio] { width: auto; height: auto; accent-color: var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1; min-width: 150px; }

/* One primary action per task (the default button); the rest are .ghost (quiet) or .link. */
button, .btn { background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); border-radius: var(--radius-sm);
  padding: 0 14px; height: 34px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 7px; box-shadow: var(--shadow-btn); line-height: 1; white-space: nowrap; }
button:hover, .btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); text-decoration: none; color: var(--on-accent); }
button.ghost, .btn.ghost, button.quiet, .btn.quiet { background: var(--panel); color: var(--ink-2); border: 1px solid var(--line); box-shadow: none; }
button.ghost:hover, .btn.ghost:hover, button.quiet:hover, .btn.quiet:hover { background: var(--panel-hover); color: var(--ink); border-color: var(--input-line); }
button.danger, .btn.danger { background: var(--panel); color: var(--danger); border: 1px solid var(--danger-line); box-shadow: none; }
button.danger:hover, .btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
button.link, .btn.link { background: none; border: none; box-shadow: none; color: var(--accent); padding: 0 2px; height: auto; font-weight: 600; }
button.link:hover, .btn.link:hover { background: none; color: var(--accent-deep); text-decoration: underline; }
button.small, .btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
button:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.error { color: var(--danger); background: var(--danger-soft); border: 1px solid var(--danger-line);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; }

/* Messages: .notice (information), .notice.ok (done), .notice.warn (needs attention); .error above. */
.notice { color: var(--ink-2); background: var(--info-soft); border: 1px solid var(--line);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; margin: 0 0 12px; }
.notice.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.notice.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }

/* ═══════════ Shared building blocks (docs/platform/ui-style.md) ═══════════ */
.muted { color: var(--muted); }
.small:not(button):not(.btn), .hint { font-size: 12px; color: var(--muted); }
.hint { margin: 4px 0 0; line-height: 1.45; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.cluster { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }

/* A section heading with its count and one action on the right. */
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 8px; }
.section-head h2 { margin: 0; }
.section-head .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.section-head .end { margin-left: auto; display: flex; gap: 8px; }

/* Compact summary rows: a label, its value or count, an action. Also an empty section's single row. */
.summary { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.summary-row { display: flex; align-items: center; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--line-soft); min-height: 40px; }
.summary-row:last-child { border-bottom: none; }
.summary-row .label { flex: 1; min-width: 0; color: var(--ink-2); }
.summary-row .value { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.summary-row .meta { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); font-size: 13px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 14px; }

/* A detail grid: label over value, several to a row. */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 18px; margin: 0; }
.detail-grid > div { min-width: 0; }
.detail-grid dt, .detail-grid .k { font-size: 12px; color: var(--muted); margin: 0 0 2px; }
.detail-grid dd, .detail-grid .v { margin: 0; color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
table.kv { border: none; background: transparent; }
table.kv th { background: transparent; border: none; color: var(--muted); font-weight: 500; font-size: 12.5px; width: 160px; padding: 5px 12px 5px 0; }
table.kv td { border: none; padding: 5px 0; }
table.kv tbody tr:hover td { background: transparent; }

/* Editing tucked away: <details class="edit"><summary>Change ...</summary> ...form... </details>. */
details.edit, details.section { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 14px; }
details.edit > summary, details.section > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; font-weight: 600; color: var(--ink); min-height: 40px; }
details.edit > summary::-webkit-details-marker, details.section > summary::-webkit-details-marker { display: none; }
details.edit > summary::before, details.section > summary::before { content: ""; width: 7px; height: 7px; flex: none;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .15s ease; }
details.edit[open] > summary::before, details.section[open] > summary::before { transform: rotate(45deg); }
details.edit > summary .meta, details.section > summary .meta { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--muted); }
details.edit, details.section { padding: 0 14px; }
details.edit[open], details.section[open] { padding-bottom: 14px; }
details.edit > summary, details.section > summary { margin: 0 -14px; }
details.edit > summary:hover, details.section > summary:hover { background: var(--panel-hover); border-radius: var(--radius); }
details.inline { display: inline-block; }
details.inline > summary { cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; }
details.inline > summary::-webkit-details-marker { display: none; }

/* Key points: a long explanation reduced to short headings, one line each, side by side.
   <div class="keypoints"><div><h3>Rule priority</h3><p>Each car uses its class rule, or the default.</p></div>...</div> */
.keypoints { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.keypoints > h2 { grid-column: 1 / -1; margin: 0; font-size: 14px; }
.keypoints h3 { margin: 0 0 3px; font-size: 13px; font-weight: 600; color: var(--ink); }
.keypoints p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* A row of real buttons where links used to sit (secondary navigation, related pages). */
.button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.button-row a { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); font-size: 13px; font-weight: 600; }
.button-row a:hover { background: var(--panel-hover); color: var(--ink); text-decoration: none; }
.button-row a.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.button-row a.primary:hover { background: var(--accent-strong); }
.button-row svg { width: 15px; height: 15px; }

/* A large money figure: <div class="amount"><span class="cur">KES</span> 13,500<span class="dec">.00</span></div> */
.amount { font-size: 30px; font-weight: 650; color: var(--ink); letter-spacing: -0.5px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.amount .cur { font-size: 13px; font-weight: 500; color: var(--muted); margin-right: 4px; letter-spacing: 0; }
.amount .dec { font-size: 18px; color: var(--muted); }
.amount-label { font-size: 12.5px; color: var(--muted); margin: 0 0 2px; }
/* A side panel's primary action fills its width. */
.card > button.block, .card .block, button.block, .btn.block { width: 100%; height: 40px; }

/* Small tag beside a name (Default, Express, In package). */
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border: 1px solid var(--line); border-radius: 5px;
  font-size: 11.5px; color: var(--muted); background: var(--panel); margin-left: 8px; vertical-align: middle; }

.tag.ok { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, var(--line)); }
.tag.warn { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, var(--line)); }
.tag.danger { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
td > .tag:first-child { margin-left: 0; }

/* A key-value list: <dl class="kv"><dt>Paybill</dt><dd>880100</dd>...</dl> */
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* A checkbox (or radio) with its words in one row, anywhere. */
.checkline { display: flex; align-items: center; gap: 8px; min-height: 30px; font-size: 13px; color: var(--ink-2); margin: 0; font-weight: 400; }
.checkline input { margin: 0; }
/* A summary that should look like the page's primary action ("+ Add a rule"). */
details > summary.btn, details > summary.primary { list-style: none; display: inline-flex; width: auto; }
details > summary.btn::-webkit-details-marker { display: none; }

/* Read by screen readers, not shown. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ═══════════ Login ═══════════ */
.login-card { max-width: 360px; margin: 12vh auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; box-shadow: var(--shadow-pop); }
.login-card h1 { text-align: center; }
.login-card p { text-align: center; color: var(--muted); margin-top: 0; }
.login-card input { max-width: none; }
.login-card button { width: 100%; margin-top: 16px; height: 40px; }

/* ═══════════ Pills (statuses across pages) ═══════════ */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: var(--line-soft); color: var(--muted); line-height: 1.6; }
.pill.on, .pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad, .pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--info-soft); color: var(--info); }

/* ═══════════ Page header (title + one line + the page's primary action) ═══════════ */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 4px; }
.page-head .titles { flex: 1; min-width: 0; }
.page-head .titles h1 { margin: 0; }
.page-head p, p.lead { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 6px 0 0; max-width: 760px; }
.page-head .head-action { flex: none; display: flex; gap: 8px; }

/* ═══════════ Stat tiles ═══════════ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 14px 0; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin: 0; }
.stat .value { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.stat .value .n { font-size: 20px; font-weight: 650; color: var(--ink); letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .value .n.alert { color: var(--danger); }
.stat .value .note { font-size: 12px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ═══════════ Quick-action chips ═══════════ */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.chip { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-2); font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap; }
.chip:hover { background: var(--panel-hover); text-decoration: none; color: var(--ink); }
.chip.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); box-shadow: var(--shadow-btn); }
.chip.primary:hover { background: var(--accent-strong); color: var(--on-accent); }

/* ═══════════ Grouped card-forms (Details / Pricing / Stock ...) ═══════════ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; margin-top: 14px;
  align-items: start; }
.form-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; }
.form-card > h3 { font-size: 14px; font-weight: 650; color: var(--ink); margin: 0; }
.form-card > .sub { font-size: 12px; color: var(--muted); margin: 3px 0 0; line-height: 1.45; }
.form-card .fields { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.form-card .field { flex: 1 1 150px; min-width: 150px; display: flex; flex-direction: column; }
.form-card .field.wide { flex: 1 1 100%; }
.form-card .field label { margin: 0 0 5px; }
.form-card .field input, .form-card .field select, .form-card .field textarea { max-width: none; width: 100%; }
.form-card .field input[type=checkbox] { width: auto; }
.form-card .field .checkline { display: flex; align-items: center; gap: 8px; min-height: 34px; font-size: 13px; color: var(--ink-2); }
.form-card .actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.form-card .actions button, .form-card .actions .btn { height: 34px; }
/* a full-width form card that should span the whole grid row */
.form-card.span-all { grid-column: 1 / -1; }
.field { margin: 0; }
.field label { margin: 0 0 5px; }

/* Tabbed form: a segmented control above a single card; one panel visible at a time. */
.form-tabs { display: inline-flex; flex-wrap: wrap; background: var(--bg-sunken); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 3px; gap: 2px; margin: 14px 0 10px; max-width: 100%; }
.form-tab { background: transparent; color: var(--muted); border: none; box-shadow: none; height: 30px;
  padding: 0 14px; border-radius: 5px; font-size: 13px; font-weight: 600; cursor: pointer; }
.form-tab:hover { background: var(--panel-hover); color: var(--ink); }
.form-tab.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(17,24,39,0.08); }
.form-tab-panel { display: none; }
.form-tab-panel.active { display: block; }

/* ═══════════ Module manager ═══════════ */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.module { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px; background: var(--panel); cursor: pointer; }
.module.on { border-color: var(--accent); background: var(--accent-soft); }
.module strong { display: block; font-size: 13.5px; color: var(--ink); }
.module .module-desc { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Account payment method: the till picker shows only for cash (PaymentMethodFields.razor). */
.pm-fields { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pm-fields .pm-till { display: none; }
.pm-fields:has(select.pm-method option[value="Cash"]:checked) .pm-till { display: inline; }

/* ══════════════════════════════════════════════════════════════════════════
   TABLETS AND SMALL SCREENS
   Adapts on two axes: by WIDTH, and separately by POINTER, because a finger needs a bigger target than a
   mouse does however wide the screen is. No page markup changes: the nav sections are <details>.
   ══════════════════════════════════════════════════════════════════════════ */

/* Landscape tablet: the rail still fits beside the content, it just stops taking so much. */
@media (max-width: 1180px) {
  .sidebar { width: 204px; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px 16px 24px; }
}

/* The menu button and the drawer's switch exist at every width; only a phone shows them. */
.nav-toggle { display: none; }
.menu-btn { display: none; align-items: center; justify-content: center; width: 38px; height: 38px; flex: none;
  margin-right: 8px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  cursor: pointer; }
.menu-btn svg { width: 20px; height: 20px; }
.nav-backdrop { display: none; }

/* Portrait tablet and narrower: the SIDEBAR is still the navigation for every user. It slides in from the left
   OVER the page, opened by the menu button in the top bar; a tap on the backdrop, or on a link, closes it. No JS. */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .menu-btn { display: inline-flex; }

  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 284px; max-width: 86vw; z-index: 80;
    transform: translateX(-100%); transition: transform .18s ease-out; overflow-y: auto; }
  .nav-toggle:checked ~ .sidebar { transform: none; box-shadow: var(--shadow-pop); }
  .nav-backdrop { position: fixed; inset: 0; z-index: 70; background: var(--scrim); }
  .nav-toggle:checked ~ .nav-backdrop { display: block; }
  .sidebar .rail-status { display: none; }

  .topbar { height: auto; min-height: 50px; flex-wrap: wrap; padding: 8px 14px; }
  .content { padding: 14px 14px 22px; }

  /* A table too wide to fit scrolls sideways INSIDE its own box. */
  .content table { display: block; overflow-x: auto; min-width: 100%; }
  .page-head { flex-wrap: wrap; }
}

/* Touch, at any width. 34px is comfortable with a mouse and fiddly without one. */
@media (pointer: coarse) {
  button, .btn { height: 42px; }
  button.link, .btn.link { height: auto; }
  input, select, textarea { height: 42px; }
  select[multiple], select[size]:not([size="1"]) { height: auto; }
  input[type=checkbox], input[type=radio] { height: auto; }
  .sidebar nav a { min-height: 40px; }
  th, td { padding: 12px 12px; }
}

/* Page links under a long table (Shared/Pager.razor): fifty rows a page, the rest a link away. */
.pager { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px 16px;
  margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.pager-links { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager-links a, .pager-links strong, .pager-links .off, .pager-links .gap { display: inline-block; min-width: 28px;
  padding: 3px 8px; border-radius: var(--radius-sm); text-align: center; line-height: 1.4; }
.pager-links a { color: var(--accent); }
.pager-links a:hover { background: var(--panel-hover); text-decoration: none; }
.pager-links strong { background: var(--accent); color: var(--on-accent); }
.pager-links .off { color: var(--muted-2); }
.pager-links .gap { color: var(--muted-2); min-width: 0; }

/* ═══════════ Report header: range, quick picks, downloads (Shared/ReportRange.razor) ═══════════ */
.report-range { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.report-range .rr-exports { display: flex; gap: 8px; margin-left: auto; }
.report-range .rr-picks { display: flex; gap: 6px; flex-wrap: wrap; flex-basis: 100%; }
.rr-pick { display: inline-flex; align-items: center; height: 28px; padding: 0 11px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.rr-pick:hover { background: var(--panel-hover); color: var(--ink); text-decoration: none; }
.rr-pick.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
/* The Reports hub: one entry per report */
.report-hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 8px; }
.report-hub .rh-card { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--panel); color: var(--ink); }
.report-hub .rh-card:hover { text-decoration: none; border-color: var(--accent); }
.report-hub .rh-card strong { font-size: 13.5px; font-weight: 600; }
.report-hub .rh-card span { font-size: 12.5px; color: var(--muted); }
.report-hub h2 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 18px 0 6px; }

/* Printing: paper is always light, and the chrome stays off it. */
@media print {
  :root { color-scheme: light; --bg: #fff; --panel: #fff; --bg-sunken: #fff; --ink: #000; --ink-2: #111; --line: #ccc; --line-soft: #ddd; --muted: #444; }
  .sidebar, .topbar, .nav-backdrop, .menu-btn, .no-print { display: none !important; }
  .content { padding: 0; overflow: visible; }
}

/* ── How a bill is paid (Shared/PaymentPicker): Cash, M-Pesa, Card or Split, the car wash's rules everywhere ── */
.pp { display: grid; gap: 8px; }
.pp-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.pp-pick button { height: 34px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink-2); box-shadow: none; font-weight: 600; }
.pp-pick button:hover { border-color: var(--accent); color: var(--accent-deep); background: var(--panel); }
.pp-pick button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep); }
.pp-row { display: grid; gap: 4px; }
.pp-l { font-size: 12.5px; color: var(--muted); margin: 0; }
.pp-with { display: flex; gap: 6px; align-items: center; }
.pp-with input { flex: 1; margin: 0; max-width: none; }
.pp-row > input, .pp-into { margin: 0; max-width: none; width: 100%; }
.pp-note { margin: 0; font-size: 12.5px; color: var(--muted); }
.pp-note.warn { color: var(--danger); }
.pp-split { display: grid; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-sunken); }
.pp-split .sr { display: flex; align-items: center; gap: 10px; }
.pp-split .sr .m { width: 64px; font-weight: 600; font-size: 13px; }
.pp-split .sr input { flex: 1; margin: 0; height: 36px; max-width: none; }
.pp-split .sr b { flex: 1; text-align: right; font-variant-numeric: tabular-nums; }
.pp-split .sr.cash { border-top: 1px dashed var(--line); padding-top: 6px; }
.pp-split .sr.tot { font-size: 14px; }
.pp-split > input, .pp-split > select { margin: 0; max-width: none; width: 100%; }

/* Form checks as you go (js/forms.js): the field that is wrong, and what is wrong with it. */
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger, #c0392b); box-shadow: 0 0 0 3px var(--danger-soft, rgba(192, 57, 43, .15)); }
.field-error { margin-top: 4px; font-size: 12px; font-weight: 500; color: var(--danger, #c0392b); }
