/* Keep colors in sync with the chart constants in app.py */
:root {
  --page: #eef1f4;
  --surface: #ffffff;
  --line: #dde2e8;
  --ink: #14202b;
  --ink-2: #4a5866;
  --muted: #7d8894;
  --accent: #f76707;
  --p1: #d0312d;
  --p2: #ef7a12;
  --p3: #d9a400;
  --p4: #4f7cac;
  --avail: #178a52;
  --enroute: #2f6fde;
  --onsite: #7048e8;
  --num: "Barlow Condensed", "Barlow", sans-serif;
}

body {
  background: var(--page);
  color: var(--ink);
  margin: 0;
}

/* Header */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 3px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: block;
  flex: none;
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
  line-height: 1.1;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.clock-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.clock {
  font-family: var(--num);
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.clock-date {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Main */

.main {
  padding: 14px 20px 24px;
  max-width: 1800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  min-width: 0;
}

.kpi.bad { border-top-color: var(--p1); }
.kpi.warn { border-top-color: var(--p2); }
.kpi.good { border-top-color: var(--avail); }

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  font-family: var(--num);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi.bad .kpi-value { color: var(--p1); }

/* Panels */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-family: var(--num);
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

.console {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 390px;
  gap: 14px;
  height: 640px;
}

.map-panel .map {
  flex: 1;
  min-height: 0;
}

.map, .board, .trend {
  height: 100%;
}

.lower {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 14px;
}

.board-panel .board {
  height: 440px;
}

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.side-stack .trend {
  height: 170px;
}

.events-panel {
  flex: 1 1 0;
}

/* fill whatever height the crew board leaves, so both cards end on the same line */
.events {
  flex: 1 1 0;
  min-height: 120px;
  overflow-y: auto;
  padding: 6px 12px;
}

.ev {
  display: flex;
  gap: 10px;
  font-size: 13px;
  padding: 3px 0;
  color: var(--ink-2);
  border-bottom: 1px dashed var(--line);
}

.ev-t {
  font-family: var(--num);
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Queue */

.queue {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.job-card {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  background: var(--surface);
  transition: background 0.1s;
}

.job-card:hover { background: #f6f8fa; }

.job-card.selected {
  background: #fff7e6;
  border-color: #f5b25a;
  box-shadow: 0 0 0 1px #f5b25a;
}

.jc-bar {
  width: 5px;
  flex-shrink: 0;
  border-radius: 4px 0 0 4px;
}

.jc-body {
  padding: 7px 10px;
  min-width: 0;
  flex: 1;
}

.jc-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.jc-prio {
  font-family: var(--num);
  font-weight: 700;
  font-size: 14px;
}

.jc-id {
  font-family: var(--num);
  font-weight: 600;
  font-size: 14px;
}

.flag-hazard { color: var(--p1); }
.flag-crit { color: var(--p2); }

.jc-status {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.jc-status.s-unassigned { color: var(--p1); }
.jc-status.s-dispatched { color: var(--enroute); }
.jc-status.s-on-site { color: var(--onsite); }

.jc-type {
  font-weight: 600;
  font-size: 14px;
}

.jc-addr, .jc-meta {
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.jc-meta .late { color: var(--p1); font-weight: 600; }

.jc-crew {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--enroute);
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Job detail */

.detail {
  overflow-y: auto;
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dt-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dt-id {
  font-family: var(--num);
  font-size: 24px;
  font-weight: 700;
}

.dt-type {
  font-size: 16px;
  font-weight: 600;
  margin-top: 2px;
}

.dt-addr {
  font-size: 13px;
  color: var(--ink-2);
}

.dt-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.st {
  background: var(--surface);
  padding: 7px 10px;
}

.st-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.st-value {
  font-family: var(--num);
  font-size: 18px;
  font-weight: 600;
}

.dt-note {
  font-size: 13px;
  color: var(--ink-2);
}

.assigned {
  border: 1px solid var(--line);
  border-left: 4px solid var(--enroute);
  border-radius: 4px;
  padding: 10px 12px;
}

.as-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.as-head span {
  color: var(--muted);
  font-size: 12px;
}

.as-line, .as-etr {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 4px;
}

.as-etr { font-weight: 600; color: var(--ink); }

.recs {
  border: 1px solid var(--line);
  border-radius: 4px;
}

.rc-header {
  display: flex;
  justify-content: space-between;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line);
  background: #f7f9fb;
}

.rc-h-eta { margin-right: 86px; }

.rc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 78px;
  grid-template-areas: "name when btn" "skill when btn";
  align-items: center;
  column-gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.rc-row:last-child { border-bottom: none; }

.rc-name { grid-area: name; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.rc-lead { color: var(--ink-2); }
.rc-skill { grid-area: skill; font-size: 12px; color: var(--muted); }
.rc-when { grid-area: when; text-align: right; display: flex; flex-direction: column; }
.rc-row button { grid-area: btn; }

.rc-eta {
  font-family: var(--num);
  font-size: 17px;
  font-weight: 600;
}

.rc-km {
  font-size: 11px;
  color: var(--muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.tag {
  font-size: 11px;
  padding: 0 5px;
  border-radius: 3px;
  background: #eef1f4;
  color: var(--ink-2);
  margin-right: 4px;
}

.tag-good { background: #e3f4ea; color: var(--avail); }
.tag-warn { background: #fdeede; color: #b8560a; }

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 12px;
}

.foot {
  font-size: 12px;
  color: var(--muted);
}

/* Narrow screens */

@media (max-width: 1350px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .console { grid-template-columns: 300px minmax(0, 1fr); height: auto; }
  .queue-panel, .map-panel { height: 600px; }
  .detail-panel { grid-column: 1 / -1; }
  .lower { grid-template-columns: 1fr; }
  .events-panel, .events { flex: none; }
  .events { height: 186px; }
}

@media (max-width: 800px) {
  .main { padding: 12px 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .console { grid-template-columns: 1fr; }
  .queue-panel { height: 420px; }
  .map-panel { height: 460px; }
}

.detail > *, .queue > * {
  flex-shrink: 0;
}
