/* Orderat web demo. Tokens follow the marketing site (site/src/assets/css/style.css): the same
   indigo brand gradient, cool background, IBM Plex fonts, radii and pill buttons. Logical
   properties throughout, so one stylesheet serves Arabic (RTL) and English (LTR). */

:root {
  color-scheme: light;
  --brand: #2f3fb0;
  --brand-2: #4a5fdc;
  --brand-grad: linear-gradient(135deg, #4a5fdc, #2f3fb0);
  --accent: #2f3fb0;
  --brand-soft: #e9ecff;
  --bg: #f4f6ff;
  --surface: #ffffff;
  --surface-2: #f7f8ff;
  --text: #1c1f3a;
  --muted: #565b82;
  --border: #e1e5fb;
  --ok: #17784a;
  --ok-soft: #e2f5eb;
  --warn: #8a5a00;
  --warn-soft: #fff1d6;
  --bad: #b42318;
  --bad-soft: #fdeceb;
  --out: #6d28d9;
  --out-soft: #efe9fe;
  --neutral-soft: #eef0f8;
  --radius-lg: 1.25rem;
  --radius-md: 0.9rem;
  --radius-sm: 0.6rem;
  --shadow: 0 12px 30px -12px rgba(47, 63, 176, 0.25);
  --shadow-sm: 0 1px 2px rgba(28, 31, 58, 0.05), 0 6px 18px -14px rgba(47, 63, 176, 0.25);
  --font-ar: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-en: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #9aa8ff;
  --brand-soft: #262d63;
  --bg: #0e1128;
  --surface: #171b38;
  --surface-2: #1d2244;
  --text: #eef0ff;
  --muted: #a4a9d0;
  --border: #2b3163;
  --ok: #5fd39a;
  --ok-soft: #173a2c;
  --warn: #f3c267;
  --warn-soft: #3d3016;
  --bad: #ff8a80;
  --bad-soft: #43201f;
  --out: #c4b5fd;
  --out-soft: #2e2458;
  --neutral-soft: #242a52;
  --shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --accent: #9aa8ff;
    --brand-soft: #262d63;
    --bg: #0e1128;
    --surface: #171b38;
    --surface-2: #1d2244;
    --text: #eef0ff;
    --muted: #a4a9d0;
    --border: #2b3163;
    --ok: #5fd39a;
    --ok-soft: #173a2c;
    --warn: #f3c267;
    --warn-soft: #3d3016;
    --bad: #ff8a80;
    --bad-soft: #43201f;
    --out: #c4b5fd;
    --out-soft: #2e2458;
    --neutral-soft: #242a52;
    --shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ar);
  font-size: 15px;
  line-height: 1.6;
}
html[lang="en"] body { font-family: var(--font-en); }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p, figure { margin: 0; }
h1, h2, h3, h4 { line-height: 1.35; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { width: 20px; height: 20px; flex: none; }
[dir="rtl"] .flip { transform: scaleX(-1); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.hidden { display: none !important; }
/* The hidden attribute wins over a layout class (Edit order's delivery fields carry .stack-sm). */
[hidden] { display: none !important; }
.warn-text { color: var(--warn); }
.bad-text { color: var(--bad); }
button.kpi-link { font: inherit; color: var(--text); text-align: start; cursor: pointer; width: 100%; }
.link-btn.owes { color: var(--text); font-weight: 500; min-height: 44px; }
.overdue-card { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }

/* ---------- Layout: sidebar on desktop, floating tab bar on phones ---------- */

.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.side {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1rem; padding: 1.25rem 1rem;
  background: var(--surface); border-inline-end: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--text); padding-inline: 0.4rem; }
.brand img { border-radius: 0.6rem; }
.brand b { display: block; font-size: 1.2rem; }
.brand small { display: block; color: var(--muted); font-size: 0.75rem; }
.side-shop {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.7rem; color: var(--text);
  border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border);
}
.side-shop small { color: var(--muted); font-size: 0.8rem; }
.side-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.side-link {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md); color: var(--text); font-weight: 500;
}
.side-link:hover { background: var(--surface-2); }
.side-link.on { background: var(--brand-soft); color: var(--accent); font-weight: 700; }
.side-link.is-new { background: var(--brand-grad); color: #fff; font-weight: 700; margin-block: 0.35rem; box-shadow: var(--shadow); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.main { min-width: 0; width: 100%; max-width: 980px; padding: 1.75rem 2.25rem 3rem; }
.top { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; }
.top-title { flex: 1; min-width: 0; }
.top-title h1 { font-size: clamp(1.6rem, 3vw, 2rem); font-weight: 700; }
.top-title p { color: var(--muted); }
.top-actions { display: flex; gap: 0.5rem; align-items: center; }
.tabbar, .icon-btn.mobile-only { display: none; }

@media (max-width: 899px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .main { padding: 1rem 1rem calc(6.5rem + env(safe-area-inset-bottom)); }
  .icon-btn.mobile-only { display: inline-flex; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; z-index: 30;
    inset-inline: 0.6rem; bottom: calc(0.6rem + env(safe-area-inset-bottom)); padding: 0.35rem;
    border-radius: 1.5rem; border: 1px solid var(--border); box-shadow: var(--shadow);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 0.1rem; padding: 0.4rem 0.15rem;
    border-radius: 1.1rem; color: var(--muted); font-size: 0.75rem; font-weight: 500; text-align: center;
  }
  .tab.on { color: var(--accent); background: var(--brand-soft); font-weight: 700; }
  .tab.is-new .ic { width: 24px; height: 24px; color: var(--accent); }
}

/* ---------- Building blocks ---------- */

.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { display: flex; flex-direction: column; gap: 0.75rem; }
.card {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm);
}
button.card { width: 100%; text-align: start; cursor: pointer; font: inherit; }
.card-title { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.5rem; }
.card-title .ic { width: 18px; height: 18px; }
.stack-sm > .card-title, .split .card-title { margin-bottom: 0; }
.split { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } }

