/* ══════════════════════════════════════════════════════════════════
   CONTENTO'S DATABASE — Black & Red Marble UI
   ══════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #080809;
  --surface: rgba(18, 18, 22, 0.85);
  --surface-solid: #121216;
  --surface-raised: rgba(26, 26, 32, 0.9);
  --surface-overlay: rgba(32, 32, 40, 0.92);
  --border: rgba(255, 255, 255, 0.07);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-red: rgba(180, 30, 30, 0.2);
  --text: #eaeaef;
  --text-secondary: #a8a8b8;
  --text-muted: #5e5e70;
  --primary: #c41a1a;
  --primary-hover: #e03030;
  --primary-glow: rgba(196, 26, 26, 0.2);
  --primary-subtle: rgba(196, 26, 26, 0.07);
  --danger: #ef4444;
  --danger-hover: #f87171;
  --danger-subtle: rgba(239, 68, 68, 0.12);
  --success: #22c55e;
  --success-subtle: rgba(34, 197, 94, 0.1);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.1);
  --radius: 10px;
  --radius-lg: 14px;
  --radius-sm: 6px;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5), 0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.65), 0 4px 12px rgba(0, 0, 0, 0.4);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
  overscroll-behavior-x: none;
  touch-action: pan-y;
}

/* Prevent iOS zoom on input focus — must be 16px+ globally */
input, select, textarea {
  font-size: 16px !important;
  touch-action: manipulation;
}

/* Lock down all elements from triggering horizontal scroll/zoom */
*, *::before, *::after {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* ── Marble background ── */
  background-color: #060607;
  background-image:
    /* Deep red vein glow — top left */
    radial-gradient(ellipse 80% 60% at 15% 20%, rgba(140, 15, 15, 0.18) 0%, transparent 60%),
    /* Red vein — center right */
    radial-gradient(ellipse 50% 80% at 85% 45%, rgba(120, 10, 10, 0.12) 0%, transparent 55%),
    /* Subtle warm pulse — bottom */
    radial-gradient(ellipse 90% 40% at 50% 95%, rgba(100, 10, 10, 0.1) 0%, transparent 50%),
    /* Dark stone veins */
    radial-gradient(ellipse 40% 30% at 30% 70%, rgba(20, 20, 28, 0.8) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 70% 25%, rgba(18, 18, 24, 0.6) 0%, transparent 65%),
    /* Fine grain texture */
    radial-gradient(circle at 20% 50%, rgba(30, 10, 10, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(25, 8, 8, 0.1) 0%, transparent 35%),
    radial-gradient(circle at 50% 10%, rgba(20, 20, 30, 0.3) 0%, transparent 50%);
  background-attachment: fixed;
}

/* ── Layout ──────────────────────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
  max-width: 100vw;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════════════ */
.sidebar {
  width: 64px;
  background:
    linear-gradient(180deg,
      rgba(12, 12, 14, 0.97) 0%,
      rgba(8, 8, 10, 0.98) 50%,
      rgba(10, 10, 12, 0.99) 100%);
  backdrop-filter: blur(20px);
  color: #fff;
  padding: 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: visible;
  height: 100vh;
  position: sticky;
  top: 0;
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
}

.sidebar h1 {
  font-size: 17px;
  font-weight: 800;
  padding: 24px 22px 22px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.4px;
  background:
    linear-gradient(135deg, rgba(180, 20, 20, 0.08) 0%, transparent 50%),
    linear-gradient(225deg, rgba(100, 10, 10, 0.05) 0%, transparent 40%);
}

.sidebar h1 span {
  background: linear-gradient(135deg, #e53e3e 0%, #c41a1a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar h2 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.25);
  padding: 22px 22px 8px;
  font-weight: 700;
}

/* ── Collapsible Sidebar Sections ────────────────────────────────── */
.sidebar-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-toggle {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--transition);
}

.sidebar-toggle:hover {
  color: rgba(255, 255, 255, 0.55);
}

.toggle-arrow {
  font-size: 9px;
  transition: transform var(--transition);
  display: inline-block;
  line-height: 1;
}

.toggle-arrow.collapsed {
  transform: rotate(-90deg);
}

.sidebar-collapsible {
  overflow-y: auto;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  max-height: 2000px;
  opacity: 1;
}

.sidebar-collapsible.collapsed {
  max-height: 0 !important;
  opacity: 0;
  overflow: hidden;
}

.table-list {
  list-style: none;
  overflow-y: auto;
}

#tableList {
  flex: 1;
  min-height: 0;
}

#queryList {
  max-height: 200px;
}

.table-list li {
  padding: 9px 22px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.45);
  border-left: 2px solid transparent;
  position: relative;
}

.table-list li::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  transition: all var(--transition);
}

.table-list li:hover {
  background: rgba(196, 26, 26, 0.04);
  color: rgba(255, 255, 255, 0.8);
  border-left-color: rgba(196, 26, 26, 0.25);
}

.table-list li:hover::before {
  background: rgba(196, 26, 26, 0.4);
}

.table-list li.active {
  background: linear-gradient(90deg, rgba(196, 26, 26, 0.1) 0%, rgba(196, 26, 26, 0.03) 100%);
  color: #fff;
  border-left-color: var(--primary);
  font-weight: 600;
}

.table-list li.active::before {
  background: var(--primary);
  box-shadow: 0 0 8px rgba(196, 26, 26, 0.5);
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
}

.sidebar-footer-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  min-width: 0;
}

.sidebar-footer-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-info {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.15);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.settings-gear {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.settings-gear:hover {
  color: var(--primary-hover);
  background: rgba(196, 26, 26, 0.08);
}

/* ══════════════════════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════════════════════ */
.main {
  flex: 1;
  padding: 32px 36px;
  overflow-x: hidden;
  overflow-y: auto;
  min-width: 0;
  max-width: calc(100vw - 64px);
  height: 100vh;
}

/* ── Welcome State ───────────────────────────────────────────────── */
.welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60vh;
  text-align: center;
}

.welcome h2 {
  font-size: 26px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: -0.3px;
}

.welcome p {
  color: var(--text-muted);
  margin-top: 8px;
  font-size: 15px;
}

/* ── Toolbar ─────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  max-width: 100%;
}

.toolbar h2 {
  font-size: 24px;
  font-weight: 800;
  margin-right: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  letter-spacing: -0.5px;
}

.search-box {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  width: 260px;
  max-width: 100%;
  outline: none;
  transition: all var(--transition);
  background: var(--surface);
  backdrop-filter: blur(12px);
  color: var(--text);
  font-family: var(--font-sans);
}

.search-box::placeholder {
  color: var(--text-muted);
}

.search-box:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--surface-raised);
}

.sort-select {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: all var(--transition);
  background: var(--surface);
  backdrop-filter: blur(12px);
  color: var(--text-secondary);
  cursor: pointer;
  min-width: 160px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235e5e70' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.sort-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.sort-select option {
  background: var(--surface-solid);
  color: var(--text);
}

/* ══════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════ */
.btn {
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, #d42020 0%, #a01515 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(196, 26, 26, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #e53030 0%, #c41a1a 100%);
  box-shadow: 0 4px 16px rgba(196, 26, 26, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.18);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-success {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-success:hover {
  background: linear-gradient(135deg, #2dd468 0%, #1db954 100%);
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.35);
}

/* ══════════════════════════════════════════════════════════════════
   TABLE LAYOUT — Desktop: traditional rows, Mobile: cards
   ══════════════════════════════════════════════════════════════════ */

.table-wrapper-outer {
  position: relative;
  max-width: 100%;
}

.table-wrapper {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-x: auto;
  max-width: 100%;
}

/* ── Scroll arrow buttons ── */
.scroll-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d42020 0%, #a01515 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 12px rgba(196, 26, 26, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s ease;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
}

.scroll-arrow.visible {
  opacity: 1;
  pointer-events: auto;
}

.scroll-arrow:hover {
  background: linear-gradient(135deg, #e53030 0%, #c41a1a 100%);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5), 0 0 20px rgba(196, 26, 26, 0.4);
  transform: translateY(-50%) scale(1.1);
}

.scroll-arrow:active {
  transform: translateY(-50%) scale(0.95);
}

.scroll-arrow-left {
  left: -18px;
}

.scroll-arrow-right {
  right: -18px;
}

/* Edge fade hints */
.table-wrapper-outer::before,
.table-wrapper-outer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.table-wrapper-outer::before {
  left: 0;
  background: linear-gradient(90deg, rgba(18, 18, 22, 0.9) 0%, transparent 100%);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.table-wrapper-outer::after {
  right: 0;
  background: linear-gradient(270deg, rgba(18, 18, 22, 0.9) 0%, transparent 100%);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.table-wrapper-outer.can-scroll-left::before {
  opacity: 1;
}

.table-wrapper-outer.can-scroll-right::after {
  opacity: 1;
}

.data-table {
  min-width: 100%;
  width: max-content;
  border-collapse: collapse;
  font-size: 13px;
  border: none;
}

/* Desktop: show table header */
.data-table thead {
  display: table-header-group;
}

.data-table th {
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 6px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table tbody {
  display: table-row-group;
}

.data-table tr {
  display: table-row;
  transition: background 0.2s ease;
}

.data-table tr:hover td {
  background: rgba(196, 26, 26, 0.03);
}

.data-table td {
  display: table-cell;
  padding: 10px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  vertical-align: middle;
}

/* Hide data-label on desktop — only used in mobile card layout */
.data-table td::before {
  display: none;
}

/* Actions cell in table row */
.data-table td.actions {
  white-space: nowrap;
  text-align: right;
  padding: 8px 6px;
}

.data-table td.actions .btn {
  margin-left: 4px;
}

/* Empty state row */
.data-table .empty-cell {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  border: none;
  font-size: 15px;
  display: table-cell;
  justify-content: center;
}

/* ── Row Pop-in Animation ──────────────────────────────────────── */
.data-table tr.row-pop-in {
  animation: rowPopIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes rowPopIn {
  0% {
    opacity: 0;
    transform: scale(0.92) translateY(-8px);
    box-shadow: 0 0 0 2px rgba(196, 26, 26, 0.4);
  }
  50% {
    box-shadow: 0 0 20px rgba(196, 26, 26, 0.25);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
    box-shadow: none;
  }
}

/* Pop-in highlight flash for desktop table rows */
.data-table tr.row-pop-in td {
  animation: cellFlash 0.6s ease both;
}

@keyframes cellFlash {
  0% {
    background: rgba(196, 26, 26, 0.12);
  }
  100% {
    background: transparent;
  }
}

/* ── Pagination ──────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 4px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

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

.sort-arrow {
  margin-left: 4px;
  font-size: 10px;
}

/* ══════════════════════════════════════════════════════════════════
   MODALS — Frosted Overlay
   ══════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.25s;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

.modal-overlay.show {
  opacity: 1;
}

.modal {
  background: var(--surface-solid);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow:
    var(--shadow-lg),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay.show .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(196, 26, 26, 0.04) 0%, transparent 60%);
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

/* ══════════════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════════════ */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.form-group label .type-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  max-width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
  font-family: var(--font-sans);
  outline: none;
  transition: all var(--transition);
  background: rgba(8, 8, 10, 0.6);
  color: var(--text);
  touch-action: manipulation;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: rgba(8, 8, 10, 0.8);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-group .identity-badge {
  display: inline-block;
  background: rgba(8, 8, 10, 0.4);
  color: var(--text-muted);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  width: 100%;
  font-style: italic;
}

/* ══════════════════════════════════════════════════════════════════
   TOASTS
   ══════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 250px;
  backdrop-filter: blur(16px);
  letter-spacing: 0.01em;
}

.toast.success {
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.9), rgba(21, 128, 61, 0.9));
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.toast.error {
  background: linear-gradient(135deg, rgba(196, 26, 26, 0.9), rgba(160, 21, 21, 0.9));
  border: 1px solid rgba(239, 68, 68, 0.3);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ── Loading ─────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  gap: 12px;
  font-size: 14px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Confirm Dialog ──────────────────────────────────────────────── */
.confirm-body {
  text-align: center;
  padding: 12px 0;
}

.confirm-body p {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ══════════════════════════════════════════════════════════════════
   QUERY EDITOR
   ══════════════════════════════════════════════════════════════════ */
.query-editor-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 100%;
  overflow: hidden;
}

.query-top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 100%;
}

.query-top-bar h2 {
  font-size: 24px;
  font-weight: 800;
  margin-right: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  letter-spacing: -0.5px;
}

.query-name-input {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  width: 260px;
  max-width: 100%;
  outline: none;
  transition: all var(--transition);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
}

.query-name-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.query-desc-input {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  width: 100%;
  outline: none;
  transition: all var(--transition);
  color: var(--text-muted);
  background: var(--surface);
  font-family: var(--font-sans);
}

.query-desc-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  color: var(--text);
}

.query-textarea {
  width: 100%;
  min-height: 180px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  background: rgba(8, 8, 10, 0.7);
  color: var(--text);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: all var(--transition);
  tab-size: 2;
}

.query-textarea:focus {
  border-color: var(--primary);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4), 0 0 0 3px var(--primary-glow);
}

.query-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Query results keep traditional table layout */
.query-results {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-x: auto;
  max-width: 100%;
}

.query-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.2);
}

/* Query results — keep table layout even on mobile */
.query-results .data-table td {
  max-width: 220px;
  font-size: 13px;
  padding: 10px 16px;
}

@media (max-width: 768px) {
  .query-results .data-table thead {
    display: table-header-group;
  }

  .query-results .data-table tbody {
    display: table-row-group;
  }

  .query-results .data-table tr {
    display: table-row;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
  }

  .query-results .data-table td {
    display: table-cell;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: normal;
    padding: 10px 12px;
  }

  .query-results .data-table td::before {
    display: none;
  }

  .query-results .data-table td:first-child {
    padding-top: 10px;
  }

  .query-results .data-table td:last-child {
    padding-bottom: 10px;
  }
}

.query-results-info {
  padding: 12px 18px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.query-error {
  padding: 16px;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: var(--radius);
  color: #f87171;
  font-size: 14px;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
}

.query-empty {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.sidebar .table-list + .table-list {
  border-top: none;
}

.table-list li .query-icon {
  flex-shrink: 0;
}

.table-list li .query-delete {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
  transition: all var(--transition);
}

.table-list li .query-delete:hover {
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
}

/* ══════════════════════════════════════════════════════════════════
   CONTAINER TRACKING
   ══════════════════════════════════════════════════════════════════ */
.ct-page {
  max-width: 100%;
}

.ct-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.ct-header h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

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

/* Search bar */
.ct-search-bar {
  position: relative;
  margin-bottom: 16px;
}

.ct-search-input {
  width: 100%;
  padding: 11px 40px 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(8, 8, 10, 0.6);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: all var(--transition);
}

.ct-search-input::placeholder {
  color: var(--text-muted);
}

.ct-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: rgba(8, 8, 10, 0.8);
}

.ct-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 4px;
  transition: all var(--transition);
}

.ct-search-clear:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

/* Pagination */
.ct-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
  padding: 16px 0;
}

