/* =========================================================================
   Invoice Generator — design system

   Typography: a condensed display face leads headers; body text uses the
   normal-width counterpart, so hierarchy reads structurally, not by size.
   Colour: neutrals sit on hue ~190 at low saturation, giving a slight teal
   cast that relates to the hue-212 blue accent instead of reading as
   generic grey.
   ========================================================================= */

:root {
  /* --- Type ------------------------------------------------------------ */
  --font-display: "Avenir Next Condensed", "Helvetica Neue", Inter, system-ui, sans-serif;
  --font-body: "Avenir Next", "Helvetica Neue", Inter, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* --- Colour: LIGHT (neutrals hue 190, sat 9–20%) --------------------- */
  --bg: #F9FBFB;
  --surface: #FFFFFF;
  --surface-alt: #F1F5F6;
  --border: #D9E1E2;
  --border-strong: #C0CBCE;
  --text: #1C2526;
  --text-muted: #617275;
  --accent: #1671DA;
  --accent-hover: #1365C3;
  --accent-soft: #E9F2FC;
  --on-accent: #FFFFFF;
  --success: #1F8667;
  --warning: #CA850F;
  --danger: #CE2D27;

  /* --- Geometry -------------------------------------------------------- */
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(28, 37, 38, .05), 0 4px 16px rgba(28, 37, 38, .06);
  --shadow-lg: 0 12px 40px rgba(28, 37, 38, .14);
  --maxw: 1180px;
}

[data-theme="dark"] {
  --bg: #131A1B;
  --surface: #1B2325;
  --surface-alt: #232D2F;
  --border: #313D3F;
  --border-strong: #465558;
  --text: #EEF1F2;
  --text-muted: #9CA8AB;
  --accent: #549EF2;
  --accent-hover: #77B3F8;
  --accent-soft: #1F3247;
  --on-accent: #0C1620;
  --success: #45C49E;
  --warning: #EBAF47;
  --danger: #E45D58;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
}

/* =========================================================================
   Base
   ========================================================================= */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color .18s ease, color .18s ease;
}

h1, h2, h3, h4, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .01em;
  margin: 0;
  color: var(--text);
}

h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 20px; line-height: 1.25; }
h3 { font-size: 16px; line-height: 1.3; }

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

.mono, .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.muted { color: var(--text-muted); }
.small { font-size: 13px; }

/* =========================================================================
   Top bar
   ========================================================================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  height: 62px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: .015em;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  flex: none;
}

.nav { display: flex; gap: 4px; margin-left: 8px; }

.nav a {
  font-family: var(--font-display);
  letter-spacing: .015em;
  font-size: 15px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.nav a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
/* accent-hover, not accent — the plain accent only clears 4.2:1 on the soft
   tint, the deeper shade clears AA at 5.05:1. */
.nav a.active { background: var(--accent-soft); color: var(--accent-hover); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Theme toggle — top right on every page */
.theme-toggle {
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.theme-toggle:hover {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border-strong);
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* Drive status pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
  white-space: nowrap;
}
.pill:hover { border-color: var(--border-strong); color: var(--text); }

/* "Take a tour" launcher in the top bar */
.tour-launch svg { width: 15px; height: 15px; }
.tour-launch:hover {
  color: var(--accent);
  border-color: var(--accent);
}
@media (max-width: 560px) {
  .tour-launch .pill-label { display: none; }
}
.pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border-strong);
  flex: none;
}
.pill.connected { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.pill.connected .dot { background: var(--success); }

/* =========================================================================
   Layout
   ========================================================================= */

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 30px 24px 44px; }