.list { padding-block: 0.2rem; }
.row {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; padding: 0.8rem 0;
  color: var(--text); background: none; border: 0; text-align: start; cursor: pointer; font: inherit;
}
.row + .row { border-top: 1px solid var(--border); }
a.card.row { padding: 0.8rem 1.1rem; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-main b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.row-main small { color: var(--muted); font-size: 0.85rem; display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.row-main small.one-line { flex-wrap: nowrap; min-width: 0; }
.one-line .when { flex: none; }
.one-line .what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.one-line .what::before { content: "· "; }
.see-all { display: inline-block; margin-top: 0.4rem; min-height: 44px; line-height: 44px; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; }
.row-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 0.7rem; background: var(--brand-soft); color: var(--accent); flex: none; }
.row .chev { color: var(--muted); width: 18px; height: 18px; }
.row.dim { opacity: 0.55; }
.row.danger, .row.danger:hover .row-main > b { color: var(--bad); }
.row.danger .row-ic { background: var(--bad-soft); color: var(--bad); }
.row-actions { display: flex; gap: 0.4rem; }
.web-order { flex-wrap: wrap; cursor: default; }
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.group-title { font-size: 0.9rem; color: var(--muted); font-weight: 700; margin: 1.1rem 0.3rem 0.45rem; }
.group-title:first-child { margin-top: 0.4rem; }
.empty { color: var(--muted); text-align: center; padding: 1.2rem 0.5rem; }
.note {
  font-size: 0.85rem; color: var(--muted); padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md); background: var(--surface-2); border: 1px dashed var(--border);
}
.ai-note {
  display: flex; gap: 0.45rem; align-items: flex-start; margin-top: 0.75rem; padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--accent); font-size: 0.88rem; font-weight: 500;
}
.stack-sm > .ai-note { margin-top: 0; }
.ai-note .ic { width: 18px; height: 18px; margin-top: 0.15rem; }

