:root {
  --bg: #0b0908;
  --bg-2: #15100d;
  --card: #1c1612;
  --card-2: #2a211b;
  --line: rgba(243, 235, 225, 0.1);
  --text: #f3ebe1;
  --muted: #b3a597;
  --accent: #e8a24a;
  --accent-soft: #f6cf96;
  --on-accent: #201304;
  --ok: #7fd29a;
  --bad: #ff8a7a;
  --warn: #f3c969;
  --radius: 16px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

h1,
h2,
h3 {
  margin: 0 0 8px;
  line-height: 1.2;
}
h1 { font-size: 20px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
h3 { font-size: 16px; margin-top: 18px; }
p { margin: 0 0 8px; }
ol, ul { padding-left: 20px; margin: 0 0 12px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.loading { color: var(--muted); padding: 24px 16px; }

.screen,
.content {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}
.content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 20px;
}
.brand img { border-radius: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card.center { text-align: center; }
.card.hint { background: var(--bg-2); }
.card.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 360px) { .card.two { grid-template-columns: 1fr; } }

.btn {
  display: inline-block;
  appearance: none;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  padding: 12px 16px;
  min-height: 44px;
  cursor: pointer;
}
.btn.big { width: 100%; padding: 16px; margin: 8px 0; }
.btn.ghost { background: var(--card-2); color: var(--text); }
.btn.danger { background: #5a1d17; color: #ffd6cf; }
.btn:disabled { opacity: 0.5; }
.link {
  appearance: none;
  background: none;
  border: 0;
  color: var(--accent-soft);
  font: inherit;
  padding: 10px 0;
  text-decoration: underline;
  cursor: pointer;
}
.link.danger { color: var(--bad); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

input[type='text'],
input[type='number'],
input[type='time'],
select {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}
.code-form { display: grid; gap: 8px; margin-top: 8px; }
.code-form input { text-transform: uppercase; letter-spacing: 0.08em; font-size: 18px; text-align: center; }
.field { display: grid; gap: 6px; margin: 12px 0; }
.field span { color: var(--muted); font-size: 14px; }

/* App shell */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(11, 9, 8, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top h1, .top select { flex: 1; margin: 0; }
.top select { font-weight: 600; }
.icon-btn {
  appearance: none;
  background: var(--card-2);
  border: 0;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  font-size: 18px;
  cursor: pointer;
}
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(21, 16, 13, 0.96);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}
.nav-item {
  appearance: none;
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 16px 0;
  cursor: pointer;
}
.nav-item.active { color: var(--accent); }

/* Today */
.banner {
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--card-2);
  color: var(--muted);
  font-size: 14px;
}
.banner.ok { color: var(--ok); background: rgba(127, 210, 154, 0.1); }
.banner.bad { color: var(--bad); background: rgba(255, 138, 122, 0.1); }
.big-number { font-size: 36px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 6px; font-variant-numeric: tabular-nums; }
.unit { font-size: 18px; font-weight: 500; color: var(--muted); }
.split { display: flex; gap: 20px; margin-bottom: 8px; }
.split div { display: grid; }
.delta { font-size: 13px; color: var(--muted); }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }

.beds { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.bed {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: 'name countdown' 'state client';
  gap: 2px 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-2);
  border-left: 4px solid var(--muted);
}
.bed-name { grid-area: name; font-weight: 600; }
.bed-state { grid-area: state; font-size: 14px; color: var(--muted); }
.bed-client { grid-area: client; font-size: 14px; text-align: right; }
.countdown { grid-area: countdown; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent-soft); text-align: right; }
.state-free { border-left-color: var(--ok); }
.state-inUse, .state-starting { border-left-color: var(--accent); }
.state-coolDown, .state-cleaning { border-left-color: #7aa7ff; }
.state-fault { border-left-color: var(--bad); }
.state-fault .bed-state { color: var(--bad); font-weight: 600; }
.state-notConnected { border-left-color: var(--warn); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--card-2); border-radius: 999px; padding: 2px 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.plain { list-style: none; padding: 0; }
.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }

.salon-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  text-align: left;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.salon-name { font-weight: 600; }
.salon-figs { grid-column: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); align-self: center; justify-self: end; }
.dot.live { background: var(--ok); }
.dot.offline, .dot.inactive { background: var(--bad); }

