/* Work Order List — hand-written, no build step. CLAUDE.md §0/§3.
 *
 * Designed for a phone held one-handed, outdoors, possibly with gloves on.
 * Priorities in order: legible in sunlight, big targets, thumb-reachable
 * actions, never scrolls sideways. Desktop is an afterthought that happens
 * to work.
 *
 * Target sizes: Apple's HIG says 44px minimum, Android's Material says 48dp.
 * We use 48 everywhere so both are satisfied.
 */

:root {
  --bg:        #f2f4f7;
  --surface:   #ffffff;
  --border:    #d3d8e0;
  --text:      #111418;
  --muted:     #5b636e;
  --accent:    #1546c4;   /* darkened for sunlight contrast */
  --danger:    #b3261e;
  --radius:    12px;
  --tap:       48px;      /* satisfies both iOS 44 and Android 48 */
  --shadow:    0 1px 2px rgba(0,0,0,.07), 0 2px 10px rgba(0,0,0,.04);
  --navh:      60px;      /* bottom nav height */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #0f1115;
    --surface: #191c22;
    --border:  #2c313a;
    --text:    #f0f2f5;
    --muted:   #98a1ad;
    --accent:  #7aa2ff;
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;   /* iOS: don't reflow text on rotate */
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  /* Kill the grey flash Android Chrome paints on tap */
  -webkit-tap-highlight-color: transparent;
  /* NOTE: deliberately NOT `overscroll-behavior-y: none`.
     That stops iOS rubber-banding, but it also KILLS the browser's native
     pull-to-refresh — which is the gesture people actually reach for on a
     phone. Keeping the native gesture is worth a bit of bounce.
     `contain` still prevents scroll chaining to parent scrollers. */
  overscroll-behavior-y: contain;
  /* Nothing should ever scroll sideways on a phone */
  overflow-x: hidden;
}

/* Leave room for the fixed bottom nav plus the iPhone home indicator */
body.has-nav main {
  padding-bottom: calc(var(--navh) + env(safe-area-inset-bottom) + 16px);
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-left)) 16px max(16px, env(safe-area-inset-right));
}

/* ---------- Header ---------- */
.site-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-head h1 {
  font-size: 17px; margin: 0; letter-spacing: -.01em;
  flex: 1; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.site-head form { margin: 0; }
.head-actions { display: flex; align-items: center; gap: 2px; }

/* Header controls are still full-size touch targets even though they look
   like plain text — thumbs in gloves need the same 48px as everything else. */
.head-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 3px;
  background: none; border: 0;
  color: var(--accent);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  min-height: var(--tap); min-width: 44px;
  padding: 0 6px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.head-btn:active { opacity: .55; }
.head-btn { text-decoration: none; }          /* the Add button is an <a> */

/* Add is the primary header action — give it weight without a full button */
.head-add span[aria-hidden] { font-size: 26px; font-weight: 400; line-height: 1; }

/* Three actions plus a title has to survive a 360px phone. */
@media (max-width: 400px) {
  .head-btn { min-width: 38px; padding: 0 3px; font-size: 14px; }
  .site-head { padding-left: 8px; padding-right: 8px; gap: 4px; }
}
.head-btn span[aria-hidden] { font-size: 20px; line-height: 1; }
/* Keeps the title centred when there's no Back button */
.head-spacer { pointer-events: none; }

/* Spin the refresh glyph while the page reloads, so a slow network still
   feels responsive rather than ignored. */
.head-btn.is-refreshing span[aria-hidden] {
  display: inline-block;
  animation: wo-spin .7s linear infinite;
}

/* ---------- Bottom nav — thumb zone, where field apps put navigation ------ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);   /* iPhone home indicator */
}
.tabbar a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  min-height: var(--navh);
  text-decoration: none;
  color: var(--muted);
  font-size: 11px; font-weight: 600;
  letter-spacing: .01em;
}
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar .glyph { font-size: 19px; line-height: 1; }
.tabbar .badge {
  position: absolute; transform: translate(16px, -14px);
  background: var(--danger); color: #fff;
  border-radius: 999px; font-size: 10px; padding: 1px 5px; font-weight: 700;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 14px; }
.card h2 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.02em; }
.card .sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.field input, .field select, .field textarea {
  width: 100%; min-height: var(--tap);
  padding: 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text);
  /* MUST stay >=16px: anything smaller makes iOS Safari zoom on focus,
     which then leaves the page scrolled sideways. */
  font-size: 16px;
  appearance: none; -webkit-appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.field .hint { margin-top: 6px; font-size: 13px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; min-height: var(--tap);
  padding: 13px 18px;
  border: 0; border-radius: 10px;
  background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;   /* removes the 300ms double-tap-zoom delay */
}
.btn:active { transform: translateY(1px); }
.btn-secondary {
  background: var(--surface); color: var(--accent); border: 1px solid var(--border);
}