.badge { display: inline-flex; align-items: center; padding: 0.1rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.badge.neutral { background: var(--neutral-soft); color: var(--muted); }
.badge.brand { background: var(--brand-soft); color: var(--accent); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
/* Out for delivery, between Ready (warn) and Delivered (ok). */
.badge.out { background: var(--out-soft); color: var(--out); }
.src { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; flex: none; }
.src .ic { width: 14px; height: 14px; }
.src-whatsapp { background: rgba(31, 157, 85, 0.14); color: #1f9d55; }
.src-instagram { background: rgba(216, 27, 96, 0.13); color: #d81b60; }
.src-link { background: var(--brand-soft); color: var(--accent); }
.src-manual { background: var(--neutral-soft); color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.65rem 1.2rem;
  border-radius: 999px; border: 1.5px solid transparent; font-weight: 700; white-space: nowrap; cursor: pointer; text-decoration: none;
}
.btn .ic { width: 18px; height: 18px; }
.btn.primary { background: var(--brand-grad); color: #fff; box-shadow: var(--shadow); }
.btn.primary:hover { opacity: 0.93; }
.btn.ghost { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.dark { background: #111; color: #fff; }
.btn.danger-soft { background: var(--bad-soft); color: var(--bad); }
.btn.small { padding: 0.4rem 0.85rem; font-size: 0.85rem; }
.btn.big { padding: 0.85rem 1.6rem; font-size: 1.02rem; }
.btn.block { width: 100%; }
.btn.grow { flex: 1; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.btn-col { display: flex; flex-direction: column; gap: 0.5rem; }
textarea + .btn-row { margin-top: 0.75rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; cursor: pointer;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
}
.icon-btn.accent { color: var(--accent); }
.lang-btn { width: auto; display: inline-flex; align-items: center; gap: 0.3rem; padding-inline: 0.75rem; font-size: 0.8rem; font-weight: 700; }
.lang-btn .ic { width: 16px; height: 16px; }
.pill {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.9rem; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 0.85rem;
}
.pill .ic { width: 16px; height: 16px; }
.pill:hover { border-color: var(--accent); }
.link-btn { background: none; border: 0; padding: 0.2rem 0; color: var(--accent); font-weight: 700; cursor: pointer; text-align: start; }
.link-btn.danger { color: var(--bad); }

.chips { display: flex; gap: 0.45rem; overflow-x: auto; padding-bottom: 0.2rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem; flex: none; padding: 0.4rem 0.9rem; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 0.9rem; font-weight: 500;
}
.chip .ic { width: 16px; height: 16px; }
.chip.on { background: var(--brand-grad); color: #fff; border-color: transparent; font-weight: 700; }
.chip.small { padding: 0.25rem 0.7rem; font-size: 0.8rem; }
.chip.static { cursor: default; background: var(--surface-2); }
.search {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; padding: 0.55rem 1rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}
.search input { border: 0; outline: 0; background: none; flex: 1; min-width: 0; padding: 0; }
.search input:focus { box-shadow: none; }

.kpis { display: grid; gap: 0.75rem; }
.kpis.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi {
  display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; padding: 0.9rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.kpi-v { font-size: 1.35rem; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-l { color: var(--muted); font-size: 0.85rem; }
.kpi.bad .kpi-v { color: var(--bad); }
.kpi.ok .kpi-v { color: var(--ok); }
.delta { align-self: flex-start; font-size: 0.75rem; font-weight: 700; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
@media (max-width: 720px) { .kpis.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .kpi { padding: 0.75rem; } .kpi-v { font-size: 1.05rem; } }

.meter { height: 10px; margin: 0.6rem 0 0.4rem; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--brand-grad); }
.meter span.full { background: var(--bad); }
.accent-text { color: var(--accent); }
.setup-row { width: 100%; min-height: 48px; }
.setup-row.done .row-main b { color: var(--muted); font-weight: 500; }
.setup-mark { display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); color: #fff; }
.setup-mark.done { background: #34c759; border-color: transparent; }
.setup-mark .ic { width: 16px; height: 16px; stroke-width: 2.4; }
.setup-card .link-btn { margin-top: 0.3rem; color: var(--muted); font-weight: 500; }
.line { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.45rem 0; }
.line + .line { border-top: 1px dashed var(--border); }
.line.muted { color: var(--muted); }
.line.total { font-weight: 700; font-size: 1.05rem; }
.line.small { font-size: 0.85rem; }
.line > span:last-child { text-align: end; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field > span { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.field .seg { align-self: flex-start; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea {
  width: 100%; min-width: 0; padding: 0.6rem 0.75rem; outline: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
/* 16px on phones and tablets, so focusing a field never zooms the page on iPhone Safari. */
@media (max-width: 899px) { input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea { font-size: 16px; } }
@media (pointer: coarse) {
  .stepper button, .icon-btn { width: 44px; height: 44px; }
  .chip, .seg span { min-height: 44px; display: inline-flex; align-items: center; }
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
textarea { resize: vertical; line-height: 1.6; }
.static { padding: 0.6rem 0; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; padding: 0.25rem; border-radius: 1.1rem; background: var(--surface-2); border: 1px solid var(--border); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 0.35rem 0.9rem; border-radius: 0.9rem; font-size: 0.88rem; font-weight: 500; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--accent); font-weight: 700; box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.switch-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.2rem 0; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; flex: none; width: 46px; height: 28px; border-radius: 999px; background: var(--neutral-soft); border: 1px solid var(--border); transition: background 0.15s; }
.switch::after {
  content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: inset-inline-start 0.15s;
}
.switch-row input:checked + .switch { background: #34c759; border-color: transparent; }
.switch-row input:checked + .switch::after { inset-inline-start: 20px; }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 0.45rem; font-size: 0.88rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.stepper { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.15rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.stepper button { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--brand-soft); color: var(--accent); cursor: pointer; }
.stepper b { min-width: 2.2ch; text-align: center; font-variant-numeric: tabular-nums; }
.items-ed .stepper input.qty {
  flex: none; width: 2.75rem; padding: 0.45rem 0.1rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums;
  border-color: transparent; background: transparent; -moz-appearance: textfield; appearance: textfield;
}
.stepper input.qty::-webkit-inner-spin-button, .stepper input.qty::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.item-controls .icon-btn { width: 44px; height: 44px; color: var(--bad); }
.items-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem; }
.picker .row { width: 100%; }
.stepper .ic { width: 16px; height: 16px; }
.items-ed { display: flex; flex-direction: column; gap: 0.6rem; }
.item-row { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.6rem; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-2); }
.item-row select, .item-row input { background: var(--surface); }
.item-controls { display: flex; align-items: center; gap: 0.5rem; }
.stepper button { flex: none; }
.item-controls .price { flex: 1 1 4rem; width: auto; min-width: 0; max-width: 140px; margin-inline-start: auto; }
.item-controls .stepper { flex: none; }
@media (min-width: 720px) {
  .item-row { flex-direction: row; align-items: center; }
  .item-row > select, .item-row > input { flex: 1; }
}
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.75rem; }
/* New order's payment: the deposit is a small secondary link under the two main choices. */
.pay-more { display: inline-flex; align-items: center; gap: 0.3rem; align-self: flex-start; min-height: 44px; font-size: 0.85rem; font-weight: 500; }
.pay-more .ic { width: 16px; height: 16px; }
.save-bar {
  position: sticky; bottom: 1rem; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1rem;
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
@media (max-width: 899px) {
  .save-bar { bottom: calc(5.6rem + env(safe-area-inset-bottom)); }
  /* New order: the save bar takes the tab bar's place, so the form keeps the room. */
  body.route-new .tabbar { display: none; }
  body.route-new .save-bar { bottom: calc(1rem + env(safe-area-inset-bottom)); }
  body.route-new .main { padding-bottom: calc(2rem + env(safe-area-inset-bottom)); }
}
.join { display: flex; gap: 0.5rem; align-items: flex-end; }
.join .field { flex: 1; }

/* ---------- Screens ---------- */

.onb {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem 1rem;
  background: radial-gradient(circle at 15% 0%, var(--brand-soft), transparent 60%), var(--bg);
}
.onb-card {
  width: min(640px, 100%); display: flex; flex-direction: column; gap: 0.7rem; padding: 1.6rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 1.6rem; box-shadow: var(--shadow);
}
.onb-head { display: flex; justify-content: space-between; align-items: center; }
.onb-head img { border-radius: 1rem; }
.onb h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
.kicker { color: var(--accent); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; }
.types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; margin-top: 0.4rem; }
.type {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.9rem; cursor: pointer; text-align: start; color: var(--text);
  border-radius: var(--radius-md); border: 1.5px solid var(--border); background: var(--surface-2);
}
.type-ic, .ask-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 0.9rem; background: var(--brand-grad); color: #fff; flex: none; }
@media (max-width: 520px) { .types { grid-template-columns: minmax(0, 1fr); } }

/* Signing in (live.js): the start screen, log in with the phone, the shop picker */
.onb-card.start { width: min(460px, 100%); }
.signin { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.4rem; }
.g-btn { min-height: 44px; display: flex; justify-content: center; align-items: center; }
.btn.apple { background: #000; color: #fff; border-radius: 999px; }
:root[data-theme="dark"] .btn.apple { background: #fff; color: #000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.apple { background: #fff; color: #000; } }
.signin .btn.ghost { border-radius: 999px; }
.or { display: flex; align-items: center; gap: 0.7rem; color: var(--muted); font-size: 0.85rem; margin-block: 0.3rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.form-error { color: var(--bad); font-size: 0.9rem; }
.field-error { display: block; color: var(--bad); font-size: 0.85rem; font-weight: 500; }
[aria-invalid="true"] { border-color: var(--bad) !important; }
.pay-row .icon-btn { width: 44px; height: 44px; color: var(--bad); box-shadow: none; }
.steps { margin: 0.2rem 0; padding-inline-start: 1.3rem; display: grid; gap: 0.3rem; }
.pair-box { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.pair-qr .qr { width: min(220px, 60vw); height: auto; display: block; border-radius: 0.6rem; }
.pair-code { font-size: clamp(1.8rem, 8vw, 2.4rem); font-weight: 700; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }
.loading { display: flex; flex-direction: column; align-items: center; gap: 0.7rem; padding: 1.5rem 0; text-align: center; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.chips.store { margin-block: 0.2rem; }
.live-banner {
  position: fixed; z-index: 90; inset-inline: 0; top: 0; padding: 0.45rem 1rem; text-align: center;
  background: var(--bad-soft); color: var(--bad); font-size: 0.85rem; font-weight: 500;
}
.banner-chip { display: inline-block; margin-inline-start: 0.4rem; padding: 0.05rem 0.55rem; border-radius: 999px; background: var(--surface); font-weight: 700; }
body.has-banner .main { padding-top: calc(1.75rem + 2.4rem); }
@media (max-width: 899px) { body.has-banner .main { padding-top: calc(1rem + 2.4rem); } }
.thumb { width: 40px; height: 40px; border-radius: 0.6rem; object-fit: cover; flex: none; background: var(--surface-2); }
.thumb.lg { width: 72px; height: 72px; }
.photo-row { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.row:disabled { cursor: default; opacity: 1; }

.ask-card, .shop-card { display: flex; align-items: center; gap: 0.85rem; }
.demo-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--brand-soft); border-color: transparent; }
.demo-banner p { font-weight: 500; }
@media (max-width: 560px) { .demo-banner { flex-direction: column; align-items: stretch; } }
.camp-card { display: block; border-inline-start: 5px solid var(--camp); }
.camp-card .row { padding: 0.15rem 0; }
.camp-card .link-btn { margin-top: 0.3rem; }
.camp-emoji {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none; font-size: 1.5rem;
  border-radius: 0.9rem; background: color-mix(in srgb, var(--camp) 16%, transparent);
}
.camp-emoji.big { width: 72px; height: 72px; font-size: 2.3rem; border-radius: 1.2rem; }
.camp-hero { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; border-top: 5px solid var(--camp); }
.camp-hero .btn-row { margin-top: 0.4rem; }
.od-head h2 { font-size: 1.15rem; }
.od-head.tappable { cursor: pointer; }
@media (hover: hover) { .od-head.tappable:hover { border-color: var(--accent); } }
.od-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.45rem; }
.od-meta .ic { width: 18px; height: 18px; }
.od-address { margin-top: 0.6rem; display: flex; flex-direction: column; gap: 0.4rem; }
.od-address p { white-space: pre-line; }
.od-notes { margin-top: 0.6rem; padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.lines .link-btn { margin-top: 0.3rem; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid line { stroke: var(--border); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font-en); }
.chart rect { fill: var(--brand-2); }
.chart rect:hover { fill: var(--brand); }
.avatar { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--brand-grad); color: #fff; font-weight: 700; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.3rem; }
.avatar.sm { width: 34px; height: 34px; font-size: 0.9rem; }
.shop-card .row-main b { font-size: 1.15rem; }
.caption-box { white-space: pre-line; line-height: 1.7; padding: 0.8rem 0.9rem; border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); }
.caption { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.bullets { margin: 0; padding-inline-start: 1.2rem; display: flex; flex-direction: column; gap: 0.35rem; }
.studio-photo {
  display: grid; place-items: center; height: 220px; overflow: hidden; color: var(--muted);
  border-radius: var(--radius-md); background: var(--surface-2); border: 1px dashed var(--border);
}
.studio-photo .ic { width: 42px; height: 42px; }
.studio-photo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 0.6rem; }
.style {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem; padding: 0.5rem; cursor: pointer; color: var(--text);
  border-radius: var(--radius-md); border: 2px solid transparent; background: var(--surface-2);
}
.style.on { border-color: var(--accent); background: var(--brand-soft); }
.swatch { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 14px; border: 1px solid rgba(0, 0, 0, 0.08); font-size: 1.4rem; }
.before-after { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.before-after figure { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.before-after img { width: 100%; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.before-after figcaption { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.slug { display: flex; align-items: center; gap: 0.4rem; }
.slug-status { color: var(--muted); }
.slug-status.available { color: var(--ok); }
.slug-status.taken, .slug-status.invalid { color: var(--bad); }
.link-url { font-weight: 700; word-break: break-all; }
.member { padding-top: 0.75rem; border-top: 1px solid var(--border); }
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem 0.8rem; margin-top: 0.5rem; }
.invite-code { font-size: 2rem; font-weight: 700; letter-spacing: 0.3em; }

/* Receipts stay paper-white in dark mode too. */
.receipt {
  display: flex; flex-direction: column; gap: 0.8rem; max-width: 460px; margin-inline: auto; padding: 1.5rem;
  background: #fff; color: #111; font-size: 0.92rem; border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.rc-head { display: flex; align-items: center; gap: 0.8rem; }
.rc-head h2 { font-size: 1.15rem; }
.rc-title { text-align: center; font-size: 1rem; padding: 0.4rem; border-block: 1px dashed #bbb; }
.rc-meta { display: flex; flex-direction: column; gap: 0.15rem; color: #444; }
.rc-table { width: 100%; border-collapse: collapse; }
.rc-table th, .rc-table td { text-align: start; padding: 0.4rem 0.2rem; border-bottom: 1px solid #eee; }
.rc-table th:nth-child(2), .rc-table td:nth-child(2) { text-align: center; }
.rc-table th:last-child, .rc-table td:last-child { text-align: end; white-space: nowrap; }
.rc-totals .line + .line { border-top-color: #ddd; }
.rc-qr { margin-inline: auto; display: flex; flex-direction: column; align-items: center; gap: 0.3rem; font-size: 0.8rem; color: #555; }
.rc-thanks { text-align: center; color: #555; }
.receipt + .btn-row { justify-content: center; margin-top: 1rem; }

.paywall { align-items: center; text-align: center; }
.paywall img { border-radius: 1rem; }
.checks { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem 0.9rem; text-align: start; }
.checks li { display: flex; align-items: flex-start; gap: 0.4rem; font-size: 0.9rem; }
.checks .ic { width: 18px; height: 18px; margin-top: 0.2rem; color: var(--ok); }
.plans { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }
.plan { display: flex; align-items: center; gap: 0.75rem; padding: 0.8rem 1rem; cursor: pointer; text-align: start; border: 2px solid var(--border); border-radius: var(--radius-md); }
.plan:has(input:checked) { border-color: var(--accent); background: var(--brand-soft); }
.plan input { width: 18px; height: 18px; accent-color: var(--brand); }
@media (max-width: 480px) { .checks { grid-template-columns: minmax(0, 1fr); } }

.ask { display: flex; flex-direction: column; gap: 0.75rem; }
.ask-log { display: flex; flex-direction: column; gap: 0.6rem; min-height: 180px; max-height: 46vh; overflow-y: auto; padding: 0.25rem; }
.ask-empty { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; padding: 1.2rem 0; text-align: center; }
.ask-empty .ic { width: 40px; height: 40px; color: var(--accent); }
.msg { max-width: 88%; padding: 0.6rem 0.85rem; border-radius: 1.1rem; line-height: 1.6; }
.msg > * + * { margin-top: 0.4rem; }
.msg ul, .msg ol { margin-bottom: 0; padding-inline-start: 1.2rem; }
.msg.me { align-self: flex-end; background: var(--brand-grad); color: #fff; border-end-end-radius: 0.35rem; }
.msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-end-start-radius: 0.35rem; }
.msg.typing { color: var(--muted); font-style: italic; }
.ask-form { display: flex; gap: 0.5rem; }
.ask-form .btn { padding-inline: 0.9rem; }

/* ---------- Dialog and toast ---------- */

dialog#modal { width: min(560px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; border: 0; background: transparent; color: var(--text); overflow: visible; }
dialog#modal.wide { width: min(680px, calc(100vw - 2rem)); }
dialog#modal::backdrop { background: rgba(12, 14, 36, 0.45); }
.sheet {
  display: flex; flex-direction: column; max-height: calc(100dvh - 2rem); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.45);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem 0.6rem; }
.sheet-head h2 { font-size: 1.15rem; }
.sheet-body { padding: 0.4rem 1.2rem 1.2rem; overflow-y: auto; }
@media (max-width: 560px) {
  dialog#modal, dialog#modal.wide { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; }
  .sheet { max-height: 92dvh; border-radius: 1.4rem 1.4rem 0 0; }
}
.toast {
  position: fixed; z-index: 100; inset-inline: 0; bottom: calc(6.5rem + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 2rem);
  margin-inline: auto; padding: 0.6rem 1.1rem; border-radius: 999px; background: var(--text); color: var(--surface);
  font-size: 0.9rem; font-weight: 500; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.toast.has-action { display: flex; align-items: center; gap: 0.9rem; padding-block: 0.3rem; padding-inline-end: 0.35rem; pointer-events: auto; }
.toast-act {
  min-height: 40px; padding: 0 1rem; border: 0; border-radius: 999px; cursor: pointer;
  background: color-mix(in srgb, var(--surface) 18%, transparent); color: var(--surface); font: inherit; font-weight: 700;
}
.toast.show { opacity: 1; transform: none; }
@media (min-width: 900px) { .toast { bottom: 2rem; } }

/* Hover styles only where a pointer really hovers, so a tap on a phone doesn't leave them stuck. */
@media (hover: hover) {
  .row:hover .row-main > b { color: var(--accent); }
  .type:hover { border-color: var(--accent); background: var(--brand-soft); }
}

@media print {
  body { background: #fff; }
  .side, .tabbar, .top, .no-print, .toast { display: none !important; }
  .app { display: block; }
  .main { max-width: none; padding: 0; }
  .receipt { border: 0; box-shadow: none; }
}
