/* Movex Fleet — operations console.
   A dashboard is scanned and operated, not read, so the work here is
   information design: summary before detail, state encoded in form as well as
   colour, and anything interactive looking interactive. */

:root {
  --bg:        #0a0d12;
  --surface:   #141a24;
  --surface-2: #1c2431;
  --surface-3: #232d3d;
  --line:      #26303f;
  --line-soft: #1e2735;

  --text:   #e9edf4;
  --text-2: #aab8cc;
  --muted:  #7c8ba2;

  --accent:      #3d6fff;
  --accent-soft: #16203a;
  --accent-text: #9fbaff;

  /* operational status */
  --driving: #34d399;
  --parked:  #f5a524;
  --overdue: #f4525c;
  --offline: #64748b;
  --charge:  #38bdf8;

  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 13px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 4px 16px -6px rgba(0,0,0,.6), 0 1px 2px rgba(0,0,0,.4);
  --shadow-3: 0 18px 48px -20px rgba(0,0,0,.85), 0 2px 6px rgba(0,0,0,.4);

  --header-h: 56px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.tabular, .kv span:last-child, .veh .sub, table td, .stat-value, .summary {
  font-variant-numeric: tabular-nums;
}

.hidden { display: none !important; }
.muted  { color: var(--muted); }
.small  { font-size: 12px; }
.error  { color: var(--overdue); min-height: 1em; font-size: 13px; }
.spacer { flex: 1; }
.pad    { padding: 22px 26px 40px; overflow: auto; }

h2 { font-size: 19px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 4px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 10px; }

code, .mono, pre { font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; }

/* ---------------------------------------------------------------- controls */

input, select, button, textarea {
  font: inherit; font-family: inherit;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s var(--ease), background .15s var(--ease),
              box-shadow .15s var(--ease);
}
input, select, textarea { width: 100%; margin-top: 5px; }
input::placeholder { color: #55627a; }
input:hover, select:hover { border-color: var(--surface-3); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61,111,255,.16);
}

button {
  cursor: pointer; background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 500; padding: 8px 14px; box-shadow: var(--shadow-1);
}
button:hover { background: #4d7bff; border-color: #4d7bff; }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
button.ghost {
  background: var(--surface-2); color: var(--text-2);
  border-color: var(--line); box-shadow: none;
}
button.ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--surface-3); }
button.link {
  background: none; border: none; color: var(--muted);
  padding: 4px 6px; box-shadow: none; font-weight: 400;
}
button.link:hover { color: var(--text); background: var(--surface-2); }
button:disabled { opacity: .45; cursor: default; transform: none; }

label {
  display: block; margin: 12px 0;
  font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .01em;
}

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px; margin-bottom: 16px;
  box-shadow: var(--shadow-1);
}

/* ------------------------------------------------------------------ login */

.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -12%, rgba(61,111,255,.14), transparent 70%),
    var(--bg);
}
.login-card { width: 360px; padding: 30px 28px; box-shadow: var(--shadow-3); }
.login-card h1 { margin: 0 0 6px; font-size: 23px; font-weight: 600; letter-spacing: -.02em; }
.login-card button[type=submit] { width: 100%; margin-top: 8px; padding: 10px; }
.login-card .muted.small { line-height: 1.7; }

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 600; letter-spacing: -.01em; font-size: 15px;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent), #2a52d8);
  box-shadow: 0 2px 8px -2px rgba(61,111,255,.7);
}
.brand-mark svg { width: 17px; height: 17px; fill: #fff; }

/* ----------------------------------------------------------------- chrome */

header {
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px; height: var(--header-h);
  background: rgba(20,26,36,.82);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 500;
}

.crumb { font-size: 13px; font-weight: 500; color: var(--text-2); }

.badge {
  display: inline-block; min-width: 17px; text-align: center;
  background: var(--overdue); color: #fff;
  border-radius: 20px; padding: 1px 6px;
  font-size: 10px; font-weight: 700; margin-left: 5px;
  box-shadow: 0 0 0 3px rgba(244,82,92,.16);
}

.summary { font-size: 12px; color: var(--muted); letter-spacing: .01em; }

.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--offline); flex: none;
  transition: background .2s var(--ease), box-shadow .2s var(--ease);
}
.dot.live { background: var(--driving); box-shadow: 0 0 0 3px rgba(52,211,153,.16); }

/* ------------------------------------------------------ application shell */

.shell { display: flex; height: calc(100vh - var(--header-h)); min-height: 0; }

.rail {
  width: 194px; flex: none;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 12px 10px; display: flex; flex-direction: column; gap: 3px;
}
.rail-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--r-md);
  color: var(--text-2); text-decoration: none;
  font-size: 13.5px; font-weight: 500; position: relative;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.rail-item:hover { background: var(--surface-2); color: var(--text); }
