/**
 * shared.css — Shared component styles loaded by all pages.
 *
 * This is the single source of truth for toast appearance.
 * Pages must not define local .toast CSS — override here if needed.
 *
 * Script dependency: /js/utils/toast.js
 * Load order: <link rel="stylesheet" href="/css/shared.css"> before page scripts.
 */

/* =============================================================
   Toast notification
   ============================================================= */

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  max-width: 400px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  background: #333;
  transform: translateX(120%);
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.toast.active,
.toast.visible {
  transform: translateX(0);
  opacity: 1;
}

.toast.success  { background: #10b981; }
.toast.error    { background: #ef4444; }
.toast.warning  { background: #f59e0b; }
.toast.info     { background: #3b82f6; }

/* =============================================================
   Delivery order exclusion controls
   ============================================================= */

.delivery-exclude-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.875rem;
}

.delivery-exclude-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
}

.delivery-exclude-summary {
  color: #64748b;
}

/* LOGIC CHANGE (BUG-014): Moved exclude checkbox from absolute top-right to inline
   in the card header to prevent overlap with the Edit button */
.delivery-exclude-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 0.75rem;
  color: #94a3b8;
  margin-right: 8px;
}

.delivery-exclude-checkbox input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

.delivery-exclude-checkbox:hover {
  color: #475569;
}

.delivery-exclude-label {
  user-select: none;
}

.order-card {
  position: relative;
}

.order-card.delivery-excluded {
  opacity: 0.5;
}

.order-card.delivery-excluded .order-info h3 {
  text-decoration: line-through;
}

/* =============================================================
   Route options panel (per-route start/end overrides)
   ============================================================= */

.route-options-panel {
  margin-bottom: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.route-options-toggle {
  padding: 8px 12px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  color: #475569;
}

.route-options-content {
  padding: 8px 12px 12px;
}

.route-options-row {
  margin-bottom: 8px;
}

.route-options-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: #475569;
  margin-bottom: 4px;
}

.route-options-input-group {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.route-options-input {
  flex: 1;
  min-width: 120px;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
}

.route-options-input-sm {
  flex: 0 1 100px;
  min-width: 80px;
}

.route-options-coords {
  display: inline-block;
  margin-top: 2px;
  font-size: 0.75rem;
  color: #64748b;
}

.route-options-advanced {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #64748b;
}

.route-options-advanced summary {
  cursor: pointer;
  margin-bottom: 6px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.route-endpoints {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-bottom: 4px;
}

/* =============================================================
   Base Layout
   Shared across all standard dashboard pages.
   Pages override individual properties inline when needed.
   ============================================================= */

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background-color: #f5f5f5;
  padding: 20px;
  line-height: 1.4;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  overflow: hidden;
}

.header {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 24px;
  font-weight: 600;
}

.header-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.back-button {
  background: rgba(255,255,255,0.2);
  color: white;
  padding: 8px 16px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 14px;
}

.back-button:hover {
  background: rgba(255,255,255,0.3);
}

.content {
  padding: 30px;
}

.footer {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: #6b7280;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

.footer a {
  color: #2563eb;
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.header p {
  font-size: 14px;
  opacity: 0.9;
}

.back-link {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 14px;
  display: inline-block;
}

.back-link:hover {
  color: white;
}

/* =============================================================
   Buttons
   Mode values derived from 19+ pages. Pages with different
   colors/sizes keep inline overrides with page-specific comments.
   ============================================================= */

.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary          { background: #2563eb; color: white; }
.btn-primary:hover    { background: #1d4ed8; }

.btn-secondary        { background: #6b7280; color: white; }
.btn-secondary:hover  { background: #4b5563; }

.btn-success          { background: #059669; color: white; }
.btn-success:hover    { background: #047857; }

.btn-danger           { background: #dc2626; color: white; }
.btn-danger:hover     { background: #b91c1c; }

.btn-warning          { background: #f59e0b; color: white; }
.btn-warning:hover    { background: #d97706; }

.btn:active           { transform: scale(0.98); }

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-success:disabled,
.btn-danger:disabled  { background: #9ca3af; cursor: not-allowed; }

/* =============================================================
   Dropdown button (.btn-dropdown-wrap)
   A trigger button paired with a floating menu.
   Toggle .open on the wrapper to show/hide the menu.
   ============================================================= */

.btn-dropdown-wrap {
  position: relative;
  display: inline-flex;
}

.btn-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  list-style: none;
  padding: 4px 0;
  margin: 0;
  z-index: 200;
  white-space: nowrap;
}

.btn-dropdown-wrap.open .btn-dropdown-menu {
  display: block;
}

.btn-dropdown-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: #111827;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-dropdown-item:hover {
  background: #f3f4f6;
}

/* =============================================================
   Controls bar buttons (.controls button)
   Mode: green action buttons used on catalog/inventory pages.
   Pages with outline-style controls buttons override bg/color inline.
   ============================================================= */

.controls button {
  background: #059669;
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
}

.controls button:hover {
  background: #047857;
}

/* =============================================================
   Tables
   Mode values derived from 14+ pages. Pages with different
   font sizes, sticky z-index, max-height, or special column
   layouts keep inline overrides with page-specific comments.
   ============================================================= */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

th {
  background: #f9fafb;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table-container {
  overflow-x: auto;
}

tr:hover {
  background: #f9fafb;
}

.text-right {
  text-align: right;
}

.product-name {
  max-width: 250px;
  white-space: normal;
  font-weight: 500;
  line-height: 1.3;
}

/* Utility — used by table cell renderers */
.color-muted { color: #9ca3af; }
.font-small  { font-size: 12px; }

/* Audit view — vendor stack cell (inventory category audit) */
.vendor-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: nowrap;
}
.vendor-list-item {
  font-size: 12px;
  color: #374151;
}
.vendor-list-item.vendor-cheapest {
  color: #059669;
  font-weight: 600;
}

/* =============================================================
   Forms
   Mode values derived from 9+ pages. Pages with different
   spacing (20px margin), larger font-size, or 2px border style
   keep inline overrides with page-specific comments.
   ============================================================= */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

/* =============================================================
   Modals
   Two patterns in use:
     A) .modal as fullscreen overlay (cycle-count, expiry-audit,
        purchase-orders) — this is the canonical definition.
     B) .modal-overlay as overlay + .modal as dialog content
        (driver, delivery-route, delivery-history) — those pages
        override .modal to reset the overlay styles.
   ============================================================= */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

/* Overlay wrapper used with .modal as dialog content */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

/* Reset Pattern A overlay styles when .modal is a dialog inside .modal-overlay (Pattern B) */
.modal-overlay .modal {
  display: block;
  position: static;
  top: auto;
  left: auto;
  right: auto;
  bottom: auto;
  background: white;
  z-index: auto;
  padding: 30px;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6b7280;
  line-height: 1;
}

.modal-close:hover {
  color: #111827;
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 15px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f9fafb;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

/* Modal size variants — padding: 30px overrides the default padded body approach */
.modal-content--sm { max-width: 420px; padding: 30px; }
.modal-content--md { max-width: 650px; padding: 30px; }
.modal-content--lg { max-width: 700px; padding: 30px; }

/* Modal interior layout helpers */
.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-title { margin: 0; font-size: 18px; font-weight: 600; }
.modal-subtitle { margin-bottom: 16px; font-size: 14px; color: #6b7280; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-body-text { margin-bottom: 20px; font-size: 14px; color: #374151; }
/* Modal form input spacing */
.modal-input { margin-bottom: 20px; }

/* Page subsection h3 headings (within a section, before a sub-list) */
.subsection-title { font-size: 15px; font-weight: 600; color: #374151; margin: 16px 0 14px; }
.subsection-title--gap { margin-top: 24px; }

/* Generic muted text */
.text-muted { color: #6b7280; }

/* Table cell utilities for dynamically built rows */
.td-nowrap { white-space: nowrap; }
.td-notes  { max-width: 200px; font-size: 12px; color: #6b7280; }
.td-period { font-size: 12px; color: #6b7280; }
.td-meta   { font-size: 12px; color: #6b7280; margin-top: 8px; }
.row-refunded { color: #9ca3af; text-decoration: line-through; }

/* Admin feature override badge */
.badge-admin-override { background: #dbeafe; color: #1d4ed8; }

/* Feature module toggle row */
.feature-toggle-label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.feature-key-text { font-size: 12px; color: #6b7280; }

/* Inline button spacing in action columns */
.btn-row-item { margin-right: 4px; }

/* Alert with top spacing (e.g. config warnings below a form) */
.alert-spaced { margin-top: 15px; margin-bottom: 0; }

/* Input transform */
.input-uppercase { text-transform: uppercase; }

/* Required field indicator */
.text-required { color: #dc2626; }

/* =============================================================
   Alerts
   Canonical color scheme derived from admin-subscriptions.html.
   Pages using .alert.success/.alert.error (dot notation) or
   different border shades keep their inline rules.
   ============================================================= */

.alert {
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 14px;
}

.alert-success, .alert.success {
  background: #d1fae5;
  border: 1px solid #059669;
  color: #065f46;
}

.alert-error, .alert.error {
  background: #fee2e2;
  border: 1px solid #dc2626;
  color: #991b1b;
}

.alert-warning, .alert.warning {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
}

.alert-info, .alert.info {
  background: #dbeafe;
  border: 1px solid #2563eb;
  color: #1e40af;
}

/* =============================================================
   Stats Bar
   Canonical dark-background stats strip used by 4+ pages.
   Pages with grid layout, white background, or different padding
   override locally with a comment.
   ============================================================= */

.stats-bar {
  background: #1f2937;
  color: white;
  padding: 15px 30px;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 20px;
}

.stat {
  text-align: center;
  min-width: 100px;
}

.stat-number {
  font-size: 24px;
  font-weight: bold;
  color: #10b981;
}

/* =============================================================
   Tabs
   Canonical tab bar: 2px border, light-grey background.
   Pages with 1px border or white background override locally.
   Tab active color defaults to blue; purple-theme pages override
   .tab.active { color / border-bottom-color } locally.
   ============================================================= */

.tabs {
  display: flex;
  border-bottom: 2px solid #e5e7eb;
  background: #f9fafb;
  overflow-x: auto;
}

.tab {
  padding: 12px 24px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  font-weight: 500;
  color: #6b7280;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab:hover {
  color: #374151;
  background: #f3f4f6;
}

.tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  background: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* =============================================================
   Variation Picker List
   Used by pinned count group (and loyalty modal via shared extraction
   TODO when used a third time — see public/js/utils/variation-picker.js).
   ============================================================= */

.var-pick-result-list {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  margin-top: 6px;
}

.var-pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid #f3f4f6;
}

.var-pick-row:last-child { border-bottom: none; }

.var-pick-row:hover { background: #f9fafb; }

.var-pick-info { flex: 1; min-width: 0; }

.var-pick-name {
  font-weight: 600;
  font-size: 13px;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.var-pick-sub {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.var-pick-empty {
  padding: 16px 12px;
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
}

/* =============================================================
   Empty State
   Canonical: dark text, generous padding. Pages with smaller
   padding or h2 instead of h3 override locally.
   ============================================================= */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #6b7280;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: #374151;
}

.empty-state p {
  font-size: 14px;
  color: #9ca3af;
}

/* =============================================================
   Loading & Spinner
   Pages with extra properties (font-size, font-style) add them
   locally. Spinner color overridden with border-top-color.
   Pages needing a larger block-centered spinner override
   display/width/height/margin locally.
   ============================================================= */

.loading {
  text-align: center;
  padding: 40px;
  color: #6b7280;
}

.spinner {
  display: inline-block;
  width: 30px;
  height: 30px;
  border: 3px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-spinner {
  text-align: center;
  padding: 40px;
}

.loading-spinner .spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
}

/* =============================================================
   Controls bar
   Pages with different padding (loyalty: 15px 20px) or gap
   override locally. Note: .controls button is defined above.
   ============================================================= */

.controls {
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

/* =============================================================
   CSS Custom Properties
   Canonical color palette used across all pages.
   ============================================================= */

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

:root {
  /* Brand */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-accent-purple: #7c3aed;
  --color-accent-purple-hover: #6d28d9;
  --color-accent-green: #059669;
  --color-accent-green-hover: #047857;

  /* Semantic */
  --color-success: #059669;
  --color-success-hover: #047857;
  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-danger-light: #ef4444;
  --color-warning: #f59e0b;
  --color-warning-hover: #d97706;
  --color-info: #3b82f6;

  /* Semantic backgrounds (badges, alerts) */
  --color-success-bg: #d1fae5;
  --color-success-text: #065f46;
  --color-danger-bg: #fee2e2;
  --color-danger-text: #991b1b;
  --color-warning-bg: #fef3c7;
  --color-warning-text: #92400e;
  --color-info-bg: #dbeafe;
  --color-info-text: #1e40af;
  --color-purple-bg: #f3e8ff;
  --color-purple-text: #6b21a8;

  /* Neutrals */
  --color-text: #111827;
  --color-text-secondary: #374151;
  --color-text-muted: #6b7280;
  --color-text-faint: #9ca3af;
  --color-border: #e5e7eb;
  --color-border-input: #d1d5db;
  --color-bg-page: #f5f5f5;
  --color-bg-light: #f9fafb;
  --color-bg-hover: #f3f4f6;
  --color-bg-dark: #1f2937;
  --color-bg-dark-card: #374151;
}

/* =============================================================
   Stat Cards
   White-background stat cards used in grid/row layouts.
   Pages using dark-bg stat rows (.stats-bar) use the Stats Bar
   section above. Pages with custom stat colors (loyalty, gmc)
   override .stat-value color locally.
   ============================================================= */

.stat-card {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
}

.stat-label {
  font-size: 12px;
  color: var(--color-text-faint);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* =============================================================
   Badges & Tags
   Pill-shaped badges for status indicators and labels.
   Page-specific badge variants (tier badges, velocity badges)
   remain inline with page-specific comments.
   ============================================================= */

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
.badge-error   { background: var(--color-danger-bg);  color: var(--color-danger-text); }
.badge-info    { background: var(--color-info-bg);     color: var(--color-info-text); }
.badge-gray    { background: var(--color-bg-hover);    color: var(--color-text-muted); }

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

/* =============================================================
   Search & Filters
   Controls bar input/select/label styling and filter groups.
   The .controls container itself is defined in "Controls bar".
   ============================================================= */

.controls input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--color-border-input);
  border-radius: 4px;
  font-size: 14px;
}

.controls select {
  padding: 8px 12px;
  border: 1px solid var(--color-border-input);
  border-radius: 4px;
  font-size: 14px;
  background: white;
}

.controls label {
  font-weight: 500;
  font-size: 14px;
}

.filter-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* =============================================================
   Pagination
   Bottom bar with page info and prev/next buttons.
   ============================================================= */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-light);
}

.pagination-info {
  font-size: 13px;
  color: var(--color-text-muted);
}

.pagination-buttons {
  display: flex;
  gap: 8px;
}

.pagination-btn {
  padding: 8px 14px;
  border: 1px solid var(--color-border-input);
  border-radius: 4px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.pagination-btn:hover:not(:disabled) {
  background: var(--color-bg-hover);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =============================================================
   Sections
   Content sections with header/title/description.
   Used in settings, admin, delivery-settings, staff pages.
   ============================================================= */

.section {
  margin-bottom: 30px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
}

.section-desc {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* =============================================================
   Product Elements
   Shared catalog display elements: variation name, SKU,
   product images. Used by inventory, catalog-audit,
   sales-velocity, expiry, reorder, deleted-items pages.
   ============================================================= */

.variation-name {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.sku {
  font-family: monospace;
  font-size: 12px;
  color: var(--color-text-muted);
}

.product-image {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

.no-image {
  width: 50px;
  height: 50px;
  background: var(--color-bg-hover);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-faint);
  font-size: 20px;
  border: 1px solid var(--color-border);
}

/* =============================================================
   Info Badge
   Inline informational label used in controls bars.
   ============================================================= */

.info-badge {
  background: var(--color-info-bg);
  color: var(--color-info-text);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  margin-left: auto;
}

/* =============================================================
   Sortable Columns
   Table header sorting indicators.
   ============================================================= */

.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 20px;
}

.sortable:hover {
  background: var(--color-border);
}

.sort-indicator {
  position: absolute;
  right: 5px;
  font-size: 10px;
  color: var(--color-text-muted);
}

.sort-indicator.asc::after { content: '\25B2'; color: var(--color-primary); }
.sort-indicator.desc::after { content: '\25BC'; color: var(--color-primary); }

/* =============================================================
   Loading Overlay
   Full-screen overlay with centered spinner for async operations.
   ============================================================= */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-overlay.active {
  display: flex;
}

/* =============================================================
   Tab Badge
   Badge inside tab buttons for item counts.
   ============================================================= */

.tab .badge {
  background: var(--color-border);
  color: var(--color-text-secondary);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
}

.tab.active .badge {
  background: var(--color-info-bg);
  color: var(--color-primary-hover);
}

/* =============================================================
   Container Width Variants
   Use instead of per-page max-width overrides.
   ============================================================= */

.container-narrow  { max-width: 900px; }
.container-wide    { max-width: 1400px; }
.container-xl      { max-width: 1600px; }
.container-xxl     { max-width: 1800px; }


/* =============================================================
   Button Variants
   Mobile-first touch targets for driver/route/audit pages.
   ============================================================= */

.btn-mobile {
  flex: 1;
  min-width: 80px;
  padding: 14px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s, background 0.2s;
}

.btn-mobile:active {
  transform: scale(0.98);
}

/* =============================================================
   Card
   White card with shadow, used for content sections.
   Used by logs, purchase-orders, and similar pages.
   ============================================================= */

.card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 25px;
  margin-bottom: 25px;
}

.card h2 {
  font-size: 20px;
  margin-bottom: 20px;
  color: var(--color-bg-dark);
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 10px;
}

/* =============================================================
   Progress Bar
   Horizontal progress indicator. Color via modifier classes.
   ============================================================= */

.progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
  background: var(--color-primary);
}

.progress-fill-success { background: var(--color-success); }
.progress-fill-warning { background: #fbbf24; }
.progress-fill-danger  { background: var(--color-danger); }

/* =============================================================
   Form Rows
   Side-by-side form groups.
   ============================================================= */

.form-row {
  display: flex;
  gap: 15px;
}

.form-row .form-group {
  flex: 1;
}

/* =============================================================
   Text Utilities
   ============================================================= */

.text-center { text-align: center; }

/* =============================================================
   Delivery Stop Cards
   Shared by driver.html and delivery-route.html.
   Page-specific accent colors (stop-number bg, current border)
   override locally.
   ============================================================= */

.stop-list {
  padding: 15px;
}

.stop-card {
  background: white;
  border-radius: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.stop-card.completed { opacity: 0.6; }
.stop-card.skipped   { border-left: 4px solid var(--color-warning); }

.stop-header {
  display: flex;
  align-items: center;
  padding: 15px;
  background: var(--color-bg-light);
  border-bottom: 1px solid var(--color-border);
}

.stop-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  margin-right: 12px;
  flex-shrink: 0;
}

.stop-card.completed .stop-number { background: var(--color-success); }
.stop-card.skipped .stop-number   { background: var(--color-warning); }

.stop-customer     { flex: 1; }
.stop-customer h3  { font-size: 16px; font-weight: 600; color: var(--color-text); }

.stop-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.status-active    { background: var(--color-info-bg);    color: var(--color-primary-hover); }
.status-completed { background: var(--color-success-bg); color: var(--color-success-text); }
.status-skipped   { background: var(--color-warning-bg); color: var(--color-warning-text); }
.status-delivered { background: var(--color-success-bg); color: var(--color-success-text); }

.stop-body { padding: 15px; }

.stop-address {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  cursor: pointer;
  padding: 12px;
  background: var(--color-bg-hover);
  border-radius: 8px;
  transition: background 0.2s;
}

.stop-address:hover    { background: var(--color-border); }
.stop-address .icon    { font-size: 20px; flex-shrink: 0; }
.stop-address .text    { flex: 1; font-size: 15px; color: var(--color-text-secondary); }
.stop-address .arrow   { color: var(--color-text-faint); font-size: 20px; }

.stop-phone {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--color-bg-hover);
  border-radius: 8px;
  margin-bottom: 12px;
  text-decoration: none;
  color: var(--color-text-secondary);
}

.stop-phone:hover { background: var(--color-border); }
.stop-phone .icon { font-size: 18px; }

.stop-notes {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--color-warning-text);
}

.stop-notes strong { display: block; margin-bottom: 4px; }

.stop-customer-notes {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--color-info-text);
}

.stop-customer-notes strong { display: block; margin-bottom: 4px; }

.stop-order-items {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.order-items-toggle {
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
  color: #166534;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toggle-arrow         { transition: transform 0.2s; }
.toggle-arrow.open    { transform: rotate(180deg); }

.order-items-list {
  margin-top: 12px;
  border-top: 1px solid #bbf7d0;
  padding-top: 12px;
  display: none;
}

.order-items-list.visible { display: block; }

.order-item {
  padding: 8px 0;
  border-bottom: 1px solid #dcfce7;
}

.order-item:last-child { border-bottom: none; }

.item-qty {
  display: inline-block;
  background: #166534;
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 12px;
  margin-right: 8px;
}

.item-name {
  font-weight: 500;
  color: #14532d;
}

.item-modifiers {
  margin-top: 4px;
  padding-left: 40px;
}

.modifier {
  display: block;
  font-size: 12px;
  color: #15803d;
}

.stop-pod {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--color-success-bg);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--color-success-text);
}

.stop-pod img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
}

.stop-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* =============================================================
   Modal Dialog Variant
   Pattern B: .modal as dialog box inside .modal-overlay.
   Used by driver.html, delivery-route.html.
   ============================================================= */

.modal-dialog {
  display: block;
  position: static;
  background: white;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 0;
}

/* =============================================================
   Min-max history page (min-max-history.html)
   ============================================================= */

.mmh-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 16px 20px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.mmh-stat {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px 16px;
}

.mmh-stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
}

.mmh-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin-top: 4px;
}

.mmh-table-wrap {
  overflow-x: auto;
  padding: 0 20px 20px;
}

.mmh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 16px;
}

.mmh-table th {
  text-align: left;
  padding: 10px 12px;
  background: #f3f4f6;
  border-bottom: 2px solid #e5e7eb;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}

.mmh-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.mmh-table tr.mmh-row-reduced {
  background: #fef2f2;
}

.mmh-table tr.mmh-row-increased {
  background: #f0fdf4;
}

/* Conflict rows (min would meet or exceed max) need merchant attention.
   Amber + left border distinguish them from reduced (red) / increased (green). */
.mmh-table tr.mmh-row-conflict {
  background: #fff7ed;
  border-left: 3px solid #d97706;
}

.mmh-badge-warning {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  font-weight: 600;
  font-size: 12px;
}

/* Reorder page min/max conflict chip. Shown on any suggestion row where the
   backend detected stock_alert_min >= stock_alert_max. Merchant can still
   order — the chip signals that the max cap is being ignored and needs fixing. */
.reorder-minmax-conflict {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: 3px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
}

.mmh-table tr:hover {
  filter: brightness(0.97);
}

.mmh-pin-btn {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  background: white;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.mmh-pin-btn.pinned {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.mmh-pin-btn:hover {
  background: #f3f4f6;
}

.mmh-pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  font-size: 13px;
  color: #6b7280;
}

/* =============================================================
   Pricing page (pricing.html)
   Public page — no auth required.
   ============================================================= */

.pricing-hero {
  text-align: center;
  padding: 60px 20px 40px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: white;
}

.pricing-hero h1 {
  font-size: 2.4rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.pricing-hero p {
  font-size: 1.1rem;
  opacity: 0.9;
  max-width: 540px;
  margin: 0 auto;
}

.pricing-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 20px;
}

.pricing-section-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
}

.pricing-section-sub {
  font-size: 0.95rem;
  color: #6b7280;
  margin-bottom: 32px;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.pricing-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 24px 20px;
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.pricing-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
}

.pricing-card-price {
  font-size: 1.6rem;
  font-weight: 700;
  color: #2563eb;
  margin-bottom: 4px;
}

.pricing-card-price span {
  font-size: 0.9rem;
  font-weight: 400;
  color: #6b7280;
}

.pricing-card-cta {
  display: inline-block;
  margin-top: 16px;
  padding: 9px 18px;
  background: #2563eb;
  color: white;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s;
}

.pricing-card-cta:hover {
  background: #1d4ed8;
}

/* Full-access hero card */
.pricing-full-access {
  display: flex;
  gap: 40px;
  border: 2px solid #2563eb;
  border-radius: 14px;
  padding: 36px 32px;
  background: #eff6ff;
  box-shadow: 0 4px 16px rgba(37,99,235,0.10);
  max-width: 900px;
  margin: 0 auto;
}

.pricing-full-access-features {
  flex: 1;
}

.pricing-full-access-features h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1e3a8a;
  margin-bottom: 6px;
}

.pricing-full-access-features p {
  font-size: 0.95rem;
  color: #374151;
  margin-bottom: 18px;
}

.pricing-module-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 24px;
}

.pricing-module-list li {
  font-size: 0.9rem;
  color: #1f2937;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.4;
}

.pricing-module-list li::before {
  content: '\2713';
  color: #2563eb;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.pricing-module-desc {
  color: #6b7280;
  font-size: 0.82rem;
}

.pricing-full-access-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  gap: 16px;
}

.pricing-plan-toggle {
  display: flex;
  gap: 0;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
}

.pricing-plan-toggle button {
  flex: 1;
  padding: 9px 0;
  border: none;
  background: white;
  font-size: 0.9rem;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.pricing-plan-toggle button.active {
  background: #2563eb;
  color: white;
}

.pricing-price-display {
  text-align: center;
}

.pricing-price-display .price-amount {
  font-size: 2.4rem;
  font-weight: 700;
  color: #1e3a8a;
  line-height: 1;
}

.pricing-price-display .price-period {
  font-size: 0.9rem;
  color: #6b7280;
  margin-top: 2px;
}

.pricing-price-display .price-savings {
  font-size: 0.82rem;
  color: #065f46;
  font-weight: 600;
  margin-top: 4px;
}

.pricing-cta-btn {
  display: block;
  width: 100%;
  padding: 13px 0;
  background: #2563eb;
  color: white;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: background 0.2s;
}

.pricing-cta-btn:hover {
  background: #1d4ed8;
}

.pricing-cta-note {
  font-size: 0.8rem;
  color: #6b7280;
  text-align: center;
}

/* Coming-soon module cards */
.pricing-card.muted {
  background: #f9fafb;
  border-color: #e5e7eb;
  opacity: 0.75;
}

.pricing-card-desc {
  font-size: 0.82rem;
  color: #6b7280;
  margin-top: 4px;
  line-height: 1.4;
}

.pricing-badge-soon {
  display: inline-block;
  margin-top: 14px;
  padding: 5px 12px;
  background: #f3f4f6;
  color: #6b7280;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid #e5e7eb;
}

.pricing-coming-soon-note {
  margin-top: 28px;
  text-align: center;
  font-size: 0.9rem;
  color: #6b7280;
}

.pricing-coming-soon-note a {
  color: #2563eb;
  text-decoration: none;
}

.pricing-coming-soon-note a:hover {
  text-decoration: underline;
}

@media (max-width: 700px) {
  .pricing-full-access { flex-direction: column; gap: 24px; padding: 24px 16px; }
  .pricing-module-list { grid-template-columns: 1fr; }
  .pricing-full-access-cta { width: 100%; }
}

/* Promo code section */
.pricing-promo {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 28px;
  max-width: 480px;
  margin: 0 auto 48px;
}

.pricing-promo h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: #111827;
}

.pricing-promo-row {
  display: flex;
  gap: 10px;
}

.pricing-promo-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
  text-transform: uppercase;
}

.pricing-promo-btn {
  padding: 10px 20px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.pricing-promo-btn:hover {
  background: #1d4ed8;
}

.pricing-promo-result {
  margin-top: 12px;
  font-size: 0.9rem;
  min-height: 20px;
}

.pricing-promo-result.valid {
  color: #065f46;
}

.pricing-promo-result.invalid {
  color: #991b1b;
}

.pricing-divider {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 0;
}

@media (max-width: 600px) {
  .pricing-hero h1 { font-size: 1.7rem; }
  .pricing-grid { grid-template-columns: 1fr; }
  .pricing-promo-row { flex-direction: column; }
}

/* ==================== TRIAL COUNTDOWN BANNER ==================== */
/* Shown below page header when merchant is in a free trial.
 * Builds on .alert.warning; adds flex layout and Subscribe button. */
.trial-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 0 0;
  border-radius: 0;
  padding: 10px 24px;
}

/* Elevated urgency when ≤ 3 days remain */
.trial-banner.trial-banner-urgent {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #7f1d1d;
}

/* When injected by feature-gate.js on pages without a header */
.trial-banner.trial-banner-injected {
  border-radius: 6px;
  margin: 12px 0;
}

/* Small subscribe button inside the banner */
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* ─── PO line-item drag-reorder ──────────────────────────────────────────── */
.drag-handle-col {
  width: 32px;
}

.drag-handle {
  width: 32px;
  color: #9ca3af;
  text-align: center;
  cursor: grab;
  user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.sortable-ghost {
  background: #eff6ff;
  opacity: 0.7;
}