.row-links {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-top: 8px; font-size: 15px; flex-wrap: wrap;
}
.row-links a {
  color: var(--accent); text-decoration: none;
  min-height: var(--tap); display: inline-flex; align-items: center;
}

/* ---------- Feedback ---------- */
.alert {
  padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 15px;
  border: 1px solid transparent;
}
.alert-error   { background: #fdeaea; border-color: #f0b9b9; color: #7a1c1c; }
.alert-success { background: #e7f6ec; border-color: #b3dfc3; color: #14532d; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

@media (prefers-color-scheme: dark) {
  .alert-error   { background: #3a1b1b; border-color: #7d2a2a; color: #ffd9d9; }
  .alert-success { background: #14301e; border-color: #2e6b44; color: #ccf0d9; }
}

/* ---------- Status chips (colour comes from the account, not from here) --- */
.chip {
  display: inline-block; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap;
  letter-spacing: .01em;
}

/* ---------- Work order list ---------- */
.wo-list { list-style: none; margin: 0; padding: 0; }
.wo-item {
  display: block; padding: 15px 16px;
  text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 10px; box-shadow: var(--shadow);
  touch-action: manipulation;
}
.wo-item:active { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.wo-item .top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.wo-item .ident {
  font-weight: 680; font-size: 17px; letter-spacing: -.01em; margin-top: 9px;
  /* Long store names truncate rather than forcing a sideways scroll */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wo-item .meta {
  margin-top: 3px; color: var(--muted); font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wo-item .age {
  font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap;
}
.wo-item .age.old { color: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 44px 16px; }

/* ---------- Detail actions: full-width, stacked, thumb-friendly ---------- */
.actions { display: grid; gap: 10px; margin-top: 16px; }
@media (min-width: 560px) {
  .actions { grid-template-columns: 1fr 1fr; }
}

/* Long addresses and complaints must wrap, never overflow */
.wrapline { overflow-wrap: anywhere; }

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

/* ---------- Submit feedback ----------
   Any form submit that hits the network gets a spinner. The IMAP connection
   test takes several seconds; with no feedback it reads as a hung page and
   people tap Connect repeatedly. */
.btn.is-loading {
  position: relative;
  color: transparent !important;   /* hide label, keep button width stable */
  pointer-events: none;
}

/* A disabled button must still LOOK disabled, spinner or not. */
.btn:disabled { opacity: .65; cursor: not-allowed; }
.btn.is-loading:disabled { opacity: 1; }   /* the spinner already reads as busy */
.btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 20px; height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: wo-spin .7s linear infinite;
}
.btn-secondary.is-loading::after {
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
}
@keyframes wo-spin { to { transform: rotate(360deg); } }

/* Reduced motion: a static ring instead of a spinner, still clearly "busy" */
@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::after { animation: none; border-top-color: rgba(255,255,255,.9); }
}

/* Status line under a slow action, e.g. "Connecting to imap.gmail.com..." */
.submitting-note {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}
.submitting-note[hidden] { display: none; }

/* ---------- "New work orders" banner ----------
   Sits above the bottom nav so it never covers navigation. */
.refresh-banner {
  position: fixed;
  left: 50%;
  bottom: calc(var(--navh) + env(safe-area-inset-bottom) + 14px);
  transform: translateX(-50%);
  z-index: 40;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 650;
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
  cursor: pointer;
  min-height: var(--tap);
  touch-action: manipulation;
  animation: wo-rise .22s ease-out;
}
@keyframes wo-rise { from { opacity: 0; transform: translate(-50%, 10px); } }
@media (prefers-reduced-motion: reduce) { .refresh-banner { animation: none; } }

/* ---------- List row with a quick-note button ---------- */
.wo-row { display: flex; align-items: stretch; gap: 8px; }
.wo-row .wo-item { flex: 1; min-width: 0; }

.note-btn {
  flex: 0 0 auto;
  width: 52px;
  margin-bottom: 10px;          /* line up with .wo-item's margin */
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent);
  font-size: 22px;
  cursor: pointer;
  box-shadow: var(--shadow);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.note-btn:active { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }

/* ---------- Quick-note modal ----------
   Native <dialog>: the browser handles focus trapping, Esc, and the backdrop,
   so there is no modal library and no focus-management code to get wrong. */
.modal {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.modal::backdrop { background: rgba(0,0,0,.45); }
.modal-title { margin: 0 0 4px; font-size: 19px; letter-spacing: -.01em; }
.modal-sub {
  margin: 0 0 14px; font-size: 14px; color: var(--muted);
  overflow-wrap: anywhere;
}
.modal textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;              /* keeps iOS from zooming on focus */
  resize: vertical;
}
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.modal-error {
  margin: 10px 0 0; font-size: 14px; color: var(--danger); font-weight: 600;
}
.modal-error[hidden] { display: none; }

/* Toast confirmation after saving without a page reload */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--navh) + env(safe-area-inset-bottom) + 14px);
  transform: translateX(-50%);
  z-index: 60;
  padding: 11px 20px;
  border-radius: 999px;
  background: #12351f;
  color: #d7f5e2;
  font-size: 15px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  animation: wo-rise .2s ease-out;
}

/* ---------- Review decisions ---------- */
.review-why {
  margin-top: 8px;
  padding: 6px 9px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  white-space: normal;
}
.review-actions {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 10px;
}
.review-actions form { margin: 0; flex: 1; display: flex; }
.yn {
  flex: 1;
  width: 52px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 20px; font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.yn.yes { color: #15803d; }
.yn.no  { color: var(--danger); }
.yn.yes:active { background: color-mix(in srgb, #15803d 12%, var(--surface)); }
.yn.no:active  { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }

/* ---------- One-tap status picker (detail screen) ----------
   Chips rather than a <select>: a dropdown on a phone means a tap, a scroll,
   a pick and a dismiss. Chips are one tap, and the colour is the same one the
   list uses, so the mapping is learned rather than looked up. */
.status-picker {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 14px 0 18px;
}
.status-picker form { margin: 0; }
.status-chip {
  min-height: 40px;
  padding: 8px 14px;
  border: 2px solid var(--chip);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 14px; font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  opacity: .62;
}
.status-chip:active { transform: translateY(1px); }
/* The current status is filled; the rest are outlines. Obvious at a glance
   in daylight without relying on colour alone. */
.status-chip.is-current {
  background: var(--chip);
  color: #fff;
  opacity: 1;
}
.status-chip.is-current::before { content: "\2713\00a0"; }

/* ---------- Photos ---------- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.photo { position: relative; }
.photo img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: block;
}
.photo form { position: absolute; top: 4px; right: 4px; margin: 0; }
.photo-del {
  width: 30px; height: 30px;
  border: 0; border-radius: 50%;
  background: rgba(0,0,0,.62);
  color: #fff;
  font-size: 14px; line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- WO number ----------
   Monospace so digits align down the list and a transposed number is easier
   to spot when checking against an invoice. */
.wo-number {
  margin-top: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .02em;
}
.wo-number-lg { font-size: 15px; margin: 6px 0 0; }

/* ---------- Merge candidate list ---------- */
.merge-option {
  display: block; width: 100%; text-align: left;
  padding: 13px 14px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: inherit;
  cursor: pointer; box-shadow: var(--shadow);
  touch-action: manipulation;
}
.merge-option:active { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.merge-option .merge-ident {
  display: block; margin-top: 8px; font-weight: 650; font-size: 16px;
  overflow-wrap: anywhere;
}
.merge-option .meta { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; }

/* Equipment and description on the merge screen. These wrap fully rather than
   truncating to one line — on the merge screen the whole point is telling two
   similar jobs apart, so hiding the text defeats the screen. */
.merge-equip, .merge-desc {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
}
.merge-equip { color: var(--text); font-weight: 600; }
.merge-desc  { color: var(--muted); }

/* ---------- Scanned mail ---------- */
.filter-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pill {
  display: inline-flex; align-items: center; min-height: 40px;
  padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); text-decoration: none;
  font-size: 13px; font-weight: 600;
}
.pill.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

.mail-row { padding: 14px 16px; }
.mail-subject { font-weight: 650; font-size: 15px; }
.mail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  display: inline-block; padding: 3px 9px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 12px; font-weight: 650; color: var(--muted);
  text-transform: capitalize;
}
.tag-parsed         { background: #e7f6ec; border-color: #b3dfc3; color: #14532d; }
.tag-failed         { background: #fdeaea; border-color: #f0b9b9; color: #7a1c1c; }
.tag-not_work_order { opacity: .75; }
.tag-link { color: var(--accent); border-color: var(--accent); text-decoration: none; text-transform: none; }
@media (prefers-color-scheme: dark) {
  .tag-parsed { background: #14301e; border-color: #2e6b44; color: #ccf0d9; }
  .tag-failed { background: #3a1b1b; border-color: #7d2a2a; color: #ffd9d9; }
}

/* Laravel's paginator markup, minimally styled */
nav[role="navigation"] { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
nav[role="navigation"] a, nav[role="navigation"] span {
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px; text-decoration: none;
  color: var(--accent); background: var(--surface); font-size: 14px;
}
nav[role="navigation"] svg { width: 16px; height: 16px; fill: currentColor; }

/* ---------- Quick edit modal: status ---------- */
.modal-status {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 4px 0 16px;
}
.modal-label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.modal-label span { font-weight: 400; }
.modal-status-hint {
  margin: -8px 0 16px;
  font-size: 13px;
  color: var(--muted);
}
.modal-status-hint.is-changed { color: var(--text); font-weight: 650; }

/* ---------- Search + sort ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Full-bleed strip under the header, so the field is as wide as the phone. */
.search-panel {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.search-panel[hidden] { display: none; }

.searchbar {
  display: flex; gap: 8px;
  margin: 0;
}
.searchbar-input {
  flex: 1 1 auto; min-width: 0;         /* min-width:0 or the flex item refuses to shrink */
  min-height: var(--tap);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;                      /* under 16px iOS zooms the page on focus */
  -webkit-appearance: none;
  appearance: none;
}
.searchbar-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.searchbar-go {
  flex: 0 0 auto;
  width: var(--tap); min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.searchbar-go:active { transform: translateY(1px); }

.search-summary {
  margin: 0 0 12px;
  font-size: 14px; color: var(--muted);
}
.search-clear { margin-left: 8px; color: var(--accent); }

/* One row, always. Five pills do not fit across a phone, so the bar scrolls
   sideways INSIDE itself — the page still never scrolls horizontally. */
.sortbar {
  display: flex; align-items: center; flex-wrap: nowrap;
  gap: 8px;
  margin: 0 0 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;                /* the pills are self-evidently scrollable */
  scroll-snap-type: x proximity;
}
.sortbar::-webkit-scrollbar { display: none; }

.sort-pill {
  flex: 0 0 auto;                       /* never squash the labels */
  scroll-snap-align: start;
  min-height: var(--tap);               /* 48px — the rule at the top of this file */
  display: inline-flex; align-items: center;
  padding: 8px 15px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px; font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.sort-pill.is-on {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}

/* ---------- Pull down to check mail ---------- */
.pull-ind {
  position: fixed; top: 0; left: 50%;
  z-index: 60;
  margin-left: -110px; width: 220px;
  padding: 9px 12px;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--text);
  color: var(--surface);
  font-size: 14px; font-weight: 650;
  text-align: center;
  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;                 /* never intercepts the gesture itself */
  transition: opacity .12s linear;
}
.pull-ind.is-visible { opacity: 1; }
.pull-ind.is-working { transition: transform .18s ease-out, opacity .12s linear; }

/* Stop the page rubber-banding into the gesture on iOS. */
body { overscroll-behavior-y: contain; }

/* ---------- Email reader ---------- */
.email-open {
  display: block; width: 100%;
  padding: 0; margin: 0;
  border: 0; background: none;
  color: inherit; font: inherit; text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.email-open > span { display: block; }
.email-open-hint {
  margin-top: 4px;
  color: var(--accent);
  font-size: 13px; font-weight: 650;
}
.email-open:active .email-open-hint { opacity: .6; }

.modal-wide { max-width: 680px; width: calc(100vw - 24px); }

.email-body {
  max-height: 60vh;
  margin: 0 0 16px;
  padding: 12px;
  overflow: auto;                    /* long emails scroll INSIDE the modal */
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; line-height: 1.5;
  white-space: pre-wrap;             /* keep the email's own line breaks */
  overflow-wrap: anywhere;           /* a 200-char URL must not widen the page */
}

/* ---------- Who (customer / company / store) ---------- */
.who {
  display: grid;
  grid-template-columns: minmax(72px, auto) 1fr;
  gap: 6px 14px;
  margin: 0 0 14px;
}
.who dt {
  color: var(--muted);
  font-size: 13px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .03em;
  padding-top: 2px;
}
.who dd { margin: 0; font-size: 15px; }

/* ---------- Add a missing store address ---------- */
.store-address { margin: 0 0 14px; }
.store-address > summary {
  min-height: var(--tap);
  display: flex; align-items: center;
  color: var(--accent);
  font-weight: 650;
  cursor: pointer;
}
.store-address .field-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.store-address .opt { color: var(--muted); font-weight: 400; }
