/* RCV Routing dashboard. Minimalist SaaS shell.
   Palette: kerbside at dawn. Deep bottle green, hi-vis amber, chalk. */
:root {
  --green-950: #0d2018;
  --green-900: #12291f;
  --green-700: #1f4835;
  --green-100: #dce9e2;
  --amber: #f5a300;
  --amber-deep: #c98600;
  --chalk: #f7f7f4;
  --paper: #ffffff;
  --ink: #1a2420;
  --muted: #66756d;
  --line: #e3e7e2;
  --danger: #b3402e;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--chalk);
  color: var(--ink);
}
.hidden { display: none !important; }
h1 { font-size: 18px; margin: 0; letter-spacing: -0.01em; }
.sub { color: var(--muted); font-size: 12.5px; margin: 2px 0 0; }
.count { color: var(--muted); font-weight: 400; font-size: 12px; }

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-mark {
  width: 18px; height: 18px; border-radius: 4px 4px 9px 4px; flex: none;
  background: linear-gradient(135deg, var(--amber) 0 50%, var(--green-700) 50% 100%);
}

/* auth */
.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(245,163,0,.14), transparent 60%),
    var(--green-950);
}
.auth-card { background: var(--paper); border-radius: 12px; padding: 34px 36px; width: 380px; box-shadow: 0 18px 50px rgba(0,0,0,.35); }
.auth-card .brand { font-size: 19px; }
.tagline { color: var(--muted); font-size: 13px; margin: 10px 0 20px; }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid var(--line); }
.auth-tabs button {
  background: none; border: none; padding: 8px 12px; font-weight: 600; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; font-size: 13.5px;
}
.auth-tabs button.active { color: var(--ink); border-bottom-color: var(--amber); }
form label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  font: inherit; background: var(--paper); color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--amber); outline-offset: 0; border-color: transparent; }
button.primary {
  background: var(--green-700); color: #fff; border: none; border-radius: 7px;
  padding: 9px 16px; font-weight: 600; cursor: pointer; font-size: 13.5px;
}
button.primary:hover { background: var(--green-900); }
form button.primary { margin-top: 14px; }
button.ghost {
  background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 7px;
  padding: 7px 12px; font-weight: 600; cursor: pointer; font-size: 12.5px;
}
button.ghost:hover { color: var(--ink); border-color: var(--muted); }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* app shell */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 208px; flex: none; display: flex; flex-direction: column;
  background: var(--green-950); color: var(--green-100); padding: 18px 12px 14px;
}
.sidebar .brand { color: #fff; padding: 0 8px 18px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav button {
  display: flex; align-items: center; gap: 8px; text-align: left;
  background: none; border: none; color: var(--green-100); padding: 9px 12px;
  font: inherit; font-weight: 550; cursor: pointer; border-radius: 8px; font-size: 13.5px;
  opacity: .8;
}
.sidebar nav button:hover { opacity: 1; background: rgba(255,255,255,.05); }
.sidebar nav button.active { background: var(--green-700); color: #fff; opacity: 1; box-shadow: inset 2px 0 0 var(--amber); }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: 12px; display: flex; flex-direction: column; gap: 8px; }
.sidebar-foot span { opacity: .7; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot button { background: none; border: 1px solid var(--green-700); color: var(--green-100); border-radius: 7px; padding: 6px 10px; cursor: pointer; font-size: 12px; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.view-page { padding: 22px 26px; overflow-y: auto; }
.panel-head { margin-bottom: 14px; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 14px; }
.card-title { font-weight: 650; font-size: 13.5px; margin-bottom: 8px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }

/* routes view: side panel + map */
.view-routes { display: flex; flex: 1; min-height: 0; }
.routes-panel {
  width: 330px; flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--paper); border-right: 1px solid var(--line);
}
.routes-panel .panel-head { padding: 20px 18px 10px; margin: 0; }
.filter-bar { padding: 0 18px 10px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.filter-bar select { width: 100%; font-size: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: none; border-radius: 999px;
  padding: 3px 11px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.chip.active { background: var(--green-100); border-color: var(--green-700); color: var(--green-700); }

.route-list { flex: 1; overflow-y: auto; padding: 8px 10px; }
.route-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 8px; border: none; background: none; border-radius: 8px; cursor: pointer;
  font: inherit; text-align: left;
}
.route-item:hover { background: var(--chalk); }
.route-item .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; border: 2px solid transparent; }
.route-item.selected .dot { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px currentColor; }
.route-item .r-name { font-weight: 600; font-size: 13px; }
.route-item .r-meta { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.route-item.selected { background: var(--green-100); }
.panel-foot {
  padding: 10px 18px; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }
.stop-pop .maplibregl-popup-content {
  font: 12px/1.45 "Segoe UI", sans-serif; padding: 8px 11px; border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
}
.stop-pop .pop-seq { font-weight: 700; font-size: 13px; }
.stop-pop .pop-sub { color: #66756d; }

/* tables */
.filters { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.filters input, .filters select { width: 140px; font-size: 13px; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 7px 9px; border-bottom: 1px solid var(--line); }
td { padding: 6px 9px; border-bottom: 1px solid var(--line); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill.ok { background: #e3efe7; color: var(--green-700); }
.pill.warn { background: #fdf0d4; color: var(--amber-deep); }

.itemlist { list-style: none; margin: 0 0 10px; padding: 0; }
.itemlist li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 13px; }
.itemlist li .subtext { color: var(--muted); font-size: 11.5px; }
.itemlist button.del { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 12px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input { width: auto; flex: 1 1 110px; }
.inline-form button.primary { margin-top: 0; }
.row { display: flex; gap: 10px; align-items: center; }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 10px 14px; }
  .sidebar nav { flex-direction: row; margin-left: 14px; }
  .sidebar-foot { margin: 0 0 0 auto; border: none; padding: 0; flex-direction: row; align-items: center; }
  .view-routes { flex-direction: column; }
  .routes-panel { width: 100%; max-height: 45vh; }
}
