:root {
  --bg: #08131f;
  --panel: #122334;
  --panel-strong: #16324c;
  --line: #243b4d;
  --text: #e9f0f7;
  --muted: #93a8bc;
  --accent: #5db3ff;
  --accent-strong: #3195ff;
  --success: #49d39a;
  --warning: #ffd166;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: linear-gradient(180deg, #08131f 0%, #0d1b2b 100%);
  color: var(--text);
}

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  width: 220px;
  height: 100vh;
  background: rgba(9, 20, 31, 0.9);
  border-right: 1px solid var(--line);
  padding: 28px 18px;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  margin-bottom: 30px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 8px;
}

nav a.active,
nav a:hover {
  background: rgba(93, 179, 255, 0.12);
  color: var(--text);
}

.main {
  flex: 1;
  padding: 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 26px;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.access-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(93, 179, 255, 0.08);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.access-badge.admin {
  background: rgba(73, 211, 154, 0.14);
  color: var(--success);
}

.access-badge.external-admin {
  background: rgba(255, 209, 102, 0.12);
  color: var(--warning);
}

.access-badge.restricted {
  background: rgba(93, 179, 255, 0.14);
  color: var(--accent);
}

.access-summary {
  margin: -8px 0 22px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(93, 179, 255, 0.05);
  color: var(--muted);
  line-height: 1.5;
}

.action-alert {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -8px 0 22px;
  padding: 12px 14px;
  border-radius: 10px;
  line-height: 1.5;
  border: 1px solid rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.12);
  color: var(--danger);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 107, 0.08);
}

.action-alert.visible {
  display: flex;
}

.action-alert.success {
  border-color: rgba(73, 211, 154, 0.45);
  background: rgba(73, 211, 154, 0.12);
  color: var(--success);
}

.action-alert-close {
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.action-alert-close:hover {
  opacity: 0.8;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-size: 11px;
  margin: 0 0 8px;
}

h1, h2, h3, p {
  margin: 0;
}

.stats,
.content-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.content-grid {
  grid-template-columns: 1.5fr 1fr;
}

.card {
  background: rgba(18, 35, 52, 0.95);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  scroll-margin-top: 20px;
}

.stat-card .label {
  color: var(--muted);
  display: block;
  margin-bottom: 12px;
}

.stat-card strong {
  font-size: 1.7rem;
}

#last-action {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

.online {
  color: var(--success);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.accounts-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.account-form-fields {
  display: grid;
  grid-template-columns: 1fr;
  align-items: end;
  gap: 12px;
}

.account-form-fields .primary-btn {
  min-height: 42px;
  white-space: nowrap;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.admin-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-meta strong {
  font-size: 1rem;
}

.admin-role {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.account-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.account-controls input {
  min-width: 0;
  width: min(190px, 32vw);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 20, 31, 0.6);
  color: var(--text);
  padding: 10px 12px;
}

.profile-user-row {
  align-items: stretch;
  flex-direction: column;
}

.profile-user-row .account-controls input {
  flex: 1;
  width: auto;
}

.admin-form {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.admin-form h3 {
  margin: 0;
}

.admin-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.admin-form input,
.admin-form select,
.action-dialog input,
.action-dialog select,
.action-dialog textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 20, 31, 0.6);
  color: var(--text);
  padding: 10px 12px;
}

#account-type {
  border-color: #45657f;
  background-color: #091723;
  color: #f7fbff;
  color-scheme: dark;
}

#account-type:hover,
#account-type:focus-visible {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px rgba(93, 179, 255, 0.24);
}

#account-type option {
  background-color: #10283b;
  color: #f7fbff;
}

#account-type option:hover,
#account-type option:focus {
  background-color: #24577a;
  color: #ffffff;
}

#account-type option:checked {
  background: var(--accent);
  color: #06131f;
  font-weight: 700;
}

.action-dialog {
  width: min(92vw, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

.action-dialog::backdrop {
  background: rgba(2, 9, 15, 0.78);
}

.action-dialog-form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.action-dialog-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.action-dialog textarea {
  min-height: 96px;
  resize: vertical;
}

.dialog-copy {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.troubleshoot-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.troubleshoot-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.troubleshoot-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
}

.troubleshoot-item strong {
  display: block;
  margin-bottom: 6px;
}

.troubleshoot-item p {
  color: var(--muted);
  line-height: 1.5;
}

.support-tool {
  display: grid;
  gap: 12px;
}

.support-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.peer-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.peer-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.01);
}

.peer-ip {
  color: var(--muted);
  margin-top: 4px;
}

.peer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.onboarding-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.onboarding-card {
  width: min(100%, 520px);
}

.onboarding-copy {
  color: var(--muted);
  margin: 10px 0 20px;
  line-height: 1.5;
}

.onboarding-form {
  padding-top: 8px;
}

.primary-btn,
.ghost-btn,
.toggle-btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.danger-btn {
  border-color: rgba(255, 107, 107, 0.45);
  color: var(--danger);
}

.toggle-btn {
  background: var(--success);
  color: #062613;
}

.toggle-btn.disabled {
  background: var(--warning);
  color: #3a2d00;
}

.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-list li {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.activity-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(93, 179, 255, 0.14);
  color: var(--accent);
  margin-bottom: 5px;
}

.activity-list small,
.activity-list p {
  color: var(--muted);
  display: block;
}

@media (max-width: 900px) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .stats,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .account-form-fields {
    grid-template-columns: 1fr;
  }

  .admin-row,
  .account-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .account-controls input {
    width: 100%;
  }
}
