/* =========================================================================
   Trakto — visual language
   One place for colour, radius and shadow; everything below uses these.
   ========================================================================= */
:root {
  --bg:        #eef2f7;
  --surface:   #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #f1f4f9;

  --ink:   #0f1b2a;
  --ink-2: #5b6b7f;
  --ink-3: #8d9aab;

  --line:   #e5eaf1;
  --line-2: #d3dbe6;

  --brand:      #3b6ef6;
  --brand-ink:  #1f4fd0;
  --brand-soft: #eaf0ff;
  --brand-2:    #7b5cfa;   /* violet end of the brand gradient */
  --brand-3:    #29c3e0;   /* cyan tail, used in the accent line */

  --navy:   #0f2438;
  --navy-2: #1a3d5c;

  --ok:   #0f7a43;  --ok-soft:   #e6f6ed;  --ok-line:   #bde3cd;
  --warn: #96610a;  --warn-soft: #fff5e3;  --warn-line: #f0d9ac;
  --bad:  #c0342a;  --bad-soft:  #fdeceb;  --bad-line:  #f3c4c0;

  --r1: 8px;
  --r2: 12px;
  --r3: 16px;

  --sh1: 0 1px 2px rgba(15,27,42,.05), 0 1px 3px rgba(15,27,42,.04);
  --sh2: 0 6px 20px rgba(15,27,42,.09);
  --sh3: 0 24px 60px rgba(15,27,42,.24);

  /* the frosted materials the top bar is made of */
  --glass:      rgba(255,255,255,.72);
  --glass-solid:rgba(255,255,255,.94);
  --blur:       saturate(180%) blur(16px);
  --spectrum:   linear-gradient(90deg, var(--brand) 0%, var(--brand-2) 52%, var(--brand-3) 100%);
  --grad:       linear-gradient(135deg, #4d7bf8, var(--brand-2));

  --focus: 0 0 0 3px rgba(59,110,246,.28);
  --t: .16s cubic-bezier(.4,.2,.2,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 520px at 6% -6%, rgba(77,123,248,.13) 0%, transparent 60%),
    radial-gradient(760px 460px at 104% 8%, rgba(123,92,250,.11) 0%, transparent 58%),
    radial-gradient(700px 420px at 50% 108%, rgba(41,195,224,.09) 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#app { display: flex; flex-direction: column; height: 100%; }
.hidden { display: none !important; }
.muted { color: var(--ink-3); }
a { color: var(--brand-ink); text-underline-offset: 2px; }
::selection { background: rgba(59,110,246,.22); }

/* thin, unobtrusive scrollbars */
* { scrollbar-width: thin; scrollbar-color: #c3cddb transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #c9d3e0; border: 3px solid transparent; background-clip: content-box; border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: #aebbcc; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------------- controls ---------------- */
button {
  font: inherit; font-weight: 500; cursor: pointer; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 6px 13px;
  box-shadow: var(--sh1);
  transition: background var(--t), border-color var(--t), box-shadow var(--t), transform var(--t);
}
button:hover { background: var(--surface); border-color: #c6d0de; box-shadow: var(--sh2); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--brand); }
button:disabled { opacity: .45; cursor: default; transform: none; }
button.danger { color: var(--bad); border-color: var(--bad-line); }
button.danger:hover { background: var(--bad-soft); border-color: #e6a9a3; }
button.amber { color: var(--warn); border-color: var(--warn-line); background: var(--warn-soft); }
button.primary {
  color: #fff; font-weight: 600; border-color: transparent;
  background: var(--grad);
  box-shadow: 0 2px 10px rgba(87,92,246,.32);
}
button.primary:hover { filter: brightness(1.06); border-color: transparent; box-shadow: 0 4px 16px rgba(87,92,246,.4); }
button.primary:disabled { background: #b9c7e4; box-shadow: none; }

input[type=text], input[type=number], input[type=email], input[type=password],
input:not([type]), select, .route-name-input {
  font: inherit; width: 100%;
  padding: 7px 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r1);
  transition: border-color var(--t), box-shadow var(--t);
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input::placeholder { color: var(--ink-3); }
input[type=checkbox] { accent-color: var(--brand); width: 15px; height: 15px; }

#stops-list .stop-actions button, .od-rowacts button, .au-acts button,
.tc-acts button, .ce-actions button, .vias-row button {
  border-radius: 999px;
}

.linkbtn {
  border: 0; background: none; padding: 2px 4px; font-size: 12px; font-weight: 500;
  color: var(--ink-3); text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.linkbtn:hover { background: none; color: var(--bad); }

.pill {
  display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; padding: 2px 7px; border-radius: 999px;
  background: var(--surface-3); color: var(--ink-2);
}
.pill.amber { background: var(--warn-soft); color: var(--warn); }
.pill.blue { background: var(--brand-soft); color: var(--brand-ink); }

/* ---------------- sign-in ---------------- */
#auth-gate {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(77,123,248,.55) 0%, transparent 62%),
    radial-gradient(780px 480px at 108% 108%, rgba(123,92,250,.45) 0%, transparent 60%),
    #0b1626;
}
.auth-card {
  width: min(380px, 92vw); background: var(--surface); border-radius: var(--r3);
  padding: 26px 24px; box-shadow: var(--sh3);
}
.auth-brand {
  display: flex; align-items: center; justify-content: center; gap: 11px;
  font-size: 22px; font-weight: 650; margin-bottom: 20px; letter-spacing: -.025em;
}
.auth-brand .mark { border-radius: 12px; box-shadow: 0 6px 18px rgba(87,92,246,.4); }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 16px; padding: 3px; background: var(--surface-3); border-radius: 10px; }
.auth-tabs button { flex: 1; padding: 7px 0; border: 0; background: none; border-radius: 7px; color: var(--ink-2); }
.auth-tabs button:hover { background: #e8edf5; }
.auth-tabs button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--sh1); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.auth-form button.primary { margin-top: 4px; padding: 10px 0; border-radius: 10px; }
.auth-form .hint { font-size: 12px; color: var(--ink-3); margin: 2px 0 0; }
.auth-msg {
  margin-top: 14px; padding: 9px 11px; border-radius: 10px; font-size: 13px;
  background: var(--bad-soft); border: 1px solid var(--bad-line); color: var(--bad);
}
.auth-msg.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }

/* ---------------- top bar ---------------- */
#topbar {
  position: relative; z-index: 900; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 11px 18px 10px; color: var(--ink);
  background: rgba(255,255,255,.78);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}
/* a hairline of brand colour along the very top edge */
#topbar::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-2) 52%, var(--brand-3) 100%);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark { display: block; border-radius: 9px; box-shadow: 0 3px 12px rgba(87,92,246,.34); }
.wordmark {
  font-size: 18px; font-weight: 650; letter-spacing: -.03em;
  background: linear-gradient(96deg, #16233a 15%, #3d5bd6 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.user-menu { position: relative; }
.user-menu-btn {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  border-radius: 999px; padding: 4px 13px 4px 4px; font-weight: 500;
  box-shadow: var(--sh1);
}
.user-menu-btn:hover { background: var(--surface); border-color: #c6d0de; box-shadow: var(--sh2); }
.avatar {
  width: 27px; height: 27px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #4d7bf8, var(--brand-2));
}
.user-menu-btn.is-admin .avatar { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px rgba(59,110,246,.5); }
.chip-role {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--brand-ink); background: var(--brand-soft); padding: 2px 6px; border-radius: 999px;
}
.user-menu-btn .caret { font-size: 9px; color: var(--ink-3); transition: transform var(--t); }
.user-menu-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }
.user-menu-list {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 1200;
  min-width: 208px; color: var(--ink);
  background: var(--glass-solid); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-radius: var(--r2); padding: 6px;
  box-shadow: var(--sh2); display: flex; flex-direction: column; gap: 1px;
}
.user-menu-list button {
  width: 100%; text-align: left; background: none; border: 0;
  padding: 8px 10px; border-radius: 8px; font-weight: 500;
}
.user-menu-list button:hover { background: var(--brand-soft); color: var(--brand-ink); }
.user-menu-list #btn-signout { color: var(--bad); }
.user-menu-list #btn-signout:hover { background: var(--bad-soft); color: var(--bad); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 2px; }

.banner {
  flex: 0 0 auto; background: var(--warn-soft); border-bottom: 1px solid var(--warn-line);
  color: var(--warn); padding: 9px 18px; font-size: 12.5px;
}

/* ---------------- layout ---------------- */
#layout { flex: 1; display: grid; grid-template-columns: 268px 1fr 412px; min-height: 0; }
#sidebar { border-right: 1px solid var(--line); background: rgba(255,255,255,.55); overflow: auto; }
#map { min-height: 0; }
#panel { border-left: 1px solid var(--line); background: rgba(255,255,255,.55); overflow: auto; padding: 14px; }

/* ---------------- sidebar ---------------- */
.side-head {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 12px 10px; font-weight: 600;
  background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line);
}
.side-toggles {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.side-toggles label { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 5px; cursor: pointer; }
#route-list { padding: 10px; display: flex; flex-direction: column; gap: 7px; }

.route-card {
  border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface);
  padding: 10px 11px; cursor: pointer; display: grid;
  grid-template-columns: 10px 1fr auto; column-gap: 9px; row-gap: 3px; align-items: center;
  box-shadow: var(--sh1);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.route-card:hover { border-color: #c0cbdb; box-shadow: var(--sh2); transform: translateY(-1px); }
.route-card.active {
  border-color: transparent;
  background: linear-gradient(#fff, #fff) padding-box, var(--grad) border-box;
  box-shadow: 0 0 0 3px rgba(87,92,246,.13), var(--sh2);
}
.route-card .dot { width: 10px; height: 10px; border-radius: 50%; grid-row: 1 / span 2; box-shadow: 0 0 0 3px #fff, 0 0 0 4px rgba(15,27,42,.08); }
.route-card .rc-name { grid-column: 2; grid-row: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-card .rc-meta { grid-column: 2; grid-row: 2; font-size: 11.5px; color: var(--ink-3); }
.route-card .rc-urgent { grid-column: 3; grid-row: 1; }
.route-card .rc-free { grid-column: 3; grid-row: 2; justify-self: end; }
.route-card[draggable="true"] { cursor: grab; }
.route-card[draggable="true"]:active { cursor: grabbing; }
.route-card.dragging { opacity: .4; }
.route-card.drop-over { border-color: var(--brand); box-shadow: 0 -2px 0 var(--brand) inset, var(--sh1); }
.route-card.urgent { border-color: var(--bad-line); background: linear-gradient(180deg, #fffafa, var(--surface)); }

.rc-urgent {
  width: 22px; height: 22px; padding: 0; line-height: 1;
  border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface);
  color: #c3ccd8; font-weight: 800; font-size: 13px;
}
.rc-urgent:hover { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.rc-urgent.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.rc-urgent.on:hover { background: #a92a22; color: #fff; }

.rc-free { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.rc-free.ok { background: var(--ok-soft); color: var(--ok); }
.rc-free.low { background: var(--warn-soft); color: var(--warn); }
.rc-free.full { background: var(--bad-soft); color: var(--bad); }

/* ---------------- panel ---------------- */
.panel-empty { color: var(--ink-3); padding: 24px 6px; }
.route-name-input {
  font-size: 16px; font-weight: 600; margin-bottom: 10px; padding: 9px 11px;
  background: var(--surface); letter-spacing: -.01em;
}
.panel-summary { min-height: 20px; margin-bottom: 10px; }
.big-sum {
  position: relative; overflow: hidden;
  display: flex; align-items: baseline; gap: 12px;
  background: var(--glass-solid); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-radius: var(--r2); padding: 13px 15px;
  box-shadow: var(--sh1);
}
.big-sum::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--spectrum); }
.big-sum .bs-km { font-size: 23px; font-weight: 700; letter-spacing: -.02em; }
.big-sum .bs-dur { font-size: 16px; font-weight: 600; color: var(--ink-2); }
.big-sum .bs-delay { font-size: 12px; font-weight: 700; color: var(--bad); }
.big-sum .bs-clear { font-size: 12px; font-weight: 700; color: var(--ok); }
.big-sum .bs-n { font-size: 12px; color: var(--ink-3); margin-left: auto; }

.stops-head { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.stops-head > span:first-child { margin-right: auto; }

/* what the route is doing, where the Calculate button used to be */
.calc-status {
  display: none; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 500; color: var(--ink-3);
}
.calc-status.show { display: inline-flex; }
.calc-status.busy::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand); animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }

#btn-order { font-size: 12.5px; padding: 5px 11px; }

#stops-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; counter-reset: s; }
#stops-list li {
  display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 7px 8px 7px 6px;
  flex-wrap: wrap; box-shadow: var(--sh1);
  transition: border-color var(--t), box-shadow var(--t);
}
#stops-list li:hover { border-color: #c8d2e0; }
#stops-list li.dragging { opacity: .4; }
#stops-list li.over { border-color: var(--brand); box-shadow: 0 -2px 0 var(--brand) inset; }
#stops-list li.editing, #stops-list li.cargo-open { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59,110,246,.14); }
#stops-list li::before {
  counter-increment: s; content: counter(s);
  min-width: 22px; height: 22px; border-radius: 50%;
  background: var(--grad); color: #fff;
  font-size: 11.5px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(87,92,246,.35);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
#stops-list .handle { cursor: grab; color: #b7c1cf; user-select: none; letter-spacing: -2px; }
#stops-list .handle:hover { color: var(--ink-3); }
#stops-list .stop-label {
  flex: 1; min-width: 0; cursor: pointer; line-height: 1.32;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
#stops-list .stop-label:hover { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
#stops-list .stop-actions { display: flex; gap: 3px; flex: 0 0 auto; }
#stops-list .stop-actions button { padding: 2px 6px; font-size: 12px; border-color: var(--line); color: var(--ink-2); }
#stop-search.editing { border-color: var(--brand); box-shadow: var(--focus); }

.stop-role {
  display: inline-block; font-size: 9.5px; font-weight: 800; letter-spacing: .05em;
  padding: 1px 5px; border-radius: 5px; margin-right: 6px; vertical-align: 1px;
}
.stop-role.load { background: var(--ok-soft); color: var(--ok); }
.stop-role.unload { background: var(--surface-3); color: var(--ink-2); }
.stop-when { display: block; font-size: 11px; color: var(--ink-3); }

/* ---------------- search box ---------------- */
.add-stop { position: relative; margin-bottom: 12px; }
.ac-results {
  position: absolute; left: 0; right: 0; top: 40px; z-index: 500;
  background: var(--glass-solid); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-radius: var(--r2);
  max-height: 260px; overflow: auto; box-shadow: var(--sh2);
}
.ac-results div { padding: 8px 11px; cursor: pointer; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 8px; }
.ac-results div:last-child { border-bottom: 0; }
.ac-results div:hover { background: var(--brand-soft); }
.ac-results .ac-label { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ac-results .ac-label b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-results .ac-label small { font-size: 11px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-results .ac-type { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); white-space: nowrap; }
.ac-results .ac-type.biz { color: var(--ok); background: var(--ok-soft); padding: 2px 7px; border-radius: 999px; font-weight: 700; }
.ac-results div.is-biz:hover { background: var(--ok-soft); }
.ac-results .ac-hint { display: block; font-size: 11.5px; color: var(--warn); background: var(--warn-soft); padding: 7px 10px; cursor: default; }
.ac-results .ac-hint:hover { background: var(--warn-soft); }
.click-add { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); margin-top: 8px; cursor: pointer; }

/* ---------------- messages, legs, profile ---------------- */
.calc-error {
  background: var(--bad-soft); border: 1px solid var(--bad-line); color: var(--bad);
  padding: 8px 11px; border-radius: 10px; margin-bottom: 10px; font-size: 13px;
}
.calc-error.as-hint { background: var(--brand-soft); border-color: #d5e2fb; color: var(--brand-ink); }
.notice {
  background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn);
  padding: 7px 10px; border-radius: 10px; margin-bottom: 8px; font-size: 12.5px;
}
.vias-row { font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.vias-row button { padding: 2px 8px; margin-left: 6px; font-size: 12px; }

.legs { display: flex; flex-direction: column; margin-bottom: 12px; }
.leg {
  display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px;
  padding: 6px 0; border-bottom: 1px solid var(--line);
}
.leg:last-child { border-bottom: 0; }

.truck-profile {
  border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface);
  padding: 4px 12px; margin-bottom: 12px; box-shadow: var(--sh1);
}
.truck-profile summary { cursor: pointer; padding: 8px 0; font-weight: 600; }
.truck-profile summary::marker { color: var(--ink-3); }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 8px 0; }
.profile-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--ink-2); }
.profile-grid label.chk { flex-direction: row; align-items: center; gap: 7px; }
.profile-grid label.chk input { width: auto; }
.profile-grid .prof-clear { grid-column: 1 / -1; font-size: 12px; }
.sub-head { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 10px 0 2px; font-weight: 600; }

.panel-foot { display: flex; gap: 7px; flex-wrap: wrap; }
.updated-by { font-size: 11px; color: var(--ink-3); margin-top: 10px; }

/* ---------------- load / capacity ---------------- */
.load-box {
  position: relative; overflow: hidden;
  background: var(--glass-solid); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-radius: var(--r2);
  padding: 13px 15px; margin-bottom: 12px; box-shadow: var(--sh1);
}
.load-box::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, #3fa46a, #2f8d59);
}
.load-box.over::before { background: linear-gradient(180deg, #d9483b, #b7302a); }
.load-box.over { border-color: var(--bad-line); background: linear-gradient(180deg, #fefaf9, var(--glass-solid)); }
.load-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.load-truck { font-size: 11.5px; color: var(--ink-2); }
.load-free { font-size: 16px; font-weight: 700; color: var(--ok); letter-spacing: -.01em; }
.load-box.over .load-free { color: var(--bad); }
.load-row { display: flex; align-items: center; gap: 10px; font-size: 11.5px; margin-top: 5px; }
.load-row .lr-k { width: 46px; color: var(--ink-3); }
.load-row .lr-v { width: 110px; text-align: right; color: var(--ink-2); white-space: nowrap; }
.load-row .bar { flex: 1; height: 8px; background: rgba(15,27,42,.08); border-radius: 99px; overflow: hidden; }
.load-row .bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #3fa46a, #2f8d59); transition: width var(--t); }
.load-box.over .bar i { background: linear-gradient(90deg, #d9483b, #c0342a); }
.load-hint { font-size: 11.5px; color: var(--ink-3); margin-top: 8px; }

/* ---------------- per-stop cargo ---------------- */
.cargo-badge {
  flex: 0 0 auto; font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px dashed var(--line-2); background: var(--surface); color: var(--ink-3); white-space: nowrap;
}
.cargo-badge:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.cargo-badge.load { border-style: solid; border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.cargo-badge.unload { border-style: solid; border-color: var(--bad-line); background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.onboard { flex: 0 0 100%; font-size: 10.5px; color: var(--ink-3); padding-left: 30px; margin-top: 2px; }
.onboard.over { color: var(--bad); font-weight: 600; }

.cargo-edit {
  flex: 0 0 100%; margin-top: 8px; padding-top: 9px; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.cargo-edit label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--ink-2); }
.cargo-edit label.wide { grid-column: 1 / -1; }
.cargo-edit input { font-size: 12.5px; padding: 5px 8px; }
.ce-dir { grid-column: 1 / -1; display: flex; gap: 5px; }
.ce-dir button { flex: 1; font-size: 12px; padding: 5px 0; }
.ce-dir button.on { background: var(--grad); color: #fff; border-color: transparent; }
.ce-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 7px; }
.ce-actions button { font-size: 12px; padding: 4px 12px; }

/* ---------------- truck picker ---------------- */
.truck-picker { display: flex; gap: 7px; flex-wrap: wrap; margin: 8px 0 10px; }
.truck-picker .tk {
  flex: 1 1 72px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 6px; font-size: 13px; font-weight: 600; border-radius: 10px;
}
.truck-picker .tk small { font-size: 10px; font-weight: 400; color: var(--ink-3); }
.truck-picker .tk.on {
  background: var(--grad); color: #fff; border-color: transparent;
  box-shadow: 0 3px 12px rgba(87,92,246,.34);
}
.truck-picker .tk.on small { color: rgba(255,255,255,.75); }
.cap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding-bottom: 6px; }
.cap-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--ink-2); }

/* ---------------- map ---------------- */
.num-marker div {
  width: 28px; height: 28px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  border: 2.5px solid #fff; box-shadow: 0 2px 8px rgba(15,27,42,.35);
}
.via-marker div {
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  border: 3px solid var(--navy); box-shadow: 0 1px 5px rgba(15,27,42,.4); cursor: grab;
}
.leaflet-interactive.route-line:hover { cursor: grab; }
.leaflet-control-zoom a, .leaflet-bar a {
  border-radius: 9px !important; color: var(--ink) !important;
  background: var(--glass-solid) !important; backdrop-filter: var(--blur);
}
.leaflet-control-zoom a:hover, .leaflet-bar a:hover { background: #fff !important; }
.leaflet-bar { border: 1px solid var(--line) !important; box-shadow: var(--sh2) !important; border-radius: 10px !important; overflow: hidden; }
.leaflet-control-attribution {
  background: rgba(255,255,255,.7) !important; backdrop-filter: blur(6px);
  border-radius: 8px 0 0 0; padding: 2px 7px !important; color: var(--ink-3) !important;
}
.pegman-box { box-shadow: var(--sh2); border: 1px solid var(--line); }

/* ---------------- dialogs (shared) ---------------- */
dialog { color: var(--ink); }
dialog::backdrop { background: rgba(9,18,30,.55); backdrop-filter: blur(3px); }
#settings-dialog, #newroute-dialog {
  position: relative; overflow: hidden;   /* keeps the spectrum edge inside the rounded corner */
  border: 1px solid var(--line); border-radius: var(--r3); padding: 0;
  box-shadow: var(--sh3);
  background: var(--glass-solid); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  max-height: 92vh;
}
/* the form inside is what scrolls, so the coloured top edge stays put */
#settings-dialog > form, #newroute-dialog > form {
  max-height: 92vh; overflow-y: auto; padding: 24px 22px 22px;
}
#settings-dialog::before, #newroute-dialog::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--spectrum);
}
#settings-dialog { width: min(480px, 92vw); }
#newroute-dialog { width: min(400px, 92vw); }
#settings-dialog h3, #newroute-dialog h3 { margin: 0 0 12px; font-size: 17px; letter-spacing: -.01em; }
#settings-dialog h4, #newroute-dialog h4 {
  margin: 18px 0 7px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-3); font-weight: 700;
}
#settings-dialog label.stack, #newroute-dialog label.stack { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
#settings-dialog .hint, #newroute-dialog .hint { font-size: 12px; color: var(--ink-3); margin: 7px 0 0; }
#settings-dialog menu, #newroute-dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 18px 0 0; }

.herekey-box { display: flex; gap: 7px; }
.herekey-box input { flex: 1; }
#herekey-status { min-height: 14px; }

.admin-users { display: flex; flex-direction: column; gap: 7px; max-height: 280px; overflow: auto; }
.au-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--r2); padding: 9px 11px; background: var(--surface-2);
}
.au-main { font-size: 13px; }
.au-acts { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.au-acts button { font-size: 12px; padding: 3px 9px; }

.tilecache-box { font-size: 12.5px; color: var(--ink-2); }
.tc-line { padding: 2px 0; }
.tc-line b { color: var(--ink); }
.tc-acts { display: flex; gap: 8px; margin-top: 9px; }
.tc-acts button { font-size: 12px; padding: 4px 10px; }

/* ---------------- Street View ---------------- */
#streetview-dialog { border: 0; border-radius: var(--r3); padding: 0; width: min(680px, 94vw); overflow: hidden; box-shadow: var(--sh3); }
.sv-wrap { display: flex; flex-direction: column; }
.sv-head, .pi-head, .od-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; color: var(--ink); font-size: 13.5px; font-weight: 600;
  background: var(--surface); border-bottom: 1px solid var(--line); position: relative;
}
.sv-head::before, .pi-head::before, .od-head::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2) 55%, var(--brand-3));
}
.sv-head button, .pi-head button, .od-head button {
  background: var(--surface); border-color: var(--line); color: var(--ink-3); padding: 3px 9px;
}
.sv-head button:hover, .pi-head button:hover, .od-head button:hover { background: var(--surface-3); color: var(--ink); }
.sv-imgbox { background: #0b1520; min-height: 200px; display: flex; align-items: center; justify-content: center; }
.sv-imgbox img { display: block; max-width: 100%; }
.sv-controls { display: flex; gap: 7px; align-items: center; padding: 10px 14px; background: var(--glass); }
.sv-controls button { min-width: 40px; }
.sv-open { margin-left: auto; font-size: 13px; text-decoration: none; color: var(--brand-ink); font-weight: 500; }
.sv-note { padding: 0 14px 12px; font-size: 12.5px; color: var(--bad); }
.sv-note:empty { display: none; }

.pegman-box {
  background: var(--surface); width: 34px; height: 40px; display: flex;
  align-items: center; justify-content: center; cursor: grab; border-radius: 8px;
}
.pegman-box:hover { background: var(--surface-3); }
.pegman-box:active { cursor: grabbing; }
.pegman-ghost { position: fixed; z-index: 4000; pointer-events: none; filter: drop-shadow(0 3px 6px rgba(0,0,0,.45)); opacity: .95; }
#map.pegman-dropping, #map.pegman-dropping .leaflet-container { cursor: crosshair; }

/* ---------------- Google place card ---------------- */
#placeinfo-dialog { border: 0; border-radius: var(--r3); padding: 0; width: min(480px, 94vw); overflow: hidden; box-shadow: var(--sh3); }
.pi-body { padding: 14px 16px 16px; max-height: 70vh; overflow: auto; background: var(--glass-solid); }
.pi-name { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.pi-type { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.pi-sec { margin-top: 10px; font-size: 13px; }
.pi-sec b { display: block; margin-bottom: 4px; }
.pi-open { font-size: 11px; font-weight: 700; color: var(--ok); background: var(--ok-soft); padding: 2px 8px; border-radius: 999px; }
.pi-shut { font-size: 11px; font-weight: 700; color: var(--bad); background: var(--bad-soft); padding: 2px 8px; border-radius: 999px; }
.pi-hours { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--ink-2); }
.pi-hours li { padding: 2px 0; }
.pi-hours li.today { font-weight: 700; color: var(--ink); }
.pi-none { color: var(--ink-3); font-size: 13px; margin: 0 0 8px; }
.pi-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.pi-link { font-size: 13px; color: var(--brand-ink); text-decoration: none; font-weight: 500; }
.pi-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 12px; }
.pi-photos img { width: 100%; border-radius: 10px; display: block; }
.pi-matchlist { display: flex; flex-direction: column; gap: 6px; margin-top: 5px; }
.pi-match {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.pi-match:hover { border-color: var(--brand); background: var(--brand-soft); }
.pi-match .pm-name { font-weight: 600; font-size: 13px; }
.pi-match .pm-addr { font-size: 11.5px; color: var(--ink-3); }

/* ---------------- order screenshot → route ---------------- */
#order-dialog { border: 0; border-radius: var(--r3); padding: 0; width: min(1000px, 96vw); overflow: hidden; box-shadow: var(--sh3); }
.od-step { padding: 16px; max-height: 78vh; overflow: auto; background: var(--glass-solid); }
.od-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 16px 0 0; }
.od-msg { margin-top: 12px; font-size: 12.5px; padding: 9px 11px; border-radius: 10px; }
.od-msg.bad { background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad-line); }
.od-msg.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.od-msg.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-line); }

