:root {
  --bg: #0f1722;
  --panel: #16212e;
  --panel2: #1d2b3a;
  --line: #2c3e52;
  --text: #e6edf3;
  --muted: #8aa0b4;
  --accent: #2f81f7;
  --accent2: #1f6feb;
  --danger: #e5534b;
  --ok: #3fb950;
  --warn: #d29922;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0 0 .5rem; }

/* ---- Login ---- */
.login-page { display: grid; place-items: center; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2rem;
  width: 320px;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.login-card h1 { margin: 0; font-size: 1.6rem; }
.login-card .muted { margin-top: 0; }
.login-card label { display: block; margin: 1rem 0 .25rem; font-size: .85rem; color: var(--muted); }
.login-card input {
  width: 100%; padding: .55rem .6rem;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 6px; color: var(--text);
}
button, .btn {
  cursor: pointer; border: 1px solid var(--accent2);
  background: var(--accent); color: #fff;
  padding: .5rem .8rem; border-radius: 6px; font-size: .9rem;
}
button:hover, .btn:hover { background: var(--accent2); }
.login-card button { width: 100%; margin-top: 1.2rem; }

/* ---- App layout ---- */
body.app { display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .5rem 1rem; background: var(--panel);
  border-bottom: 1px solid var(--line); z-index: 1000;
}
.topbar .spacer { flex: 1; }
.topbar .btn-link { color: var(--text); }
.modes { display: flex; gap: .25rem; }
.modes button {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); padding: .35rem .6rem;
}
.modes button.active { background: var(--accent); border-color: var(--accent2); }

#map { flex: 1; min-height: 0; }

.sidebar {
  position: absolute; top: 49px; right: 0; bottom: 0; width: 360px;
  background: var(--panel); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 1rem; z-index: 1000;
  box-shadow: -6px 0 24px rgba(0,0,0,.35);
}
.sidebar.hidden { display: none; }
.sidebar h2 { margin: 0 0 .5rem; font-size: 1.1rem; }
.sidebar .close { float: right; background: none; border: none; color: var(--muted); font-size: 1.2rem; }
.sidebar label { display: block; margin: .6rem 0 .2rem; font-size: .8rem; color: var(--muted); }
.sidebar input, .sidebar select, .sidebar textarea {
  width: 100%; padding: .45rem .5rem; background: var(--panel2);
  color: var(--text); border: 1px solid var(--line); border-radius: 6px;
}
.sidebar textarea { min-height: 60px; resize: vertical; }
.row { display: flex; gap: .5rem; }
.row > * { flex: 1; }
.actions { display: flex; gap: .5rem; margin-top: 1rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-secondary { background: var(--panel2); color: var(--text); border-color: var(--line); }

table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { text-align: left; padding: .3rem .4rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }

.notes-list { list-style: none; padding: 0; margin: .5rem 0; }
.notes-list li { background: var(--panel2); border: 1px solid var(--line);
  border-radius: 6px; padding: .4rem .5rem; margin-bottom: .4rem; }
.notes-list .meta { color: var(--muted); font-size: .75rem; }

.badge { display: inline-block; padding: .05rem .4rem; border-radius: 10px; font-size: .72rem; }
.badge.in_use { background: #1a3a5a; color: #7cc4ff; }
.badge.spare  { background: #2a2f38; color: var(--muted); }
.badge.dark   { background: #111; color: #888; }
.badge.reserved { background: #3a2f12; color: #e8c468; }
.badge.faulty { background: #4a1f1c; color: #ff9a92; }
.warn-text { color: var(--warn); }

.toast {
  position: absolute; bottom: 1rem; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: .6rem 1rem; border-radius: 8px; z-index: 2000; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.toast.hidden { display: none; }
.toast.err { border-color: var(--danger); }
.toast.ok  { border-color: var(--ok); }

/* Leaflet marker labels */
.node-label { font-size: 11px; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.hint {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.7); color: #fff; padding: .4rem .8rem;
  border-radius: 6px; z-index: 1000; pointer-events: none; font-size: .85rem;
}
.hint.hidden { display: none; }
