/* ═══ DESIGN TOKENS ════════════════════════════════════════════════════════ */
:root {
  --bg: #f0f2f5;
  --surf: #ffffff;
  --surf2: #f7f8fa;
  --surf3: #eef0f4;
  --bdr: #d4d8e2;
  --bdr2: #c0c5d4;
  --txt: #1a1e2e;
  --txt2: #4a5068;
  --txt3: #8890a8;
  --acc: #2563eb;
  --acc2: #1d4ed8;
  --green: #16a34a;
  --yellow: #ca8a04;
  --orange: #ea580c;
  --red: #dc2626;
  --darkred: #991b1b;
  --purple: #7c3aed;
  --teal: #0e7490;
  --tealdk: #0c5f75;
  --nu: #d97706;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --r: 6px;
  --r2: 10px;
  --sh: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font);
  font-size: 13px;
  min-height: 100vh;
}

/* ═══ NAV ═══════════════════════════════════════════════════════════════════ */
.top-nav {
  background: var(--surf);
  border-bottom: 1px solid var(--bdr);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 44px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--sh);
}
.nav-brand {
  font-size: 14px;
  font-weight: 800;
  color: var(--acc);
  text-decoration: none;
  letter-spacing: .5px;
  white-space: nowrap;
}
.nav-shop { flex: 1; font-size: 12px; color: var(--txt2); font-weight: 600; }
.nav-right { display: flex; align-items: center; gap: 10px; }
.nav-user { font-size: 12px; color: var(--txt3); }
.btn-nav {
  font-size: 11px;
  font-weight: 600;
  color: var(--txt2);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--bdr);
  border-radius: var(--r);
  transition: border-color .15s, color .15s;
  background: none;
  cursor: pointer;
  font-family: var(--font);
}
.btn-nav:hover { border-color: var(--acc); color: var(--acc); }

