/* POD Calendar — dispatch whiteboard. Truck "magnets" (dots) carry the color; everything else stays quiet. */
:root {
  --bg: #E7EAE8;
  --surface: #FFFFFF;
  --surface-2: #F3F5F4;
  --surface-3: #E9EDEB;
  --ink: #1B2225;
  --ink-2: #55626A;
  --ink-3: #85929A;
  --line: #CFD6D3;
  --line-2: #E1E6E3;
  --accent: #0B6B4C;          /* highway-sign green */
  --accent-hover: #095A40;
  --accent-soft: #DDEFE6;
  --accent-ink: #FFFFFF;
  --danger: #B3261E;
  --danger-soft: #FBE5E3;
  --warn: #9A5B00;
  --warn-soft: #FFF1D6;
  --focus: #1A73E8;

  /* order status (left bar) */
  --st-open: #C5CDC9;
  --st-staged: #6F7F87;
  --st-loaded: #2E6DB4;
  --st-enroute: #E09A00;
  --st-delivered: #2E9B57;
  --st-invoiced: #B3BCC0;

  /* manual event types */
  --t-rma: #8CC8E3;      --t-rma-bg: #EAF6FB;
  --t-pto: #2BB3A5;      --t-pto-bg: #E3F6F3;
  --t-oos: #E07B00;      --t-oos-bg: #FFF0DF;
  --t-hold: #B66FB8;     --t-hold-bg: #F7EAF7;
  --t-purple: #6C0BA9;   --t-purple-bg: #EFE4F7;
  --t-other: #A7B1B6;    --t-other-bg: #F3F5F4;
  --t-done: #2E9B57;     --t-done-bg: #E5F5EA;
  --t-maint: #E07B00;    --t-maint-bg: #FFF0DF;
  --t-overdue: #C2372D;  --t-overdue-bg: #FCE6E4;
  --t-incoming: #C8508A; --t-incoming-bg: #FBEAF2;

  --radius-s: 5px;
  --radius-m: 8px;
  --radius-l: 14px;
  --shadow-pop: 0 10px 30px rgba(20, 30, 28, .18), 0 2px 6px rgba(20, 30, 28, .10);
  --rail-w: 252px;
  --sheet-w: 440px;
  --font: "Barlow", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-cond: "Barlow Semi Condensed", "Barlow", "Arial Narrow", "Segoe UI", system-ui, sans-serif;
  --card-size: 13px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101416;
    --surface: #182023;
    --surface-2: #1E272B;
    --surface-3: #263135;
    --ink: #E4EAE7;
    --ink-2: #9EABB1;
    --ink-3: #6F7D84;
    --line: #2F3B40;
    --line-2: #253034;
    --accent: #3DB487;
    --accent-hover: #52C496;
    --accent-soft: #173A2E;
    --accent-ink: #08130F;
    --danger: #F2867D;
    --danger-soft: #3A1F1D;
    --warn: #F0B54A;
    --warn-soft: #3A2C12;
    --st-open: #3B474C;
    --st-staged: #8798A0;
    --st-invoiced: #4A565B;
    --t-rma-bg: #17303A; --t-pto-bg: #12302D; --t-oos-bg: #3A2710; --t-hold-bg: #33213A;
    --t-purple-bg: #2C1840; --t-other-bg: #1E272B; --t-done-bg: #15301F; --t-maint-bg: #3A2710;
    --t-overdue-bg: #3E1C1A; --t-incoming-bg: #3A1B2A;
    --shadow-pop: 0 14px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.4 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Buttons & fields ───────────────────────────────────────── */
.btn { text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-m);
  background: var(--surface); color: var(--ink);
  font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn.small { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.small.icon { width: 28px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.busy { pointer-events: none; opacity: .7; }

.field { display: grid; gap: 4px; align-content: start; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: 12px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 36px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-m);
  background: var(--surface);
}
textarea.input { min-height: 90px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.input[readonly] { background: var(--surface-2); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

/* segmented / chips */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-m); background: var(--surface-3); }
.seg button { border: 0; background: transparent; padding: 0 10px; height: 28px; border-radius: 6px; color: var(--ink-2); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-size: 14px; cursor: pointer; user-select: none;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.chip:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); }

/* ── Magnet (truck dot) ─────────────────────────────────────── */
.dot {
  --c: #8A949A;
  display: inline-block; flex: none;
  width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.55) 0 18%, transparent 30%), var(--c);
  box-shadow: 0 0 0 1px rgba(0,0,0,.22), 0 1px 1px rgba(0,0,0,.18);
}
.dot.ring { background: transparent; box-shadow: inset 0 0 0 2.5px var(--c), 0 0 0 1px rgba(0,0,0,.18); }
.dot.none { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.dot.lg { width: 16px; height: 16px; }
.dot.xl { width: 22px; height: 22px; }

/* ── App layout ─────────────────────────────────────────────── */
.app { display: grid; grid-template-rows: auto auto 1fr; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 16px; letter-spacing: .01em; margin-right: 4px; }
.brand-mark { display: inline-flex; gap: 3px; }
.brand-mark i { width: 9px; height: 9px; border-radius: 50%; display: block; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.brand-mark i:nth-child(1) { background: #F2C200; } .brand-mark i:nth-child(2) { background: #2E6DB4; } .brand-mark i:nth-child(3) { background: #E4572E; }
.branch-pick { min-width: 160px; height: 34px; font-weight: 600; }
.branch-name { font-weight: 600; padding: 0 4px; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav h1 { font-size: 20px; font-weight: 600; margin: 0 0 0 10px; white-space: nowrap; letter-spacing: -.005em; }
.topbar .spacer { flex: 1; }
.tools { display: flex; align-items: center; gap: 6px; position: relative; }

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line); font-weight: 500;
}

.layout { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 0; }
.rail {
  display: flex; flex-direction: column; gap: 18px;
  padding: 16px 12px 12px 14px; overflow-y: auto;
  background: var(--surface-2); border-right: 1px solid var(--line);
}
.rail h2 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0; }
.rail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.rail-sec { display: grid; gap: 6px; }
.rail .hint { font-size: 12px; color: var(--ink-3); margin: 2px 0 0; }
.rail-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; }

