:root {
  --bg: #07090f;
  --bg-soft: #0b0f19;
  --panel: #101522;
  --panel-2: #151b2b;
  --panel-3: #1b2336;
  --line: rgba(148, 163, 184, .14);
  --line-strong: rgba(148, 163, 184, .24);
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --accent: #ef1717;
  --accent-2: #b90f1a;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 16px;
  --sidebar-w: 268px;
  --shadow: 0 22px 70px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(239, 23, 23, .16), transparent 28rem),
    radial-gradient(circle at 90% 10%, rgba(59, 130, 246, .10), transparent 24rem),
    linear-gradient(180deg, #07090f 0%, #090d15 100%);
}
button, input { font: inherit; }
code { padding: 2px 7px; border-radius: 8px; background: rgba(148,163,184,.12); color: #dbeafe; }

.hidden { display: none !important; }
.boot-screen { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.spinner { width: 42px; height: 42px; border: 3px solid rgba(148,163,184,.18); border-top-color: var(--accent); border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; }
.login-card {
  width: min(420px, 100%);
  padding: 32px;
  background: linear-gradient(180deg, rgba(16,21,34,.94), rgba(10,14,23,.94));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.login-brand { font-size: 2rem; font-weight: 900; text-align: center; letter-spacing: -.04em; }
.login-brand::first-letter { color: var(--accent); }
.login-sub { margin: 6px 0 26px; text-align: center; color: var(--muted); }
.error-text { min-height: 1.2em; margin: 12px 0 0; color: #fecaca; text-align: center; font-size: .88rem; }

/* Shell */
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar-w);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(16,21,34,.98), rgba(9,13,22,.98));
  border-right: 1px solid var(--line);
  box-shadow: 16px 0 60px rgba(0,0,0,.24);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 24px;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: -.03em;
}
.sidebar-brand small {
  display: block;
  margin-top: 1px;
  color: var(--muted-2);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.logo-dot {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #ff6b6b);
  box-shadow: 0 14px 34px rgba(239,23,23,.36);
}
.logo-dot::after { content: ""; display: block; width: 10px; height: 10px; margin: 12px; border-radius: 50%; background: #fff; opacity: .92; }
.nav { display: flex; flex-direction: column; gap: 7px; flex: 1; }
.nav-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 12px 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-weight: 750;
}
.nav-item:hover { background: rgba(148,163,184,.08); color: var(--text); border-color: var(--line); }
.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 14px 34px rgba(239, 23, 23, .22);
}
.nav-ico {
  width: 34px;
  height: 28px;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  background: rgba(255,255,255,.08);
  font-size: .62rem;
  font-weight: 900;
  letter-spacing: .06em;
}
.sidebar-foot { margin-top: auto; padding: 18px 4px 4px; }
.sidebar-credit { margin: 14px 0 0; text-align: center; color: var(--muted-2); font-size: .75rem; }

.content { width: 100%; min-width: 0; margin-left: var(--sidebar-w); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 74px;
  padding: 0 34px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(7,9,15,.76);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.topbar h1 { margin: 0; font-size: 1.35rem; letter-spacing: -.035em; }
.page-kicker {
  display: block;
  margin-bottom: 2px;
  color: var(--muted-2);
  font-size: .73rem;
  font-weight: 850;
  letter-spacing: .10em;
  text-transform: uppercase;
}
.icon-btn {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.section {
  display: none;
  max-width: 1120px;
  padding: 30px 34px 72px;
}
.section.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Cards */
.card {
  background: linear-gradient(180deg, rgba(16,21,34,.95), rgba(13,18,30,.95));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 16px 45px rgba(0,0,0,.18);
}
.card + .card { margin-top: 18px; }
.card-title { margin: 0 0 16px; font-size: 1.05rem; letter-spacing: -.025em; }
.hint { margin: -6px 0 18px; color: var(--muted); font-size: .9rem; line-height: 1.65; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { margin-bottom: 14px; }
.field-wide { grid-column: 1 / -1; }
label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.input {
  width: 100%;
  min-height: 44px;
  padding: 11px 13px;
  color: var(--text);
  background: rgba(2,6,23,.42);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input:focus { border-color: rgba(239,23,23,.68); box-shadow: 0 0 0 4px rgba(239,23,23,.11); background: rgba(2,6,23,.56); }
.input::placeholder { color: #596579; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }

.btn {
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease, opacity .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 12px 28px rgba(239,23,23,.22); }
.btn-secondary { color: var(--text); background: rgba(148,163,184,.09); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--line-strong); background: rgba(148,163,184,.14); }
.btn-danger { color: #fecaca; background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.22); }
.btn-block { width: 100%; display: block; }

/* Table */
.table-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: rgba(2,6,23,.20); }
table { width: 100%; min-width: 640px; border-collapse: collapse; }
th {
  padding: 13px 14px;
  background: rgba(148,163,184,.06);
  color: var(--muted);
  font-size: .74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  text-align: left;
}
td { padding: 12px 14px; border-top: 1px solid var(--line); font-size: .9rem; }
tbody tr:hover { background: rgba(148,163,184,.04); }
td:last-child { white-space: nowrap; text-align: right; }
td .input { min-height: 38px; padding: 8px 10px; border-radius: 10px; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.mono { font-family: Consolas, "SF Mono", ui-monospace, monospace; font-size: .82rem; word-break: break-all; }
.muted { color: var(--muted); font-size: .88rem; }

/* Security */
.status-row {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.status-row:first-of-type { border-top: 0; }
.status-label { color: var(--muted); font-size: .88rem; }
.badge {
  width: fit-content;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(148,163,184,.10);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}
.badge.ok { background: rgba(34,197,94,.13); color: #86efac; }
.badge.err { background: rgba(239,68,68,.13); color: #fecaca; }
.bullets { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.8; font-size: .9rem; }
.bullets b { color: var(--text); }

.footer { text-align: center; padding: 14px; font-size: .8rem; color: var(--muted-2); }
.footer b { color: var(--text); }
.footer-static { position: absolute; bottom: 12px; left: 0; right: 0; }
.overlay { position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.58); backdrop-filter: blur(4px); }

/* Card head + helpers */
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-head .card-title { margin: 0; }
.card-sub { margin: 4px 0 0; color: var(--muted-2); font-size: .82rem; }
.card-sub span { color: var(--text); font-weight: 800; }
.btn-sm { min-height: 36px; padding: 7px 13px; font-size: .85rem; }
.btn-ico { display: inline-block; margin-right: 4px; font-weight: 900; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* Add server form */
.add-server { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 14px; align-items: end; }
.add-server .field { margin-bottom: 0; }
.add-server .btn { height: 44px; white-space: nowrap; }

/* Server list (cards instead of table) */
.server-list { display: flex; flex-direction: column; gap: 10px; }
.server-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: rgba(2,6,23,.30);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color .15s ease, background .15s ease, opacity .2s ease, transform .2s ease;
}
.server-item:hover { border-color: var(--line-strong); }
.server-item.saving { opacity: .7; }
.server-item.saved { border-color: rgba(34,197,94,.55); box-shadow: 0 0 0 3px rgba(34,197,94,.12); }
.server-item.removing { opacity: 0; transform: translateX(14px); }
.server-fields { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; min-width: 0; }
.server-fields .input { min-height: 40px; }

/* Toggle switch */
.switch { position: relative; display: inline-flex; width: 44px; height: 25px; cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0;
  background: rgba(148,163,184,.22);
  border-radius: 999px;
  transition: background .18s ease;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 19px; height: 19px; border-radius: 50%;
  background: #fff; transition: transform .18s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.switch input:checked + .switch-track { background: linear-gradient(135deg, var(--success), #16a34a); }
.switch input:checked + .switch-track::after { transform: translateX(19px); }

/* Delete icon button */
.icon-del {
  width: 38px; height: 38px; flex: none;
  border-radius: 10px;
  border: 1px solid rgba(239,68,68,.22);
  background: rgba(239,68,68,.10);
  color: #fecaca; cursor: pointer; font-size: 1rem;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.icon-del:hover { background: rgba(239,68,68,.20); border-color: rgba(239,68,68,.4); transform: translateY(-1px); }

/* Empty state */
.empty-state { text-align: center; padding: 40px 16px; }
.empty-state .empty-ico { font-size: 2.4rem; margin-bottom: 10px; }
.empty-state p { margin: 0 0 4px; font-weight: 700; }

/* Toasts */
.toasts {
  position: fixed; z-index: 60; right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(360px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 15px;
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(21,27,43,.98), rgba(13,18,30,.98));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  color: var(--text); font-size: .9rem; font-weight: 600;
  opacity: 0; transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast-ico {
  width: 24px; height: 24px; flex: none;
  display: grid; place-items: center; border-radius: 50%;
  font-size: .78rem; font-weight: 900; color: #fff;
}
.toast-success .toast-ico { background: var(--success); }
.toast-error .toast-ico { background: var(--danger); }
.toast-info .toast-ico { background: #3b82f6; }
.toast-error { border-color: rgba(239,68,68,.4); }
.toast-success { border-color: rgba(34,197,94,.35); }

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: none; }
  .content { margin-left: 0; }
  .icon-btn { display: inline-grid; place-items: center; }
  .topbar { height: 66px; padding: 0 16px; }
  .section { padding: 18px 14px 56px; }
  .form-grid, .status-row { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; }
  .card { padding: 18px; }
  .add-server { grid-template-columns: 1fr; }
  .add-server .btn { width: 100%; }
  .server-fields { grid-template-columns: 1fr; }
  .toasts { right: 12px; left: 12px; bottom: 12px; max-width: none; }
}
