* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; padding-bottom: 100px; }
#app-container { display: flex; flex-direction: column; min-height: 100vh; }
#offline-banner { display: none; position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 99; background: #d97706; color: #000; text-align: center; padding: 10px 24px; font-weight: 700; font-size: 0.85rem; letter-spacing: 0.5px; }

header { height: var(--header-h); background: var(--surface); border-bottom: 2px solid var(--accent); display: flex; align-items: center; padding: 0 24px; gap: 12px; position: sticky; top: 0; z-index: 100; overflow: visible; }
.header-brand { display: flex; align-items: center; flex-shrink: 0; gap: 8px; }
.logo { font-family: 'Bebas Neue', sans-serif; font-size: 2.2rem; letter-spacing: 4px; color: var(--accent); text-shadow: 0 0 20px rgba(245,166,35,0.4); white-space: nowrap; }
.logo span { color: var(--text); }
#title-left { color: var(--accent); }
.header-clock { font-family: 'Share Tech Mono', monospace; font-size: 1.5rem; color: var(--accent2); text-shadow: 0 0 12px rgba(0,212,255,0.4); white-space: nowrap; }
.header-date { font-family: 'Share Tech Mono', monospace; font-size: 0.85rem; color: var(--muted); margin-left: 4px; }
.header-spacer { flex: 1; min-width: 0; }
.header-controls { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; flex-shrink: 0; }

.filter-bar { background: var(--surface2); border-bottom: 1px solid var(--border); padding: 10px 24px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin-right: 4px; }
.filter-sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.date-input { background: var(--surface); border: 1px solid var(--border); color: var(--text); font-family: 'Share Tech Mono', monospace; font-size: 0.85rem; padding: 5px 10px; border-radius: 4px; cursor: pointer; }
.date-input:focus { outline: none; border-color: var(--accent2); }
.search-input { background: var(--surface); border: 1px solid var(--border); color: var(--text); font-family: 'Inter', sans-serif; font-size: 0.8rem; padding: 5px 12px; border-radius: 4px; width: 180px; }
.search-input:focus { outline: none; border-color: var(--accent2); }

.shift-notes-banner { background: var(--surface2); border: 1px solid var(--border); border-left: 3px solid var(--accent2); padding: 10px 20px; margin-bottom: 16px; border-radius: 4px; display: flex; align-items: flex-start; gap: 12px; font-size: 0.85rem; }
.shift-notes-banner .sn-label { font-size: 0.65rem; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent2); margin-right: 8px; white-space: nowrap; padding-top: 2px; }

main { padding: 20px 24px; }
.stats-row { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 14px 20px; min-width: 130px; flex: 1; }
.stat-card .s-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); margin-bottom: 4px; }
.stat-card .s-value { font-family: 'Bebas Neue', sans-serif; font-size: 2.2rem; line-height: 1; letter-spacing: 2px; }
.stat-card.c-total .s-value { color: var(--text); }
.stat-card.c-pallets .s-value { color: var(--purple); }
.stat-card.c-arrived .s-value { color: var(--green); }
.stat-card.c-departed .s-value { color: var(--accent2); }
.stat-card.c-pending .s-value { color: var(--yellow); }
.stat-card.c-cancelled .s-value { color: var(--red); }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: visible; }
.table-title-bar { background: var(--surface2); padding: 10px 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.table-title-bar .tt { font-family: 'Bebas Neue', sans-serif; font-size: 1.1rem; letter-spacing: 3px; color: var(--accent); flex-shrink: 0; }

/* ── Consolidated Live Board bar ─────────────────────────────────────────── */
.live-board-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px;
  background: var(--surface2); border-radius: 10px 10px 0 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap; overflow-x: visible; scrollbar-width: none;
}
.live-board-bar::-webkit-scrollbar { display: none; }

.live-board-title {
  font-size: 0.8rem; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.1em;
  white-space: nowrap; flex-shrink: 0; margin-right: 4px;
  font-family: 'Bebas Neue', sans-serif; font-size: 1.1rem; letter-spacing: 3px;
}


.live-board-search {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0 10px; height: 30px; width: 200px;
  flex-shrink: 0; transition: border-color 0.15s, width 0.2s;
}
.live-board-search:focus-within { border-color: var(--accent); width: 260px; }

