/* ════════════════════════════════════════════════════════════
   JRB Labels App — Styles
   Phase 5.6: search input style (filter-search)
   ════════════════════════════════════════════════════════════ */

:root {
  --jrb-red:        #c8102e;
  --jrb-red-dark:   #a50d26;
  --jrb-navy:       #1a2b4a;
  --jrb-navy-dark:  #0f1b30;
  --text:           #1a1a1a;
  --text-muted:     #5b6470;
  --border:         #e5e7eb;
  --border-strong:  #cbd0d8;
  --bg:             #f7f7f5;
  --bg-card:        #ffffff;
  --bg-subtle:      #f3f4f6;
  --bg-printed:     #f0f4f8;
  --bg-note:        #fff7e6;
  --border-note:    #f6e2b6;
  --shadow-sm: 0 1px 2px  rgba(0,0,0,0.05);
  --shadow-md: 0 2px 8px  rgba(0,0,0,0.06);
  --shadow-lg: 0 -2px 16px rgba(0,0,0,0.08);
  --radius:    8px;
  --radius-sm: 4px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--jrb-red); }
a:hover { color: var(--jrb-red-dark); }

/* ── TOP NAV ─────────────────────────────────────────────── */
.topnav {
  background: var(--jrb-red);
  color: #fff;
  padding: 1.1rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow-md);
  position: sticky; top: 0; z-index: 50;
}
.topnav-brand { display: flex; align-items: center; }
.topnav-title { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.02em; }
.topnav-links {
  display: flex; gap: 0.25rem; margin-left: auto;
  list-style: none; flex-wrap: wrap;
}
.topnav-links a {
  color: #fff; text-decoration: none;
  padding: 0.55rem 1rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.95rem;
  transition: background 0.15s;
}
.topnav-links a:hover { background: rgba(255,255,255,0.15); }
.topnav-links a.active { background: var(--jrb-navy); }
.topnav-links a.logout { opacity: 0.85; }
.topnav-links a.logout:hover { opacity: 1; }
.topnav-links a.external-link { opacity: 0.92; }
.topnav-links a.external-link:hover { opacity: 1; }
.external-arrow {
  font-size: 0.78em;
  opacity: 0.7;
  margin-left: 0.15rem;
}

