:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --bg-soft: #13171b;
  --panel: #171c21;
  --panel-2: #20272e;
  --panel-3: #26313a;
  --text: #f3f6f8;
  --muted: #93a0aa;
  --line: #2c363f;
  --accent: #31d19c;
  --accent-2: #5aa9ff;
  --danger: #ff5d5d;
  --warn: #f0b84a;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(180deg, rgba(49, 209, 156, 0.08), transparent 280px),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--panel-3);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.18);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary {
  background: var(--accent);
  color: #04110d;
}

.danger {
  background: rgba(255, 93, 93, 0.12);
  border-color: rgba(255, 93, 93, 0.28);
  color: #ffb4b4;
}

.ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  color: var(--text);
}

.wide,
.full {
  width: 100%;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.auth-shell {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(340px, 430px);
  align-items: center;
  gap: 48px;
}

.auth-copy {
  max-width: 520px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06100d;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 12px 40px rgba(49, 209, 156, 0.22);
}

.auth-copy .brand-mark {
  width: 62px;
  height: 62px;
  margin-bottom: 22px;
  font-size: 20px;
}

.auth-copy h1 {
  margin: 0 0 14px;
  font-size: clamp(42px, 7vw, 76px);
  line-height: 0.95;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

.muted {
  color: var(--muted);
  line-height: 1.55;
}

.panel,
.app-row,
.stat {
  background: rgba(23, 28, 33, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel,
.setup-panel {
  padding: 24px;
}

form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0f1317;
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: rgba(49, 209, 156, 0.72);
  box-shadow: 0 0 0 3px rgba(49, 209, 156, 0.12);
}

.app-shell {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 22px;
}

.sidebar {
  position: sticky;
  top: 28px;
  height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 21, 25, 0.94);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.nav-item {
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  text-align: left;
  transform: none;
}

.nav-item.active {
  background: rgba(49, 209, 156, 0.11);
  color: var(--text);
}

.nav-item:hover:not(:disabled) {
  transform: none;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.session-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid rgba(49, 209, 156, 0.25);
  border-radius: 7px;
  background: rgba(49, 209, 156, 0.1);
  color: #aef7de;
  font-size: 13px;
  font-weight: 800;
}

.content {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 7px;
}

.error {
  background: rgba(255, 93, 93, 0.13);
  border: 1px solid rgba(255, 93, 93, 0.24);
  color: #ffc0c0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat {
  padding: 16px;
  box-shadow: none;
}

.stat span,
.app-meta {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.list {
  display: grid;
  gap: 12px;
}

.app-row {
  display: grid;
  grid-template-columns: minmax(230px, 1.2fr) minmax(180px, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px;
  box-shadow: none;
}

.status-admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 28, 33, 0.92);
}

.status-intro {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  padding: 18px;
  box-shadow: none;
}

.status-intro code {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0f1317;
  color: var(--accent);
  white-space: nowrap;
}

.switch {
  position: relative;
  width: 62px;
  height: 34px;
  display: inline-block;
  color: transparent;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  cursor: pointer;
  border: 1px solid rgba(255, 93, 93, 0.32);
  border-radius: 999px;
  background: rgba(255, 93, 93, 0.18);
  transition: background 160ms ease, border-color 160ms ease;
}

.switch span::before {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
  transition: transform 160ms ease;
}

.switch input:checked + span {
  border-color: rgba(49, 209, 156, 0.36);
  background: rgba(49, 209, 156, 0.9);
}

.switch input:checked + span::before {
  transform: translateX(28px);
}

.switch input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(90, 169, 255, 0.24);
}

.app-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-main h2,
.app-main p,
.app-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-main p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.app-meta {
  min-width: 0;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.04);
}

.status-dot.good {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(49, 209, 156, 0.12);
}

.status-dot.warn {
  background: var(--warn);
  box-shadow: 0 0 0 5px rgba(240, 184, 74, 0.12);
}

.status-dot.bad {
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(255, 93, 93, 0.12);
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(230px, 320px);
  align-items: start;
  gap: 24px;
}

.setup-grid form {
  margin-top: 20px;
}

.qr-wrap {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.qr-wrap img {
  width: min(260px, 100%);
  height: auto;
  background: white;
  border-radius: 7px;
}

code {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--muted);
}

@media (max-width: 900px) {
  .shell {
    width: min(100% - 20px, 760px);
    padding: 10px 0;
  }

  .auth-shell,
  .app-shell,
  .setup-grid {
    grid-template-columns: 1fr;
  }

  .auth-shell {
    gap: 20px;
    align-items: start;
    padding-top: 28px;
  }

  .auth-copy h1 {
    font-size: 44px;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .app-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .status-admin-row,
  .status-intro {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .status-intro {
    flex-direction: column;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1;
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }
}
