:root {
  --bg: #0b0f14;
  --panel: #141b24;
  --panel-2: #1b2431;
  --line: #263140;
  --text: #e6edf5;
  --muted: #8b9bb0;
  --accent: #38bdf8;
  --danger: #ef4444;
  --ok: #22c55e;
}

* { box-sizing: border-box; }

/* `hidden` must win over a component's own `display`. Author rules beat the UA
   sheet at equal specificity, so `.login { display: grid }` used to leave the
   login gate painted over the panel until the map covered it — and the token
   box has the same shape. One rule instead of remembering it per component. */
[hidden] { display: none !important; }

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

/* --- Login gate ------------------------------------------------------------ */

.login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(circle at 30% 20%, rgba(56, 189, 248, 0.12), transparent 55%),
    var(--bg);
}

.login-card {
  width: min(100%, 340px);
  display: grid;
  gap: 10px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.login-card h1 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.02em;
}

/* Same quiet build marker as the map page: the version is a fact about the
   deployment, not a title. */
.version {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.login-note {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.login-error {
  margin: 2px 0 0;
  color: #fca5a5;
  font-size: 12px;
}

/* --- Shell ----------------------------------------------------------------- */

#app { position: absolute; inset: 0; }

#map { position: absolute; inset: 0; }

#sidebar {
  position: absolute;
  top: 12px;
  left: 12px;
  bottom: 12px;
  width: 330px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow-y: auto;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 10px;
  z-index: 5;
}

#sidebar header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#sidebar h1 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.02em;
}

#sidebar h2 {
  margin: 4px 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

h1, h2 { font-weight: 650; }

hr {
  width: 100%;
  margin: 2px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

/* --- Tabs ------------------------------------------------------------------ */

.tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tabs button {
  flex: 1;
  margin: 0;
  padding: 6px 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--line) inset;
}

/* --- Forms ----------------------------------------------------------------- */

label {
  display: block;
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
}

label.check {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

input[type="text"],
input[type="search"],
input[type="password"],
select {
  width: 100%;
  padding: 7px 9px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  cursor: text;
}

select { cursor: pointer; }

input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  padding: 7px 10px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }

button.primary {
  background: #10344a;
  border-color: #1d5f80;
  font-weight: 600;
}

button.secondary { flex: 0 0 auto; }

button.ghost {
  color: var(--muted);
  background: transparent;
}

button.danger {
  background: #3a1a1a;
  border-color: #622727;
  color: #fca5a5;
}

button.danger:hover:not(:disabled) { border-color: var(--danger); }

.icon-btn {
  padding: 5px 9px;
  color: var(--muted);
  background: transparent;
}

.row {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}

.row:last-child { margin-bottom: 0; }

.search-row {
  display: flex;
  gap: 6px;
}