.trucks { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.truck {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 5px 4px 5px 8px; border-radius: var(--radius-m); cursor: pointer;
}
.truck:hover { background: var(--surface-3); }
.truck[aria-pressed="true"] { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--ink); }
.truck .name { font-weight: 600; line-height: 1.15; min-width: 0; }
.truck .name small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12px; }
.truck .acts { display: flex; opacity: 0; transition: opacity .12s; }
.truck:hover .acts, .truck:focus-within .acts, .truck[aria-pressed="true"] .acts { opacity: 1; }
.truck.is-hidden { opacity: .55; }
.link { border: 0; background: none; color: var(--accent); padding: 2px 0; font-weight: 500; text-align: left; }
.link:hover { text-decoration: underline; }

.toggles { display: grid; gap: 7px; }
.fleet-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-m);
  background: var(--surface); text-align: left; font-weight: 500;
}
.fleet-btn:hover { background: var(--surface-3); }
.badge { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--accent-soft); color: var(--accent); }

main { min-width: 0; overflow: auto; padding: 12px 16px 24px; }
#calendar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden; }

/* ── FullCalendar skin ─────────────────────────────────────── */
.fc { --fc-border-color: var(--line-2); --fc-page-bg-color: var(--surface); --fc-neutral-bg-color: var(--surface-2);
      --fc-today-bg-color: color-mix(in srgb, var(--accent) 6%, transparent); --fc-event-bg-color: transparent; --fc-event-border-color: transparent;
      --fc-event-text-color: var(--ink); --fc-list-event-hover-bg-color: var(--surface-2); --fc-highlight-color: var(--accent-soft); }
