:root {
  --bg-main: #09090d;
  --bg-card: #12121a;
  --bg-card-hover: #181823;
  --bg-input: #0d0d14;
  --border-color: #242434;
  --border-accent: rgba(229, 9, 20, 0.45);
  --primary: #e50914;
  --primary-hover: #ff1e29;
  --primary-glow: rgba(229, 9, 20, 0.28);
  --text-main: #f4f4f8;
  --text-muted: #9292a8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

html,
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
  color-scheme: dark;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #0b0b10;
}

::-webkit-scrollbar-thumb {
  background: #272736;
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3a3a4e;
}

textarea {
  min-height: 110px !important;
  resize: vertical;
}

.hidden {
  display: none !important;
}

html.is-authenticated #authScreen {
  display: none !important;
}

html.is-authenticated #appScreen {
  display: flex !important;
}

.sidebar-backdrop {
  display: none;
}

/* АВТОРИЗАЦИЯ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 15%, rgba(229, 9, 20, 0.16), transparent 60%), var(--bg-main);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  width: 84px;
  height: 84px;
  object-fit: contain;
  margin-bottom: 12px;
  filter: drop-shadow(0 6px 18px rgba(229, 9, 20, 0.35));
}

.auth-brand h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1px;
}

.auth-brand h1 span {
  color: var(--primary);
}

.auth-brand p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.auth-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* ОСНОВНОЙ ЛЕЙАУТ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 270px;
  background: #0d0d14;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand-title {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.6px;
}

.brand-title span {
  color: var(--primary);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.mobile-close-btn {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.18s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(229, 9, 20, 0.12);
  border-color: rgba(229, 9, 20, 0.35);
  color: #ffffff;
  font-weight: 600;
}

.ic {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
}

.ic-sm {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-dot.warning {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
}

.status-dot.offline {
  background: var(--danger);
}

/* ВЕРХНЯЯ ПАНЕЛЬ И КОНТЕНТ */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 68px;
  padding: 0 28px;
  background: rgba(18, 18, 26, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.burger-btn {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
}

.topbar h2 {
  font-size: 19px;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.api-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.content-area {
  padding: 28px;
  flex: 1;
  max-width: 1440px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.tab-pane.active {
  display: flex;
}

/* КАРТОЧКИ И СЕТКИ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 18px;
  min-width: 0;
  width: 100%;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  min-width: 0;
}

.stat-card.accent-red {
  background: linear-gradient(135deg, rgba(229, 9, 20, 0.16), var(--bg-card));
  border-color: var(--border-accent);
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  margin: 8px 0 4px;
}

.stat-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.grid-2col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 20px;
  min-width: 0;
  width: 100%;
}

.grid-2col > *,
.servers-cards-grid > *,
.stats-grid > *,
.form-row > * {
  min-width: 0;
  max-width: 100%;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-wrap: break-word;
}

.max-w-700 {
  max-width: 860px;
  width: 100%;
}

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

.card-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 22px;
  min-width: 0;
  max-width: 100%;
}

.section-toolbar > div:first-child {
  flex: 1 1 220px;
  min-width: 0;
}

.section-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.section-toolbar .section-desc {
  margin-bottom: 0;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
}

/* КАРТОЧКИ СЕРВЕРОВ */
.servers-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: 20px;
  min-width: 0;
}

.server-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.server-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: var(--srv-color, var(--primary));
}

.server-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.server-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.server-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}

.badge-red {
  background: rgba(229, 9, 20, 0.2);
  color: #ff6b72;
  border: 1px solid rgba(229, 9, 20, 0.4);
}

.badge-green {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-yellow {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-gray {
  background: rgba(146, 146, 168, 0.15);
  color: var(--text-muted);
}

.online-bar-wrap {
  background: #0b0b12;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.online-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: #1d1d2b;
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #ff4b55);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.maint-banner {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  color: #fde68a;
}

.server-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

/* ФОРМЫ И КНОПКИ */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  width: 100%;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 14px;
  min-width: 0;
  width: 100%;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #d0d0e0;
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-main);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

input[type="color"] {
  width: 100%;
  height: 40px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.checkbox-label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s ease;
  color: var(--text-main);
  text-decoration: none;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #1e1e2c;
  border-color: #2f2f44;
}

.btn-secondary:hover {
  background: #272738;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.28);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

/* ТАБЛИЦЫ */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.skin-item-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px;
  min-width: 0;
  max-width: 100%;
}

.skin-item-thumb {
  width: 68px;
  height: 68px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.16);
  flex-shrink: 0;
}

.skin-item-info {
  flex: 1 1 180px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.skin-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.data-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 13px;
  word-break: normal;
  overflow-wrap: normal;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  word-break: normal;
  overflow-wrap: normal;
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

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

.info-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.mini-server-list,
.selections-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mini-srv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

/* МОДАЛЬНОЕ ОКНО */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}

.modal-dialog {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

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

/* ТОСТЫ И АЛЕРТЫ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 300;
}

.toast {
  background: #181824;
  border-left: 4px solid var(--primary);
  border-top: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  font-weight: 500;
}

/* АДАПТИВНОСТЬ (ПЛАНШЕТЫ И ТЕЛЕФОНЫ) */
@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 84vw);
    transform: translate3d(-102%, 0, 0);
    will-change: transform;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 12px 0 32px rgba(0, 0, 0, 0.75);
  }

  .sidebar.open {
    transform: translate3d(0, 0, 0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-close-btn,
  .burger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar {
    height: auto;
    min-height: 60px;
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .topbar-left {
    flex: 1 1 auto;
    min-width: 0;
    gap: 10px;
  }

  .topbar h2 {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-right {
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    justify-content: flex-start;
  }

  .content-area {
    padding: 14px;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .tab-pane {
    gap: 16px;
    min-width: 0;
  }

  .grid-2col,
  .servers-cards-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .card,
  .server-card {
    padding: 16px;
  }

  .section-toolbar {
    padding: 14px 16px;
    flex-direction: column;
    align-items: stretch;
  }

  .section-toolbar > div:first-child {
    flex: 0 0 auto;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions .btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 600px) {
  .auth-card {
    padding: 24px 18px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat-card {
    padding: 14px 12px;
  }

  .stat-value {
    font-size: 24px;
    margin: 4px 0 2px;
  }

  .stat-label {
    font-size: 12px;
  }

  .stat-meta {
    font-size: 11px;
  }

  .form-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .server-card-actions {
    flex-direction: column;
  }

  .server-card-actions .btn {
    width: 100%;
    margin-left: 0 !important;
  }

  .online-bar-header {
    flex-wrap: wrap;
    gap: 4px;
  }

  .mini-srv-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .modal-dialog {
    padding: 16px;
    max-height: 92vh;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
}