.rail-item.active { background: var(--accent-soft); color: var(--text); }
.rail-item.active::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.rail-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rail-icon { width: 19px; height: 19px; flex: none; display: grid; place-items: center; }
.rail-icon svg {
  width: 19px; height: 19px; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.rail-item.active .rail-icon { color: var(--accent-text); }

.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.section.hidden { display: none !important; }

.subnav {
  display: flex; align-items: center; gap: 2px;
  height: 44px; flex: none; padding: 0 14px;
  border-bottom: 1px solid var(--line); background: var(--surface);
  overflow-x: auto;
}
.subnav a {
  position: relative; color: var(--muted); text-decoration: none;
  padding: 6px 11px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.subnav a:hover { color: var(--text); background: var(--surface-2); }
.subnav a.active { color: var(--text); background: var(--surface-3); }
.subnav a.active::after {
  content: ""; position: absolute; left: 11px; right: 11px; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--accent);
}
.subnav-title { font-size: 13px; font-weight: 600; color: var(--text-2); }

.section-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.section-body.pad { display: block; overflow: auto; }

.view { flex: 1; min-height: 0; }
/* position: relative so the floating map panel anchors to the map view
   rather than escaping to the page and landing over the header. */
#view-map { display: flex; min-height: 0; position: relative; }
#map { flex: 1; min-width: 0; }

.side {
  width: 316px; flex: none; border-left: 1px solid var(--line);
  background: var(--surface); overflow: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.side h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); font-weight: 600; margin: 0;
}
.detail { width: 356px; }

.side::-webkit-scrollbar, .pad::-webkit-scrollbar,
pre::-webkit-scrollbar, .table-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.side::-webkit-scrollbar-thumb, .pad::-webkit-scrollbar-thumb,
pre::-webkit-scrollbar-thumb, .table-scroll::-webkit-scrollbar-thumb {
  background: var(--surface-3); border-radius: 10px; border: 3px solid var(--surface);
}

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

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); padding: 9px 8px 8px;
  text-align: center; position: relative; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: var(--tone, var(--offline)); opacity: .85;
}
.stat-value { font-size: 19px; font-weight: 600; line-height: 1.15; color: var(--tone, var(--text)); }
.stat-label {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600; margin-top: 2px;
}
.stat.is-driving { --tone: var(--driving); }
.stat.is-parked  { --tone: var(--parked); }
.stat.is-overdue { --tone: var(--overdue); }
.stat.is-offline { --tone: var(--offline); }
.stat.zero .stat-value { color: var(--muted); }
.stat.zero::before { opacity: .25; }

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

.veh-list { display: flex; flex-direction: column; gap: 6px; }

.veh {
  position: relative; display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 11px 10px 13px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  cursor: pointer; overflow: hidden;
  transition: background .15s var(--ease), border-color .15s var(--ease),
              transform .12s var(--ease);
}
.veh::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--tone, var(--offline));
}
.veh:hover { background: var(--surface-3); border-color: var(--surface-3); }
.veh:active { transform: scale(.995); }
.veh.sel {
  border-color: var(--accent);
  background: linear-gradient(90deg, var(--accent-soft), var(--surface-2) 65%);
}
.veh.s-driving { --tone: var(--driving); }
.veh.s-parked  { --tone: var(--parked); }
.veh.s-overdue { --tone: var(--overdue); }
.veh.s-offline, .veh.s-unknown { --tone: var(--offline); }