.hint {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.summary {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* --- Repeater list --------------------------------------------------------- */

.bulk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.bulk button { margin: 0; }

.rep-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
}

.rep-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 7px;
  align-items: start;
  padding: 7px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.rep-list li:hover { border-color: #33506b; }

.rep-list li.selected {
  border-color: var(--accent);
  background: #16283a;
}

.rep-list input[type="checkbox"] {
  margin: 2px 0 0;
  cursor: pointer;
}

.rep-main { min-width: 0; }

.rep-name {
  display: block;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rep-name .unnamed { color: var(--muted); font-weight: 400; font-style: italic; }

.rep-meta {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}

.rep-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

.badge {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #10161e;
  white-space: nowrap;
}

/* A node with no echoes and no recent advert is the one the operator came here
   to find; the colour says so without making them read every timestamp. */
.badge.never { color: #fca5a5; border-color: #622727; background: #2a1414; }
.badge.stale { color: #fcd34d; border-color: #6b4e13; background: #2a2110; }
.badge.alive { color: #86efac; border-color: #245c34; background: #11251a; }
.badge.echoes { color: #a8c0e8; border-color: #2b3d5c; background: #1a2233; }

.rep-actions {
  display: grid;
  gap: 5px;
  align-content: start;
}

.rep-actions button { margin: 0; padding: 4px 8px; }

/* --- Region list ----------------------------------------------------------- */

.zone-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: grid;
  gap: 6px;
}

.zone-list:empty::after {
  content: "Регионов пока нет.";
  display: block;
  padding: 8px;
  color: var(--muted);
  font-size: 11px;
}

.zone-list li {
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 8px;
}

.zone-list li[data-zone-code="DEV"] { border-left-color: var(--muted); }

.zone-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  justify-content: space-between;
}

.zone-title {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zone-code {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.zone-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}

.zone-actions {
  display: flex;
  gap: 5px;
  margin-top: 6px;
}

.zone-actions button { padding: 4px 8px; font-size: 11px; }

.zone-warn {
  margin: 4px 0 0;
  color: #fcd34d;
  font-size: 10.5px;
}

/* --- Observer list --------------------------------------------------------- */

.obs-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: grid;
  gap: 6px;
}

.obs-list li {
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.obs-head {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: space-between;
}

.obs-title {
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.obs-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.field-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
}

/* --- One-time token reveal ------------------------------------------------- */

.obs-token {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  background: #11251a;
  border: 1px solid #245c34;
  border-radius: 8px;
}

.obs-token h3 {
  margin: 0;
  font-size: 12px;
  color: #86efac;
}

.obs-token-note {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}

#obs-token-value {
  display: block;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
  user-select: all;
}

.obs-token .row {
  display: flex;
  gap: 6px;
  margin: 0;
}

.obs-token .row button { flex: 1; }

/* The install code, shown once. Same one-time-reveal contract as the token, but
   it is a short code a person reads out, so it is set larger than a credential
   and paired with the exact command it belongs in. */
.enrol-code {
  display: grid;
  gap: 8px;
  margin: 10px 0;
  padding: 10px;
  background: #11251a;
  border: 1px solid #245c34;
  border-radius: 8px;
}

.enrol-code h3 {
  margin: 0;
  font-size: 12px;
  color: #86efac;
}

#enrol-code-value {
  display: block;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: 700 20px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
  text-align: center;
  user-select: all;
}

#enrol-code-command {
  margin: 0;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: 10.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: all;
}

.enrol-code .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0;
}

/* "Скрыть" is not a peer action: it gets its own full-width line so the two
   copy buttons stay a readable width in the narrow panel. */
.enrol-code .row #enrol-code-hide {
  grid-column: 1 / -1;
}

/* --- Boundary method ------------------------------------------------------- */

.method {
  margin: 4px 0 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.method legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.method-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 7px;
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
}

.method-option + .method-option { margin-top: 2px; }

.method-option input {
  margin: 2px 0 0;
  flex: 0 0 auto;
}

.method-option span { display: grid; gap: 2px; min-width: 0; }

.method-option b { font-size: 12px; font-weight: 600; }

.method-option small { color: var(--muted); font-size: 10.5px; line-height: 1.4; }

.method-option:has(input:checked) {
  background: #16283a;
  box-shadow: 0 0 0 1px #2b4a66 inset;
}

/* The stub. Kept legible on purpose — a greyed-out option that cannot be read
   explains nothing — but unmistakably inactive. */
.method-option.disabled {
  cursor: not-allowed;
  opacity: 0.45;
  filter: grayscale(1);
}

.method-option.disabled b::after {
  content: " · скоро";
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* --- Geocoder results ------------------------------------------------------ */

.osm-fields { margin-bottom: 8px; }

.geo-status {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
}

.geo-status.error { color: #fca5a5; }

.geo-results {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  display: grid;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}

.geo-results li {
  padding: 6px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}

.geo-results li:hover { border-color: var(--accent); }

.geo-results li.picked {
  border-color: var(--ok);
  background: #11251a;
}

.geo-results .geo-name { font-weight: 600; font-size: 12px; }

.geo-results .geo-kind {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.geo-results .geo-full {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.geo-picked {
  margin: 0;
  padding: 7px 8px;
  color: #86efac;
  background: #11251a;
  border: 1px solid #245c34;
  border-radius: 7px;
  font-size: 11px;
  line-height: 1.45;
}

/* --- Toast ----------------------------------------------------------------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: min(90%, 480px);
  margin: 0;
  padding: 9px 14px;
  background: #1b2431;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.toast.ok { border-color: #245c34; color: #86efac; }
.toast.error { border-color: #622727; color: #fca5a5; }

@media (max-width: 760px) {
  #sidebar {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 60%;
  }
}
