:root {
  color-scheme: dark;
  --bg: #0f0f14;
  --panel: #17171f;
  --panel-2: #1e1e28;
  --border: #ffffff14;
  --border-strong: #ffffff24;
  --text: #f1eee0;
  --muted: #f1eee08c;
  --accent: #f9b701;
  --accent-soft: #f9b70122;
  --danger: #ff5c5c;
  --danger-soft: #ff5c5c1f;
  --ok: #6fd13c;
  --ok-soft: #6fd13c1f;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: radial-gradient(1200px 500px at 50% -200px, #f9b70112, transparent), var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

h1, h3 { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 1.2em; margin: 0; }
code { background: #ffffff14; padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* ---------- controls ---------- */
input, select {
  height: 38px;
  background: #ffffff0a;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  outline: none;
  transition: border-color .15s, background .15s;
}
input:focus, select:focus { border-color: var(--accent); background: #ffffff10; }
select option { background: var(--panel); }
input[type="file"] { padding: 6px 8px; height: auto; max-width: 220px; font-size: 12px; }

button {
  height: 38px;
  background: var(--accent);
  color: #17140a;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: filter .15s, background .15s, border-color .15s;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
button.ghost:hover { background: #ffffff0d; filter: none; }
button.danger { background: var(--danger-soft); color: var(--danger); border-color: #ff5c5c40; }
button.danger:hover { background: #ff5c5c33; filter: none; }
button.small { height: 30px; padding: 0 12px; font-size: 12px; }

/* ---------- login ---------- */
#login-view { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px 28px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 30px 80px #0009;
}
.login-box h1 { font-size: 24px; letter-spacing: -.02em; }
.login-box button { margin-top: 4px; }

/* ---------- app shell ---------- */
#app-view > * { width: min(1180px, calc(100% - 48px)); margin-inline: auto; }

header { display: flex; align-items: center; justify-content: space-between; padding: 28px 0 20px; }
header h1 { font-size: 22px; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
header h1::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
}
.tab-btn {
  height: 34px;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 600;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); background: #ffffff0a; filter: none; }
.tab-btn.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }

.badge {
  display: inline-block;
  min-width: 18px;
  background: var(--accent);
  color: #17140a;
  border-radius: 9px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  margin-left: 6px;
}

.server-bar { display: flex; align-items: flex-start; gap: 12px; padding: 16px 0 4px; }
.server-bar > .muted { padding-top: 5px; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 28px;
  min-width: 34px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 600;
}
.chip:hover { color: var(--text); background: #ffffff0d; filter: none; }
.chip.active { background: var(--accent); color: #17140a; border-color: var(--accent); }
.chip .n { margin-left: 5px; opacity: .65; font-weight: 500; }
.chip .n:empty { display: none; }

.tab-panel {
  display: none;
  margin-top: 14px !important;
  margin-bottom: 40px !important;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.tab-panel.active { display: block; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.inline-form input[type="text"] { flex: 1 1 200px; min-width: 160px; }
label.file { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 0 14px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #ffffff06; }
tbody tr:last-child td { border-bottom: none; }
td:first-child { font-weight: 600; }
th:last-child, td:last-child { text-align: right; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.num { font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.pill-approved, .pill-active { background: var(--ok-soft); color: var(--ok); }
.pill-pending { background: var(--accent-soft); color: var(--accent); }
.pill-revoked { background: var(--danger-soft); color: var(--danger); }
.pill-neutral { background: #ffffff12; color: var(--muted); }

.warn { color: var(--accent); font-size: 12px; margin-left: 4px; }
.empty { text-align: center; color: var(--muted); padding: 36px 0 12px; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 13px; }

/* ---------- dialog ---------- */
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 22px 24px;
  width: min(560px, calc(100% - 32px));
}
dialog h3 { margin-bottom: 14px; }
dialog button { margin-top: 16px; }
dialog::backdrop { background: #000b; backdrop-filter: blur(3px); }

@media (max-width: 720px) {
  .tab-panel { padding: 14px; overflow-x: auto; }
  td, th { padding-inline: 8px; }
}

.w-sm { width: 100px; flex: none; }
.section-title { margin: 26px 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
textarea {
  flex: 1 1 320px;
  min-height: 90px;
  background: #ffffff0a;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font: 13px/1.4 ui-monospace, 'Cascadia Mono', Consolas, monospace;
  outline: none;
  resize: vertical;
}
textarea:focus { border-color: var(--accent); }
.chip.test { border-style: dashed; }
.chip.test.active { border-style: solid; }
td input.cell { height: 32px; width: 100%; min-width: 120px; }
td input.cell.port { min-width: 80px; width: 90px; }
.pill-live { background: var(--ok-soft); color: var(--ok); }
.pill-down { background: #ffffff12; color: var(--muted); }

/* ---------- сводка ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 0;
}
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; line-height: 1.15; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.stat.alert .value { color: var(--accent); }
.stat.good .value { color: var(--ok); }
@media (max-width: 820px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* ---------- уведомления ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--ok);
  border-radius: 10px;
  padding: 10px 16px;
  box-shadow: 0 12px 32px #0009;
  animation: toast-in .18s ease-out;
  max-width: 360px;
}
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- подсказки адресов ---------- */
.suggestions {
  background: var(--accent-soft);
  border: 1px solid #f9b70140;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.suggestions strong { display: block; margin-bottom: 8px; color: var(--accent); }
.suggestion { display: flex; align-items: center; gap: 12px; padding: 6px 0; flex-wrap: wrap; }
.suggestion .sid { font-weight: 700; min-width: 70px; }

/* ---------- полировка ---------- */
tbody tr { transition: background .12s; }
.pill { letter-spacing: .01em; }
.pill-down { cursor: help; }
tr.unset td:not(:last-child) { opacity: .8; }
tr.unset:hover td { opacity: 1; }
.tab-panel { box-shadow: 0 18px 50px #0006; }
.chip { transition: all .12s; }
.chip.active { box-shadow: 0 0 0 3px var(--accent-soft); }
.login-box h1::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 16px var(--accent); margin-right: 10px; }
button:active { transform: translateY(1px); }
::selection { background: #f9b70155; }

.mon-note { margin: 0 0 12px; }