.veh .veh-body { min-width: 0; flex: 1; }
.veh .nm {
  font-weight: 600; font-size: 13.5px; letter-spacing: -.005em;
  display: flex; align-items: center; gap: 6px;
}
.veh .sub { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.veh .addr {
  font-size: 11px; color: var(--muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.pip { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pip.driving { background: var(--driving); }
.pip.parked  { background: var(--parked); }
.pip.overdue { background: var(--overdue); }
.pip.offline, .pip.unknown { background: var(--offline); }

.veh-icon {
  width: 26px; height: 26px; flex: none; display: grid; place-items: center;
  border-radius: 7px; background: var(--surface); border: 1px solid var(--line);
}
.veh-icon svg { width: 18px; height: 18px; }
.veh-icon .car-glass { fill: #0d131d; opacity: .75; }
.veh-icon .car-halo { display: none; }
.veh-icon .car-charge { display: none; }
.veh.s-driving .veh-icon svg { fill: var(--driving); }
.veh.s-parked  .veh-icon svg { fill: var(--parked); }
.veh.s-overdue .veh-icon svg { fill: var(--overdue); }
.veh.s-offline .veh-icon svg, .veh.s-unknown .veh-icon svg { fill: var(--offline); }

.bolt { color: var(--charge); font-size: 11px; }

/* ---------------------------------------------------------- map markers */
/* top-down car icons, rotated to heading */

.car-marker {
  width: 30px; height: 30px; display: grid; place-items: center;
  transition: transform .5s var(--ease); will-change: transform;
}
.car-marker svg {
  width: 26px; height: 26px; display: block; overflow: visible;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.75));
}
.car-marker .car-body { transition: fill .25s var(--ease); }
.car-marker .car-glass { fill: #080c14; opacity: .62; }
.car-marker.m-driving .car-body { fill: var(--driving); }
.car-marker.m-parked  .car-body { fill: var(--parked); }
.car-marker.m-overdue .car-body { fill: var(--overdue); }
.car-marker.m-offline .car-body, .car-marker.m-unknown .car-body { fill: var(--offline); }
.car-marker.m-offline { opacity: .55; }

.car-marker.overdue .car-halo { animation: halo 2s ease-out infinite; }
@keyframes halo {
  0%   { r: 8px;  opacity: .55; }
  100% { r: 15px; opacity: 0; }
}
.car-halo { fill: none; stroke: var(--overdue); stroke-width: 1.5; opacity: 0; }

.car-charge { display: none; }
.car-marker.charging .car-charge { display: block; }
.car-marker.selected { filter: drop-shadow(0 0 7px rgba(61,111,255,.95)); }

/* Leaflet chrome, brought into the palette */
.leaflet-container { background: #070a0f; font-family: "IBM Plex Sans", sans-serif; }
/* A dispatch console is looked at for hours: the map recedes so the vehicles
   carry the colour. */
.leaflet-tile { filter: invert(1) hue-rotate(188deg) brightness(.62) contrast(1.08) saturate(.32); }
.leaflet-bar {
  border: 1px solid var(--line) !important; border-radius: var(--r-sm) !important;
  box-shadow: var(--shadow-2) !important; overflow: hidden;
}
.leaflet-bar a {
  background: var(--surface) !important; color: var(--text-2) !important;
  border-bottom-color: var(--line) !important;
}
.leaflet-bar a:hover { background: var(--surface-3) !important; color: var(--text) !important; }
.leaflet-tooltip {
  background: rgba(16,21,30,.96) !important; border: 1px solid var(--line) !important;
  border-radius: var(--r-sm) !important; color: var(--text) !important;
  box-shadow: var(--shadow-2) !important; font-size: 12px !important;
  white-space: pre-line; padding: 6px 9px !important;
}
.leaflet-tooltip::before { display: none !important; }
.leaflet-control-attribution {
  background: rgba(10,13,18,.75) !important; color: var(--muted) !important; font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--text-2) !important; }

/* ----------------------------------------------------------- detail panel */

.detail-head { display: flex; align-items: flex-start; gap: 10px; }
.detail-head h2 { flex: 1; font-size: 15px; text-transform: none; letter-spacing: -.01em; color: var(--text); }
.detail-head .veh-icon { width: 30px; height: 30px; }
.detail-head .veh-icon svg { width: 20px; height: 20px; }
.detail-head button.link { font-size: 19px; line-height: 1; padding: 2px 8px; }
.detail.s-driving .veh-icon svg { fill: var(--driving); }
.detail.s-parked  .veh-icon svg { fill: var(--parked); }
.detail.s-overdue .veh-icon svg { fill: var(--overdue); }
.detail.s-offline .veh-icon svg, .detail.s-unknown .veh-icon svg { fill: var(--offline); }

.big { font-size: 21px; font-weight: 600; letter-spacing: -.02em; margin: 2px 0; line-height: 1.2; }

.kv {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px;
}
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); flex: none; }
.kv span:last-child { text-align: right; min-width: 0; }

.section-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); font-weight: 600;
  margin: 18px 0 6px; padding-top: 12px; border-top: 1px solid var(--line);
}

.timeline {
  display: flex; height: 8px; border-radius: 5px; overflow: hidden;
  background: var(--bg); margin: 8px 0 5px;
}
.timeline div { height: 100%; }

.addr-val { max-width: 200px; }
.charging-val { color: var(--charge); font-weight: 500; }
.maplink { color: var(--accent-text); text-decoration: none; }
.maplink:hover { text-decoration: underline; }

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

.table-scroll {
  overflow-x: auto; border: 1px solid var(--line);
  border-radius: var(--r-lg); background: var(--surface); margin-bottom: 18px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: left; padding: 10px 13px;
  border-bottom: 1px solid var(--line-soft); vertical-align: top;
}
thead th {
  color: var(--muted); font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .07em;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1;
}
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.open td { background: rgba(244,82,92,.06); }

