:root {
  --bg0: #070a08;
  --bg1: #0e1410;
  --ink: #f2f5ef;
  --muted: #9aa89a;
  --line: rgba(182, 255, 46, 0.14);
  --lime: #b6ff2e;
  --open: #b6ff2e;
  --closed: #ff6b5a;
  --maint: #f0c24b;
  --accent: #b6ff2e;
  --danger: #ff7a6a;
  --font-display: "Syne", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg0);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(720px 420px at 12% -8%, rgba(182, 255, 46, 0.16), transparent 58%),
    radial-gradient(560px 360px at 92% 8%, rgba(182, 255, 46, 0.08), transparent 55%),
    radial-gradient(480px 280px at 70% 90%, rgba(80, 120, 40, 0.12), transparent 60%),
    linear-gradient(180deg, #0a0f0b 0%, var(--bg0) 50%, #050706 100%);
}

.bg-grid {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.05;
  background-image:
    linear-gradient(rgba(182, 255, 46, 0.45) 1px, transparent 1px),
    linear-gradient(90deg, rgba(182, 255, 46, 0.45) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at center, #000 18%, transparent 72%);
}

.shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(1.25rem + var(--safe-t)) 1rem calc(1.5rem + var(--safe-b));
}

.card {
  width: min(440px, 100%);
  background:
    linear-gradient(165deg, rgba(182, 255, 46, 0.05), transparent 42%),
    var(--bg1);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.6rem 1.35rem 1.4rem;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.45);
}

.card.wide { width: min(560px, 100%); }

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.85rem, 7vw, 2.4rem);
  letter-spacing: 0.04em;
  line-height: 1;
  margin: 0;
  color: var(--lime);
  text-transform: uppercase;
}

.tagline {
  margin: 0.45rem 0 1.35rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.95rem 0 0.4rem;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  font: inherit;
  font-size: 1.05rem;
}

input:focus {
  outline: 2px solid rgba(182, 255, 46, 0.55);
  outline-offset: 1px;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  min-height: 52px;
  padding: 0.85rem 1.1rem;
  font: inherit;
  font-weight: 700;
  font-size: 1.02rem;
  cursor: pointer;
  color: #081008;
  background: var(--accent);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.block { width: 100%; margin-top: 1.15rem; }

.btn.secondary {
  margin-top: 0.7rem;
  background: transparent;
  color: var(--lime);
  border: 1px solid rgba(182, 255, 46, 0.35);
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.1rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.actions {
  display: grid;
  gap: 0.7rem;
  margin-top: 1.15rem;
}

.actions .btn.open { background: var(--open); color: #081008; }
.actions .btn.closed { background: var(--closed); color: #2a0b08; }
.actions .btn.maint { background: var(--maint); color: #241800; }

.actions .btn.current,
.actions .btn.current:disabled {
  opacity: 0.42;
  filter: grayscale(0.85);
  cursor: default;
  box-shadow: none;
}

.allow-add {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

.allow-add input {
  flex: 1 1 160px;
  margin: 0;
}

.allow-add .btn {
  margin-top: 0;
  flex: 0 0 auto;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--line);
}
.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}
.pill.open { background: rgba(182, 255, 46, 0.12); color: var(--open); }
.pill.closed { background: rgba(255, 107, 90, 0.14); color: var(--closed); }
.pill.maintenance { background: rgba(240, 194, 75, 0.16); color: var(--maint); }
.pill.online { background: rgba(182, 255, 46, 0.12); color: var(--open); }
.pill.offline { background: rgba(255, 107, 90, 0.14); color: var(--closed); }

.meta {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 0.65rem;
  line-height: 1.5;
}
.meta strong { color: var(--ink); font-weight: 600; }
.warn-line { color: var(--maint); }

.err {
  color: var(--danger);
  margin-top: 0.75rem;
  font-size: 0.92rem;
}

.ok {
  color: var(--lime);
  margin-top: 0.75rem;
  font-size: 0.92rem;
}

.qr {
  display: block;
  margin: 1rem auto;
  width: min(180px, 55vw);
  height: auto;
  aspect-ratio: 1;
  border-radius: 14px;
  background: #fff;
  padding: 8px;
}

code {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  word-break: break-all;
}

.btn.sm {
  min-height: 40px;
  padding: 0.45rem 0.85rem;
  font-size: 0.88rem;
}

/* ---- Dashboard layout ---- */
.dash {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  margin: 0 auto;
  padding: calc(1rem + var(--safe-t)) 1rem calc(2.5rem + var(--safe-b));
}

.dash-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.dash-brand {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  color: var(--lime);
  text-transform: uppercase;
}

.dash-sub {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.dash-nav-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-user {
  color: var(--muted);
  font-size: 0.85rem;
  margin-right: 0.25rem;
}

.hero-panel,
.panel {
  background:
    linear-gradient(165deg, rgba(182, 255, 46, 0.04), transparent 42%),
    var(--bg1);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.35rem 1.25rem;
  margin-bottom: 1rem;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 7vw, 2.75rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.hero-copy {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
  max-width: 36rem;
}

.hero-pills {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
}

.fill-wrap { margin-top: 1.25rem; }
.fill-wrap.muted-fill .fill-bar { opacity: 0.25; }
.fill-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.45rem;
}
.fill-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.fill-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8fce22, var(--lime));
  transition: width 0.35s ease;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1rem 0.9rem;
}

.stat-label {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  margin: 0.35rem 0 0.2rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.65rem;
  line-height: 1.1;
}

.stat-value.sm { font-size: 1.2rem; }

.stat-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.panel-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.panel .actions { margin-top: 1rem; }

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.link-chip {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0.5rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.22);
}

.link-chip:hover {
  border-color: rgba(182, 255, 46, 0.35);
  color: var(--lime);
}

.two-col {
  display: grid;
  gap: 1rem;
}

.pk-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.pk-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.audit-pre {
  margin: 0.85rem 0 0;
  max-height: 220px;
  overflow: auto;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: pre-wrap;
  line-height: 1.45;
}

@media (min-width: 720px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .two-col { grid-template-columns: 1fr 1fr; }
  .actions { grid-template-columns: repeat(3, 1fr); }
  .actions .btn { font-size: 0.95rem; }
}

@media (max-width: 520px) {
  .hero-top { flex-direction: column; }
  .hero-pills { flex-direction: row; align-items: center; }
}

/* ---- MOTD editor ---- */
.motd-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0 0.85rem;
}

.motd-tabs .tab {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--muted);
  border-radius: 999px;
  min-height: 36px;
  padding: 0.35rem 0.9rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.motd-tabs .tab.active {
  color: #081008;
  background: var(--lime);
  border-color: var(--lime);
}

.motd-toolbar { margin-bottom: 0.75rem; }

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: var(--c);
  cursor: pointer;
  padding: 0;
}

.swatch:disabled { opacity: 0.35; cursor: not-allowed; }

.fmt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.motd-text {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.4);
  color: var(--ink);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  line-height: 1.45;
  resize: vertical;
  min-height: 5.5rem;
}

.motd-text:focus {
  outline: 2px solid rgba(182, 255, 46, 0.45);
  outline-offset: 1px;
}

.motd-preview {
  margin-top: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #1a1a1a;
  padding: 0.9rem 1rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.95rem;
  line-height: 1.55;
  min-height: 3.6rem;
  overflow-x: auto;
  white-space: nowrap;
}

.motd-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.motd-actions .btn { margin-top: 0; }
