/* PestCore — the dispatch desk.
 *
 * Used all day, in bright light, by people scanning for the one broken thing
 * among twenty fine ones. So: quiet chrome, loud exceptions, and identifiers
 * set in a monospace because in this trade almost everything is a code —
 * station numbers, EPA registrations, licence classes, invoice numbers.
 *
 * The signature is the route rail on the dispatch board: stops threaded by a
 * continuous line whose colour encodes drive distance, so a badly sequenced
 * day reads as a shape before you read a word of it.
 */

:root {
  /* Ink is a very dark green-black, not neutral — it ties the interface to
     the pine accent instead of floating on generic grey. */
  --ink:        #16211C;
  --ink-2:      #3D4A44;
  --muted:      #6E7A74;
  --faint:      #939C97;

  --line:       #D9DEDB;
  --line-soft:  #E9ECEA;
  --surface:    #FFFFFF;
  --canvas:     #F1F3F2;
  --sunk:       #E7EAE8;

  --pine:       #0E4F48;
  --pine-deep:  #093632;

  --moss:       #2C6B45;  --moss-wash:  #E3F0E8;
  --clay:       #9A5B12;  --clay-wash:  #FBF0DE;
  --brick:      #A3342C;  --brick-wash: #FAE8E6;
  --slate:      #2C5878;  --slate-wash: #E6EEF5;
  --plum:       #4A4194;  --plum-wash:  #EBEAF6;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --r: 6px;  --r-s: 4px;

  /* One soft shadow, used sparingly. Depth is a signal, not a texture. */
  --lift:   0 1px 2px rgba(22,33,28,.05), 0 1px 3px rgba(22,33,28,.04);
  --lift-2: 0 2px 6px rgba(22,33,28,.07), 0 8px 20px rgba(22,33,28,.06);
}

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

body {
  font-family: var(--sans);
  font-size: 14px; line-height: 1.5;
  color: var(--ink); background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--pine); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; border-radius: var(--r-s); }

/* ---------------- top bar ---------------- */

.topbar {
  background: var(--ink); color: #fff;
  display: flex; align-items: stretch;
  padding: 0 14px; height: 50px;
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 1px 0 rgba(0,0,0,.2);
}
.brand {
  display: flex; align-items: center;
  font-weight: 700; font-size: 15.5px; letter-spacing: -0.025em;
  color: #fff; padding-right: 18px; margin-right: 4px; white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,.11);
}
.brand span { color: #79C4B7; }

/* Twelve destinations is a lot to scan, so they are grouped by what you'd be
   doing: running today, then records, then money. Hairlines do the grouping. */
.nav { display: flex; align-items: stretch; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: flex; align-items: center; color: #AEB9B4;
  padding: 0 12px; font-size: 13.5px; white-space: nowrap;
  position: relative; transition: color .12s ease;
}
.nav a:hover { color: #fff; text-decoration: none; }
.nav a.on { color: #fff; font-weight: 600; }
.nav a.on::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: 0;
  height: 2px; background: #79C4B7; border-radius: 2px 2px 0 0;
}
.nav .sep { width: 1px; background: rgba(255,255,255,.11); margin: 14px 7px; flex: none; }

.topbar-right {
  display: flex; align-items: center; gap: 12px;
  font-size: 12.5px; color: #98A39E;
  padding-left: 14px; border-left: 1px solid rgba(255,255,255,.11); white-space: nowrap;
}
.topbar-right form { display: inline; }
.linkbtn {
  background: none; border: 0; color: #98A39E; cursor: pointer;
  font-size: 12.5px; font-family: inherit; padding: 0;
}
.linkbtn:hover { color: #fff; text-decoration: underline; }

.wrap { max-width: 1440px; margin: 0 auto; padding: 22px 18px 72px; }

/* ---------------- page headers ---------------- */

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-head h1 { font-size: 25px; margin: 0 0 3px; letter-spacing: -0.022em; font-weight: 700; line-height: 1.15; }
.page-head p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 68ch; }
.page-head > div:last-child { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); font-weight: 700; margin-bottom: 5px;
}
.eyebrow a { color: var(--muted); }
.eyebrow a:hover { color: var(--pine); }

/* ---------------- cards ---------------- */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); margin-bottom: 16px;
  box-shadow: var(--lift); overflow: hidden;
}
.card-head {
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(var(--surface), #FCFDFC);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h2 {
  font-size: 11.5px; margin: 0; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2);
}
.card-head .num, .card-head .count {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  background: var(--sunk); padding: 2px 7px; border-radius: 10px;
}
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

