/* car-portal: one column on a phone, two on a wide screen. No inline
   styles anywhere (the CSP forbids them); scripts set what varies through
   the CSSOM. */
:root {
  --bg: #f4f6f5; --card: #fff; --text: #17201d; --muted: #66726d; --line: #dfe5e2;
  --brand: #0e3a2f; --accent: #2a9d6f; --good: #2a9d6f; --warn: #d99a00; --bad: #d1453b; --info: #2f6fd1;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1412; --card: #18201d; --text: #e7ecea; --muted: #93a19b; --line: #2a3531; --brand: #0b2b23; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--info); }
.loading { padding: 2rem; color: var(--muted); text-align: center; }
[hidden] { display: none !important; }

header.top { background: var(--brand); color: #fff; padding: .7rem 1rem calc(.7rem) ; padding-top: max(.7rem, env(safe-area-inset-top));
  display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 1000; }
header.top h1 { font-size: 1.1rem; margin: 0; flex: 1; }
header.top .who { font-size: .85rem; opacity: .8; }
header.top button { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 8px; padding: .25rem .6rem; }

nav.tabs { display: flex; overflow-x: auto; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 3.1rem; z-index: 999; }
nav.tabs button { flex: 1 0 auto; border: 0; background: none; padding: .7rem .9rem; color: var(--muted); border-bottom: 3px solid transparent; }
nav.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: .8rem; padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
.cols { display: grid; gap: .8rem; }
@media (min-width: 860px) { .cols { grid-template-columns: 1fr 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.card h2 { font-size: 1rem; margin: 0 0 .6rem; }
.card h3 { font-size: .9rem; margin: .8rem 0 .4rem; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.hero { display: grid; grid-template-columns: 1fr; gap: .4rem; text-align: center; }
.hero img { width: 100%; max-height: 200px; object-fit: contain; }
.hero .place { font-size: .95rem; }
.battery { position: relative; height: 34px; border-radius: 9px; background: var(--line); overflow: hidden; margin: .4rem 0 .2rem; }
.battery .fill { position: absolute; inset: 0 auto 0 0; background: var(--good); width: 0; }
.battery .fill.low { background: var(--warn); }
.battery .fill.empty { background: var(--bad); }
.battery .fill.charging { background: repeating-linear-gradient(45deg, var(--info), var(--info) 10px, #4f8be0 10px, #4f8be0 20px); }
.battery .limit { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: .6; }
.battery .label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff;
  text-shadow: 0 0 3px rgba(0,0,0,.6); }
.big { font-size: 1.6rem; font-weight: 700; }

.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.chip { border-radius: 10px; padding: .45rem .6rem; background: var(--bg); border: 1px solid var(--line); }
.chip .k { font-size: .75rem; color: var(--muted); }
.chip .v { font-weight: 600; }
.chip.good { border-color: color-mix(in srgb, var(--good) 50%, transparent); }
.chip.good .v { color: var(--good); }
.chip.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--card)); }
.chip.bad .v { color: var(--bad); }
.chip.warn .v { color: var(--warn); }
.chip.info .v { color: var(--info); }

.nums { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; }
.num .k { font-size: .75rem; color: var(--muted); }
.num .v { font-size: 1.15rem; font-weight: 700; }
.num .v.good { color: var(--good); }

table.list { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; padding: .3rem .4rem; border-bottom: 1px solid var(--line); }
table.list td { padding: .45rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list td.r, table.list th.r { text-align: right; white-space: nowrap; }
.item { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .t { font-size: .8rem; color: var(--muted); }
.item .route { font-weight: 600; }
.item .meta { font-size: .85rem; color: var(--muted); }
.state { font-size: .75rem; padding: .1rem .45rem; border-radius: 999px; background: var(--line); }
.state.confirmed { background: var(--good); color: #fff; }
.state.sent { background: var(--info); color: #fff; }
.state.refused, .state.not_seen { background: var(--bad); color: #fff; }

#map { height: calc(100vh - 12rem); min-height: 320px; border-radius: var(--radius); border: 1px solid var(--line); }
.bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .6rem; }
select, input[type=text], input[type=password] { padding: .45rem .6rem; border-radius: 8px; border: 1px solid var(--line); background: var(--card); }

.btn { border: 0; border-radius: 10px; padding: .6rem 1rem; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.btn.ghost { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.btn.stop { background: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sel { outline: 3px solid var(--info); }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.stepper { display: flex; align-items: center; gap: .4rem; }
.stepper .val { min-width: 4.5rem; text-align: center; font-size: 1.3rem; font-weight: 700; }

.login { max-width: 360px; margin: 12vh auto; }
.login form { display: grid; gap: .7rem; }
.login input { width: 100%; }
.err { color: var(--bad); min-height: 1.2em; }

#toast { position: fixed; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2000;
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; max-width: 92vw; }