.row { display: flex; gap: 9px; align-items: center; }
.row select, .row input { width: auto; margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 18px; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.checks label {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0; color: var(--text-2); font-weight: 400; cursor: pointer;
}
.checks input { width: auto; margin: 0; accent-color: var(--accent); }

pre {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 13px; overflow: auto; max-height: 340px;
  font-size: 12px; color: var(--text-2); line-height: 1.6;
}
pre.ok     { border-color: rgba(52,211,153,.4); color: var(--text); }
pre.failed { border-color: rgba(244,82,92,.5); color: #ffb4b8; background: rgba(244,82,92,.05); }

code {
  font-size: .88em; background: var(--surface-2);
  border: 1px solid var(--line-soft); border-radius: 4px;
  padding: .1em .35em; word-break: break-word; color: var(--text-2);
}

.tag {
  display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  padding: 2px 7px; border-radius: 20px; background: var(--surface-3); color: var(--text-2);
}
.tag.ok   { color: var(--driving); background: rgba(52,211,153,.13); }
.tag.bad  { color: var(--overdue); background: rgba(244,82,92,.13); }
.tag.rest { color: var(--muted);   background: var(--surface-3); }

ol#tesla-steps { padding-left: 20px; }
ol#tesla-steps li { margin-bottom: 14px; }
ol#tesla-steps li::marker { color: var(--muted); font-weight: 600; }
ol#tesla-steps button { margin-right: 9px; }

.authorize-link { margin: 12px 0; }
.authorize-link a {
  display: inline-block; padding: 9px 15px; border-radius: var(--r-sm);
  background: var(--accent); color: #fff; text-decoration: none;
  font-weight: 500; box-shadow: var(--shadow-1);
}
.authorize-link a:hover { background: #4d7bff; }

/* -------------------------------------------------------- weekly shift plan */

.sched-card { padding: 16px 18px; }
.hours-row { flex-wrap: wrap; }
label.inline {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 0; font-size: 12px; color: var(--muted);
}
label.inline input, label.inline select { width: auto; margin: 0; }

table.sched { table-layout: fixed; }
table.sched th, table.sched td { padding: 5px 6px; border-bottom: 1px solid var(--line-soft); }
table.sched thead th {
  text-align: center; position: static; background: transparent;
  border-bottom: 1px solid var(--line);
}
table.sched thead th.today { color: var(--accent-text); }
table.sched th.shift-label {
  width: 104px; text-transform: none; letter-spacing: 0;
  font-size: 13px; color: var(--text); white-space: nowrap;
  background: transparent; position: static; border-bottom: 1px solid var(--line-soft);
}
table.sched th.shift-label .pip { display: inline-block; margin-right: 6px; }
td.slot input.drv {
  width: 100%; margin: 0; padding: 6px 8px; font-size: 12px;
  background: var(--bg); border-color: var(--line-soft);
}
td.slot input.drv:hover { border-color: var(--surface-3); }
td.slot.live input.drv { border-color: rgba(52,211,153,.55); background: rgba(52,211,153,.07); }
td.slot.off input.drv {
  color: var(--muted); background: var(--surface-2);
  border-style: dashed; font-style: italic;
}

.rest-bar { padding: 14px 18px; }
.rest-bar select { width: auto; }

/* ------------------------------------------------------------ placeholders */

.placeholder { max-width: 620px; }
.placeholder-icon {
  width: 44px; height: 44px; border-radius: var(--r-md);
  display: grid; place-items: center; margin-bottom: 14px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.placeholder-icon svg {
  width: 22px; height: 22px; fill: none; stroke: var(--muted);
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.placeholder h2 { font-size: 22px; margin-bottom: 4px; }
.placeholder > p { margin: 0 0 20px; font-size: 14px; }
.planned {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px 20px;
}
.planned h3 {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); margin-bottom: 10px;
}
ul.plain { padding-left: 18px; margin: 0 0 12px; }
ul.plain li { margin-bottom: 7px; color: var(--text-2); font-size: 13.5px; }
ul.plain li::marker { color: var(--muted); }

/* --------------------------------------------------------------- finance */

.fin-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-top: 16px; }
.fin-stats .stat { padding: 14px 12px 12px; text-align: left; }
.fin-stats .stat-value { font-size: 22px; letter-spacing: -.02em; }
.fin-stats .stat-label { font-size: 10px; }

.share {
  display: inline-block; width: 62px; height: 6px; border-radius: 3px;
  background: var(--surface-3); vertical-align: middle; margin-right: 7px; overflow: hidden;
}
.share > span { display: block; height: 100%; background: var(--driving); border-radius: 3px; }

#fin-drivers tfoot td {
  border-top: 1px solid var(--line); border-bottom: 0;
  background: var(--surface-2); font-size: 13px;
}

.daybar {
  display: grid; grid-template-columns: 92px 1fr 108px;
  align-items: center; gap: 12px; padding: 4px 0; font-size: 12.5px;
}
.daybar-label { color: var(--muted); font-variant-numeric: tabular-nums; }
.daybar-track { height: 9px; border-radius: 5px; background: var(--bg); overflow: hidden; }
.daybar-track > span {
  display: block; height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, var(--accent), #5b8cff);
}
.daybar-value { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------- period picker */

.period { position: relative; }
.period-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 11px; min-width: 168px; font-variant-numeric: tabular-nums;
}
.period-btn svg {
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.period-cal { width: 15px; height: 15px; color: var(--muted); flex: none; }
.period-chev {
  width: 14px; height: 14px; color: var(--muted); margin-left: auto; flex: none;
  transition: transform .18s var(--ease);
}
.period-btn[aria-expanded="true"] .period-chev { transform: rotate(180deg); }
.period-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--text); }
#period-label { font-weight: 500; }

.period-pop {
  position: absolute; top: calc(100% + 7px); right: 0; z-index: 900;
  display: flex; align-items: stretch;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  overflow: hidden; animation: pop-in .13s var(--ease);
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.period-presets {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px; width: 216px;
  border-right: 1px solid var(--line); background: var(--surface-2);
}
.period-preset {
  display: flex; flex-direction: column; gap: 1px; align-items: flex-start;
  width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; box-shadow: none;
  color: var(--text-2); font-weight: 500; padding: 7px 10px; border-radius: var(--r-sm);
}
.period-preset:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.period-preset.active { background: var(--accent-soft); color: var(--text); }
.period-preset-dates {
  font-size: 11px; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums;
}
.period-preset.active .period-preset-dates { color: var(--accent-text); }

.period-custom { padding: 14px; width: 232px; display: flex; flex-direction: column; }
.period-custom-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); font-weight: 600; margin-bottom: 10px;
}
.period-field { margin: 0 0 10px; }
.period-field input { margin-top: 4px; }
/* the native picker glyph is black-on-black in a dark UI */
.period-field input[type=date]::-webkit-calendar-picker-indicator {
  filter: invert(1); opacity: .45; cursor: pointer;
}
.period-field input[type=date]::-webkit-calendar-picker-indicator:hover { opacity: .9; }
.period-hint { color: var(--overdue); font-size: 12px; margin: 0 0 8px; min-height: 1em; }
.period-actions { display: flex; gap: 8px; margin-top: auto; }
.period-actions button { flex: 1; }

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

