:root {
  --bg: #e8eef2;
  --bg-deep: #d5e0e8;
  --ink: #122033;
  --muted: #5a6b7c;
  --muted-2: #8494a4;
  --panel: #f7fafc;
  --line: rgba(18, 32, 51, 0.1);
  --accent: #0d7a6f;
  --accent-h: #0a635a;
  --accent-soft: rgba(13, 122, 111, 0.12);
  --danger: #b42318;
  --sidebar: #152536;
  --sidebar-text: #d7e2ec;
  --sidebar-muted: #8aa0b4;
  --shadow: 0 18px 40px rgba(18, 32, 51, 0.12);
  --radius: 14px;
  --font: "Outfit", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(13, 122, 111, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(21, 37, 54, 0.1), transparent 50%),
    linear-gradient(160deg, var(--bg), var(--bg-deep));
  background-attachment: fixed;
}

body.auth-pending .login-screen,
body.auth-pending .app-shell { display: none !important; }
body:not(.authed) .app-shell { display: none !important; }
body.authed .login-screen { display: none !important; }
body.authed .app-shell { display: grid; }

.auth-boot {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 50;
}
body.auth-pending .auth-boot { display: flex; }
.auth-boot-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(18, 32, 51, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-screen {
  min-height: 100%;
  display: none;
  flex-direction: column;
}
body:not(.authed):not(.auth-pending) .login-screen { display: flex; }

.login-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 28px;
}
.login-top-mark,
.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(145deg, #0d7a6f, #155e75);
}
.login-top-name, .logo-name { font-weight: 700; font-size: 18px; line-height: 1.1; }
.login-top-sub, .logo-sub { color: var(--muted); font-size: 13px; }

.login-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px 40px;
}
.login-grid {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: rise .45s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.login-hero {
  padding: 42px 36px;
  background:
    linear-gradient(155deg, rgba(13, 122, 111, 0.92), rgba(21, 37, 54, 0.96)),
    repeating-linear-gradient(
      -18deg,
      transparent,
      transparent 10px,
      rgba(255, 255, 255, 0.03) 10px,
      rgba(255, 255, 255, 0.03) 11px
    );
  color: #eff7f6;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 420px;
}
.login-hero-kicker {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  opacity: 0.75;
}
.login-hero h2 {
  margin: 0 0 12px;
  font-size: 34px;
  line-height: 1.15;
  font-weight: 650;
  max-width: 11ch;
}
.login-hero p {
  margin: 0;
  max-width: 28ch;
  color: rgba(239, 247, 246, 0.78);
  font-size: 15px;
  line-height: 1.45;
}
.login-card {
  padding: 42px 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-card-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.login-card h1 {
  margin: 0 0 22px;
  font-size: 26px;
  font-weight: 650;
}
.login-card label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  margin-bottom: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-err {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  margin: 0 0 10px;
}
.btn-login {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 13px 16px;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.btn-login:hover { background: var(--accent-h); }
.btn-login:active { transform: translateY(1px); }
.btn-login:disabled { opacity: .6; cursor: wait; }

.app-shell {
  min-height: 100%;
  grid-template-columns: 240px 1fr;
}
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  min-height: 100vh;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 22px;
}
.sidebar .logo-sub { color: var(--sidebar-muted); }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); }
.nav-item.active {
  background: rgba(13, 122, 111, 0.28);
  color: #fff;
}
.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-chip {
  font-size: 13px;
  color: var(--sidebar-muted);
  padding: 0 8px;
}
.btn-logout {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--sidebar-text);
  font: inherit;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
}
.btn-logout:hover { background: rgba(255, 255, 255, 0.06); }

.main {
  padding: 28px 32px 40px;
  animation: rise .4s ease both;
}
.main-head h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 650;
}
.main-head p {
  margin: 0 0 22px;
  color: var(--muted);
}

.servers-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 720px;
}
.server-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 18px;
  align-items: center;
  padding: 16px 18px;
  background: rgba(247, 250, 252, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  transition: border-color .15s, transform .15s;
}
.server-row:hover {
  border-color: rgba(13, 122, 111, 0.35);
  transform: translateY(-1px);
}
.server-name {
  font-weight: 600;
  font-size: 15px;
}
.server-note {
  grid-column: 1;
  color: var(--muted);
  font-size: 13px;
}
.server-addr {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent-h);
  text-align: right;
  white-space: nowrap;
}
.server-ip {
  grid-column: 2;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted-2);
  text-align: right;
}
.servers-loading,
.servers-empty {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 820px) {
  .login-grid { grid-template-columns: 1fr; }
  .login-hero { min-height: 0; padding: 28px 24px; }
  .login-hero h2 { max-width: none; font-size: 26px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: 0; }
  .main { padding: 20px 16px 32px; }
  .server-row {
    grid-template-columns: 1fr;
  }
  .server-addr, .server-ip { text-align: left; }
}