/* ── PAGE LAYOUT ─────────────────────────────────────────── */
.page {
  max-width: 1200px; margin: 0 auto;
  padding: 2rem 1.5rem 8rem;
}
.page-h1 {
  font-size: 1.75rem; font-weight: 700; color: var(--jrb-navy);
  margin-bottom: 0.35rem;
}
.page-sub { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  border: 0; border-radius: var(--radius-sm);
  font-size: 1rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
  font-family: inherit;
  line-height: 1;
}
.btn-primary { background: var(--jrb-red); color: #fff; }
.btn-primary:hover  { background: var(--jrb-red-dark); }
.btn-primary:active { box-shadow: inset 0 2px 4px rgba(0,0,0,0.15); }
.btn-primary:disabled,
.btn-primary[disabled] {
  background: var(--border-strong);
  cursor: not-allowed;
  box-shadow: none;
}
.btn-secondary {
  background: #fff;
  color: var(--jrb-navy);
  border: 1px solid var(--jrb-navy);
}
.btn-secondary:hover { background: var(--jrb-navy); color: #fff; }
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.92rem; }

.btn-link {
  background: transparent; border: 0;
  padding: 0.2rem 0.4rem;
  font: inherit; font-size: 0.92rem;
  color: var(--jrb-red);
  cursor: pointer; text-decoration: underline;
  font-family: inherit;
}
.btn-link:hover { color: var(--jrb-red-dark); }

.back-link { color: var(--jrb-navy); text-decoration: none; font-weight: 600; }
.back-link:hover { color: var(--jrb-red); }

/* ── FILTER BAR (Page 1) ─────────────────────────────────── */
.filter-bar {
  display: flex; gap: 1rem; align-items: flex-end;
  background: var(--bg-card);
  padding: 1rem 1.2rem; border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.filter-field { display: flex; flex-direction: column; min-width: 140px; }
.filter-label {
  font-size: 0.85rem; font-weight: 600;
  color: var(--jrb-navy); margin-bottom: 0.3rem;
}
.filter-bar input[type="date"],
.filter-bar input[type="text"] {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 1rem; font-family: inherit; background: #fff;
}
.filter-bar input[type="date"]:focus,
.filter-bar input[type="text"]:focus {
  outline: none; border-color: var(--jrb-red);
  box-shadow: 0 0 0 3px rgba(200,16,46,0.15);
}
/* Search input — slightly narrower than date fields */
.filter-search { min-width: 130px; }
.filter-search input[type="text"] {
  font-variant-numeric: tabular-nums;
}
.btn-filter { padding-top: 0.55rem; padding-bottom: 0.55rem; }

/* ── ORDERS META & TABLE (Page 1) ────────────────────────── */
.orders-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.92rem; color: var(--text-muted);
  margin-bottom: 0.5rem; padding: 0 0.25rem;
}
.orders-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.orders-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.orders-table thead th {
  background: var(--bg-subtle); color: var(--jrb-navy);
  font-weight: 600; text-align: left;
  padding: 0.65rem 0.8rem;
  border-bottom: 2px solid var(--border-strong);
  white-space: nowrap;
}
.orders-table thead th a { color: inherit; text-decoration: none; }
.orders-table thead th a:hover { color: var(--jrb-red); }
.orders-table thead th.col-total { text-align: right; }
.orders-table tbody  td.col-total {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.orders-table tbody td {
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.orders-table tbody tr.order-row:hover { background: var(--bg-subtle); }

.col-check    { width: 40px; text-align: center; }
.col-id       { white-space: nowrap; }
.col-status   { white-space: nowrap; }
.col-date     { white-space: nowrap; }

.row-toggle {
  background: transparent; border: 0;
  padding: 0.15rem 0.3rem;
  font: inherit; font-weight: 600;
  color: var(--jrb-red); cursor: pointer;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: 0.25rem;
}
.row-toggle:hover { background: rgba(200,16,46,0.07); }
.chevron {
  display: inline-block; width: 1em; text-align: center;
  font-size: 0.8em; color: var(--text-muted);
  transition: transform 0.15s;
}

.row-icons { margin-left: 0.3rem; }
.note-icon { display: inline-block; font-size: 1rem; cursor: default; }
.note-icon-empty { display: none; }

.order-row.is-printed { background: var(--bg-printed); color: var(--text-muted); }
.order-row.is-printed .col-customer,
.order-row.is-printed .col-total { opacity: 0.7; }

/* Phase 7.1 — status-based tinting. Same intensity as is-printed, just red.
   Selectability unchanged — these are visual hints only. is-pending/is-failed
   override is-printed when both apply (rare but possible). */
.order-row.is-pending,
.order-row.is-failed { background: #fdf0f0; }
.order-row.is-pending:hover,
.order-row.is-failed:hover { background: #fbe5e5; }

.badge {
  display: inline-block; font-size: 0.78rem; font-weight: 600;
  padding: 0.15rem 0.5rem; border-radius: 999px; margin-left: 0.4rem;
}
.badge-printed { background: #dcfce7; color: #166534; }
.print-again-link {
  margin-left: 0.4rem; font-size: 0.85rem; text-decoration: underline;
}

/* Detail row (inline expand on Page 1) */
.order-detail-row[hidden] { display: none; }
.order-detail-row td {
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}
.order-detail-content { color: var(--text); }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}
.detail-block { min-width: 0; }
.detail-h {
  font-size: 0.85rem; font-weight: 700;
  letter-spacing: 0.04em; color: var(--jrb-navy);
  text-transform: uppercase; margin-bottom: 0.5rem;
}
.detail-address { font-style: normal; line-height: 1.55; color: var(--text); }
.detail-meta { margin-top: 0.25rem; font-size: 0.92rem; }
.detail-comment {
  margin-top: 0.5rem; font-size: 0.92rem;
  background: var(--bg-note); border: 1px solid var(--border-note);
  padding: 0.5rem 0.7rem; border-radius: var(--radius-sm);
}
.detail-items { list-style: none; padding: 0; margin: 0; }
.detail-items li { padding: 0.2rem 0; }

/* ── PICKING NOTE BLOCK ──────────────────────────────────── */
.note-block {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.note-display {
  background: var(--bg-note); border: 1px solid var(--border-note);
  padding: 0.7rem 0.9rem; border-radius: var(--radius-sm);
  font-size: 0.95rem;
}
.note-text { color: var(--text); white-space: pre-wrap; word-wrap: break-word; }
.note-actions { margin-top: 0.5rem; display: flex; gap: 0.5rem; }
.note-empty { padding-top: 0.25rem; }
.note-form { margin-top: 0.25rem; }
.note-textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: 0.95rem;
  resize: vertical; min-height: 80px;
  background: #fff;
}
.note-textarea:focus {
  outline: none; border-color: var(--jrb-red);
  box-shadow: 0 0 0 3px rgba(200,16,46,0.15);
}
.note-form-actions {
  margin-top: 0.5rem;
  display: flex; gap: 0.6rem; align-items: center;
}
.note-form-status {
  margin-top: 0.4rem; font-size: 0.88rem;
  color: var(--text-muted); min-height: 1em;
}

/* ── CONTINUE BAR ────────────────────────────────────────── */
.continue-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  padding: 0.8rem 1.5rem;
  z-index: 40;
}
.continue-bar-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem;
  font-weight: 600; color: var(--jrb-navy);
}

/* ════════════════════════════════════════════════════════════
   EDITOR BLOCKS (Phase 5.5 — accordion)
   ════════════════════════════════════════════════════════════ */
.editor-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.editor-block.is-dpd { background: #f5f5f4; opacity: 0.75; }
.editor-block-error {
  border-color: #fca5a5; background: #fef2f2;
  padding: 1.25rem 1.5rem;
}

.editor-block summary {
  list-style: none;
  cursor: default;
}
.editor-block summary::-webkit-details-marker { display: none; }
.editor-block summary::marker { display: none; content: ''; }

.editor-summary {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 1.5rem;
  user-select: none;
  flex-wrap: wrap;
}
.editor-summary:hover { background: var(--bg-subtle); }

.editor-toggle {
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  color: var(--jrb-navy);
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  font-size: 1.2rem; font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: inherit;
  padding: 0;
}
.editor-toggle:hover {
  background: var(--jrb-navy);
  color: #fff;
  border-color: var(--jrb-navy);
}
.editor-toggle-plus  { display: inline; }
.editor-toggle-minus { display: none; }
.editor-block[open] .editor-toggle-plus  { display: none; }
.editor-block[open] .editor-toggle-minus { display: inline; }

.editor-block-num {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.78rem; font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  flex-shrink: 0;
}
.editor-summary-id {
  color: var(--jrb-navy);
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.editor-summary-name {
  flex: 1 1 200px;
  font-weight: 600;
  color: var(--text);
  min-width: 140px;
}
.editor-summary-loc {
  color: var(--text-muted);
  font-size: 0.92rem;
  flex: 0 1 auto;
  min-width: 0;
}
.editor-summary-total {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--jrb-navy);
  font-size: 0.95rem;
  flex-shrink: 0;
}
.editor-summary-flags {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}
.summary-flag { font-size: 1rem; }

.dpd-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--jrb-navy);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}
.dpd-toggle:hover { background: rgba(26,43,74,0.08); }
.dpd-toggle input[type="checkbox"] { cursor: pointer; }

.editor-block-body {
  padding: 0.5rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border);
}

.editor-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 2rem;
  margin-top: 1rem;
}
.editor-col { min-width: 0; }