.ct-page-info {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.ct-page-total {
  color: var(--text-muted);
  font-weight: 400;
}

/* Toggle button row (Return/No Return, Swap/No Swap) */
.ct-toggle-row {
  display: flex;
  gap: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.ct-toggle-btn {
  flex: 1;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  background: rgba(8, 8, 10, 0.5);
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}

.ct-toggle-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

.ct-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
}

.ct-toggle-btn.active {
  background: var(--primary-subtle);
  color: var(--primary-hover);
  font-weight: 700;
}

/* Filter pills */
.ct-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.ct-filter-pill {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ct-filter-pill:hover {
  border-color: var(--pill-color, var(--text-muted));
  color: var(--pill-color, var(--text));
}

.ct-filter-pill.active {
  background: var(--pill-color, var(--primary));
  color: #fff;
  border-color: var(--pill-color, var(--primary));
}

.ct-pill-count {
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}

.ct-filter-pill.active .ct-pill-count {
  background: rgba(255, 255, 255, 0.25);
}

/* Container grid */
.ct-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Container card */
.ct-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  border-top: 2px solid var(--card-border);
  /* Flex column so the footer pins to the bottom even when the grid stretches a
     shorter card (fewer body rows) to match its neighbours — no white gap. */
  display: flex;
  flex-direction: column;
}

.ct-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--card-border);
}

.ct-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 0;
}

.ct-card-id {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}

.ct-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid;
  letter-spacing: 0.3px;
}

.ct-status-badge-lg {
  padding: 6px 18px;
  font-size: 13px;
}

.ct-card-body {
  padding: 12px 18px;
  flex: 1 1 auto;   /* grow to fill, pushing the footer to the bottom */
}

.ct-card-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}

.ct-card-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.ct-card-value {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

.ct-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.15);
}

/* Detail page */
.ct-detail {
  max-width: 100%;
}

.ct-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.ct-detail-header h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.ct-detail-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 2px;
}

.ct-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ct-detail-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.ct-detail-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(196, 26, 26, 0.2), transparent);
}

.ct-detail-card h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.ct-info-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ct-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.ct-info-row span {
  color: var(--text-muted);
}

.ct-info-row strong {
  color: var(--text);
  font-weight: 600;
}

/* Action form */
.ct-action-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ct-action-form select,
.ct-action-form input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-sans);
  background: rgba(8, 8, 10, 0.6);
  color: var(--text);
  outline: none;
  transition: all var(--transition);
}

.ct-action-form select:focus,
.ct-action-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Inline yard selector in the container detail info rows */
.ct-yard-select {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px !important;
  font-family: var(--font-sans);
  background: rgba(8, 8, 10, 0.6);
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: all var(--transition);
}
.ct-yard-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Lifecycle form elements */
.ct-form-hint {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 4px;
}

.ct-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: -4px;
}

.ct-manual-override {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.ct-manual-override details summary {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}

.ct-manual-override details summary:hover {
  color: var(--text-secondary);
}

.ct-manual-override details[open] summary {
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.btn-success {
  background: var(--success);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-success:hover {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Status timeline */
.ct-timeline {
  position: relative;
  padding-left: 24px;
}

.ct-timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}

.ct-timeline-item {
  position: relative;
  padding: 8px 0 16px 16px;
}

.ct-timeline-item:last-child {
  padding-bottom: 0;
}

.ct-timeline-dot {
  position: absolute;
  left: -20px;
  top: 12px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--surface-solid);
  z-index: 1;
}

.ct-timeline-latest .ct-timeline-dot {
  width: 14px;
  height: 14px;
  left: -21px;
  box-shadow: 0 0 8px currentColor;
}

.ct-timeline-status {
  font-weight: 700;
  font-size: 14px;
}

.ct-timeline-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ct-timeline-notes {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}
.ct-timeline-assign {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  font-size: 12px;
}
.ct-timeline-cust {
  font-weight: 600;
  color: var(--text);
}
.ct-timeline-loc {
  color: var(--text-secondary);
}
.ct-timeline-ds {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--primary-hover);
  background: var(--primary-subtle);
  border: 1px solid var(--border-red);
  padding: 1px 7px;
  border-radius: 20px;
}

@media (max-width: 768px) {
  .ct-header h2 {
    font-size: 22px;
  }

  .ct-grid {
    grid-template-columns: 1fr;
  }

  .ct-detail-grid {
    grid-template-columns: 1fr;
  }

  .ct-detail-header h2 {
    font-size: 22px;
  }

  .ct-filters {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .ct-filter-pill {
    flex-shrink: 0;
  }
}

/* ══════════════════════════════════════════════════════════════════
   DASHBOARD
   ══════════════════════════════════════════════════════════════════ */
.dashboard {
  max-width: 100%;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.dashboard-header h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* Summary stat cards */
.dash-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.dash-stat-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.dash-stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(196, 26, 26, 0.4), transparent);
}

.dash-stat-card:hover {
  border-color: rgba(196, 26, 26, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.dash-stat-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #e53e3e 0%, #c41a1a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.dash-stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Chart cards */
.dash-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.dash-chart-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.dash-chart-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(196, 26, 26, 0.2), transparent);
}

.dash-chart-card h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.dash-chart-wrap {
  height: clamp(220px, 28vh, 500px);
  position: relative;
}

.dash-chart-tall {
  height: clamp(280px, 35vh, 600px);
}

.dash-full-width {
  margin-bottom: 16px;
}

/* Recent activity */
.dash-recent {
  display: flex;
  flex-direction: column;
}

.dash-activity-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
}

.dash-activity-row:last-child {
  border-bottom: none;
}

.dash-activity-source {
  font-weight: 700;
  color: var(--primary-hover);
  min-width: 100px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.dash-activity-date {
  color: var(--text-secondary);
  min-width: 100px;
}

.dash-activity-detail {
  color: var(--text-muted);
  min-width: 80px;
  text-align: right;
}

/* Large screens — bigger cards, more padding */
@media (min-width: 1400px) {
  .dash-summary {
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
  }

  .dash-stat-card {
    padding: 36px 28px;
  }

  .dash-stat-value {
    font-size: 40px;
  }

  .dash-stat-label {
    font-size: 12px;
    margin-top: 6px;
  }

  .dash-charts-row {
    gap: 20px;
    margin-bottom: 20px;
  }

  .dash-chart-card {
    padding: 28px;
  }

  .dash-chart-card h3 {
    font-size: 14px;
    margin-bottom: 20px;
  }

  .dash-activity-row {
    padding: 14px 8px;
    font-size: 14px;
  }
}

/* Extra large screens */
@media (min-width: 1800px) {
  .dash-summary {
    gap: 24px;
  }

  .dash-stat-card {
    padding: 44px 32px;
  }

  .dash-stat-value {
    font-size: 48px;
  }

  .dash-charts-row {
    gap: 24px;
    margin-bottom: 24px;
  }

  .dash-chart-card {
    padding: 36px;
  }
}

@media (max-width: 768px) {
  .dashboard-header h2 {
    font-size: 22px;
  }

  .dash-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .dash-stat-value {
    font-size: 24px;
  }

  .dash-stat-card {
    padding: 16px 12px;
  }

  .dash-charts-row {
    grid-template-columns: 1fr;
  }

  .dash-chart-wrap {
    height: 200px;
  }

  .dash-activity-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .dash-activity-source {
    min-width: auto;
  }

  .dash-activity-date {
    min-width: auto;
  }

  .dash-activity-detail {
    min-width: auto;
    text-align: left;
  }
}

/* ══════════════════════════════════════════════════════════════════
   DELIVERY INTAKE FORM
   ══════════════════════════════════════════════════════════════════ */
.di-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.di-header {
  margin-bottom: 24px;
}

.di-header h2 {
  font-size: 24px;
  font-weight: 800;
  margin: 12px 0 4px;
}

.di-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

.di-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.di-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  backdrop-filter: blur(20px);
}

.di-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Container slot builder (delivery intake) ─────────────────── */
.di-container-slots {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.di-container-slot {
  display: flex;
  align-items: center;
  gap: 8px;
}

.di-container-slot select.di-slot-size {
  flex: 1;
  min-width: 120px;
}

.di-container-slot .di-slot-qty {
  width: 60px;
  text-align: center;
}

.di-container-slot .di-slot-remove {
  color: var(--text-muted);
  font-size: 16px;
}

.di-container-slot .di-slot-remove:hover {
  color: #ef4444;
}

.di-toggle-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.di-toggle {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}

.di-toggle:hover {
  color: var(--text-secondary);
  border-color: rgba(255,255,255,0.15);
}

.di-toggle.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.di-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.di-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.di-field.di-full {
  grid-column: 1 / -1;
}

.di-field.di-half {
  /* stays as one column */
}

.di-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.di-form select,
.di-form input,
.di-form textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-sans);
  background: rgba(8, 8, 10, 0.6);
  color: var(--text);
  outline: none;
  transition: all var(--transition);
  width: 100%;
  min-width: 0;   /* iOS date/number inputs carry an intrinsic min-width that
                     otherwise overrides width:100% and overflows the card */
}

.di-form select:focus,
.di-form input:focus,
.di-form textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.di-form textarea {
  resize: vertical;
  min-height: 60px;
}

.di-money-input {
  position: relative;
  display: flex;
  align-items: center;
}

.di-money-prefix {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
  z-index: 1;
}

.di-money-input input {
  padding-left: 28px;
}

.di-submit-row {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 8px 0 32px;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 700;
}

@media (max-width: 768px) {
  .di-page {
    padding: 16px;
  }

  .di-section {
    padding: 16px;
  }

  .di-fields {
    grid-template-columns: 1fr;
  }

  .di-toggle-row {
    flex-wrap: wrap;
  }

  /* Container-request row: wrap so it never runs off the screen. Size + qty +
     remove share the top line; the material field drops to its own full line. */
  .di-container-slot { flex-wrap: wrap; }
  .di-container-slot select.di-slot-size { order: 1; flex: 1 1 auto; min-width: 0; }
  .di-container-slot .di-slot-qty { order: 2; }
  .di-container-slot .di-slot-remove { order: 3; }
  .di-container-slot .di-slot-material { order: 4; flex: 1 1 100%; min-width: 0 !important; }

  /* Same treatment for the add-container row on the Edit Delivery Sheet page */
  .eds-add #eds_newMat { min-width: 0 !important; flex: 1 1 100%; order: 4; }
  .eds-add #eds_newSize { order: 1; }
  .eds-add #eds_newQty { order: 2; }
  .eds-add > .btn { order: 3; }

  .di-submit-row {
    flex-direction: column;
  }

  .di-submit-row .btn {
    width: 100%;
    text-align: center;
  }
}

/* ── Delivery Sheet Detail ─────────────────────────────────────── */
.ds-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.ds-detail-header h2 {
  font-size: 24px;
  font-weight: 800;
}

.ds-assign-card {
  background: var(--surface);
  border: 2px dashed var(--warning);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}

.ds-assign-card.ds-assigned {
  border: 2px solid rgba(34, 197, 94, 0.3);
  border-style: solid;
  text-align: left;
}

.ds-assign-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.ds-assign-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.ds-assign-card .ct-form-hint {
  margin-bottom: 16px;
}

.ds-assign-card .ct-action-form {
  text-align: left;
}

.ds-assign-card + .ds-assign-card {
  margin-top: 12px;
}

.ds-assigned .ds-assign-icon {
  color: var(--success);
}

/* ── Delivery Sheet Records Tables ──────────────────────────────── */
.ds-records-table-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

.ds-records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ds-records-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.ds-records-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-primary);
  white-space: nowrap;
}

.ds-records-table tr:last-child td {
  border-bottom: none;
}

.ds-records-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

/* ══════════════════════════════════════════════════════════════════
   DATA ENTRY PAGE
   ══════════════════════════════════════════════════════════════════ */
.data-entry-page {
  max-width: 720px;
  margin: 0 auto;
}

