:root {
  --ink: #1f2f3a;
  --muted: #667681;
  --line: #d7e0e4;
  --surface: #ffffff;
  --canvas: #f2f6f7;
  --navy: #163746;
  --navy-soft: #e7f0f3;
  --orange: #d75d3c;
  --orange-dark: #af452b;
  --orange-soft: #fff1eb;
  --teal: #16776e;
  --teal-soft: #e8f6f2;
  --shadow: 0 8px 24px rgba(31, 47, 58, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px clamp(18px, 4vw, 58px);
  color: #fff;
  background: var(--navy);
}
.topbar h1 { margin: 0; font-size: clamp(1.35rem, 2.2vw, 2rem); letter-spacing: 0; }
.eyebrow { margin: 0 0 3px; color: #86a9b8; font-size: .7rem; font-weight: 800; letter-spacing: .12em; }
.top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.top-status { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 9px 11px; color: #e0edf1; border: 1px solid #64808b; border-radius: 5px; font-size: .82rem; font-weight: 800; }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: #aab8bc; }
.state-online .status-dot { background: #7bd4a6; }
.state-offline .status-dot, .state-error .status-dot { background: #f2a08b; }
.state-never_connected .status-dot, .state-not_configured .status-dot { background: #e6c777; }

.page-shell { width: min(1440px, calc(100% - 32px)); margin: 24px auto 42px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); }
.date-bar { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 16px 18px; }
.date-actions, .form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.remote-panel { margin-top: 14px; padding: 20px; }
.section-note { max-width: 58ch; margin: 5px 0 0; color: var(--muted); font-size: .88rem; }
.remote-status { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .82rem; }
.remote-status.state-online { color: #17704e; border-color: #9acaae; background: #eef8f0; }
.remote-status.state-offline, .remote-status.state-error { color: #a44436; border-color: #e6b1a6; background: #fff4f1; }
.remote-status.state-never_connected, .remote-status.state-not_configured { color: #8c6314; border-color: #e4ce91; background: #fff9e9; }
.remote-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(360px, 1.1fr); gap: 24px; padding-top: 4px; }
.remote-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin: 0; }
.remote-facts div { border-top: 1px solid var(--line); padding-top: 8px; }
.remote-facts dt { color: var(--muted); font-size: .76rem; }
.remote-facts dd { margin: 2px 0 0; font-weight: 800; }
.remote-actions { display: grid; gap: 10px; align-content: start; }
.remote-date-field { margin-bottom: 0; }
.remote-action-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.remote-export-row { display: grid; grid-template-columns: auto minmax(110px, 1fr) auto; align-items: center; gap: 9px; color: var(--muted); font-size: .82rem; font-weight: 800; }
.remote-export-row select { padding: 8px 10px; }
.remote-result-wrap { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 15px; }
.compact-heading { align-items: center; margin-bottom: 10px; }
.compact-heading h3 { margin: 0; font-size: 1rem; }
.compact-heading .button { min-height: 36px; padding: 6px 10px; font-size: .82rem; }
.remote-jobs { display: grid; gap: 7px; }
.remote-job { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 12px; border-top: 1px solid var(--line); }
.remote-job-main { min-width: 0; }
.remote-job-main strong, .remote-job-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remote-job-main small { color: var(--muted); font-size: .76rem; }
.job-status { display: inline-flex; flex: 0 0 auto; min-width: 55px; justify-content: center; padding: 3px 8px; border-radius: 999px; font-size: .76rem; font-weight: 800; }
.status-queued { color: #8c6314; background: #fff4cd; }
.status-running { color: #1f5f86; background: #e8f3fb; }
.status-succeeded { color: #17704e; background: #e5f3e8; }
.status-failed { color: #a44436; background: #fff0ec; }
.remote-result { margin: 12px 0 0; padding: 10px 12px; border: 1px solid var(--line); color: var(--ink); background: #f7faf8; font: inherit; font-size: .82rem; white-space: pre-wrap; overflow-wrap: anywhere; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 14px 0; }
.metric { padding: 14px 16px; }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; margin: 4px 0 0; font-size: 2rem; line-height: 1.1; }
.metric small { font-size: .8rem; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr); gap: 14px; align-items: start; }
.order-editor, .students-panel, .orders-panel { padding: 20px; }
.orders-panel { margin-top: 14px; }
.section-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
h2 { margin: 0; font-size: 1.3rem; }
h3 { margin: 0; font-size: 1.05rem; }
.status-chip, .count-label { display: inline-flex; align-items: center; min-height: 30px; padding: 3px 9px; border-radius: 999px; color: var(--navy); background: var(--navy-soft); font-size: .78rem; font-weight: 800; white-space: nowrap; }

.field { display: grid; gap: 6px; margin-bottom: 13px; }
label, legend { color: var(--ink); font-size: .86rem; font-weight: 800; }
input, select, textarea { width: 100%; min-height: 46px; border: 1px solid #b6c6cd; border-radius: 5px; padding: 10px 12px; color: var(--ink); background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(22, 119, 110, .14); }
input:disabled { color: #8b999f; background: #f2f5f6; cursor: not-allowed; }
textarea { min-height: 92px; resize: vertical; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 14px; border: 1px solid transparent; border-radius: 5px; font-weight: 800; text-decoration: none; cursor: pointer; }
.button:hover { filter: brightness(.97); }
.button:active { transform: translateY(1px); }
.button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .choice-button:focus-visible, .date-choice:focus-visible, .toggle-card:focus-within { outline: 3px solid rgba(215, 93, 60, .35); outline-offset: 2px; }
.button:disabled { cursor: not-allowed; filter: none; opacity: .55; }
.button-primary { color: #fff; background: var(--orange); }
.button-primary:hover { background: var(--orange-dark); }
.button-secondary { color: var(--navy); background: #fff; border-color: #aebfc6; }
.topbar .button-secondary { color: #fff; border-color: #64808b; background: rgba(255,255,255,.08); }
.button-large { min-height: 50px; min-width: 138px; font-size: 1rem; }

.student-entry { margin-bottom: 10px; }
.student-entry input { min-height: 52px; font-size: 1rem; }
.selected-student { min-height: 82px; margin: 8px 0 16px; padding: 12px 14px; border: 1px solid #edb4a4; background: var(--orange-soft); }
.selected-student.empty-selection { display: flex; align-items: center; color: var(--muted); border-color: var(--line); background: #f7f9fa; }
.student-primary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.student-primary strong { font-size: 1.15rem; }
.student-primary span { color: var(--orange-dark); font-weight: 900; }
.student-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 9px; }
.student-facts span { color: var(--muted); font-size: .76rem; }
.student-facts strong { display: block; color: var(--ink); font-size: .88rem; }
.search-results { display: grid; gap: 7px; max-height: 240px; overflow: auto; }
.search-result { width: 100%; min-height: 70px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: #fff; text-align: left; cursor: pointer; }
.search-result:hover { border-color: var(--orange); background: var(--orange-soft); }
.search-result .student-primary strong { font-size: 1rem; }

.order-details { display: grid; gap: 0; }
.choice-section { border-top: 1px solid var(--line); padding: 18px 0 4px; }
.choice-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.choice-heading .eyebrow { margin-bottom: 2px; color: var(--teal); }
.choice-value { color: var(--muted); font-size: .82rem; font-weight: 800; }
.choice-grid { display: grid; gap: 9px; }
.package-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.option-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice-button, .date-choice { display: flex; min-width: 0; min-height: 64px; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 8px; border: 1px solid #b7c7cd; border-radius: 6px; color: var(--navy); background: #fff; cursor: pointer; }
.choice-button:hover, .date-choice:hover { border-color: var(--orange); background: var(--orange-soft); }
.choice-button.is-selected, .date-choice.is-selected { border-color: var(--orange); color: #fff; background: var(--orange); box-shadow: 0 3px 0 var(--orange-dark); }
.choice-button strong { font-size: 1.12rem; line-height: 1.2; }
.choice-button span, .date-choice-day { color: var(--muted); font-size: .74rem; font-weight: 800; }
.choice-button.is-selected span, .date-choice.is-selected .date-choice-day { color: #ffe4da; }
.option-button { min-height: 62px; }
.option-button strong { font-size: .98rem; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }
.date-choice-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; }
.date-choice { min-height: 86px; }
.date-choice-day { font-size: .9rem; }
.date-choice-value { color: var(--navy); font-size: .98rem; }
.date-choice.is-selected .date-choice-value { color: #fff; }
.custom-date-row { display: flex; justify-content: flex-end; margin-top: 10px; }
.custom-date-choice { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); cursor: pointer; }
.custom-date-choice input { width: auto; min-height: 38px; padding: 5px 8px; color: var(--navy); font-size: .86rem; cursor: pointer; }
.custom-date-choice.is-selected { border-color: var(--orange); color: #fff; background: var(--orange); box-shadow: 0 3px 0 var(--orange-dark); }
.custom-date-choice.is-selected .date-choice-value, .custom-date-choice.is-selected input { color: #fff; }

.toggle-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.toggle-card { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; min-height: 66px; padding: 10px 12px; border: 1px solid #b7c7cd; border-radius: 6px; color: var(--navy); background: #fff; cursor: pointer; }
.toggle-card-wide { grid-column: 1 / -1; }
.toggle-card > input[type="checkbox"] { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.toggle-card::before { content: ""; width: 24px; height: 24px; border: 2px solid #a9bbc2; border-radius: 50%; background: #fff; }
.toggle-card.is-selected { border-color: var(--teal); background: var(--teal-soft); }
.toggle-card.is-selected::before { border-color: var(--teal); background: var(--teal); box-shadow: inset 0 0 0 5px var(--teal-soft); }
.toggle-copy strong, .toggle-copy small { display: block; }
.toggle-copy small { color: var(--muted); font-size: .76rem; font-weight: 400; }
.toggle-mark { display: grid; place-items: center; min-width: 25px; min-height: 25px; color: var(--teal); font-size: 1.25rem; font-weight: 900; }
.toggle-card.is-selected .toggle-mark { color: var(--teal); font-size: 0; }
.toggle-card.is-selected .toggle-mark::after { content: "✓"; font-size: 1.05rem; }
.toggle-card-wide > input[type="text"] { grid-column: 1 / -1; min-height: 44px; margin-top: 2px; }
.notes-section textarea { margin-bottom: 2px; }
.order-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; margin-top: 18px; }
.save-button { min-height: 56px; }
.message { min-height: 24px; margin: 12px 0 0; color: var(--muted); font-size: .88rem; }
.message.success { color: #17704e; }
.message.error { color: #b33c2d; }
.message.warning { color: #995c13; }
.confirmation-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; margin-top: 18px; padding: 17px; border: 1px solid #a8d4c8; border-radius: 7px; background: var(--teal-soft); }
.confirmation-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: #fff; background: var(--teal); font-size: 1.4rem; font-weight: 900; }
.confirmation-copy .eyebrow { color: var(--teal); }
.confirmation-copy h3 { margin: 0 0 3px; }
.confirmation-copy strong, .confirmation-copy span { display: block; }
.confirmation-copy strong { font-size: 1rem; }
.confirmation-copy span { color: var(--muted); font-size: .84rem; }

.student-form { margin: 0 0 18px; padding: 14px; border: 1px solid var(--line); background: #f8fafb; }
.roster-search-field { margin-top: 6px; }
.student-list { display: grid; gap: 8px; max-height: 460px; overflow: auto; }
.student-item { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 5px; }
.student-no { display: grid; place-items: center; min-width: 66px; min-height: 48px; color: var(--orange); background: var(--orange-soft); font-weight: 900; }
.student-item strong, .student-item small { display: block; }
.student-item small { color: var(--muted); font-size: .82rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { padding: 10px 8px; color: var(--muted); font-size: .76rem; text-align: left; text-transform: uppercase; letter-spacing: .04em; background: #f4f7f8; }
td { padding: 12px 8px; border-top: 1px solid var(--line); vertical-align: top; }
td strong, td small { display: block; }
td small { color: var(--muted); }
.package-mark { display: inline-grid; place-items: center; min-width: 36px; min-height: 36px; color: var(--orange); background: var(--orange-soft); font-size: 1.15rem; font-weight: 900; }
.row-actions { display: flex; gap: 6px; }
.row-actions .button { min-height: 36px; padding: 5px 9px; font-size: .8rem; }
.empty-state { padding: 32px 12px 12px; color: var(--muted); text-align: center; }
footer { padding: 0 18px 28px; color: var(--muted); font-size: .82rem; text-align: center; }
.mobile-only { display: none; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; border: 0 !important; }
[hidden] { display: none !important; }

/* Auth stays deliberately small: the app remains the first useful screen after access. */
.auth-gate {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--canvas);
}
.auth-card {
  width: min(100%, 580px);
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 18px;
  color: #fff;
  background: var(--orange);
  font-size: 1.4rem;
  font-weight: 900;
}
.auth-card > h1 { margin: 0; color: var(--navy); font-size: clamp(1.75rem, 4vw, 2.4rem); }
.auth-view { margin-top: 28px; }
.auth-note { max-width: 52ch; margin: 0 0 18px; color: var(--muted); font-size: .92rem; }
.auth-primary { width: 100%; }
.auth-text-button {
  display: block;
  margin: 14px auto 0;
  padding: 4px 8px;
  border: 0;
  color: var(--teal);
  background: transparent;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.auth-text-button:hover { color: var(--orange-dark); }
.auth-view-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.auth-view-heading h2 { margin: 3px 0 0; color: var(--navy); font-size: 1.35rem; }
.auth-step { color: var(--muted); font-size: .74rem; font-weight: 800; }
.auth-badge { flex: 0 0 auto; padding: 5px 8px; color: var(--teal); border: 1px solid #abd3c8; border-radius: 999px; background: var(--teal-soft); font-size: .74rem; font-weight: 800; }
.auth-status-title { margin: 0 0 6px; color: var(--navy); font-size: 1.1rem; font-weight: 900; }
.pairing-stage { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: center; gap: 24px; padding: 18px; border: 1px solid var(--line); background: #f7fafb; }
.pairing-qr { display: grid; grid-template-columns: repeat(21, 1fr); aspect-ratio: 1; width: 220px; padding: 12px; border: 10px solid #fff; outline: 1px solid #a7b9c0; background: #fff; }
.pairing-qr span { display: block; background: #fff; }
.pairing-qr span.is-dark { background: var(--navy); }
.pairing-label { margin: 0 0 8px; color: var(--muted); font-size: .8rem; font-weight: 800; }
.pairing-code { display: block; overflow-wrap: anywhere; color: var(--navy); font: 700 .88rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }
.pairing-expiry { margin: 8px 0 12px; color: var(--orange-dark); font-size: .86rem; font-weight: 900; }
.pairing-details .auth-note { margin-bottom: 0; font-size: .8rem; }
.pairing-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.pairing-actions .button { min-height: 42px; padding: 8px 10px; font-size: .82rem; }
.phone-pair-summary { display: flex; align-items: center; gap: 12px; margin: 18px 0; padding: 13px; border: 1px solid var(--line); background: #f7fafb; }
.pairing-summary-icon { display: grid; place-items: center; width: 42px; height: 42px; color: #fff; background: var(--navy); font-size: .72rem; font-weight: 900; letter-spacing: .04em; }
.phone-pair-summary strong, .phone-pair-summary small { display: block; }
.phone-pair-summary small { margin-top: 2px; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.auth-message { min-height: 24px; margin-top: 18px; }
.session-logout { flex: 0 0 auto; }

@media (max-width: 640px) {
  .auth-gate { align-items: start; padding: 16px 12px; }
  .auth-card { margin-top: 8vh; padding: 24px 18px; }
  .pairing-stage { grid-template-columns: 1fr; justify-items: center; gap: 16px; padding: 16px; }
  .pairing-qr { width: min(220px, 68vw); }
  .pairing-details { width: 100%; }
  .pairing-actions { grid-template-columns: 1fr; }
  .pairing-actions .button { width: 100%; }
  .session-logout { position: absolute; top: 16px; right: 16px; min-height: 36px; padding: 7px 10px; font-size: .78rem; }
  .topbar { position: relative; padding-right: 74px; }
}

@media (max-width: 1120px) {
  .topbar { align-items: start; flex-direction: column; }
  .top-actions { justify-content: start; }
  .workspace { grid-template-columns: 1fr; }
  .remote-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  body { min-width: 320px; }
  .topbar { min-height: 64px; padding: 13px 16px; }
  .topbar h1 { font-size: 1.15rem; }
  .topbar .eyebrow { margin-bottom: 1px; font-size: .62rem; }
  .top-actions { display: none; }
  .page-shell { width: calc(100% - 24px); margin: 10px auto 28px; }
  .date-bar, .remote-panel, .metrics, .students-panel, .orders-panel, footer { display: none; }
  .top-actions { display: none; }
  .topbar { display: block; padding: 16px 16px 8px; }
  .topbar h1 { font-size: 1.4rem; }
  .page-shell { padding: 0 12px 28px; }
  .order-editor { padding: 18px 14px 24px; border: 0; box-shadow: none; }
  .order-heading { margin-bottom: 18px; }
  .order-heading .eyebrow, .order-heading .status-chip { display: none; }
  .order-heading h2 { font-size: 1.35rem; }
  .choice-heading .eyebrow { display: none; }
  .choice-heading h3 { font-size: 1.05rem; }
  .date-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .package-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .package-button { min-height: 58px; }
  .option-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .option-button { min-height: 58px; padding: 10px 6px; }
  .toggle-grid { gap: 8px; }
  .toggle-card { min-height: 60px; padding: 12px; }
  .notes-section textarea { min-height: 84px; }
  .save-button { width: 100%; min-height: 60px; }
  .form-actions { position: sticky; bottom: 0; z-index: 2; margin: 0 -14px; padding: 12px 14px max(12px, env(safe-area-inset-bottom)); background: rgba(246, 248, 246, .96); }
  .field-hint { margin: 8px 0 0; color: #58665f; font-size: .86rem; }
  .search-results { max-height: 220px; overflow-y: auto; }
  .workspace { display: block; }
  .order-editor { padding: 0; border: 0; box-shadow: none; background: transparent; }
  .order-heading { display: none; }
  .student-entry { padding-top: 7px; margin-bottom: 0; }
  .student-entry label { margin-bottom: 2px; font-size: 1rem; }
  .student-entry input { min-height: 60px; padding: 12px 14px; border: 2px solid var(--navy); border-radius: 7px; font-size: 1.12rem; }
  .student-entry input::placeholder { color: #8a989e; }
  .desktop-only { display: none; }
  .mobile-only { display: inline; }
  .selected-student.empty-selection { display: none; }
  body:not(.student-ready) .order-details { display: none; }
  .selected-student { margin: 12px 0 0; padding: 13px; border-radius: 6px; box-shadow: 0 2px 7px rgba(31, 47, 58, .04); }
  .student-primary strong { font-size: 1.08rem; }
  .student-facts { gap: 5px; }
  .student-facts strong { font-size: .82rem; overflow-wrap: anywhere; }
  .search-results { margin-top: 8px; max-height: 300px; }
  .search-result { min-height: 78px; padding: 11px 12px; }
  .order-details { margin-top: 12px; padding: 0 12px 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
  .choice-section { padding-top: 19px; }
  .choice-heading { margin-bottom: 11px; }
  .choice-heading h3 { font-size: 1.04rem; }
  .date-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .date-choice { min-height: 82px; }
  .date-choice-day { font-size: .98rem; }
  .date-choice-value { font-size: 1rem; }
  .custom-date-row { justify-content: stretch; }
  .custom-date-choice { width: 100%; justify-content: space-between; }
  .custom-date-choice input { max-width: 58%; }
  .package-grid { gap: 8px; }
  .choice-button { min-height: 68px; }
  .option-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .option-button { min-height: 66px; }
  .toggle-grid { gap: 8px; }
  .toggle-card { min-height: 70px; padding: 10px; }
  .order-actions { grid-template-columns: 1fr; margin-top: 18px; }
  .save-button { min-height: 60px; font-size: 1.08rem; }
  .confirmation-card { grid-template-columns: auto 1fr; gap: 11px; margin-top: 12px; padding: 14px; }
  .confirmation-card .button { grid-column: 1 / -1; width: 100%; }
  .orders-panel { margin-top: 14px; padding: 14px 12px; box-shadow: none; }
  .orders-panel .section-heading { flex-direction: row; align-items: center; margin-bottom: 12px; }
  .orders-panel h2 { font-size: 1.1rem; }
  footer { padding: 0 12px 24px; font-size: .75rem; }
}

@media (max-width: 380px) {
  .page-shell { width: calc(100% - 18px); }
  .order-details { padding-right: 9px; padding-left: 9px; }
  .choice-button { min-height: 64px; }
  .choice-button strong { font-size: 1rem; }
  .student-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.phone-only { display: none; }

/* The phone flow is intentionally linear: student, date, meal, extras, note, save. */
@media (max-width: 700px) {
  body { min-width: 0; background: #f6f8f6; }
  .topbar { display: block; padding: 16px 16px 8px; }
  .topbar h1 { font-size: 1.4rem; }
  .top-actions { display: none; }
  .page-shell { padding: 0 12px 28px; }
  .order-editor { padding: 18px 14px 24px; border: 0; box-shadow: none; }
  .order-heading { margin-bottom: 18px; }
  .order-heading .eyebrow, .order-heading .status-chip { display: none; }
  .order-heading h2 { font-size: 1.35rem; }
  .order-details { display: grid; gap: 18px; }
  .choice-section { padding-top: 18px; }
  .choice-heading { margin-bottom: 10px; }
  .choice-heading .eyebrow { display: none; }
  .choice-heading h3 { font-size: 1.05rem; }
  .date-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .package-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .package-button { min-height: 58px; }
  .option-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .option-button { min-height: 58px; padding: 10px 6px; }
  .toggle-grid { gap: 8px; }
  .toggle-card { min-height: 60px; padding: 12px; }
  .toggle-card-wide { grid-column: auto; }
  .notes-section textarea { min-height: 84px; }
  .save-button { width: 100%; min-height: 60px; }
  .form-actions { position: sticky; bottom: 0; z-index: 2; margin: 0 -14px; padding: 12px 14px max(12px, env(safe-area-inset-bottom)); background: rgba(246, 248, 246, .96); }
  .field-hint { margin: 8px 0 0; color: #58665f; font-size: .86rem; }
  .search-results { max-height: 220px; overflow-y: auto; }
}