.od-drop {
  border: 2px dashed #c3d0e6; border-radius: var(--r2);
  background: linear-gradient(180deg, #f8fbff, #f1f6ff);
  padding: 30px 16px; text-align: center; cursor: pointer; outline: none;
  transition: border-color var(--t), background var(--t);
}
.od-drop:hover, .od-drop:focus, .od-drop.over { border-color: var(--brand); background: var(--brand-soft); }
.od-drop-big { font-size: 15px; font-weight: 600; }
.od-drop-big kbd {
  font: inherit; font-size: 12px; background: var(--surface); border: 1px solid var(--line-2);
  border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px;
}
.od-drop-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 7px; }
.od-thumbs { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 12px; }
.od-thumb { position: relative; }
.od-thumb img { height: 100px; border: 1px solid var(--line); border-radius: 10px; display: block; box-shadow: var(--sh1); }
.od-thumb button { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; padding: 0; border-radius: 50%; line-height: 1; box-shadow: var(--sh1); }
.od-hint-lbl { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; margin-top: 14px; color: var(--ink-2); }
.od-busy { display: flex; align-items: center; gap: 11px; font-size: 15px; padding: 28px 0 6px; }
.spinner {
  width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; display: inline-block; animation: od-spin .8s linear infinite;
}
@keyframes od-spin { to { transform: rotate(360deg); } }

