:root {
  --bg: #12160f;
  --panel: #1a2116;
  --line: #2d3a28;
  --text: #e7efdf;
  --muted: #9aab8f;
  --accent: #c6f26d;
  --warn: #f0b429;
  --danger: #ff6b4a;
  --ok: #6dd6a2;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1000px 500px at 10% -10%, #24301c 0%, transparent 55%),
    radial-gradient(800px 400px at 90% 0%, #1d2a2a 0%, transparent 50%),
    var(--bg);
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; gap: 0.85rem; align-items: center; }
.brand .mark { color: var(--accent); font-size: 1.4rem; }
.brand strong { font-size: 1.15rem; letter-spacing: 0.02em; }
.brand p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.85rem; }

main { width: min(1100px, calc(100% - 2rem)); margin: 1.5rem auto 3rem; }

.hero-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.hero-board article {
  background: linear-gradient(180deg, #222b1c, var(--panel));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.hero-board span { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.hero-board strong { display: block; margin-top: 0.35rem; font-size: 1.8rem; font-family: var(--mono); }

.panel {
  background: color-mix(in srgb, var(--panel) 92%, black);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.panel-head h1 { margin: 0; font-size: 1.35rem; }
.panel-head p { margin: 0.35rem 0 1rem; color: var(--muted); }

.add-form {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 1fr auto;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
label { display: grid; gap: 0.35rem; font-size: 0.8rem; color: var(--muted); }
input {
  width: 100%;
  border: 1px solid var(--line);
  background: #0f140c;
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
}
button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #15200c;
  font-weight: 700;
  padding: 0.75rem 1rem;
  cursor: pointer;
  align-self: end;
}
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 600;
}
button:hover { filter: brightness(1.05); }

.install {
  margin: 0 0 1rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1px dashed color-mix(in srgb, var(--accent) 50%, var(--line));
  background: #171e13;
}
.install.hidden[hidden] { display: none; }
.install h2 { margin: 0 0 0.35rem; font-size: 1rem; }
.install p { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.9rem; }
.install code {
  display: block;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: var(--mono);
  font-size: 0.82rem;
  background: #0c110a;
  border-radius: 8px;
  padding: 0.75rem;
  border: 1px solid var(--line);
}
.install .row { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.75rem; }
.install .token { flex: 1; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.75rem 0.5rem; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem !important; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}
.badge.online { color: var(--ok); }
.badge.pending { color: var(--warn); }
.badge.offline, .badge.disabled { color: var(--danger); }

.inventory { margin-top: 1.25rem; }
.sub { color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; }
.mono-cell { font-family: var(--mono); font-size: 0.78rem; max-width: 220px; word-break: break-all; }
.actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.actions .ghost { padding: 0.35rem 0.55rem; font-size: 0.78rem; }

.tabs {
  display: flex;
  gap: 0.4rem;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.65rem;
}
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  font-weight: 600;
  padding: 0.45rem 0.8rem;
}
.tab.active {
  color: var(--text);
  border-color: var(--line);
  background: #141a10;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  width: min(440px, calc(100% - 2rem));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
#edit-form {
  display: grid;
  gap: 0.75rem;
  padding: 1.1rem 1.2rem 1.2rem;
}
#edit-form h2 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.dialog-actions { display: flex; gap: 0.5rem; margin-top: 0.35rem; }
.dialog-actions button { align-self: auto; }

.top-actions { display: flex; gap: 0.75rem; align-items: center; }
.main-tabs { display: flex; gap: 0.35rem; }
.main-tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  font-weight: 700;
  padding: 0.5rem 0.9rem;
}
.main-tab.active {
  color: #15200c;
  background: var(--accent);
  border-color: transparent;
}
.view.hidden[hidden] { display: none; }
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.metric, .empty-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #141a10;
  padding: 0.9rem 1rem;
}
.metric header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}
.metric dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.85rem;
  margin: 0;
}
.metric dt { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.metric dd { margin: 0.15rem 0 0; font-family: var(--mono); font-size: 0.82rem; }
.login-form, .promo-form, .toolbar {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.login-form { grid-template-columns: 1.4fr 1.2fr auto; }
.promo-form { grid-template-columns: 1fr 0.8fr 0.8fr auto 1.2fr auto; align-items: end; }
.toolbar { grid-template-columns: 1fr auto auto; }
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #0f140c;
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
}
.check {
  display: flex !important;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  font-size: 0.9rem;
}
.check input { width: auto; }
.row-between { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.error-text { color: var(--danger); margin: 0.5rem 0 0; }
#user-form {
  display: grid;
  gap: 0.75rem;
  padding: 1.1rem 1.2rem 1.2rem;
}
#user-form h2 { margin: 0 0 0.25rem; font-size: 1.1rem; }
#user-dialog { width: min(480px, calc(100% - 2rem)); }

@media (max-width: 860px) {
  .hero-board { grid-template-columns: 1fr 1fr; }
  .add-form, .login-form, .promo-form, .toolbar, .metrics-grid { grid-template-columns: 1fr; }
  .install .row { flex-direction: column; align-items: stretch; }
  .top { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  .top-actions { justify-content: space-between; }
}