@media (max-width: 900px) {
  #view-map { flex-direction: column; }
  #map { height: 52vh; flex: none; }
  .side, .detail { width: auto; border-left: 0; border-top: 1px solid var(--line); }
  header { gap: 10px; padding: 0 12px; }
  .summary { display: none; }
  .rail { width: 58px; padding: 10px 8px; }
  .rail-item { justify-content: center; padding: 11px 0; }
  .rail-item span:not(.rail-icon) { display: none; }
  .section-body > .view { overflow: auto; }
}

@media (max-width: 640px) {
  .period-pop { flex-direction: column; right: auto; left: 0; }
  .period-presets { width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .period-custom { width: auto; }
}

/* the one instruction people misread: a 404 here is success, not failure */
.callout-inline {
  border-left: 3px solid var(--parked);
  background: rgba(245,165,36,.08);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: 10px 13px; margin: 10px 0; font-size: 12.5px; color: var(--text-2);
}
.callout-inline strong { color: var(--text); }
.callout-inline p { margin: 6px 0 0; }

/* --- Tesla integration: one-time connect ---------------------------------
   The connect flow reports progress in a single line of text, so success and
   failure need a colour outside <pre>, where .ok/.failed were defined. */
p.ok, p.ok.small          { color: var(--driving); }
p.failed, p.failed.small  { color: var(--overdue); }

/* Everything that is not the one button an operator needs lives behind a
   disclosure, so the page reads as "log in" rather than as a checklist. */
details.card > summary,
details.fallback > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  list-style: none;
}
details.card > summary::-webkit-details-marker,
details.fallback > summary::-webkit-details-marker { display: none; }
details.card > summary::before,
details.fallback > summary::before { content: "▸ "; }
details.card[open] > summary::before,
details.fallback[open] > summary::before { content: "▾ "; }
details.card > summary:hover,
details.fallback > summary:hover { color: var(--text); }
details.fallback { margin-top: 14px; }
details.fallback[open] {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
#relay-output { max-height: 320px; }

/* ------------------------------------------------- weekly payouts (Uke) --
   Money columns line up only when they are right-aligned and tabular; a
   ragged right edge makes two figures hard to compare at a glance. */
#uke-table { width: 100%; border-collapse: collapse; }
#uke-table th, #uke-table td { padding: 7px 10px; white-space: nowrap; }
#uke-table th {
  text-align: left; font-size: 11px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
#uke-table td { border-bottom: 1px solid var(--line-soft); }
#uke-table tbody tr:last-child td { border-bottom: 0; }
#uke-table tbody tr:hover td { background: var(--surface-2); }
#uke-table .num, #uke-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
#uke-suggestions .kv { padding: 7px 0; }
#uke-suggestions .kv + .kv { border-top: 1px solid var(--line-soft); }
#uke-out { max-height: 420px; }

/* ===================================================== finance dashboard ==
   The data is the only thing allowed to be loud: recessive grid, hairline
   rules, and numbers in text tokens rather than in the series colour. */

.kpi-grid {
  display: grid; gap: 8px; margin-top: 16px;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
}
.kpi {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); padding: 13px 14px 11px;
}
.kpi-label {
  font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.kpi-value {
  font-size: 23px; font-weight: 600; letter-spacing: -.02em;
  margin-top: 5px; font-variant-numeric: tabular-nums; color: var(--text);
}
.kpi-foot {
  margin-top: 4px; font-size: 11px; color: var(--muted);
  display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap;
}
.kpi-change { font-variant-numeric: tabular-nums; font-weight: 600; }
.kpi-change.up   { color: var(--driving); }
.kpi-change.down { color: var(--overdue); }

.viz-card { margin-top: 14px; }
.viz-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; flex-wrap: wrap; margin-bottom: 10px;
}
.viz-head h3 { margin: 0 0 2px; }
.viz-head p { margin: 0; }
.viz-pair { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .viz-pair { grid-template-columns: 1fr; } }