/* ── FORM FIELDS ─────────────────────────────────────────── */
.form-row { display: grid; gap: 0.75rem; margin-bottom: 0.6rem; }
.form-row-two   { grid-template-columns: 1fr 1fr; }
.form-row-three { grid-template-columns: 2fr 1.4fr 1fr; }

.ff { display: block; margin-bottom: 0.6rem; }
.ff-label {
  display: block;
  font-size: 0.85rem; font-weight: 600;
  color: var(--jrb-navy);
  margin-bottom: 0.25rem;
}
.ff-opt { font-weight: 400; color: var(--text-muted); font-size: 0.82rem; }
.ff input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.95rem; font-family: inherit;
  background: #fff;
}
.ff input:focus {
  outline: none; border-color: var(--jrb-red);
  box-shadow: 0 0 0 3px rgba(200,16,46,0.15);
}
.ff-postcode { text-transform: uppercase; }
.ff-error {
  border-color: #dc2626 !important;
  background: #fef2f2 !important;
}

/* ── LOGIN ───────────────────────────────────────────────── */
.login-wrap {
  min-height: calc(100vh - 200px);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1rem;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--bg-card);
  padding: 2rem; border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.login-card .btn-primary { width: 100%; padding: 0.85rem 1.4rem; }
.login-title {
  color: var(--jrb-navy); font-size: 1.5rem; font-weight: 700;
  text-align: center; margin-bottom: 0.25rem;
}
.login-sub {
  color: var(--text-muted); text-align: center;
  font-size: 0.95rem; margin-bottom: 1.5rem;
}
.field { display: block; margin-bottom: 1rem; }
.field-label {
  display: block; font-weight: 600;
  font-size: 0.9rem; margin-bottom: 0.35rem;
  color: var(--jrb-navy);
}
.field input {
  width: 100%; padding: 0.65rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 1rem; font-family: inherit;
  color: var(--text); background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  outline: none; border-color: var(--jrb-red);
  box-shadow: 0 0 0 3px rgba(200,16,46,0.15);
}

