/* Business system prototype: components. Reused by every page and meant to
   be lifted into customer builds as they are. Lee's rule: buttons, switches,
   segmented buttons and sliders for choices, not checkboxes and dropdowns. */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r-control);
  border: 1px solid transparent; background: var(--accent); color: var(--on-accent);
  font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .15s var(--ease), box-shadow .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }
/* No button is ever white (Lee, 2026-11-12): every variant carries a colour. */
.btn--ghost { background: var(--accent-soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.btn--ghost:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 30%); }
.btn--soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn--soft:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 30%); color: var(--accent-ink); }
/* Darkened a step so white text on it reads at 4.5:1 or better. */
.btn--spark { background: var(--spark-strong); }
.btn--spark:hover { background: color-mix(in srgb, var(--spark-strong) 85%, black); }
.btn--plain { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); color: var(--accent-ink); }
.btn--plain:hover { background: var(--accent-soft); }
.btn--good { background: var(--good-ink); color: #fff; }
.btn--good:hover { background: color-mix(in srgb, var(--good-ink) 85%, black); }
/* WhatsApp: its own green, darkened so white text passes contrast. */
.btn--wa { background: #117A43; color: #fff; }
.btn--wa:hover { background: #0D6537; }
.btn--wa img { width: 16px; height: 16px; flex: none; }
.btn--nowrap, .btn--wa { white-space: nowrap !important; }
.btn--muted { background: color-mix(in srgb, var(--ink-2) 14%, var(--surface)); color: var(--ink); }
.btn--muted:hover { background: color-mix(in srgb, var(--ink-2) 22%, var(--surface)); }
.btn--danger { background: var(--bad-soft); color: var(--bad-ink); }
.btn--danger:hover { background: color-mix(in srgb, var(--bad-soft) 60%, var(--bad) 40%); color: #fff; }
.btn--sm { height: 30px; padding: 0 10px; font-size: var(--fs-xs); }
.btn--lg { height: 44px; padding: 0 20px; font-size: var(--fs-md); }
.btn--icon { width: 36px; padding: 0; }
.btn--icon.btn--sm { width: 30px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Switch (a button with role="switch") ---------- */
.switch {
  --w: 38px; --h: 22px;
  position: relative; flex: none; width: var(--w); height: var(--h); padding: 0;
  border: 0; border-radius: var(--r-pill); background: var(--line-strong);
  transition: background .18s var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: calc(var(--h) - 6px); height: calc(var(--h) - 6px);
  border-radius: var(--r-dot); background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .2s var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(calc(var(--w) - var(--h))); }
.switch--sm { --w: 30px; --h: 18px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Segmented buttons ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: color-mix(in srgb, var(--accent-soft) 75%, var(--surface)); border-radius: calc(var(--r-control) + 2px); flex-wrap: wrap; }
.seg button {
  height: 30px; padding: 0 12px; border: 0; border-radius: var(--r-control); background: transparent;
  color: var(--accent-ink); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg button:hover { background: var(--accent-soft); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-1); }
.seg--sm button { height: 26px; padding: 0 9px; font-size: var(--fs-xs); }
.seg button .dot { width: 8px; height: 8px; border-radius: var(--r-dot); }
.seg--block { display: flex; }
.seg--block button { flex: 1; justify-content: center; }

/* ---------- Choice buttons (a row of buttons where a list would be a dropdown) ---------- */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 6px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); border-radius: var(--r-control);
  background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); color: var(--accent-ink); font-size: var(--fs-sm); font-weight: 500; text-align: left;
  transition: border-color .15s, background .15s, color .15s;
}
.choice:hover { background: var(--accent-soft); border-color: var(--accent); }
.choice svg { width: 15px; height: 15px; }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600; }

/* ---------- Slider ---------- */
.slider { display: grid; gap: 6px; }
.slider__top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: var(--fs-sm); }
.slider__top b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.slider input[type="range"] {
  --pct: 50%;
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent;
}
.slider input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: var(--r-pill);
  background: linear-gradient(to right, var(--accent) 0 var(--pct), var(--line) var(--pct) 100%);
}
.slider input[type="range"]::-moz-range-track { height: 6px; border-radius: var(--r-pill); background: var(--line); }
.slider input[type="range"]::-moz-range-progress { height: 6px; border-radius: var(--r-pill); background: var(--accent); }
.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: var(--r-dot);
  background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow-1);
}
.slider input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: var(--r-dot); background: var(--surface); border: 2px solid var(--accent); }
.slider__ends { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--muted); }

