/* =====================================================================
   WAR Job Board — public/app.css
   Mobile-first stylesheet (phone 360–430px is the base; enhancements at
   600px and 900px only — no max-width media queries anywhere).
   Brand: dark navy + amber, carried over from the original artifact.
   ===================================================================== */


/* ---------------------------------------------------------------------
   1. DESIGN TOKENS
   ------------------------------------------------------------------ */
:root {
  /* surfaces & ink (verbatim from the original artifact) */
  --bg: #071427;
  --surface: #0d1f38;
  --surface-2: #132c4c;
  --surface-3: #1a3860;
  --ink: #f5f7ff;
  --ink-soft: #a9b9dc;
  --ink-faint: #5d7098;
  --line: #1e3557;

  /* accents */
  --accent: #f8cc46;
  --accent-ink: #10203a;
  --success: #4bdb8e;
  --success-bg: #0f3628;
  --success-ink: #d3fbe6;
  --danger: #ff7169;
  --danger-bg: #3c141c;
  --danger-ink: #ffdadb;
  --warn: #ffab4a;
  --warn-bg: #3a2510;
  --info: #8ab4e8;              /* cool blue-grey — the "ใน 7 วัน" chip     */
  --info-bg: #14293f;

  /* elevation / shape */
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 28px -14px rgba(0, 0, 0, 0.7);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.45), 0 22px 44px -18px rgba(0, 0, 0, 0.85);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  /* type */
  --font-body: 'IBM Plex Sans Thai', 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-brand: 'Big Shoulders Display', 'IBM Plex Sans Thai', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* metrics — the compact-header maths depends on --hero-h and --bar-h */
  --hero-h: 176px;   /* full hero height on a phone            */
  --bar-h: 52px;     /* compact sticky header height           */
  --tab-h: 56px;     /* bottom tab bar height (excl. safe area)*/
  --safe-b: env(safe-area-inset-bottom, 0px);
  --gutter: 12px;
  --tap: 44px;       /* minimum tap target                     */

  color-scheme: dark;
  accent-color: var(--accent);
}


/* ---------------------------------------------------------------------
   2. RESET & DOCUMENT BASE
   ------------------------------------------------------------------ */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--bar-h) + 8px);
}

html,
body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(248, 204, 70, 0.18);
  /* never allow the page itself to scroll sideways; `clip` wins where it is
     supported because `hidden` on <body> would break position: sticky. */
  overflow-x: hidden;
  overflow-x: clip;
  min-height: 100%;
}

/* the [hidden] attribute must beat every display rule in this sheet */
[hidden] { display: none !important; }

img,
svg,
video { max-width: 100%; }

img {
  border-style: none;
  /* a width-capped image must never be stretched by its height attribute */
  height: auto;
}

button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

/* long Thai strings must never widen a row */
p, h1, h2, h3, li, span, label { overflow-wrap: anywhere; }

/* every flex/grid child may shrink below its content width */
.field,
.field-grid > *,
.card-top > *,
.hero-brand > *,
.item-row > *,
.tab-btn,
.tab-btn > *,
.appt-card,
.appt-card > *,
.stat-chip,
.summary-strip > *,
.grp-buttons > *,
.grp-cancel > *,
.pay-btns > *,
.hc-row1 > *,
.toast,
.toast > * { min-width: 0; }

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* one visible focus treatment for the whole app */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible { outline-offset: 1px; }


/* ---------------------------------------------------------------------
   3. APP SHELL
   ------------------------------------------------------------------ */
#app {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  position: relative;
  isolation: isolate;
}

main#views {
  display: block;
  padding: 14px var(--gutter)
           calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 16px);
}

/* --- view switching: only the section matching #app[data-view] shows --- */
#view-add,
#view-today,
#view-upcoming,
#view-history { display: none; }

#app[data-view="add"] #view-add { display: block; }
#app[data-view="today"] #view-today { display: block; }
#app[data-view="upcoming"] #view-upcoming { display: block; }
#app[data-view="history"] #view-history { display: block; }

/* --- while the lock screen is up nothing else exists (focus containment) */
#app.is-locked #top-bar,
#app.is-locked main#views,
#app.is-locked #tabbar { display: none; }

/* --- loading / offline shell states --- */
#app.is-loading #top-bar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  z-index: 3;
  background: linear-gradient(90deg,
    transparent 0%, var(--accent) 35%, var(--accent) 65%, transparent 100%);
  background-size: 220% 100%;
  background-position: 0% 0;
}