/* ── ALERTS ──────────────────────────────────────────────── */
.alert {
  padding: 0.7rem 1rem; border-radius: var(--radius-sm);
  margin-bottom: 1rem; font-size: 0.95rem;
}
.alert-error {
  background: #fee2e2; color: #991b1b;
  border: 1px solid #fca5a5;
}

/* ── PLACEHOLDER CARD ────────────────────────────────────── */
.placeholder {
  background: var(--bg-card);
  padding: 2rem; border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}
.placeholder p { margin-bottom: 0.5rem; }
.placeholder p:last-child { margin-bottom: 0; }

/* ════════════════════════════════════════════════════════════
   PHASE 7 — LABELS READY / SENT / EMAIL FLAG
   ════════════════════════════════════════════════════════════ */

/* Top-nav count badge for "Labels Ready (N)" */
.nav-badge {
  display: inline-block;
  background: #fff;
  color: var(--jrb-red);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  margin-left: 0.3rem;
  min-width: 1.2em;
  text-align: center;
  line-height: 1.2;
}
.topnav-links a.active .nav-badge {
  background: #fff;
  color: var(--jrb-navy);
}

/* Phase 7.1 — Stacked cycle lines per order on Page 1.
   Each line is two clusters: id-cluster (fixed width) + badges-cluster.
   On lines 2+, the id-cluster is a transparent spacer of the same width
   so the badges align under the first line's badges. */
