/* ═══════════════════════════════════════════════════════════════════════
   RyssVPN Admin — Design tokens matching ryss.pro
   ═══════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg: #131313;
  --bg-raised: #1c1b1b;
  --bg-card: #20201f;
  --bg-elevated: #2a2a2a;
  --bg-highest: #353535;
  --bg-floor: #0e0e0e;

  --primary: #ffbd7f;
  --primary-bright: #ff9500;
  --primary-dim: #ffb874;
  --primary-text: #2d1600;

  --secondary: #ffdf3f;

  --text: #e5e2e1;
  --text-muted: #dbc2ad;
  --text-dim: #a38d7a;

  --outline: #554334;
  --outline-subtle: rgba(85, 67, 52, 0.15);

  --error: #ffb4ab;
  --error-bg: rgba(255, 180, 171, 0.1);
  --success: #a8e6a1;
  --success-bg: rgba(168, 230, 161, 0.1);
  --warning: #ffdf3f;
  --warning-bg: rgba(255, 223, 63, 0.1);

  --font-body: 'Inter', sans-serif;
  --font-label: 'Space Grotesk', sans-serif;

  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;

  --sidebar-width: 260px;
  --header-height: 64px;
}

::selection {
  background-color: var(--primary-bright);
  color: var(--primary-text);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  overflow-x: clip;
  scroll-behavior: smooth;
  scrollbar-color: #554334 #131313;
  scrollbar-width: thin;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-bright); }

/* ── Layout ────────────────────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-floor);
  border-right: 1px solid var(--outline-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 24px;
  font-family: var(--font-body);
  font-weight: 900;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: -0.05em;
  color: var(--primary-bright);
  border-bottom: 1px solid var(--outline-subtle);
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: var(--bg-raised);
  color: var(--primary);
}

.sidebar-nav a.active {
  color: var(--primary-bright);
  background: rgba(255, 149, 0, 0.06);
  border-left-color: var(--primary-bright);
  font-weight: 600;
}

.sidebar-nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav a.active svg,
.sidebar-nav a:hover svg {
  opacity: 1;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--outline-subtle);
}

.sidebar-footer a {
  font-family: var(--font-label);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.sidebar-footer a:hover { color: var(--error); }

.main-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-height);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--outline-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 700;
}

.topbar-user {
  font-family: var(--font-label);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.content {
  padding: 32px;
  flex: 1;
}

/* ── Cards ─────────────────────────────────────────────────────────── */