.viz { position: relative; }
.viz-svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-axis { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.viz-value { fill: var(--text); font-size: 11px; font-weight: 600;
             font-variant-numeric: tabular-nums; }
.viz-hit { cursor: default; }

/* Identity is carried by the swatch beside the text, never by colouring the
   text itself - a mid-chroma hue is illegible as small type. */
.viz-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.viz-legend span { display: inline-flex; align-items: center; gap: 6px;
                   font-size: 11px; color: var(--text-2); }
.viz-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

.viz-tip {
  position: absolute; top: 4px; pointer-events: none; z-index: 5;
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 10px; min-width: 140px;
  box-shadow: var(--shadow-2); font-size: 11px; color: var(--text-2);
}
.viz-tip strong { display: block; color: var(--text); font-size: 12px; margin-bottom: 5px; }
.viz-tip span { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.viz-tip b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }
.viz-tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.viz-tip-total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 5px !important; }

#fin-people { width: 100%; border-collapse: collapse; }
#fin-people th, #fin-people td { padding: 7px 10px; white-space: nowrap; }
#fin-people th {
  text-align: left; font-size: 11px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
#fin-people td { border-bottom: 1px solid var(--line-soft); }
#fin-people tbody tr:last-child td { border-bottom: 0; }
#fin-people tbody tr:hover td { background: var(--surface-2); }
#fin-people .num, #fin-people th.num { text-align: right; font-variant-numeric: tabular-nums; }

.share-cell { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.share-bar {
  flex: 1; height: 6px; border-radius: 3px; background: var(--surface-3);
  overflow: hidden; display: block; min-width: 60px;
}
.share-bar > span { display: block; height: 100%; border-radius: 3px; }
.share-pct { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
             min-width: 34px; text-align: right; }
/* Half-width charts render from a 360-wide viewBox, so their type is sized
   in that coordinate space rather than scaled down from the wide one. */
.viz-axis-sm { font-size: 9px; }
.viz-value-sm { font-size: 10px; }

/* On a phone the tiles would otherwise become one long column - eight of them
   is a lot of scrolling before the first chart. Two up keeps the headline
   figures on one screen. */
@media (max-width: 700px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .kpi { padding: 10px 11px 9px; }
  .kpi-value { font-size: 18px; }
  .kpi-label { font-size: 9px; }
  .kpi-foot { font-size: 10px; }
  .viz-head { margin-bottom: 8px; }
  .viz-card { margin-top: 10px; }
}

/* ======================================================== fleet map chrome ==
   A control panel floating over the map, and a fleet strip above the vehicle
   list. Both stay recessive: the map and the cars are the subject. */

.map-panel {
  /* Offset by the sidebar's width: the panel belongs to the map, and the
     sidebar occupies the right edge of the same positioning context. */
  position: absolute; top: 12px; right: 328px; z-index: 500;
  background: rgba(20, 26, 36, .93); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 9px 10px; box-shadow: var(--shadow-2); max-width: 236px;
}
.map-panel-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.map-panel-row + .map-panel-row { margin-top: 8px; }
.map-panel-title {
  font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--r-sm); padding: 2px; }
