:root {
  --limewash: #edefe8;
  --paper: #ffffff;
  --ink: #1f2a22;
  --muted: #5d6a5f;
  --line: #d6dbd1;
  --line-strong: #b9c1b3;
  --vine: #2f4630;
  --vine-ink: #e7eee2;
  --vine-soft: #dfe7d9;
  --clay: #b65735;
  --clay-dark: #93452a;
  --clay-soft: #f6e4dc;
  --grape: #6b3a5b;
  --grape-soft: #f0e3ec;
  --gold: #8a6512;
  --gold-soft: #f7ecd2;
  --ok: #2f6b3a;
  --ok-soft: #e1efe1;
  --danger: #a3312a;
  --radius-s: 6px;
  --radius-m: 10px;
  --serif: 'Spectral', Georgia, serif;
  --sans: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --rail: 232px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--limewash);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }
h1 { font-size: 30px; letter-spacing: -0.01em; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0; }
a { color: var(--clay-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
/* 16px stops iPhone/iPad Safari zooming in when a field is tapped. */
input, select, textarea { font-size: 16px; }
:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ───────── shell ───────── */
.shell { min-height: 100vh; min-height: 100dvh; }
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail);
  background: var(--vine); color: var(--vine-ink);
  display: flex; flex-direction: column; padding: 28px 16px 20px;
}
.brand { padding: 0 10px 28px; }
.brand-name { font-family: var(--serif); font-size: 23px; font-weight: 600; color: #fff; }
.brand-sub { font-size: 13px; opacity: 0.75; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-s);
  color: var(--vine-ink); text-decoration: none; font-weight: 500;
}
.nav a[aria-current='page'] { background: rgba(255, 255, 255, 0.13); color: #fff; }
.nav svg { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav .badge { margin-left: auto; background: var(--clay); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 8px; line-height: 20px; }
.rail-foot { margin-top: auto; padding: 0 10px; font-size: 13px; opacity: 0.85; display: grid; gap: 8px; }
.rail-foot button { background: none; border: 0; color: inherit; padding: 0; text-align: left; text-decoration: underline; cursor: pointer; }
.conn { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa596; flex: none; }
.dot.on { background: #9fd28f; }

main { margin-left: var(--rail); padding: 32px 40px 64px; max-width: calc(1160px + var(--rail)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .lead { margin-top: 4px; color: var(--muted); }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.freshness { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.linklike { background: none; border: 0; padding: 0; color: var(--clay-dark); text-decoration: underline; cursor: pointer; font-size: inherit; }

/* ───────── controls ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 16px; border-radius: var(--radius-s); border: 1px solid var(--line-strong);
  background: var(--paper); cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--clay); border-color: var(--clay); color: #fff; }
.btn.quiet { border-color: transparent; background: transparent; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }

.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: 14px; }
.field .hint { font-size: 13px; color: var(--muted); font-weight: 400; }
input[type='text'], input[type='search'], input[type='email'], input[type='tel'], input[type='number'], input[type='date'], input[type='time'], input[type='password'], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--paper);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--vine); outline: 2px solid var(--vine-soft); outline-offset: 0; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-strong); background: var(--paper); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px; font-weight: 500;
}
.chip[aria-pressed='true'] { background: var(--vine); border-color: var(--vine); color: #fff; }
.chip .count { opacity: 0.7; margin-left: 4px; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px 22px; }
.panel + .panel { margin-top: 16px; }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; align-items: start; }
.grid-2 > .panel { margin-top: 0; }

.notice { border-radius: var(--radius-m); padding: 12px 16px; margin-bottom: 16px; background: var(--gold-soft); color: #4a3608; border: 1px solid #e6d3a4; }
.notice.error { background: #f8e3e1; color: #5d1b16; border-color: #ebc0bb; }
.notice.ok { background: var(--ok-soft); color: #173d1f; border-color: #bfdcbf; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.loading { padding: 48px 0; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; transition: opacity 0.2s, transform 0.2s;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--radius-s); z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* ───────── reports ───────── */
.range-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.range-custom { display: flex; gap: 8px; align-items: center; }
.range-custom input { width: 160px; }
.headline-figure { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: end; }
.takings { font-family: var(--serif); font-size: 52px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.takings-label { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.delta { font-size: 14px; margin-top: 8px; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.stat { background: var(--paper); padding: 12px 14px; }
.stat-value { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.stat-label { font-size: 13px; color: var(--muted); }
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 12px var(--sans); fill: var(--muted); }
.chart .bar { fill: var(--vine); }
.chart .bar.today { fill: var(--clay); }
.chart .gridline { stroke: var(--line); }
.hbar { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; gap: 10px; align-items: center; padding: 6px 0; font-size: 14px; }
.hbar-track { height: 10px; background: var(--vine-soft); border-radius: 5px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--vine); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); font-size: 13px; }
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data td.r, table.data th.r { text-align: right; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; }

/* ───────── enquiries ───────── */
.inbox { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 16px; align-items: start; }
.inbox-filters { display: grid; gap: 10px; margin-bottom: 12px; }
.inbox-filters .row { display: flex; gap: 8px; }
.inbox-list { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; max-height: calc(100vh - 260px); max-height: calc(100dvh - 240px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.msg { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; cursor: pointer; }
.msg:last-child { border-bottom: 0; }
.msg[aria-current='true'] { background: var(--vine-soft); box-shadow: inset 3px 0 0 var(--vine); }
.msg-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.msg-name { font-weight: 600; font-size: 15px; margin-top: 2px; display: flex; gap: 8px; align-items: center; }
.msg.is-new .msg-name::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--clay); flex: none; }
.msg-subject { font-size: 14px; }
.msg-preview { font-size: 13px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.status { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 4px; padding: 1px 8px; white-space: nowrap; }
.status.new { background: var(--clay-soft); color: var(--clay-dark); }
.status.in_progress { background: var(--gold-soft); color: var(--gold); }
.status.replied { background: var(--vine-soft); color: var(--vine); }
.status.booked { background: var(--ok-soft); color: var(--ok); }
.status.closed { background: #eceeea; color: var(--muted); }
.source-tag { font-size: 12px; color: var(--muted); }
.reader { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 24px 28px; position: sticky; top: 20px; }
.reader-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 16px; }
.reader-meta { font-size: 14px; color: var(--muted); margin-top: 6px; display: grid; gap: 2px; }
.reader-body { white-space: pre-wrap; max-width: 70ch; line-height: 1.6; }
.reader-fields { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin-top: 18px; font-size: 14px; }
.reader-fields dt { color: var(--muted); }
.reader-fields dd { margin: 0; }
.reader-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.reader-track { display: grid; grid-template-columns: 220px 1fr; gap: 16px; margin-top: 18px; align-items: start; }
.back-link { display: none; }


/* ───────── replying ───────── */
.sent-reply { margin-top: 18px; padding: 14px 16px; background: #f4f7f1; border: 1px solid var(--line); border-left: 3px solid var(--vine); border-radius: var(--radius-s); }
.sent-reply-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.sent-reply-head strong { color: var(--vine); font-weight: 600; }
.composer { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.composer-meta { display: grid; gap: 2px; font-size: 14px; }
.composer-meta > div { display: grid; grid-template-columns: 64px 1fr; gap: 8px; overflow-wrap: anywhere; }
.composer textarea { min-height: 190px; line-height: 1.55; }
.composer-sig { white-space: pre-wrap; font-size: 14px; color: var(--muted); padding-left: 12px; border-left: 2px solid var(--line); }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--vine); }
.composer .form-actions { margin-top: 4px; flex-wrap: wrap; }

/* ───────── events ───────── */
.event { display: grid; grid-template-columns: 76px 1fr; gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.event:first-child { padding-top: 4px; }
.event:last-child { border-bottom: 0; padding-bottom: 4px; }
.datestone { text-align: center; border: 1px solid var(--grape); border-radius: var(--radius-s); overflow: hidden; align-self: start; }
.datestone .mon { background: var(--grape); color: #fff; font-size: 13px; font-weight: 600; padding: 2px 0; }
.datestone .day { font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1.25; color: var(--grape); }
.datestone .wd { font-size: 12px; color: var(--muted); padding-bottom: 4px; }
.event-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.event-when { color: var(--muted); font-size: 14px; margin-top: 2px; }
.event-desc { margin-top: 8px; font-size: 14px; max-width: 70ch; color: #3b473e; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.event-img { width: 88px; height: 64px; object-fit: cover; border-radius: var(--radius-s); flex: none; }
.tickets { margin-top: 12px; width: 100%; }
.event-tickets { grid-column: 2; }
.event > .datestone { grid-row: 1 / span 2; }
.stock-edit { display: inline-flex; gap: 6px; align-items: center; }
.stock-edit input { width: 76px; min-height: 32px; padding: 4px 8px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 4px; background: var(--grape-soft); color: var(--grape); }
.pill.warn { background: var(--gold-soft); color: var(--gold); }

.sheet { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 24px 28px; margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.ticket-rows { display: grid; gap: 8px; }
.ticket-row { display: grid; grid-template-columns: 1fr 120px 150px 40px; gap: 8px; align-items: center; }
.ticket-row-head { font-size: 13px; color: var(--muted); font-weight: 600; }
.icon-btn { width: 36px; height: 36px; border: 1px solid var(--line-strong); background: var(--paper); border-radius: var(--radius-s); cursor: pointer; display: grid; place-items: center; }
.form-actions { display: flex; gap: 8px; margin-top: 22px; align-items: center; }
.image-preview { width: 120px; height: 80px; object-fit: cover; border-radius: var(--radius-s); border: 1px solid var(--line); }

/* ───────── sunday roast ───────── */
.roast-day { margin-bottom: 28px; }
.roast-day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.roast-day-head .totals { font-size: 14px; color: var(--muted); }
.meals { display: flex; gap: 6px; flex-wrap: wrap; }
.meal { font-size: 13px; background: var(--vine-soft); color: var(--vine); border-radius: 4px; padding: 1px 8px; }
.sittings { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); }
.sitting { display: grid; grid-template-columns: 76px 1fr auto; gap: 20px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.sitting:last-child { border-bottom: 0; }
.sitting-time { font-family: var(--serif); font-size: 24px; font-weight: 600; }
.plates { display: flex; flex-wrap: wrap; gap: 5px; max-width: 420px; }
.plate { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--clay); background: var(--paper); }
.plate.booked { background: var(--clay); box-shadow: inset 0 0 0 3px var(--paper); }
.plate.closed { border-color: var(--line-strong); background: repeating-linear-gradient(135deg, var(--line) 0 2px, var(--paper) 2px 5px); }
.sitting-numbers { font-size: 14px; margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.sitting-numbers strong { font-weight: 600; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--radius-s); overflow: hidden; }
.stepper button { width: 38px; height: 38px; border: 0; background: var(--paper); cursor: pointer; font-size: 18px; }
.stepper input { width: 56px; min-height: 38px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0; text-align: center; padding: 0; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.covers-ctl { display: grid; gap: 6px; justify-items: end; }
.covers-ctl .label { font-size: 13px; color: var(--muted); }
.covers-ctl .row { display: flex; gap: 6px; }
.bookings { grid-column: 1 / -1; margin-top: -4px; }
.bookings summary { cursor: pointer; font-size: 14px; color: var(--clay-dark); font-weight: 600; width: fit-content; }
.bookings table { margin-top: 10px; }
.flag { font-size: 13px; color: var(--gold); }
.add-sittings .times { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.time-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 14px; background: var(--paper); }
.time-chip button { border: 0; background: none; cursor: pointer; width: 22px; height: 22px; border-radius: 50%; }


/* ───────── phone and in-person bookings ───────── */
.plate.booked.hand { border-color: var(--vine); background: var(--vine); }
.book-btn { margin-top: 10px; }
.booking-form { grid-column: 1 / -1; background: #f7f9f4; border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px 18px; display: grid; gap: 14px; }
.booking-form .panel-title { margin-bottom: 0; }
.bk-grid { display: grid; grid-template-columns: 1.2fr 1fr 1.2fr; gap: 12px; }
.bk-meals { display: flex; flex-wrap: wrap; gap: 10px 24px; }
.bk-meal { display: flex; align-items: center; gap: 12px; }
.bk-total { font-weight: 600; }
.bk-total.over { color: var(--danger); }
.bk-choices { display: flex; flex-wrap: wrap; gap: 12px 28px; }
.bk-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.roast-legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin: -6px 0 16px; align-items: center; flex-wrap: wrap; }
.roast-legend .plate { width: 14px; height: 14px; display: inline-block; vertical-align: -2px; margin-right: 6px; }
@media (max-width: 900px), (max-height: 500px) {
  .bk-grid { grid-template-columns: 1fr; }
  .bk-meals { flex-direction: column; gap: 10px; }
  .bk-meal { justify-content: space-between; }
  .booking-form { padding: 14px; }
}
@media (max-height: 500px) and (min-width: 700px) {
  .bk-grid { grid-template-columns: 1fr 1fr 1fr; }
  .bk-meals { flex-direction: row; }
}

/* ───────── customers ───────── */
.cust-tools { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cust-tools input { max-width: 360px; }
.cust-tools select { width: auto; }
.cust-contact { font-size: 13px; color: var(--muted); }
.person-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.person-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-top: 16px; }
.person-facts dt { font-size: 13px; color: var(--muted); }
.person-facts dd { margin: 2px 0 0; }
.order-lines { margin: 4px 0 0; padding: 0; list-style: none; font-size: 14px; }
.order-lines li { padding: 1px 0; }

/* ───────── login ───────── */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--vine); }
.login-card { background: var(--paper); border-radius: var(--radius-m); padding: 36px 32px; width: 100%; max-width: 380px; }
.login-card h1 { font-size: 28px; }
.login-card p { color: var(--muted); margin: 6px 0 24px; }
.login-card .btn { width: 100%; margin-top: 18px; min-height: 44px; }
.login-error { color: var(--danger); font-size: 14px; margin-top: 12px; min-height: 21px; }


/* ───────── pointer vs touch ───────── */
@media (hover: hover) {
  .nav a:hover { background: rgba(255, 255, 255, 0.07); }
  .btn:hover { border-color: var(--ink); }
  .btn.primary:hover { background: var(--clay-dark); border-color: var(--clay-dark); }
  .btn.quiet:hover { background: var(--vine-soft); }
  .chart .bar:hover { fill: var(--clay-dark); }
  table.data tr.clickable:hover td { background: #f6f8f3; }
  .msg:hover { background: #f6f8f3; }
  .stepper button:hover, .time-chip button:hover { background: var(--vine-soft); }
}
/* Pressed feedback for fingers. */
.btn:active, .chip:active, .stepper button:active, .icon-btn:active { transform: translateY(1px); }
.btn.primary:active { background: var(--clay-dark); }
.msg:active, table.data tr.clickable:active td { background: var(--vine-soft); }
.chart .bar.picked { fill: var(--clay-dark); }
.chart-readout { font-size: 14px; color: var(--muted); margin-top: 8px; min-height: 21px; }

/* Finger-sized targets (Apple asks for 44pt) on iPhone and iPad. */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; padding: 0 14px; }
  .chip { padding: 9px 16px; }
  input[type='text'], input[type='search'], input[type='email'], input[type='tel'], input[type='number'], input[type='date'], input[type='time'], input[type='password'], select { min-height: 44px; }
  .stepper button { width: 46px; height: 46px; font-size: 20px; }
  .stepper input { width: 60px; min-height: 46px; }
  .stock-edit input { min-height: 40px; width: 84px; }
  .icon-btn { width: 44px; height: 44px; }
  .time-chip { padding: 6px 6px 6px 14px; }
  .time-chip button { width: 32px; height: 32px; }
  .linklike.small, [data-close] { padding: 8px 0; }
  [data-cancel] { padding: 12px 0; display: inline-block; }
  .nav a { padding: 12px; }
  .bookings summary { padding: 8px 0; }
  .rail-foot button { padding: 12px 0; }
  .freshness .linklike, .mobile-top .linklike { padding: 12px 6px; margin: -12px -6px; }
  .person-facts dd a { display: inline-block; padding: 10px 0; margin: -10px 0; }
  .ticket-row { grid-template-columns: 1fr 120px 150px 44px; }
}

/* ───────── iPad landscape and small laptops ───────── */
@media (min-width: 901px) and (max-width: 1280px) and (min-height: 501px) {
  :root { --rail: 208px; }
  .rail { padding: 24px 12px 20px; }
  main { padding: 28px 28px 56px; }
  .inbox { grid-template-columns: minmax(280px, 340px) 1fr; }
  .reader { padding: 22px 24px; }
  .reader-track { grid-template-columns: 180px 1fr; }
  .takings { font-size: 46px; }
  .headline-figure { gap: 22px; }
  .sitting { gap: 16px; padding: 14px 16px; }
  .plates { max-width: 330px; }
}

/* ───────── small screens ───────── */
@media (max-width: 900px), (max-height: 500px) {
  .rail { position: fixed; inset: auto 0 0 0; width: auto; height: auto; flex-direction: row; padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); z-index: 20; border-top: 1px solid rgba(0, 0, 0, 0.2); }
  body.typing .rail { display: none; } /* keyboard up: give the screen to the form */
  .brand, .rail-foot { display: none; }
  .nav { flex-direction: row; width: 100%; gap: 0; }
  .nav a { flex: 1; flex-direction: column; gap: 3px; font-size: 11px; padding: 9px 2px 7px; min-height: 52px; border-radius: 0; position: relative; text-align: center; justify-content: center; }
  .nav svg { width: 22px; height: 22px; }
  .nav .badge { position: absolute; top: 4px; left: calc(50% + 6px); margin: 0; font-size: 10px; line-height: 16px; padding: 0 5px; }
  main { margin-left: 0; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(88px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 18px; }
  .head-actions { width: 100%; justify-content: space-between; }
  h1 { font-size: 25px; }
  .mobile-top { display: flex !important; }
  .grid-2 { grid-template-columns: 1fr; }
  .headline-figure { grid-template-columns: 1fr; gap: 16px; }
  .takings { font-size: 42px; }
  .inbox { grid-template-columns: 1fr; }
  .inbox-list { max-height: none; }
  .inbox.reading .inbox-col { display: none; }
  .inbox:not(.reading) .reader { display: none; }
  .reader { position: static; padding: 18px; }
  .back-link { display: inline-flex; margin-bottom: 12px; }
  .reader-track { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .ticket-row { grid-template-columns: 1fr 96px 44px; }
  .ticket-row .qty-col { grid-column: 1 / 3; }
  .ticket-row-head { display: none; }
  /* Time beside the plates, controls on one line underneath: a Sunday fits in far less scrolling. */
  .sitting { grid-template-columns: 58px 1fr; gap: 10px 12px; padding: 14px 16px; }
  .sitting-time { font-size: 22px; align-self: start; padding-top: 2px; }
  .covers-ctl { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
  .covers-ctl .label { width: 100%; }
  .plates { gap: 4px; }
  .plate { width: 17px; height: 17px; }
  .event { grid-template-columns: 56px 1fr; gap: 6px 14px; }
  .event-tickets { grid-column: 1 / -1; }
  .event > .datestone { grid-row: auto; }
  .datestone .day { font-size: 26px; }
  /* Ticket table becomes stacked rows on a phone. */
  table.tickets thead { display: none; }
  table.tickets tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.tickets tbody tr:last-child { border-bottom: 0; }
  table.tickets td { padding: 0; border: 0; text-align: left !important; }
  table.tickets td[data-label]::before { content: attr(data-label) ' '; color: var(--muted); }
  table.tickets td.stock { grid-column: 1 / -1; }
  .sheet { padding: 18px 16px; }
  .panel { padding: 16px; }
  .event-img { display: none; }
  .hide-sm { display: none; }
  table.data { font-size: 13px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .hbar { grid-template-columns: 76px 1fr auto; gap: 8px; }
  .inbox-filters .row select { flex: none; }
  .reader-actions .btn { flex: 1 1 auto; }
}

/* iPhone on its side: wide but short, so keep two columns where they fit. */
@media (max-height: 500px) and (min-width: 700px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .headline-figure { grid-template-columns: auto 1fr; }
  .stat-row { grid-template-columns: repeat(3, 1fr); }
  .sitting { grid-template-columns: 64px 1fr auto; }
  .covers-ctl { grid-column: auto; display: grid; justify-items: end; }
  .sitting-time { align-self: center; padding-top: 0; }
  .covers-ctl .label { width: auto; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .mobile-top { margin-top: 0; }
}
.mobile-top { display: none; justify-content: space-between; align-items: center; margin: -4px 0 16px; font-family: var(--serif); font-weight: 600; font-size: 18px; color: var(--vine); }
.mobile-top button { font-family: var(--sans); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
