/* ===== Design Tokens ===== */
:root {
  /* Brand */
  --lime: #b5cc18;
  --lime-light: #d9e87c;
  --lime-subtle: #f4f8e1;
  --coral: #e8664a;
  --coral-hover: #d14e33;

  /* Neutrals */
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e2e5ee;
  --border-strong: #cbd0dc;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  /* Semantic */
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --info-text: #1e40af;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --success-text: #065f46;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --warning-text: #92400e;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-text: #991b1b;

  /* Sizing & ranking */
  --rank-tadpole: #fda4af;
  --rank-small: #fdba74;
  --rank-medium: #fcd34d;
  --rank-large: #86efac;
  --rank-quart: #67e8f9;
  --rank-halfgallon: #818cf8;
  --rank-bucket: #c084fc;

  /* Typography */
  --font-heading: 'Poppins', sans-serif;
  --font-body: 'Open Sans', sans-serif;

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --shadow-focus: 0 0 0 3px rgba(181,204,24,0.35);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
#app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  height: 44px;
  width: auto;
  flex-shrink: 0;
  object-fit: contain;
}

#app-header h1 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

#app-header h1 span {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== Views ===== */
.view {
  width: 100%;
}

.hidden {
  display: none !important;
}

/* ===== Login ===== */
.login-backdrop {
  min-height: calc(100vh - 61px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(181,204,24,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(232,102,74,0.06) 0%, transparent 50%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-lg);
}

.login-card-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-card-header h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== Forgot Password Contact Box ===== */
.forgot-contact-box {
  text-align: center;
  padding: 24px;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.forgot-contact-box svg {
  color: var(--info-text);
  margin-bottom: 12px;
}

.forgot-contact-box p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.forgot-contact-box a {
  color: var(--info-text);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
}

.forgot-contact-box a:hover {
  text-decoration: underline;
}

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--lime);
  box-shadow: var(--shadow-focus);
}

