/* ── MODALS & MOBILE OVERRIDES ──
   Phase 12E: extracted verbatim from components.css lines 760-1186 (no rule changes).
   Cascade order preserved exactly: stylesheet links in index.html load these files
   in the original source order. Contents: mobile-responsive block (icon-only header buttons, mobile status badge, filter chip sizing, toast, full-screen modals, analytics stack), settings-modal mobile layout, audit log modal, WH selector, modal attachment section, upload button group, inline cell editing, full-screen attachment panel, lightbox */

/* ── MOBILE RESPONSIVE ── max-width: 768px ──────────────────────────────── */
@media (max-width: 768px) {

  /* ── Change 1: Icon-only header buttons ──────────────────────────────── */
  .header-controls .btn {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 0 !important;   /* hides text; ::before re-injects emoji */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  /* Inject icon via ::before; explicit font-size overrides the inherited 0 */
  #btn-doors::before     { content: '🚪'; font-size: 1.1rem; }
  #btn-reports::before   { content: '📊'; font-size: 1.1rem; }
  #btn-settings::before  { content: '⚙';  font-size: 1.1rem; }
  #btn-logout::before    { content: '🔓'; font-size: 1rem;   }

  /* Login keeps its text label */
  #btn-login {
    width: auto !important;
    padding: 8px 14px !important;
    font-size: 0.7rem !important;
  }

  /* ── Mobile status badge: dot + short abbreviation ──────────────────── */
  .col-status .status-pill {
    font-size: 0 !important;
    padding: 3px 6px !important;
    border-radius: 4px !important;
    gap: 3px;
  }
  .col-status .status-pill::after {
    content: attr(data-abbr);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0;
  }

  /* ── Change 2: Filter chip sizing ────────────────────────────────────── */
  .filter-chip {
    font-size: 0.75rem;
    padding: 6px 10px;
    flex-shrink: 0;
  }

  /* ── Toast: clear of FAB ─────────────────────────────────────────────── */
  .toast { bottom: 140px; }

  /* ── Change 7: Full-screen modals ────────────────────────────────────── */
  .modal-backdrop {
    align-items: flex-start;
    justify-content: flex-start;
  }
  .modal {
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0;
    border-radius: 0;
    overflow-y: auto;
  }

  /* ── Analytics: single-column stack on mobile ────────────────────────── */
  .chart-grid {
    grid-template-columns: 1fr !important;
  }
  .chart-cell:nth-child(1),
  .chart-cell:nth-child(2),
  .chart-cell:nth-child(3),
  .chart-cell:nth-child(4) {
    grid-column: 1 !important;
    grid-row: auto !important;
  }
  /* Override the inline height set by JS on mobile */
  .chart-cell [data-chart-wrap] {
    height: 180px !important;
  }
}