.seg button {
  background: none; border: 0; color: var(--text-2); cursor: pointer;
  font-size: 11px; padding: 4px 8px; border-radius: 4px; font-family: inherit;
}
.seg button.on { background: var(--accent); color: #fff; }
.seg button:not(.on):hover { color: var(--text); }
.map-select {
  width: 100%; background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 5px 7px; font-size: 11px; font-family: inherit; margin-top: 0;
}
.heat-legend { display: flex; align-items: center; gap: 3px; margin-top: 9px; }
.heat-legend i { width: 18px; height: 7px; border-radius: 2px; display: block; }
.heat-scale-label { font-size: 9px; color: var(--muted); white-space: nowrap; }
.heat-scale-label:first-child { margin-right: 3px; }
.heat-scale-label:last-child { margin-left: 4px; }
.map-note { font-size: 10px; color: var(--muted); margin: 8px 0 0; line-height: 1.45; }

.fleet-kpi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.fkpi {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--r-sm); padding: 8px 9px;
}
.fkpi-value {
  font-size: 17px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.fkpi-of { font-size: 12px; color: var(--muted); font-weight: 400; }
.fkpi-label { font-size: 9px; color: var(--muted); margin-top: 2px; line-height: 1.3; }

.side-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin: 14px 0 8px;
}
.side-head h2 { margin: 0; }

.hotspots { margin-top: 16px; border-top: 1px solid var(--line-soft); }
.hotspot {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: 0; border-radius: var(--r-sm);
  padding: 7px 6px; cursor: pointer; text-align: left; font-family: inherit;
}
.hotspot:hover { background: var(--surface-2); }
.hotspot-rank {
  width: 19px; height: 19px; flex: none; border-radius: 5px;
  background: #5340a3; color: #fff; font-size: 10px; font-weight: 600;
  display: grid; place-items: center;
}
.hotspot-body { min-width: 0; }
.hotspot-name {
  display: block; font-size: 12px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hotspot-sub { display: block; font-size: 10px; color: var(--muted); margin-top: 1px;
               font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  /* Stacked layout: the map is full width, so the panel returns to its edge.
     The three-way control plus its label will not fit a phone's width, so the
     label goes and the row is allowed to wrap - a cut-off "Venting" button is
     worse than no caption. */
  .map-panel {
    top: 8px; right: 8px; left: auto; max-width: calc(100vw - 90px);
    padding: 7px 8px;
  }
  .map-panel-row { flex-wrap: wrap; }
  .map-panel-title { display: none; }
  .seg button { padding: 5px 9px; }
  .fleet-kpi { grid-template-columns: repeat(3, 1fr); }
  .fkpi-value { font-size: 15px; }
}

/* ==================================================== monthly settlement == */
#mnd-table { width: 100%; border-collapse: collapse; }
#mnd-table th, #mnd-table td { padding: 7px 9px; white-space: nowrap; }
#mnd-table th {
  text-align: left; font-size: 11px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
#mnd-table td { border-bottom: 1px solid var(--line-soft); vertical-align: top; }
#mnd-table tfoot td { border-top: 1px solid var(--line); border-bottom: 0; }
#mnd-table .num, #mnd-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
#mnd-table tbody tr:hover td { background: var(--surface-2); }
#mnd-table tr.is-loss td:first-child { box-shadow: inset 2px 0 0 var(--overdue); }
.pos { color: var(--driving); }
.neg { color: var(--overdue); }
.cost-in {
  width: 86px; text-align: right; margin-top: 0; padding: 4px 6px;
  font-size: 12px; font-variant-numeric: tabular-nums;
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--text); font-family: inherit;
}
.cost-in:focus { border-color: var(--accent); outline: none; }
#mnd-unalloc .kv { padding: 7px 0; }
#mnd-unalloc .kv + .kv { border-top: 1px solid var(--line-soft); }
#mnd-unalloc select { max-width: 160px; margin-top: 0; }

/* Vaktliste: sjåfør velges fra Drift-listen */
td.slot select.drv {
  width: 100%; min-width: 120px; margin: 0; padding: 6px 6px; font-size: 12px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 6px; color: inherit;
}
td.slot select.drv:hover { border-color: var(--surface-3); }
td.slot.live select.drv { border-color: rgba(52,211,153,.55); background: rgba(52,211,153,.07); }
td.slot.off select.drv { color: var(--muted); background: var(--surface-2); border-style: dashed; font-style: italic; }

/* ==========================================================================
   Movex designsystem v2 – roligere og mer konsekvent utseende.
   Samme fargenavn som før, så resten av CSS-en følger med automatisk.
   Kontrast (WCAG): brødtekst ≥ 9:1, dempet tekst ≥ 5:1, hvit på knapp 5:1.
   ========================================================================== */
