/* ============================================================
   MTProto Fleet Manager — Design System v2.0
   Premium dark-mode infrastructure dashboard
   ============================================================ */

/* ── 1. Design Tokens ───────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-base:     #060e1a;
  --bg-surface:  #0c1929;
  --bg-elevated: #112035;
  --bg-overlay:  #162740;
  --bg-input:    #0a1625;

  /* Borders */
  --border-subtle:  rgba(99,158,255,.08);
  --border-default: rgba(99,158,255,.14);
  --border-strong:  rgba(99,158,255,.24);

  /* Text */
  --text-primary:   #e8f1ff;
  --text-secondary: #8aa3c2;
  --text-muted:     #4a6585;

  /* Brand */
  --blue:   #3b82f6;
  --cyan:   #06b6d4;
  --violet: #7c3aed;

  /* Semantic */
  --success: #10b981;
  --warning: #f59e0b;
  --danger:  #ef4444;
  --info:    #06b6d4;

  /* Sidebar */
  --sidebar-w: 248px;
  --header-h:  60px;

  /* Misc */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.6);

  --transition: .18s ease;
}

/* ── 2. Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui,
               'Inter', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--cyan); text-decoration: none; transition: color var(--transition); }
a:hover { color: #38d1f0; }

img, svg { display: block; }

code, pre {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: .875em;
}

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

/* ── 4. Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform var(--transition);
  overflow: hidden;
}

.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(6,182,212,.35);
}

.sidebar-brand-icon svg { width: 18px; height: 18px; color: #fff; }

.sidebar-brand-name {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .03em;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: .65rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
  cursor: pointer;
  white-space: nowrap;
}

.nav-item svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  transition: color var(--transition);
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.nav-item.active {
  color: var(--cyan);
  background: rgba(6,182,212,.08);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: linear-gradient(to bottom, var(--cyan), var(--blue));
  border-radius: 0 2px 2px 0;
}

.nav-item.active svg { color: var(--cyan); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: .65rem;
  color: var(--text-muted);
}

.sidebar-logout {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
  display: flex; align-items: center;
}
.sidebar-logout:hover { color: var(--danger); }
.sidebar-logout svg { width: 16px; height: 16px; }

/* ── 5. Header ──────────────────────────────────────────────── */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.app-header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0; z-index: 100;
}

.header-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  align-items: center;
}
.header-menu-btn:hover { color: var(--text-primary); background: var(--bg-elevated); }
.header-menu-btn svg { width: 20px; height: 20px; }

.header-breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  color: var(--text-muted);
  min-width: 0;
}

.header-breadcrumb .bc-sep { color: var(--text-muted); opacity: .5; }
.header-breadcrumb .bc-current {
  color: var(--text-primary);
  font-weight: 600;
  font-size: .9rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── 6. Content Area ────────────────────────────────────────── */
.app-content {
  flex: 1;
  padding: 28px;
  max-width: 1400px;
  width: 100%;
}

/* ── 7. Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
}

.page-subtitle {
  font-size: .875rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.page-actions { display: flex; align-items: center; gap: 8px; }

/* ── 8. Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
}

.card + .card { margin-top: 16px; }

.card-sm { padding: 14px 18px; border-radius: var(--radius-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.card-title {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-sub {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Stat Cards */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.stat-card[class*="stat-card--"]::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-from, var(--cyan)), var(--accent-to, var(--blue)));
  opacity: .7;
}

.stat-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}

