:root {
  color-scheme: dark;
  --bg: #070a12;
  --surface: rgba(16, 22, 38, 0.6);
  --surface-hover: rgba(22, 30, 52, 0.85);
  --surface-soft: rgba(30, 41, 69, 0.4);
  --text: #f3f4f6;
  --muted: #9ca3af;
  --line: rgba(255, 255, 255, 0.05);
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  --radius: 16px;
  --glow-purple: 0 0 20px rgba(139, 92, 246, 0.15);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: rgba(255, 255, 255, 0.7);
  --surface-hover: rgba(255, 255, 255, 0.9);
  --surface-soft: rgba(243, 244, 246, 0.8);
  --text: #111827;
  --muted: #6b7280;
  --line: rgba(0, 0, 0, 0.06);
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
  --blue: #2563eb;
  --purple: #7c3aed;
  --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
  --glow-purple: 0 0 20px rgba(124, 58, 237, 0.08);
}

* {
  box-sizing: border-box;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.15s ease;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 45%), 
              radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.06) 0%, transparent 45%), 
              var(--bg);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Стилизация скроллбара */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--surface-soft);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Хедер / Шапка сайта */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 40px);
  background: rgba(7, 10, 18, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--purple);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  color: var(--text);
}

.topbar__actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar__status,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: max-content;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 18px;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s;
}

.icon-button:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
  border-color: rgba(139, 92, 246, 0.3);
}

.icon-button:active {
  transform: translateY(0);
}

/* Индикатор статуса SSE */
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  position: relative;
}

.dot::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: inherit;
  animation: pulse 1.8s infinite ease-in-out;
}

.dot--warn {
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
}

.dot--bad {
  background: var(--red);
  box-shadow: 0 0 10px var(--red);
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(2.8);
    opacity: 0;
  }
}

/* Сетка и разметка */
.layout {
  display: grid;
  gap: 20px;
  width: min(1400px, 100%);
  margin: 0 auto;
  padding: 24px clamp(12px, 3vw, 32px) 48px;
}

.summary,
.grid,
.details {
  display: grid;
  gap: 16px;
}

.summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
}

.grid--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid > .panel:only-child {
  grid-column: 1 / -1;
}

/* Карточки метрик (CPU, RAM, Disk, Uptime) */
.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s, box-shadow 0.3s;
}

.metric:hover,
.panel:hover {
  transform: translateY(-4px);
  border-color: rgba(139, 92, 246, 0.2);
  box-shadow: var(--glow-purple), var(--shadow);
}

.metric {
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
}

.metric span,
.details span,
.panel__head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-family: 'Outfit', sans-serif;
  font-size: clamp(24px, 2.5vw, 36px);
  font-weight: 700;
  margin-top: 8px;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--text) 30%, var(--muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.panel {
  padding: 20px;
}

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

.panel__head h2 {
  font-family: 'Outfit', sans-serif;
}

/* Список сайтов */
.sites {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.site {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  transition: transform 0.2s, border-color 0.2s;
}

.site:hover {
  border-color: rgba(139, 92, 246, 0.15);
  transform: scale(1.01);
}

.site__main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site__title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.site__title span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.site__url {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.site__url:hover {
  color: var(--purple);
  text-decoration: underline;
}

/* Бейджи статусов */
.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.15);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.2);
  letter-spacing: 0.02em;
}

.badge--bad {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge--warn {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.site__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 12px;
}

.site__meta span {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.site__code {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  color: var(--muted);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  white-space: nowrap;
}

/* Область под графики */
.chart-wrap {
  position: relative;
  height: 300px;
  max-width: 100%;
}

/* Детали VPS (ячейки) */
.details {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.details div {
  padding: 16px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.details strong {
  display: block;
  margin-top: 6px;
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 600;
}

/* Алерты */
.alerts,
.mini-list,
.bars {
  display: grid;
  gap: 12px;
}

.alert {
  display: grid;
  gap: 4px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 10px;
  background: var(--surface-soft);
}

.alert--critical {
  border-left-color: var(--red);
  background: rgba(239, 68, 68, 0.03);
}

.alert--ok {
  border-left-color: var(--green);
  background: rgba(16, 185, 129, 0.03);
}

.alert strong {
  font-size: 14px;
  font-weight: 600;
}

.alert span {
  color: var(--muted);
  font-size: 13px;
}

/* Списки / Карточки мини-списков */
.row-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.row-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row-card__head strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.row-card span {
  color: var(--muted);
  font-size: 12px;
}

.row-card code {
  color: var(--muted);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Полоски дисков */
.bar {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.bar__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

.bar__meta strong {
  color: var(--text);
  font-weight: 600;
}

.bar__track {
  height: 8px;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

.bar__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar__fill--warn {
  background: var(--amber);
}

.bar__fill--bad {
  background: var(--red);
}

/* Таблицы (процессы) */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

td {
  color: var(--text);
}

td:nth-child(2) {
  white-space: normal;
  overflow-wrap: anywhere;
  font-weight: 500;
}

/* Стили авторизации (Логин) */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.12) 0%, transparent 50%), var(--bg);
}

.auth-wrapper {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.auth-glow {
  position: absolute;
  top: -10%;
  left: -10%;
  width: 120%;
  height: 120%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 60%);
  z-index: 1;
  pointer-events: none;
}

.auth-card {
  position: relative;
  z-index: 2;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 40px 32px;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow: var(--glow-purple);
  margin-bottom: 16px;
}

.auth-logo__icon {
  font-size: 28px;
}

.auth-header h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  text-align: center;
  font-weight: 500;
  animation: shake 0.4s ease-in-out;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper input {
  width: 100%;
  padding: 12px 42px 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.password-input-wrapper input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

.toggle-password-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  font-size: 16px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.toggle-password-btn:hover {
  opacity: 1;
}

.auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--purple) 0%, var(--blue) 100%);
  color: white;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
  transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
}

.auth-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.45);
}

.auth-btn:active {
  transform: translateY(0);
}

.auth-btn:disabled {
  cursor: not-allowed;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.shake {
  animation: shake 0.4s ease-in-out;
}

/* Адаптивность под мобильные устройства */
@media (max-width: 1024px) {
  .summary,
  .grid,
  .grid--three,
  .sites,
  .details {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 22px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 16px;
    gap: 16px;
  }

  .topbar__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .summary,
  .grid,
  .grid--three,
  .sites,
  .details {
    grid-template-columns: 1fr;
  }

  .panel__head,
  .site__main {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .chart-wrap {
    height: 240px;
  }
}