.page-head { margin-bottom: 26px; }
.page-head p { margin: 6px 0 0; color: var(--text-muted); font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
.card-head h2 { font-size: 17px; text-transform: uppercase; letter-spacing: .03em; }
.card-head .spacer { margin-left: auto; }
.card-head p { margin: 2px 0 0; font-size: 13px; color: var(--text-muted); }

/* collapsible sections */
.card-head.is-toggle { cursor: pointer; }
.card-toggle {
  margin-left: 8px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.card-toggle:hover { color: var(--text); }
.card-toggle svg { transition: transform .18s ease; }
/* when the head has no spacer sibling, push the toggle to the far right */
.card-head.is-toggle > .card-toggle:first-of-type { margin-left: auto; }
.card-head.is-toggle .spacer ~ .card-toggle { margin-left: 8px; }

.card.collapsed > *:not(.card-head) { display: none; }
.card.collapsed > .card-head { border-bottom: none; }
.card.collapsed .card-toggle svg { transform: rotate(-90deg); }

.card-body { padding: 20px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-full { grid-column: 1 / -1; }

/* Extra payment methods — a header row with an add button, then label/value
   rows each with a delete button. */
.pay-methods-head { display: flex; align-items: flex-start; gap: 12px; }
.pay-methods-head .spacer { margin-left: auto; }
.pay-method-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
@media (max-width: 640px) {
  .pay-method-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
}

/* =========================================================================
   Forms
   ========================================================================= */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

label, .label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: .005em;
}

input[type="text"], input[type="number"], input[type="email"],
input[type="tel"], input[type="date"], input[type="url"],
select, textarea {
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance: none;
  appearance: none;
}

input[type="number"], .num-input { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Hex colour input paired with a native swatch picker. */
.color-field { display: flex; align-items: center; gap: 8px; }
.color-field input[type="text"] { flex: 1; text-transform: uppercase; }
.color-field input[type="color"] {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-field input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }

textarea { resize: vertical; min-height: 84px; line-height: 1.5; }

select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23617275' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  padding-right: 32px;
}
[data-theme="dark"] select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239CA8AB' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .65; }

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(.75);
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.check input[type="checkbox"] {
  width: 17px; height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

.hint { font-size: 12.5px; color: var(--text-muted); }

/* Small "?" badge that reveals a help text on hover (native title tooltip). */
.hint-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px; height: 15px;
  margin-left: 6px;
  border-radius: 50%;
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
  user-select: none;
}
.hint-icon:hover { border-color: var(--accent); color: var(--accent); }

/* Read-only "how this prints" footer preview on the Generate page. Mirrors the
   layout produced by tools/pdf_builder.py — two columns above a hairline rule. */
.footer-preview {
  display: grid;
  grid-template-columns: 52% 48%;
  gap: 24px;
  padding: 18px 20px;
  background: var(--surface-alt);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}
@media (max-width: 640px) {
  .footer-preview { grid-template-columns: 1fr; gap: 18px; }
}
.footer-preview-col:empty { display: none; }
.fp-section {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 8px;
}
.fp-lines { font-size: 13px; line-height: 1.75; color: var(--text); margin: 0; }
.fp-lines b { font-weight: 700; }
.fp-terms { margin-top: 10px; font-size: 13px; color: var(--text); }
.fp-muted { color: var(--text-muted); font-style: italic; }

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 500;
  padding: 9px 17px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn:hover { background: var(--surface-alt); border-color: var(--border-strong); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-lg { font-size: 16px; padding: 12px 26px; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); border-color: transparent; }

.btn-danger-ghost {
  background: transparent; border-color: transparent;
  color: var(--text-muted); padding: 6px 8px;
}
.btn-danger-ghost:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger); border-color: transparent;
}

/* Row reorder arrows in the SKU catalog */
.row-actions { display: inline-flex; align-items: center; gap: 2px; }
.btn-move {
  background: transparent; border-color: transparent;
  color: var(--text-muted); padding: 4px 6px; font-size: 11px; line-height: 1;
}
.btn-move:hover:not(:disabled) {
  background: var(--surface-alt); color: var(--text); border-color: transparent;
}

/* Segmented control — the Invoice / Quotation toggle */
.segmented {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}
.segmented button {
  font-family: var(--font-display);
  letter-spacing: .015em;
  font-size: 14.5px;
  font-weight: 600;
  padding: 7px 20px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.segmented button:hover { color: var(--text); }
.segmented button.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}