.od-summary { font-size: 13px; margin-bottom: 12px; }
.od-sum-line { padding: 1px 0; }
.od-sum-line.over { color: var(--bad); }
.od-sum-cost { font-size: 11.5px; color: var(--ink-3); }
.od-notes { font-size: 12.5px; color: var(--ink-2); background: var(--surface-3); border-radius: 10px; padding: 9px 11px; margin-top: 12px; }
.od-notes:empty { display: none; }

.od-rows { display: flex; flex-direction: column; gap: 8px; }
.od-row {
  display: grid; grid-template-columns: 22px 66px 1fr 214px; gap: 9px; align-items: start;
  border: 1px solid var(--line); border-radius: var(--r2); padding: 9px 10px;
  background: var(--surface); box-shadow: var(--sh1);
}
.od-row.off { opacity: .45; background: var(--surface-3); box-shadow: none; }
.od-inc { display: flex; justify-content: center; padding-top: 6px; }
.od-kind {
  font-size: 10px; font-weight: 800; letter-spacing: .06em; padding: 6px 0; border-radius: 8px;
  border: 1px solid transparent;
}
.od-kind.load { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.od-kind.unload { background: var(--surface-3); color: var(--ink-2); border-color: var(--line-2); }
.od-fields { display: grid; grid-template-columns: 1.3fr 2fr 48px 1.1fr; gap: 6px; }
.od-fields input { font-size: 12.5px; padding: 5px 8px; }
.od-fields .od-goods { grid-column: 1 / -1; }
.od-num { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--ink-3); }
.od-num input { width: 100%; min-width: 54px; }
.od-side { display: flex; flex-direction: column; gap: 6px; }
.od-geo { font-size: 11.5px; line-height: 1.35; min-height: 15px; }
.od-geo.ok { color: var(--ok); }
.od-geo.bad { color: var(--bad); }
.od-geo.busy { color: var(--ink-3); }
.od-rowacts { display: flex; gap: 6px; }
.od-rowacts button { font-size: 11.5px; padding: 3px 9px; }