.fc .fc-scrollgrid { border: 0; }
.fc .fc-col-header-cell { background: var(--surface-2); }
.fc .fc-col-header-cell-cushion { padding: 8px 6px; font-weight: 600; font-size: 14px; color: var(--ink-2); text-decoration: none; }
.fc .fc-daygrid-day-number { font-weight: 600; font-size: 13px; color: var(--ink-2); padding: 6px 8px; text-decoration: none; }
.fc .fc-day-today .fc-daygrid-day-number { color: var(--accent-ink); background: var(--accent); border-radius: 999px; margin: 4px; padding: 1px 8px; }
.fc .fc-day-other .fc-daygrid-day-top { opacity: .45; }
.fc .fc-daygrid-day-frame { min-height: 120px; }
.fc .fc-daygrid-day-events { margin: 0 4px 6px; }
.fc .fc-daygrid-event-harness { margin-top: 3px; }
.fc .fc-daygrid-event { margin: 0; border: 0; border-radius: var(--radius-s); background: transparent; box-shadow: none; white-space: normal; }
.fc .fc-event:focus { box-shadow: none; }
.fc .fc-event:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.fc .fc-daygrid-event .fc-event-main { padding: 0; }
.fc-direction-ltr .fc-daygrid-event.fc-event-end, .fc-direction-ltr .fc-daygrid-event.fc-event-start { margin: 0; }
.fc .fc-event.fc-event-mirror { opacity: .8; }
.fc .fc-list { border: 0; }
.fc .fc-list-day-cushion { background: var(--surface-2); font-weight: 600; }
.fc .fc-list-event-dot { display: none; }
.fc .fc-list-event-graphic { padding-right: 0; }
.fc .fc-list-event-time { width: 0; padding: 0; }
.fc .fc-list-event td { border-color: var(--line-2); }
.fc .fc-list-event-title { padding: 6px 12px; }
.fc .fc-list-event:hover td { background: var(--surface-2); }

/* focus on one truck */
.focusing .fc-event:not(.match) { opacity: .18; filter: saturate(.3); }
.focusing .fc-event.match { opacity: 1; }

/* ── Event cards ─────────────────────────────────────────────── */
.ev { font-family: var(--font-cond); font-size: var(--card-size); line-height: 1.25; color: var(--ink); }
.density-compact { --card-size: 12px; }
.density-large { --card-size: 15px; }