/* =========================================================================
   Tables
   ========================================================================= */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data th {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  white-space: nowrap;
}

table.data td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data tbody tr:hover { background: var(--surface-alt); }
table.data tbody tr:last-child td { border-bottom: none; }

table.data td input, table.data td select {
  padding: 7px 9px;
  font-size: 14px;
}

.col-right { text-align: right; }
.col-right input { text-align: right; }

.row-total {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

/* ---- Sections & sub-items in the line-item / catalog tables ---------------- */
table.data tr.line-section > td { background: var(--accent-soft); }
.section-head { display: flex; align-items: center; gap: 10px; }
.sec-badge {
  flex: none;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  color: var(--accent); background: var(--surface);
  border: 1px solid var(--accent); border-radius: 999px; padding: 2px 9px;
  white-space: nowrap;
}
.sec-title { font-weight: 600; flex: 1; }
.btn-sub {
  flex: none; padding: 5px 11px; font-size: 13px;
  color: var(--accent); border-color: transparent;
}
.btn-sub:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* Sub-item rows sit under their section with a small indent + accent rail. */
table.data tr.line-subitem > td:first-child { box-shadow: inset 3px 0 0 var(--accent-soft); }
.desc-cell { display: flex; align-items: center; gap: 8px; }
.desc-cell input { flex: 1; }
.line-num {
  flex: none;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--text-muted);
  min-width: 26px; text-align: right;
}

/* Tax column: charge tax, and whether the printed line says so. */
.tax-cell { display: flex; justify-content: center; gap: 10px; }
.tax-opt {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer; user-select: none;
}
.tax-opt input[type="checkbox"] {
  width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer;
}
.tax-opt span { font-size: 10.5px; color: var(--text-muted); }

/* "+ Sub-item" affordance row inside a catalog bundle. */
table.data tr.bundle-add > td { padding-top: 4px; padding-bottom: 10px; }
table.data tr.bundle-add > td { box-shadow: inset 3px 0 0 var(--accent-soft); }

/* Bundle marker in the Generate page SKU picker. */
.pi-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .05em;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 4px; padding: 1px 5px; vertical-align: middle;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* =========================================================================
   Totals panel
   ========================================================================= */

.totals {
  margin-left: auto;
  width: 340px;
  max-width: 100%;
}

.totals-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14.5px;
}
.totals-row .label { color: var(--text-muted); font-size: 14px; }
.totals-row .value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.totals-row.grand {
  margin-top: 10px;
  padding: 14px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
}
.totals-row.grand .label {
  color: var(--on-accent);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .02em;
  opacity: .92;
}
.totals-row.grand .value { font-size: 20px; font-weight: 700; color: var(--on-accent); }

/* =========================================================================
   Logo preview
   ========================================================================= */

