:root {
  --bg: #0f1419;
  --panel: #1a212b;
  --panel-2: #222c38;
  --line: #2c3947;
  --text: #d7e0ea;
  --muted: #8395a7;
  --accent: #4aa8ff;
  --good: #3ecf8e;
  --ok: #e2b340;
  --bad: #ff6b6b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 600; }
h2 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
code, .mono, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: .85em; }

/* --- header / tabs --- */
header {
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .02em; }
.spacer { flex: 1; }
.tabs { display: flex; gap: .25rem; }
.tab {
  background: transparent; color: var(--muted); border: 0; padding: .4rem .8rem;
  border-radius: 6px; cursor: pointer; font-size: .95rem;
}
.tab.active { background: var(--panel-2); color: var(--text); }
.badge {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
  background: var(--panel-2); color: var(--muted); padding: .15rem .5rem; border-radius: 4px;
}
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: .85rem; }

/* --- layout --- */
.view { padding: 1rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 1rem; margin-bottom: 1rem;
}

/* --- tables --- */
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); }
table.data th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; }
table.fleet tbody tr { cursor: pointer; }
table.fleet tbody tr:hover { background: var(--panel-2); }
table.fleet tbody tr.selected { background: #25405c; }
tr.offline td { opacity: .55; }
.modems td, .modems th { font-size: .85rem; white-space: nowrap; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .5rem; }
.dot-on { background: var(--good); }
.dot-off { background: var(--bad); }
.dev { font-weight: 600; }

.sig-good { color: var(--good); }
.sig-ok { color: var(--ok); }
.sig-mid { color: #e8853a; }
.sig-bad { color: var(--bad); }

/* --- pills / badges --- */
.pill { padding: .15rem .55rem; border-radius: 999px; font-size: .8rem; }
.pill-on { background: rgba(62,207,142,.15); color: var(--good); }
.pill-off { background: rgba(255,107,107,.15); color: var(--bad); }
.pill-warn { background: rgba(226,179,64,.15); color: var(--ok); }

/* --- detail kv grid --- */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem; margin: .5rem 0; }
.kv-cell { background: var(--panel-2); border-radius: 6px; padding: .5rem .6rem; }
.kv-label { color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.kv-value { font-size: 1rem; }

/* --- map --- */
#map { height: 360px; border-radius: 6px; }

/* --- forms --- */
form label { display: block; margin: .5rem 0; color: var(--muted); font-size: .85rem; }
form .row { display: flex; gap: .75rem; flex-wrap: wrap; }
form .row label { flex: 1; min-width: 120px; }
input, select, textarea {
  width: 100%; margin-top: .2rem; padding: .4rem .5rem;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 5px;
}
textarea { resize: vertical; font-family: ui-monospace, monospace; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: .5rem 0; padding: .5rem .75rem; }
fieldset:disabled { opacity: .5; }

button {
  background: var(--accent); color: #06121f; border: 0; border-radius: 6px;
  padding: .45rem .9rem; font-weight: 600; cursor: pointer; margin-top: .5rem;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: var(--panel-2); color: var(--text); }
button.danger { background: var(--bad); color: #1a0606; }
.cmd-buttons { display: flex; gap: .5rem; flex-wrap: wrap; }
.result { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .6rem; min-height: 2.5rem; white-space: pre-wrap; }

.banner {
  background: rgba(226,179,64,.12); color: var(--ok); border: 1px solid var(--ok);
  border-radius: 6px; padding: .5rem .75rem;
}

/* --- login overlay --- */
/* z-index sits above every Leaflet pane/control (Leaflet tops out around 1000)
   so the overlay always wins. The map also doesn't initialize until the shell
   is shown, so in practice nothing is behind it before connection. */
.overlay {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg);
  z-index: 2000;
}
/* Belt-and-suspenders: the [hidden] app shell must stay hidden even if some
   library sets an inline display on a descendant. */
[hidden] { display: none !important; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.5rem; }
.login-card { width: min(360px, 92vw); }
.login-card h1 { margin-bottom: 0; }
.login-card button { width: 100%; }

/* --- toasts --- */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 1000; }
.toast {
  padding: .6rem .9rem; border-radius: 8px; color: #fff; max-width: 340px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4); transition: opacity .3s, transform .3s;
}
.toast-out { opacity: 0; transform: translateY(8px); }
.toast-info { background: #2f4256; }
.toast-success { background: #1f7a52; }
.toast-warn { background: #8a6d1f; }
.toast-error { background: #8a2f2f; }
