/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Ensure [hidden] always wins over display rules in author stylesheets */
[hidden] { display: none !important; }
/* Hide <dialog> elements that are not open */
dialog:not([open]) { display: none !important; }

:root {
  --color-primary:   #2563eb;
  --color-primary-h: #1d4ed8;
  --color-danger:    #dc2626;
  --color-danger-h:  #b91c1c;
  --color-secondary: #6b7280;
  --color-bg:        #f9fafb;
  --color-surface:   #ffffff;
  --color-border:    #e5e7eb;
  --color-text:      #111827;
  --color-muted:     #6b7280;
  --radius:          6px;
  --shadow:          0 1px 3px rgba(0,0,0,.1);
  --nav-h:           52px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ────────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
  padding: 0 1.25rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}

.nav-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text);
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  width: 100%;
}

.nav-links a {
  color: var(--color-muted);
  font-weight: 500;
  font-size: .875rem;
}

.nav-links a:hover { color: var(--color-text); text-decoration: none; }
.nav-logout { color: var(--color-danger) !important; }

.nav-right {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  margin-left: auto;
}

/* Right-anchored variant so the user menu doesn't overflow the right edge */
.nav-dropdown-menu-right {
  left: auto;
  right: 0;
}

/* ── Nav flat links (desktop) / Menu dropdown (mobile) ─────────────────────── */
.nav-flat-links  { display: flex; gap: 1.25rem; align-items: center; }
.nav-menu-mobile { display: none; }

@media (max-width: 640px) {
  .nav-flat-links  { display: none; }
  .nav-menu-mobile { display: block; }
}

/* ── Settings dropdown ─────────────────────────────────────────────────────── */
.nav-dropdown {
  position: relative;
}
.nav-dropdown-label {
  color: var(--color-muted);
  font-weight: 500;
  font-size: .875rem;
  cursor: pointer;
  user-select: none;
}
.nav-dropdown:hover .nav-dropdown-label { color: var(--color-text); }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  min-width: 150px;
  z-index: 200;
  /* padding-top creates visible gap while keeping hover area continuous */
  padding: .4rem 0 .25rem;
  margin-top: 0;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block;
  padding: .45rem 1rem;
  color: var(--color-muted);
  font-size: .875rem;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
}
.nav-dropdown-menu a:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