/* ── SETTINGS MODAL — mobile layout ─────────────────────────────────────── */
@media (max-width: 768px) {

  /* CHANGE 1: Settings modal fills screen (already fixed+inset:0, just prevent overflow) */
  #settingsModal {
    overflow: hidden;
  }

  /* CHANGE 3: Header — compact, flush */
  .settings-page-header {
    height: auto !important;
    padding: 10px 14px !important;
    gap: 8px !important;
    flex-shrink: 0;
  }

  .settings-page-title {
    font-size: 1rem !important;
    letter-spacing: 0.05em;
  }

  .settings-page-header .btn {
    flex-shrink: 0;
    padding: 6px 12px !important;
    font-size: 0.8rem !important;
  }

  /* CHANGE 2: Body — vertical stack */
  .settings-page-body {
    flex-direction: column !important;
    overflow: hidden;
    flex: 1;
  }

  /* Sidebar → horizontal scrollable tab strip */
  .settings-sidebar {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border, #334155) !important;
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none !important;
    padding: 6px 8px !important;
    gap: 4px !important;
    flex-shrink: 0;
  }

  .settings-sidebar::-webkit-scrollbar { display: none; }

  /* Style nav chips — display is controlled entirely by JS, never forced here */
  .settings-nav-item[style*="flex"],
  .settings-nav-item:not([style*="none"]) {
    white-space: nowrap;
    padding: 6px 12px;
    font-size: 0.72rem;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid var(--border, #334155);
    border-left-width: 1px;
    background: var(--surface2, #1e293b);
    color: var(--muted, #94a3b8);
    cursor: pointer;
    align-items: center;
    gap: 5px;
  }

  .settings-nav-item.active {
    background: var(--accent, #f59e0b) !important;
    color: #000 !important;
    border-color: var(--accent, #f59e0b) !important;
  }

  .settings-nav-item:hover:not(.active) {
    background: var(--surface, #0f172a);
    color: var(--text, #f1f5f9);
  }

  /* Content area scrolls vertically */
  .settings-content {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 16px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Tabs fill full width */
  .settings-tab {
    max-width: 100% !important;
  }

  /* CHANGE 4: Inputs fill full width */
  .settings-content input,
  .settings-content select,
  .settings-content textarea {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Input rows: let items wrap so button drops below on narrow screens */
  .settings-input-row {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  /* Chip/filter rows wrap on mobile */
  .settings-chip-row {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  /* Form grids single-column */
  .form-grid {
    grid-template-columns: 1fr !important;
  }

  /* Tighter section spacing */
  .settings-section {
    margin-bottom: 20px !important;
    padding-bottom: 16px !important;
  }

  .settings-tab-title {
    font-size: 1.1rem !important;
    margin-bottom: 16px !important;
  }
}

/* ── AUDIT LOG MODAL ─────────────────────────────────────────────────────── */
.audit-modal-card { background: var(--surface2, #1e293b); border-radius: 16px; width: 100%; max-width: 800px; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px rgba(0,0,0,0.7); }
.audit-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border, #334155); flex-shrink: 0; }
.audit-modal-header h2 { color: var(--accent, #f59e0b); font-size: 1rem; margin: 0; font-family: 'Bebas Neue', sans-serif; letter-spacing: 2px; font-size: 1.3rem; }
.audit-modal-controls { display: flex; gap: 8px; padding: 12px 24px; border-bottom: 1px solid var(--border, #334155); flex-shrink: 0; flex-wrap: wrap; }
.audit-input { background: var(--surface, #0f172a); border: 1px solid var(--border, #334155); color: var(--text, #f1f5f9); border-radius: 6px; padding: 6px 10px; font-size: 0.82rem; font-family: 'Inter', sans-serif; }
.audit-input:focus { outline: none; border-color: var(--accent, #f59e0b); }
.audit-search-input { flex: 1; min-width: 180px; }
.audit-log-list { flex: 1; overflow-y: auto; padding: 0 24px; }
.audit-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(51,65,85,0.4); }
.audit-row:last-child { border-bottom: none; }
.audit-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.audit-time { color: var(--muted, #64748b); font-size: 0.72rem; white-space: nowrap; font-family: 'Share Tech Mono', monospace; }
.audit-user { color: var(--accent2, #38bdf8); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.audit-action { font-size: 0.65rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; white-space: nowrap; }
.audit-action-create { background: rgba(34,197,94,0.15); color: #22c55e; }
.audit-action-update { background: rgba(59,130,246,0.15); color: #3b82f6; }
.audit-action-delete, .audit-action-clear_day { background: rgba(239,68,68,0.15); color: #ef4444; }
.audit-summary { color: var(--muted, #94a3b8); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.audit-pagination { padding: 10px 24px; border-top: 1px solid var(--border, #334155); flex-shrink: 0; }
.pag-row { display: flex; align-items: center; gap: 12px; justify-content: center; }
@media (max-width: 768px) { .audit-modal-card { max-width: 100%; max-height: 100dvh; border-radius: 0; } }

/* ── WH SELECTOR (Warehouses & Lists tab) ───────────────────────────────── */
.wh-selector-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.wh-select-btn { display: flex; flex-direction: column; align-items: center; background: var(--surface, #0f172a); border: 2px solid var(--border, #334155); border-radius: 10px; padding: 10px 14px; cursor: pointer; transition: all 0.15s; min-width: 72px; gap: 3px; }
.wh-select-btn:hover { border-color: var(--accent, #f59e0b); }
.wh-select-btn.active { border-color: var(--accent, #f59e0b); background: rgba(245,158,11,0.1); }
.wh-select-name { font-size: 0.6rem; color: var(--muted, #64748b); text-align: center; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wh-details-inner { border: 1px solid var(--border, #334155); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.wh-actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border, #334155); }
.global-lists-section { border-top: 2px solid var(--border, #334155); padding-top: 20px; margin-top: 4px; }
.list-subsection { margin-bottom: 16px; }
.list-subsection-title { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; color: var(--muted, #64748b); margin-bottom: 8px; }
.settings-hint-inline { font-size: 0.7rem; color: var(--muted, #64748b); text-transform: none; letter-spacing: 0; margin-left: 8px; font-weight: 400; }

/* Warehouse door/loader add inputs */
.wh-add-door-input,
.wh-add-loader-input,
#new-door-input,
#new-loader-input,
.wh-details-inner input[type="text"] {
  background: var(--surface, #0f172a) !important;
  color: var(--text-primary, #f1f5f9) !important;
  border: 1px solid var(--border, #334155) !important;
  border-radius: 6px !important;
  padding: 8px 12px !important;
  font-size: 0.85rem !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.wh-details-inner input[type="text"]:focus {
  outline: none !important;
  border-color: var(--accent, #f59e0b) !important;
}

/* ── Modal attachment section (Edit Entry / Add Truck post-save) ─────────── */
.modal-attachments-section { margin-top: 16px; }
.modal-section-divider { border-top: 1px solid var(--border, #334155); margin-bottom: 16px; }
.modal-section-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted, #64748b); margin-bottom: 10px; }
.modal-attach-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid rgba(51,65,85,0.4); font-size: 0.82rem; }
.modal-attach-row:last-child { border-bottom: none; }
.modal-attach-icon { flex-shrink: 0; }
.modal-attach-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted, #94a3b8); }
.modal-attach-actions { display: flex; gap: 4px; flex-shrink: 0; }
.modal-upload-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ── Upload button group (camera + library) ───────────────────────────────── */
.upload-btn-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.upload-btn-camera { border-color: #22c55e !important; color: #22c55e !important; }
.upload-btn-camera:hover { background: rgba(34,197,94,0.1) !important; }

@media (max-width: 768px) {
  .upload-btn-group { flex-direction: column; width: 100%; }
  .upload-btn-group label.btn { width: 100%; justify-content: center; padding: 12px !important; font-size: 0.9rem !important; }
}

/* ── Inline cell editing ──────────────────────────────────────────────────── */
.cell-editable {
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}

.cell-editable:hover {
  background: rgba(245,158,11,0.06);
  border-radius: 4px;
}

.cell-editable::after {
  content: attr(data-edit-label);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2, #1e293b);
  border: 1px solid var(--border, #334155);
  color: var(--muted, #94a3b8);
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
}

.cell-editable:hover::after {
  opacity: 1;
}

.cell-editing {
  background: rgba(245,158,11,0.1) !important;
  outline: 1px solid var(--accent, #f59e0b);
  border-radius: 4px;
}

.cell-inline-input,
.cell-inline-select,
.cell-inline-time {
  background: var(--surface, #0f172a);
  color: var(--text-primary, #f1f5f9);
  border: 1px solid var(--accent, #f59e0b);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.82rem;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}

.cell-inline-input:focus,
.cell-inline-select:focus,
.cell-inline-time:focus {
  outline: none;
}

/* ── Full-screen attachment panel ─────────────────────────────────────────── */
.attach-full-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border, #334155); background: var(--surface, #1e293b); flex-shrink: 0; }
.attach-full-title { font-size: 1rem; font-weight: 700; letter-spacing: 0.05em; color: var(--text, #f1f5f9); }
.attach-full-close { background: transparent; border: 1px solid var(--border, #334155); color: var(--muted, #94a3b8); font-size: 0.75rem; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; padding: 6px 14px; border-radius: 4px; cursor: pointer; transition: all 0.15s; }
.attach-full-close:hover { border-color: var(--accent2, #38bdf8); color: var(--accent2, #38bdf8); }

.attach-full-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 28px; }
.attach-full-section { background: var(--surface, #1e293b); border: 1px solid var(--border, #334155); border-radius: 10px; padding: 16px 20px; }
.attach-full-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.attach-full-section-title { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text, #f1f5f9); }
.attach-count-badge { background: var(--accent, #f59e0b); color: #000; font-size: 0.65rem; font-weight: 800; padding: 1px 7px; border-radius: 20px; }

/* ── Drag-and-drop upload zones (Phase 20E) ─────────────────────────────────
   Each upload-permitted section (data-drop-type) becomes a drop target. The
   hint strip is a small, always-visible affordance; the whole section lifts and
   outlines while a file is dragged over it. Desktop enhancement — the manual
   upload buttons stay fully usable and the strip never blocks them. */
.attach-full-section[data-drop-type] { transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease; }
.attach-full-section.is-dragover {
  border-color: var(--accent, #f59e0b);
  box-shadow: 0 0 0 2px var(--accent, #f59e0b) inset, 0 6px 18px rgba(0,0,0,0.25);
  background: rgba(245, 158, 11, 0.06);
}
.attach-dropzone-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 7px 12px;
  border: 1px dashed var(--border, #334155);
  border-radius: 8px;
  color: var(--muted, #94a3b8);
  background: rgba(255,255,255,0.02);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  user-select: none;
}
.attach-dropzone-ico { font-size: 0.95rem; line-height: 1; }
.attach-dropzone-or { color: var(--muted, #64748b); font-weight: 500; opacity: 0.75; font-size: 0.68rem; margin-left: auto; }
.attach-full-section.is-dragover .attach-dropzone-hint {
  border-color: var(--accent, #f59e0b);
  border-style: solid;
  color: var(--accent, #f59e0b);
  background: rgba(245, 158, 11, 0.10);
}
/* Touch devices: drag/drop is a desktop enhancement; hide the hint strip so
   phones/tablets keep the original button-only layout. */
@media (hover: none) and (pointer: coarse) {
  .attach-dropzone-hint { display: none; }
}

.attach-bol-list { display: flex; flex-direction: column; gap: 6px; }
.attach-bol-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: rgba(255,255,255,0.03); border: 1px solid var(--border, #334155); border-radius: 8px; }
.attach-bol-icon { font-size: 1.4rem; flex-shrink: 0; }
.attach-bol-info { flex: 1; min-width: 0; }
.attach-bol-name { font-size: 0.85rem; font-weight: 600; color: var(--text, #f1f5f9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-bol-meta { font-size: 0.72rem; color: var(--muted, #64748b); margin-top: 2px; }
.attach-bol-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

.attach-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.attach-photo-card { background: rgba(255,255,255,0.03); border: 1px solid var(--border, #334155); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.attach-photo-thumb { position: relative; width: 100%; aspect-ratio: 4/3; overflow: hidden; cursor: pointer; background: #0f172a; }
.attach-photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.2s; }
.attach-photo-thumb:hover img { transform: scale(1.05); }
.attach-thumb-error { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; font-size: 2rem; color: var(--muted, #64748b); }
.attach-thumb-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; letter-spacing: 1px; color: #fff; opacity: 0; transition: opacity 0.2s; text-transform: uppercase; }
.attach-photo-thumb:hover .attach-thumb-overlay { opacity: 1; }
.attach-photo-info { padding: 8px 10px 10px; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.attach-photo-name { font-size: 0.75rem; font-weight: 600; color: var(--text, #f1f5f9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-photo-meta { font-size: 0.68rem; color: var(--muted, #64748b); }
.attach-photo-btns { display: flex; gap: 4px; margin-top: 4px; }

.attach-empty-msg { color: var(--muted, #64748b); font-size: 0.82rem; margin: 0; padding: 8px 0; }

/* ── Lightbox ─────────────────────────────────────────────────────────────── */
.lb-topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: rgba(0,0,0,0.8); flex-shrink: 0; gap: 12px; flex-wrap: wrap; }
.lb-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.lb-info #lb-name { font-size: 0.85rem; font-weight: 600; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-info #lb-meta { font-size: 0.72rem; color: #64748b; }
.lb-topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lb-counter { font-size: 0.75rem; color: #64748b; font-variant-numeric: tabular-nums; }

.lb-image-area { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 0; }
.lb-image { max-width: 100%; max-height: 100%; object-fit: contain; display: block; user-select: none; }
.lb-nav-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.15); color: #fff; font-size: 2rem; line-height: 1; width: 48px; height: 64px; border-radius: 6px; cursor: pointer; transition: background 0.15s; display: flex; align-items: center; justify-content: center; }
.lb-nav-btn:hover { background: rgba(245,158,11,0.4); border-color: var(--accent, #f59e0b); }
.lb-prev-btn { left: 12px; }
.lb-next-btn { right: 12px; }

.lb-thumb-strip { display: flex; gap: 6px; padding: 8px 12px; background: rgba(0,0,0,0.6); overflow-x: auto; flex-shrink: 0; scroll-snap-type: x mandatory; }
.lb-thumb-strip::-webkit-scrollbar { height: 4px; }
.lb-thumb-strip::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }
.lb-thumb { width: 60px; height: 45px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 2px solid transparent; transition: border-color 0.15s, opacity 0.15s; scroll-snap-align: center; flex-shrink: 0; opacity: 0.55; }
.lb-thumb:hover { opacity: 0.85; }
.lb-thumb.active { border-color: var(--accent, #f59e0b); opacity: 1; }

@media (max-width: 600px) {
  .attach-photo-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
  .attach-full-body { padding: 12px; gap: 16px; }
  .attach-full-section { padding: 12px; }
  .attach-bol-actions { flex-direction: column; }
  .lb-nav-btn { width: 36px; height: 50px; font-size: 1.5rem; }
  .lb-prev-btn { left: 4px; }
  .lb-next-btn { right: 4px; }
  .lb-topbar { padding: 8px 10px; }
}


/* ── Send BOL Email modal (Phase 17Q) ────────────────────────────────────── */
.bol-send-modal {
  width: 560px; max-width: 100%; max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--surface, #14181f); border: 1px solid var(--border, #252a35);
  border-radius: 12px; overflow: hidden;
}
.bol-send-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--surface2, #181c23); border-bottom: 1px solid var(--border, #252a35);
}
.bol-send-title { font-size: 1rem; font-weight: 700; color: var(--accent, #f5a623); }
.bol-send-body { padding: 14px 16px; overflow-y: auto; }
.bol-send-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--border, #252a35); background: var(--surface2, #181c23);
}
.bol-send-summary {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px;
  padding: 10px; margin-bottom: 12px;
  background: var(--surface2, #181c23); border: 1px solid var(--border, #252a35); border-radius: 8px;
}
.bol-send-sum { display: flex; justify-content: space-between; gap: 8px; font-size: 0.78rem; }
.bol-send-sum span { color: var(--muted, #6b7280); }
.bol-send-sum b { color: var(--text, #e5e7eb); text-align: right; }
.bol-send-section { margin-bottom: 14px; }
.bol-send-label { font-size: 0.74rem; font-weight: 700; color: var(--muted, #6b7280); text-transform: uppercase; margin-bottom: 6px; }
.bol-send-files { display: flex; flex-direction: column; gap: 4px; }
.bol-send-file { font-size: 0.82rem; color: var(--text, #e5e7eb); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.bol-send-recip { font-size: 0.82rem; line-height: 1.7; }
.bol-send-recip strong { color: var(--accent2, #00d4ff); }
.bol-send-flags { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.82rem; }
.bol-send-flags label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.bol-send-warn { color: #f59e0b; font-size: 0.76rem; margin-top: 6px; }
.bol-send-last { font-size: 0.74rem; color: var(--muted, #6b7280); margin-bottom: 8px; }
.bol-send-ok { color: #22c55e; font-size: 0.82rem; line-height: 1.5; }
@media (max-width: 560px) { .bol-send-summary { grid-template-columns: 1fr; } }

/* ── In-app multi-photo camera capture (Phase 17O-B) ─────────────────────── */
/* Distinguish the in-app camera trigger from the native picker buttons. */
.tfcam-trigger { border-color: #22c55e !important; color: #fff !important; background: #16a34a !important; }
.tfcam-trigger:hover { background: #15803d !important; }

.tfcam-modal {
  /* Phase 17O-C: above the mobile truck-preview sheet (z-index 9999) so the
     in-app camera opens over the preview, not behind it. */
  position: fixed; inset: 0; z-index: 10050;
  background: #000; display: flex; flex-direction: column;
  overflow: hidden; color: #fff;
  /* Hotfix: prevent iOS Safari double-tap-to-zoom and text-selection callouts
     inside the camera overlay (rapid Capture taps were zooming the page). Scoped
     to the camera modal only — global page zoom is untouched. */
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
/* All tappable camera controls: kill the 300ms double-tap zoom gesture and keep
   sizing stable so a tap never reflows/zooms the layout. */
.tfcam-modal button {
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.tfcam-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: #0f172a; flex: 0 0 auto;
}
.tfcam-title { font-weight: 700; font-size: 1rem; }
.tfcam-close {
  background: #334155; color: #fff; border: none; border-radius: 6px;
  padding: 8px 14px; font-size: 0.85rem; cursor: pointer;
}
.tfcam-close:hover { background: #475569; }
.tfcam-stage {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center; background: #000;
}
.tfcam-video { max-width: 100%; max-height: 100%; width: auto; height: 100%; object-fit: contain; }
/* Phase 17O-D: live resolution badge + steady-hand / low-res hint */
.tfcam-resbadge {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  background: rgba(0,0,0,0.6); color: #cbd5e1; font-size: 0.72rem;
  padding: 4px 8px; border-radius: 6px; letter-spacing: 0.5px;
}
.tfcam-hint {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 2;
  background: rgba(0,0,0,0.6); color: #e2e8f0; font-size: 0.78rem; line-height: 1.4;
  text-align: center; padding: 8px 10px; border-radius: 8px;
}
.tfcam-hint-warn { background: rgba(120,53,15,0.85); color: #fed7aa; }
/* Phase 17O-F: softer note for ordinary mobile (standard) resolution */
.tfcam-hint-soft { background: rgba(30,58,138,0.78); color: #dbeafe; }
.tfcam-error {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px; font-size: 0.95rem; line-height: 1.5;
  background: rgba(0,0,0,0.85); color: #fca5a5;
}
.tfcam-tray {
  flex: 0 0 auto; display: flex; gap: 8px; padding: 8px 10px;
  overflow-x: auto; background: #0f172a; min-height: 0;
}
.tfcam-tray:empty { display: none; }
.tfcam-thumb { position: relative; flex: 0 0 auto; width: 64px; height: 64px; cursor: pointer; }
.tfcam-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid #334155; }
/* Phase 17O-F: highlight the thumbnail currently open in the review/edit pane */
.tfcam-thumb-sel img { border-color: #22c55e; box-shadow: 0 0 0 2px #22c55e; }
.tfcam-thumb-del {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px;
  border-radius: 50%; border: none; background: #ef4444; color: #fff;
  font-size: 0.7rem; line-height: 1; cursor: pointer;
}
.tfcam-thumb-del:hover { background: #dc2626; }
.tfcam-controls {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: #0f172a;
}
.tfcam-count { font-size: 0.85rem; color: #cbd5e1; min-width: 84px; }
.tfcam-capture {
  flex: 1 1 auto; max-width: 260px; padding: 14px; border-radius: 999px;
  border: 3px solid #fff; background: #ef4444; color: #fff;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  /* Stable min height so the disabled-while-encoding state can't reflow the
     control row (a size change under the finger can trigger iOS zoom). */
  min-height: 52px; box-sizing: border-box;
}
.tfcam-capture:hover:not(:disabled) { background: #dc2626; }
.tfcam-capture:disabled { opacity: 0.45; cursor: not-allowed; }
.tfcam-upload {
  flex: 0 0 auto; padding: 14px 18px; border-radius: 8px; border: none;
  background: #16a34a; color: #fff; font-size: 0.9rem; font-weight: 700; cursor: pointer;
}
.tfcam-upload:hover:not(:disabled) { background: #15803d; }
.tfcam-upload:disabled { opacity: 0.45; cursor: not-allowed; }
@media (max-width: 560px) {
  .tfcam-count { display: none; }
  .tfcam-capture { font-size: 0.95rem; padding: 16px; }
}

/* ── Phase 17O-F: review tray + resize/edit before upload ──────────────────── */
/* Selected-photo preview + the edit toolbar are hidden in camera-first mode and
   revealed when the modal carries .tfcam-reviewing (a thumbnail is selected). */
.tfcam-preview {
  display: none; position: absolute; inset: 0; margin: auto;
  max-width: 100%; max-height: 100%; width: auto; height: 100%;
  object-fit: contain; background: #000; z-index: 1;
}
.tfcam-preview-close {
  display: none; position: absolute; top: 10px; left: 10px; z-index: 4;
  background: rgba(15,23,42,0.85); color: #fff; border: none; border-radius: 6px;
  padding: 8px 12px; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.tfcam-livetag {
  display: none; position: absolute; z-index: 4;
  background: rgba(0,0,0,0.65); color: #fca5a5; font-size: 0.65rem; font-weight: 700;
  letter-spacing: 0.5px; padding: 2px 6px; border-radius: 4px;
}
.tfcam-edit { display: none; }

.tfcam-modal.tfcam-reviewing .tfcam-preview { display: block; }
.tfcam-modal.tfcam-reviewing .tfcam-preview-close { display: block; }
.tfcam-modal.tfcam-reviewing .tfcam-hint { display: none; }
.tfcam-modal.tfcam-reviewing .tfcam-resbadge { display: none !important; }
.tfcam-modal.tfcam-reviewing .tfcam-edit { display: flex; flex-direction: column; gap: 8px; }
/* Live camera shrinks to a compact card so Capture keeps working while reviewing. */
.tfcam-modal.tfcam-reviewing .tfcam-video {
  position: absolute; right: 10px; bottom: 10px; z-index: 3;
  width: 110px; height: auto; max-height: 32%;
  object-fit: cover; background: #000;
  border: 2px solid #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.6);
}
.tfcam-modal.tfcam-reviewing .tfcam-livetag {
  display: block; right: 14px; bottom: calc(10px + 32% + 4px);
}

.tfcam-edit {
  flex: 0 0 auto; background: #0f172a; padding: 10px 12px;
  border-top: 1px solid #1e293b;
}
.tfcam-edit-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tfcam-edit-label { font-size: 0.78rem; color: #94a3b8; }
.tfcam-edit-size { font-size: 0.78rem; color: #cbd5e1; margin-left: auto; }
.tfcam-ebtn {
  flex: 0 0 auto; padding: 9px 12px; border-radius: 7px; border: 1px solid #334155;
  background: #1e293b; color: #e2e8f0; font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
.tfcam-ebtn:hover:not(:disabled) { background: #334155; }
.tfcam-ebtn:disabled { opacity: 0.4; cursor: not-allowed; }
.tfcam-ebtn-save  { background: #16a34a; border-color: #16a34a; color: #fff; margin-left: auto; }
.tfcam-ebtn-save:hover:not(:disabled)  { background: #15803d; }
.tfcam-ebtn-del   { background: #7f1d1d; border-color: #991b1b; color: #fecaca; }
.tfcam-ebtn-del:hover:not(:disabled)   { background: #991b1b; }
.tfcam-preset {
  flex: 0 0 auto; padding: 7px 11px; border-radius: 999px; border: 1px solid #334155;
  background: #1e293b; color: #cbd5e1; font-size: 0.78rem; font-weight: 600; cursor: pointer;
}
.tfcam-preset:hover { background: #334155; }
.tfcam-preset-on { background: #2563eb; border-color: #2563eb; color: #fff; }
@media (max-width: 560px) {
  .tfcam-ebtn, .tfcam-preset { padding: 10px 12px; font-size: 0.85rem; }
  .tfcam-edit-size { width: 100%; margin-left: 0; }
}

/* ── Phase 17O-G: touch crop overlay ───────────────────────────────────────── */
/* The crop overlay takes over the modal body while .tfcam-cropping is set: the
   stage, edit panel, tray and capture controls are swapped out for a full-image
   crop view with a draggable/resizable box and Apply/Cancel actions. */
.tfcam-crop { display: none; }
.tfcam-modal.tfcam-cropping .tfcam-crop {
  display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; background: #000;
}
.tfcam-modal.tfcam-cropping .tfcam-stage,
.tfcam-modal.tfcam-cropping .tfcam-edit,
.tfcam-modal.tfcam-cropping .tfcam-tray,
.tfcam-modal.tfcam-cropping .tfcam-controls { display: none !important; }

.tfcam-crop-bar {
  flex: 0 0 auto; text-align: center; font-size: 0.78rem; color: #cbd5e1;
  background: #0f172a; padding: 8px 10px; line-height: 1.4;
}
.tfcam-crop-stage {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 6px; background: #000;
}
/* Element box equals the rendered image (no letterbox), so the overlaid crop box
   lines up exactly. Sizing is constrained to the stage. */
.tfcam-crop-img {
  display: block; max-width: 100%; max-height: 100%; width: auto; height: auto;
  user-select: none; -webkit-user-select: none; -webkit-user-drag: none;
  touch-action: none;
}
.tfcam-crop-box {
  position: absolute; box-sizing: border-box;
  border: 2px solid #22c55e; cursor: move; touch-action: none;
  /* Dim everything outside the crop rect (clipped to the stage). */
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
}
.tfcam-crop-h {
  position: absolute; width: 26px; height: 26px; box-sizing: border-box;
  background: #22c55e; border: 2px solid #fff; border-radius: 50%;
  touch-action: none;
}
.tfcam-crop-h-nw { left: -14px; top: -14px;    cursor: nwse-resize; }
.tfcam-crop-h-ne { right: -14px; top: -14px;    cursor: nesw-resize; }
.tfcam-crop-h-sw { left: -14px; bottom: -14px;  cursor: nesw-resize; }
.tfcam-crop-h-se { right: -14px; bottom: -14px; cursor: nwse-resize; }

.tfcam-crop-actions {
  flex: 0 0 auto; display: flex; gap: 10px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: #0f172a;
}
.tfcam-crop-actions .tfcam-ebtn { flex: 1 1 auto; padding: 14px; font-size: 0.95rem; }
.tfcam-crop-apply { background: #16a34a; border-color: #16a34a; color: #fff; }
.tfcam-crop-apply:hover { background: #15803d; }

/* ── PDF PREVIEW VIEWER (Phase 17P-B) ──────────────────────────────────────── */
/* Past-day typed-date confirmation — must stack above Bulk Entry/Edit panels */
.modal-backdrop.past-day-add-modal,
#past-day-add-modal.modal-backdrop {
  z-index: 10100;
  background: rgba(0, 0, 0, 0.72);
}
.pdfv-overlay {
  position: fixed; inset: 0; z-index: 9700;
  background: #1e1e1e;
  display: flex; flex-direction: column;
  overscroll-behavior: contain;
}
.pdfv-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--surface, #0f172a);
  border-bottom: 1px solid var(--border, #334155);
  flex-wrap: wrap;
}
.pdfv-title {
  flex: 1 1 160px; min-width: 0;
  font-weight: 600; color: var(--text, #e2e8f0);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pdfv-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pdfv-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; min-height: 38px; padding: 6px 12px;
  border: 1px solid var(--border, #334155);
  background: var(--surface, #1e293b);
  color: var(--text, #e2e8f0);
  border-radius: 6px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1;
}
.pdfv-btn:hover { background: var(--accent, #f59e0b); color: #0f172a; border-color: var(--accent, #f59e0b); }
.pdfv-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pdfv-btn:disabled:hover { background: var(--surface, #1e293b); color: var(--text, #e2e8f0); border-color: var(--border, #334155); }
.pdfv-btn-dl { color: var(--accent, #f59e0b); }
.pdfv-btn-close { font-weight: 700; }
.pdfv-zoom { min-width: 52px; text-align: center; color: var(--muted, #94a3b8); font-size: 0.85rem; }
.pdfv-pages { min-width: 60px; text-align: center; color: var(--muted, #94a3b8); font-size: 0.85rem; }
.pdfv-body {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: row;
  align-items: stretch; overflow: hidden;
}
.pdfv-scroll {
  flex: 1 1 auto; overflow: auto; -webkit-overflow-scrolling: touch;
  padding: 12px; text-align: center; overscroll-behavior: contain; min-width: 0;
}
/* width:max-content + min-width:100% lets pages render at their true scale and
   scroll horizontally when wider than the viewport (Phase 17P-C), while still
   centering when they are narrower than the scroller. */
.pdfv-pages-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  width: max-content; min-width: 100%; margin: 0 auto;
}
.pdfv-page {
  display: block;
  background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.pdfv-status { color: var(--muted, #94a3b8); padding: 40px 16px; font-size: 0.95rem; }
.pdfv-status-error { color: #f87171; }

@media (max-width: 640px) {
  .pdfv-topbar { padding: 6px 8px; gap: 6px; }
  .pdfv-title { flex-basis: 100%; font-size: 0.85rem; }
  .pdfv-controls { width: 100%; justify-content: space-between; }
  .pdfv-btn { padding: 8px 10px; min-height: 42px; }   /* finger-friendly */
  .pdfv-scroll { padding: 8px; }
}

/* Phase 20A — Send BOL Email modal: live recipient counts */
.bol-send-counts { margin-top: 8px; font-size: 0.8rem; color: var(--muted); }
.bol-send-counts b { color: var(--text, #e2e8f0); }

/* Phase 20A — BOL Queue sent proof */
.bq-pill.bq-sent { background: #16a34a; color: #fff; font-weight: 600; margin-left: 6px; cursor: help; }
.bq-lastsent { font-size: 0.72rem; }
.bq-lastsent-main { color: #22c55e; font-weight: 600; }
.bq-lastsent-sub { color: var(--muted); }

/* Phase 20A.1 — Last Sent details affordance + popover */
.bq-detail-btn {
  margin-top: 3px; background: none; border: none; padding: 0;
  color: var(--accent2, #38bdf8); font-size: 0.72rem; font-weight: 600; cursor: pointer;
}
.bq-detail-btn:hover { text-decoration: underline; }
.bq-detail-overlay {
  position: fixed; inset: 0; z-index: 9600;
  background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; padding: 16px;
}
.bq-detail-card {
  width: min(560px, 96vw); max-height: 86vh; overflow: auto;
  background: var(--surface, #14181f); border: 1px solid var(--border, #334155);
  border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.55);
}
.bq-detail-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border, #252a35);
  font-weight: 700; color: var(--text, #e2e8f0); font-size: 0.92rem;
}
.bq-detail-x { background: none; border: none; color: var(--muted, #94a3b8); font-size: 1rem; cursor: pointer; line-height: 1; }
.bq-detail-x:hover { color: var(--text, #e2e8f0); }
.bq-detail-body { padding: 12px 16px; font-size: 0.82rem; }
.bq-det-row { display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(148,163,184,0.12); }
.bq-det-row:last-child { border-bottom: none; }
.bq-det-label { flex: 0 0 96px; color: var(--muted, #94a3b8); font-weight: 600; }
.bq-det-val { flex: 1 1 auto; color: var(--text, #e2e8f0); overflow-wrap: anywhere; word-break: break-word; }

/* Phase 20A.1 — PO Send History lookup modal */
.bq-history-card {
  width: min(820px, 96vw); max-height: 86vh; display: flex; flex-direction: column;
  background: var(--surface, #14181f); border: 1px solid var(--border, #334155);
  border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.55);
}
.bq-history-search { padding: 12px 16px; border-bottom: 1px solid var(--border, #252a35); }
.bq-history-body { flex: 1 1 auto; overflow: auto; padding: 8px 12px; }
.bq-hist-empty { padding: 28px 12px; text-align: center; color: var(--muted, #94a3b8); font-size: 0.85rem; }
.bq-hist-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.bq-hist-table th { text-align: left; padding: 6px 8px; color: var(--muted, #6b7280); border-bottom: 1px solid var(--border, #252a35); position: sticky; top: 0; background: var(--surface, #14181f); font-size: 0.7rem; text-transform: uppercase; }
.bq-hist-table td { padding: 6px 8px; border-bottom: 1px solid var(--border, #252a35); color: var(--text, #e5e7eb); vertical-align: top; }

/* Phase 20A — truck BOL section: proof-of-send card */
.bol-proof { margin-top: 8px; }
.bol-proof-card { background: rgba(22,163,74,0.10); border: 1px solid rgba(22,163,74,0.45); border-left: 4px solid #16a34a; border-radius: 6px; padding: 8px 12px; font-size: 0.8rem; }
.bol-proof-head { color: #22c55e; font-weight: 700; }
.bol-proof-sub { color: var(--muted); margin: 2px 0 4px; }
.bol-proof-detail { color: var(--text, #e2e8f0); line-height: 1.5; }
.bol-proof-detail b { color: var(--muted); }