/* ---------------- tables ---------------- */

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted); font-weight: 700;
  padding: 9px 16px; border-bottom: 1px solid var(--line);
  background: #FAFBFA; white-space: nowrap;
}
td { padding: 11px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s ease; }
tbody tr:hover { background: #FAFBFA; }
td.right, th.right { text-align: right; }

/* Identifiers are codes in this trade — set them as codes. */
.num, .mono { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ---------------- stat tiles ---------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--line); border-radius: var(--r);
  padding: 13px 15px; box-shadow: var(--lift);
}
.stat .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.stat .v { font-family: var(--mono); font-size: 27px; font-weight: 600; margin-top: 4px; letter-spacing: -0.03em; line-height: 1.1; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat.is-alert { border-left-color: var(--brick); }
.stat.is-warn  { border-left-color: var(--clay); }
.stat.is-ok    { border-left-color: var(--moss); }

/* ---------------- badges ---------------- */

.badge {
  display: inline-block; padding: 2.5px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 650; letter-spacing: .015em;
  white-space: nowrap; border: 1px solid transparent; line-height: 1.4;
}
.badge-scheduled  { background: var(--sunk);       color: var(--ink-2); border-color: #D5DBD8; }
.badge-dispatched { background: var(--slate-wash); color: var(--slate); border-color: #CBDDEB; }
.badge-in_progress{ background: var(--clay-wash);  color: var(--clay);  border-color: #EFDFBE; }
.badge-completed  { background: var(--moss-wash);  color: var(--moss);  border-color: #C6E2D1; }
.badge-no_access  { background: var(--brick-wash); color: var(--brick); border-color: #EFCFCB; }
.badge-skipped, .badge-cancelled { background: var(--sunk); color: var(--faint); border-color: #DDE2DF; }
.badge-active     { background: var(--moss-wash);  color: var(--moss);  border-color: #C6E2D1; }
.badge-suspended  { background: var(--clay-wash);  color: var(--clay);  border-color: #EFDFBE; }
.badge-commercial { background: var(--plum-wash);  color: var(--plum);  border-color: #D7D4EE; }
.badge-alert      { background: var(--brick-wash); color: var(--brick); border-color: #EFCFCB; }

/* ============================================================
   THE ROUTE RAIL — dispatch board signature
   ============================================================ */

.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; align-items: start; }

.col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--lift); overflow: hidden; }
.col-head {
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: linear-gradient(var(--surface), #FAFBFA);
}
.col-head strong { font-size: 13.5px; letter-spacing: -0.01em; }
.col-head .count { font-family: var(--mono); font-size: 11.5px; color: var(--muted); background: var(--sunk); padding: 2px 8px; border-radius: 10px; }
.col.over { border-color: #E9C6C2; }
.col.over .col-head { background: var(--brick-wash); }
.col.over .count { background: #F3D4D0; color: var(--brick); }

/* Unassigned work is a problem, not a column. */
.col.is-unassigned { border-color: #E9C6C2; border-style: dashed; }
.col.is-unassigned .col-head { background: var(--brick-wash); }

/* The rail: a continuous spine down the stop list, each segment coloured by
   drive distance from the previous stop. Read the column edge and you know
   whether the day is tight or scattered. */
.stop { padding: 12px 14px 12px 22px; border-bottom: 1px solid var(--line-soft); position: relative; }
.stop:last-child { border-bottom: 0; }
.stop::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 3px; background: var(--line); }
.stop:first-child::before { top: 16px; border-radius: 2px 2px 0 0; }
.stop:last-child::before  { bottom: 16px; border-radius: 0 0 2px 2px; }
.stop::after {
  content: ''; position: absolute; left: 6.5px; top: 16px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff; border: 3px solid var(--line);
}
.stop.p-tight::before { background: var(--moss); }
.stop.p-tight::after  { border-color: var(--moss); }
.stop.p-ok::before    { background: #B6C2BC; }
.stop.p-ok::after     { border-color: #B6C2BC; }
.stop.p-loose::before { background: var(--clay); }
.stop.p-loose::after  { border-color: var(--clay); }
.stop.p-far::before   { background: var(--brick); }
.stop.p-far::after    { border-color: var(--brick); }
.stop.p-unknown::before { background: var(--line); }
.stop.p-unknown::after  { border-color: var(--line); }
.stop.done::after { background: var(--moss); border-color: var(--moss); }
.stop.done .who a { color: var(--muted); }

.stop .who { font-weight: 650; font-size: 13.5px; letter-spacing: -0.01em; }
.stop .where { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.stop .meta { display: flex; gap: 7px; align-items: center; margin-top: 7px; flex-wrap: wrap; font-size: 12px; }
.stop details { margin-top: 8px; }
.stop summary { cursor: pointer; font-size: 12.5px; color: var(--pine); font-weight: 600; list-style: none; }
.stop summary::-webkit-details-marker { display: none; }
.stop summary::before { content: '+ '; font-weight: 400; }
.stop details[open] summary::before { content: '- '; }
.stop details > div { margin-top: 10px; padding: 12px; border-radius: var(--r-s); background: #FAFBFA; border: 1px solid var(--line-soft); }

.leg { font-family: var(--mono); font-size: 11.5px; }
.leg-tight { color: var(--moss); }
.leg-ok    { color: var(--muted); }
.leg-loose { color: var(--clay); font-weight: 700; }
.leg-far   { color: var(--brick); font-weight: 700; }

.legend {
  display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
  font-size: 12.5px; color: var(--muted); margin-bottom: 14px;
  padding: 9px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
}
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: 2px; }

/* ---------------- forms ---------------- */

.field { margin-bottom: 14px; }
.field label, label { display: block; font-size: 12.5px; font-weight: 650; margin-bottom: 5px; color: var(--ink-2); }
.field .hint, .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; line-height: 1.45; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], input[type=search], input[type=file],
select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: var(--r-s);
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: #C2CAC6; }
input:focus, select:focus, textarea:focus {
  border-color: var(--pine); outline: none; box-shadow: 0 0 0 3px rgba(14,79,72,.11);
}
textarea { min-height: 76px; resize: vertical; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }

.checkline {
  display: flex; align-items: center; gap: 8px; font-size: 13.5px;
  margin-bottom: 9px; font-weight: 500; color: var(--ink); cursor: pointer;
}
.checkline input { width: auto; accent-color: var(--pine); }

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 15px; border-radius: var(--r-s);
  border: 1px solid var(--pine); background: var(--pine); color: #fff;
  font-size: 13.5px; font-weight: 650; cursor: pointer;
  font-family: inherit; text-decoration: none; line-height: 1.4;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.btn:hover { background: var(--pine-deep); border-color: var(--pine-deep); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-quiet { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn-quiet:hover { background: #F5F7F6; color: var(--ink); border-color: #C2CAC6; }
.btn-danger { background: #fff; color: var(--brick); border-color: #E5C4C0; }
.btn-danger:hover { background: var(--brick-wash); color: var(--brick); border-color: #DDB2AD; }

/* ---------------- flash ---------------- */

.flash {
  padding: 11px 15px; border-radius: var(--r); margin-bottom: 16px;
  font-size: 13.5px; border: 1px solid; border-left-width: 3px; box-shadow: var(--lift);
}
.flash-success { background: var(--moss-wash);  border-color: #C6E2D1; border-left-color: var(--moss);  color: #1D5334; }
.flash-error   { background: var(--brick-wash); border-color: #EFCFCB; border-left-color: var(--brick); color: #86281F; }

/* ---------------- empty states ---------------- */

.empty { padding: 40px 24px; text-align: center; color: var(--muted); font-size: 13.5px; }
.empty strong { display: block; color: var(--ink); font-size: 15.5px; margin-bottom: 5px; font-weight: 650; letter-spacing: -0.01em; }
.empty .btn { margin-top: 14px; }

/* ---------------- toolbar ---------------- */

.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar form { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search] { min-width: 260px; }
.toolbar input[type=date] { width: auto; }
.toolbar .field { margin: 0; }

/* ---------------- auth ---------------- */

.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: var(--ink);
  background-image: radial-gradient(circle at 50% 0%, #22332C 0%, var(--ink) 60%);
}
.auth-card { background: #fff; border-radius: 10px; padding: 34px; width: 100%; max-width: 390px; box-shadow: var(--lift-2); }
.auth-card h1 { font-size: 21px; margin: 0 0 5px; letter-spacing: -0.02em; }
.auth-card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; line-height: 1.5; }

/* ---------------- responsive ---------------- */

@media (max-width: 820px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .wrap { padding: 16px 12px 56px; }
  th, td { padding: 9px 12px; }
  .page-head h1 { font-size: 21px; }
  .board { grid-template-columns: 1fr; }
  .topbar-right span { display: none; }
}

@media print {
  .topbar, .toolbar, .btn { display: none; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