.card {
  background: rgba(53, 53, 53, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--outline-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card-flat {
  background: var(--bg-card);
  border: 1px solid var(--outline-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--outline-subtle);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary-bright);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card .stat-sub {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.3;
}

.stat-card .stat-label {
  font-family: var(--font-label);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

/* ── Tables ────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--outline-subtle);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background: var(--bg-elevated);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-family: var(--font-label);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 1px solid var(--outline-subtle);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(85, 67, 52, 0.08);
  color: var(--text);
}

tbody tr:hover {
  background: rgba(255, 149, 0, 0.03);
}

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #ffbd7f, #ff9500);
  color: var(--primary-text);
  box-shadow: 0 4px 12px rgba(255, 149, 0, 0.2);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(255, 149, 0, 0.35);
  transform: translateY(-1px);
  color: var(--primary-text);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--outline);
}

.btn-secondary:hover {
  background: var(--bg-highest);
  color: var(--primary);
}

.btn-danger {
  background: rgba(255, 180, 171, 0.1);
  color: var(--error);
  border: 1px solid rgba(255, 180, 171, 0.25);
}

.btn-danger:hover {
  background: rgba(255, 180, 171, 0.2);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
}

.btn-ghost:hover {
  color: var(--primary);
  background: rgba(255, 149, 0, 0.06);
}

/* ── Forms ─────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-family: var(--font-label);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-input,
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary-bright);
  box-shadow: 0 0 0 2px rgba(255, 149, 0, 0.15);
}

select option {
  background: var(--bg-floor);
  color: var(--text);
}

/* ── Badges ────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-active {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(168, 230, 161, 0.2);
}

.badge-expired {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(255, 180, 171, 0.2);
}

.badge-pending {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(255, 223, 63, 0.2);
}

.badge-blocked {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.badge-no-sub {
  background: rgba(163, 141, 122, 0.12);
  color: var(--text-muted);
  border: 1px solid rgba(163, 141, 122, 0.28);
}

/* VPN usage (short pill: есть / нет — как badge «web» в списке) */
.badge-usage-live {
  background: rgba(34, 139, 87, 0.18);
  color: #7ddf9a;
  border: 1px solid rgba(125, 223, 154, 0.28);
  font-size: 10px;
}

.badge-usage-idle {
  background: rgba(180, 60, 60, 0.14);
  color: #f0a8a0;
  border: 1px solid rgba(240, 168, 160, 0.28);
  font-size: 10px;
}

.badge-usage-unk {
  background: #2f3a4d;
  color: #bcd;
  border: 1px solid rgba(188, 221, 255, 0.12);
  font-size: 10px;
}

/* ── Alerts / Flash ────────────────────────────────────────────────── */

.alert {
  padding: 14px 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(168, 230, 161, 0.2);
}

.alert-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(255, 180, 171, 0.2);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(255, 223, 63, 0.2);
}

.alert-info {
  background: rgba(100, 180, 255, 0.08);
  color: #8ec8ff;
  border: 1px solid rgba(100, 180, 255, 0.15);
}

/* ── Pagination ────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 16px;
  justify-content: center;
}

.pagination a,
.pagination span {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}

.pagination a {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--outline-subtle);
}

.pagination a:hover {
  background: var(--bg-highest);
  color: var(--primary);
}

.pagination .current {
  background: var(--primary-bright);
  color: var(--primary-text);
  font-weight: 700;
}

/* ── Toolbar ───────────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.toolbar .search-box {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.toolbar .filter-group {
  display: flex;
  gap: 4px;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-elevated);
  border: 1px solid var(--outline-subtle);
  color: var(--text-muted);
  transition: all 0.15s;
}

.filter-btn:hover { color: var(--primary); border-color: var(--outline); }
.filter-btn.active {
  background: rgba(255, 149, 0, 0.1);
  color: var(--primary-bright);
  border-color: var(--primary-bright);
}

/* ── Progress bar ──────────────────────────────────────────────────── */

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-dim), var(--primary-bright));
  border-radius: 4px;
  transition: width 0.3s;
}

/* ── Login page ────────────────────────────────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: rgba(53, 53, 53, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--outline-subtle);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
}

.login-card .brand {
  color: var(--primary-bright);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.05em;
}

.login-card .subtitle {
  text-align: center;
  font-family: var(--font-label);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 28px;
}

.login-card .form-input { margin-bottom: 12px; }

.login-card .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 12px;
  margin-top: 8px;
}

/* ── Toggle switch ─────────────────────────────────────────────────── */

.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  cursor: pointer;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--outline);
  border-radius: 12px;
  transition: all 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all 0.2s;
}

.toggle input:checked + .toggle-slider {
  background: rgba(255, 149, 0, 0.2);
  border-color: var(--primary-bright);
}

.toggle input:checked + .toggle-slider::before {
  background: var(--primary-bright);
  transform: translateX(18px);
}

/* ── Details / expandable ──────────────────────────────────────────── */

details {
  border: 1px solid var(--outline-subtle);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

details summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-card);
  border-radius: var(--radius);
}

details[open] summary { border-bottom: 1px solid var(--outline-subtle); }

details .details-body {
  padding: 14px;
  font-size: 13px;
  color: var(--text-dim);
  word-break: break-all;
}

/* ── Misc utilities ────────────────────────────────────────────────── */

.text-dim { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary-bright); }
.text-error { color: var(--error); }
.text-success { color: var(--success); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.font-label { font-family: var(--font-label); }
.font-mono { font-family: 'SF Mono', 'Consolas', monospace; font-size: 13px; }

.mt-1 { margin-top: 4px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mr-2 { margin-right: 8px; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }

.hidden { display: none; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── HTMX transitions ─────────────────────────────────────────────── */

.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }

/* ── Scrollbar ─────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--outline); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-bright); }

/* ── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-area { margin-left: 0; }
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr; }
}
