:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #238636;
  --accent-dim: #2ea043;
  --danger: #f85149;
  --focus: #1f6feb;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}
.auth-card h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.5rem; }
.stack label { display: flex; flex-direction: column; gap: 0.35rem; }
.stack label span { font-size: 0.85rem; color: var(--muted); }
input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  color: var(--text);
  font-size: 1rem;
}
input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.25);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent-dim);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger {
  background: #6e2a2a;
  border-color: var(--danger);
  color: #fff;
  font-weight: 600;
}
.btn.danger:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; }
.hidden { display: none !important; }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.panel-alert {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
  line-height: 1.45;
}
.panel-alert.warn {
  border-color: #9e6a03;
  background: rgba(158, 106, 3, 0.12);
}
.panel-alert.hidden { display: none; }
.panel-alert .small { font-size: 0.8rem; }

.btn.link {
  border: none;
  background: none;
  color: var(--focus);
  padding: 0 0 0 0.5rem;
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { font-weight: 700; letter-spacing: -0.02em; }
.badge {
  margin-left: 0.5rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  vertical-align: middle;
}
.user-menu { display: flex; align-items: center; gap: 1rem; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.panel-head h2 { margin: 0 0 0.5rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  border: 1px solid var(--border);
}
.data-table th, .data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border: 1px solid var(--border);
  vertical-align: middle;
}
.data-table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.05);
}
.data-table thead th .th-sub {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.25;
}
.data-table .col-stat {
  min-width: 6.5rem;
}
.stat-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  line-height: 1.25;
}
.stat-stack .stat-today {
  display: block;
  text-align: right;
}
.data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.025);
}
.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.06);
}
.data-table .col-idx {
  width: 3rem;
  text-align: center;
  font-weight: 600;
  color: var(--muted);
}
.mono { font-family: ui-monospace, monospace; font-size: 0.85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ok { color: var(--accent-dim); font-weight: 600; }
.bad { color: var(--danger); font-weight: 600; }

/* Прирост счётчика с прошлого тика WS/опроса (только в браузере, без лишних запросов) */
.stat-delta {
  color: var(--accent-dim);
  font-weight: 700;
  font-size: 0.82em;
  margin-left: 0.35rem;
  white-space: nowrap;
}

.alert {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error {
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid var(--danger);
  color: #ff7b72;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
}
.modal-dialog {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-dialog h3 { margin-top: 0; }
.protected-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  max-height: 200px;
  overflow-y: auto;
}
.protected-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.row.gap { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.row.gap input { flex: 1; min-width: 120px; }