.ev-order {
  position: relative; display: grid; grid-template-columns: auto 1fr; column-gap: 7px; align-items: start;
  padding: 5px 7px 5px 9px; background: var(--surface); border: 1px solid var(--line-2);
  border-left: 3px solid var(--st, var(--st-open)); border-radius: var(--radius-s);
}
.fc-event:hover .ev-order { border-color: var(--line); border-left-color: var(--st, var(--st-open)); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.ev-order .dot { margin-top: 3px; }
.ev-order > div { min-width: 0; }
.fc .fc-daygrid-event-harness, .fc .fc-daygrid-event { min-width: 0; max-width: 100%; }
.ev-sum .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ev-line1 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: break-word; }
.ev-stop { font-weight: 700; color: var(--ink); white-space: nowrap; margin-right: 5px; }
.ev-cust { font-weight: 600; }
.ev-line2 { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; color: var(--ink-2); margin-top: 1px; }
.ev-line2 > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ev-status { font-weight: 600; }
.ev-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.tag { display: inline-flex; align-items: center; gap: 3px; padding: 0 5px; border-radius: 4px; font-size: .86em; font-weight: 600; background: var(--surface-3); color: var(--ink-2); line-height: 1.5; }
.tag.pickup { background: #E9F7CF; color: #3F5A00; }
.tag.direct { background: #FBF0CF; color: #6B4E00; }
.tag.xfer { background: #ECE8F7; color: #4B3B7A; }
.tag.sister { background: #E1F0FA; color: #1F5375; }
.tag.noloader { background: var(--warn-soft); color: var(--warn); }
.tag.ref { background: var(--accent-soft); color: var(--accent); font-weight: 500; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (prefers-color-scheme: dark) {
  .tag.pickup { background: #2A3A10; color: #C8E58A; } .tag.direct { background: #3A3010; color: #EBCF7A; }
  .tag.xfer { background: #2A2440; color: #C5B8F0; } .tag.sister { background: #14303F; color: #9ACDEB; }
}
.ev-icons { position: absolute; top: 4px; right: 5px; display: flex; gap: 3px; color: var(--ink-2); }
.ev-icons svg.i { width: 13px; height: 13px; }
.ev-icons .ok { color: var(--st-delivered); }
.ev-icons .no { color: var(--danger); }
.ev-order.has-icons .ev-line1 { padding-right: 34px; }

.st-staged { --st: var(--st-staged); }
.st-loaded { --st: var(--st-loaded); }
.st-enroute { --st: var(--st-enroute); }
.st-delivered { --st: var(--st-delivered); }
.st-invoiced { --st: var(--st-invoiced); }
.st-delivered .ev-status { color: var(--st-delivered); }
.st-enroute .ev-status { color: var(--warn); }
.st-loaded .ev-status { color: var(--st-loaded); }
.st-invoiced { opacity: .62; }
.st-invoiced .ev-cust { font-weight: 500; }

/* truck header — the run sheet line above each truck's stops */
.ev-sum {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 2px 2px; margin-top: 4px; border-top: 1px dashed var(--line);
  font-family: var(--font-cond); font-size: var(--card-size); color: var(--ink-2); cursor: default;
}
.ev-sum .lbl { font-weight: 700; color: var(--ink); }
.ev-sum .money { margin-left: auto; font-weight: 600; color: var(--ink); }
.ev-sum .w { font-size: .92em; }
.ev-sum-runs { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 2px 2px 19px; font-family: var(--font-cond); font-size: calc(var(--card-size) - 1px); color: var(--ink-2); }
.ev-total { display: flex; justify-content: space-between; gap: 6px; padding: 3px 4px; border-radius: var(--radius-s); background: var(--surface-2); font-family: var(--font-cond); font-size: var(--card-size); color: var(--ink-2); cursor: default; }
.ev-total b { color: var(--ink); font-weight: 600; }

.ev-manual { padding: 4px 7px 4px 9px; border-radius: var(--radius-s); border-left: 3px solid var(--tc); background: var(--tb); }
.ev-manual .t { font-weight: 600; }
.ev-manual .sub { color: var(--ink-2); font-size: .92em; }
.ty-rma { --tc: var(--t-rma); --tb: var(--t-rma-bg); }
.ty-pto { --tc: var(--t-pto); --tb: var(--t-pto-bg); }
.ty-oos { --tc: var(--t-oos); --tb: var(--t-oos-bg); }
.ty-hold { --tc: var(--t-hold); --tb: var(--t-hold-bg); }
.ty-purple { --tc: var(--t-purple); --tb: var(--t-purple-bg); }
.ty-other { --tc: var(--t-other); --tb: var(--t-other-bg); }
.ty-rma-done { --tc: var(--t-done); --tb: var(--t-done-bg); }
.ty-maintenance { --tc: var(--t-maint); --tb: var(--t-maint-bg); }
.ty-maintenance-overdue { --tc: var(--t-overdue); --tb: var(--t-overdue-bg); }

.ev-incoming { padding: 4px 7px; border: 1px dashed var(--t-incoming); border-radius: var(--radius-s); background: var(--t-incoming-bg); }
.ev-incoming .t { font-weight: 600; display: flex; gap: 5px; align-items: center; }
.ev-incoming .t svg.i { width: 13px; height: 13px; color: var(--t-incoming); }
.ev-incoming .sub { color: var(--ink-2); font-size: .92em; }

/* ── Popovers, sheet, dialogs ───────────────────────────────── */
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 50; min-width: 220px;
  padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow-pop);
}
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: none; text-align: left; text-decoration: none; color: var(--ink); }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--line-2); margin: 4px 0; }

.hovercard {
  position: fixed; z-index: 60; width: 300px; max-width: calc(100vw - 20px); pointer-events: none;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow-pop); font-size: 14px;
}
.hovercard h4 { margin: 0 0 2px; font-size: 15px; }
.hovercard dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 8px 0 0; }
.hovercard dt { color: var(--ink-3); }
.hovercard dd { margin: 0; }
.hovercard .msg { margin-top: 8px; padding: 6px 8px; background: var(--surface-2); border-radius: 6px; font-size: 13px; }