.od-target { display: flex; flex-direction: column; gap: 5px; margin-top: 14px; font-size: 13px; }
.od-dest b { color: var(--brand-ink); }
.od-target-hint { font-size: 11.5px; color: var(--ink-3); }
.od-create { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.od-create.hidden { display: none; }
.od-create label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.od-create input { font-weight: 400; min-width: 240px; }

/* ---------------- narrow screens ---------------- */
@media (max-width: 1100px) { #layout { grid-template-columns: 240px 1fr 380px; } }
@media (max-width: 950px) {
  #layout { grid-template-columns: 1fr; grid-auto-rows: minmax(240px, auto); }
  #map { min-height: 300px; }
  #sidebar, #panel { border: 0; border-top: 1px solid var(--line); }
}

/* FULL: a plain button until it is on, then it shouts */
#btn-full { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; padding: 5px 11px; color: var(--ink-3); }
#btn-full:hover { color: var(--ink); }
#btn-full.on {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, #d9483b, #b7302a);
  box-shadow: 0 2px 10px rgba(192,52,42,.35);
}
#btn-full.on:hover { filter: brightness(1.06); }

/* the line between trucks still being worked and trucks that are settled */
.route-divider {
  display: flex; align-items: center; gap: 8px;
  margin: 6px 2px 2px; padding: 2px 0;
  font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3); user-select: none;
}
.route-divider::before, .route-divider::after { content: ''; flex: 1; height: 1px; background: var(--line-2); }
.route-divider.drop-over { color: var(--brand); }
.route-divider.drop-over::before, .route-divider.drop-over::after { background: var(--brand); height: 2px; }
.route-card.parked { opacity: .7; }
.route-card.parked:hover { opacity: 1; }

/* IN TRANSIT sits next to the ! flag */
.rc-top { grid-column: 3; grid-row: 1; display: flex; align-items: center; gap: 6px; }
.rc-transit {
  font-size: 9px; font-weight: 800; letter-spacing: .05em;
  padding: 2px 6px; border-radius: 999px; white-space: nowrap;
  background: var(--brand-soft); color: var(--brand-ink);
}
#btn-transit { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; padding: 5px 10px; color: var(--ink-3); }
#btn-transit:hover { color: var(--ink); }
#btn-transit.on {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, #4d7bf8, var(--brand-2));
  box-shadow: 0 2px 10px rgba(87,92,246,.35);
}
#btn-transit.on:hover { filter: brightness(1.06); }
