/* ============================================================
   VPN Gateway — дизайн-система
   Индустриально-техническая эстетика. Тёмная/светлая темы.
   ============================================================ */

:root {
  /* Типографика: технический sans + моноширинный для данных */
  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --radius: 8px;
  --radius-sm: 5px;
  --gap: 16px;
  --transition: 160ms cubic-bezier(.4,0,.2,1);
}

/* ── Тёмная тема (по умолчанию) ── */
html.dark {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev2: #1c2128;
  --bg-hover: #21262d;
  --border: #30363d;
  --border-soft: #21262d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --text-faint: #6e7681;
  --accent: #2f9e6e;
  --accent-bright: #3fb950;
  --accent-dim: #238636;
  --warn: #d29922;
  --danger: #f85149;
  --info: #58a6ff;
  --shadow: 0 8px 24px rgba(0,0,0,.4);
}

/* ── Светлая тема ── */
html.light {
  --bg: #f6f8fa;
  --bg-elev: #ffffff;
  --bg-elev2: #f0f3f6;
  --bg-hover: #eaeef2;
  --border: #d0d7de;
  --border-soft: #e4e8ec;
  --text: #1f2328;
  --text-dim: #636c76;
  --text-faint: #8c959f;
  --accent: #1a7f4b;
  --accent-bright: #1f883d;
  --accent-dim: #1a7f37;
  --warn: #9a6700;
  --danger: #cf222e;
  --info: #0969da;
  --shadow: 0 8px 24px rgba(140,149,159,.2);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 50;
  transition: transform var(--transition);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.brand-mark { color: var(--accent-bright); font-size: 22px; }
.brand-text { font-weight: 600; letter-spacing: .3px; }

.sidebar nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  transition: var(--transition);
  font-weight: 500;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--bg-elev2);
  color: var(--accent-bright);
  box-shadow: inset 2px 0 0 var(--accent-bright);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 4px;
}
.theme-toggle {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); padding: 8px 12px;
  border-radius: var(--radius-sm); cursor: pointer;
  font-family: inherit; font-size: 13px;
  transition: var(--transition); text-align: left;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }
.logout:hover { color: var(--danger); }
.version { color: var(--text-faint); font-size: 11px; text-align: center; padding-top: 6px; font-family: var(--font-mono); }

.main { flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.menu-btn { display: none; background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; }
.page-title { font-size: 18px; font-weight: 600; flex: 1; }
.topbar-right { display: flex; gap: 10px; align-items: center; }

.content { padding: 28px; max-width: 1400px; width: 100%; }

/* ── Карточки ── */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); margin-bottom: 14px; font-weight: 600; }

.grid { display: grid; gap: var(--gap); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ── Статистические плитки ── */
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; font-family: var(--font-mono); }
.stat-sub { color: var(--text-faint); font-size: 12px; margin-top: 4px; }

/* ── Таблицы ── */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); font-weight: 600; }
td { padding: 12px; border-bottom: 1px solid var(--border-soft); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }
.mono { font-family: var(--font-mono); font-size: 13px; }

/* ── Бейджи статусов ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-online { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-bright); }
.badge-offline { background: color-mix(in srgb, var(--text-faint) 18%, transparent); color: var(--text-faint); }
.badge-warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge-danger { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.badge-xray { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); }
.badge-awg { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-bright); }

/* ── Кнопки ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elev2);
  color: var(--text); font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: var(--transition); text-decoration: none;
}
.btn:hover { background: var(--bg-hover); border-color: var(--text-faint); }
.btn-primary { background: var(--accent-dim); border-color: var(--accent-dim); color: #fff; }
.btn-primary:hover { background: var(--accent-bright); border-color: var(--accent-bright); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 9px; }

/* ── Формы ── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 9px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: inherit; font-size: 14px; transition: var(--transition);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
textarea { font-family: var(--font-mono); font-size: 12px; resize: vertical; min-height: 100px; }

/* ── Health-индикатор ── */
.health-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.health-green { background: var(--accent-bright); box-shadow: 0 0 8px var(--accent-bright); }
.health-yellow { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.health-red { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

/* ── Логин ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .brand-mark { font-size: 36px; color: var(--accent-bright); display: block; }
.login-brand h1 { font-size: 20px; margin-top: 10px; }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.alert-error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }

/* ── Утилиты ── */
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mb { margin-bottom: var(--gap); }
.empty { text-align: center; padding: 48px; color: var(--text-faint); }
.empty-icon { font-size: 40px; display: block; margin-bottom: 12px; opacity: .5; }

/* ── Адаптив ── */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .content { padding: 18px; }
  .topbar { padding: 14px 18px; }
}

/* ── Графики ── */
.chart { width: 100%; height: 120px; display: block; }