.stat-card--blue   { --accent-from: #3b82f6; --accent-to: #06b6d4; }
.stat-card--green  { --accent-from: #10b981; --accent-to: #06b6d4; }
.stat-card--amber  { --accent-from: #f59e0b; --accent-to: #ef4444; }
.stat-card--violet { --accent-from: #7c3aed; --accent-to: #3b82f6; }
.stat-card--red    { --accent-from: #ef4444; --accent-to: #7c3aed; }
.stat-card--cyan   { --accent-from: #06b6d4; --accent-to: #10b981; }

.stat-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }

.stat-icon--blue   { background: rgba(59,130,246,.15); color: #60a5fa; }
.stat-icon--green  { background: rgba(16,185,129,.15); color: #34d399; }
.stat-icon--amber  { background: rgba(245,158,11,.15); color: #fbbf24; }
.stat-icon--violet { background: rgba(124,58,237,.15); color: #a78bfa; }
.stat-icon--red    { background: rgba(239,68,68,.15);  color: #f87171; }
.stat-icon--cyan   { background: rgba(6,182,212,.15);  color: #22d3ee; }

.stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  letter-spacing: -.03em;
}

.stat-label {
  font-size: .775rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stat-delta {
  font-size: .75rem;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-delta--up   { color: var(--success); }
.stat-delta--down { color: var(--danger); }
.stat-delta--neutral { color: var(--text-muted); }

/* ── 9. Stat Grid ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ── 10. Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: .8125rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
  position: relative;
  outline: none;
}

.btn:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn:disabled, .btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 1px 4px rgba(37,99,235,.4);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 2px 12px rgba(37,99,235,.5);
  color: #fff;
}
.btn-primary:active { transform: translateY(1px); }

/* Cyan / brand */
.btn-cyan {
  background: linear-gradient(135deg, var(--cyan), #0891b2);
  color: #fff;
  box-shadow: 0 1px 4px rgba(6,182,212,.35);
}
.btn-cyan:hover {
  background: linear-gradient(135deg, #22d3ee, var(--cyan));
  color: #fff;
  box-shadow: 0 2px 12px rgba(6,182,212,.45);
}

/* Secondary */
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}
.btn-secondary:hover {
  background: var(--bg-overlay);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

/* Danger */
.btn-danger {
  background: rgba(239,68,68,.15);
  color: #f87171;
  border: 1px solid rgba(239,68,68,.25);
}
.btn-danger:hover {
  background: rgba(239,68,68,.25);
  color: #fca5a5;
  border-color: rgba(239,68,68,.4);
}

/* Warning */
.btn-warning {
  background: rgba(245,158,11,.15);
  color: #fbbf24;
  border: 1px solid rgba(245,158,11,.25);
}
.btn-warning:hover {
  background: rgba(245,158,11,.25);
  border-color: rgba(245,158,11,.4);
}

/* Success */
.btn-success {
  background: rgba(16,185,129,.15);
  color: #34d399;
  border: 1px solid rgba(16,185,129,.25);
}
.btn-success:hover {
  background: rgba(16,185,129,.25);
  border-color: rgba(16,185,129,.4);
}

/* Violet */
.btn-violet {
  background: rgba(124,58,237,.2);
  color: #a78bfa;
  border: 1px solid rgba(124,58,237,.3);
}
.btn-violet:hover {
  background: rgba(124,58,237,.35);
  border-color: rgba(124,58,237,.5);
}

/* Amber */
.btn-amber {
  background: rgba(245,158,11,.15);
  color: #fbbf24;
  border: 1px solid rgba(245,158,11,.2);
}
.btn-amber:hover { background: rgba(245,158,11,.25); }

/* Sizes */
.btn-sm { padding: 5px 11px; font-size: .75rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 11px 22px; font-size: .9375rem; }
.btn-xl { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 7px; }
.btn-icon svg { width: 16px; height: 16px; }

/* ── 11. Badges / Status ────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Status badges */
.badge-active    { background: rgba(16,185,129,.15); color: #34d399; border: 1px solid rgba(16,185,129,.25); }
.badge-active .badge-dot    { background: #10b981; box-shadow: 0 0 6px #10b981; }

.badge-inactive  { background: rgba(100,116,139,.12); color: #94a3b8; border: 1px solid rgba(100,116,139,.2); }
.badge-installing { background: rgba(245,158,11,.12); color: #fbbf24; border: 1px solid rgba(245,158,11,.2); }
.badge-installing .badge-dot { background: #f59e0b; animation: pulse-dot 1.5s infinite; }

.badge-error     { background: rgba(239,68,68,.12); color: #f87171; border: 1px solid rgba(239,68,68,.22); }
.badge-error .badge-dot { background: #ef4444; }

.badge-warning   { background: rgba(245,158,11,.12); color: #fbbf24; border: 1px solid rgba(245,158,11,.22); }
.badge-creating  { background: rgba(59,130,246,.12); color: #60a5fa; border: 1px solid rgba(59,130,246,.22); }
.badge-warming   { background: rgba(245,158,11,.12); color: #fbbf24; border: 1px solid rgba(245,158,11,.2); }
.badge-disabled  { background: rgba(75,101,133,.12); color: #4b6585; border: 1px solid rgba(75,101,133,.2); }
.badge-blocked   { background: rgba(239,68,68,.12); color: #f87171; border: 1px solid rgba(239,68,68,.22); }
.badge-standby   { background: rgba(6,182,212,.1);  color: #22d3ee; border: 1px solid rgba(6,182,212,.2); }
.badge-new       { background: rgba(59,130,246,.1);  color: #60a5fa; border: 1px solid rgba(59,130,246,.2); }
.badge-cooldown  { background: rgba(124,58,237,.12); color: #a78bfa; border: 1px solid rgba(124,58,237,.22); }
.badge-dead      { background: rgba(30,41,59,.5);    color: #4b5563; border: 1px solid rgba(30,41,59,.8); }
.badge-suspected { background: rgba(245,158,11,.12); color: #fbbf24; border: 1px solid rgba(245,158,11,.2); }
.badge-testing   { background: rgba(100,116,139,.12); color: #94a3b8; border: 1px solid rgba(100,116,139,.2); }
.badge-critical  { background: rgba(239,68,68,.18); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.badge-info      { background: rgba(6,182,212,.12); color: #22d3ee; border: 1px solid rgba(6,182,212,.22); }
.badge-success   { background: rgba(16,185,129,.15); color: #34d399; border: 1px solid rgba(16,185,129,.25); }
.badge-dns_error { background: rgba(245,158,11,.12); color: #fbbf24; border: 1px solid rgba(245,158,11,.2); }
.badge-service_error { background: rgba(239,68,68,.12); color: #f87171; border: 1px solid rgba(239,68,68,.22); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ── 12. Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: .01em;
}

.form-hint {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.4;
}

.form-input, .form-select, .form-textarea {
  display: block;
  width: 100%;
  padding: 9px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: .875rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 34px;
  cursor: pointer;
}

.form-select option { background: var(--bg-elevated); }

.form-textarea { resize: vertical; line-height: 1.5; }

.form-input-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: .8rem; }

/* Form grid */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-col-span-2 { grid-column: span 2; }
.form-col-span-3 { grid-column: span 3; }

/* Section divider in forms */
.form-section {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 18px 0 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.form-section:first-child { padding-top: 0; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

/* ── 13. Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8375rem;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: rgba(255,255,255,.025);
}

.data-table td.td-primary { color: var(--text-primary); font-weight: 600; }
.data-table td.td-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: .8rem; }
.data-table td.td-action { width: 1px; white-space: nowrap; }

.table-actions { display: flex; align-items: center; gap: 6px; }

/* ── 14. Progress Bars ──────────────────────────────────────── */
.progress-wrap { }
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  font-size: .72rem;
}
.progress-label { color: var(--text-secondary); }
.progress-value { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }

.progress-track {
  height: 5px;
  background: var(--bg-overlay);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  transition: width .5s ease;
}

.progress-bar--blue   { background: linear-gradient(90deg, #2563eb, #06b6d4); }
.progress-bar--green  { background: linear-gradient(90deg, #059669, #10b981); }
.progress-bar--amber  { background: linear-gradient(90deg, #d97706, #f59e0b); }
.progress-bar--red    { background: linear-gradient(90deg, #dc2626, #ef4444); }

/* ── 15. Alerts / Flash Messages ────────────────────────────── */
.flash-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.flash {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-size: .8375rem;
  font-weight: 500;
  line-height: 1.5;
  animation: flashIn .25s ease;
}

.flash svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.flash-success {
  background: rgba(16,185,129,.1);
  color: #34d399;
  border: 1px solid rgba(16,185,129,.2);
}

.flash-error {
  background: rgba(239,68,68,.1);
  color: #f87171;
  border: 1px solid rgba(239,68,68,.2);
}

.flash-warning {
  background: rgba(245,158,11,.1);
  color: #fbbf24;
  border: 1px solid rgba(245,158,11,.2);
}

@keyframes flashIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 16. Toasts ─────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: .8375rem;
  font-weight: 500;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  min-width: 280px;
  max-width: 400px;
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
}

.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast-msg { flex: 1; line-height: 1.4; }

.toast--success { border-color: rgba(16,185,129,.3); color: #34d399; }
.toast--error   { border-color: rgba(239,68,68,.3);  color: #f87171; }
.toast--warning { border-color: rgba(245,158,11,.3); color: #fbbf24; }
.toast--info    { border-color: rgba(6,182,212,.3);  color: #22d3ee; }

.toast-exit {
  animation: toastOut .25s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px) scale(.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(30px) scale(.95); }
}

/* ── 17. Modal Confirm ──────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6,14,26,.75);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}

.modal-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: scaleIn .2s cubic-bezier(.34,1.56,.64,1);
}

.modal-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.modal-icon--danger { background: rgba(239,68,68,.15); color: #f87171; }
.modal-icon--warning { background: rgba(245,158,11,.15); color: #fbbf24; }
.modal-icon svg { width: 24px; height: 24px; }

.modal-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.modal-body {
  font-size: .875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }

/* ── 18. Code Console ───────────────────────────────────────── */
.console-output {
  display: none;
  margin-top: 14px;
  padding: 14px 16px;
  background: #020810;
  border: 1px solid rgba(6,182,212,.2);
  border-radius: var(--radius-md);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .75rem;
  color: #22c55e;
  max-height: 380px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
  box-shadow: inset 0 0 20px rgba(0,0,0,.5);
}

.console-output.visible { display: block; }
.console-output.console--error { color: #f87171; }

/* ── 19. Empty States ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  color: var(--text-muted);
}
.empty-icon svg { width: 26px; height: 26px; }

.empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: .8375rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* ── 20. Info Grid (key-value pairs) ────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.info-grid--3 { grid-template-columns: 1fr 1fr 1fr; }

.info-item {}

.info-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.info-value {
  font-size: .9rem;
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-word;
}

.info-value--mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .8rem;
  word-break: break-all;
}

.info-value--muted { color: var(--text-muted); }

/* ── 21. Danger Zone ────────────────────────────────────────── */
.danger-zone {
  border: 1px solid rgba(239,68,68,.2);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  background: rgba(239,68,68,.03);
}

.danger-zone-title {
  font-size: .875rem;
  font-weight: 700;
  color: #f87171;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.danger-zone-desc {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

/* ── 22. Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
}

.pagination a {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.pagination a:hover {
  background: var(--bg-overlay);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.pagination a.active, .pagination a:nth-child(n).active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.pagination-info {
  font-size: .8rem;
  color: var(--text-muted);
  padding: 0 8px;
}

/* ── 23. Login Page ─────────────────────────────────────────── */
.login-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}

.login-layout::before {
  content: '';
  position: absolute;
  top: -200px; left: 50%;
  transform: translateX(-50%);
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(59,130,246,.08) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 20px rgba(6,182,212,.3);
}

.login-logo-icon svg { width: 24px; height: 24px; color: #fff; }

.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: .8rem;
  color: var(--text-muted);
}

/* ── 24. Filter Bar ─────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-label { font-size: .7rem; font-weight: 700; color: var(--text-muted); letter-spacing: .06em; text-transform: uppercase; }
.filter-actions { display: flex; gap: 8px; align-self: flex-end; }

/* ── 25. Section Grid Layout ────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.equal-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── 26. Misc Utilities ─────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-sm  { font-size: .8125rem; }
.text-xs  { font-size: .725rem; }
.text-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-cyan    { color: var(--cyan); }
.text-blue    { color: var(--blue); }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }

.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.flex-wrap    { flex-wrap: wrap; }
.flex-1       { flex: 1; min-width: 0; }
.shrink-0     { flex-shrink: 0; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break-all { word-break: break-all; }

.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 16px 0;
}

/* Inline code */
.code-inline {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .8em;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--cyan);
}

/* Sidebar overlay backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 150;
}

/* ── 27. Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .two-col   { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr 1fr; }
  .info-grid--3 { grid-template-columns: 1fr 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-248px);
    width: 248px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-backdrop.open { display: block; }

  .app-main { margin-left: 0; }

  .header-menu-btn { display: flex; }

  .app-content { padding: 16px; }
  .app-header { padding: 0 16px; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .equal-col  { grid-template-columns: 1fr; }
  .three-col  { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-col-span-2 { grid-column: span 1; }

  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
}