/* ═══ BUTTONS ══════════════════════════════════════════════════════════════ */
.btn {
  background: var(--acc);
  color: #fff;
  border: none;
  padding: 6px 14px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  cursor: pointer;
  border-radius: var(--r);
  transition: background .15s;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: var(--acc2); color: #fff; }
.btn.g { background: transparent; border: 1px solid var(--bdr2); color: var(--txt2); }
.btn.g:hover { border-color: var(--acc); color: var(--acc); }
.btn.i { background: var(--green); }  .btn.i:hover { background: #15803d; }
.btn.s { background: var(--teal); }   .btn.s:hover { background: var(--tealdk); }
.btn.cal { background: #7c3aed; }     .btn.cal:hover { background: #6d28d9; }
.btn.danger { background: var(--red); } .btn.danger:hover { background: #b91c1c; }

/* ═══ MODALS ════════════════════════════════════════════════════════════════ */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.overlay.open { display: flex; }
.modal {
  background: var(--surf);
  border: 1px solid var(--bdr);
  border-radius: var(--r2);
  padding: 24px;
  width: 340px;
  font-family: var(--font);
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { font-size: 15px; font-weight: 700; color: var(--txt); margin-bottom: 5px; }
.msub { font-size: 12px; color: var(--txt3); margin-bottom: 16px; font-weight: 500; }
.field { margin-bottom: 13px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--txt2);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surf2);
  border: 1.5px solid var(--bdr);
  border-radius: var(--r);
  color: var(--txt);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  transition: border-color .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--acc);
  background: #fff;
}
.field textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.macts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.tog {
  appearance: none;
  width: 34px; height: 18px;
  border-radius: 9px;
  background: var(--bdr2);
  cursor: pointer;
  position: relative;
  transition: background .2s;
  border: none; outline: none;
  flex-shrink: 0;
}
.tog:checked { background: var(--purple); }
.tog::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.tog:checked::after { left: 18px; }

/* ═══ STATUS COLORS ═════════════════════════════════════════════════════════ */
.status-green  { border-color: var(--green)  !important; background: #f0fdf4 !important; }
.status-yellow { border-color: var(--yellow) !important; background: #fefce8 !important; }
.status-orange { border-color: var(--orange) !important; background: #fff7ed !important; }
.status-red    { border-color: var(--red)    !important; background: #fef2f2 !important; }
.status-overdue, .status-critical, .status-darkred {
  border-color: var(--darkred) !important;
  background: #fee2e2 !important;
}

/* ═══ BADGE ═════════════════════════════════════════════════════════════════ */
.badge {
  font-size: 9px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 999px;
  color: white;
  letter-spacing: .4px;
  white-space: nowrap;
}
.b-parts   { background: var(--purple); }
.b-appr    { background: #d97706; }
.b-staged  { background: var(--teal); }
.b-intake  { background: var(--green); }
.b-od      { background: var(--darkred); }
.b-crit    { background: var(--red); }
.b-hold    { background: #64748b; }

/* ═══ TRUCK SVG CARD ════════════════════════════════════════════════════════ */
.tcard {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 4px 4px 6px;
  position: relative;
  cursor: grab;
  border-radius: var(--r);
  user-select: none;
  -webkit-user-select: none;
}
.tcard:active { cursor: grabbing; }
.tcard.dragging { opacity: .3; }
.tro {
  font-size: 11px; font-weight: 700;
  margin-top: 2px;
  pointer-events: none;
  font-family: var(--mono);
}
.tmeta {
  font-size: 10px; color: var(--txt2);
  line-height: 1.3; text-align: center;
  pointer-events: none; font-weight: 500;
}
.pbar {
  height: 4px; width: 100%;
  background: var(--surf3);
  position: absolute; bottom: 0; left: 0;
  border-radius: 0 0 var(--r) var(--r);
  overflow: hidden;
}
.pfill { height: 100%; transition: width 2s linear, background 2s; }
.rmv {
  position: absolute; top: 3px; left: 3px;
  width: 15px; height: 15px;
  background: rgba(220,38,38,.85);
  border: none; border-radius: 50%;
  color: #fff; font-size: 9px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s; z-index: 7;
  line-height: 1; font-weight: 700;
}
.tcard:hover .rmv { opacity: 1; }
.note-dot {
  position: absolute; top: 4px; left: 22px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #ca8a04; pointer-events: none;
  box-shadow: 0 0 0 2px rgba(202,138,4,.25);
}
.pri-badge {
  position: absolute; bottom: 4px; left: 4px;
  min-width: 18px; height: 18px;
  border-radius: 9px; background: var(--nu);
  color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px; pointer-events: none; z-index: 4;
  box-shadow: 0 0 0 2px rgba(217,119,6,.2);
}
.pri-badge.p1 { animation: glow .9s ease-in-out infinite alternate; }
@keyframes glow {
  from { box-shadow: 0 0 4px rgba(217,119,6,.4); }
  to   { box-shadow: 0 0 10px rgba(217,119,6,.9), 0 0 0 2px rgba(217,119,6,.3); }
}

/* ═══ NOTE TOOLTIP ══════════════════════════════════════════════════════════ */
.note-tip {
  display: none;
  position: fixed; z-index: 600;
  max-width: 220px; min-width: 140px;
  background: var(--surf);
  border: 1.5px solid #ca8a04;
  border-radius: var(--r2);
  padding: 9px 11px;
  font-size: 12px; line-height: 1.5; color: var(--txt);
  pointer-events: none;
  white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.note-tip.show { display: block; }
.note-tip-head {
  font-size: 10px; font-weight: 700; color: #ca8a04;
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px;
}

/* ═══ CAPACITY BAR ══════════════════════════════════════════════════════════ */
.cap-bar-wrap { display: flex; align-items: center; gap: 8px; }
.cap-bar { flex: 1; height: 8px; background: var(--surf3); border-radius: 4px; overflow: hidden; }
.cap-fill { height: 100%; border-radius: 4px; transition: width .4s, background .4s; }
.cap-fill.healthy  { background: var(--green); }
.cap-fill.busy     { background: var(--yellow); }
.cap-fill.near_full { background: var(--orange); }
.cap-fill.overloaded { background: var(--red); }

/* ═══ STATUS BAR ════════════════════════════════════════════════════════════ */
.sbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surf); border-top: 1px solid var(--bdr);
  padding: 5px 16px;
  display: flex; gap: 18px;
  font-size: 11px; font-weight: 500; color: var(--txt3);
  z-index: 10; flex-wrap: wrap;
  box-shadow: 0 -1px 3px rgba(0,0,0,.06);
}
.sbar span { color: var(--txt); font-weight: 600; }
.sbar .sb-pct { font-weight: 400; color: var(--txt3) !important; }
.sbar .sb-status-healthy    { color: var(--green)  !important; }
.sbar .sb-status-busy       { color: var(--yellow) !important; }
.sbar .sb-status-near_full  { color: var(--orange) !important; }
.sbar .sb-status-overloaded { color: var(--red)    !important; }
.sbar-sep { width: 1px; background: var(--bdr); align-self: stretch; margin: 0 2px; }

/* ═══ TOAST NOTIFICATIONS ═══════════════════════════════════════════════════ */
._toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  max-width: 320px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  opacity: 0;
  transform: translateX(24px);
  transition: opacity .2s, transform .2s;
  line-height: 1.4;
}
._toast._toast-show   { opacity: 1; transform: translateX(0); }
._toast._toast-error  { background: #fef2f2; color: #991b1b; border: 1.5px solid #fca5a5; }
._toast._toast-success{ background: #f0fdf4; color: #166534; border: 1.5px solid #86efac; }
._toast._toast-warning{ background: #fefce8; color: #854d0e; border: 1.5px solid #fde047; }
._toast._toast-info   { background: color-mix(in srgb, var(--acc) 8%, #fff); color: var(--acc2); border: 1.5px solid color-mix(in srgb, var(--acc) 30%, #fff); }

/* ═══ GHOST DRAG ════════════════════════════════════════════════════════════ */
#dragGhost {
  position: fixed; top: -200px; left: -200px;
  pointer-events: none; z-index: 999;
  border-radius: var(--r); padding: 5px 10px;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  border: 1.5px solid var(--bdr); background: var(--surf);
  box-shadow: var(--sh);
}