/* ── Calendar day info (holidays + notes under column headers / list rows) ── */
.fc-day-info { font-size: .75rem; padding: 2px 4px 4px; }
.fc-day-info-holidays,
.fc-day-info-notes { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; }
.fc-day-info-holiday,
.fc-day-info-note   {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.fc-day-info-holiday { background: #dbeafe; color: #1e40af; }
.fc-day-info-note    { background: #fef9c3; color: #713f12; }
.fc-day-info-total              { background: #dcfce7; color: #166534; font-weight: 600; }
.fc-day-info-total--warning     { background: #fff7ed; color: #c2410c; }
.fc-day-info-total--danger      { background: #fee2e2; color: #991b1b; }

/* List view: day info sits below the date cushion */
.fc-list-day .fc-day-info { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 8px 6px; }

/* ── Calendar day-view button row ─────────────────────────────────────────── */
.fc-day-extra-btns {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 4px 6px 4px;
}
.fc-day-extra-btn {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.8rem;
  background: var(--color-primary, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.fc-day-extra-btn:hover         { opacity: 0.85; }
.fc-day-extra-btn--warning      { background: #f97316; }
.fc-day-extra-btn--secondary    { background: #6b7280; }

/* ── Calendar quick-action modal ─────────────────────────────────────────── */
.fc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.fc-modal {
  background: #fff;
  border-radius: 8px;
  padding: 20px 24px;
  min-width: 260px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
}
.fc-modal h3 { margin: 0 0 14px; font-size: 1rem; }
.fc-modal label { display: block; margin-bottom: 14px; font-size: 0.9rem; }
.fc-modal-select { display: block; width: 100%; margin-top: 4px; padding: 6px; border: 1px solid #d1d5db; border-radius: 4px; }
.fc-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Calendar event status emoji ──────────────────────────────────────────── */
.fc-event-main-frame { position: relative; }
.event-status-emoji {
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: .78rem;
  line-height: 1;
  pointer-events: none;
}

/* ── Calendar event order ID ──────────────────────────────────────────────── */
.event-order-id {
  margin-left: auto;
  font-size: .7rem;
  opacity: .75;
  font-weight: 500;
}

/* ── Calendar event shipper name ──────────────────────────────────────────── */
.event-shipper-name {
  margin-left: 4px;
  font-weight: 600;
  opacity: .9;
}

/* ── Shipper swatch / colour input ────────────────────────────────────────── */
.shipper-swatch {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  vertical-align: middle;
}
.shipper-color-input {
  width: 48px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  background: none;
}

/* ── Main content ──────────────────────────────────────────────────────────── */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

/* ── Flash messages ────────────────────────────────────────────────────────── */
.flash-container { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.flash {
  padding: .6rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
}
.flash-success { background: #d1fae5; color: #065f46; }
.flash-error   { background: #fee2e2; color: #991b1b; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .9rem;
  border: none;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}

.btn-primary   { background: var(--color-primary);   color: #fff; }
.btn-primary:hover { background: var(--color-primary-h); text-decoration: none; }
.btn-secondary { background: var(--color-border);    color: var(--color-text); }
.btn-secondary:hover { background: #d1d5db; text-decoration: none; }
.btn-danger    { background: var(--color-danger);    color: #fff; }
.btn-danger:hover  { background: var(--color-danger-h); text-decoration: none; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.login-card label { display: block; margin-bottom: .35rem; font-weight: 500; }
.login-card input  {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  margin-bottom: 1rem;
}
.login-card input:focus { outline: 2px solid var(--color-primary); border-color: transparent; }
.login-card button { width: 100%; justify-content: center; font-size: 1rem; padding: .65rem; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-page {
  max-width: 820px;
}

.form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.form-header h2 { font-size: 1.25rem; }

.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.form-section h3 { font-size: .95rem; font-weight: 600; margin-bottom: 1rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: .04em; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem 1rem;
}

.form-grid + .form-grid { margin-top: .75rem; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (min-width: 641px) {
  .fc-timeGrid2Day-button,
  .fc-timeGrid3Day-button { display: none !important; }
}

@media (max-width: 600px) {
  .form-grid-3, .form-grid-2 { grid-template-columns: 1fr; }

  /* ── Items table → stacked card layout ─────────────────────────────────── */
  .items-table thead { display: none; }

  .items-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-rows: auto auto;
    gap: 4px 8px;
    padding: .6rem .5rem;
    border-bottom: 1px solid var(--color-border);
  }

  .items-table tbody tr td {
    border-bottom: none;
    padding: 0;
  }

  /* Row 1: description spans full width minus remove button */
  .items-table tbody tr td:first-child {
    grid-column: 1 / -2;
    grid-row: 1;
  }

  /* Remove button top-right */
  .items-table tbody tr .item-remove-col {
    grid-column: -2 / -1;
    grid-row: 1;
    width: auto;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
  }

  /* Row 2: qty, price, subtotal side by side */
  .items-table tbody tr .item-qty-col {
    grid-column: 1;
    grid-row: 2;
    width: auto;
  }
  .items-table tbody tr .item-price-col {
    grid-column: 2;
    grid-row: 2;
    width: auto;
  }
  .items-table tbody tr .item-total-col {
    grid-column: 3;
    grid-row: 2;
    width: auto;
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: .85rem;
  }

  .items-table tbody tr td input[type="number"] { width: 80px; }

  /* Footer: weight left, total right */
  .items-table tfoot tr {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    padding: .6rem .5rem;
  }
  .items-table tfoot td { border-bottom: none; padding: 0; }
  .items-table tfoot .total-label { margin-left: auto; margin-right: .4rem; }
  .items-table tfoot td:last-child { display: none; }

  /* Read-only view total row */
  .items-table tfoot tr.ro-total-row {
    display: flex;
    justify-content: flex-end;
    gap: .4rem;
    padding: .6rem .5rem;
  }
  .items-table tfoot tr.ro-total-row td { border-bottom: none; padding: 0; }
  .items-table tfoot tr.ro-total-row td:last-child { display: block; }

  /* Read-only view: rows without .item-*-col classes */
  .items-table tbody tr:not(:has(.item-qty-col)) {
    grid-template-columns: 1fr auto auto;
    grid-template-rows: auto auto;
  }
  .items-table tbody tr:not(:has(.item-qty-col)) td:nth-child(1) {
    grid-column: 1 / -1; grid-row: 1;
  }
  .items-table tbody tr:not(:has(.item-qty-col)) td:nth-child(2) {
    grid-column: 1; grid-row: 2;
  }
  .items-table tbody tr:not(:has(.item-qty-col)) td:nth-child(3) {
    grid-column: 2; grid-row: 2;
  }
  .items-table tbody tr:not(:has(.item-qty-col)) td:nth-child(4) {
    grid-column: 3; grid-row: 2; font-weight: 600;
  }

  /* Discount rows */
  .items-table tbody tr.discount-row {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto;
  }
  .items-table tbody tr.discount-row .item-qty-col,
  .items-table tbody tr.discount-row .item-price-col,
  .items-table tbody tr.discount-row .item-remove-col { display: none; }
  .items-table tbody tr.discount-row .item-total-col {
    grid-column: -2 / -1;
    grid-row: 1;
  }
}

/* ── FullCalendar mobile toolbar ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .fc .fc-toolbar {
    flex-wrap: wrap;
    gap: 6px;
  }
  .fc .fc-toolbar-title {
    font-size: 1.1rem;
    width: 100%;
    text-align: center;
    order: -1;
  }
  .fc .fc-toolbar-chunk {
    display: flex;
    justify-content: center;
  }
  .fc .fc-button {
    padding: 4px 8px;
    font-size: .8rem;
  }
}

/* Standalone input/select outside a .form-group (e.g. search page, delivery filter) */
.form-control {
  padding: .5rem .7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1rem;
}
.form-control:focus { outline: 2px solid var(--color-primary); border-color: transparent; }
.form-control-sm { padding: .3rem .65rem; font-size: .875rem; }

.form-group { display: flex; flex-direction: column; }
.form-group label { font-weight: 500; margin-bottom: .3rem; font-size: .875rem; }
.form-group input,
.form-group select,
.form-group textarea {
  padding: .5rem .7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: .875rem;
  background: var(--color-surface);
  color: var(--color-text);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: 2px solid var(--color-primary); border-color: transparent; }
.form-group textarea { resize: vertical; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-header h3 { margin-bottom: 0; }

/* ── Name autocomplete ──────────────────────────────────────────────────────── */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 200;
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
}

.autocomplete-list li {
  padding: .5rem .75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}

.autocomplete-list li:hover,
.autocomplete-list li.ac-active {
  background: #eff6ff;
}

.ac-name  { font-weight: 500; font-size: .875rem; }
.ac-phone { font-weight: 400; color: var(--color-muted); }
.ac-city  { font-size: .8rem; color: var(--color-muted); }

.end-preview {
  padding: .5rem .7rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--color-muted);
  min-height: 2.25rem;
  display: flex;
  align-items: center;
}

.form-actions { display: flex; gap: .75rem; margin-top: 1rem; align-items: center; }

/* ── Collapsible form section (Schedule) ───────────────────────────────────── */
details.form-section > summary {
  font-size: .95rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .5rem;
  user-select: none;
}
details.form-section > summary::-webkit-details-marker { display: none; }
details.form-section > summary::before {
  content: '▶';
  font-size: .65rem;
  display: inline-block;
  transition: transform .18s ease;
}
details.form-section[open] > summary::before { transform: rotate(90deg); }
details.form-section[open] > summary { margin-bottom: 1rem; }

/* ── Items table ───────────────────────────────────────────────────────────── */
.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.items-table th {
  text-align: left;
  padding: .5rem .75rem;
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-border);
  font-weight: 600;
  white-space: nowrap;
}

.items-table td {
  padding: .45rem .75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.items-table tfoot td { font-weight: 600; padding-top: .65rem; }
.total-label { text-align: right; color: var(--color-muted); }
.weight-total { color: var(--color-muted); font-size: .88rem; font-weight: 500; }

.btn-shipping-override {
  padding: .25rem .45rem;
  font-size: .82rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
  opacity: .55;
  transition: opacity .15s, background .15s, border-color .15s;
}
.btn-shipping-override:hover { opacity: 1; }
.btn-shipping-override.is-override {
  background: #fef3c7;
  border-color: #f59e0b;
  opacity: 1;
}

.items-table input[type="number"],
.items-table input[type="text"] {
  width: 100%;
  padding: .3rem .5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: .875rem;
}

.item-desc-split {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .4rem;
  align-items: center;
}

.item-size-select {
  width: 80px;
  padding: .3rem .4rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: .875rem;
}

.item-qty-col     { width: 90px; }
.item-price-col   { width: 110px; }
.item-total-col   { width: 90px; white-space: nowrap; }
.item-remove-col  { width: 40px; text-align: center; }

.btn-remove-item {
  background: none;
  border: none;
  color: var(--color-danger);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 .25rem;
  line-height: 1;
}
.btn-remove-item:hover { color: var(--color-danger-h); }

/* ── Product picker dialog ─────────────────────────────────────────────────── */
.product-dialog {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,.15);
  padding: 0;
  width: 420px;
  max-width: 95vw;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.product-dialog::backdrop {
  background: rgba(0,0,0,.35);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.dialog-header h3 { font-size: 1rem; }

.dialog-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--color-muted);
  padding: .1rem .3rem;
  border-radius: var(--radius);
}
.dialog-close:hover { background: var(--color-bg); }

.dialog-search { padding: .75rem 1rem; border-bottom: 1px solid var(--color-border); }
.dialog-search input {
  width: 100%;
  padding: .45rem .7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: .875rem;
}
.dialog-search input:focus { outline: 2px solid var(--color-primary); border-color: transparent; }

.product-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: .5rem 0;
}

.product-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem 1rem;
  cursor: pointer;
  transition: background .1s;
}

.product-list li:hover { background: var(--color-bg); }

.product-list .product-info { display: flex; flex-direction: column; }
.product-list .product-name { font-weight: 500; }
.product-list .product-meta { font-size: .8rem; color: var(--color-muted); }
.product-list .product-price { font-weight: 600; white-space: nowrap; margin-left: 1rem; }

/* ── Discount rows ─────────────────────────────────────────────────────────── */
.discount-row td { background: #f0fdf4; }
.discount-label  { font-style: italic; color: #166534; font-size: .875rem; }
.discount-amount { color: #16a34a; font-weight: 600; }

/* ── Discount admin ────────────────────────────────────────────────────────── */
.field-hint   { font-size: .78rem; color: var(--color-muted); margin-top: .2rem; }
.toggle-label { display: flex; align-items: center; gap: .4rem; cursor: pointer; font-weight: 500; }

.type-badge   { font-size: .8rem; color: var(--color-muted); }
.params-cell  { font-size: .825rem; }

.status-badge        { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.status-active       { background: #d1fae5; color: #065f46; }
.status-inactive     { background: #f3f4f6; color: #6b7280; }

/* ── Discount product tags ─────────────────────────────────────────────────── */
.discount-product-list {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  min-height: 1.5rem;
}

.discount-product-tag {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .55rem;
  background: #dbeafe;
  color: #1e40af;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
}

.tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #1e40af;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  opacity: .7;
}
.tag-remove:hover { opacity: 1; }

/* ── Calendar ──────────────────────────────────────────────────────────────── */
#calendar { background: var(--color-surface); border-radius: var(--radius); }

/* ── Admin pages ───────────────────────────────────────────────────────────── */
.admin-page { max-width: 900px; }
.admin-page h2 { font-size: 1.25rem; margin-bottom: 1.25rem; }

.admin-form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.admin-form-card h3 { font-size: .95rem; font-weight: 600; margin-bottom: 1rem; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: .875rem;
}

.admin-table th {
  text-align: left;
  padding: .65rem 1rem;
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-border);
  font-weight: 600;
}

.admin-table td {
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table .row-editing { background: #eff6ff; }
.row-actions { display: flex; gap: .5rem; align-items: center; }
.drag-handle { cursor: grab; color: var(--color-muted); user-select: none; padding: 0 .25rem; font-size: 1rem; }
.drag-handle:active { cursor: grabbing; }
.admin-table tr.drag-over td { border-top: 2px solid var(--color-primary); }
.admin-table tr.dragging { opacity: .4; }
.empty-row { color: var(--color-muted); text-align: center; padding: 2rem; }

/* ── Splitting page ───────────────────────────────────────────────────────── */
.split-page { max-width: 700px; padding: 1.5rem; }
.split-page h2 { font-size: 1.25rem; margin-bottom: 1.25rem; }

.split-day-header {
  font-size: .95rem;
  font-weight: 700;
  color: var(--color-muted);
  padding: .6rem 0 .3rem;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: .5rem;
  margin-top: .8rem;
}
.split-day-header:first-child { margin-top: 0; }

.split-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: .6rem;
  box-shadow: var(--shadow);
}
.split-card-done { opacity: .5; }

.split-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .75rem;
  font-size: .9rem;
  font-weight: 600;
}
.split-date { color: var(--color-muted); font-weight: 500; }
.split-status { margin-left: auto; }
.split-order-id { font-size: .875rem; color: var(--color-muted); font-weight: 700; }

.split-card-items {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .5rem;
}
.split-item-tag {
  background: #e0e7ff;
  color: #3730a3;
  font-size: .8rem;
  font-weight: 500;
  padding: .15rem .5rem;
  border-radius: 4px;
  white-space: nowrap;
}

.split-card-note {
  margin-top: .5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: pre-line;
}

.split-card-actions { margin-top: .6rem; display: flex; align-items: center; justify-content: space-between; }

/* ── Split Queue page (side-by-side layout) ───────────────────────────────── */
.split-queue-page { max-width: 900px; }
.split-queue-heading { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.split-queue-heading h2 { margin-bottom: 0; }
.split-queue-counter { font-size: .9rem; font-weight: 700; padding: .2rem .6rem; border-radius: 4px; color: #fff; }
.split-queue-counter-ok   { background: #16a34a; }
.split-queue-counter-over { background: #dc2626; }
.split-queue-card { display: flex; align-items: stretch; gap: 1rem; }
.split-queue-body { flex: 1 1 0; min-width: 0; }
.split-queue-actions { display: flex; flex-direction: column; justify-content: space-between; flex-shrink: 0; padding-top: .15rem; }
.split-queue-action-btns { display: flex; flex-direction: column; gap: .4rem; }
.split-queue-actions .btn { white-space: nowrap; }
.split-card-note-splitter { background: #fef9c3; border-left: 3px solid #eab308; padding: .25rem .5rem; border-radius: 3px; }
.split-card-problematic { border-left: 4px solid #dc2626; }
.split-problematic-banner { background: #dc2626; color: #fff; font-weight: 600; font-size: .85rem; padding: .25rem .6rem; border-radius: 3px; margin-bottom: .4rem; }

.delivery-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.delivery-header h2 { margin-bottom: 0; }
.delivery-header select { width: auto; min-width: 140px; }
.delivery-location { font-size: .85rem; color: var(--color-muted); margin-top: .3rem; }
.delivery-total { font-size: .95rem; font-weight: 700; margin-top: .5rem; }
.delivery-shipper { font-size: .82rem; color: var(--color-muted); }
.split-item-tag-other { background: #fef3c7; color: #92400e; }
.ro-value { padding: .4rem 0; font-size: .95rem; }

/* ── Audit history rows (order view, settings) ────────────────────────────── */
.history-list { margin-top: .5rem; }
.history-row {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .75rem;
  align-items: baseline;
  padding: .35rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: .85rem;
}
.history-row:last-child { border-bottom: none; }
.history-ts    { color: var(--color-muted); white-space: nowrap; min-width: 10ch; }
.history-user  { font-weight: 600; min-width: 6ch; }
.history-field { background: #e0e7ff; color: #3730a3; padding: .1rem .4rem; border-radius: 3px; font-size: .8rem; font-weight: 500; }
.history-diff  { color: var(--color-text); word-break: break-word; }
.history-summary { color: var(--color-muted); }

/* ── Customer notes timeline ──────────────────────────────────────────────── */
.note-timeline { margin-top: .35rem; }
.note-entry {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
  padding: .4rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: .9rem;
}
.note-entry:last-child { border-bottom: none; }
.note-meta { color: var(--color-muted); font-size: .8rem; white-space: nowrap; flex-shrink: 0; }

/* Session warning modal */
#session-warning-modal .modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000;
}
#session-warning-modal .modal-box {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 1001; background: var(--card-bg, #fff); border-radius: 8px;
  padding: 2rem; min-width: 320px; box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  text-align: center;
}
#session-warning-modal .modal-box h2 { margin-top: 0; }
#session-warning-modal .modal-box a { display: block; margin-top: 0.75rem; }
.note-text { white-space: pre-line; flex: 1; word-break: break-word; }