#app.is-offline #top-bar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  z-index: 3;
  background: var(--danger);
}


/* ---------------------------------------------------------------------
   4. HEADER — full hero + sticky compact bar
   The hero box is exactly --hero-h tall and sticks with a NEGATIVE top of
   (bar-h - hero-h), so it scrolls away until only its bottom --bar-h strip
   is pinned. No layout jump when app.js adds/removes #top-bar.is-compact.
   ------------------------------------------------------------------ */
#top-bar {
  position: sticky;
  top: calc(var(--bar-h) - var(--hero-h));
  z-index: 40;
}

.hero {
  position: relative;
  height: var(--hero-h);
  background: #04070d;
  line-height: 0;
  overflow: hidden;
}

.hero-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
}

/* readability scrim behind the brand block */
.hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 62%;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(4, 7, 13, 0) 0%, rgba(4, 7, 13, 0.82) 100%);
}

.hero-brand {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px;
  line-height: 1.5;
}

.brand-logo {
  height: 34px;
  width: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.55));
}

.brand-text {
  min-width: 0;
  padding-bottom: 1px;
}

.brand-code {
  margin: 0;
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: 0.05em;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65);
}

.brand-full {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.3;
  color: #fbfbfb;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}

.hero-credit {
  position: absolute;
  top: 8px;
  /* clears #logout-btn, which is pinned at right:12px and is --tap (44px) wide */
  right: 64px;
  z-index: 2;
  margin: 0;
  max-width: calc(100% - 76px);
  text-align: right;
  font-size: 9.5px;
  line-height: 1.3;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

/* header-anchored controls sit in the bottom strip in BOTH states, so the
   compact bar needs no repositioning of them at all */
#top-bar #sync-pill {
  position: absolute;
  right: 12px;
  bottom: 14px;
  z-index: 3;
}

#top-bar #logout-btn {
  position: absolute;
  right: 12px;
  top: 10px;
  z-index: 3;
}

/* --- compact state (class toggled by app.js at scroll >= hero-h - bar-h) */
#top-bar.is-compact .hero {
  background: transparent;
  overflow: visible;
}

#top-bar.is-compact .hero-photo,
#top-bar.is-compact .hero-credit,
#top-bar.is-compact .brand-full,
#top-bar.is-compact .hero::after { display: none; }

#top-bar.is-compact .hero-brand {
  height: var(--bar-h);
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: rgba(9, 24, 44, 0.86);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px -18px rgba(0, 0, 0, 0.95);
}

#top-bar.is-compact .brand-logo { height: 26px; }

#top-bar.is-compact .brand-code {
  font-size: 19px;
  text-shadow: none;
}

#top-bar.is-compact #sync-pill { bottom: 12px; }

#top-bar.is-compact #logout-btn {
  top: auto;
  bottom: 4px;
  right: 8px;
}


/* ---------------------------------------------------------------------
   5. SYNC PILL & LOGOUT
   ------------------------------------------------------------------ */
#sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: rgba(13, 31, 56, 0.9);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 1;
}

#sync-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

#sync-pill[data-state="idle"] {
  opacity: 0;
  visibility: hidden;
}

#sync-pill[data-state="saving"] {
  color: var(--accent);
  border-color: rgba(248, 204, 70, 0.45);
}

#sync-pill[data-state="saved"] {
  color: var(--success);
  border-color: rgba(75, 219, 142, 0.45);
}

#sync-pill[data-state="offline"] {
  color: var(--danger);
  border-color: rgba(255, 113, 105, 0.5);
  background: rgba(60, 20, 28, 0.92);
}

#logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0 10px;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-pill);
  background: rgba(7, 20, 39, 0.55);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

#logout-btn svg { width: 18px; height: 18px; }
#logout-btn:hover { border-color: var(--accent); color: var(--accent); }


/* ---------------------------------------------------------------------
   6. LOCK SCREEN
   ------------------------------------------------------------------ */
#lock-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  align-items: safe center;     /* an over-tall card must stay scrollable, not clip at the top */
  justify-content: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  overflow-y: auto;
}

#app.is-locked #lock-screen { display: flex; }

/* dimmed + blurred hero as the backdrop */
#lock-screen::before {
  content: "";
  position: absolute;
  inset: -24px;
  background-image: url("/assets/hero.jpg");
  background-size: cover;
  background-position: center 45%;
  filter: blur(16px) brightness(0.34) saturate(0.85);
  transform: scale(1.06);
  pointer-events: none;
}

