:root {
  --bg: #111318; --panel: #181b22; --panel-2: #1d2029; --border: #272b36; --border-2: #323745;
  --text: #e8eaf0; --muted: #8a90a0; --faint: #5d6372;
  --accent: #3fdcb0; --accent-ink: #062a20; --accent-soft: rgba(63,220,176,.12);
  --orange: #f0884a; --plum: #3d1d42;
  --blue: #5b9cf0; --amber: #f5b94a; --red: #f06a6a; --red-soft: rgba(240,106,106,.13);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Ubuntu, "Noto Sans", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; cursor: pointer; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: .01em; }
.hidden { display: none !important; }

/* sign in */
.signin { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(63,220,176,.06), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgba(240,136,74,.06), transparent 60%), var(--bg); }
.signin .card { width: 380px; max-width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 30px 28px 28px; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.signin img { width: 72px; height: 72px; display: block; margin: 0 auto 12px; border-radius: 16px; }
.signin h1 { font-size: 18px; text-align: center; margin: 0; }
.signin .sub { text-align: center; color: var(--muted); margin: 4px 0 22px; font-size: 13px; }
label.f { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.field { margin-bottom: 14px; }
input.in, textarea.in, select.in { width: 100%; background: #0f1116; border: 1px solid var(--border-2); border-radius: 8px; padding: 9px 11px; outline: none; }
input.in:focus, textarea.in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.in { resize: vertical; min-height: 70px; }
.err { color: var(--red); font-size: 13px; margin: -4px 0 12px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border-2); background: var(--panel-2); border-radius: 8px; padding: 7px 13px; cursor: pointer; white-space: nowrap; font-weight: 500; }
.btn:hover { border-color: #444a5a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; padding: 10px; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* shell */
.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100%; }
.side { border-right: 1px solid var(--border); padding: 16px 10px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand b { display: block; font-size: 14px; }
.brand span { display: block; font-size: 12px; color: var(--muted); }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); cursor: pointer; border-left: 2px solid transparent; }
.nav:hover { color: var(--text); background: rgba(255,255,255,.03); }
.nav.on { background: var(--panel-2); color: var(--text); border-left-color: var(--accent); }
.nav svg { width: 16px; height: 16px; flex-shrink: 0; }
.side .foot { margin-top: auto; border-top: 1px solid var(--border); padding: 12px 8px 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: #3a1f3f; color: #f3c9e9; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.foot a { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.foot a:hover { color: var(--text); }
.foot .ver { color: var(--faint); font-size: 12px; margin-top: 4px; }
.main { padding: 26px 32px 40px; min-width: 0; }
.head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.head h1 { font-size: 22px; margin: 0; font-weight: 650; }
.head .sub { color: var(--muted); font-size: 13.5px; }
.head .sp { flex: 1; }

/* cards */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; min-width: 0; }
.stat .l { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 650; margin: 6px 0 4px; }
.stat .s { font-size: 12.5px; color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.panel > .ph { display: flex; align-items: center; gap: 10px; padding: 14px 16px; }
.panel > .ph h2 { font-size: 15px; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; align-items: start; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-left: auto; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart { padding: 0 16px 14px; }
.chart svg { width: 100%; height: 170px; display: block; }
.chart .axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); padding: 2px 24px 0; }

/* activity list */
.act { list-style: none; margin: 0; padding: 0 16px 8px; }
.act li { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.act .ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; flex-shrink: 0; background: rgba(91,156,240,.12); color: var(--blue); }
.act .ic svg { width: 14px; height: 14px; }
.act .ic.g { background: var(--accent-soft); color: var(--accent); }
.act .ic.r { background: var(--red-soft); color: var(--red); }
.act .ic.n { background: rgba(255,255,255,.05); color: var(--muted); }
.act .ic.o { background: rgba(245,185,74,.12); color: var(--amber); }
.act .t { flex: 1; min-width: 0; }
.act .t b { font-weight: 500; display: block; }
.act .t b.g { color: var(--accent); }
.act .t span { color: var(--muted); font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act .w { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* tables */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
input.in.search { width: 300px; max-width: 100%; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 6px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--panel-2); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border-2); }
.tw { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 13px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr:first-child td { border-top: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: rgba(255,255,255,.02); }
td .n { font-weight: 600; }
td .e { color: var(--muted); font-size: 13px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .05em; padding: 2px 7px; border-radius: 5px; background: rgba(255,255,255,.07); color: #b9bfcc; }
.tag.off { background: rgba(245,185,74,.13); color: var(--amber); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.active { background: var(--accent-soft); color: var(--accent); }
.pill.revoked { background: var(--red-soft); color: var(--red); }
.pill.expired, .pill.ended { background: rgba(255,255,255,.06); color: var(--muted); }
.pill.running { background: rgba(91,156,240,.13); color: var(--blue); }
.pill.purchased { background: var(--accent-soft); color: var(--accent); }
.bar { width: 70px; height: 4px; border-radius: 3px; background: #262a35; margin-top: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar i.full { background: var(--amber); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(5,6,9,.62); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 620px; max-width: 100%; background: var(--panel); border-left: 1px solid var(--border); z-index: 21; display: flex; flex-direction: column; animation: slide .16s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: .4; } }
.drawer .dh { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 10px; }
.drawer .dh h2 { margin: 0 0 4px; font-size: 18px; }
.drawer .dh .x { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; padding: 4px; }
.drawer .db { padding: 6px 20px 30px; overflow: auto; }
.sec { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 20px 0 10px; }
.keybox { background: #0f1116; border: 1px solid var(--border-2); border-radius: 9px; padding: 11px 13px; font-family: var(--mono); font-size: 11.5px; line-height: 1.6; word-break: break-all; color: #c9ced9; max-height: 120px; overflow: auto; user-select: all; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.seat { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px; margin-bottom: 8px; background: var(--panel-2); }
.seat .nm { font-weight: 600; }
.seat .id { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.seat .meta { margin-left: auto; text-align: right; font-size: 13px; color: var(--muted); }
.seat .meta b { color: var(--text); font-weight: 500; display: block; }

/* modal */
.mwrap { position: fixed; inset: 0; background: rgba(5,6,9,.62); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 20px; }
.modal { width: 520px; max-width: 100%; max-height: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--border-2); border-radius: 14px; padding: 20px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.modal h2 { font-size: 17px; margin: 0 0 16px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-top: 8px; color: var(--muted); }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.mfoot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.mfoot .left { margin-right: auto; }
.note { background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; color: var(--muted); font-size: 13.5px; margin-bottom: 10px; }

/* toasts */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 40; }
.toast { background: var(--panel-2); border: 1px solid var(--border-2); padding: 10px 14px; border-radius: 9px; box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: 13.5px; }
.toast.bad { border-color: rgba(240,106,106,.5); color: #ffb4b4; }

/* narrow screens: the sidebar becomes a top bar */
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(3, 1fr); } .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); background: var(--bg); gap: 4px; }
  .brand { padding: 0 6px 0 2px; }
  .brand div { display: none; }
  .brand img { width: 28px; height: 28px; }
  .nav { border-left: 0; padding: 7px 12px; white-space: nowrap; }
  .nav svg { display: none; }
  .side .foot { display: none; }
  .main { padding: 18px 16px 30px; }
  .head { flex-wrap: wrap; }
  .stats { grid-template-columns: 1fr 1fr; }
  input.in.search { width: 100%; }
  .seg { overflow-x: auto; max-width: 100%; }
  .hide-sm { display: none; }
  dl.kv { grid-template-columns: 110px 1fr; }
  .two { grid-template-columns: 1fr; }
}