.data-entry-header {
  margin-bottom: 28px;
}

.data-entry-header h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.data-entry-subtitle {
  color: var(--text-muted);
  font-size: 15px;
}

.data-entry-table-select {
  margin-bottom: 28px;
}

.data-entry-table-select label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.data-entry-table-select select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: var(--font-sans);
  font-weight: 600;
  outline: none;
  background: var(--surface);
  backdrop-filter: blur(12px);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235e5e70' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.data-entry-table-select select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.data-entry-form {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  position: relative;
}

/* Red shimmer on top of the form card */
.data-entry-form::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(196, 26, 26, 0.2) 25%,
    rgba(196, 26, 26, 0.4) 50%,
    rgba(196, 26, 26, 0.2) 75%,
    transparent 100%);
}

.data-entry-fields {
  padding: 32px 32px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
}

.data-entry-fields .form-group {
  margin-bottom: 20px;
}

/* Make full-width fields span both columns */
.data-entry-fields .form-group:has(textarea) {
  grid-column: 1 / -1;
}

/* Identity badge fields span one column */
.data-entry-fields .form-group:first-child {
  grid-column: 1 / -1;
}

.data-entry-actions {
  display: flex;
  gap: 12px;
  padding: 20px 32px 28px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius);
}

/* ── Data Entry Session Log ─────────────────────────────────────── */
.de-session-card {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.de-session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.de-session-header h3 {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.de-session-count {
  background: var(--primary-subtle);
  color: var(--primary-hover);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.de-session-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.de-session-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.de-session-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.de-session-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.de-session-table tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.de-session-table tbody tr:last-child td {
  border-bottom: none;
}

.de-session-table tbody tr:hover {
  background: rgba(196, 26, 26, 0.03);
}

.de-session-actions {
  white-space: nowrap;
  text-align: right;
}

@media (max-width: 768px) {
  .de-session-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 16px;
  }
}

@media (max-width: 768px) {
  .data-entry-page {
    max-width: 100%;
  }

  .data-entry-header h2 {
    font-size: 22px;
  }

  .data-entry-fields {
    grid-template-columns: 1fr;
    padding: 20px 16px 8px;
    gap: 0;
  }

  .data-entry-fields .form-group:first-child {
    grid-column: 1;
  }

  .data-entry-actions {
    flex-direction: column;
    padding: 16px;
  }

  .btn-lg {
    width: 100%;
    justify-content: center;
  }
}

/* ══════════════════════════════════════════════════════════════════
   ADMIN PANEL
   ══════════════════════════════════════════════════════════════════ */
.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.admin-tab {
  padding: 12px 22px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
}

.admin-tab:hover {
  color: var(--text-secondary);
  background: rgba(196, 26, 26, 0.03);
}

.admin-tab.active {
  color: var(--primary-hover);
  border-bottom-color: var(--primary);
}

/* ── Access Checkboxes ──────────────────────────────────────────── */
.access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}

.access-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}

.access-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
}

.access-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.access-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin: 20px 0 10px;
  font-weight: 700;
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE & TABLET
   ══════════════════════════════════════════════════════════════════ */
.mobile-header {
  display: none;
}

.sidebar-overlay {
  display: none;
}

.sidebar-close {
  display: none;
}

@media (max-width: 768px) {

  .app {
    flex-direction: column;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(10, 10, 12, 0.95);
    backdrop-filter: blur(20px);
    color: #fff;
    padding: 14px 16px;
    position: sticky;
    top: 0;
    z-index: 900;
    border-bottom: 1px solid var(--border);
  }

  .hamburger {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
  }

  .mobile-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.3px;
  }

  .mobile-title span {
    background: linear-gradient(135deg, #e53e3e 0%, #c41a1a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    height: auto;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar h1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .sidebar-close {
    display: block;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 26px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
  }

  .sidebar-close:hover {
    color: #fff;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1050;
    backdrop-filter: blur(4px);
  }

  .sidebar-overlay.show {
    display: block;
  }

  .main {
    padding: 16px;
    min-height: calc(100vh - 52px);
    max-width: 100vw;
    height: auto;
    overflow-y: visible;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar h2 {
    font-size: 20px;
  }

  .search-box {
    width: 100%;
  }

  .sort-select {
    width: 100%;
  }

  .btn {
    padding: 11px 20px;
    font-size: 14px;
  }

  .btn-sm {
    padding: 8px 14px;
    font-size: 13px;
  }

  /* ── Switch to card layout on mobile ── */
  .table-wrapper-outer::before,
  .table-wrapper-outer::after {
    display: none;
  }

  .scroll-arrow {
    display: none !important;
  }

  .table-wrapper {
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
    max-width: 100%;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .data-table {
    width: 100%;
    min-width: 0;
  }

  .data-table tr {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
    max-width: 100%;
  }

  .data-table tr:hover td {
    background: transparent;
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    max-width: none;
    white-space: normal;
    word-break: break-word;
    overflow: visible;
    text-overflow: unset;
    font-size: 14px;
    gap: 16px;
  }

  .data-table td:first-child {
    padding-top: 12px;
  }

  .data-table td:last-child {
    border-bottom: none;
    padding-bottom: 12px;
  }

  .data-table td::before {
    display: block;
    content: attr(data-label);
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    flex-shrink: 0;
    padding-top: 3px;
    min-width: 90px;
  }

  .data-table td.actions {
    justify-content: flex-start;
    gap: 8px;
    padding: 10px 16px 14px;
    border-top: 1px solid var(--border);
    border-bottom: none;
    background: rgba(0, 0, 0, 0.2);
    flex-wrap: wrap;
    text-align: left;
  }

  .data-table td.actions .btn {
    flex-shrink: 0;
    font-size: 12px;
    padding: 6px 10px;
  }

  .data-table td.actions::before {
    display: none;
  }

  .data-table td.actions .btn {
    margin-left: 0;
  }

  .data-table .empty-row {
    background: transparent;
    border: 1px dashed var(--border);
  }

  .data-table .empty-cell {
    display: flex;
    justify-content: center;
    text-align: center;
    padding: 40px 16px;
    font-size: 14px;
  }

  .data-table .empty-cell::before {
    display: none !important;
  }

  .query-results {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .pagination {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow-x: hidden;
  }

  .modal-header {
    padding: 16px;
    position: sticky;
    top: 0;
    background: var(--surface-solid);
    z-index: 1;
  }

  .modal-body {
    padding: 16px;
    overflow-x: hidden;
  }

  .modal-footer {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)); /* clear the home indicator */
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    background: var(--surface-solid);
    z-index: 1;
  }

  /* Full-width, thumb-reachable action buttons in the bottom-sheet footer */
  .modal-footer .btn { flex: 1 1 auto; justify-content: center; min-height: 46px; }

  .query-name-input {
    width: 100%;
  }

  .query-textarea {
    min-height: 140px;
    font-size: 13px;
  }

  .query-actions {
    flex-direction: column;
  }

  .query-actions .btn {
    justify-content: center;
  }

  .toast {
    min-width: 0;
    max-width: calc(100vw - 40px);
    font-size: 13px;
  }

  .welcome h2 {
    font-size: 18px;
  }

  .admin-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-tab {
    padding: 10px 16px;
    font-size: 12px;
    white-space: nowrap;
  }
}

/* ══════════════════════════════════════════════════════════════════
   MATERIALS OUT TABLE
   ══════════════════════════════════════════════════════════════════ */

.mo-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.mo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.mo-table thead th {
  padding: 12px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.mo-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
}

.mo-table tbody tr:last-child td {
  border-bottom: none;
}

.mo-table tbody tr:hover {
  background: rgba(196, 26, 26, 0.03);
}

/* Empty state */
.mo-table .empty-cell {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  border: none;
  font-size: 15px;
  display: table-cell;
}

.mo-table .empty-row {
  background: transparent;
}

.mo-type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  background: var(--primary-subtle);
  color: var(--primary-hover);
  border: 1px solid rgba(196, 26, 26, 0.15);
  white-space: nowrap;
}

/* ── Mobile: Materials Out cards ──────────────────────────────────── */
@media (max-width: 768px) {
  .mo-table thead {
    display: none;
  }

  .mo-table tbody tr {
    display: block;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    position: relative;
  }

  .mo-table tbody tr:last-child {
    border-bottom: none;
  }

  .mo-table tbody td {
    display: block;
    padding: 2px 0;
    border-bottom: none;
    text-align: left !important;
    white-space: normal;
  }

  .mo-table tbody td::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-right: 8px;
  }

  .mo-table .empty-row {
    background: transparent;
    border: 1px dashed var(--border);
  }

  .mo-table .empty-cell {
    display: flex;
    justify-content: center;
    text-align: center;
    padding: 40px 16px;
    font-size: 14px;
  }

  .mo-table .empty-cell::before {
    display: none !important;
  }
}

/* Desktop: traditional table rows | Mobile: card layout */

/* ══════════════════════════════════════════════════════════════════
   BRAND & MOTION LAYER  ·  Contento's — black & red marble
   (appended: enhancements only, overrides nothing structural)
   ══════════════════════════════════════════════════════════════════ */

/* ── Brand logo (monochrome JPEG → white via invert + screen blend) ── */
.brand {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
  min-width: 0;
}
.brand-logo {
  height: 26px;
  width: auto;
  max-width: 182px;
  filter: invert(1) contrast(1.15) brightness(1.05);
  mix-blend-mode: screen;
  -webkit-user-drag: none;
  user-select: none;
  animation: brandIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.brand-sub {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-left: 3px;
}
.mobile-title .brand-logo { height: 20px; }
@keyframes brandIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: none; }
}

/* ── View entrance ── */
@keyframes viewEnter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.dashboard,
.ct-page,
.ct-detail,
.di-page,
.data-entry-page,
.query-editor-wrapper,
.welcome {
  animation: viewEnter 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ── Staggered card reveal ── */
@keyframes cardRise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
.ct-grid .ct-card,
.dash-summary .dash-stat-card {
  animation: cardRise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.ct-grid .ct-card:nth-child(1),  .dash-summary .dash-stat-card:nth-child(1) { animation-delay: 0.02s; }
.ct-grid .ct-card:nth-child(2),  .dash-summary .dash-stat-card:nth-child(2) { animation-delay: 0.06s; }
.ct-grid .ct-card:nth-child(3),  .dash-summary .dash-stat-card:nth-child(3) { animation-delay: 0.10s; }
.ct-grid .ct-card:nth-child(4),  .dash-summary .dash-stat-card:nth-child(4) { animation-delay: 0.14s; }
.ct-grid .ct-card:nth-child(5),  .dash-summary .dash-stat-card:nth-child(5) { animation-delay: 0.18s; }
.ct-grid .ct-card:nth-child(6) { animation-delay: 0.22s; }
.ct-grid .ct-card:nth-child(7) { animation-delay: 0.26s; }
.ct-grid .ct-card:nth-child(8) { animation-delay: 0.30s; }
.ct-grid .ct-card:nth-child(n+9) { animation-delay: 0.34s; }

/* ── Card hover lift + red glow ── */
.ct-card,
.dash-stat-card,
.ct-detail-card,
.ds-assign-card {
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.22s ease,
              border-color 0.22s ease;
  will-change: transform;
}
.ct-card:hover,
.dash-stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-red), 0 6px 22px rgba(196, 26, 26, 0.12);
  border-color: var(--border-red);
}
.ct-detail-card:hover { box-shadow: var(--shadow-md), 0 0 0 1px var(--border-red); }

/* ── Buttons: press feedback + primary sheen sweep ── */
.btn { position: relative; overflow: hidden; }
.btn:active { transform: translateY(1px) scale(0.985); }
.btn-primary::after,
.btn-success::after {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  transform: skewX(-18deg);
  transition: left 0.55s ease;
  pointer-events: none;
}
.btn-primary:hover::after,
.btn-success:hover::after { left: 130%; }

/* ── Filter pills: active pop ── */
.ct-filter-pill { transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); }
.ct-filter-pill.active { transform: translateY(-1px); }
.ct-filter-pill:active { transform: scale(0.94); }

/* ── Status badges: gentle living glow ── */
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196, 26, 26, 0); }
  50%      { box-shadow: 0 0 10px 0 rgba(196, 26, 26, 0.18); }
}
.ct-status-badge-lg { animation: badgePulse 3.2s ease-in-out infinite; }

/* ── Branded scrollbar ── */
* { scrollbar-width: thin; scrollbar-color: rgba(196, 26, 26, 0.35) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(196, 26, 26, 0.45), rgba(120, 12, 12, 0.4));
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(224, 48, 48, 0.6), rgba(150, 16, 16, 0.5));
  background-clip: padding-box;
}

/* ── Toast: subtle entry bounce already exists (slideIn); add depth ── */
.toast { box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-red); }

/* ── Sidebar nav items: red wipe on hover ── */
.table-list li { position: relative; transition: color 0.2s ease, background 0.2s ease; }

/* ── Respect reduced-motion preferences ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ══════════════════════════════════════════════════════════════════
   COLLAPSIBLE SIDEBAR  ·  hide/show with smooth transition
   ══════════════════════════════════════════════════════════════════ */

/* Header becomes a row so the collapse button sits opposite the brand */
.sidebar h1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-collapse-btn {
  flex-shrink: 0;
  margin-top: 2px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.sidebar-collapse-btn:hover {
  background: var(--primary-subtle);
  border-color: var(--border-red);
  color: var(--text);
  transform: translateX(-1px);
}

/* Floating button to bring the sidebar back (desktop, when hidden) */
.sidebar-show-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 950;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-raised);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-red);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: all var(--transition);
}
.sidebar-show-btn:hover {
  background: var(--primary-subtle);
  transform: translateX(2px);
  box-shadow: var(--shadow-md), 0 0 16px var(--primary-glow);
}