.row-id-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}
.row-id-line:first-child { margin-top: 0; }
.row-id-cluster {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex: 0 0 auto;
  min-width: 5.5rem;     /* enough for "▶ 8543 📝" */
}
.row-id-cluster-spacer {
  visibility: hidden;     /* invisible but takes the same horizontal space */
}
.row-badges-cluster {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  flex: 1 1 auto;
}

/* Email flag on Page 1 (next to Printed badge or standalone when print overridden) */
.email-flag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  background: #dbeafe;
  color: #1e40af;
  cursor: default;
  white-space: nowrap;
}

/* ── LABELS READY PAGE ─────────────────────────────────── */
.ready-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}
.ready-h2 {
  font-size: 1.2rem;
  color: var(--jrb-navy);
  margin-bottom: 0.6rem;
  font-weight: 700;
}
.ready-help {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 0.6rem;
}

.ready-pdf-prompt {
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}
.ready-pdf-prompt p { margin-bottom: 0.5rem; }
.ready-upload-form {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.ready-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ready-item {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.ready-item:last-child { border-bottom: none; }

.ready-item-pending { color: var(--text-muted); }
.ready-item-pending .ready-status { color: #b45309; }

.ready-oid {
  font-weight: 700;
  color: var(--jrb-navy);
  min-width: 70px;
}
.ready-name {
  font-weight: 600;
  flex: 1 1 180px;
  min-width: 140px;
}
.ready-loc {
  color: var(--text-muted);
  font-size: 0.92rem;
  flex: 0 1 auto;
  min-width: 120px;
}
.ready-total {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--jrb-navy);
  min-width: 70px;
  text-align: right;
}
.ready-status {
  font-size: 0.85rem;
  font-weight: 600;
}
.ready-check { display: inline-flex; align-items: center; }
.ready-note-flag {
  font-size: 1rem;
  cursor: default;
}
.ready-comment-toggle {
  flex-basis: 100%;
  margin-top: 0.3rem;
}
.ready-comment-toggle summary {
  font-size: 0.85rem;
  color: var(--jrb-red);
  cursor: pointer;
  list-style: none;
  display: inline-block;
}
.ready-comment-toggle summary::-webkit-details-marker { display: none; }
.ready-comment-toggle summary::marker { display: none; content: ''; }
.ready-comment-toggle summary:hover { text-decoration: underline; }
.ready-comment-toggle textarea {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.92rem;
  resize: vertical;
  background: #fff;
}

.ready-send-bar {
  margin-top: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.ready-sendto {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Skip button on Labels Ready rows — neutral grey, hover red.
   Sits at the right end of each row, never accidentally clicked. */
.ready-skip-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-left: auto;
  white-space: nowrap;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ready-skip-btn:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}

/* Custom-styled file input. The native control is replaced visually
   by a pretty button + filename display. The real <input type="file">
   is hidden but still receives the click via the wrapping <label>. */
.file-input-label {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}
.file-input-label input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.file-input-button {
  display: inline-block;
  background: var(--bg-card);
  color: var(--jrb-navy);
  border: 1px solid var(--jrb-navy);
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}
.file-input-label:hover .file-input-button {
  background: var(--jrb-navy);
  color: #fff;
}
.file-input-label:focus-within .file-input-button {
  outline: 2px solid var(--jrb-red);
  outline-offset: 2px;
}
.file-input-name {
  color: var(--text-muted);
  font-size: 0.92rem;
  font-style: italic;
}
.file-input-name.has-file {
  color: var(--jrb-navy);
  font-style: normal;
  font-weight: 600;
}

/* ── MATCH-REVIEW PANEL (P2G PDF uploaded) ─────────────── */
.match-panel {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
}
.match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.match-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.match-table thead th {
  background: var(--bg-subtle);
  color: var(--jrb-navy);
  font-weight: 600;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 2px solid var(--border-strong);
  font-size: 0.88rem;
}
.match-table tbody td {
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 0.92rem;
}

.match-row.is-skipped { opacity: 0.55; background: #f9f9f7; }
.match-row.is-matched { background: #f3faf3; }
.match-row.is-failed,
.match-row.is-needs-input { background: #fef9e6; }

.match-page {
  font-weight: 600;
  color: var(--jrb-navy);
  white-space: nowrap;
}
.match-extracted { line-height: 1.4; }
.match-target { line-height: 1.4; }
.match-comment { min-width: 140px; }

.match-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-left: 0.3rem;
}
.match-tag-skip    { background: #e5e7eb; color: #4b5563; }
.match-tag-auto    { background: #dcfce7; color: #166534; }
.match-tag-manual  { background: #dbeafe; color: #1e40af; }
.match-tag-pending { background: #fef3c7; color: #92400e; }

.match-edit-toggle { margin-top: 0.4rem; }
.match-edit-toggle summary {
  font-size: 0.85rem;
  color: var(--jrb-red);
  cursor: pointer;
  list-style: none;
}
.match-edit-toggle summary::-webkit-details-marker { display: none; }
.match-edit-toggle summary::marker { display: none; content: ''; }
.match-edit-toggle summary:hover { text-decoration: underline; }
.match-edit-options {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.4rem;
  padding: 0.5rem 0.7rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}
.match-edit-options label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.match-unmatched {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  background: #fef9e6;
  border: 1px solid #f6e2b6;
  border-radius: var(--radius-sm);
}
.match-unmatched h4 {
  color: #92400e;
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
}
.match-unmatched ul {
  margin: 0.4rem 0 0 1.2rem;
  font-size: 0.9rem;
}
.match-help {
  margin-top: 0.7rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── SENT TABLE ──────────────────────────────────────────── */
.sent-table tbody td { font-size: 0.92rem; }
.sent-row .badge-resend {
  background: #fef3c7;
  color: #92400e;
  margin-left: 0.3rem;
}
.sent-row .badge-dpd {
  background: #fef3c7;
  color: #92400e;
}
.sent-row .badge-p2g {
  background: #dbeafe;
  color: #1e40af;
}

/* Tracking column on Sent page — tabular monospace for scannability.
   Links to Royal Mail's tracking page (opens in new tab). */
.col-tracking { white-space: nowrap; }
.tracking-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--jrb-red);
  text-decoration: none;
  user-select: all;          /* triple-click selects whole tracking ID */
}
a.tracking-num:hover {
  color: var(--jrb-red-dark);
  text-decoration: underline;
}

/* ── SUCCESS ALERT ──────────────────────────────────────── */
.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

/* ── MOBILE ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .editor-grid { grid-template-columns: 1fr; gap: 1.25rem; }
}
@media (max-width: 800px) {
  .orders-table thead th.col-status,
  .orders-table tbody td.col-status,
  .orders-table thead th.col-date,
  .orders-table tbody td.col-date { display: none; }
  .form-row-three { grid-template-columns: 1fr 1fr; }
  .editor-summary-loc { display: none; }
}
@media (max-width: 600px) {
  .topnav { padding: 0.9rem 1rem; flex-wrap: wrap; }
  .topnav-title { font-size: 1.1rem; }
  .page { padding: 1.5rem 1rem 7rem; }
  .page-h1 { font-size: 1.4rem; }
  .login-card { padding: 1.5rem; }
  .filter-bar { padding: 0.8rem; }
  .filter-field { min-width: 120px; flex: 1 1 130px; }
  .orders-table { font-size: 0.88rem; }
  .orders-table thead th, .orders-table tbody td { padding: 0.5rem 0.5rem; }
  .detail-grid { grid-template-columns: 1fr; gap: 1rem; }
  .continue-bar { padding: 0.7rem 1rem; }
  .editor-summary { padding: 0.6rem 0.8rem; gap: 0.5rem; }
  .editor-block-body { padding: 0.4rem 1rem 1rem; }
  .form-row-two, .form-row-three { grid-template-columns: 1fr; }
}