/* History */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--card); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.segmented button { appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; padding: 10px; border-radius: 10px; cursor: pointer; }
.segmented button.active { background: var(--card-2); color: var(--text); }
.history { list-style: none; padding: 0; margin: 0; }
.history li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.h-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.bar { height: 6px; background: var(--bg-2); border-radius: 3px; margin: 8px 0; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* Settings */
.toggles { list-style: none; padding: 0; margin: 0; }
.toggles li { border-bottom: 1px solid var(--line); }
.toggles label { display: flex; align-items: center; gap: 12px; padding: 12px 0; cursor: pointer; }
.toggles input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(80px + env(safe-area-inset-bottom));
  max-width: 528px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 12px;
  background: #2f3a2f;
  color: var(--text);
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.toast.error { background: #4a211b; }

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise 0.2s ease-out; }
  @keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* Diary */
.diary { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.diary-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 4px;
  max-width: 900px;
  margin: 0 auto;
}
.date-nav { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.date-label {
  flex: 1;
  min-width: 0;
  appearance: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.icon-btn:disabled { opacity: 0.35; }
.icon-btn { color: var(--text); flex: none; }
.small-seg { margin: 0; flex: none; grid-template-columns: repeat(2, auto); }
.small-seg button { padding: 10px 12px; }
.diary-summary { padding: 0 16px; max-width: 900px; margin: 4px auto 8px; }

.dg-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 8px;
  max-width: 900px;
  margin: 0 auto;
}
.dg-count { font-weight: 600; color: var(--accent-soft); }
.dg-arrows { display: flex; gap: 6px; }
.dg-arrows .icon-btn { width: 40px; height: 40px; font-size: 14px; }

.dg-wrap { position: relative; margin: 0 8px; }
.dg-scroll {
  overflow: auto;
  overscroll-behavior: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-left: var(--time-col);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  -webkit-overflow-scrolling: touch;
}
.dg-scroll:focus-visible { outline: 2px solid var(--accent); }
.dg-grid { width: max-content; min-width: 100%; }
.dg-head {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.dg-corner {
  width: var(--time-col);
  flex: none;
  position: sticky;
  left: 0;
  z-index: 4;
  background: var(--card);
}
.dg-bedname {
  width: var(--col);
  flex: none;
  padding: 10px 6px;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 1px solid var(--line);
  scroll-snap-align: start;
}
.dg-body { display: flex; }
.dg-times {
  width: var(--time-col);
  flex: none;
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card);
  border-right: 1px solid var(--line);
}
.dg-times span {
  position: absolute;
  right: 6px;
  transform: translateY(-50%);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.dg-times span:first-child { transform: none; }
.dg-times span.half { opacity: 0.55; font-size: 11px; }
.dg-col {
  width: var(--col);
  flex: none;
  position: relative;
  border-left: 1px solid var(--line);
  background-image: repeating-linear-gradient(to bottom, rgba(243, 235, 225, 0.07) 0 1px, transparent 1px var(--slot));
  scroll-snap-align: start;
}
.dg-booking {
  position: absolute;
  left: 3px;
  right: 3px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  overflow: hidden;
  padding: 3px 6px;
  border: 0;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: rgba(232, 162, 74, 0.2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.dg-client { font-size: 13px; font-weight: 600; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.dg-meta { font-size: 11px; color: var(--muted); line-height: 1.1; white-space: nowrap; }
.dg-booking.status-arrived { border-left-color: #7aa7ff; background: rgba(122, 167, 255, 0.18); }
.dg-booking.status-in_session { border-left-color: var(--ok); background: rgba(127, 210, 154, 0.2); }
.dg-booking.status-completed { border-left-color: var(--muted); background: rgba(179, 165, 151, 0.12); color: var(--muted); }
.dg-booking.status-no_show { border-left-color: var(--muted); background: rgba(179, 165, 151, 0.08); color: var(--muted); text-decoration: line-through; }
.dg-now { position: absolute; left: 0; right: 0; height: 2px; background: #fff; z-index: 1; pointer-events: none; }

/* Fades and the swipe hint: they show there are more beds off to the side. */
.dg-fade {
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: 28px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 5;
}
.dg-fade.left { left: calc(var(--time-col, 52px) + 1px); background: linear-gradient(to right, rgba(11, 9, 8, 0.85), transparent); }
.dg-fade.right { right: 1px; border-radius: 0 12px 12px 0; background: linear-gradient(to left, rgba(11, 9, 8, 0.85), transparent); }
.dg-fade.on { opacity: 1; }
.dg-hint {
  text-align: center;
  color: var(--accent-soft);
  font-size: 14px;
  margin: 8px 0 0;
}
@media (prefers-reduced-motion: no-preference) {
  .dg-hint:not([hidden]) { animation: nudge 1.6s ease-in-out 3; }
  @keyframes nudge { 0%, 100% { transform: none; } 50% { transform: translateX(6px); } }
}

.diary-list { list-style: none; margin: 0 auto; }
.dl-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.dl-row.is-next { border-color: var(--accent); }
.dl-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.dl-main { display: grid; min-width: 0; }
.dl-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-row.status-completed { opacity: 0.6; }
.dl-row.status-no_show strong { text-decoration: line-through; }
.pill { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 8px; background: var(--card-2); white-space: nowrap; }
.pill.status-arrived { color: #9dbcff; }
.pill.status-in_session { color: var(--ok); }
.pill.status-no_show { color: var(--muted); text-decoration: line-through; }
.pill.status-booked { color: var(--accent-soft); }
.dg-booking.short { flex-direction: row; align-items: center; gap: 6px; padding: 0 6px; }
.dg-booking.short .dg-client { flex: 1; min-width: 0; font-size: 12px; }
.dg-booking.short .dg-meta { flex: none; }
.dg-hint { text-align: left; padding: 0 16px; margin: -2px auto 8px; max-width: 900px; }

/* Paid bookings are red: the client has bought something today (as in TanEngine's own diary). Red means nothing else
   in the diary, so no-shows are grey and the "now" line is white. */
:root { --paid: #d8342c; }
.dg-booking.paid { background: var(--paid); color: #fff; }
.dg-booking.paid .dg-meta { color: rgba(255, 255, 255, 0.9); font-weight: 600; }
.dg-booking.paid.status-completed { background: rgba(216, 52, 44, 0.6); color: rgba(255, 255, 255, 0.85); }
.dl-row.paid { border-left: 4px solid var(--paid); }
.dl-side { display: grid; justify-items: end; gap: 4px; }
.dl-spent { color: #ff7a72; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.diary-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 0 16px;
  margin: -4px auto 8px;
  max-width: 900px;
  font-size: 12px;
  color: var(--muted);
}
.diary-legend .key { display: inline-flex; align-items: center; gap: 5px; }
.diary-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; background: var(--accent); }
.diary-legend .key-paid i { background: var(--paid); }
.diary-legend .key-arrived i { background: #7aa7ff; }
.diary-legend .key-in_session i { background: var(--ok); }
.diary-legend .key-completed i { background: var(--muted); }
.dg-line { display: flex; align-items: baseline; gap: 6px; width: 100%; min-width: 0; }
.dg-line .dg-client { flex: 1; min-width: 0; }
.dg-line .dg-meta, .dg-amount { flex: none; margin-left: auto; }
.dg-amount { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* A booking's details (opens when a booking is tapped) */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
}
.sheet .btn { width: 100%; margin-top: 8px; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.pf-name { font-size: 22px; text-transform: none; letter-spacing: 0; color: var(--text); margin-bottom: 4px; }
.pf-paid { color: #ff7a72; font-weight: 700; }
.pf-suspended { background: rgba(255, 138, 122, 0.12); border: 1px solid rgba(255, 138, 122, 0.4); color: var(--bad); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.pf-suspended p { margin: 4px 0 0; color: var(--text); }
.pf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.pf-row { display: grid; gap: 2px; background: var(--bg-2); border-radius: 10px; padding: 10px; }
.pf-row span { font-size: 13px; }
.pf-row.warn strong { color: var(--warn); }
.dl-row { cursor: pointer; }
.dl-row:focus-visible { outline: 2px solid var(--accent); }
.limit-banner { margin: 8px 16px 0; }
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: sheet-up 0.18s ease-out; }
  @keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* Stats: charts. Series colours are validated together on the card colour (colour-blind and contrast checks). */
:root {
  --bar: #e8a24a;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-other: #7d7066;
  --grid: rgba(243, 235, 225, 0.08);
}
.stats { display: grid; gap: 0; }
.section-head { margin: 20px 4px 10px; }
.history-embedded .segmented { margin-top: 0; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 4px; }
.tile-value { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.tile .delta { font-size: 12px; }
.chart-card { position: relative; }
.chart-card h2 { margin-bottom: 2px; }
.chart-sub { margin-bottom: 10px; }
.chart-box { width: 100%; overflow: hidden; }
.chart-box svg { display: block; touch-action: pan-y; }
.chart-box .grid { stroke: var(--grid); stroke-width: 1; }
.chart-box .baseline { stroke: rgba(243, 235, 225, 0.25); stroke-width: 1; }
.chart-box .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-box .value { fill: var(--text); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-box .hit { fill: transparent; }
.chart-box .mark { cursor: pointer; outline: none; }
.chart-box .mark:hover .bar, .chart-box .mark:focus .bar { filter: brightness(1.25); }
.chart-box .mark:focus-visible .hit { stroke: var(--accent); stroke-width: 1.5; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-tip {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  display: grid;
  gap: 1px;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #0f0c0a;
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  font-size: 13px;
}
.chart-tip strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.chart-tip span { color: var(--muted); }
.small-link { font-size: 13px; padding: 6px 0 0; }
.chart-table table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.chart-table th { text-align: left; font-weight: 500; color: var(--muted); padding: 5px 0; border-bottom: 1px solid var(--line); }
.chart-table td { text-align: right; padding: 5px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }

/* How people paid: one bar split into parts */
.split-bar { display: flex; gap: 2px; height: 28px; border-radius: 8px; overflow: hidden; margin: 4px 0 10px; }
.split-seg { border: 0; padding: 0; min-width: 4px; cursor: pointer; }
.split-seg:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }

/* Busy hours heatmap */
.heat { display: grid; gap: 2px; align-items: center; }
.heat-h { font-size: 10px; color: var(--muted); text-align: left; font-variant-numeric: tabular-nums; }
.heat-d { font-size: 12px; color: var(--muted); }
.heat-cell { aspect-ratio: 1 / 1; min-height: 14px; border: 0; border-radius: 3px; padding: 0; cursor: pointer; }
.heat-cell:focus-visible { outline: 2px solid var(--text); }
.heat-scale { display: flex; align-items: center; gap: 3px; margin: 10px 0 0; }
.heat-scale i { width: 16px; height: 10px; border-radius: 2px; display: inline-block; }
.heat-scale span:first-child { margin-right: 4px; }
.heat-scale span:last-child { margin-left: 4px; }

/* Bed usage: horizontal bars */
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hbars li { display: grid; grid-template-columns: 64px 1fr 40px; gap: 8px; align-items: center; cursor: pointer; }
.hbars li:focus-visible { outline: 2px solid var(--accent); border-radius: 4px; }
.hbar-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 14px; border-radius: 0 4px 4px 0; background: var(--bg-2); overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; max-width: 100%; }
.hbar-value { font-size: 13px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.stats-note { margin: 0 4px 8px; }
.show-all { width: 100%; margin-top: 4px; }

/* Five tabs: a little tighter */
.nav-item { font-size: 14px; padding: 14px 0; }

/* Rota */
.rota { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.rota-days { padding-top: 4px; }
.rota-day { padding: 12px 14px; }
.rota-day.is-today { border-color: var(--accent); }
.rota-day.is-past { opacity: 0.85; }
.rota-date { display: flex; align-items: center; justify-content: space-between; text-transform: none; letter-spacing: 0; font-size: 16px; color: var(--text); margin-bottom: 6px; }
.rota-list { list-style: none; margin: 0; padding: 0; }
.rota-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: 'name time' 'status status';
  gap: 2px 10px;
  padding: 8px 0 8px 10px;
  border-top: 1px solid var(--line);
  border-left: 3px solid var(--line);
}
.rota-row:first-child { border-top: 0; }
.rota-name { grid-area: name; font-weight: 600; }
.rota-time { grid-area: time; font-variant-numeric: tabular-nums; color: var(--muted); }
.rota-status { grid-area: status; font-size: 13px; color: var(--muted); }
.st-on { border-left-color: var(--ok); }
.st-on .rota-status { color: var(--ok); font-weight: 600; }
.st-late { border-left-color: var(--warn); }
.st-late .rota-status { color: var(--warn); }
.st-missed { border-left-color: var(--bad); }
.st-missed .rota-status { color: var(--bad); font-weight: 600; }
.st-unplanned { border-left-color: #7aa7ff; }
.st-unplanned .rota-time { color: #9dbcff; }
.st-planned .rota-status { color: var(--accent-soft); }
.rota-day { scroll-margin-top: 84px; }

/* Tab bar: icons only. The selected tab is marked by colour and a short bar above the icon. */
.nav-item { display: grid; place-items: center; padding: 12px 0 14px; position: relative; color: var(--muted); }
.nav-item svg { width: 26px; height: 26px; }
.nav-item.active { color: var(--accent); }
.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 28px;
  height: 3px;
  margin-left: -14px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
}
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 10px; }
.lock-btn { display: grid; place-items: center; color: var(--accent-soft); }
.lock-btn svg { width: 22px; height: 22px; }

/* Home: free minutes and discounts in the last 3 days */
.recent-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.recent-total { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 0 0 8px; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.recent-list .r-main { font-weight: 600; min-width: 0; }
.recent-list .r-amount { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.recent-list .r-meta { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }

/* Each tab's heading sits in the top bar (which stays at the top), with the salon underneath. */
.top { align-items: center; }
.top-titles { flex: 1; min-width: 0; display: grid; gap: 4px; }
.page-title { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; color: var(--text); text-transform: none; }
.salon-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-titles select { min-height: 34px; padding: 4px 10px; font-size: 14px; font-weight: 600; color: var(--muted); background: var(--card); max-width: 100%; }
.rota-day { scroll-margin-top: 116px; }

/* Home: cash, what's unusual, clients, stock, tubes */
.watch-card { border-color: var(--warn); }
.watch-card h2 { color: var(--warn); }
.clients-grid { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.mini-bars { display: flex; gap: 6px; align-items: flex-end; height: 64px; }
.mini-bars > div { display: grid; justify-items: center; gap: 2px; }
.mini-bars span { width: 14px; border-radius: 3px 3px 0 0; background: rgba(232, 162, 74, 0.38); display: block; }
.mini-bars span.now { background: var(--bar, #e8a24a); }
.mini-bars small { font-size: 10px; color: var(--muted); }
.expiring { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
.r-amount.out { color: var(--bad); }
.tubes .tube-track { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--bg-2); overflow: hidden; margin: 4px 0 2px; }
.tubes .tube-fill { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.tubes .tube-fill.soon { background: var(--warn); }
.tubes .tube-fill.due { background: var(--bad); }
.chart-box .ly-mark { stroke: var(--text); stroke-width: 2; stroke-linecap: round; opacity: 0.85; }
.chart-legend .line-key { width: 14px; height: 0; border-top: 2px solid var(--text); border-radius: 0; opacity: 0.85; }

/* Settings: backups */
.backup-salon + .backup-salon { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.backup-salon h3 { margin: 0 0 6px; }
.backup-path { display: grid; gap: 2px; margin: 8px 0 0; }
.backup-path code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--text); overflow-wrap: anywhere; background: var(--bg-2); border-radius: 8px; padding: 6px 8px; }

/* Sessions: four periods in a sideways strip. Each panel is narrower than the strip, so the next one is cut off at
   the edge, and the edge fades: both say "there's more this way". Dots underneath show which one you're on. */
.periods { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.period-wrap { position: relative; }
.period-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-left: 0;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.period-strip::-webkit-scrollbar { display: none; }
.period-strip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 12px; }
.period {
  flex: 0 0 72%;
  scroll-snap-align: start;
  display: grid;
  gap: 2px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.period-label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.period-number { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.period-fade {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 36px;
  pointer-events: none;
  background: linear-gradient(to left, var(--card), transparent);
  transition: opacity 0.2s;
}
.period-wrap.at-end .period-fade { opacity: 0; }
.period-dots { display: flex; justify-content: center; gap: 4px; margin-top: 8px; }
.dot-btn { appearance: none; border: 0; padding: 8px 4px; background: none; cursor: pointer; }
.dot-btn::before { content: ''; display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); transition: width 0.2s, background 0.2s; }
.dot-btn.on::before { width: 20px; border-radius: 4px; background: var(--accent); }
@media (min-width: 640px) { .period { flex-basis: 46%; } }

/* Under the beds: customers waiting, and the bed each is going on. */
.waiting { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.waiting-head { margin: 0 0 4px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.waiting-list li { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name bed" "when when"; gap: 2px 12px; }
.waiting-list li:last-child, .shift-list li:last-child { border-bottom: 0; }
.waiting-name { grid-area: name; font-weight: 600; }
.waiting-bed { grid-area: bed; text-align: right; }
.waiting-list .small { grid-area: when; }

/* On shift: name and clock-in time, sessions this shift on the right. */
.shift-list { margin: 4px 0 0; }
.shift-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.shift-count { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Customers box: lapsed regulars under the sideways panels. */
.customers-lapsed { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.expiring .btn { margin-top: 8px; }
.small-btn { padding: 8px 14px; font-size: 14px; }

/* A full-screen page over the app (e.g. who has minutes expiring). The screen underneath keeps its place. */
.over-page {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
}
body.over-open { overflow: hidden; }
.over-page .top h1 { font-size: 20px; }
.over-body { max-width: 560px; margin: 0 auto; padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
.over-body .card { margin: 0; }
.over-note { text-align: center; }
.expiring-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.expiring-list li:last-child { border-bottom: 0; }
.exp-name { font-weight: 600; }
.exp-min { text-align: right; font-variant-numeric: tabular-nums; }
.exp-when { grid-column: 1 / -1; }
.expiring-list li.soon .exp-when { color: var(--warn, #f0b35a); }

/* Low stock box: products sold by period under the list. */
.products-sold { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.products-sold .recent-head { align-items: baseline; }

/* Stats: most popular products. Rank, name, how many / value, and a thin bar against the best seller. */
.popular-products { margin-bottom: 16px; }
.tp-periods { grid-template-columns: repeat(4, 1fr); background: var(--bg-2); }
.tp-periods button { padding: 8px 4px; font-size: 14px; }
.top-products { list-style: none; padding: 0; margin: 0 0 4px; }
.top-products li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  grid-template-areas: "rank name figures" ". track track";
  align-items: baseline;
  gap: 4px 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.top-products li:last-child { border-bottom: 0; }
.tp-rank { grid-area: rank; color: var(--muted); font-variant-numeric: tabular-nums; }
.tp-name { grid-area: name; font-weight: 600; overflow-wrap: anywhere; }
.tp-figures { grid-area: figures; display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.tp-track { grid-area: track; height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; }
.tp-fill { display: block; height: 100%; border-radius: 3px; background: #3987e5; }
.over-body .tp-periods { margin-bottom: 8px; }

/* Settings: a row per salon that opens its Notifications screen. */
.notif-rows { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.notif-row {
  appearance: none; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card-2);
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.notif-row-text { display: grid; gap: 2px; }
.notif-row svg { flex: none; color: var(--muted); }

/* The Notifications screen: switches, with a setting under a switch while it's on. */
.notif-list label { align-items: flex-start; }
.notif-list input[type="checkbox"] { margin-top: 1px; }
.notif-label { display: grid; gap: 4px; }
.notif-setting { display: none; padding: 0 0 12px 34px; }
.notif-list li.is-on .notif-setting { display: block; }
.notif-list .notif-field { display: grid; gap: 6px; padding: 0; cursor: default; }
.unit-input { display: inline-flex; align-items: center; gap: 8px; }
.unit-input input { width: 150px; }
.notif-mode { grid-template-columns: repeat(2, 1fr); margin: 0; max-width: 320px; background: var(--bg-2); }
.notif-mode button { padding: 8px; font-size: 14px; }
.quiet-times { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; max-width: 340px; }
.quiet-times input { width: 100%; min-width: 0; padding: 10px 8px; }
input[type='time'] { color-scheme: dark; }