/* Desktop collapse behaviour */
@media (min-width: 769px) {
  .sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.22s ease,
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .main {
    transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.3s ease;
  }
  .app.sidebar-collapsed .sidebar {
    width: 0;
    min-width: 0;
    opacity: 0;
    transform: translateX(-16px);
    border-right: none;
    box-shadow: none;
    pointer-events: none;
    overflow: hidden;
  }
  .app.sidebar-collapsed .main {
    max-width: 100vw;
    /* reserve a gutter so page content never renders under the floating show button */
    padding-left: 72px;
  }
  .app.sidebar-collapsed .sidebar-show-btn {
    display: flex;
    animation: brandIn 0.3s ease both;
  }
}

/* On mobile the slide-in drawer + hamburger handle this instead */
@media (max-width: 768px) {
  .sidebar-collapse-btn { display: none; }
  .sidebar-show-btn { display: none !important; }
}

/* ══════════════════════════════════════════════════════════════════
   CONDENSED CONTAINER FILTERS  ·  icon chips + yard dropdown
   ══════════════════════════════════════════════════════════════════ */
.ct-filters-bar {
  align-items: center;
  gap: 8px 10px;
}
.ct-filters-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

/* Compact status chip: icon + count by default, name reveals when active/hovered */
.ct-chip { padding: 7px 12px; }
.ct-chip-ico {
  font-size: 12px;
  line-height: 1;
  color: var(--pill-color, var(--text-secondary));
  transition: color var(--transition);
}
.ct-chip-name {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition: max-width 0.25s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.18s ease;
}
.ct-chip.active .ct-chip-name,
.ct-chip:hover .ct-chip-name {
  max-width: 120px;
  opacity: 1;
}
.ct-chip.active .ct-chip-ico { color: #fff; }

/* Yard dropdown styled as a pill */
.ct-yard-filter-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 8px 4px 13px;
  margin-left: auto;
  transition: all var(--transition);
}
.ct-yard-filter-wrap.active {
  border-color: var(--border-red);
  background: var(--primary-subtle);
}
.ct-yard-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}
.ct-yard-filter {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px !important;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
  padding: 2px 4px;
}
.ct-yard-filter:focus { outline: none; }
.ct-yard-filter option { background: var(--surface-solid); color: var(--text); }

@media (max-width: 768px) {
  .ct-yard-filter-wrap { margin-left: 0; }
}

/* ══════════════════════════════════════════════════════════════════
   OPERATIONAL DASHBOARD  ·  KPI accents, pickups, overdue flags
   ══════════════════════════════════════════════════════════════════ */
/* Per-metric colored accent on each KPI card's top bar */
.dash-stat-card::before {
  background: linear-gradient(90deg, transparent, var(--stat, rgba(196, 26, 26, 0.5)), transparent);
  height: 2.5px;
}
.dash-stat-card:hover {
  border-color: color-mix(in srgb, var(--stat, var(--primary)) 30%, transparent);
}

/* Unit (e.g. "t") and overdue flag inside the gradient-clipped value */
.dash-stat-unit {
  font-size: 17px;
  font-weight: 700;
  margin-left: 3px;
  -webkit-text-fill-color: var(--text-muted);
  color: var(--text-muted);
}
.dash-stat-flag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  margin-left: 8px;
  vertical-align: middle;
  -webkit-text-fill-color: #f87171;
  color: #f87171;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 1px 8px;
  border-radius: 20px;
}