.logo-box {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.logo-preview {
  width: 150px; height: 78px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--surface-alt);
  overflow: hidden;
  flex: none;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview span { font-size: 12.5px; color: var(--text-muted); }

/* =========================================================================
   SKU picker
   ========================================================================= */

.picker { position: relative; }

.picker-results {
  position: absolute;
  z-index: 30;
  top: calc(100% + 5px);
  left: 0; right: 0;
  max-height: 300px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: none;
}
.picker-results.open { display: block; }

.picker-item {
  padding: 10px 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.picker-item:last-child { border-bottom: none; }
.picker-item:hover, .picker-item.hi { background: var(--accent-soft); }
.picker-item .pi-main { min-width: 0; flex: 1; }
.picker-item .pi-desc {
  font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.picker-item .pi-sku { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }
.picker-item .pi-price {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* =========================================================================
   Sticky action bar
   ========================================================================= */

.actionbar {
  position: sticky;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  margin-top: 6px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.actionbar .spacer { margin-left: auto; }

/* =========================================================================
   Site footer
   ========================================================================= */

.sitefoot {
  border-top: 1px solid var(--border);
  padding: 22px 24px 30px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.sitefoot strong {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text);
}

/* =========================================================================
   Toasts
   ========================================================================= */

.toasts {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(400px, calc(100vw - 40px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: toast-in .2s ease;
}
.toast.ok { border-left-color: var(--success); }
.toast.warn { border-left-color: var(--warning); }
.toast.err { border-left-color: var(--danger); }
.toast a { font-weight: 500; }
.toast .t-close {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 17px; line-height: 1;
  padding: 0 0 0 6px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .wrap { padding: 22px 16px 36px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .nav a { padding: 7px 10px; font-size: 14px; }
  .brand span:not(.brand-mark) { display: none; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .totals { width: 100%; }
  h1 { font-size: 25px; }
  .actionbar { flex-wrap: wrap; }
}

@media print {
  .topbar, .actionbar, .toasts, .sitefoot { display: none; }
}

/* Demo banner — only rendered when DEMO_MODE is on (see app.py). Uses the
   accent-soft token so it reads as informational rather than as an error, and
   inherits the dark-theme values automatically. */
.demo-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--accent-soft);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.demo-banner strong { color: var(--accent); }

.demo-reset {
  flex: none;
  padding: 4px 12px;
  font: inherit;
  font-size: 12px;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
}

.demo-reset:hover:not(:disabled) {
  color: #fff;
  background: var(--accent);
}

.demo-reset:disabled { opacity: .6; cursor: default; }

/* =========================================================================
   First-visit spotlight tour
   ========================================================================= */

/* Full-screen click blocker — captures interaction while the tour runs.
   The dimmed backdrop itself comes from the ring's giant box-shadow. */
.tour-block {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  cursor: default;
  background: transparent;
  transition: background-color .18s ease;
}
/* Steps without a target (e.g. Welcome) dim the whole screen instead of
   cutting a spotlight hole. */
.tour-block--dim { background: rgba(10, 14, 15, .62); }

/* The transparent "hole" over the highlighted element. Its box-shadow
   paints the surrounding dim, and pointer-events:none lets the shadow
   sit above the page without swallowing clicks (the blocker handles that). */
.tour-ring {
  display: none;
  position: fixed;
  z-index: 10001;
  pointer-events: none;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 9999px rgba(10, 14, 15, .62),
              0 0 0 2px var(--accent),
              0 0 0 6px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: left .18s ease, top .18s ease, width .18s ease, height .18s ease;
}

.tour-pop {
  display: none;
  position: fixed;
  z-index: 10002;
  width: 360px;
  max-width: calc(100vw - 24px);
  padding: 18px 18px 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  transition: left .18s ease, top .18s ease;
}

.tour-count {
  position: absolute;
  top: 16px;
  right: 18px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* "Built by Grunt Digital" line under the Welcome headline. */
.tour-byline {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--accent);
  margin-bottom: 10px;
}

.tour-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 7px;
  padding-right: 52px;
}

.tour-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 14px;
}

.tour-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.tour-check input { accent-color: var(--accent); cursor: pointer; }

.tour-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
/* Skip button with the "Don't show this again" checkbox stacked beneath it. */
.tour-foot-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.tour-nav { display: flex; gap: 8px; }

.tour-pop button {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color .14s ease, border-color .14s ease, color .14s ease;
}

/* Skip — red text, red border, on the bottom-left. */
.tour-skip {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.tour-skip:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* Back — quiet secondary. */
.tour-back {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.tour-back:hover { border-color: var(--text-muted); }

/* Next — solid green so it's the obvious primary action. */
.tour-next {
  background: #B0CF97;
  color: #1C2526;
  border: 1px solid #B0CF97;
}
.tour-next:hover {
  background: #9CBE80;
  border-color: #9CBE80;
}

@media (max-width: 480px) {
  .tour-pop { width: calc(100vw - 24px); }
}
