:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1f2630;
  --surface-3: #262f3b;
  --border: #2a3340;
  --border-2: #384354;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #2dd4a7;
  --accent-2: #25b892;
  --accent-ink: #052e23;
  --danger: #f2555a;
  --warn: #f0b429;
  --ok: #2dd4a7;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(0,0,0,.38);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #141b25 0%, var(--bg) 60%) no-repeat, var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h1 { font-size: 22px; margin: 2px 0 10px; letter-spacing: -.2px; }
h2 { font-size: 15px; margin: 0 0 10px; letter-spacing: .1px; }

/* header */
header.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: rgba(14,17,22,.82);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
header.bar .logo { font-weight: 700; letter-spacing: -.2px; font-size: 18px; }
header.bar .logo span { color: var(--accent); }
.spacer { flex: 1; }
.acct { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted);
  max-width: 48vw; overflow: hidden; }
.acct .who { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 2px 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.role-tag.admin { color: var(--accent); border-color: #1d4a3d; background: #0a241d; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  padding: 0; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; }

.drybanner { background: #3a2d05; color: var(--warn); border-bottom: 1px solid #5a4710;
  font-size: 13px; text-align: center; padding: 7px 16px; }
.drybanner strong { color: #ffcf4a; }

/* cards & forms */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; font-size: 16px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; outline: none;
  transition: border-color .15s ease;
}
input:focus, select:focus { border-color: var(--accent); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; font-weight: 600; padding: 13px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  cursor: pointer; width: 100%; transition: transform .05s ease, background .15s ease, filter .15s ease;
  user-select: none;
}
button:active { transform: scale(.985); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.primary:hover { filter: brightness(1.04); }
button.danger { background: transparent; color: var(--danger); border-color: #5a1416; }
button.ghost { background: transparent; }
button.small { width: auto; padding: 9px 13px; font-size: 14px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* hold-to-open */
.hold { position: relative; overflow: hidden; touch-action: none; }
.hold .fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: rgba(5,46,35,.30); pointer-events: none; }
.hold.err .fill { background: rgba(242,85,90,.25); }
.hold .lbl { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px; }
.hold.ok { background: var(--accent-2); }
.hold.err { background: var(--surface-2); color: var(--danger); border-color: #5a1416; }

/* segmented tabs */
.tabs { display: flex; gap: 4px; margin: 14px 0 4px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.tabs button { width: auto; flex: 1; background: transparent; border: none; color: var(--muted);
  border-radius: 9px; padding: 9px 6px; font-size: 14px; font-weight: 600; }
.tabs button.active { color: var(--text); background: var(--surface-3); box-shadow: 0 1px 2px rgba(0,0,0,.3); }

/* gate cards */
.gate { padding: 14px 14px 14px; }
.gate .gmain { display: flex; align-items: center; gap: 12px; }
.gate .meta { flex: 1; min-width: 0; }
.gate .name { font-weight: 650; font-size: 17px; letter-spacing: -.1px; }
.gate .sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.gate.off { opacity: .72; }
.gate .hold, .gate .enablebtn { margin-top: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.online { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.offline { background: #5a6572; }

.editpanel { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border-2); }
.editpanel .acts { display: flex; gap: 10px; margin-top: 12px; }

/* status line (token health) */
.statusline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  margin: 12px 0; cursor: pointer; }
.statusline .dot { width: 8px; height: 8px; }
.statusline.ok .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.statusline.bad { color: var(--danger); border-color: #5a1416; }
.statusline.bad .dot { background: var(--danger); }

/* link + user items */
.item { border: 1px solid var(--border); border-radius: 12px; padding: 13px; margin: 10px 0; background: var(--surface-2); }
.item .top { display: flex; align-items: center; gap: 8px; }
.item .top strong { font-size: 15px; }
.pill { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.pill.active { background: #06332a; color: var(--ok); }
.pill.expired, .pill.used_up, .pill.revoked, .pill.outside_window, .pill.not_found, .pill.invalid { background: #2a0f10; color: var(--danger); }
.pill.hidden { background: var(--surface-3); color: var(--muted); }
.pill.admin { background: #0a241d; color: var(--accent); }
.pill.member { background: var(--surface-3); color: var(--muted); }

/* toast + modal */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--border-2); color: var(--text);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 50; max-width: 90%; font-size: 14px; }
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.62); display: flex;
  align-items: center; justify-content: center; padding: 16px; z-index: 40; }
.modal { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius);
  padding: 20px; max-width: 420px; width: 100%; box-shadow: var(--shadow); max-height: 92vh; overflow: auto; }
.qr { background: #fff; border-radius: 12px; padding: 12px; margin: 14px auto; width: 210px; }
.qr svg { width: 100%; height: auto; display: block; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all;
  background: var(--surface-2); padding: 10px; border-radius: 8px; border: 1px solid var(--border); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { width: auto; padding: 8px 12px; font-size: 14px; font-weight: 500; }
.chips button.sel { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }

table.audit { width: 100%; border-collapse: collapse; font-size: 13px; }
table.audit th, table.audit td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.audit th { color: var(--muted); font-weight: 600; }
table.audit td.r-ok { color: var(--ok); } table.audit td.r-fail, table.audit td.r-deny, table.audit td.r-error { color: var(--danger); }

.sectionhead { display: flex; align-items: center; margin: 18px 2px 2px; }
.sectionhead h2 { margin: 0; } .sectionhead .spacer { flex: 1; }

/* guest page */
.guest-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.guest-card { text-align: center; max-width: 420px; width: 100%; }
.guest-card .big-open { font-size: 19px; padding: 24px; margin-top: 20px; }
.guest-card .gate-name { font-size: 27px; font-weight: 700; margin: 6px 0; letter-spacing: -.3px; }
.guest-card .hint { margin-top: 14px; min-height: 20px; }
.status-msg { padding: 20px 10px; }
.status-msg .icon { font-size: 46px; line-height: 1.2; }
.status-msg h1 { margin: 10px 0 6px; }