.search-icon { font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }
.live-board-search-input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 0.8rem; min-width: 0; font-family: 'Inter', sans-serif; }
.live-board-search-input::placeholder { color: var(--muted); font-size: 0.78rem; }
.search-clear-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.75rem; padding: 0; flex-shrink: 0; }
.search-clear-btn:hover { color: var(--text); }
.live-board-count { font-size: 0.72rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; min-width: 55px; text-align: right; font-family: 'Share Tech Mono', monospace; }

/* ── Calendar button in week nav ─────────────────────────────────────────── */
.date-nav-cal-btn { background: var(--surface2); border: 1px solid var(--border); color: var(--muted); border-radius: 8px; padding: 6px 12px; font-size: 1rem; cursor: pointer; transition: all 0.15s; flex-shrink: 0; }
.date-nav-cal-btn:hover { border-color: var(--accent); color: var(--accent); }
.table-title-bar .wh-badge { font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 3px; background: var(--accent); color: #000; letter-spacing: 1px; cursor: pointer; }
.table-title-bar .wh-badge.active { box-shadow: 0 0 10px rgba(245,166,35,0.5); }
.table-title-bar .wh-badge.off { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.table-title-bar .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
thead th { background: #0d1017; color: var(--muted); font-size: 0.65rem; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; cursor: pointer; }
body.light-mode thead th { background: #d8dce4; }
thead th:hover { color: var(--accent2); }
thead th.sort-asc::after { content: ' ↑'; color: var(--accent); }
thead th.sort-desc::after { content: ' ↓'; color: var(--accent); }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; cursor: pointer; }
tbody tr:hover { background: rgba(245,166,35,0.04); }
tbody tr:last-child { border-bottom: none; }
tbody tr.selected { background: rgba(0,212,255,0.06); }
td { padding: 10px 14px; vertical-align: middle; white-space: nowrap; }
.td-door { font-family: 'Bebas Neue', sans-serif; font-size: 1.5rem; letter-spacing: 2px; color: var(--accent); text-align: center; width: 60px; }
.td-time { font-family: 'Share Tech Mono', monospace; font-size: 0.82rem; color: var(--accent2); }
.td-carrier { font-weight: 600; color: var(--text); font-size: 0.9rem; }
.td-customer { color: #c8cdd8; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.td-order { font-family: 'Share Tech Mono', monospace; font-size: 0.78rem; color: var(--purple); }
.td-skids { text-align: center; font-weight: 700; color: var(--text); }
.dwell-ok   { color: var(--green); font-size: 0.8rem; font-weight: 600; }
.dwell-warn { color: var(--yellow); font-size: 0.8rem; font-weight: 700; }
.dwell-crit { color: var(--red); font-size: 0.8rem; font-weight: 700; animation: dwell-pulse 2s infinite; padding: 3px 6px; border-radius: 4px; }
.comment-cell { color: var(--muted); font-style: italic; font-size: 0.75rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.actions-cell { display: flex; gap: 4px; }

.ticker { background: #000; border-top: 1px solid var(--border); padding: 6px 0; overflow: hidden; position: fixed; bottom: 0; left: 0; right: 0; z-index: 95; }
.ticker-inner { display: flex; gap: 40px; animation: scroll-ticker linear infinite; will-change: transform; white-space: nowrap; }
.ticker-item { font-family: 'Share Tech Mono', monospace; font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }
.ticker-item span { color: var(--accent); margin-right: 6px; }

.week-nav { position: fixed; bottom: 28px; left: 0; right: 0; background: var(--surface); border-top: 2px solid var(--accent); display: flex; justify-content: center; padding: 10px 24px; gap: 12px; z-index: 90; overflow-x: auto; white-space: nowrap; box-shadow: 0 -10px 20px rgba(0,0,0,0.3); }
.week-tab { background: var(--surface2); border: 1px solid var(--border); color: var(--muted); padding: 8px 24px; border-radius: 6px; font-family: 'Bebas Neue', sans-serif; font-size: 1.3rem; letter-spacing: 1.5px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 8px; }
.week-tab.active { background: var(--accent); color: #000; border-color: var(--accent); box-shadow: 0 0 16px rgba(245,166,35,0.4); }
.week-tab:hover:not(.active) { border-color: var(--accent2); color: var(--accent2); }
.week-tab-date { font-family: 'Inter', sans-serif; font-size: 0.7rem; font-weight: 700; opacity: 0.7; }

/* ── WAREHOUSE PILL (used in CEO dashboard / analytics) ─────────────────── */
.wh-pill { background: var(--surface2); border: 1px solid var(--border); color: var(--muted); border-radius: 6px; padding: 4px 10px; font-size: 0.75rem; font-weight: 700; cursor: pointer; white-space: nowrap; transition: all 0.15s; letter-spacing: 0.05em; }
.wh-pill:hover { border-color: var(--accent); color: var(--accent); }
.wh-pill.active { background: var(--accent); border-color: var(--accent); color: #000; }
.wh-current-badge { font-size: 0.75rem; font-weight: 700; color: var(--accent); padding: 4px 10px; border: 1px solid var(--accent); border-radius: 6px; }

/* Hide WH column when viewing a single warehouse */
table.hide-wh-col .col-wh { display: none !important; }
/* Hide BOL column when attachments feature is disabled */
table.hide-bol-col .col-bol { display: none !important; }

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

  /* Two-row header height for offline-banner offset */
  :root { --header-h: 96px; }

  /* ── Header two-row layout ────────────────────────────────────────────── */
  header {
    height: auto;
    flex-wrap: wrap;
    padding: 6px 10px;
    gap: 4px;
    align-items: center;
  }

  /* Row 1: brand(grows, shrinks) + controls(right) — both flex items in the same line */
  .header-brand {
    flex: 1 1 auto;
    order: 1;
    min-width: 0;
    overflow: hidden;
  }

  .header-controls {
    flex-shrink: 0;
    order: 2;
    width: auto;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 0;
    gap: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .header-controls::-webkit-scrollbar { display: none; }

  /* Row 2: header-row-2 wraps to its own line */
  .header-row-2 {
    order: 3;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 4px;
    border-top: 1px solid var(--border, #334155);
    min-height: 0;
  }

  /* Compact header text on mobile */
  .logo         { font-size: 1.4rem; letter-spacing: 1.5px; flex-shrink: 0; }
  .header-clock { font-size: 0.85rem !important; letter-spacing: 0.5px !important; white-space: nowrap; }
  .header-date  { display: none; }
  .header-spacer { display: none; }

  /* Timezone label — tiny, shown inline next to clock */
  #clock-tz-label { font-size: 0.55rem !important; letter-spacing: 0.5px; margin-left: 2px; color: var(--muted, #64748b); white-space: nowrap; }

  /* Weather — compact icon + temp only */
  .header-weather {
    display: flex !important;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    flex-shrink: 0;
  }

  .weather-icon { font-size: 1rem; }
  .weather-temp { font-size: 0.85rem; letter-spacing: 1px; }
  .weather-desc,
  .weather-city { display: none !important; }
  .weather-info { gap: 0; }

  .wh-pill {
    font-size: 0.65rem;
    padding: 3px 8px;
  }

  /* ── Change 6: Floating Add Truck button ──────────────────────────────── */
  /* Repurpose the existing #btn-add-truck as a FAB; JS auth-gating preserved */
  #btn-add-truck {
    position: fixed !important;
    bottom: 80px;
    right: 16px;
    z-index: 999;
    border-radius: 50px;
    padding: 12px 20px !important;
    width: auto !important;
    height: auto !important;
    background: var(--accent) !important;
    color: #000 !important;
    font-size: 0.8rem !important;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    white-space: nowrap;
    letter-spacing: 0.5px;
  }

  /* Hide inline add trigger row — FAB replaces it */
  #inline-add-trigger { display: none !important; }

  /* Hide inline input row — FAB is used on mobile */
  .add-truck-inline-row { display: none !important; }

  /* ── Live board bar on mobile ────────────────────────────────────────── */
  .live-board-title { display: none; }
  .live-board-bar { gap: 5px; padding: 6px 10px; flex-wrap: wrap; overflow-x: visible; overflow-y: visible; }
  .live-board-search { width: 120px; }
  .live-board-search:focus-within { width: 160px; }

  /* ── Change 2: Filter bar scrollable ─────────────────────────────────── */
  .filter-bar {
    padding: 8px 14px;
    gap: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-sep   { display: none; }
  .search-input { width: 130px; flex-shrink: 0; font-size: 0.75rem; }

  /* ── Change 3: Stats 2×3 grid ────────────────────────────────────────── */
  .stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    flex-wrap: unset;
  }
  .stat-card          { padding: 12px; min-width: 0; flex: unset; }
  .stat-card .s-value { font-size: 1.8rem; }
  .stat-card .s-label { font-size: 0.65rem; }

  /* ── Main padding ─────────────────────────────────────────────────────── */
  main { padding: 12px 14px; }

  /* ── Change 4: Table ─────────────────────────────────────────────────── */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  table    { font-size: 0.78rem; }
  td       { padding: 6px 8px; white-space: nowrap; }
  thead th { padding: 6px 8px; }

  /* Show only: DOOR · PICK UP TIME · ORDER/PO# · STATUS */
  .col-eta, .col-wh, .col-carrier, .col-custom,
  .col-pallets, .col-arrival, .col-departure,
  .col-dwell, .col-loader, .col-comments,
  .col-actions { display: none !important; }

  /* Mobile column widths */
  .col-door   { width: 18%; }
  .col-time   { width: 20%; }
  .col-wh     { width: 14%; }
  .col-order  { width: 28%; }
  .col-status { width: 20%; }

  /* ── Change 5: Week nav — scroll-snap tabs ──────────────────────────── */
  .week-nav {
    padding: 6px 10px;
    gap: 4px;
    justify-content: flex-start;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .week-nav::-webkit-scrollbar { display: none; }

  .week-tab {
    scroll-snap-align: center;
    flex-shrink: 0;
    padding: 5px 10px;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    min-width: 54px;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-align: center;
  }

  .week-tab.active {
    box-shadow: 0 0 10px rgba(245, 166, 35, 0.4);
  }

  .week-tab-date {
    font-size: 0.6rem;
    opacity: 0.8;
  }

  /* Calendar picker button — same height as tabs */
  .date-nav-cal-btn {
    flex-shrink: 0;
    min-width: 40px;
    padding: 5px 8px;
    font-size: 1rem;
  }
}

/* Weather widget in header */
.header-weather { display: flex; align-items: center; gap: 10px; padding: 6px 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; flex-shrink: 1; min-width: 0; overflow: hidden; }
.weather-icon { font-size: 1.6rem; line-height: 1; flex-shrink: 0; }
.weather-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.weather-temp { font-family: 'Bebas Neue', sans-serif; font-size: 1.3rem; letter-spacing: 2px; color: var(--text); line-height: 1; white-space: nowrap; }
.weather-desc { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); white-space: nowrap; }
.weather-city { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }

@media (max-width: 1100px) {
  .weather-desc { display: none; }
  .weather-city { display: none; }
}

/* Hide weather on tablets (769–900px) but allow mobile row-2 to show it */
@media (max-width: 900px) and (min-width: 769px) {
  .header-weather { display: none !important; }
}

/* Desktop: header-row-2 dissolves into the parent flex row via display:contents,
   making weather and wh-switcher behave as if the wrapper doesn't exist. */
@media (min-width: 769px) {
  .header-row-2 { display: contents; }
  header { flex-wrap: nowrap; }
}

@media (max-width: 768px) {
  table .col-eta,
  tr .col-eta,
  td.col-eta,
  th.col-eta {
    display: none !important;
    width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }
}

@media (max-width: 768px) {
  #truckTable,
  #truckTable table {
    table-layout: auto !important;
    width: 100% !important;
  }

  #truckTable .col-door     { width: auto; white-space: nowrap; }
  #truckTable .col-time     { width: auto; white-space: nowrap; }
  #truckTable .col-wh       { width: auto; white-space: nowrap; }
  #truckTable .col-order    { width: auto; min-width: 0;
                               overflow: hidden;
                               text-overflow: ellipsis;
                               max-width: 80px; }
  #truckTable .col-status   { width: auto; white-space: nowrap; }

  /* Make status pill show abbreviation on mobile */
  #truckTable .status-pill {
    font-size: 0.6rem !important;
    padding: 2px 5px !important;
    white-space: nowrap;
  }
}

@media (max-width: 768px) {
  #truckTable .col-wh,
  #truckTable th.col-wh { display: none !important; }
}

@media (max-width: 768px) {
  #btn-reports {
    font-size: 0.65rem;
    padding: 4px 8px;
    letter-spacing: 0.5px;
  }
}

/* ── Mobile filter trigger / sheet visibility ─────────────────────────────── */
.mobile-filter-trigger { display: none; }

@media (max-width: 768px) {
  .filter-dropdowns { display: none !important; }
  .mobile-filter-trigger { display: inline-flex; }
}
