:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #272c37;
  --text: #e6e9ef;
  --muted: #8c94a6;
  --accent: #5b9dff;
  --ok: #43c07d;
  --warn: #e8b13a;
  --bad: #e5544b;
  --radius: 12px;
}

* { box-sizing: border-box; }

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

h1, h2, h3 { font-weight: 600; }
h2 { font-size: 15px; letter-spacing: .02em; margin: 0 0 12px; }
.muted { color: var(--muted); font-weight: 400; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: var(--panel); position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; letter-spacing: .06em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right form { margin: 0; }

main { max-width: 1120px; margin: 0 auto; padding: 20px; }
section { margin-bottom: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; }

button {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 6px 12px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
button.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
button.ghost:hover { color: var(--text); border-color: var(--muted); }
button.tiny { padding: 3px 8px; font-size: 12px; }

.badge {
  font-size: 12px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.badge.ok { color: var(--ok); border-color: rgba(67, 192, 125, .4); }
.badge.bad { color: var(--bad); border-color: rgba(229, 84, 75, .4); }

/* Карточки серверов ------------------------------------------------------- */
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-head h3 { margin: 0; font-size: 16px; }
.card-sub { color: var(--muted); font-size: 12px; margin: 2px 0 14px; }

.metric { margin-bottom: 12px; }
.metric-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.bar { height: 6px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar > i.warn { background: var(--warn); }
.bar > i.bad { background: var(--bad); }

.spark { display: block; width: 100%; height: 38px; margin-top: 6px; }
.spark-empty { display: flex; align-items: center; color: var(--muted); font-size: 11px; }

/* Таблицы ----------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }

.table-wrap {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow-x: auto; margin-bottom: 14px;
}
.table-wrap h3 { margin: 0; padding: 14px 10px 6px; font-size: 14px; }
.kind { font-size: 11px; color: var(--muted); border: 1px solid var(--line);
        border-radius: 4px; padding: 1px 5px; margin-left: 6px; }

/* Оплаты ------------------------------------------------------------------ */
.due { font-variant-numeric: tabular-nums; }
.due.soon { color: var(--warn); }
.due.over { color: var(--bad); font-weight: 600; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.total { padding: 10px; color: var(--muted); text-align: right; }
.total b { color: var(--text); }

.empty { color: var(--muted); padding: 14px; }

/* Диалог ------------------------------------------------------------------ */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--text); padding: 20px; min-width: 320px;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h3 { margin: 0 0 14px; }
dialog label { display: block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
dialog input {
  display: block; width: 100%; margin-top: 4px; padding: 7px 9px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font: inherit;
}
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Вход -------------------------------------------------------------------- */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px; width: 300px; text-align: center;
}
.login h1 { margin: 0; font-size: 20px; letter-spacing: .06em; }
.login p { margin: 4px 0 18px; font-size: 13px; }
.login input {
  width: 100%; padding: 9px 11px; margin-bottom: 12px; font: inherit;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text);
}
.login button { width: 100%; }
.error { color: var(--bad); font-size: 13px; margin: 0 0 12px; }

@media (max-width: 620px) {
  main { padding: 14px; }
  .topbar { padding: 10px 14px; }
}