.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
  width: var(--sheet-w); max-width: 100vw; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-pop);
  animation: sheet-in .16s ease-out;
}
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } }
.sheet-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 16px 12px; border-bottom: 1px solid var(--line-2); }
.sheet-head h2 { margin: 0; font-size: 19px; line-height: 1.2; }
.sheet-head .sub { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.sheet-head .btn { margin-left: auto; }
.sheet-body { overflow-y: auto; padding: 14px 16px 24px; display: grid; gap: 18px; align-content: start; }
.sheet section { display: grid; gap: 10px; }
.sheet h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 5px 12px; margin: 0; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); }
.status-pill::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--st, var(--st-open)); }
.items { list-style: none; padding: 0; margin: 0; border: 1px solid var(--line-2); border-radius: var(--radius-m); max-height: 260px; overflow-y: auto; }
.items li { display: grid; grid-template-columns: 46px 1fr; gap: 8px; padding: 7px 10px; border-top: 1px solid var(--line-2); font-size: 14px; }
.items li:first-child { border-top: 0; }
.items .q { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.items .sz { color: var(--ink-3); }
.mapframe { width: 100%; height: 220px; border: 0; border-radius: var(--radius-m); background: var(--surface-3); }
.texts { display: grid; gap: 6px; }
.text { padding: 8px 10px; border-radius: var(--radius-m); background: var(--surface-2); font-size: 14px; }
.text.reply { background: var(--accent-soft); }
.text .meta { font-size: 12px; color: var(--ink-3); margin-bottom: 3px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sticky-actions { position: sticky; bottom: -24px; padding: 12px 0; background: linear-gradient(transparent, var(--surface) 30%); }

dialog.dlg {
  width: min(560px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius-l);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop);
}
dialog.dlg.wide { width: min(900px, calc(100vw - 24px)); }
dialog.dlg::backdrop { background: rgba(14, 22, 20, .42); }
dialog.dlg[open] { animation: pop .14s ease-out; }
@keyframes pop { from { transform: translateY(6px) scale(.985); opacity: 0; } }
.dlg form, .dlg .dlg-inner { display: grid; gap: 0; }
.dlg header { display: flex; align-items: center; gap: 10px; padding: 16px 18px 6px; }
.dlg header h2 { margin: 0; font-size: 19px; }
.dlg header > .btn:last-child { margin-left: auto; }
.dlg .body { display: grid; gap: 14px; padding: 10px 18px 16px; max-height: calc(100vh - 190px); overflow-y: auto; }
.dlg footer { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line-2); background: var(--surface-2); border-radius: 0 0 var(--radius-l) var(--radius-l); }
.dlg footer .left { margin-right: auto; display: flex; gap: 8px; }
.dlg .note { font-size: 13px; color: var(--ink-2); margin: 0; }
.dlg .err { color: var(--danger); font-weight: 500; font-size: 14px; margin: 0; }
fieldset.box { border: 1px solid var(--line-2); border-radius: var(--radius-m); padding: 10px 12px 12px; margin: 0; display: grid; gap: 10px; }
fieldset.box legend { padding: 0 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }

.palette { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.palette button { width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.palette button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.palette input[type="color"] { width: 34px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.truck-preview { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-m); background: var(--surface-2); font-weight: 600; }

.key { display: grid; gap: 14px; }
.key-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; font-size: 14px; }
.key-grid > div { display: flex; align-items: center; gap: 8px; }
.key .bar { width: 4px; height: 16px; border-radius: 2px; background: var(--st, var(--st-open)); }

.gps { display: grid; grid-template-columns: 1fr 240px; gap: 0; }
.gps iframe { width: 100%; height: 420px; border: 0; background: var(--surface-3); }
.gps aside { padding: 14px 16px; display: grid; gap: 10px; align-content: start; font-size: 14px; }
.gps .big { font-size: 26px; font-weight: 600; line-height: 1; }

.list { display: grid; gap: 6px; }
.list-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-m); font-size: 14px; }
.list-row .t { font-weight: 600; }
.list-row .s { color: var(--ink-2); font-size: 13px; }
.maint-item { cursor: grab; background: var(--surface); }
.maint-item:active { cursor: grabbing; }
.maint-item.overdue { border-color: color-mix(in srgb, var(--t-overdue) 45%, var(--line-2)); }
.flag { width: 8px; height: 30px; border-radius: 3px; background: var(--c); }
.empty { padding: 26px 10px; text-align: center; color: var(--ink-2); }

.users-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.users-table th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 6px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.users-table td { padding: 7px 8px; border-bottom: 1px solid var(--line-2); }
.users-table td:last-child { text-align: right; white-space: nowrap; }

.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: var(--radius-m); background: var(--ink); color: var(--surface); box-shadow: var(--shadow-pop); font-weight: 500; animation: pop .16s ease-out; max-width: min(560px, calc(100vw - 24px)); }
.toast.error { background: var(--danger); color: #fff; }

.loading-bar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 200; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: slide 1s linear infinite; }
@keyframes slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }

