:root {
  --bg: #0b1220;
  --surface: #131c2e;
  --surface-2: #1b2740;
  --border: #2a3650;
  --text: #e8eef7;
  --muted: #8da3c4;
  --accent: #3b82f6;
  --accent-hover: #2f6fd6;
  --ok: #34d399;
  --error: #f87171;
  --warn: #fbbf24;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, #16233c, var(--bg));
  color: var(--text);
}

/* top nav */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.brand-mark { color: var(--accent); font-size: 20px; }
.navlinks { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.navlinks a {
  color: var(--muted);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.navlinks a:hover { color: var(--text); background: var(--surface-2); }
.navlinks a.active { color: #fff; background: var(--accent); }
.who { color: var(--muted); font-size: 13px; margin-left: 10px; }
.role {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  text-transform: uppercase;
}

/* layout */
.wrap { max-width: 920px; margin: 0 auto; padding: 26px 18px; }
h1.page { font-size: 22px; margin: 0 0 4px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
input[type="text"], input[type="password"], select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 140px; margin-bottom: 0; }

/* buttons */
button { font-family: inherit; }
.primary, .secondary, .ghost-btn {
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-hover); }
.primary.block { width: 100%; }
.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.secondary:hover { border-color: var(--accent); }
.ghost-btn { background: transparent; color: var(--muted); border-color: var(--border); }
.ghost-btn:hover { color: var(--text); border-color: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* table */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* badges */
.badge { border-radius: 5px; padding: 2px 8px; font-size: 11px; font-weight: 700; }
.badge.ok { background: rgba(52,211,153,0.15); color: var(--ok); }
.badge.off { background: rgba(248,113,113,0.15); color: var(--error); }
.badge.active { background: var(--accent); color: #fff; }
.badge.muted { background: var(--surface-2); color: var(--muted); }

/* status */
.status { min-height: 18px; margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.error { color: var(--error); }
.note { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.note.warn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  padding: 10px 12px;
}

/* login */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { margin-bottom: 18px; font-size: 17px; }
.hint { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.hint code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; color: var(--text); }

/* tabs (within a page) */
.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  margin-bottom: 16px;
  max-width: 420px;
}
.tab {
  flex: 1;
  padding: 9px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
}
.tab.active { background: var(--accent); color: #fff; }
.panel { display: none; }
.panel.active { display: block; }

/* QR modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 9, 18, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  text-align: center;
}
.modal h3 { margin: 0 0 6px; font-size: 16px; }
.modal .modal-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }
.modal canvas {
  width: 280px;
  max-width: 100%;
  height: auto;
  background: #fff;
  border-radius: 8px;
  image-rendering: pixelated;
}
.modal .modal-meta { color: var(--muted); font-size: 11.5px; margin: 10px 0 0; }
.modal .modal-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.modal-field { display: flex; gap: 8px; align-items: center; justify-content: center; margin-bottom: 12px; font-size: 12.5px; color: var(--muted); }

/* inline small select for qr options */
.qr-opt { display: inline-flex; gap: 8px; align-items: center; }

/* stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat .n { font-size: 28px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
