:root {
  --bg: #f6f6f4; --panel: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --line: #dddcd6;
  --accent: #2563eb; --good: #15803d; --bad: #b91c1c; --bad-bg: #fde8e8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161615; --panel: #222220; --text: #ecebe6; --muted: #a3a29b; --line: #3a3936;
    --accent: #60a5fa; --good: #4ade80; --bad: #f87171; --bad-bg: #3b1515;
  }
}
:root[data-theme="dark"] {
  --bg: #161615; --panel: #222220; --text: #ecebe6; --muted: #a3a29b; --line: #3a3936;
  --accent: #60a5fa; --good: #4ade80; --bad: #f87171; --bad-bg: #3b1515;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
             font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { display: flex; flex-direction: column; }
h1 { font-size: 16px; margin: 0; font-weight: 650; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; }
p { margin: 4px 0; }
.muted { color: var(--muted); }
.msg { color: var(--bad); min-height: 1.4em; }

button, input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
                        border-radius: 6px; padding: 6px 10px; }
button { cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; }
button.link { background: none; border: none; padding: 0; color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
label.inline { flex-direction: row; align-items: center; gap: 6px; margin: 0; }
input[type="email"], input[type="password"] { width: 100%; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px;
        width: min(360px, 100%); display: flex; flex-direction: column; gap: 4px; }

header { display: flex; gap: 12px; align-items: center; padding: 8px 16px; background: var(--panel);
         border-bottom: 1px solid var(--line); flex-wrap: wrap; }
header button { margin-left: auto; }
.chip { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.good { color: var(--good); border-color: currentColor; }
.chip.bad { color: var(--bad); border-color: currentColor; }

.alert { padding: 8px 16px; background: var(--bad-bg); color: var(--bad); font-weight: 600; border-bottom: 1px solid var(--bad); }

.layout { flex: 1; display: grid; grid-template-columns: 300px 1fr; min-height: 0; }
aside { background: var(--panel); border-right: 1px solid var(--line); padding: 12px; overflow-y: auto; }
aside section { margin-bottom: 18px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list li { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--bg); }
.list li.tracker { cursor: pointer; }
.list li.selected { border-color: var(--accent); }
.list .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.list .row + .muted { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
select { width: 100%; }

#map { min-height: 300px; }

footer { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 8px 16px; background: var(--panel);
         border-top: 1px solid var(--line); color: var(--muted); }
footer b { color: var(--text); font-weight: 600; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 60vh auto; }
  #map { order: -1; min-height: 60vh; }
  aside { border-right: none; border-top: 1px solid var(--line); }
}
