html,
body {
  height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(14, 165, 233, 0.16), transparent 32%),
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.14), transparent 30%),
    #030712;
  color: #e2e8f0;
  font-family: "Plus Jakarta Sans", "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

#appView {
  min-height: 100dvh;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

.topbar {
  min-height: 52px;
  background: #0b1220;
  border-bottom: 1px solid #1f2a44;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  gap: 12px;
}

.title {
  font-size: 16px;
  font-weight: 700;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 170px;
  background: #0b1220;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 6px;
  display: grid;
  gap: 6px;
  z-index: 20;
}

.dropdown-item {
  width: 100%;
  text-align: left;
}

button,
select,
input {
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #e2e8f0;
  padding: 8px 12px;
  font-size: 13px;
}

button {
  cursor: pointer;
}

button.primary {
  background: #2563eb;
  border-color: #3b82f6;
}

button.warn {
  background: #7c2d12;
  border-color: #ea580c;
}

button.ok {
  background: #14532d;
  border-color: #22c55e;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #1f2a44;
  background: #071022;
}

.tab {
  border-radius: 999px;
  min-width: 110px;
}

.tab.active {
  background: #1d4ed8;
  border-color: #3b82f6;
  font-weight: 700;
}

.main-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 320px;
  overflow: hidden;
}

#terminal {
  height: 100%;
  min-height: 0;
}

.side-panel {
  border-left: 1px solid #1f2a44;
  background: #070f1d;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.panel-section {
  padding: 10px 12px;
  border-bottom: 1px solid #1f2a44;
}

.panel-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
  max-height: 220px;
}

.list li {
  font-size: 12px;
  line-height: 1.35;
  padding: 8px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: #0d172b;
  border: 1px solid #1f2a44;
}

.state-badge {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid #334155;
}

.state-connected {
  background: #14532d;
  border-color: #22c55e;
}

.state-failed {
  background: #7f1d1d;
  border-color: #ef4444;
}

.state-connecting {
  background: #1e3a8a;
  border-color: #60a5fa;
}

.state-disconnected {
  background: #111827;
  border-color: #374151;
}

.login-shell {
  width: min(980px, calc(100% - 32px));
  margin: clamp(24px, 8vh, 72px) auto;
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(300px, 0.9fr);
  gap: 16px;
  align-items: stretch;
}

.login-context,
.login-card {
  border: 1px solid #1f2a44;
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(11, 18, 32, 0.95), rgba(7, 15, 29, 0.92));
  box-shadow: 0 18px 36px rgba(2, 6, 23, 0.45);
}

.login-context {
  padding: 24px;
  display: grid;
  gap: 12px;
}

.login-kicker {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 700;
  color: #fde68a;
}

.login-context h1 {
  margin: 0;
  font-size: clamp(26px, 3.5vw, 38px);
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.login-points {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.login-points li {
  border: 1px solid #1f2a44;
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.78);
  color: #cbd5e1;
  font-size: 13px;
}

.login-card {
  padding: 20px;
  display: grid;
  align-content: center;
  gap: 10px;
}

.login-card h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.login-card form {
  display: grid;
  gap: 10px;
}

.login-footnote {
  font-size: 12px;
}

.error {
  color: #fca5a5;
  font-size: 12px;
}

.success-text {
  color: #86efac;
  font-size: 12px;
}

.admin-layout {
  padding: 12px;
  display: grid;
  gap: 12px;
}

.settings-layout {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
}

.settings-card {
  min-height: 180px;
}

.settings-card-wide {
  grid-column: 1 / -1;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 8px;
}

.admin-shell {
  height: calc(100% - 52px);
  display: grid;
  grid-template-columns: 220px 1fr;
}

.admin-sidebar {
  border-right: 1px solid #1f2a44;
  background: #070f1d;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-tab {
  text-align: left;
  width: 100%;
}

.sidebar-tab.active {
  background: #1d4ed8;
  border-color: #3b82f6;
  font-weight: 700;
}

.admin-main {
  min-width: 0;
  overflow: auto;
  padding: 12px;
}

.admin-pane {
  display: none;
}

.admin-pane.active {
  display: grid;
  gap: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.stat-box {
  border: 1px solid #1f2a44;
  border-radius: 12px;
  padding: 10px;
  background: #0f1a2f;
}

.stat-label {
  font-size: 12px;
  color: #93c5fd;
}

.stat-value {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 700;
}

.muted {
  color: #94a3b8;
}

.status-banner {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid #ef4444;
  background: #7f1d1d;
  color: #fee2e2;
  font-size: 13px;
}

.docs-card pre {
  overflow: auto;
  border: 1px solid #1f2a44;
  background: #020617;
  border-radius: 10px;
  padding: 10px;
}

.card {
  border: 1px solid #1f2a44;
  border-radius: 12px;
  background: #0b1220;
  padding: 12px;
}

.card h3 {
  margin: 0 0 10px;
}

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

.table th,
.table td {
  border-bottom: 1px solid #1f2a44;
  padding: 8px;
  text-align: left;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.input-with-btn {
  display: flex;
  gap: 6px;
}

.input-with-btn input {
  flex: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 16px;
}

.modal-card {
  width: min(640px, 100%);
  border: 1px solid #334155;
  background: #0b1220;
  border-radius: 12px;
  padding: 12px;
}

.modal-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 900px) {
  .login-shell {
    grid-template-columns: 1fr;
    margin: 18px auto 26px;
  }

  .main-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-left: 0;
    border-top: 1px solid #1f2a44;
    max-height: 280px;
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-form-grid {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    border-right: 0;
    border-bottom: 1px solid #1f2a44;
    flex-direction: row;
    overflow-x: auto;
  }

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

  .modal-controls {
    grid-template-columns: 1fr;
  }
}