/* ---------- Badges and chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--ink-2);
}
.badge svg { width: 12px; height: 12px; }
.badge--good { background: var(--good-soft); color: var(--good-ink); }
.badge--warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge--bad { background: var(--bad-soft); color: var(--bad-ink); }
.badge--accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge--spark { background: var(--spark-soft); color: color-mix(in srgb, var(--spark) 70%, black); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: var(--r-dot); flex: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surface);
  box-shadow: var(--shadow-1); padding: var(--pad); min-width: 0; display: flex; flex-direction: column; gap: 14px;
}
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card__head h3 { font-size: var(--fs-md); }
.card__head p { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
.card__actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.card--flush { padding: 0; gap: 0; }
.card--flush > .card__head { padding: var(--pad) var(--pad) 12px; }
.card--accent { background: var(--accent); border-color: var(--accent); color: color-mix(in srgb, var(--on-accent) 82%, transparent); }
.card--accent h3, .card--accent .ink { color: var(--on-accent); }
.card__fill { flex: 1; min-height: 0; position: relative; }

/* Layout grids */
.grid { display: grid; gap: var(--gap); min-width: 0; }
.g-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
.span-9 { grid-column: span 9; } .span-12 { grid-column: span 12; }
@media (max-width: 1180px) {
  .span-3 { grid-column: span 6; } .span-4, .span-5 { grid-column: span 6; } .span-7, .span-8, .span-9 { grid-column: span 12; }
  .span-6.keep { grid-column: span 6; }
}
@media (max-width: 760px) { .g-12 > * { grid-column: span 12 !important; } }

/* ---------- Figure tiles ---------- */
.kpi { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: end; }
.kpi__label { grid-column: 1 / -1; font-size: var(--fs-sm); color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi__value { font: 700 var(--fs-3xl) / 1.05 var(--font-head); color: var(--ink); letter-spacing: -0.02em; }
.kpi__value small { font-size: .5em; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi__spark { position: relative; display: block; width: 96px; height: 38px; }
.kpi__spark canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.kpi__delta { grid-column: 1 / -1; font-size: var(--fs-xs); color: var(--muted); display: flex; gap: 6px; align-items: center; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.delta--up { color: var(--good-ink); }
.delta--down { color: var(--bad-ink); }
.delta svg { width: 13px; height: 13px; }

/* Meter */
.meter { display: block; height: 8px; border-radius: var(--r-pill); background: var(--accent-soft); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--accent); width: 0; transition: width .8s var(--ease); }
.meter--spark { background: var(--spark-soft); }
.meter--spark > i { background: var(--spark); }

/* Legend */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-xs); color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: var(--r-small); display: inline-block; }
.legend i.line { height: 2px; width: 14px; border-radius: 2px; }

/* Chart boxes: the height is set on the box, Chart.js fills it */
.chart { position: relative; width: 100%; min-height: 0; }
.chart canvas { width: 100% !important; height: 100% !important; }
.h-140 { height: 140px; } .h-180 { height: 180px; } .h-200 { height: 200px; } .h-220 { height: 220px; }
.h-240 { height: 240px; } .h-260 { height: 260px; } .h-280 { height: 280px; } .h-320 { height: 320px; }

/* ---------- Tabs ---------- */
/* Tabs are buttons (Lee, 2026-11-12: "more obvious and more button like"). */
.tabs { position: relative; display: flex; gap: 8px; padding: 2px 0 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line)); border-radius: var(--r-control);
  background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); color: var(--accent-ink);
  font-weight: 600; white-space: nowrap; flex: none; transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { background: var(--accent-soft); border-color: var(--accent); }
.tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 4px 12px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
.tab .count { font-size: var(--fs-xs); padding: 1px 7px; border-radius: var(--r-pill); background: var(--surface); color: var(--accent-ink); font-weight: 700; }
.tab[aria-selected="true"] .count { background: color-mix(in srgb, var(--on-accent) 22%, transparent); color: var(--on-accent); }
.tabs__bar { display: none; position: absolute; bottom: -1px; left: 0; height: 2px; background: var(--accent); border-radius: 2px; transition: transform .25s var(--ease), width .25s var(--ease); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow: auto; min-height: 0; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.tbl th {
  position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 600; font-size: var(--fs-xs);
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl th.r, .tbl td.r { text-align: right; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
.tbl td.r { font-variant-numeric: tabular-nums; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--surface-2); }
.tbl .who { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.tbl .who b { color: var(--ink); font-weight: 600; display: block; }
.tbl .who small { color: var(--muted); font-size: var(--fs-xs); }

/* ---------- Avatars ---------- */
.av {
  --c: var(--accent); width: 32px; height: 32px; flex: none; border-radius: var(--r-dot); display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 16%, var(--surface)); color: color-mix(in srgb, var(--c) 80%, black);
  font: 700 12px var(--font-head);
}
.av--sm { width: 24px; height: 24px; font-size: 10px; }
.av--lg { width: 52px; height: 52px; font-size: 18px; }
.av-stack { display: flex; }
.av-stack .av { border: 2px solid var(--surface); margin-left: -8px; }
.av-stack .av:first-child { margin-left: 0; }

/* ---------- Inputs ---------- */
.input, .textarea {
  width: 100%; min-height: 38px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-control);
  background: var(--surface); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.field { display: grid; gap: 6px; }
.field > span { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.field > small { font-size: var(--fs-xs); color: var(--muted); }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 34px; }

/* ---------- Lists ---------- */
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.row:last-child { border-bottom: 0; }
.row__main { flex: 1; min-width: 0; }
.row__main b { display: block; color: var(--ink); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__main small { display: block; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.row { width: 100%; border: 0; background: transparent; text-align: left; border-bottom: 1px solid var(--line); border-radius: 0; }
button.row:hover { background: var(--surface-2); }
.ico-tile { width: 34px; height: 34px; flex: none; border-radius: var(--r-small); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.ico-tile svg { width: 17px; height: 17px; }
.ico-tile--spark { background: var(--spark-soft); color: color-mix(in srgb, var(--spark) 75%, black); }
.ico-tile--warn { background: var(--warn-soft); color: var(--warn-ink); }
.ico-tile--bad { background: var(--bad-soft); color: var(--bad-ink); }
.ico-tile--good { background: var(--good-soft); color: var(--good-ink); }

/* ---------- The "this replaces" side note ---------- */
.page__note { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); }
.page__note svg { width: 14px; height: 14px; color: var(--accent-ink); }

/* ---------- Drawer (drill-down from the right, 75% of the screen) ---------- */
.veil { position: fixed; inset: 0; z-index: 60; background: rgba(15, 26, 36, .32); opacity: 0; transition: opacity .22s; }
.veil.on { opacity: 1; }
.drawer {
  position: fixed; z-index: 61; top: 0; right: 0; bottom: 0; width: 75vw; max-width: 100vw;
  background: var(--canvas); box-shadow: var(--shadow-3); display: flex; flex-direction: column;
  transform: translateX(102%); transition: transform .26s var(--ease);
}
.drawer.on { transform: none; }
.drawer__head { flex: none; display: flex; align-items: center; gap: 14px; padding: 16px var(--pad) 0; background: var(--surface); }
.drawer__title { flex: 1; min-width: 0; }
.drawer__title h2 { font-size: var(--fs-xl); }
.drawer__title p { font-size: var(--fs-sm); color: var(--muted); }
.drawer__tabs { flex: none; padding: 12px var(--pad) 0; background: var(--surface); transition: opacity .2s; }
.drawer.editing .drawer__tabs { opacity: .35; pointer-events: none; }
.drawer__body { flex: 1; min-height: 0; overflow: auto; padding: var(--pad); }
@media (max-width: 900px) { .drawer { width: 100vw; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 90; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r-surface); background: var(--ink); color: var(--surface);
  font-size: var(--fs-sm); box-shadow: var(--shadow-2); animation: toastIn .25s var(--ease);
}
.toast svg { width: 16px; height: 16px; color: var(--good); }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Misc ---------- */
.empty { display: grid; place-items: center; gap: 8px; padding: 30px; text-align: center; color: var(--muted); }
.empty svg { width: 28px; height: 28px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; font-size: var(--fs-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.divider { height: 1px; background: var(--line); }
.stack { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.map { width: 100%; border-radius: max(0px, calc(var(--r-surface) - 4px)); overflow: hidden; background: var(--surface-3); }
.map .leaflet-container { font-family: var(--font-body); }
/* Leaflet's panes and controls carry z-indexes of 400 to 1000: keep them
   inside the map so drawers, modals and pop-overs sit above it (Lee, 2026-11-13). */
.map, .leaflet-container { position: relative; z-index: 0; isolation: isolate; }
.pin {
  --c: var(--accent);
  width: 16px; height: 16px; border-radius: var(--r-dot); background: var(--c); border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.pin--lg { width: 22px; height: 22px; }
@media (max-width: 900px) {
  .leaflet-touch .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
  .leaflet-control-attribution a { display: inline-block; padding: 6px 0; }
}
.pin-hit { display: grid !important; place-items: center; background: transparent; border: 0; }
.pin-hit:hover .pin { transform: scale(1.25); }
.pin { transition: transform .15s var(--ease); }
.leaflet-popup-content { margin: 10px 12px; font-size: 13px; }
.leaflet-popup-content b { color: var(--ink); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
/* backwards, not both: a fill that holds a transform makes every card a stacking
   context, which put the search suggestions underneath the table below. */
.rise > * { animation: rise .35s var(--ease) backwards; }
.rise > *:nth-child(2) { animation-delay: .04s; } .rise > *:nth-child(3) { animation-delay: .08s; }
.rise > *:nth-child(4) { animation-delay: .12s; } .rise > *:nth-child(5) { animation-delay: .16s; }
.rise > *:nth-child(6) { animation-delay: .2s; } .rise > *:nth-child(n+7) { animation-delay: .24s; }

/* ---------- Sortable table headers: every column sorts (Lee, 2026-11-12) ---------- */
.tbl th[data-sort] { cursor: pointer; user-select: none; }
.tbl th[data-sort]:hover, .tbl th[data-sort]:focus-visible { color: var(--accent-ink); }
.tbl th[data-sort]::after { content: "\2195"; margin-left: 6px; font-size: 11px; opacity: .45; }
.tbl th[aria-sort="ascending"], .tbl th[aria-sort="descending"] { color: var(--accent-ink); }
.tbl th[aria-sort="ascending"]::after { content: "\25B2"; opacity: 1; font-size: 9px; }
.tbl th[aria-sort="descending"]::after { content: "\25BC"; opacity: 1; font-size: 9px; }

/* ---------- Filter chips: prominent, coloured, with counts ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 14px;
  border: 1.5px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); color: var(--accent-ink);
  font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.filter:hover { background: var(--accent-soft); border-color: var(--accent); }
.filter[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.filter .dot { width: 10px; height: 10px; box-shadow: 0 0 0 2px var(--surface); }
.filter__n { min-width: 26px; height: 24px; padding: 0 8px; border-radius: var(--r-pill); display: inline-grid; place-items: center; background: var(--surface); color: var(--accent-ink); font-size: var(--fs-xs); font-weight: 700; }
.filter[aria-pressed="true"] .filter__n { background: color-mix(in srgb, var(--on-accent) 22%, transparent); color: var(--on-accent); }
.toolbar { position: relative; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar__search { width: min(360px, 100%); }
.toolbar__search .input { min-height: 40px; border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.av--xs { width: 20px; height: 20px; font-size: 9px; margin-left: -6px; }
.filter[aria-pressed="true"] .av--xs { background: var(--surface); }

/* ---------- Predictive search ---------- */
.ta { position: relative; display: block; }
.search > svg { z-index: 2; }
.ta__list {
  position: absolute; z-index: 35; top: calc(100% + 6px); left: 0; right: 0; min-width: 260px; max-height: 340px; overflow: auto;
  padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surface); box-shadow: var(--shadow-2);
}
.ta__item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-control); background: transparent; text-align: left; color: var(--ink-2); }
.ta__item:hover, .ta__item[aria-selected="true"] { background: var(--accent-soft); }
.ta__ico { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: var(--r-small); background: var(--accent-soft); color: var(--accent-ink); }
.ta__ico svg { position: static; transform: none; width: 15px; height: 15px; color: inherit; }
.ta__txt { min-width: 0; }
.ta__txt b { display: block; color: var(--ink); font-weight: 600; font-size: var(--fs-sm); }
.ta__txt small { display: block; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ta mark { background: var(--spark-soft); color: inherit; border-radius: var(--r-small); padding: 0 1px; }

/* ---------- Add and edit forms ---------- */
.edit { gap: 18px; }
.edit__intro { font-size: var(--fs-sm); color: var(--accent-ink); background: var(--accent-soft); padding: 10px 14px; border-radius: var(--r-control); }
.fx-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; align-items: start; }
.fx { align-content: start; }
.fx [data-ct-add] { justify-self: start; }
.fx--full { grid-column: 1 / -1; }
.fx > span .req { color: var(--bad); }
.fx--bad .input, .fx--bad .textarea { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.fx--bad > span { color: var(--bad-ink); }
.money-in { position: relative; display: block; }
.money-in > b { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
.money-in .input { padding-left: 26px; }
.ct-list { display: grid; gap: 8px; }
.ct-row { display: grid; grid-template-columns: 1.2fr 1.3fr 1fr 1.4fr auto auto; gap: 8px; align-items: center; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--r-pill);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface));
  color: var(--accent-ink); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap;
}
.chip-btn svg { width: 14px; height: 14px; }
.chip-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.chip-btn.on { background: var(--warn-soft); border-color: var(--warn); color: var(--warn-ink); }
.edit__err { color: var(--bad-ink); background: var(--bad-soft); padding: 10px 14px; border-radius: var(--r-control); font-size: var(--fs-sm); font-weight: 600; }
.edit__foot { position: sticky; bottom: calc(-1 * var(--pad)); z-index: 2; display: flex; gap: 10px; padding: 14px 0 0; margin-bottom: -4px; background: var(--surface); border-top: 1px solid var(--line); }
.ico-tile--lg { width: 52px; height: 52px; border-radius: var(--r-surface); }
.ico-tile--lg svg { width: 24px; height: 24px; }
@media (max-width: 700px) {
  .fx-grid { grid-template-columns: minmax(0, 1fr); }
  .ct-row { grid-template-columns: 1fr 1fr; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-control); }
}

/* ---------- Modal (Customise this) ---------- */
.modal-veil { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 16px; background: rgba(15, 26, 36, .45); animation: m-fade .18s; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-surface); box-shadow: var(--shadow-2); animation: m-up .22s var(--ease); }
.modal--wide { width: min(880px, 100%); }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 14px; }
.modal__head h2 { font-size: var(--fs-xl); }
.modal__head p { margin-top: 6px; color: var(--ink-2); font-size: var(--fs-sm); }
.modal__body { flex: 1; min-height: 0; overflow: auto; padding: 4px 24px 18px; }
.modal__foot { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 24px 20px; border-top: 1px solid var(--line); }
.ideas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.idea { display: flex; gap: 12px; padding: 14px; border-radius: var(--r-surface); background: var(--surface-2); border: 1px solid var(--line); }
.idea b { display: block; color: var(--ink); font-size: var(--fs-sm); }
.idea p { margin-top: 4px; font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.5; }
@media (max-width: 700px) { .ideas { grid-template-columns: minmax(0, 1fr); } }
/* Customise this: easier to read (Lee, 2026-11-13: text 16px, headings 25% bigger). */
.modal--custom { width: min(960px, 100%); }
.modal--custom .modal__head h2 { font-size: calc(var(--fs-xl) * 1.25); }
.modal--custom .modal__head p { font-size: 16px; line-height: 1.5; }
.modal--custom .idea { padding: 16px; }
.modal--custom .idea b { font-size: 20px; line-height: 1.3; }
.modal--custom .idea p { font-size: 16px; line-height: 1.55; margin-top: 6px; }
.modal__talk { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-left: auto; }
.modal__or { color: var(--ink-2); font-size: var(--fs-sm); }
@media (max-width: 700px) {
  .modal__talk { margin-left: 0; width: 100%; }
  .modal__or { width: 100%; }
  .modal--custom .modal__head h2 { font-size: 22px; }
  .modal--custom .modal__head p { font-size: 15px; }
  .modal--custom .modal__foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 12px 16px 16px; }
  .modal--custom .modal__foot > .btn:first-child, .modal--custom .modal__foot > .btn:nth-child(2) { grid-column: 1 / -1; }
  .modal--custom .modal__foot .btn { justify-content: center; white-space: normal; }
  .modal--custom .modal__talk { display: contents; }
  .modal--custom .modal__or { display: none; }
}
/* Accounts and payments we connect to, with their logos. */
.intg { margin-top: 18px; padding: 18px; border-radius: var(--r-surface); border: 1px solid var(--line); background: var(--surface); }
.intg h3 { display: flex; align-items: center; gap: 8px; font-size: 20px; color: var(--ink); }
.intg h3 svg { width: 22px; height: 22px; color: var(--accent); flex: none; }
.intg > p { margin-top: 6px; font-size: 16px; line-height: 1.55; color: var(--ink-2); }
.intg__row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: start; margin-top: 14px; }
.intg__row > b { padding-top: 8px; font-size: 16px; color: var(--ink); }
.intg__logos { display: flex; flex-wrap: wrap; gap: 8px; }
.intg__logo { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px 7px 9px; border-radius: var(--r-control); background: var(--surface-2); border: 1px solid var(--line); font-size: 15px; font-weight: 600; color: var(--ink); }
.intg__logo img { width: 20px; height: 20px; flex: none; }
.intg__logo i { display: grid; place-items: center; width: 20px; height: 20px; border-radius: var(--r-small); color: #fff; font-style: normal; font-size: 9px; font-weight: 800; flex: none; }
.intg__more { align-self: center; padding: 0 4px; font-size: 15px; color: var(--ink-2); }
@media (max-width: 700px) { .intg__row { grid-template-columns: minmax(0, 1fr); gap: 6px; } .intg__row > b { padding-top: 0; } }
@keyframes m-fade { from { opacity: 0; } }
@keyframes m-up { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Guided tour ---------- */
.tour-veil { position: fixed; inset: 0; z-index: 95; }
.tour-spot {
  position: fixed; z-index: 96; border-radius: var(--r-surface); pointer-events: none;
  box-shadow: 0 0 0 4px var(--spark), 0 0 0 9999px rgba(15, 26, 36, .55);
  transition: top .3s var(--ease), left .3s var(--ease), width .3s var(--ease), height .3s var(--ease);
}
.tour-pop {
  position: fixed; z-index: 97; width: min(360px, calc(100vw - 24px)); padding: 18px; display: grid; gap: 10px;
  background: var(--surface); border-radius: var(--r-surface); box-shadow: var(--shadow-2); transition: top .3s var(--ease), left .3s var(--ease);
}
.tour-pop__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-pop__n { font-size: var(--fs-xs); font-weight: 700; color: var(--spark-strong); text-transform: uppercase; letter-spacing: .04em; }
.tour-pop h3 { font-size: var(--fs-lg); }
.tour-pop p { font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.55; }
.tour-pop__nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-dots { display: flex; gap: 5px; }
.tour-dots i { width: 7px; height: 7px; border-radius: var(--r-dot); background: var(--line-strong); transition: width .2s; }
.tour-dots i.on { background: var(--spark); width: 18px; border-radius: var(--r-small); }
.tour-pop__fin { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-pop, .modal, .modal-veil { transition: none; animation: none; } }
@media (max-width: 900px) {
  .drawer__head { flex-wrap: wrap; padding: 12px; gap: 10px; }
  .drawer__title { flex: 1 1 200px; }
  .drawer__head .card__actions { width: 100%; justify-content: flex-start; }
  .drawer__head .card__actions [data-close] { margin-left: auto; order: 9; }
  .drawer__head .btn { height: 44px; }
  .drawer__head .btn--icon { width: 44px; }
}

/* ---------- Our own icons (core/icons.js), Lee 2026-11-13 ----------
   A line drawing in the text colour over a solid block of the highlight
   colour, a little off register. */
.bi { display: inline-block; flex: none; overflow: visible; }
.bi__a { fill: color-mix(in srgb, var(--spark) 46%, transparent); stroke: none; }
.bi__s { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
/* On a highlight-coloured button the block would vanish: show it in white. */
.btn--spark .bi__a, .mysys .bi__a, .filter[aria-pressed="true"] .bi__a, .tab[aria-selected="true"] .bi__a,
.btn:not(.btn--soft):not(.btn--ghost):not(.btn--plain):not(.btn--muted):not(.btn--danger) .bi__a { fill: color-mix(in srgb, #fff 38%, transparent); }

/* ---------- No icons boxed in rounded squares: just the icon ---------- */
.ico-tile, .ico-tile--spark, .ico-tile--warn, .ico-tile--bad, .ico-tile--good { width: auto; height: auto; min-width: 24px; background: none; border-radius: 0; }
.ico-tile svg { width: 22px; height: 22px; }
.ico-tile--lg svg { width: 30px; height: 30px; }
.ta__ico { background: none; width: 22px; }
.ta__ico svg { width: 18px; height: 18px; }

/* ---------- Text sizes from Appearance ---------- */
.card__head h3 { font-size: var(--fs-card); }
.kpi__value { font-size: var(--fs-fig); }
.btn { font-size: var(--fs-btn); }
.btn--sm { font-size: calc(var(--fs-btn) - 1px); }
.tab { font-size: calc(var(--fs-btn) + 1px); }
.seg button, .choice, .filter, .chip-btn { font-size: var(--fs-btn); }

/* ---------- The Appearance panel: right half, no backdrop ---------- */
.ap {
  position: fixed; z-index: 75; top: 0; right: 0; bottom: 0; width: min(50vw, 760px); min-width: 400px;
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-3); transform: translateX(104%); transition: transform .28s var(--ease);
}
.ap.on { transform: none; }
.ap__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 6px; }
.ap__head h2 { font-size: var(--fs-xl); }
.ap__head p { margin-top: 4px; font-size: var(--fs-sm); color: var(--muted); }
.ap__tabs { padding: 10px 20px 0; }
.ap__body { flex: 1; min-height: 0; overflow: auto; padding: 16px 20px 28px; }
.ap__stack { display: grid; gap: 18px; }
.ap__sec { margin-top: 6px; }
.ap__sec h3 { font-size: var(--fs-card); }
.ap__sec p { font-size: var(--fs-xs); margin-top: 2px; }
.aprow { display: grid; gap: 8px; }
.aprow__lbl b { display: block; color: var(--ink); font-size: var(--fs-sm); }
.aprow__lbl small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.apsize { display: grid; gap: 2px; }
.apsize small { font-size: var(--fs-xs); }
.ap .fontgrid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.ap .presets { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (max-width: 900px) { .ap { width: 100vw; min-width: 0; } }
@media (prefers-reduced-motion: reduce) { .ap { transition: none; } }

/* Icons in filter chips and choice buttons sit at text size, not 24px. */
.filter svg, .filter .bi, .choice svg, .choice .bi, .chip-btn .bi { width: 16px; height: 16px; flex: none; }