.login-hint {
  text-align: center;
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.login-links {
  text-align: center;
  margin-top: 20px;
  font-size: 0.88rem;
}

.login-links a {
  color: var(--text-secondary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}

.login-links a:hover {
  color: var(--coral);
}

/* ===== Buttons ===== */
.btn-primary {
  display: block;
  width: 100%;
  padding: 12px 24px;
  background: var(--coral);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  letter-spacing: 0.01em;
}

.btn-primary:hover {
  background: var(--coral-hover);
  box-shadow: 0 2px 8px rgba(232,102,74,0.3);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  padding: 10px 22px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-ghost:hover {
  background: var(--error-bg);
  color: var(--error-text);
}

.btn-full {
  width: 100%;
}

/* ===== Messages ===== */
.warning-msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.warning-msg svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.error-msg {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  text-align: center;
}

.info-msg {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  text-align: center;
}

/* ===== Top Bar ===== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.top-bar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.dialog-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 400px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  text-align: center;
}

.dialog-box p {
  margin-bottom: 20px;
  line-height: 1.6;
}

.dialog-box a {
  color: var(--coral);
  font-weight: 600;
}

#user-greeting {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

/* ===== Dashboard Layout ===== */
.dashboard {
  display: flex;
  height: calc(100vh - 109px);
  overflow: hidden;
}

.panel-left {
  width: 300px;
  min-width: 260px;
  padding: 24px 20px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.panel-right {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  background: var(--bg);
}

/* ===== Controls Card ===== */
.controls-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px 20px;
}

.controls-title {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.controls-card select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.controls-card .btn-primary {
  margin-top: 8px;
}

/* ===== Results Container ===== */
.results-container {
  max-width: 720px;
}

/*
 * The two special-orders tabs fill whatever width they are given.
 *
 * 720px was inherited from the forecast feedback form, which is a single narrow column of inputs and
 * reads well at that width. Special Orders and Supplier Performance are mostly tables - order lines,
 * by-store breakdowns, the line-detail drill-down - and at 720px they scroll sideways inside their
 * own container while most of the screen sits empty. Noah asked about exactly this on 2026-08-17.
 *
 * The standard approach is a fixed cap (say 1200px), and the standard reason is that long lines of
 * text are hard to read - the eye loses its place coming back to the start of the next line. But a
 * cap set for prose also stops the tables growing on a 27" monitor, which is the thing Ian wanted
 * fixed. So the two are separated: the CONTAINER is fluid, and the cap moves onto the prose itself
 * as a measure limit in `ch` units, which track the font rather than the viewport. Tables get the
 * whole monitor; paragraphs stay readable.
 *
 * Scoped to the two tabs rather than changed globally: the forecasting tab is Sam's side of the app
 * and there is no reason for a layout change here to reach it.
 */
#tab-sysco .results-container,
#tab-analytics .results-container,
#tab-app-orders .results-container,
#tab-feedback .results-container {
  max-width: none;
}

#tab-sysco .section-note,
#tab-analytics .section-note,
#tab-sysco .stage-help,
#tab-analytics .an-basis-note,
#tab-feedback .section-note,
#tab-feedback .an-basis-note {
  max-width: 90ch;
}

/* Slice picker above the line-detail drill-down. */
.an-fate-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.an-fate-picker label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.an-fate-picker select {
  padding: 6px 10px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

/* ===== Loading Indicator ===== */
.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 100px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--coral);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-backdrop {
  min-height: calc(100vh - 61px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.loading-card {
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
}

.loading-card p {
  margin-top: 16px;
}

.spinner-large {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--coral);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 0 auto;
}

.placeholder {
  color: var(--text-muted);
  font-size: 1rem;
  text-align: center;
  margin-top: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.placeholder-icon {
  color: var(--border-strong);
}

.placeholder p {
  max-width: 300px;
  line-height: 1.6;
}

/* ===== Sections ===== */
.section {
  margin-bottom: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.section-header svg {
  color: var(--coral);
  flex-shrink: 0;
}

.section-header h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.section-note {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 16px;
  line-height: 1.6;
}

.section-note p + p {
  margin-top: 12px;
}

/* Collapsed-by-default explainer, e.g. "What do the four stages mean?" above the Order Tracker. */
.stage-help {
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.stage-help summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 6px 0;
}

.stage-help summary:hover {
  color: var(--coral);
}

.stage-help ul {
  margin: 8px 0 4px 0;
  padding-left: 20px;
}

.stage-help li {
  margin-bottom: 8px;
}

.section-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 12px;
  font-weight: 500;
}

/* ===== Info Box (Logic, Summary) ===== */
.info-box {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text);
}

.summary-box {
  background: var(--lime-subtle);
  border: 1px solid #d0dd70;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--text);
  margin-top: 12px;
}

/* ===== Data Tables ===== */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.data-table thead th {
  background: var(--text);
  color: #fff;
  padding: 11px 16px;
  text-align: left;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: none;
}

.data-table thead th:not(:last-child) {
  border-right: 1px solid rgba(255,255,255,0.1);
}

.data-table tbody td {
  padding: 11px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:nth-child(even) {
  background: rgba(0,0,0,0.015);
}

.data-table tbody tr:hover {
  background: rgba(181,204,24,0.06);
}

/* ===== Size Legend ===== */
.size-legend-description {
  margin-bottom: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: normal;
}

.size-legend {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  table-layout: fixed;
}

.size-legend td {
  text-align: center;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 10px 4px;
  border-right: 1px solid rgba(255,255,255,0.3);
}

.size-legend td:last-child {
  border-right: none;
}

.size-legend .legend-numbers td {
  background: var(--text);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
}

.legend-tadpole    { background: var(--rank-tadpole); color: #881337; }
.legend-small      { background: var(--rank-small); color: #9a3412; }
.legend-medium     { background: var(--rank-medium); color: #854d0e; }
.legend-large      { background: var(--rank-large); color: #166534; }
.legend-quart      { background: var(--rank-quart); color: #155e75; }
.legend-halfgallon { background: var(--rank-halfgallon); color: #3730a3; }
.legend-bucket     { background: var(--rank-bucket); color: #6b21a8; }

/* ===== Feedback Table ===== */
.feedback-table tbody td {
  background: transparent;
}

.feedback-table input[type="number"] {
  width: 80px;
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 6px;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--surface);
}

.feedback-table input[type="number"]:focus {
  outline: none;
  border-color: var(--lime);
  box-shadow: var(--shadow-focus);
}

/* ===== Feedback Actions ===== */
.feedback-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-start;
  margin-top: 20px;
}

.feedback-actions .btn-primary {
  width: auto;
  padding: 11px 28px;
}

/* ===== Tab Bar ===== */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  background: var(--surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 0 8px;
}

.tab {
  padding: 14px 24px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -2px;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
  background: rgba(0,0,0,0.02);
}

.tab.active {
  color: var(--coral);
  border-bottom-color: var(--coral);
}

.tab-content.hidden {
  display: none;
}

/* ===== Table Scroll (for wide tables) ===== */
.table-scroll {
  overflow-x: auto;
  margin-bottom: 12px;
}

/* ===== Order Tracker (Domino's style) ===== */
.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  overflow: hidden;
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  cursor: pointer;
  transition: background 0.15s;
  gap: 12px;
}

.order-card-header:hover {
  background: rgba(0,0,0,0.02);
}

.order-card-header .order-info {
  flex: 1;
}

.order-card-header .order-number {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.order-card-header .order-meta {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.order-status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.order-status-badge.submitted { background: var(--info-bg); color: var(--info-text); border: 1px solid var(--info-border); }
.order-status-badge.matched { background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); }
.order-status-badge.delivered { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.order-status-badge.pending { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }

/* Order History only: marks a row the store has hidden from the tracker. Deliberately quieter than
   the status badge next to it - it describes a display preference, not what Sysco is doing. */
.order-archived-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg);
  color: var(--text-muted, var(--text-secondary));
  border: 1px dashed var(--border);
  white-space: nowrap;
}

.order-expand-icon {
  transition: transform 0.2s;
  color: var(--text-muted);
  flex-shrink: 0;
}

.order-card.expanded .order-expand-icon {
  transform: rotate(180deg);
}

.order-card-body {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
}

.order-card.expanded .order-card-body {
  display: block;
}

.order-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.order-item:last-child {
  border-bottom: none;
}

.order-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.order-item-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.order-item-qty {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.order-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}

.order-item-delivery {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Quantity badge */
.qty-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.qty-badge-match {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.qty-badge-short {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-border);
}

.qty-badge-over {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

/* Exception status badge (Backordered / arrived-but-not-ready) */
.status-exception-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 2px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-border);
}

/* Backordered-items list (surface layer) */
.bo-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
}
.bo-row-main { display: flex; flex-direction: column; gap: 2px; }
.bo-row-name { font-weight: 600; font-size: 0.9rem; }
.bo-row-meta { font-size: 0.78rem; color: var(--text-muted, #777); }
.bo-row-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bo-chip {
  font-size: 0.72rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; white-space: nowrap;
}
.bo-chip-available { background: #e6f4ea; color: #1e7e34; border: 1px solid #b7e0c2; }
.bo-chip-soon { background: #fff4e0; color: #a86413; border: 1px solid #f0d9a8; }
.bo-chip-out { background: #f1f1f4; color: #777; border: 1px solid #ddd; }
.bo-notify {
  font-size: 0.75rem; font-weight: 700; padding: 5px 12px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border, #ddd); background: var(--surface); color: var(--text-secondary, #555);
}
.bo-notify.on { background: #eef6ff; color: #1666c2; border-color: #bcd9f5; }
.bo-notify.off { opacity: 0.75; }
.bo-notify:disabled { opacity: 0.5; cursor: default; }

/* Dismiss - deliberately quieter than the notify toggle. Removing a row from your list is a
   smaller, more reversible act than turning off the email you were waiting for. */
.bo-dismiss {
  font-size: 1.1rem; line-height: 1; font-weight: 700;
  width: 26px; height: 26px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 1px solid transparent; background: transparent; color: var(--text-muted, #999);
}
.bo-dismiss:hover { background: #fdecea; color: #c0392b; border-color: #f5c6c0; }
.bo-dismiss:disabled { opacity: 0.4; cursor: default; }

.bo-row-notified { font-style: italic; }

/* --- Order archive ------------------------------------------------------------------------- */

.order-archive {
  font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 20px; cursor: pointer;
  margin-left: 10px;
  border: 1px solid var(--border, #ddd); background: var(--surface); color: var(--text-secondary, #555);
}
.order-archive:hover { background: var(--bg, #f5f6fa); }
.order-archive:disabled { opacity: 0.5; cursor: default; }

.archive-header { cursor: pointer; user-select: none; }
.archive-header h3 { flex: 1; }
.archive-expand-icon { transition: transform 0.2s ease; color: var(--text-muted, #999); }
.archive-header.expanded .archive-expand-icon { transform: rotate(180deg); }

.archive-filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 12px 0 16px;
}
.archive-filters label { font-size: 0.78rem; font-weight: 700; color: var(--text-secondary, #555); }
.archive-filters input[type="date"] {
  font: inherit; font-size: 0.82rem; padding: 6px 10px;
  border: 1px solid var(--border, #ddd); border-radius: 8px; background: var(--surface);
}
.btn-tertiary {
  font-size: 0.8rem; font-weight: 600; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: none; background: transparent; color: var(--text-secondary, #555);
}
.btn-tertiary:hover { text-decoration: underline; }

/* --- Store settings ------------------------------------------------------------------------ */

.settings-status {
  font-size: 0.72rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; margin-left: auto;
  margin-right: 8px;
}
.settings-status.complete   { background: #e8f6ec; color: #1e7e34; }
.settings-status.incomplete { background: #fdf3e3; color: #a8690a; }

.settings-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: center; gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border, #eee);
}
.settings-row:last-child { border-bottom: none; }
.settings-row label {
  font-size: 0.82rem; font-weight: 700; color: var(--text-secondary, #555);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.settings-row input {
  font: inherit; font-size: 0.85rem; padding: 7px 10px; width: 100%;
  border: 1px solid var(--border, #ddd); border-radius: 8px; background: var(--surface);
}
.settings-row input:focus { outline: 2px solid var(--lime); outline-offset: -1px; }
.settings-row.readonly input { background: var(--bg, #f5f6fa); color: var(--text-muted, #888); }
.settings-hint { font-size: 0.75rem; color: var(--text-muted, #999); }

.settings-badge {
  font-size: 0.65rem; font-weight: 700; padding: 2px 7px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.02em;
}
.settings-badge.derived { background: #eef6ff; color: #1666c2; }
.settings-badge.missing { background: #fdf3e3; color: #a8690a; }

.settings-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.settings-saved { font-size: 0.8rem; font-weight: 700; color: #1e7e34; }

@media (max-width: 720px) {
  .settings-row { grid-template-columns: 1fr; gap: 4px; }
}

.cw-guidance-note {
  margin: 2px 0 4px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.4;
  background: var(--surface);
  color: var(--text-secondary, #555);
  border: 1px solid var(--border, #e0e0e0);
  border-left: 3px solid var(--coral);
}

.tracker-progress.tracker-exception {
  opacity: 0.55;
}

/* Progress tracker (horizontal stepper) */
.tracker-progress {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 4px 0;
}

.tracker-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  position: relative;
}

.tracker-step .step-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.3s;
  z-index: 1;
}

.tracker-step.completed .step-circle {
  background: var(--lime);
  color: #fff;
}

.tracker-step.active .step-circle {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(232,102,74,0.2);
}

.tracker-step .step-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
  max-width: 72px;
  line-height: 1.3;
}

.tracker-step.completed .step-label,
.tracker-step.active .step-label {
  color: var(--text);
  font-weight: 500;
}

.tracker-line {
  flex: 1;
  height: 3px;
  background: var(--border);
  margin: 0 -2px;
  margin-bottom: 20px;
  min-width: 20px;
}

.tracker-line.completed {
  background: var(--lime);
}


/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
}

/* ===== Scrollbar Styling ===== */
.panel-right::-webkit-scrollbar {
  width: 8px;
}

.panel-right::-webkit-scrollbar-track {
  background: transparent;
}

.panel-right::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.panel-right::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.section {
  animation: fadeIn 0.3s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .section {
    animation: none;
  }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  #app-header {
    padding: 0 16px;
  }

  .header-inner {
    height: 52px;
  }

  #app-header h1 {
    font-size: 1.05rem;
  }

  .dashboard {
    flex-direction: column;
    height: auto;
  }

  .panel-left {
    width: 100%;
    min-width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px;
  }

  .panel-right {
    max-height: 65vh;
    padding: 20px 16px;
  }

  .section {
    padding: 18px 16px;
  }

  .login-card {
    padding: 32px 24px 28px;
  }

  .tab-bar {
    padding: 0 4px;
  }

  .tab {
    padding: 12px 14px;
    font-size: 0.8rem;
  }

  .tracker-progress {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .tracker-step .step-label {
    font-size: 0.6rem;
    max-width: 56px;
  }
}

@media (max-width: 480px) {
  .brand-logo {
    display: none;
  }

  .size-legend td {
    font-size: 0.65rem;
    padding: 8px 2px;
  }

  .feedback-actions {
    flex-direction: column;
  }

  .feedback-actions .btn-primary,
  .feedback-actions .btn-secondary {
    width: 100%;
    text-align: center;
  }
}

/* --- Supplier performance dashboard ---------------------------------------------------------- */

.analytics-filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0 18px;
}
.analytics-filters label { font-size: 0.78rem; font-weight: 700; color: var(--text-secondary, #555); }
.analytics-filters input[type="date"], .analytics-filters select {
  font: inherit; font-size: 0.82rem; padding: 6px 10px;
  border: 1px solid var(--border, #ddd); border-radius: 8px; background: var(--surface);
}

.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--border, #e6e6e6);
  border-radius: 10px; padding: 14px 16px; border-left: 3px solid var(--lime);
}
.kpi.warn  { border-left-color: #e8a33d; }
.kpi.muted { border-left-color: var(--border, #ccc); }
.kpi-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
             letter-spacing: 0.03em; color: var(--text-muted, #888); }
.kpi-value { font-family: 'Poppins', sans-serif; font-size: 1.7rem; font-weight: 700;
             line-height: 1.2; margin: 4px 0 2px; }
.kpi-sub   { font-size: 0.75rem; color: var(--text-muted, #999); }

.dist-bar {
  display: flex; height: 26px; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--border, #e6e6e6); margin-bottom: 10px;
}
.dist-seg { height: 100%; }
.dist-seg.ok    { background: #b5cc18; }
.dist-seg.warn  { background: #e8a33d; }
.dist-seg.info  { background: #7fb3e8; }
.dist-seg.bad   { background: #e8664a; }
.dist-seg.muted { background: #d6d6d6; }

.dist-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 0.78rem; }
.dist-key { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary, #555); }
.dist-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dist-dot.ok { background: #b5cc18; } .dist-dot.warn { background: #e8a33d; }
.dist-dot.info { background: #7fb3e8; } .dist-dot.bad { background: #e8664a; }
.dist-dot.muted { background: #d6d6d6; }
.dist-pct { color: var(--text-muted, #999); }

.table-scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; }
.data-table td.num, .data-table th.num { text-align: right; }
.muted-sm { color: var(--text-muted, #999); font-size: 0.75rem; }

.assumptions { font-size: 0.85rem; line-height: 1.6; color: var(--text-secondary, #555); }
.assumptions p { margin: 0 0 12px; }

.data-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.data-table th.sortable:hover { text-decoration: underline; }
.data-table th.sorted { color: var(--lime); }
.table-note {
  font-size: 0.75rem; color: var(--text-muted, #999); margin: 10px 2px 0; line-height: 1.5;
}
.table-note.warn-note { color: var(--warning-text); font-weight: 500; }

/*
 * Hover card for the distribution legend.
 *
 * A native `title` was the cheap option and is wrong here: the browser delays it about a second,
 * caps the width unpredictably and cannot be styled, and these definitions run to a couple of
 * sentences. Built from a data attribute so the text lives in one place in view.js beside the
 * category it describes.
 *
 * `:focus-within` as well as `:hover` so it is reachable by keyboard - the legend entries carry
 * tabindex for that reason.
 */
/*
 * The card is positioned against the LEGEND, not against the label you hover.
 *
 * Anchoring it to the label put its left edge wherever that label happened to sit, and the last
 * entries sit far right - so the card ran left, past the edge of `.panel-right`, and got cut in
 * half. `.panel-right` sets `overflow-y: auto`, and CSS computes the other axis to `auto` too when
 * one axis is not `visible`, so it clips horizontally even though nothing asked it to.
 *
 * Anchored to the legend and sized against it, the card cannot leave the container no matter which
 * label is hovered, which makes this independent of any ancestor's overflow. Below rather than
 * above, so it cannot be clipped by the top of the section either.
 */
.dist-legend {
  position: relative;
}

.dist-key.has-tip {
  cursor: help;
  border-bottom: 1px dotted var(--text-muted);
  padding-bottom: 1px;
}

.dist-key.has-tip::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 20;
  width: min(560px, 100%);
  padding: 10px 12px;
  background: var(--text);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.5;
  white-space: normal;
  text-align: left;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.15));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
  pointer-events: none;
}

.dist-key.has-tip:hover::after,
.dist-key.has-tip:focus-within::after,
.dist-key.has-tip:focus::after {
  opacity: 1;
  visibility: visible;
}

/*
 * The card floats over the hint line below it while open. That is normal tooltip behaviour and
 * costs nothing - the alternative, reserving space for it permanently, leaves a gap under the bar
 * that is visible every second nobody is hovering.
 */

/*
 * Frozen header row on every table.
 *
 * `.table-scroll` already caps height at 420px and scrolls, so the header sticks to the top of that
 * box and the column names stay readable however far down the catalog you are.
 *
 * Two details this depends on. The header needs its own opaque background or rows show through as
 * they pass underneath - it inherits `--text` from `.data-table thead th`, which is why this only
 * sets position and z-index. And `.data-table` carries `overflow: hidden` for its rounded corners,
 * which in some browsers creates a clipping context that breaks sticky, so the radius moves to the
 * scroll container and the table itself stops clipping.
 */
.table-scroll {
  border-radius: var(--radius-sm);
}

.data-table {
  overflow: visible;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}

/* Sort label and per-column filter share one header cell, so they cannot drift out of alignment. */
.data-table th .th-label {
  display: block;
}

.data-table th .col-filter {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 3px 6px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: text;
}

.data-table th .col-filter::placeholder {
  color: var(--text-muted);
}

/* --- Unknown-fate drill-down ------------------------------------------------------------------ */

.an-basis-toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 0.82rem; color: var(--text-secondary, #555); margin: 0 0 12px;
}
.an-basis-toggle input { cursor: pointer; }

/* Deliberately loud. These figures look better than the full picture, so the reason has to be
   visible in a screenshot - which is how a number usually travels to someone who did not run it. */
.an-basis-note {
  border-left: 3px solid #e8a33d; background: rgba(232, 163, 61, 0.08);
  border-radius: 0 8px 8px 0; padding: 10px 14px; margin: 0 0 16px;
  font-size: 0.8rem; line-height: 1.55; color: var(--text-secondary, #555);
}
/* The banner can now carry more than one caveat, so paragraphs need to separate rather than stack
   against each other - two run-together sentences read as one claim. */
.an-basis-note p { margin: 0; }
.an-basis-note p + p { margin-top: 8px; }

.an-unknown-actions { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }

.an-unknown-tops { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin: 14px 0 4px; }
.an-unknown-top h4 {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-muted, #888); margin: 0 0 6px;
}
.an-unknown-top ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.an-unknown-top li {
  display: flex; justify-content: space-between; gap: 12px; font-size: 0.82rem;
  color: var(--text-secondary, #555); border-bottom: 1px solid var(--border, #eee); padding-bottom: 3px;
}
.an-unknown-top li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mono-sm { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.78rem; }

/* PO / order reference field at submit (SO-28 follow-up). Sits above the action row so it reads as
   part of the order rather than as another filter. */
.order-reference-row { display: flex; flex-direction: column; gap: 4px; margin: 14px 0 4px; max-width: 460px; }
.order-reference-row label {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-muted, #888);
}
.order-reference-row input {
  padding: 8px 10px; border: 1px solid var(--border, #ddd); border-radius: 6px;
  font-size: 0.9rem; font-family: inherit;
}
.order-reference-hint { font-size: 0.75rem; color: var(--text-secondary, #666); line-height: 1.45; }
.order-reference-label {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-muted, #888);
}
.order-reference-generated { font-size: 0.85rem; overflow-wrap: anywhere; }
.order-reference-generated span { color: var(--text-secondary, #666); }
.order-reference-toggle {
  align-self: flex-start; background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: 0.78rem; color: var(--primary, #1a73e8); text-decoration: underline;
}
.order-reference-custom { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.order-reference-custom.hidden { display: none; }

/* --- SO-25 line receipt -------------------------------------------------------------------- */
/* The store's own confirmation that it has the goods. Deliberately quiet: it appears on every
   ready line, so anything loud would compete with the tracker it sits under. The received state is
   the one that gets colour, because that is the state worth spotting when scanning an order. */

.order-receipt-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--bg, #f5f6fa); border-radius: 8px;
}
.order-receipt-summary { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary, #555); }
.order-receipt-summary.complete { color: var(--success-text, #065f46); }
.order-receipt-error { font-size: 0.78rem; color: var(--error-text, #991b1b); flex-basis: 100%; }
.order-receipt-error:empty { display: none; }

.order-receive-all {
  font-size: 0.72rem; font-weight: 700; padding: 5px 12px; border-radius: 20px; cursor: pointer;
  margin-left: auto;
  border: 1px solid var(--lime, #b5cc18); background: var(--lime, #b5cc18); color: #fff;
}
.order-receive-all:hover { filter: brightness(0.95); }
.order-receive-all:disabled { opacity: 0.5; cursor: default; }

.line-receipt {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border, #ddd);
}
.line-invoice {
  font-size: 0.78rem; padding: 5px 9px; border-radius: 6px;
  border: 1px solid var(--border, #ddd); background: var(--surface, #fff);
  width: 170px; max-width: 100%;
}
.line-receive {
  font-size: 0.72rem; font-weight: 700; padding: 5px 12px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--lime, #b5cc18); background: var(--surface, #fff); color: var(--text, #333);
}
.line-receive:hover { background: var(--lime, #b5cc18); color: #fff; }
.line-receive:disabled, .line-unreceive:disabled { opacity: 0.5; cursor: default; }

/* Step 5 of the tracker as the Received button (Noah, 2026-10-15). It overrides the pill look of
   .line-receive so it sits in the stepper like the four steps before it - a circle and a label - with
   a dashed lime ring saying "this one is yours to finish". */
.line-receive.step-receive {
  display: flex; flex-direction: column; align-items: center;
  padding: 0; border: 0; border-radius: 0; background: none; font: inherit; color: inherit;
}
.line-receive.step-receive:hover { background: none; color: inherit; }
.tracker-step.action .step-circle {
  background: var(--surface, #fff); color: var(--success-text, #065f46);
  border: 2px dashed var(--lime, #b5cc18); box-sizing: border-box;
}
.tracker-step.action .step-label {
  color: var(--success-text, #065f46); font-weight: 700; text-decoration: underline;
}
.line-receive.step-receive:hover .step-circle { background: var(--lime, #b5cc18); color: #fff; border-style: solid; }
.line-receive.step-receive:focus-visible { outline: 2px solid var(--lime, #b5cc18); outline-offset: 3px; }
.receipt-hint { font-size: 0.78rem; color: var(--text-secondary, #555); }

.line-receipt.received .receipt-mark {
  font-size: 0.8rem; font-weight: 700; color: var(--success-text, #065f46);
}
.line-unreceive {
  font-size: 0.7rem; padding: 3px 9px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border, #ddd); background: var(--surface, #fff);
  color: var(--text-muted, #999);
}
.line-unreceive:hover { color: var(--text-secondary, #555); }

/* --- SO-30 catalogue availability ----------------------------------------------------------- */
/* Colour carries the same ordering the column sorts by: green means you can get it, grey means we
   cannot see it. Grey deliberately does NOT read as a warning - "not carried at your warehouse" is
   the normal case for a special-order item, not a problem. */

.avail { font-size: 0.78rem; font-weight: 600; white-space: nowrap; cursor: help; }
.avail-at_opco     { color: var(--success-text); }
.avail-cw_in_stock { color: var(--success-text); }
.avail-cw_restock  { color: var(--warning-text); }
.avail-cw_out      { color: var(--error-text); }
.avail-not_carried,
.avail-unknown     { color: var(--text-muted); font-weight: 500; }

/* --- SO-41 estimated price ------------------------------------------------------------------ */
.price-cell { text-align: right; white-space: nowrap; }
.price { font-size: 0.82rem; font-weight: 600; cursor: help; }
.price-none { font-size: 0.75rem; color: var(--text-muted); cursor: help; }

/* --- SO-32 stage dates --------------------------------------------------------------------- */
/* Under the step label, deliberately quieter than it. The date is supporting evidence for the
   stage, not a competing piece of information, and four dates styled as loudly as four labels
   makes the tracker harder to read at a glance rather than easier. */

.step-date {
  font-size: 0.68rem; color: var(--text-muted); margin-top: 2px; white-space: nowrap;
  cursor: help;
}

/* --- SO-31 glossary ------------------------------------------------------------------------ */
/* Scrolls inside the dialog rather than the page, so closing it returns you where you were -
   people open this mid-task, from a word they were already looking at. */

.glossary-box { max-width: 720px; width: 92vw; max-height: 82vh; display: flex; flex-direction: column; text-align: left; }
.glossary-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.glossary-head h3 { margin: 0; }
.glossary-close {
  border: none; background: none; font-size: 1.6rem; line-height: 1; cursor: pointer;
  color: var(--text-muted); padding: 0 4px;
}
.glossary-close:hover { color: var(--text); }

#glossary-body { overflow-y: auto; }
.glossary-section { margin-bottom: 20px; }
.glossary-section h4 {
  margin: 0 0 6px; font-size: 0.95rem; color: var(--text);
  border-bottom: 1px solid var(--border); padding-bottom: 4px;
}
.glossary-section dl { margin: 0; }
.glossary-section dt { font-weight: 700; font-size: 0.85rem; margin-top: 10px; color: var(--text); }
.glossary-section dd {
  margin: 2px 0 0; font-size: 0.85rem; line-height: 1.45; color: var(--text-secondary);
}
.glossary-note { color: var(--text-muted); }

/* Previous PO, under the current one. Quieter than the live number - it is provenance, and only
   matters when someone is tracing a line against Sysco's own paperwork. */
.prev-po { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; cursor: help; }

/* --- SO-33 chased with Sysco ---------------------------------------------------------------- */
/* Open items get a coral edge, resolved ones fade back. Deliberately calm: nothing in this panel
   needs the store to do anything, and styling it like an alert list would imply otherwise. */

.escalation {
  padding: 10px 12px; margin-bottom: 8px; border-radius: 8px;
  background: var(--bg); border-left: 3px solid var(--border-strong);
}
.escalation.open { border-left-color: var(--coral); }
.escalation.resolved { opacity: 0.72; }
.escalation-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.escalation-rule { font-size: 0.85rem; font-weight: 700; color: var(--text); cursor: help; }
.escalation-status { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); white-space: nowrap; }
.escalation.open .escalation-status { color: var(--coral); }
.escalation-item { font-size: 0.82rem; color: var(--text-secondary); margin-top: 3px; }
.escalation-detail { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; line-height: 1.45; }
.escalation-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 5px; }

/* --- SO-24 by-store sort mode --------------------------------------------------------------- */
/* Both numbers are already in every cell; this only changes which one the table ranks on, so it is
   styled as a small control rather than a filter - it changes the question, not the data. */

.store-sort-mode {
  display: flex; align-items: center; gap: 6px; margin-bottom: 8px;
  font-size: 0.75rem; color: var(--text-muted);
}
.store-sort-mode .mode-btn {
  font-size: 0.72rem; font-weight: 600; padding: 3px 10px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
}
.store-sort-mode .mode-btn:hover { background: var(--bg); }
.store-sort-mode .mode-btn.active {
  border-color: var(--lime); background: var(--lime-subtle); color: var(--text);
}

/* --- SO-22 breakdown picker ------------------------------------------------------------------ */
/* Same visual language as the share/count toggle beneath it: both change the question the table
   answers rather than the data behind it. */

.an-cut-picker {
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px;
  font-size: 0.75rem; color: var(--text-muted);
}
.an-cut-picker .cut-btn {
  font-size: 0.75rem; font-weight: 600; padding: 4px 12px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
}
.an-cut-picker .cut-btn:hover { background: var(--bg); }
.an-cut-picker .cut-btn.active {
  border-color: var(--coral); background: var(--coral); color: #fff;
}

/* SO-51 - App Orders */
.ao-chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem;
           font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.ao-chip.attention   { background: var(--error-bg);   color: var(--error-text);   border-color: var(--error-border); }
.ao-chip.in_progress { background: var(--info-bg);    color: var(--info-text);    border-color: var(--info-border); }
.ao-chip.arrived     { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.ao-chip.complete    { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.ao-count { display: inline-block; font-size: 0.72rem; margin: 1px 6px 1px 0; color: var(--text-secondary); }
.ao-count.attention { color: var(--error-text); font-weight: 600; }
.ao-table tr.ao-order { cursor: pointer; }
/* The shared .table-scroll caps height at 420px; this list is meant to be read top to bottom. */
#ao-table.table-scroll { max-height: none; overflow-y: visible; }
.ao-table > tbody > tr.ao-order > td { vertical-align: middle; }
.ao-table > thead > tr > th, .ao-table > tbody > tr.ao-order > td { padding: 10px 12px; }
/* Child combinators on purpose: the line table is nested INSIDE .ao-table, and a descendant
   selector here also hit its cells - which is what kept item names from wrapping. */
.ao-table > tbody > tr.ao-order > td:nth-child(2),
.ao-table > tbody > tr.ao-order > td:nth-child(4) { white-space: nowrap; }
.ao-counts { white-space: normal; max-width: 280px; }
.ao-table tr.ao-order:hover, .ao-table tr.ao-order.open { background: var(--bg); }
.ao-table tr.ao-lines > td { background: var(--bg); padding: 8px 12px 14px; }
.ao-line-table { background: var(--surface); font-size: 0.82rem; margin-bottom: 0;
                  table-layout: fixed; width: 100%; }
.ao-line-table th:nth-child(1) { width: 10%; } .ao-line-table th:nth-child(2) { width: 27%; }
.ao-line-table th:nth-child(3) { width: 6%; }  .ao-line-table th:nth-child(4) { width: 23%; }
.ao-line-table th:nth-child(5) { width: 13%; } .ao-line-table th:nth-child(6) { width: 11%; }
.ao-line-table th:nth-child(7) { width: 10%; }
.ao-line-table .ao-chip { white-space: normal; }
.ao-line-table thead th { background: var(--surface); color: var(--text-secondary); position: static;
                          padding: 6px 10px; font-size: 0.7rem; border-bottom: 1px solid var(--border); }
.ao-line-table th, .ao-line-table td { padding: 6px 8px; }
.ao-line-table td { white-space: normal; }
.ao-line-table td:nth-child(1), .ao-line-table td:nth-child(5),
.ao-line-table td:nth-child(6) { white-space: nowrap; }
.ao-line-table td:nth-child(2), .ao-line-table td:nth-child(7) { overflow-wrap: anywhere; }
.ao-line-table th:nth-child(3), .ao-line-table td:nth-child(3) { text-align: center; }
.ao-muted { color: var(--text-muted); font-size: 0.75rem; }
.ao-archived { font-size: 0.68rem; color: var(--text-muted); border: 1px solid var(--border);
               border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.ao-flag { font-size: 0.72rem; color: var(--error-text); }
.ao-legend { margin: 4px 0 14px; font-size: 0.85rem; }
.ao-legend summary { cursor: pointer; color: var(--text-secondary); }
.ao-legend dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 10px 0 0; }
.ao-legend dd { margin: 0; color: var(--text-secondary); }

/* --- SO-52 Special Orders sub-tabs and the Order Overview ---------------------------------- */
/* Quieter than the main tab bar on purpose: it sits inside a tab, and two bars styled alike read
   as one navigation level. */
.subtab-bar { display: flex; gap: 6px; margin: 0 0 18px; flex-wrap: wrap; }
.subtab {
  padding: 7px 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-family: var(--font-heading); font-size: 0.82rem; font-weight: 600; color: var(--text-secondary);
  cursor: pointer;
}
.subtab:hover { color: var(--text); border-color: var(--border-strong); }
.subtab.active { background: var(--text); border-color: var(--text); color: #fff; }

.so-pipeline { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; margin-bottom: 6px; }
.so-stages { display: flex; align-items: stretch; gap: 4px; flex: 1 1 520px; min-width: 0; }
.so-stage {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--info-border);
  border-radius: 10px; padding: 10px 12px; text-align: left; cursor: pointer; font: inherit;
}
.so-stage:hover { border-color: var(--border-strong); }
.so-stage.selected { box-shadow: 0 0 0 2px var(--coral); }
.so-stage.done { border-left-color: var(--lime); }
.so-stage.warn { border-left-color: #e8a33d; background: var(--warning-bg); flex: 0 1 200px; }
.so-stage.calm { border-left-color: var(--border-strong); flex: 0 1 200px; }
.so-stage-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
                  color: var(--text-muted); }
.so-stage-value { font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.so-stage-sub { font-size: 0.72rem; color: var(--text-muted); }
.so-arrow { align-self: center; color: var(--text-muted); font-size: 1.2rem; }
.so-pipe-note { width: 100%; margin: 2px 0 12px; font-size: 0.78rem; color: var(--text-muted); max-width: 90ch; }
.so-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; }

.so-issue { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
            background: var(--error-bg); color: var(--error-text); border: 1px solid var(--error-border);
            white-space: nowrap; cursor: help; }
.so-muted-chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem;
                 background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); cursor: help; }
.so-ok { font-size: 0.78rem; color: var(--success-text); font-weight: 600; }

/* Same caps as App Orders: read top to bottom, not inside a 420px scroll box. */
#so-table.table-scroll { max-height: none; overflow-y: visible; }
.so-table > tbody > tr.ao-order > td:nth-child(1),
.so-table > tbody > tr.ao-order > td:nth-child(3) { white-space: nowrap; }

/* The line table is nested inside .so-table - child combinators above keep the outer rules off it. */
.so-line-table { background: var(--surface); font-size: 0.82rem; margin-bottom: 0; table-layout: fixed; }
.so-line-table thead th { background: var(--surface); color: var(--text-secondary); position: static;
                          font-size: 0.7rem; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.so-line-table > tbody > tr > td { padding: 6px 8px; white-space: normal; font-size: 0.82rem; }
.so-line-table th:nth-child(1) { width: 9%; }  .so-line-table th:nth-child(2) { width: 25%; }
.so-line-table th:nth-child(3) { width: 5%; }  .so-line-table th:nth-child(9) { width: 16%; }
.so-line-table td:nth-child(1) { white-space: nowrap; }
.so-line-table td:nth-child(2) { overflow-wrap: anywhere; }
.so-line-table th:nth-child(3), .so-line-table td:nth-child(3) { text-align: center; }
.so-line-table td.so-step, .so-line-table th:nth-child(n+4):nth-child(-n+8) { text-align: center; }
.so-line-table td.so-step { white-space: nowrap; font-size: 0.76rem; }
.so-step.done { color: var(--success-text); }
.so-step.current { color: var(--text); font-weight: 700; background: var(--lime-subtle); }
.so-step.todo { color: var(--text-muted); }
.so-line-closed td { color: var(--text-muted); }

/* Received column carries Mark received + the optional invoice box (parity with My Store, 2026-10-15),
   so it gets more room than the four date columns. */
.so-line-table th:nth-child(8) { width: 14%; }
.so-line-table td.so-step.action { white-space: normal; }
.so-line-table td.so-step .line-receive { margin-bottom: 4px; }
.so-line-table td.so-step .line-invoice.so-invoice { width: 100%; box-sizing: border-box; font-size: 0.72rem; padding: 4px 6px; }
.so-line-table td.so-step .line-unreceive { margin-top: 4px; }
.so-receipt-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.so-receipt-bar .order-receive-all { margin-left: 0; }
.so-receipt-bar:empty, .so-receipt-error:empty { display: none; }
.so-receipt-error { font-size: 0.78rem; color: var(--error-text, #991b1b); }

.ao-chip.excluded { background: var(--bg); color: var(--text-muted); border-color: var(--border); }

@media (max-width: 768px) {
  .so-stages { flex-wrap: wrap; flex-basis: 100%; }
  .so-stage { flex: 1 1 30%; }
  .so-arrow { display: none; }
  .so-stage.warn, .so-stage.calm { flex: 1 1 100%; }
  .so-line-table { table-layout: auto; }
}

/* --- SO-54 Mark inactive -------------------------------------------------------------------- */
.ao-inactive-btn {
  display: inline-block; margin-top: 4px; padding: 2px 8px; font: inherit; font-size: 0.7rem;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
  color: var(--text-secondary); cursor: pointer; white-space: nowrap;
}
.ao-inactive-btn:hover { color: var(--text); border-color: var(--text-secondary); }
.ao-inactive-btn.undo { color: var(--coral); border-color: var(--coral); }
.ao-inactive-btn:disabled { opacity: 0.6; cursor: default; }

/* An estimated date, not one Sysco gave (2026-10-06). */
.ao-est { font-size: 0.66rem; font-weight: 700; color: var(--warning-text); background: var(--warning-bg);
          border: 1px solid var(--warning-border); border-radius: 4px; padding: 0 4px; cursor: help; }
/* Order Overview: the pipeline note sits under the tiles, not squeezed beside them. */
.so-pipeline > .so-pipe-note { flex: 0 0 100%; max-width: none; }

/* --- Forecast Feedback (admin) ------------------------------------------------------------- */
/* Tables here are short summaries meant to be read whole, so the shared 420px cap is lifted
   except on the two long lists (logins, store detail), which keep it and their sticky header. */
#fb-products.table-scroll, #fb-groups.table-scroll, #fb-resubs.table-scroll { max-height: none; overflow-y: visible; }
.fb-table > thead > tr > th, .fb-table > tbody > tr > td { padding: 8px 12px; }
.fb-table > thead > tr > th, .fb-table > tbody > tr > td { white-space: nowrap; }
.fb-table > tbody > tr.fb-total > td { font-weight: 700; border-top: 2px solid var(--border); }
.fb-up { color: var(--success-text); }
.fb-down { color: var(--error-text); }
.fb-check { display: inline-flex; align-items: center; gap: 6px; }
.fb-csv { margin-left: auto; font-size: 0.8rem; }
.fb-chart-col { width: 34%; min-width: 180px; }
.fb-table th.fb-chart-col { text-transform: none; letter-spacing: normal; font-weight: 500; }
.fb-pair { display: flex; flex-direction: column; gap: 3px; }
.fb-bar { display: block; height: 9px; border-radius: 3px; min-width: 1px; }
.fb-bar-orig, .fb-key-orig { background: #cbd5e1; }
.fb-bar-adj, .fb-key-adj { background: var(--lime); }
.fb-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 8px; vertical-align: -1px; }
.fb-diverge { position: relative; height: 14px; }
.fb-diverge .fb-axis { position: absolute; left: 50%; top: -4px; bottom: -4px; border-left: 1px solid var(--text-muted); }
.fb-diverge .fb-bar { position: absolute; top: 2px; height: 10px; }
.fb-bar-up { background: var(--lime); }
.fb-bar-down { background: var(--coral); }
.fb-status { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; border: 1px solid transparent; }
.fb-status.submitted { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.fb-status.signed_in { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.fb-status.never { background: var(--bg); color: var(--text-secondary); border-color: var(--border); }
.fb-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 8px; }
.fb-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.fb-days { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding: 0 2px;
           border-bottom: 1px solid var(--text-muted); }
.fb-day { flex: 1 1 0; min-width: 3px; max-width: 56px; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.fb-day:hover { background: var(--bg); }
.fb-stack { width: 100%; display: flex; flex-direction: column-reverse; border-radius: 2px 2px 0 0; overflow: hidden; }
.fb-stack > span { display: block; min-height: 2px; }
.fb-days.fb-days-axis { height: auto; border-bottom: none; margin: 4px 0 6px; font-size: 0.68rem; color: var(--text-muted); }
.fb-days-axis .fb-day { justify-content: center; white-space: nowrap; overflow: visible; }
.fb-days-axis .fb-day:hover { background: none; }
.fb-c0 { background: var(--lime); } .fb-c1 { background: var(--coral); } .fb-c2 { background: #7fb3e8; }
.fb-c3 { background: #e8a33d; } .fb-c4 { background: #8b7fe8; } .fb-c5 { background: #64748b; }

/* Two-level tabs (Noah, 2026-10-19). The top row keeps the original tab look on .tab-group; the
   second row is quieter, and the Special Orders pills (.subtab) inside a tab stay a third, distinct
   style - three levels styled alike would read as one. The .tab rules above now style that second
   row, overridden here. */
.tab-nav { margin-bottom: 24px; }
.tab-nav .tab-bar { margin-bottom: 0; }
.tab-group {
  padding: 14px 24px; background: none; border: none; border-bottom: 3px solid transparent;
  font-family: var(--font-heading); font-size: 0.95rem; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; transition: all 0.2s; margin-bottom: -2px; white-space: nowrap;
}
.tab-group:hover { color: var(--text); background: rgba(0,0,0,0.02); }
.tab-group.active { color: var(--coral); border-bottom-color: var(--coral); }
.tab-subrow {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 12px 0; background: var(--surface);
  border-bottom: 1px solid var(--border); border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.tab-subrow .tab {
  padding: 9px 14px 10px; font-size: 0.82rem; border-bottom-width: 2px; margin-bottom: -1px;
}
.tab-subrow .tab.active { color: var(--text); border-bottom-color: var(--text); }
@media (max-width: 768px) {
  .tab-group { padding: 12px 14px; font-size: 0.85rem; }
  .tab-subrow .tab { padding: 8px 10px; font-size: 0.78rem; }
}
.fb-table > tfoot > tr > td { padding: 8px 12px; font-weight: 700; border-top: 2px solid var(--border); white-space: nowrap; }
.fb-table > tbody > tr.fb-superseded > td { color: var(--text-muted); }
.fb-table > tbody > tr.fb-superseded > td b { font-weight: 400; }
/* LTO feedback windows. Archived rows grey out like superseded ones; their controls stay readable. */
.fb-windows input[type="date"] { padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; font: inherit; color: var(--text); }
.fb-windows .fb-window-msg { font-size: 0.8rem; margin-left: 8px; }
.fb-history { font-size: 0.82rem; color: var(--text-secondary); margin: 2px 0 6px; }
.fb-table .col-filter { min-width: 60px; }