/* Upcoming pickups list */
.dash-pill-warn {
  font-size: 11px;
  font-weight: 700;
  color: #f87171;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 2px 9px;
  border-radius: 20px;
  margin-left: 8px;
}
.dash-clickable {
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.dash-clickable:hover { background: rgba(255, 255, 255, 0.04); }
.dash-row-overdue { box-shadow: inset 3px 0 0 #ef4444; }
.dash-date-overdue { color: #f87171 !important; font-weight: 700; }
.dash-activity-source { font-weight: 600; flex: 1 1 auto; min-width: 0; }

/* ── Report builder (ported from DataDesk) ───────────────────────── */
.nt-flag { display:inline-flex; align-items:center; gap:4px; font-size:12px; color:var(--text-secondary); white-space:nowrap; cursor:pointer; }
.nt-flag input { width:auto; margin:0; }
.report-controls { padding: 20px; max-width: 820px; width: 100%; box-sizing: border-box; }
.report-section { margin: 16px 0; }
.report-section > label { display:block; font-size:13px; font-weight:600; color:var(--text-secondary); margin-bottom:8px; }
.rb-checks { display:flex; flex-wrap:wrap; gap:10px; max-height:150px; overflow:auto; padding:10px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); }
.report-controls input, .report-controls select { max-width: 100%; min-width: 0; box-sizing: border-box; }
.rb-row { min-width: 0; flex-wrap: wrap; }
.rb-row > input, .rb-row > select { min-width: 0; box-sizing: border-box; }
.rb-row > .rb-fl-val, .rb-row > .rb-agg-col, .rb-row > .rb-fl-col { flex: 1 1 120px; }

/* ── Dashboard delivery/pickup calendar ──────────────────────────── */
.cal-head { display:flex; align-items:center; gap:16px; flex-wrap:wrap; margin-bottom:14px; }
.cal-head h3 { margin:0; }
.cal-nav { display:flex; align-items:center; gap:8px; }
.cal-month { font-weight:700; min-width:150px; text-align:center; }
.cal-legend { margin-left:auto; font-size:12px; color:var(--text-secondary); display:flex; align-items:center; gap:6px; }
.cal-dot { width:10px; height:10px; border-radius:3px; display:inline-block; }
.cal-dot.d { background:#2563eb; } .cal-dot.p { background:#d97706; margin-left:8px; } .cal-dot.t { background:#7c3aed; margin-left:8px; }
.cal-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:6px; }
.cal-dow { text-align:center; font-size:11px; font-weight:700; color:var(--text-muted); text-transform:uppercase; padding:4px 0; }
.cal-cell { min-height:74px; border:1px solid var(--border); border-radius:8px; padding:6px; cursor:pointer; transition:background .15s, border-color .15s; display:flex; flex-direction:column; gap:3px; overflow:hidden; }
.cal-cell:hover { border-color:var(--primary); }
.cal-cell.cal-out { opacity:0.4; }
.cal-cell.cal-today { box-shadow:inset 0 0 0 2px var(--primary); }
.cal-cell.cal-sel { background:var(--primary-subtle); border-color:var(--primary); }
.cal-num { font-size:12px; font-weight:600; color:var(--text-secondary); }
.cal-chip { font-size:10px; font-weight:700; color:#fff; border-radius:8px; padding:1px 6px; white-space:nowrap; align-self:flex-start; }
.cal-chip.d { background:#2563eb; } .cal-chip.p { background:#d97706; } .cal-chip.t { background:#7c3aed; }
.cal-day-head { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px; margin:18px 0 6px; padding-top:14px; border-top:1px solid var(--border); }
.cal-day-head h4 { margin:0; font-size:14px; }
.cal-item { display:flex; align-items:center; gap:12px; padding:9px 10px; border-bottom:1px solid var(--border-subtle); cursor:pointer; }
.cal-item:hover { background:var(--primary-subtle); }
.cal-tag { font-size:10px; font-weight:700; color:#fff; border-radius:10px; padding:2px 9px; flex-shrink:0; }
.cal-tag.d { background:#2563eb; } .cal-tag.p { background:#d97706; } .cal-tag.t { background:#7c3aed; }
.cal-item.cal-done .cal-item-cust { text-decoration:line-through; opacity:0.7; }
.cal-item-cust { font-weight:600; }
.cal-item-site { color:var(--text-secondary); font-size:13px; }
.cal-item-size { color:var(--text-muted); font-size:12px; }
.cal-item-ds { margin-left:auto; color:var(--text-muted); font-size:12px; white-space:nowrap; }
@media (max-width:640px){ .cal-cell{ min-height:54px; } .cal-item{ flex-wrap:wrap; gap:6px; } .cal-item-ds{ margin-left:0; } }

/* ── Query sharing (sidebar indicators + share modal) ─────────────── */
.query-badge { font-size:12px; opacity:0.8; margin:0 2px; flex:0 0 auto; }
.query-share {
  background:none; border:none; color:var(--text-muted); cursor:pointer;
  font-size:12px; padding:0 4px; flex:0 0 auto; opacity:0; transition:opacity var(--transition);
}
#queryList li:hover .query-share { opacity:0.7; }
.query-share:hover { opacity:1; }
.access-grid.disabled { opacity:0.4; pointer-events:none; }
.share-user .type-hint { margin-left:6px; color:var(--text-muted); font-size:12px; }

/* ── Activity log (admin tab) ─────────────────────────────────────── */
.nowrap { white-space:nowrap; }
.activity-toolbar {
  display:flex; flex-wrap:wrap; align-items:center; gap:8px;
  padding:12px 4px; margin-bottom:8px;
}
.activity-toolbar select, .activity-toolbar input[type="text"], .activity-toolbar input[type="date"] {
  background:var(--surface-solid); border:1px solid var(--border); color:var(--text);
  border-radius:var(--radius-sm); padding:6px 8px; font-size:13px; font-family:var(--font-sans);
}
.activity-toolbar input[type="text"] { min-width:200px; }
.activity-toolbar-spacer { flex:1 1 auto; }
.activity-table td { vertical-align:top; }
.activity-time { color:var(--text-secondary); font-size:12px; }
.activity-desc { color:var(--text); font-size:14px; line-height:1.4; }
.activity-sub { display:flex; align-items:center; gap:10px; margin-top:4px; }
.activity-sub .action-badge { font-size:10px; opacity:0.65; }
.activity-detail-link {
  background:none; border:none; padding:0; cursor:pointer;
  color:var(--text-muted); font-size:12px; text-decoration:underline;
}
.activity-detail-link:hover { color:var(--primary-hover); }
.activity-pager {
  display:flex; align-items:center; justify-content:center; gap:14px;
  padding:14px 4px; color:var(--text-secondary); font-size:13px;
}
.activity-detail-pre {
  background:var(--surface-solid); border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:14px; max-height:50vh; overflow:auto; font-family:var(--font-mono); font-size:12px;
  color:var(--text-secondary); white-space:pre-wrap; word-break:break-word;
}
.action-badge {
  display:inline-block; padding:2px 8px; border-radius:999px; font-size:11px; font-weight:600;
  font-family:var(--font-mono); white-space:nowrap;
  background:var(--surface-overlay); color:var(--text-secondary); border:1px solid var(--border);
}
.action-badge.action-auth     { color:#93c5fd; border-color:rgba(59,130,246,0.35); }
.action-badge.action-query    { color:#86efac; border-color:rgba(34,197,94,0.35); }
.action-badge.action-user     { color:#fca5a5; border-color:rgba(239,68,68,0.35); }
.action-badge.action-access   { color:#fcd34d; border-color:rgba(245,158,11,0.35); }
.action-badge.action-row      { color:#c4b5fd; border-color:rgba(139,92,246,0.35); }
.action-badge.action-settings { color:#a8a8b8; }
.action-badge.action-container    { color:#7dd3fc; border-color:rgba(56,189,248,0.35); }
.action-badge.action-delivery     { color:#fdba74; border-color:rgba(249,115,22,0.35); }
.action-badge.action-materials_out{ color:#5eead4; border-color:rgba(20,184,166,0.35); }
.action-badge.action-password { color:#fca5a5; border-color:rgba(239,68,68,0.35); }
.action-badge.action-activity { color:#5e5e70; }

/* ── Needs Attention board ──────────────────────────────────────────── */
.na-nav-btn { position: relative; }
.na-nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
  border-radius: 9px; background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
}
.na-total-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 7px; margin-left: 8px;
  border-radius: 12px; background: #ef4444; color: #fff;
  font-size: 13px; font-weight: 700; vertical-align: middle;
}
.na-threshold { display: inline-flex; align-items: center; gap: 6px; }
.na-threshold-label { font-size: 12px; color: var(--text-muted); }

.na-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin: 4px 0 24px;
}
.na-stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 14px 16px; border-radius: 12px; cursor: pointer; text-align: left;
  background: var(--card-bg, rgba(255,255,255,0.02));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-left: 3px solid var(--na-color);
  transition: transform .12s ease, box-shadow .12s ease;
}
.na-stat:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
.na-stat-zero { opacity: .5; cursor: default; }
.na-stat-icon { font-size: 15px; color: var(--na-color); }
.na-stat-num { font-size: 26px; font-weight: 800; color: var(--na-color); line-height: 1; }
.na-stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.na-section { margin-bottom: 28px; scroll-margin-top: 16px; }
.na-section-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding-bottom: 10px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}
.na-section-icon { color: var(--na-color); font-size: 16px; }
.na-section-head h3 { margin: 0; font-size: 16px; }
.na-section-count {
  display: inline-block; padding: 1px 8px; margin-left: 4px;
  border-radius: 10px; background: var(--na-color); color: #fff;
  font-size: 12px; font-weight: 700;
}
.na-section-desc { font-size: 12px; color: var(--text-muted); }

.na-card-reason {
  font-size: 12.5px; font-weight: 600;
  margin: 6px 0 2px; padding: 0 18px;
  overflow-wrap: anywhere;
}

.na-allclear { text-align: center; padding: 70px 20px; color: var(--text-muted); }
.na-allclear-check {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.35);
  color: #22c55e; font-size: 32px;
}
.na-allclear h3 { margin: 0 0 6px; color: var(--text, #e5e7eb); }

/* ── Fleet Availability board ────────────────────────────────────────── */
.fa-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin: 4px 0 18px;
}
.fa-stat {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px;
  border-radius: 12px; background: var(--surface, rgba(255,255,255,0.02));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-left: 3px solid var(--fa-color);
}
.fa-stat-num { font-size: 26px; font-weight: 800; color: var(--fa-color); line-height: 1; }
.fa-stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.fa-legend { display: flex; gap: 18px; margin: 0 0 20px; font-size: 12px; color: var(--text-muted); }
.fa-legend span { display: inline-flex; align-items: center; gap: 6px; }
.fa-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.fa-seg-avail { background: #22c55e; }
.fa-seg-out { background: #f59e0b; }
.fa-seg-other { background: #64748b; }

.fa-section-title { font-size: 14px; font-weight: 700; margin: 8px 0 12px; }
.fa-hint { font-weight: 400; font-size: 12px; color: var(--text-muted); }

.fa-sizes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
.fa-row {
  padding: 12px 16px; border-radius: 12px; cursor: pointer;
  background: var(--surface, rgba(255,255,255,0.02));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  transition: transform .12s ease, box-shadow .12s ease;
}
.fa-row:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,0.22); }
.fa-row-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 9px; }
.fa-size { font-size: 15px; font-weight: 700; min-width: 90px; }
.fa-free { font-size: 13px; color: var(--text-muted); }
.fa-free strong { color: #22c55e; font-size: 15px; }
.fa-free-none strong { color: var(--text-muted); }
.fa-pct { margin-left: auto; font-size: 12px; color: #f59e0b; font-weight: 600; }
.fa-bar {
  display: flex; height: 10px; border-radius: 5px; overflow: hidden;
  background: rgba(255,255,255,0.06);
}
.fa-bar-seg { height: 100%; }

.fa-yards { display: flex; flex-wrap: wrap; gap: 10px; }
.fa-yard-chip {
  padding: 8px 14px; border-radius: 20px; font-size: 13px;
  background: rgba(34,197,94,0.10); border: 1px solid rgba(34,197,94,0.28);
  color: var(--text, #e5e7eb);
}
.fa-yard-chip strong { color: #22c55e; }

/* ── Fleet: demand vs supply additions ──────────────────────────────── */
.fa-seg-spoken { background: #3b82f6; }
.fa-dot.fa-seg-spoken { background: #3b82f6; }
.fa-need { font-size: 13px; color: var(--text-muted); }
.fa-need strong { color: #ef4444; font-size: 15px; }
.fa-badge {
  margin-left: auto; padding: 2px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 700;
}
.fa-badge-short { background: rgba(239,68,68,0.14); color: #ef4444; border: 1px solid rgba(239,68,68,0.35); }
.fa-badge-ok { background: rgba(34,197,94,0.12); color: #22c55e; border: 1px solid rgba(34,197,94,0.30); }

.fa-sheets { display: flex; flex-direction: column; gap: 8px; margin-bottom: 26px; }
.fa-sheet {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-radius: 12px; cursor: pointer;
  background: var(--surface, rgba(255,255,255,0.02));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-left: 3px solid #ef4444;
  transition: transform .12s ease, box-shadow .12s ease;
}
.fa-sheet:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,0.22); }
.fa-sheet-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.fa-sheet-open {
  flex: none; width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(239,68,68,0.14); color: #ef4444; font-weight: 800; font-size: 15px;
}
.fa-sheet-info { min-width: 0; }
.fa-sheet-cust { font-size: 14px; font-weight: 600; }
.fa-sheet-ds { font-size: 11px; color: var(--text-muted); font-weight: 500; margin-left: 4px; }
.fa-sheet-sub { font-size: 12px; color: var(--text-muted); }
.fa-sheet-sizes {
  flex: none; font-size: 12.5px; font-weight: 600; color: var(--text, #e5e7eb);
  padding: 4px 10px; border-radius: 8px; background: rgba(255,255,255,0.05);
}
.fa-nodemand {
  padding: 18px 20px; border-radius: 12px; color: #22c55e; font-size: 13px;
  background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.22);
  margin-bottom: 26px;
}

/* ── Daily Dispatch board ────────────────────────────────────────────── */
.dp-datebar { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }
.dp-date { font-size: 16px; font-weight: 700; }
.dp-today {
  font-size: 11px; font-weight: 700; color: #22c55e; margin-left: 6px;
  padding: 1px 8px; border-radius: 10px; background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.30);
}
.dp-summary { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.dp-sum { font-size: 13px; color: var(--text-muted); padding: 6px 14px; border-radius: 10px; border: 1px solid var(--border, rgba(255,255,255,0.08)); }
.dp-sum strong { font-size: 16px; }
.dp-sum-del strong { color: #2563eb; }
.dp-sum-pick strong { color: #d97706; }

.dp-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.dp-section {
  border: 1px solid var(--border, rgba(255,255,255,0.08)); border-radius: 14px;
  border-top: 3px solid var(--dp-color); padding: 14px 16px 6px;
  background: var(--surface, rgba(255,255,255,0.02));
}
.dp-section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.dp-section-head h3 { margin: 0; font-size: 15px; }
.dp-count { display: inline-block; padding: 1px 8px; margin-left: 4px; border-radius: 10px; background: var(--dp-color); color: #fff; font-size: 12px; font-weight: 700; }
.dp-done-note { font-size: 12px; color: var(--text-muted); }

.dp-county-group { margin-bottom: 12px; }
.dp-county {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); padding: 4px 0 6px;
}
.dp-county-n { color: var(--dp-color); margin-left: 3px; }

.dp-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  cursor: pointer; transition: background .12s ease;
}
.dp-item:hover { background: rgba(255,255,255,0.05); }
.dp-check { flex: none; width: 18px; text-align: center; color: var(--dp-color); font-weight: 700; }
.dp-item-body { min-width: 0; flex: 1; }
.dp-item-cust { font-size: 14px; font-weight: 600; }
.dp-ds { font-size: 11px; color: var(--text-muted); font-weight: 500; margin-left: 4px; }
.dp-item-site { font-size: 12px; color: var(--text-muted); }
.dp-item-cont {
  flex: none; font-size: 12.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 8px; background: rgba(255,255,255,0.06);
}
.dp-item.dp-done { opacity: 0.5; }
.dp-item.dp-done .dp-item-cust { text-decoration: line-through; }
.dp-empty { color: var(--text-muted); font-size: 13px; padding: 14px 4px; }

/* ── Global Omnisearch (⌘K) ──────────────────────────────────────────── */
.omni-kbd, .omni-esc {
  font-family: inherit; font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 5px;
  background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.75);
}
.omni-overlay {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh; animation: omniFade .12s ease;
}
@keyframes omniFade { from { opacity: 0; } to { opacity: 1; } }
.omni-modal {
  width: min(620px, 92vw); max-height: 70vh; display: flex; flex-direction: column;
  background: var(--surface-solid, #1b1b22); color: var(--text, #e5e7eb);
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  overflow: hidden; animation: omniPop .12s ease;
}
@keyframes omniPop { from { transform: translateY(-8px); opacity: .6; } to { transform: none; opacity: 1; } }
.omni-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border, rgba(255,255,255,0.10)); }
.omni-ico { font-size: 18px; color: var(--text-muted); }
.omni-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text, #e5e7eb); font-size: 16px;
}
.omni-input::placeholder { color: var(--text-muted); }
.omni-results { overflow-y: auto; padding: 6px; }
.omni-hint { padding: 22px 16px; color: var(--text-muted); font-size: 13px; text-align: center; }
.omni-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: 10px; cursor: pointer;
}
.omni-item.active { background: rgba(255,255,255,0.08); }
.omni-item-ico { flex: none; width: 20px; text-align: center; font-size: 15px; }
.omni-item-body { flex: 1; min-width: 0; }
.omni-item-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.omni-item-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.omni-item-kind { flex: none; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; opacity: 0.85; }

/* ── Container bulk selection ────────────────────────────────────────── */
.btn.ct-select-on { background: rgba(59,130,246,0.18); border-color: rgba(59,130,246,0.5); color: #fff; }
.ct-card.ct-selectable { padding-left: 2px; }
.ct-card.ct-selectable:hover { border-color: var(--card-accent); }
.ct-card-check {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  width: 22px; height: 22px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08); border: 1.5px solid rgba(255,255,255,0.25);
  color: #fff; font-size: 13px; font-weight: 800;
}
.ct-card.ct-card-selected { outline: 2px solid #3b82f6; outline-offset: -2px; }
.ct-card.ct-card-selected .ct-card-check { background: #3b82f6; border-color: #3b82f6; }

.ct-bulk-bar {
  position: sticky; bottom: 14px; z-index: 30;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin: 18px auto 0; max-width: 820px; padding: 12px 18px;
  background: var(--surface-solid, #121216);
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 14px; box-shadow: 0 14px 40px rgba(0,0,0,0.45);
}
.ct-bulk-count { font-size: 14px; }
.ct-bulk-count strong { font-size: 18px; color: #3b82f6; }
.ct-bulk-actions { display: flex; gap: 16px; margin-left: auto; flex-wrap: wrap; }
.ct-bulk-actions.ct-bulk-disabled { opacity: 0.5; }
.ct-bulk-field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--text-muted); }
.ct-bulk-field select {
  background: var(--surface, rgba(255,255,255,0.04)); color: var(--text, #e5e7eb);
  border: 1px solid var(--border, rgba(255,255,255,0.15)); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; min-width: 130px;
}

/* ── Bulk pickup form ────────────────────────────────────────────────── */
.bp-note {
  padding: 10px 14px; margin-bottom: 12px; border-radius: 10px; font-size: 13px;
  background: rgba(245,158,11,0.10); border: 1px solid rgba(245,158,11,0.30); color: #f59e0b;
}
.bp-toolbar { display: flex; align-items: flex-end; gap: 20px; margin-bottom: 16px; flex-wrap: wrap; }
.bp-hint { font-size: 12px; color: var(--text-muted); max-width: 620px; }
.bp-field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-muted); }
.bp-input {
  background: var(--surface, rgba(255,255,255,0.04)); color: var(--text, #e5e7eb);
  border: 1px solid var(--border, rgba(255,255,255,0.15)); border-radius: 8px;
  padding: 7px 10px; font-size: 14px;
}
.bp-grid {
  border: 1px solid var(--border, rgba(255,255,255,0.08)); border-radius: 12px; overflow: hidden;
}
.bp-row {
  display: grid; grid-template-columns: 2.2fr 1fr 1.1fr 1.2fr 0.7fr 1.2fr;
  gap: 12px; align-items: center; padding: 12px 16px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
}
.bp-row:last-child { border-bottom: none; }
.bp-row.bp-head { background: rgba(255,255,255,0.03); font-size: 12px; color: var(--text-muted); font-weight: 600; }
.bp-head .bp-cell { padding: 0; }
.bp-cell-id .bp-serial { font-size: 15px; font-weight: 700; color: var(--text, #e5e7eb); }
.bp-cell-id .bp-meta { font-size: 12px; color: var(--text-muted); }
.bp-field-check { align-items: center; }
.bp-field-check input { width: 18px; height: 18px; }
.bp-field-empty { visibility: hidden; }
.bp-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
@media (max-width: 820px) {
  .bp-row { grid-template-columns: 1fr 1fr; }
  .bp-row.bp-head { display: none; }
  .bp-cell-id { grid-column: 1 / -1; }
}

/* ── Fleet: upcoming availability ────────────────────────────────────── */
.fa-next {
  margin-left: 4px; font-size: 12px; font-weight: 600; color: #14b8a6;
  padding: 2px 9px; border-radius: 10px;
  background: rgba(20,184,166,0.12); border: 1px solid rgba(20,184,166,0.30);
}
.fa-upcoming { display: flex; flex-direction: column; gap: 6px; margin-bottom: 26px; }
.fa-up {
  display: grid; grid-template-columns: 130px 70px 1fr 2fr; gap: 12px; align-items: center;
  padding: 9px 14px; border-radius: 10px; cursor: pointer;
  background: var(--surface, rgba(255,255,255,0.02));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-left: 3px solid #14b8a6;
  transition: transform .12s ease, box-shadow .12s ease;
}
.fa-up:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,0.22); }
.fa-up-when { font-size: 13px; font-weight: 700; color: #14b8a6; }
.fa-up-when.fa-up-overdue { color: #f59e0b; }
.fa-up-size { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.fa-up-serial { font-size: 14px; font-weight: 600; }
.fa-up-cust { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fa-noupcoming {
  padding: 16px 18px; border-radius: 12px; font-size: 13px; color: var(--text-muted);
  background: var(--surface, rgba(255,255,255,0.02)); border: 1px solid var(--border, rgba(255,255,255,0.08));
  margin-bottom: 26px;
}
@media (max-width: 720px) {
  .fa-up { grid-template-columns: 100px 1fr; }
  .fa-up-cust { grid-column: 1 / -1; }
}

/* ── Dispatch: driver-lane kanban ────────────────────────────────────── */
.dp-hint { font-size: 12px; color: var(--text-muted); }
.dp-lanes {
  display: flex; gap: 16px; overflow-x: auto; padding-bottom: 10px; align-items: stretch;
}
/* Lanes grow to fill the window (few drivers = wider columns); they hold a readable
   minimum and cap so 1–2 drivers don't stretch absurdly wide. Many drivers overflow
   into a horizontal scroll. */
.dp-lane {
  flex: 1 1 340px; min-width: 300px; max-width: 620px;
  background: var(--surface, rgba(255,255,255,0.02));
  border: 1px solid var(--border, rgba(255,255,255,0.08)); border-radius: 14px;
  display: flex; flex-direction: column; max-height: calc(100vh - 220px);
}
.dp-lane-unassigned { border-style: dashed; }
.dp-lane-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}
.dp-lane-name { font-weight: 700; font-size: 16px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-lane-count {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  background: rgba(255,255,255,0.06); border-radius: 10px; padding: 1px 8px;
}
.dp-lane-del {
  border: none; background: none; color: var(--text-muted); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 2px;
}
.dp-lane-del:hover { color: #ef4444; }
.dp-lane-body {
  padding: 12px; display: flex; flex-direction: column; gap: 11px;
  overflow-y: auto; flex: 1; min-height: 60px;
}
.dp-lane-body.dp-over { background: rgba(59,130,246,0.08); outline: 2px dashed rgba(59,130,246,0.5); outline-offset: -4px; border-radius: 10px; }
.dp-lane-empty { color: var(--text-muted); font-size: 12px; text-align: center; padding: 18px 6px; }

.dp-card {
  background: var(--surface-solid, #16161c);
  border: 1px solid var(--border, rgba(255,255,255,0.10)); border-radius: 12px;
  border-left: 3px solid var(--border, rgba(255,255,255,0.10));
  padding: 14px 16px; cursor: pointer; transition: box-shadow .12s ease, transform .12s ease;
}
.dp-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.25); }
.dp-card.dp-dragging { opacity: 0.5; }
.dp-card.dp-done { opacity: 0.55; }
/* Colour-code the card edge by task type for quick scanning */
.dp-card.dp-del { border-left-color: #2563eb; }
.dp-card.dp-pick { border-left-color: #d97706; }
.dp-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.dp-type { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; padding: 3px 9px; border-radius: 8px; }
.dp-t-del { color: #60a5fa; background: rgba(37,99,235,0.16); }
.dp-t-pick { color: #fbbf24; background: rgba(217,119,6,0.16); }
.dp-t-truck { color: #a78bfa; background: rgba(124,58,237,0.18); }
.dp-card.dp-custom { border-left-color: #7c3aed; cursor: pointer; }
.dp-done-btn {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 7px; padding: 4px 10px; cursor: pointer;
}
.dp-done-btn:hover { background: rgba(255,255,255,0.12); color: var(--text, #e5e7eb); }

/* Trucking task modal */
.tt-modal { max-width: 560px; width: 100%; }
.tt-modal .tt-leg {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
  color: #a78bfa; margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px solid rgba(124,58,237,0.35);
}
.tt-modal .tt-leg:first-child { margin-top: 0; }
.tt-modal .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tt-modal .form-row .form-group { min-width: 0; }
@media (max-width: 560px) { .tt-modal .form-row { grid-template-columns: 1fr; } }
.dp-card .dp-ds { font-size: 12px; color: var(--text-muted); }
.dp-done-tag { font-size: 11.5px; font-weight: 700; color: #22c55e; }
.dp-grip { margin-left: auto; color: var(--text-muted); font-size: 16px; letter-spacing: -2px; cursor: grab; padding: 2px 4px; }
.dp-card-cust { font-size: 17px; font-weight: 700; cursor: pointer; margin-bottom: 2px; }
.dp-card-cust:hover { text-decoration: underline; }
.dp-card.dp-done .dp-card-cust { text-decoration: line-through; }
.dp-card-sub { font-size: 13.5px; color: var(--text-muted); }
.dp-card-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.dp-card-cont {
  font-size: 13.5px; font-weight: 700; display: inline-block;
  padding: 4px 11px; border-radius: 8px; background: rgba(255,255,255,0.07);
}
.dp-mat {
  font-size: 12.5px; font-weight: 700; padding: 4px 11px; border-radius: 8px;
  border: 1px solid transparent;
}

.dp-lane-add { flex: 0 0 220px; min-width: 220px; max-width: 220px; border-style: dashed; align-self: flex-start; }
.dp-addform { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.dp-add-input {
  background: var(--surface, rgba(255,255,255,0.04)); color: var(--text, #e5e7eb);
  border: 1px solid var(--border, rgba(255,255,255,0.15)); border-radius: 8px; padding: 8px 10px; font-size: 13px;
}

/* ── Dispatch: SortableJS states + touch grip ────────────────────────── */
.dp-ghost { opacity: 0.4; background: rgba(59,130,246,0.12); }
.dp-chosen { box-shadow: 0 6px 20px rgba(0,0,0,0.4); }
.dp-grip {
  margin-left: auto; color: var(--text-muted); font-size: 15px; letter-spacing: -2px;
  cursor: grab; padding: 4px 8px; margin: -4px -6px -4px 0; border-radius: 6px;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.dp-grip:active { cursor: grabbing; background: rgba(255,255,255,0.08); }

/* ── Tap-to-assign chip on each card + the driver bottom sheet ──────────── */
.dp-assign {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto;
  font-size: 12.5px; font-weight: 700; color: var(--primary, #c41a1a);
  background: var(--primary-subtle, rgba(196,26,26,0.12)); border: 1px solid rgba(196,26,26,0.35);
  border-radius: 8px; padding: 6px 11px; cursor: pointer; line-height: 1;
}
.dp-assign:hover { background: rgba(196,26,26,0.22); color: var(--primary, #c41a1a); }
.dp-assign svg { flex: none; opacity: 0.8; }
.dp-assign-caret { opacity: 0.55; margin-left: -2px; }
/* Unassigned tasks get an amber nudge so they stand out as needing a driver */
.dp-assign.dp-assign-none { color: var(--warning, #f59e0b); border-color: rgba(245,158,11,0.4); background: rgba(245,158,11,0.10); }
.dp-custom .dp-assign { margin-left: 0; }

.dp-assign-modal { max-width: 420px; }
.dp-assign-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.dp-assign-list { display: flex; flex-direction: column; gap: 8px; }
.dp-assign-opt {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  text-align: left; padding: 13px 16px; border-radius: 10px; min-height: 48px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 600; cursor: pointer; transition: border-color .12s ease, background .12s ease;
}
.dp-assign-opt:hover { border-color: var(--primary); background: var(--primary-subtle); }
.dp-assign-opt.active { border-color: var(--primary); background: var(--primary-subtle); }
.dp-assign-check { color: var(--primary); font-weight: 800; }

/* On phones the assign control becomes a full-width bar at the bottom of the card
   so it's unmistakably tappable (not just a small chip beside the container info) */
@media (max-width: 768px) {
  .dp-assign {
    width: 100%; justify-content: center; margin-left: 0; margin-top: 6px;
    font-size: 14px; padding: 11px 14px; gap: 8px;
  }
  .dp-assign svg { width: 16px; height: 16px; }
  .dp-custom .dp-assign { margin-top: 6px; }
}

/* ── Dispatch: mobile / narrow-screen layout ─────────────────────────── */
@media (max-width: 768px) {
  .dp-page { padding: 0 2px; }
  .dp-datebar { flex-wrap: wrap; gap: 8px; }
  .dp-date { font-size: 15px; }
  .dp-summary { flex-wrap: wrap; gap: 8px; }
  /* Stack the lanes vertically instead of a wide horizontal scroll */
  .dp-lanes { flex-direction: column; overflow-x: visible; gap: 12px; }
  .dp-lane, .dp-lane-add {
    flex: 1 1 auto; min-width: 0; width: 100%; max-height: none;
  }
  .dp-lane-body { max-height: none; }
  .dp-lane-add { border-style: dashed; }
  /* Bigger touch targets */
  .dp-grip { font-size: 20px; padding: 8px 12px; }
  .dp-card { padding: 12px 14px; }
  .dp-card-cust { font-size: 15px; }
  .dp-lane-del { font-size: 22px; padding: 2px 8px; }
}

/* ── Live-update pop out (pairs with viewEnter for the pop-in) ────────── */
@keyframes viewLeave {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateY(-6px) scale(0.985); }
}
.view-leave { animation: viewLeave 0.15s ease-in both; }

/* Respect users who prefer reduced motion — disable the in/out transitions */
@media (prefers-reduced-motion: reduce) {
  .view-leave,
  .dashboard, .ct-page, .ct-detail, .di-page, .data-entry-page, .query-editor-wrapper, .welcome,
  .ct-grid .ct-card, .dash-summary .dash-stat-card,
  .data-table tr.row-pop-in {
    animation: none !important;
  }
}

/* ── Silent live-update: suppress every keyframe entrance in the re-rendered view
   (viewEnter, the card-rise stagger, etc.) so ONLY the changed items animate — those
   move/fade via JS transitions in playFlip(), which `animation:none` can't cancel. ── */
.no-anim, .no-anim * { animation: none !important; }

/* ── Dispatch: stacked (full-width) layout toggle ────────────────────── */
.dp-lanes.dp-stacked { flex-direction: column; overflow-x: visible; align-items: stretch; }
.dp-stacked .dp-lane {
  flex: 1 1 auto; min-width: 0; max-width: none; width: 100%; max-height: none;
}
.dp-stacked .dp-lane-body {
  max-height: none;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 11px; align-content: start;
}
.dp-stacked .dp-lane-empty { grid-column: 1 / -1; }
.dp-stacked .dp-lane-add {
  flex: 0 0 auto; width: 100%; max-width: none; align-self: stretch;
}
.dp-stacked .dp-lane-add .dp-addform { max-width: 340px; }

/* ── Omnisearch: delivery-sheet status badge ─────────────────────────── */
.omni-status {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 1px 7px; border-radius: 8px; margin-left: 8px; vertical-align: middle;
}
.omni-st-active { color: #22c55e; background: rgba(34,197,94,0.16); }
.omni-st-completed { color: #94a3b8; background: rgba(148,163,184,0.16); }
.omni-st-unassigned { color: #f59e0b; background: rgba(245,158,11,0.16); }
.omni-item.omni-dim .omni-item-title,
.omni-item.omni-dim .omni-item-ico { opacity: 0.6; }

/* ── Dispatch: overdue (rolled-over) task indicator ──────────────────── */
.dp-card.dp-late { border-color: #ef4444; background: rgba(239,68,68,0.06); }
.dp-card.dp-late.dp-del, .dp-card.dp-late.dp-pick { border-left-color: #ef4444; }
.dp-late-tag {
  font-size: 11px; font-weight: 800; color: #fff; background: #ef4444;
  padding: 2px 8px; border-radius: 8px; text-transform: uppercase; letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════════════════════════
   COMPACT ICON RAIL (sidebar)
   ═══════════════════════════════════════════════════════════════════ */
.sidebar.rail { align-items: center; padding: 10px 0; gap: 2px; z-index: 60; }
.rail-brand { padding: 4px 0 10px; }
.rail-logo { width: 34px; height: 34px; object-fit: contain; border-radius: 8px; }
.rail-nav { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; width: 100%; }
.rail-foot { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 100%; padding-top: 8px; }
.rail-div { width: 30px; height: 1px; background: rgba(255,255,255,0.12); margin: 6px 0; }
.rail-group-label {
  font-size: 8.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(255,255,255,0.3); margin: 2px 0 1px;
}
.rail-item {
  position: relative; width: 42px; height: 42px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: rgba(255,255,255,0.72);
  cursor: pointer; transition: background .14s ease, color .14s ease, transform .1s ease;
}
.rail-item:hover { background: rgba(255,255,255,0.09); color: #fff; }
.rail-item:active { transform: scale(0.94); }
.rail-item.rail-active { background: rgba(196,26,26,0.18); color: #fff; box-shadow: inset 0 0 0 1px rgba(196,26,26,0.5); }
.rail-ico { width: 20px; height: 20px; display: block; }
.rail-item .rail-ico { transition: transform .1s ease; }
.rail-item:active .rail-ico { transform: scale(0.9); }
.rail-badge {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: #ef4444; color: #fff; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
/* Hover label tooltip (to the right of the rail) */
.rail-item[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  white-space: nowrap; background: #1b1b22; color: #fff; font-size: 12.5px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none; transition: opacity .12s ease; z-index: 200;
}
.rail-item[data-tip]:hover::after { opacity: 1; }

/* Flyout panels for Tables / Saved Queries */
.rail-flyout {
  position: fixed; left: 64px; top: 0; height: 100vh; width: 250px; z-index: 55;
  background: var(--surface-solid, #121216); border-right: 1px solid var(--border, rgba(255,255,255,0.08));
  box-shadow: 8px 0 28px rgba(0,0,0,0.45);
  display: none; flex-direction: column; padding: 14px 0;
}
.rail-flyout.open { display: flex; animation: railFlyIn .14s ease; }
@keyframes railFlyIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.rail-flyout-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 16px 12px; font-size: 14px; font-weight: 700; color: #fff;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08)); margin-bottom: 6px;
}
.rail-flyout .table-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.rail-flyout .table-list li {
  padding: 8px 16px; font-size: 13px; color: rgba(255,255,255,0.82); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-flyout .table-list li:hover { background: rgba(255,255,255,0.06); color: #fff; }
.rail-flyout .table-list li.active { background: rgba(196,26,26,0.18); color: #fff; }
.rail-empty { color: rgba(255,255,255,0.4) !important; cursor: default !important; }

/* Mobile: rail slides in like the old sidebar */
@media (max-width: 768px) {
  .main { max-width: 100vw; }
  .rail-flyout { left: 64px; }
}

/* ── Brand mark: bold red minimalist "C" (replaces the logo image) ───── */
.brand-c {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 11px;
  font-family: "Inter", system-ui, sans-serif; font-weight: 800; font-size: 26px;
  color: #ef2b2b; letter-spacing: -1px; line-height: 1;
  background: rgba(239,43,43,0.10); border: 1px solid rgba(239,43,43,0.28);
}
.brand-c-sm { width: 30px; height: 30px; font-size: 20px; border-radius: 8px; }

/* ═══════════════════════════════════════════════════════════════════
   LIGHT THEME  — flips the main content; the branded rail stays dark.
   ═══════════════════════════════════════════════════════════════════ */
html[data-theme="light"] {
  --bg: #eef0f4;
  --surface: #ffffff;
  --surface-solid: #ffffff;
  --surface-raised: #f6f7f9;
  --surface-overlay: #ffffff;
  --border: rgba(0, 0, 0, 0.12);
  --border-subtle: rgba(0, 0, 0, 0.06);
  --text: #17171d;
  --text-secondary: #45454f;
  --text-muted: #6d6d80;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.10), 0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.20), 0 4px 12px rgba(0, 0, 0, 0.10);
}
html[data-theme="light"] body { background: var(--bg); color: var(--text); }
html[data-theme="light"] .main { background: var(--bg); }
/* The rail and its flyouts are a branded dark surface in both themes */
html[data-theme="light"] .rail-flyout { background: #15151b; }
/* Common light-mode fixes for main-content patterns that hardcode white overlays */
html[data-theme="light"] .main .data-table th { color: #fff; }               /* red table headers keep white text */
html[data-theme="light"] .toast { color: #fff; }

/* ── Light mode: form controls (were hardcoded near-black → grey on white) ── */
html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select,
html[data-theme="light"] .sort-select,
html[data-theme="light"] .di-money-input {
  background: #ffffff !important;
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="light"] input:focus,
html[data-theme="light"] textarea:focus,
html[data-theme="light"] select:focus {
  background: #ffffff !important;
  border-color: var(--primary);
}
html[data-theme="light"] select option,
html[data-theme="light"] .sort-select option { background: #ffffff; color: var(--text); }
html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder { color: var(--text-muted); }

/* ── Light mode: surfaces that hardcoded a dark background ── */
html[data-theme="light"] .table-wrapper,
html[data-theme="light"] .modal,
html[data-theme="light"] .modal-body,
html[data-theme="light"] .query-editor-wrapper,
html[data-theme="light"] .di-page,
html[data-theme="light"] .di-section,
html[data-theme="light"] .mo-table-wrap,
html[data-theme="light"] .di-money-input,
html[data-theme="light"] .di-container-slot {
  background: var(--surface);
  color: var(--text);
}
html[data-theme="light"] .modal-overlay { background: rgba(0, 0, 0, 0.4); }
/* Zebra-striped / hover table rows */
html[data-theme="light"] .data-table tbody tr:nth-child(even) td { background: rgba(0, 0, 0, 0.02); }
html[data-theme="light"] .data-table tbody tr:hover td { background: rgba(0, 0, 0, 0.04); }
/* Ghost buttons in the main content read on light */
html[data-theme="light"] .main .btn-ghost { color: var(--text); border-color: var(--border); }
html[data-theme="light"] .main .btn-ghost:hover { background: rgba(0, 0, 0, 0.05); }

/* ── My Account / Profile panel ──────────────────────────────────────── */
.pf-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px 22px; margin-bottom: 16px;
}
.pf-user { display: flex; align-items: center; gap: 14px; }
.pf-avatar {
  width: 52px; height: 52px; border-radius: 14px; flex: none;
  background: var(--primary); color: #fff; font-size: 22px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.pf-name { font-size: 18px; font-weight: 700; }
.pf-role { font-size: 13px; color: var(--text-muted); }
.pf-section-title { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.pf-hint { font-size: 12.5px; color: var(--text-muted); margin: 0 0 14px; }
.pf-theme { display: flex; gap: 10px; flex-wrap: wrap; }
.pf-theme-opt {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  width: 100px; padding: 15px 10px; border-radius: 12px;
  background: var(--surface-raised); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 13px; font-weight: 600;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
.pf-theme-opt:hover { border-color: var(--primary); }
.pf-theme-opt.active { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: var(--primary-subtle); }
.pf-theme-ico { font-size: 22px; line-height: 1; }

/* ── Edit delivery sheet: container slots ────────────────────────────── */
.eds-slot {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin-bottom: 6px;
  border-radius: 10px; background: var(--surface-raised, rgba(255,255,255,0.03));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
}
.eds-slot-size { font-weight: 700; font-size: 13px; min-width: 56px; }
.eds-slot-info { flex: 1; font-size: 13px; color: var(--text-secondary); }
.eds-slot-info .eds-open { color: var(--warning, #f59e0b); font-weight: 600; }
.eds-slot-note { font-size: 11.5px; color: var(--text-muted); }
.eds-empty { color: var(--text-muted); font-size: 13px; padding: 8px 2px; }
.eds-slot-billing { font-size: 12px; max-width: 210px; }

/* Billing-mode field hint (delivery sheet forms) */
.di-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; line-height: 1.35; }

/* ── Billing worksheet (sheet detail) ─────────────────────────────────── */
.bill-head { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.bill-head h3 { margin:0; }
.bill-mode-badge { font-size:11px; font-weight:700; padding:3px 9px; border-radius:8px; text-transform:uppercase; letter-spacing:0.03em; }
.bill-mode-badge.bill-perLoad { color:#a78bfa; background:rgba(124,58,237,0.16); }
.bill-mode-badge.bill-atEnd { color:#38bdf8; background:rgba(2,132,199,0.16); }
.bill-mode-badge.bill-flatRate { color:#fbbf24; background:rgba(217,119,6,0.16); }

/* ── Add-on fees ─────────────────────────────────────────────────────── */
.fee-editor { display:flex; flex-direction:column; gap:6px; }
.fee-line { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.fee-line .fee-label { flex:1; min-width:140px; padding:6px 8px; }
.fee-line .fee-qty { width:70px; padding:6px 8px; text-align:right; }
.fee-x { color:var(--text-muted); font-size:12px; }
.fee-money { display:flex; align-items:center; gap:2px; }
.fee-money > span { color:var(--text-muted); font-size:12px; }
.fee-money > input { width:90px; padding:6px 8px; text-align:right; }
.fee-line-total { min-width:74px; text-align:right; font-weight:700; font-variant-numeric:tabular-nums; }
.fee-del {
  border:none; background:transparent; color:var(--danger-hover); cursor:pointer;
  font-size:18px; line-height:1; padding:2px 7px; border-radius:6px;
}
.fee-del:hover { background:rgba(220,38,38,0.12); }
.fee-add-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.fee-picker { padding:6px 8px; min-width:210px; }
.fee-total { font-size:13px; color:var(--text-muted); margin-left:auto; }
.fee-total strong { color:var(--text-primary); font-variant-numeric:tabular-nums; }

.tw-fee-btn.has-fees { color:#fbbf24; font-weight:700; }
.tw-fees-row > td { background:var(--bg-subtle, rgba(127,127,127,0.06)); padding:10px 12px !important; }

.bill-fees { margin-top:16px; padding-top:12px; border-top:1px solid var(--border-color, rgba(127,127,127,0.25)); }
.bill-fee {
  display:grid; grid-template-columns:1fr auto auto auto 28px;
  gap:10px; align-items:center; padding:5px 0; font-size:13px;
}
.bill-fee + .bill-fee { border-top:1px dashed rgba(127,127,127,0.2); }
.bill-fee-done { opacity:0.55; }
.bill-fee-calc, .bill-fee-where { color:var(--text-muted); font-size:12px; }
.bill-fee-amt { font-weight:700; font-variant-numeric:tabular-nums; }
.bill-fee-inv { color:#22c55e; font-size:12px; white-space:nowrap; }
.bill-load-fees { color:#fbbf24; font-size:12px; white-space:nowrap; }
.rti-fee-note { display:block; font-size:11px; color:var(--text-muted); font-weight:400; }
.bill-invoiced { display:flex; align-items:center; gap:10px; background:rgba(34,197,94,0.12); border:1px solid rgba(34,197,94,0.3); color:#22c55e; font-size:13px; font-weight:600; padding:8px 12px; border-radius:8px; margin-bottom:12px; }
.bill-cols { display:grid; grid-template-columns:1fr 1.2fr; gap:22px; }
@media (max-width:720px){ .bill-cols { grid-template-columns:1fr; } }
.bill-subhead { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:0.04em; color:var(--text-muted); margin-bottom:8px; }
.bill-line { display:flex; justify-content:space-between; gap:12px; font-size:13.5px; padding:4px 0; border-bottom:1px solid var(--border-subtle,rgba(255,255,255,0.05)); }
.bill-line.bill-muted, .bill-muted { color:var(--text-muted); font-size:12.5px; }
.bill-line.bill-total { border-bottom:none; border-top:2px solid var(--border,rgba(255,255,255,0.15)); margin-top:4px; padding-top:8px; font-size:15px; }
.bill-load { display:grid; grid-template-columns:auto 1fr auto auto; gap:10px; align-items:center; font-size:13px; padding:6px 0; border-bottom:1px solid var(--border-subtle,rgba(255,255,255,0.05)); flex-wrap:wrap; }
.bill-load-done { opacity:0.6; }
.bill-load-date { color:var(--text-muted); font-size:12px; }
.bill-load-wt { color:var(--text-secondary); font-size:12px; }
.bill-load-amt { font-weight:600; text-align:right; }
.bill-load-line { grid-column:1/-1; font-size:12px; color:var(--text-secondary); display:flex; gap:8px; align-items:center; justify-content:flex-end; flex-wrap:wrap; }
.bill-load-inv { color:#22c55e; font-size:12px; }
.bill-sum { margin-top:16px; max-width:420px; margin-left:auto; }
.bill-note { font-size:11.5px; color:var(--text-muted); margin-top:10px; line-height:1.4; }
.bill-actions { margin-top:12px; display:flex; justify-content:flex-end; }
.btn-linky { background:none; border:none; color:var(--primary,#c41a1a); cursor:pointer; font-size:12px; text-decoration:underline; padding:0; }
.bill-cust-defaults { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:12px; padding:8px 10px; border:1px dashed var(--border,rgba(255,255,255,0.14)); border-radius:8px; }
.bill-cust-defaults select { font-size:12px; max-width:230px; }

/* ── Ready to Invoice worklist ────────────────────────────────────────── */
.rti-intro { color:var(--text-muted); font-size:13px; margin:-4px 0 18px; }
.rti-grand { font-weight:700; color:#22c55e; font-size:14px; }
.rti-sec { margin-bottom:22px; background:var(--surface-raised,rgba(255,255,255,0.02)); border:1px solid var(--border,rgba(255,255,255,0.08)); border-radius:12px; overflow:hidden; }
.rti-sec-head { font-size:13px; font-weight:700; padding:11px 14px; background:rgba(255,255,255,0.03); border-bottom:1px solid var(--border,rgba(255,255,255,0.08)); display:flex; align-items:center; gap:8px; }
.rti-sec-head span { margin-left:auto; background:var(--primary-subtle,rgba(196,26,26,0.15)); color:var(--primary,#c41a1a); border-radius:20px; padding:1px 10px; font-size:12px; }
.rti-cols, .rti-row { display:grid; grid-template-columns:1.3fr 0.55fr 0.95fr 0.8fr 0.7fr 1.9fr 1fr 130px; gap:16px; align-items:center; padding:9px 14px; font-size:13px; }
.rti-cols > *, .rti-row > * { min-width:0; }
.rti-breakdown { font-size:12px; color:var(--text-secondary); white-space:nowrap; }
.rti-head { font-size:11px; text-transform:uppercase; letter-spacing:0.03em; color:var(--text-muted); border-bottom:1px solid var(--border-subtle,rgba(255,255,255,0.05)); }
.rti-row { border-bottom:1px solid var(--border-subtle,rgba(255,255,255,0.05)); cursor:default; }
.rti-row[onclick] { cursor:pointer; }
.rti-row[onclick]:hover { background:var(--primary-subtle,rgba(196,26,26,0.06)); }
.rti-row.rti-stmt { grid-template-columns:1.5fr 1.6fr 0.9fr 1fr 230px; }
.rti-cols.rti-direct, .rti-row.rti-direct { grid-template-columns:1.6fr 1fr 0.9fr 0.8fr 1fr 150px; }

/* ── Customer Loads page ──────────────────────────────────────────────── */
.cl-tabs { display:flex; gap:6px; margin:0 0 14px; flex-wrap:wrap; }
.cl-tab { font-size:13px; padding:6px 14px; border-radius:8px; border:1px solid var(--border,rgba(255,255,255,0.12)); background:transparent; color:var(--text-secondary); cursor:pointer; }
.cl-tab.active { background:var(--primary,#c41a1a); color:#fff; border-color:var(--primary,#c41a1a); }
.cl-controls { display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin:0 0 14px; }
.cl-search { flex:1; min-width:220px; font-size:13px; padding:8px 12px; }
.cl-filt { display:inline-flex; align-items:center; gap:6px; font-size:12.5px; color:var(--text-secondary); }
.cl-filt input { font-size:12.5px; padding:5px 8px; }
.cl-count { font-size:12px; color:var(--text-muted); margin-left:auto; }
.cl-cols, .cl-row { display:grid; grid-template-columns:96px minmax(120px,1.5fr) minmax(70px,0.9fr) 72px 90px 100px 140px 150px; gap:10px; align-items:center; padding:9px 14px; font-size:13px; }
.cl-cols > *, .cl-row > * { min-width:0; }
.cl-head { font-size:11px; text-transform:uppercase; letter-spacing:0.03em; color:var(--text-muted); border-bottom:1px solid var(--border-subtle,rgba(255,255,255,0.05)); }
.cl-row { border-bottom:1px solid var(--border-subtle,rgba(255,255,255,0.05)); }
.cl-row-done { opacity:0.65; }
.cl-cust { font-weight:600; }
.cl-addr { display:block; font-weight:400; font-size:11.5px; color:var(--text-muted); }
.cl-mat { color:var(--primary,#c41a1a); font-weight:600; }
.cl-date, .cl-county { color:var(--text-secondary); }
.cl-amt { text-align:right; }
.cl-check { display:inline-flex; align-items:center; gap:6px; font-size:12px; color:var(--text-secondary); cursor:pointer; }
.cl-status { font-size:11.5px; font-weight:600; }
.cl-status.cl-ready { color:#f59e0b; }
.cl-status.cl-inv { color:#22c55e; }
.cl-status.cl-paid { color:var(--text-muted); }
.cl-actions { display:flex; gap:6px; justify-content:flex-end; align-items:center; }
.be-billable-toggle { display:flex; gap:9px; align-items:flex-start; margin:10px 0 6px; font-size:12.5px; color:var(--text-secondary); cursor:pointer; }
.be-billable-toggle input { margin-top:2px; }
/* ── Customer Loads: stack the 8-column grid rows into labelled cards on phones ── */
@media (max-width: 768px) {
  .cl-cols.cl-head { display: none; }                   /* column headers not needed in card mode */
  .cl-row {
    display: block; grid-template-columns: none;
    padding: 12px 14px 14px; gap: 0;
  }
  .cl-row > span {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 14px; padding: 4px 0; text-align: right; white-space: normal; word-break: break-word;
  }
  .cl-row > [data-l]::before {
    content: attr(data-l); color: var(--text-muted); font-size: 12px;
    font-weight: 600; text-align: left; white-space: nowrap; flex: none;
  }
  /* Customer becomes the card heading — full width, no label */
  .cl-row > .cl-cust {
    display: block; text-align: left; font-size: 15.5px; font-weight: 700;
    margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  }
  .cl-row > .cl-cust .cl-addr { font-weight: 400; }
  .cl-row > .cl-billable { justify-content: flex-start; }
  .cl-row > span:empty { display: none; }
  /* Action buttons go full-width at the bottom of the card */
  .cl-row > .cl-actions { justify-content: stretch; margin-top: 8px; }
  .cl-row > .cl-actions .btn { flex: 1; }
}
.rti-cust { font-weight:600; }
.rti-sheet, .rti-date, .rti-site { color:var(--text-secondary); }
.rti-amt { text-align:right; }
.rti-due { font-weight:700; }
.rti-dep { color:var(--text-muted); }
.rti-empty { color:var(--text-muted); font-size:13px; padding:14px; text-align:center; }

/* ── Ready to Invoice: stack the dense grid rows into labelled cards on phones ── */
@media (max-width: 768px) {
  .rti-cols.rti-head { display: none; }                 /* column headers not needed in card mode */
  .rti-row, .rti-row.rti-stmt, .rti-row.rti-direct {
    display: block; grid-template-columns: none;
    padding: 12px 14px 14px; gap: 0;
  }
  /* Each value on its own line as label : value */
  .rti-row > span, .rti-row > button, .rti-row > div {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 14px; padding: 4px 0; text-align: right; white-space: normal; word-break: break-word;
  }
  .rti-row > [data-l]::before {
    content: attr(data-l); color: var(--text-muted); font-size: 12px;
    font-weight: 600; text-align: left; white-space: nowrap; flex: none;
  }
  .rti-breakdown { white-space: normal; }
  /* Customer becomes the card heading — full width, no label */
  .rti-row > .rti-cust {
    display: block; text-align: left; font-size: 15.5px; font-weight: 700;
    margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  }
  .rti-row > .rti-cust .cl-addr { font-weight: 400; }
  /* Empty placeholder cells (viewer mode) collapse away */
  .rti-row > span:empty { display: none; }
  /* Action buttons go full-width at the bottom of the card */
  .rti-row > .btn { width: 100%; justify-content: center; margin-top: 8px; }
  .rti-row > span[style*="flex"] { margin-top: 8px; }
  .rti-row > span[style*="flex"] .btn { flex: 1; }
}
.eds-add {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px;
  padding-top: 12px; border-top: 1px dashed var(--border, rgba(255,255,255,0.10));
}

/* ── Demo delivery sheet + landfill load form ────────────────────────── */
.eds-demo-toggle { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; color: var(--text); }
.eds-demo-toggle input { width: 18px; height: 18px; margin-top: 1px; flex: none; }
.ds-demo-badge {
  font-size: 11px; font-weight: 800; letter-spacing: 0.05em; color: #fff;
  background: #8b5cf6; padding: 3px 10px; border-radius: 8px; margin-left: 8px;
}
.ll-modal { width: min(600px, 94vw); }
.ll-transport { display: flex; gap: 10px; }
.ll-tt {
  flex: 1; padding: 13px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-raised); color: var(--text); cursor: pointer; font-weight: 600; font-size: 14px;
  transition: border-color .12s ease, background .12s ease;
}
.ll-tt.active { border-color: var(--primary); background: var(--primary-subtle); box-shadow: inset 0 0 0 1px var(--primary); }
.ll-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

/* ── Mobile: the icon rail becomes a slide-in drawer (tap ☰) with labels ──
   Content stays full-width; the drawer overlays and scrolls when opened. The
   z-index must sit ABOVE the overlay (1050) — that was the earlier bug. ── */
@media (max-width: 768px) {
  .sidebar.rail {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 214px; height: 100%;
    transform: translateX(-100%);
    z-index: 1100;
    overflow-y: auto; overflow-x: hidden;
    align-items: stretch; padding: 14px 10px;
  }
  .sidebar.rail.open { transform: translateX(0); }
  .sidebar.rail .sidebar-close { display: none; }
  .sidebar.rail .rail-nav, .sidebar.rail .rail-foot { align-items: stretch; width: 100%; }
  .sidebar.rail .rail-item {
    width: 100%; height: auto; justify-content: flex-start; gap: 14px; padding: 11px 12px;
  }
  /* Show each icon's label (from data-tip) inline in the drawer */
  .sidebar.rail .rail-item[data-tip]::after {
    content: attr(data-tip);
    position: static; transform: none; opacity: 1; pointer-events: auto;
    background: none; border: none; box-shadow: none; padding: 0; z-index: auto;
    color: inherit; font-size: 14px; font-weight: 600; white-space: nowrap;
  }
  .sidebar.rail .rail-badge { position: static; margin-left: auto; }
  .sidebar.rail .rail-div { width: 100%; }
  .sidebar.rail .rail-brand { align-self: flex-start; padding: 2px 8px 10px; }
  .rail-flyout { left: 214px; width: calc(100vw - 214px); z-index: 1090; }
  .main { max-width: 100vw; }
}

/* ══ Stage 2: global mobile shell — notch/safe-area, scroll & touch polish ══
   Makes the installed PWA behave like a native app: content clears the notch and
   home indicator, no rubber-band page bounce, no blue tap-flash, and the page
   behind the open drawer is locked so only the drawer scrolls. ── */
@media (max-width: 768px) {
  * { -webkit-tap-highlight-color: transparent; }
  html, body { max-width: 100%; overflow-x: hidden; }
  body { overscroll-behavior-y: none; }
  body.drawer-open { overflow: hidden; }

  /* Header clears the status bar / notch (viewport-fit=cover, translucent bar) */
  .mobile-header {
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }
  /* Drawer clears the notch (top) and the home indicator (bottom) */
  .sidebar.rail {
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    padding-left: calc(10px + env(safe-area-inset-left));
    -webkit-overflow-scrolling: touch;
  }
  /* Main content clears side notches (landscape) + the home indicator, and uses
     dynamic viewport height so it doesn't jump as the address bar shows/hides */
  .main {
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    min-height: calc(100dvh - 52px);
  }
}

/* ══ Stage 3 fix: kill horizontal overflow of inputs & button rows on phones ══
   On mobile .main's overflow-y is visible, which makes overflow-x compute to
   auto — so any element a hair too wide turns the whole screen into a sideways
   scroller. We clip at the content edge as a hard backstop, and make the usual
   offenders (button rows, text inputs) wrap/shrink so nothing gets cut off. ── */
@media (max-width: 768px) {
  .main { overflow-x: clip; }

  /* Text fields, selects and textareas never exceed their container (min-width:0
     defeats the intrinsic min-width iOS gives date/number inputs) */
  input, textarea, select { max-width: 100%; min-width: 0; }

  /* Action/toolbar button rows wrap into a tidy grid instead of running off-screen */
  .ct-header-actions, .ct-header, .toolbar { flex-wrap: wrap; }
  .ct-header-actions { width: 100%; }
  .ct-header-actions .btn { flex: 1 1 auto; }        /* fill the row + thumb-friendly */
  .ct-header-actions > *, .toolbar > * { min-width: 0; }  /* allow flex children to shrink */
}

/* ── NYS Annual Report ─────────────────────────────────────────────── */
.nys-grid { display: flex; gap: 16px; flex-wrap: wrap; margin: 4px 0 18px; }
.nys-field { flex: 1 1 260px; }
.nys-field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.nys-field input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text); font-size: 14px;
}
.nys-field input:disabled { opacity: .6; }
.nys-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.nys-table th, .nys-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.nys-table thead th { font-size: 12px; color: var(--text-muted); text-align: left; text-transform: uppercase; letter-spacing: .4px; }
.nys-table tfoot td { border-top: 2px solid var(--border); border-bottom: none; }
.nys-review {
  border: 1px solid #b45309; background: rgba(180, 83, 9, .12); color: var(--text);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 14px; font-size: 13px; line-height: 1.5;
}
.nys-review ul { margin: 6px 0 4px 18px; }
.nys-ok {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  border-radius: 10px; padding: 10px 16px; margin-bottom: 14px; font-size: 13px;
}
/* ── Version badge (sidebar footer) + admin about ──────────────────── */
.rail-version { font-size: 9px; color: var(--text-muted); text-align: center; padding: 4px 0 2px; cursor: pointer; letter-spacing: 0.3px; line-height: 1.3; }
.rail-version:hover { color: var(--text-secondary); }
.rail-version .up { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--warning); margin-left: 3px; vertical-align: middle; }
.admin-about { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); margin: -4px 0 14px; }
.admin-about .ver { font-weight: 700; color: var(--text); }
.admin-about .badge { padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.admin-about .badge.ok { background: var(--success-subtle); color: var(--success); }
.admin-about .badge.up { background: var(--warning-subtle); color: var(--warning); }

/* ── Admin material catalog ────────────────────────────────────────── */
.mc-table { width: 100%; border-collapse: collapse; }
.mc-table th, .mc-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.mc-table thead th { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.mc-table input[type="text"], .mc-table select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 13px; }
/* Inline status/result messages (connection test, settings save, password) — theme-aware. */
.status-msg { padding: 12px 14px; border-radius: var(--radius); font-weight: 500; font-size: 14px; border: 1px solid transparent; }
.status-msg.ok  { background: var(--success-subtle); border-color: rgba(34, 197, 94, 0.35); color: var(--success); }
.status-msg.err { background: var(--danger-subtle);  border-color: rgba(239, 68, 68, 0.35); color: var(--danger); }

.bk-status { display: flex; flex-wrap: wrap; gap: 10px 28px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.bk-status > div { display: flex; flex-direction: column; gap: 2px; }
.bk-status .bk-k { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.bk-status .bk-v { font-size: 14px; font-weight: 600; }
.mc-add { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 4px; }
.mc-add input, .mc-add select { border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }

.nys-note { color: var(--text-muted); font-size: 12px; line-height: 1.5; max-width: 900px; margin-bottom: 6px; }
.nys-note .yard-key { color: #c0394b; font-weight: 600; }
.crc-h3 { font-size: 15px; margin: 22px 0 8px; color: var(--text); }
.crc-scroll { overflow-x: auto; margin-bottom: 6px; }
.crc-grid { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.crc-grid th, .crc-grid td { border: 1px solid var(--border); padding: 5px 9px; text-align: right; white-space: nowrap; }
.crc-grid thead th { background: var(--surface-2, rgba(127,127,127,.12)); color: var(--text-muted); font-size: 11px; position: sticky; top: 0; }
.crc-grid td.lbl, .crc-grid th.lbl { text-align: left; font-weight: 600; }
.crc-grid td.lbl.yard { color: #c0394b; }
.crc-grid .hl { background: rgba(214, 158, 46, .14); font-weight: 600; }
.crc-grid tfoot td { font-weight: 700; border-top: 2px solid var(--border); background: var(--surface-2, rgba(127,127,127,.10)); }
.crc-permit { min-width: 720px; }