#lock-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 80% at 50% 15%,
    rgba(7, 20, 39, 0.25) 0%, rgba(7, 20, 39, 0.9) 100%);
}

/* the card is .lock-card in index.html; #lock-form only wraps the password row */
.lock-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  /* auto margins centre the card but collapse to 0 once it overflows,
     so a short viewport can still scroll to the top of it */
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 18px 20px;
  background: rgba(13, 31, 56, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  text-align: center;
}

#lock-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.lock-card .lock-logo {
  height: 42px;
  width: auto;
  align-self: center;
  margin-bottom: 2px;
}

.lock-card .lock-title {
  margin: 0;
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.lock-card .lock-sub {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--ink-soft);
}

#lock-password {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 14px;
  font: inherit;
  font-size: 16px;              /* iOS must never zoom on focus */
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color-scheme: dark;
}

#lock-password::placeholder {
  color: var(--ink-soft);
  letter-spacing: normal;
}

#lock-submit {
  width: 100%;
  min-height: var(--tap);
}

#lock-error {
  margin: 0;
  min-height: 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
}

#lock-error:empty { min-height: 0; }

.lock-hint {
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--ink-soft);
}


/* ---------------------------------------------------------------------
   7. PANELS, HEADINGS, SUMMARY STRIP, SEARCH
   ------------------------------------------------------------------ */
.panel { min-width: 0; }

.panel-head { padding: 2px 2px 12px; }

.panel-title {
  margin: 0 0 3px;
  font-weight: 700;
  font-size: 18px;
  line-height: 1.25;
}

.panel-sub {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

/* --- the strip is a horizontally scrollable rail on a phone -------------
   Four chips do not fit at 320px, so the strip scrolls sideways instead of
   widening the page (document.documentElement.scrollWidth must stay equal
   to the viewport). overflow-x:auto also clips vertically, so the vertical
   padding gives the chip shadows room and the negative margin-top cancels
   it — nothing moves relative to the previous layout. */
.summary-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-top: -4px;
  /* the trailing 14px keeps the last chip off the edge when scrolled home */
  padding: 4px 14px 12px 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scroll-padding: 0 14px 0 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;          /* Firefox                */
  -ms-overflow-style: none;       /* legacy Edge            */
}

/* no visible scrollbar — the partly-shown last chip is the affordance */
.summary-strip::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

#view-history .summary-strip { display: none; }

/* --- chips. These are <button> elements: reset the UA appearance without
   touching the box the old <div> chips drew. --------------------------- */
