:root {
  --bg: #0c1118;
  --bg2: #111821;
  --surface: #161d27;
  --surface2: #1c2532;
  --line: rgba(148, 163, 184, 0.14);
  --line2: rgba(148, 163, 184, 0.22);
  --text: #e8eef6;
  --muted: #8b98ab;
  --acc: #0d9488;
  --acc2: #38bdf8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --r: 12px;
  --shadow: 0 12px 32px -20px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #eef2f6;
  --bg2: #e4eaf1;
  --surface: #ffffff;
  --surface2: #f5f8fb;
  --line: rgba(30, 41, 59, 0.1);
  --line2: rgba(30, 41, 59, 0.16);
  --text: #0f172a;
  --muted: #64748b;
  --acc: #0f766e;
  --acc2: #0369a1;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --shadow: 0 12px 28px -18px rgba(15, 23, 42, 0.28);
  color-scheme: light;
}
* { box-sizing: border-box }
html, body { margin: 0; min-height: 100% }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 auto auto 0;
  width: 55vw;
  height: 40vh;
  background: radial-gradient(closest-side, rgba(13, 148, 136, 0.12), transparent);
  pointer-events: none;
  z-index: 0;
}
[data-theme="light"] body::before {
  background: radial-gradient(closest-side, rgba(15, 118, 110, 0.08), transparent);
}
button, input { font: inherit; color: inherit }
button {
  cursor: pointer;
  border: 1px solid var(--line2);
  border-radius: 9px;
  padding: 8px 12px;
  background: var(--surface2);
}
button:hover { border-color: var(--acc) }
button.primary {
  background: var(--acc);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.06) }
button.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, var(--line)) }
button.ghost, button.back { background: transparent; border-color: transparent }
button.back { padding-left: 0; color: var(--muted) }
button.back:hover { color: var(--text) }
input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--line2);
  background: var(--bg2);
}
input:focus { outline: 2px solid color-mix(in srgb, var(--acc) 45%, transparent); outline-offset: 1px }
.wrap { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; padding: 22px 18px 56px }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.login { max-width: 400px; margin: 12vh auto }
h1 { font-size: 22px; letter-spacing: -0.02em; margin: 0 0 4px; font-weight: 650 }
h2 { font-size: 16px; margin: 0; font-weight: 620; letter-spacing: -0.01em }
.muted { color: var(--muted) }
.small { font-size: 12.5px }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.brand h1 { font-size: 18px; margin: 0 }
.brand .muted { margin: 2px 0 0; font-size: 12.5px }
.nav { display: flex; gap: 4px }
.nav button.on { background: var(--acc); color: #fff; border-color: transparent }
.errbox { color: var(--err); min-height: 1.2em; margin: 8px 0 }
label { display: block; margin: 10px 0 4px; font-size: 12.5px; color: var(--muted) }
img.qr { width: 220px; height: 220px; background: #fff; border-radius: 8px }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0 16px }
.stat {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 0;
}
.stat b {
  display: block;
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat span { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em }

.section-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 6px 0 10px }
.pending { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin-bottom: 18px }
.pending .card { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); padding: 14px }
.pending h2 { margin-bottom: 6px }

.dot {
  width: 8px; height: 8px; border-radius: 99px;
  display: inline-block; background: var(--muted); margin-right: 7px; vertical-align: middle;
}
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent) }
.dot.off { background: var(--warn) }

table { width: 100%; border-collapse: collapse }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em }
table.agents, table.comp {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
table.agents td, table.comp td { font-size: 13.5px }
table.agents tr:hover td, table.comp tbody tr:hover td { background: color-mix(in srgb, var(--surface2) 70%, transparent) }
.ok { color: var(--ok) }
.warn { color: var(--warn) }
.err { color: var(--err) }
.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 650;
  border-radius: 99px;
  padding: 2px 8px;
  background: var(--surface2);
  border: 1px solid var(--line);
}
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)) }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)) }
.badge.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, var(--line)) }

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}
.detail-head .meta { margin: 4px 0 0; font-size: 13px }
.block { margin-top: 18px }
.block h2 { margin-bottom: 8px }
.empty {
  margin: 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px dashed var(--line2);
  color: var(--muted);
  font-size: 13.5px;
}
.actions { margin-top: 12px }
.mono { font-variant-numeric: tabular-nums }

@media (max-width: 800px) {
  .stats { grid-template-columns: 1fr 1fr }
  .top { align-items: flex-start; flex-wrap: wrap }
  .detail-head { flex-direction: column }
}