/* delivery map */
dialog.dlg.wide:has(.dmap-wrap) { width: min(1280px, calc(100vw - 24px)); }
.dmap-wrap { display: grid; grid-template-columns: 1fr 320px; height: min(72vh, 760px); border-top: 1px solid var(--line-2); }
.dmap { background: var(--surface-3); min-height: 300px; }
.dmap .empty { margin-top: 30%; }
.dmap-side { overflow-y: auto; padding: 10px 12px 16px; display: grid; gap: 14px; align-content: start; border-left: 1px solid var(--line-2); }
.dmap-side section { display: grid; gap: 2px; }
.dmap-side h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.dmap-stop { display: grid; grid-template-columns: 54px 1fr; align-items: start; gap: 8px; width: 100%; padding: 6px 6px; border: 0; border-radius: 6px; background: none; text-align: left; font-size: 14px; }
.dmap-stop:hover:not([disabled]) { background: var(--surface-2); }
.dmap-stop[disabled] { cursor: default; opacity: .75; }
.dmap-stop small { display: block; color: var(--ink-2); font-size: 12px; }
.dmap-stop .dot { margin: 2px 0 0 4px; }
.dmap-n { white-space: nowrap; font-weight: 700; font-family: var(--font-cond); padding-top: 1px; }
.dmap-info { font: 14px/1.4 var(--font); color: #1b2225; display: grid; gap: 2px; max-width: 260px; }
@media (max-width: 760px) { .dmap-wrap { grid-template-columns: 1fr; height: auto; } .dmap { height: 50vh; } .dmap-side { border-left: 0; } }

/* ── Login ─────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); }
.login-board { position: relative; overflow: hidden; background: var(--surface-2); border-right: 1px solid var(--line); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-board .brand { font-size: 18px; }
.board-lanes { display: grid; gap: 14px; max-width: 520px; }
.lane { display: grid; grid-template-columns: 22px 64px 1fr; gap: 12px; align-items: center; font-family: var(--font-cond); font-size: 15px; color: var(--ink-2); }
.lane b { color: var(--ink); font-weight: 700; }
.lane .track { height: 30px; display: flex; gap: 6px; }
.lane .stopcard { flex: 1; max-width: 110px; border-radius: 5px; background: var(--surface); border: 1px solid var(--line-2); border-left: 3px solid var(--st); }
.login-board h1 { font-size: clamp(32px, 4vw, 52px); line-height: 1.02; letter-spacing: -.02em; margin: 0 0 10px; font-weight: 600; max-width: 12ch; }
.login-board p { color: var(--ink-2); max-width: 44ch; margin: 0; font-size: 17px; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--surface); }
.login-form form { width: min(360px, 100%); display: grid; gap: 16px; }
.login-form h2 { margin: 0; font-size: 24px; }
.login-form .btn { height: 42px; justify-content: center; font-size: 16px; }
.login-form .input { min-height: 42px; }
.login-foot { color: var(--ink-3); font-size: 13px; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1100px) {
  :root { --rail-w: 220px; --sheet-w: 380px; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; z-index: 45; width: 280px; transform: translateX(-100%); transition: transform .18s; box-shadow: var(--shadow-pop); }
  .rail.open { transform: none; }
  .nav h1 { font-size: 17px; }
  .topbar { gap: 8px; padding: 8px 10px; }
  #densitySwitch, #keyBtn, .brand { display: none; }
  #viewSwitch { order: 10; width: 100%; overflow-x: auto; }
  #viewSwitch [data-view="dayGridMonth"], #viewSwitch [data-view="dayGridWeek"], #viewSwitch [data-view="dayGrid5"] { display: none; }
  main { padding: 8px; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .gps { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-board { display: none; }
}
@media (min-width: 761px) { .rail-toggle { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Month view: one line per stop so the whole month fits on screen. Details are a click away. */
.view-month .ev-order { padding: 2px 6px 2px 7px; column-gap: 6px; align-items: center; }
.view-month .ev-order .dot { margin-top: 0; width: 8px; height: 8px; }
.view-month .ev-line1 { -webkit-line-clamp: 1; }
.view-month .ev-line2, .view-month .ev-tags, .view-month .ev-icons, .view-month .ev-sum-runs { display: none; }
.view-month .ev-order.has-icons .ev-line1 { padding-right: 0; }
.view-month .ev-sum { padding-top: 4px; margin-top: 2px; }
.view-month .ev-sum .dot.lg { width: 12px; height: 12px; }
.view-month .ev-manual, .view-month .ev-incoming { padding: 2px 6px; }
.view-month .ev-manual .sub, .view-month .ev-incoming .sub { display: none; }
.view-month .fc-daygrid-event-harness { margin-top: 2px; }