.stat-chip {
  /* --chip-fill is this chip's colour when it is the selected filter */
  --chip-fill: var(--accent);

  appearance: none;
  -webkit-appearance: none;
  display: block;
  flex: 0 0 auto;                 /* never squeeze; the rail scrolls       */
  min-width: 88px;                /* was the old flex-basis                */
  min-height: var(--tap);         /* >= 44px tap target                    */
  scroll-snap-align: start;
  margin: 0;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.stat-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stat-chip .stat-n {
  display: block;
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 26px;
  line-height: 1;
}

.stat-chip .stat-l {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* --- per-chip colour: tints the number when idle, fills it when selected */
.stat-chip.chip-warn .stat-n { color: var(--warn); }
.stat-chip.chip-success .stat-n { color: var(--success); }
.stat-chip.chip-accent .stat-n { color: var(--accent); }
.stat-chip.chip-info .stat-n { color: var(--info); }
.stat-chip.chip-muted .stat-n { color: var(--ink-faint); }
.stat-chip.chip-all .stat-n { color: var(--ink); }

.stat-chip.chip-all { --chip-fill: var(--ink); }
.stat-chip.chip-accent { --chip-fill: var(--accent); }
.stat-chip.chip-warn { --chip-fill: var(--warn); }
.stat-chip.chip-info { --chip-fill: var(--info); }
.stat-chip.chip-success { --chip-fill: var(--success); }
/* --ink-faint is too dark to carry --accent-ink text, so the muted chip
   fills with the lighter --ink-soft while its number keeps the faint tint */
.stat-chip.chip-muted { --chip-fill: var(--ink-soft); }

/* --- filter chips ------------------------------------------------------ */
.chip-filter:hover { border-color: var(--surface-3); }

/* SELECTED. Solid fill in the chip's own colour with dark ink — readable at
   arm's length on a phone in a bright workshop, not a subtle tint.
   The border stays 1px (it just changes colour) so nothing reflows. */
.chip-filter.is-active,
.chip-filter[aria-pressed="true"] {
  background: var(--chip-fill);
  border-color: var(--chip-fill);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 8px 18px -10px rgba(0, 0, 0, 0.9);
}

.chip-filter.is-active .stat-n,
.chip-filter.is-active .stat-l,
.chip-filter[aria-pressed="true"] .stat-n,
.chip-filter[aria-pressed="true"] .stat-l {
  color: var(--accent-ink);
}

.chip-filter.is-active:hover,
.chip-filter[aria-pressed="true"]:hover {
  border-color: var(--chip-fill);
  filter: brightness(1.05);
}

/* --- nav chip: goes to ประวัติ, it does NOT filter. Dashed and unfilled so
   it never reads as a fourth filter chip. ------------------------------- */
.chip-goto {
  background: transparent;
  border: 1px dashed var(--surface-3);
  box-shadow: none;
}

.chip-goto .stat-l { color: var(--success); }

.chip-goto:hover { border-color: var(--success); }

.chip-arrow {
  margin-left: 4px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  opacity: 0.65;
}

.search-row {
  padding: 0 0 12px;
  position: relative;
}

.search-row input,
input.schedule-search,
#schedule-search {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color-scheme: dark;
}

.search-row input::placeholder { color: var(--ink-soft); }
.search-row input::-webkit-search-cancel-button { filter: invert(0.7); }


/* ---------------------------------------------------------------------
   8. FORM PRIMITIVES (add form + card fields share these)
   ------------------------------------------------------------------ */
.form-card {
  padding: 16px 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Phone: single column, EXCEPT the four amount fields which stay 2-up.
   The grid is always 2 tracks; everything spans both unless it is .field-amt */
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-grid > * { grid-column: 1 / -1; }
.field-grid > .field-amt { grid-column: auto; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field > span {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  line-height: 1.35;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;              /* >= 16px everywhere: no iOS zoom */
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color-scheme: dark;
}

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

.field input[type="date"],
.field input[type="time"] {
  font-family: var(--font-mono);
  min-height: var(--tap);
}

/* iOS renders date/time inputs oddly without this */
.field input[type="date"]::-webkit-date-and-time-value,
.field input[type="time"]::-webkit-date-and-time-value { text-align: left; }

.field input::placeholder,
.field textarea::placeholder { color: var(--ink-soft); }

.field input:read-only,
.field input:disabled,
.field textarea:read-only,
.field textarea:disabled {
  background: transparent;
  border-color: transparent;
  padding-left: 0;
  color: var(--ink);
  opacity: 1;
}

.field input[aria-invalid="true"],
.field input.is-invalid { border-color: var(--danger); }

/* number spinners are useless on a phone */
.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.form-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-actions .btn { width: 100%; }


/* --- repeatable install-item rows -------------------------------------- */
.item-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.item-row .item-input,
.item-row .f-item {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color-scheme: dark;
}

.item-row .item-input::placeholder,
.item-row .f-item::placeholder { color: var(--ink-soft); }

.item-remove {
  appearance: none;
  flex: 0 0 auto;
  width: var(--tap);
  min-height: var(--tap);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.item-remove:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.item-add,
#in-item-add {
  appearance: none;
  align-self: flex-start;
  margin-top: 8px;
  min-height: var(--tap);
  padding: 8px 14px;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.item-add:hover,
#in-item-add:hover { border-color: var(--accent); }


/* ---------------------------------------------------------------------
   9. BUTTONS
   ------------------------------------------------------------------ */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-success {
  background: var(--success-bg);
  color: var(--success-ink);
  border: 1px solid var(--success);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border: 1px solid var(--danger);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--surface-3); }

/* two-step cancel: armed = "tap again to really cancel" */
.btn.is-armed,
.btn-ghost.is-armed,
[data-action="cancel"].is-armed {
  color: var(--danger-ink);
  background: var(--danger-bg);
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 113, 105, 0.16);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.is-busy {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  color: var(--accent-ink);
}


/* ---------------------------------------------------------------------
   10. APPOINTMENT CARDS
   ------------------------------------------------------------------ */
.appt-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#view-history .appt-list { gap: 6px; }

.appt-card {
  display: block;
  padding: 12px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ink-faint);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* --- status / bucket driven left edge (order matters) --- */
.appt-card[data-status="pending"] { border-left-color: var(--accent); }
.appt-card[data-status="pending"][data-bucket="overdue"] {
  border-left-color: var(--warn);
  background:
    linear-gradient(90deg, rgba(255, 171, 74, 0.07) 0%, rgba(255, 171, 74, 0) 45%),
    var(--surface);
}
.appt-card[data-status="success"] { border-left-color: var(--success); }
.appt-card[data-status="failed"] { border-left-color: var(--danger); }

.appt-card.is-saving { border-color: rgba(248, 204, 70, 0.45); }
.appt-card.is-error { border-color: var(--danger); }

/* --- card header row --- */
.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.card-when {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.when-date { font-family: var(--font-mono); }

.when-time { color: var(--ink-soft); }

.when-time[data-empty="1"],
.when-time:empty {
  font-family: var(--font-body);
  font-weight: 400;
  font-style: italic;
}

.overdue-flag {
  display: none;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.appt-card[data-status="pending"][data-bucket="overdue"] .overdue-flag {
  display: inline-block;
}

/* --- card fields --- */
.appt-card .field-grid {
  gap: 10px;
  margin-bottom: 10px;
}

.appt-card .field > span { font-size: 10.5px; }

.appt-card .field input,
.appt-card .field textarea {
  padding: 9px 10px;
  font-size: 16px;
}

.appt-card .field-note { margin-bottom: 10px; }

/* --- total strip --- */
.card-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.card-total span {
  color: var(--ink-soft);
  font-weight: 600;
}

.card-total strong,
.card-total .f-total,
#in-total {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 17px;
  color: var(--accent);
}


/* --- payment method ---------------------------------------------------- */
.grp-payment { display: none; margin-bottom: 10px; }

.appt-card[data-status="pending"][data-bucket="today"] .grp-payment,
.appt-card[data-status="pending"][data-bucket="overdue"] .grp-payment {
  display: block;
}

.payment-label,
.photo-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}

.pay-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pay-btn {
  flex: 1 1 30%;
  appearance: none;
  min-height: var(--tap);
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.pay-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.appt-card[data-payment="cash"] .pay-btn[data-pay="cash"],
.appt-card[data-payment="transfer"] .pay-btn[data-pay="transfer"],
.appt-card[data-payment="credit"] .pay-btn[data-pay="credit"],
.pay-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}


/* --- photo attachment -------------------------------------------------- */
.grp-photo {
  display: none;
  position: relative;
  margin-bottom: 10px;
}

.appt-card[data-status="pending"][data-bucket="today"] .grp-photo,
.appt-card[data-status="pending"][data-bucket="overdue"] .grp-photo,
.appt-card[data-photo="1"] .grp-photo { display: block; }

.photo-upload-row {
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.appt-card[data-status="pending"][data-bucket="today"] .photo-upload-row,
.appt-card[data-status="pending"][data-bucket="overdue"] .photo-upload-row {
  display: flex;
}

.f-photo-input {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  font-size: 13px;
  color: var(--ink-soft);
}

.f-photo-input::file-selector-button {
  appearance: none;
  min-height: var(--tap);
  margin-right: 10px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.photo-remove {
  display: none;
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 6px 14px;
  font-size: 12px;
}

.appt-card[data-photo="1"] .photo-remove { display: inline-flex; }

.f-photo-img {
  display: none;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.appt-card[data-photo="1"] .f-photo-img,
.f-photo-img[src]:not([src=""]) { display: block; }

/* uploading spinner overlay (class may land on .grp-photo or on the card) */
.grp-photo.is-uploading,
.appt-card.is-uploading .grp-photo { position: relative; }

.grp-photo.is-uploading::before,
.appt-card.is-uploading .grp-photo::before {
  content: "";
  position: absolute;
  inset: -4px;
  z-index: 1;
  border-radius: var(--radius-sm);
  background: rgba(7, 20, 39, 0.62);
}

.grp-photo.is-uploading::after,
.appt-card.is-uploading .grp-photo::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  border: 3px solid rgba(248, 204, 70, 0.25);
  border-top-color: var(--accent);
}


/* --- action groups ----------------------------------------------------- */
.grp-buttons,
.grp-cancel { display: none; }

/* phone: full-width stacked action buttons */
.appt-card[data-status="pending"][data-bucket="today"] .grp-buttons,
.appt-card[data-status="pending"][data-bucket="overdue"] .grp-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.appt-card[data-status="pending"] .grp-cancel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.grp-buttons .btn,
.grp-cancel .btn { width: 100%; }


/* --- compact history row ----------------------------------------------- */
.grp-history-compact {
  display: none;
  flex-direction: column;
  gap: 4px;
}

/* a completed card collapses to its summary row */
.appt-card[data-status="success"],
.appt-card[data-status="failed"] {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
}

.appt-card[data-status="success"] .grp-history-compact,
.appt-card[data-status="failed"] .grp-history-compact {
  display: flex;
  order: -1;
}

.appt-card[data-status="success"] > .card-top,
.appt-card[data-status="success"] > .field-grid,
.appt-card[data-status="success"] > .card-total,
.appt-card[data-status="success"] > .grp-payment,
.appt-card[data-status="success"] > .grp-buttons,
.appt-card[data-status="success"] > .grp-cancel,
.appt-card[data-status="success"] .photo-upload-row,
.appt-card[data-status="failed"] > .card-top,
.appt-card[data-status="failed"] > .field-grid,
.appt-card[data-status="failed"] > .card-total,
.appt-card[data-status="failed"] > .grp-payment,
.appt-card[data-status="failed"] > .grp-buttons,
.appt-card[data-status="failed"] > .grp-cancel,
.appt-card[data-status="failed"] .photo-upload-row { display: none; }

/* The note stays editable after a job is completed, but it unfolds only when
   the compact row is tapped -- that is what app.js's `.is-expanded` toggle and
   the row's aria-expanded have always meant. Keeping it open unconditionally
   made every "compact" history row 136px tall instead of ~62px and made
   aria-expanded="false" describe content that was plainly visible.
   Nothing is hidden by collapsing it: a non-empty note is already appended to
   the summary line in .hc-row2 by historySummary(). */
.appt-card[data-status="success"] > .field-note,
.appt-card[data-status="failed"] > .field-note { display: none; }

.appt-card[data-status="success"].is-expanded > .field-note,
.appt-card[data-status="failed"].is-expanded > .field-note {
  display: flex;
  margin: 8px 0 0;
}

/* the summary row is the button that opens it, so it must look and focus like one */
.appt-card[data-status="success"] .grp-history-compact,
.appt-card[data-status="failed"] .grp-history-compact { cursor: pointer; }

.grp-history-compact:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}

.appt-card[data-status="success"] .grp-photo,
.appt-card[data-status="failed"] .grp-photo { margin: 6px 0 0; }

.appt-card[data-status="success"] .f-photo-img,
.appt-card[data-status="failed"] .f-photo-img {
  max-height: 96px;
  border-radius: 8px;
}

.hc-row1 {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.hc-when {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
}

.hc-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hc-badge {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.appt-card[data-status="success"] .hc-badge { color: var(--success); }
.appt-card[data-status="failed"] .hc-badge { color: var(--danger); }

.hc-row2 {
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ---------------------------------------------------------------------
   10b. LOAD-MORE (pagination — 10 cards at a time)
   ------------------------------------------------------------------ */
.load-more-row {
  display: flex;
  justify-content: center;
  margin: 12px 0 2px;
}

/* keeps the .btn.btn-ghost look, with a taller 48px target */
.load-more {
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  font-size: 13.5px;
}

/* " (เหลืออีก 14)" — a flex item of the button, so .btn's 6px gap spaces it.
   12.5px/600 is not WCAG "large text", so the count keeps --ink-soft
   (9.36:1 on --bg); --ink-faint would only reach 3.72:1. On hover the
   label brightens to --ink while the count stays --ink-soft, which keeps
   the two apart without dimming the count below AA. */
.load-more-rest {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* an empty span would otherwise add a stray 6px gap and off-centre the label */
.load-more-rest:empty { display: none; }


/* ---------------------------------------------------------------------
   11. EMPTY STATE
   ------------------------------------------------------------------ */
.empty-state {
  margin: 0;
  padding: 34px 16px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13.5px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}


/* ---------------------------------------------------------------------
   12. BOTTOM TAB BAR
   ------------------------------------------------------------------ */
#tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 50;
  width: 100%;
  max-width: 820px;
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(9, 24, 44, 0.88);
  border-top: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
  box-shadow: 0 -10px 30px -22px rgba(0, 0, 0, 1);
}

.tab-btn {
  position: relative;
  flex: 1 1 0;
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tab-h);
  padding: 6px 2px 4px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tab-icon {
  display: block;
  width: 22px;
  height: 22px;
  flex: none;
}

.tab-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab-label {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-btn .count {
  position: absolute;
  top: 4px;
  left: 50%;
  margin-left: 5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
}

.tab-btn .count:empty,
.tab-btn .count[data-count="0"] { display: none; }

/* active tab */
#app[data-view="add"] .tab-btn[data-tab="add"],
#app[data-view="today"] .tab-btn[data-tab="today"],
#app[data-view="upcoming"] .tab-btn[data-tab="upcoming"],
#app[data-view="history"] .tab-btn[data-tab="history"],
.tab-btn[aria-selected="true"] { color: var(--accent); }

#app[data-view="add"] .tab-btn[data-tab="add"]::before,
#app[data-view="today"] .tab-btn[data-tab="today"]::before,
#app[data-view="upcoming"] .tab-btn[data-tab="upcoming"]::before,
#app[data-view="history"] .tab-btn[data-tab="history"]::before,
.tab-btn[aria-selected="true"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
}

#app[data-view="add"] .tab-btn[data-tab="add"] .count,
#app[data-view="today"] .tab-btn[data-tab="today"] .count,
#app[data-view="upcoming"] .tab-btn[data-tab="upcoming"] .count,
#app[data-view="history"] .tab-btn[data-tab="history"] .count,
.tab-btn[aria-selected="true"] .count {
  background: var(--accent);
  color: var(--accent-ink);
}


/* ---------------------------------------------------------------------
   13. TOASTS
   ------------------------------------------------------------------ */
#toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 60;
  transform: translateX(-50%);
  width: min(100% - 24px, 460px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  pointer-events: none;
}

#toast-host:empty { display: none; }

.toast {
  pointer-events: auto;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow-lift);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
}

.toast[data-kind="error"],
.toast.is-error,
.toast.toast-error {
  border-left-color: var(--danger);
  color: var(--danger-ink);
  background: #2a1524;
}

.toast[data-kind="success"],
.toast.is-success,
.toast.toast-success {
  border-left-color: var(--success);
  color: var(--success-ink);
}

.toast[data-kind="warn"],
.toast.is-warn { border-left-color: var(--warn); }


/* ---------------------------------------------------------------------
   14. KEYFRAMES (applied only when motion is welcome — see section 15)
   ------------------------------------------------------------------ */
@keyframes war-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(7px); }
  45% { transform: translateX(-5px); }
  60% { transform: translateX(4px); }
  80% { transform: translateX(-2px); }
}

@keyframes war-spin { to { transform: rotate(360deg); } }

@keyframes war-btn-spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

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

@keyframes war-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes war-sweep {
  from { background-position: -120% 0; }
  to { background-position: 220% 0; }
}


/* ---------------------------------------------------------------------
   15. MOTION — everything animated lives behind prefers-reduced-motion
   ------------------------------------------------------------------ */
@media (prefers-reduced-motion: no-preference) {
  .tab-btn,
  .btn,
  .pay-btn,
  .stat-chip,
  .appt-card,
  .hc-badge,
  .item-remove,
  #logout-btn,
  #sync-pill {
    transition:
      background-color .15s ease,
      color .15s ease,
      border-color .15s ease,
      opacity .15s ease,
      transform .1s ease;
  }

  .field input,
  .field textarea,
  .search-row input,
  #lock-password { transition: border-color .15s ease, background-color .15s ease; }

  /* the chip ink must cross-fade with its fill, or a chip being selected
     shows dark ink on the dark surface for the length of the transition */
  .stat-chip .stat-n,
  .stat-chip .stat-l { transition: color .15s ease; }

  #top-bar.is-compact .hero-brand,
  .hero-brand {
    transition: height .18s ease, padding .18s ease, background-color .18s ease;
  }

  .btn:active,
  .pay-btn:active,
  .stat-chip:active,
  .tab-btn:active { transform: scale(0.97); }

  /* chip taps may scroll the rail to bring the chip into view */
  .summary-strip { scroll-behavior: smooth; }

  .is-shake,
  #lock-form.is-shake,
  #lock-screen.is-shake #lock-form { animation: war-shake .42s cubic-bezier(.36,.07,.19,.97) both; }

  .grp-photo.is-uploading::after,
  .appt-card.is-uploading .grp-photo::after { animation: war-spin .8s linear infinite; }

  .btn.is-busy::after { animation: war-btn-spin .7s linear infinite; }

  .toast { animation: war-toast-in .22s ease-out both; }

  #sync-pill[data-state="saving"]::before { animation: war-pulse 1s ease-in-out infinite; }

  #app.is-loading #top-bar::before { animation: war-sweep 1.1s linear infinite; }
}

/* reduced motion: the busy indicators must still read as "busy" */
@media (prefers-reduced-motion: reduce) {
  .grp-photo.is-uploading::after,
  .appt-card.is-uploading .grp-photo::after {
    border-color: var(--accent);
    border-top-color: transparent;
  }
  #sync-pill[data-state="saving"]::before { opacity: 0.6; }
}


/* ---------------------------------------------------------------------
   16. >= 600px — small tablets & large phones in landscape
   ------------------------------------------------------------------ */
@media (min-width: 600px) {
  :root {
    --hero-h: 220px;
    --gutter: 18px;
  }

  body { font-size: 15.5px; }

  main#views { padding-top: 18px; }

  /* two-column form grid; item + note + total still span the full width */
  .field-grid > * { grid-column: auto; }
  .field-grid > .field-item,
  .field-grid > .field-note,
  .field-grid > .card-total,
  .field-grid > .field-full { grid-column: 1 / -1; }

  .form-card { padding: 20px; }

  .form-actions {
    flex-direction: row;
    justify-content: flex-end;
  }
  .form-actions .btn { width: auto; min-width: 200px; }

  /* card action buttons go side-by-side */
  .appt-card[data-status="pending"][data-bucket="today"] .grp-buttons,
  .appt-card[data-status="pending"][data-bucket="overdue"] .grp-buttons,
  .appt-card[data-status="pending"] .grp-cancel {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .grp-buttons .btn,
  .grp-cancel .btn {
    flex: 1 1 160px;
    width: auto;
  }

  .appt-card { padding: 14px 16px 16px; }

  .brand-logo { height: 44px; }
  .brand-code { font-size: 27px; }
  .brand-full { font-size: 13px; }
  .hero-credit { font-size: 10.5px; top: 10px; right: 70px; max-width: calc(100% - 84px); }
  .hero-brand { padding: 14px 18px; gap: 14px; }

  #top-bar.is-compact .hero-brand { padding: 0 18px; }

  .panel-title { font-size: 20px; }

  /* room for four chips: the rail stops scrolling and flexes to fill */
  .summary-strip {
    flex-wrap: wrap;
    overflow: visible;
    margin-top: 0;
    padding: 0 0 12px;
    scroll-snap-type: none;
  }

  .stat-chip {
    flex: 1 1 88px;
    padding: 12px 14px;
  }

  .stat-chip .stat-n { font-size: 30px; }

  .load-more { width: 100%; max-width: 320px; }

  .f-photo-img { max-height: 280px; }

  .tab-btn { font-size: 11.5px; }
  .tab-icon { width: 23px; height: 23px; }

  .lock-card { padding: 30px 26px 26px; }
}


/* ---------------------------------------------------------------------
   17. >= 900px — desktop / shop counter screen
   ------------------------------------------------------------------ */
@media (min-width: 900px) {
  :root {
    --hero-h: 260px;
    --gutter: 24px;
  }

  main#views { padding-top: 22px; }

  .appt-list { gap: 12px; }

  .appt-card { padding: 16px 20px 18px; }

  .appt-card .field-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }
  .appt-card .field-grid > .field-name { grid-column: span 2; }
  .appt-card .field-grid > .field-phone,
  .appt-card .field-grid > .field-date,
  .appt-card .field-grid > .field-time { grid-column: span 1; }
  .appt-card .field-grid > .field-amt { grid-column: span 1; }
  .appt-card .field-grid > .field-item,
  .appt-card .field-grid > .field-note { grid-column: 1 / -1; }

  .brand-logo { height: 50px; }
  .brand-code { font-size: 31px; }
  .hero-brand { padding: 18px 22px; }

  .summary-strip { gap: 12px; }
  .stat-chip .stat-n { font-size: 34px; }

  .panel-head { padding-bottom: 16px; }

  #toast-host { width: min(100% - 48px, 520px); }
}