:root {
  --bg:        #0b0f16;
  --surface:   #121823;
  --surface-2: #18202d;
  --surface-3: #212b3a;
  --line:      #252f3e;
  --line-soft: #1b2431;

  --text:   #e8ecf3;
  --text-2: #b4c0d3;
  --muted:  #8b98ae;

  --accent:       #3563f0;   /* knapper: hvit tekst 5:1 */
  --accent-hover: #2d57d9;
  --accent-soft:  #152040;
  --accent-text:  #a9c0ff;
  --focus:        #7f9dff;

  --driving: #3ccf91;
  --parked:  #f2a93b;
  --overdue: #f26b74;
  --offline: #6b7a91;

  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 12px;
  --control-h: 36px;
  --control-h-sm: 30px;
  --shadow-1: 0 1px 0 rgba(255,255,255,.02) inset, 0 1px 2px rgba(0,0,0,.35);
}

body { font-size: 14px; letter-spacing: .002em; }
h1, h2, h3 { color: var(--text); }
h2 { font-size: 20px; font-weight: 600; letter-spacing: -.015em; }
h3 { font-size: 14.5px; font-weight: 600; }
::selection { background: rgba(53,99,240,.45); }

/* ---- kontroller: lik høyde og tydelig fokus ---- */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select {
  min-height: var(--control-h); padding: 7px 11px; border-radius: var(--r-sm);
  background: var(--bg); border-color: var(--line);
}
select { padding-right: 30px; }
input::placeholder, textarea::placeholder { color: #6c7a90; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(127,157,255,.18); }
button {
  min-height: var(--control-h); padding: 7px 15px; border-radius: var(--r-sm);
  font-weight: 550; letter-spacing: .005em;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); border-color: var(--accent); box-shadow: 0 1px 2px rgba(0,0,0,.35);
}
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button.ghost { background: var(--surface-2); color: var(--text); border-color: var(--line); box-shadow: none; font-weight: 500; }
button.ghost:hover { background: var(--surface-3); border-color: #2f3b4f; }
button.link { min-height: 0; color: var(--text-2); }
button.link:hover { color: var(--text); }
td button, td button.ghost, .copy-mon, #alert-refresh { min-height: var(--control-h-sm); padding: 4px 11px; font-size: 13px; }
td button + button { margin-left: 4px; }
label { font-size: 12.5px; color: var(--text-2); }

/* ---- kort, tabeller og merkelapper ---- */
.card { padding: 20px 22px; border-radius: var(--r-lg); border-color: var(--line); }
.card h3:first-child { margin-top: 0; }
thead th { background: var(--surface); color: var(--muted); font-size: 11px; letter-spacing: .06em; padding-top: 11px; padding-bottom: 11px; }
th, td { padding: 11px 14px; vertical-align: middle; }
tbody tr:hover { background: rgba(255,255,255,.025); }
.tag { border-radius: 999px; padding: 2px 9px; font-weight: 600; font-size: 11px; letter-spacing: .02em; }

/* ---- topplinje, meny og undermeny ---- */
header { background: rgba(18,24,35,.88); }
.crumb { color: var(--text-2); padding-left: 14px; border-left: 1px solid var(--line); }
.rail { background: var(--surface); border-right: 1px solid var(--line); }
.rail-item { font-weight: 500; }
.rail-item.active { background: var(--accent-soft); }
.subnav { background: var(--surface); gap: 4px; padding: 0 18px; }
.subnav a { padding: 7px 12px; color: var(--text-2); }
.subnav a.active { background: transparent; color: var(--text); }
.subnav a.active::after { bottom: -4px; height: 2px; background: var(--accent-text); }
.pad { padding: 26px 30px 48px; }
.pad > h2:first-child, .view > h2:first-child { margin-bottom: 6px; }

/* ---- vaktliste ---- */
.sched-card { padding: 18px 20px; }
table.sched th { background: transparent; text-align: center; }
td.slot input.drv, td.slot select.drv { min-height: 32px; font-size: 12.5px; }

/* ---- innlogging ---- */
.login-card { width: 380px; padding: 34px 32px 26px; border-radius: 16px; }
.login-card h1 { font-size: 24px; margin-top: 18px; }
.login-card button[type=submit] { min-height: 42px; font-size: 15px; margin-top: 14px; }
.login-card label { margin: 14px 0; }
.login-card input { min-height: 40px !important; }

/* ---- mobil ---- */
@media (max-width: 640px) {
  #whoami { display: none; }
  header { gap: 10px; padding: 0 12px; }
  .crumb { display: none; }
  .pad { padding: 18px 16px 40px; }
  .card { padding: 16px; }
  .login-card { width: 100%; padding: 28px 22px; }
}
