/* ── Палитра ───────────────────────────────────────────── */
:root {
  color-scheme: dark;
  --bg: #0e1116;
  --bg-soft: #151a22;
  --panel: #1a212b;
  --panel-2: #212a36;
  --line: #2b3644;
  --line-soft: #222b37;
  --text: #e6edf3;
  --muted: #8b98a9;
  --dim: #6b7787;
  --accent: #4f8cff;
  --accent-soft: #1e2f4d;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Каркас ────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 22px;
  padding: 0 22px; height: 54px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; letter-spacing: -0.2px; font-size: 15px; white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav a {
  padding: 7px 13px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; white-space: nowrap;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: #a9c8ff; }
.topbar .who { color: var(--dim); font-size: 13px; white-space: nowrap; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 22px 64px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
h1 { font-size: 21px; margin: 0; font-weight: 650; letter-spacing: -0.3px; }
h2 { font-size: 16px; margin: 28px 0 12px; font-weight: 600; }
.sub { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

/* ── Панели ────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel + .panel { margin-top: 16px; }
.panel-head {
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel-2);
}
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-body { padding: 16px; }

/* ── Карточки серверов ─────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; position: relative;
}
.card.offline { border-color: #4b2b2b; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 3px; }
.card-title { font-weight: 620; font-size: 15px; }
.card-title a { color: var(--text); }
.card-meta { color: var(--dim); font-size: 12px; font-family: var(--mono); margin-bottom: 14px; }
.card-purpose { color: var(--muted); font-size: 12.5px; margin: -8px 0 14px; }

/* ── Метрики ───────────────────────────────────────────── */
.metric { margin-bottom: 12px; }
.metric:last-child { margin-bottom: 0; }
.metric-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; font-size: 12.5px; }
.metric-label { color: var(--muted); }
.metric-value { font-family: var(--mono); font-size: 12px; color: var(--text); }
.bar { height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--ok); transition: width .4s ease; }
.bar > i.warn { background: var(--warn); }
.bar > i.bad  { background: var(--bad); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; }

/* ── Значки состояния ──────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.badge.ok   { background: rgba(63,185,80,.13);  color: #56d364; border-color: rgba(63,185,80,.3); }
.badge.warn { background: rgba(210,153,34,.14); color: #e3b341; border-color: rgba(210,153,34,.32); }
.badge.bad  { background: rgba(248,81,73,.13);  color: #ff7b72; border-color: rgba(248,81,73,.3); }
.badge.mute { background: var(--panel-2); color: var(--muted); border-color: var(--line); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Таблицы ───────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left; padding: 10px 14px; color: var(--muted);
  font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  background: var(--panel-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr:hover td { background: rgba(255,255,255,.018); }
table.grid td.mono, table.grid th.mono { font-family: var(--mono); font-size: 12.5px; }
table.grid td.right, table.grid th.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ── Формы ─────────────────────────────────────────────── */
label.field { display: block; margin-bottom: 13px; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
label.field .hint { color: var(--dim); font-size: 11.5px; font-weight: 400; }
input[type=text], input[type=password], input[type=email], input[type=date],
input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 8px 11px;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: 13.5px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,140,255,.15);
}
textarea { min-height: 76px; resize: vertical; font-family: inherit; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 16px; }
.form-actions { display: flex; gap: 9px; align-items: center; margin-top: 6px; flex-wrap: wrap; }

button, .btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; white-space: nowrap;
}
button:hover, .btn:hover { background: #2a3543; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3d7ae8; }
.btn-danger { color: #ff7b72; border-color: rgba(248,81,73,.35); background: rgba(248,81,73,.08); }
.btn-danger:hover { background: rgba(248,81,73,.16); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; }

/* ── Сообщения ─────────────────────────────────────────── */
.flash { padding: 11px 15px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px; border: 1px solid; }
.flash.ok  { background: rgba(63,185,80,.1);  border-color: rgba(63,185,80,.3);  color: #7ee787; }
.flash.err { background: rgba(248,81,73,.1);  border-color: rgba(248,81,73,.3);  color: #ff9d97; }
.flash.info{ background: rgba(79,140,255,.1); border-color: rgba(79,140,255,.3); color: #a9c8ff; }
.flash code { background: rgba(0,0,0,.35); padding: 2px 6px; border-radius: 4px; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }

.empty { padding: 40px 20px; text-align: center; color: var(--dim); font-size: 13.5px; }

/* ── Мелочи ────────────────────────────────────────────── */
.secret { display: inline-flex; align-items: center; gap: 7px; }
.secret code {
  font-family: var(--mono); font-size: 12.5px; background: var(--bg-soft);
  padding: 3px 8px; border-radius: 4px; border: 1px solid var(--line); min-width: 90px;
  display: inline-block; word-break: break-all;
}
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.spacer { flex: 1; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
details.inline > summary { cursor: pointer; color: var(--accent); font-size: 13px; list-style: none; padding: 4px 0; }
details.inline > summary::-webkit-details-marker { display: none; }
details.inline > summary::before { content: "＋ "; }
details.inline[open] > summary::before { content: "− "; }

.chart { width: 100%; height: 150px; display: block; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 5px; }

/* ── Вход ──────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.login-card h1 { font-size: 18px; margin-bottom: 4px; }
.login-card .sub { margin-bottom: 20px; }

@media (max-width: 640px) {
  .topbar { height: auto; padding: 10px 14px; flex-wrap: wrap; }
  .wrap { padding: 18px 14px 48px; }
  .cards { grid-template-columns: 1fr; }
}
