:root {
  --primary: #22407f;
  --navy: #15254a;
  --teal: #2aa39c;
  --blue: #2a7f97;
  --bg: #f4f6fb;
  --card: #fff;
  --text: #15254a;
  --muted: #5f6b85;
  --border: #dde3ef;
  --ok: #1f9d55;
  --warn: #e08a00;
  --err: #d64545;
  --radius: 12px;
  font-family: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

header.top {
  background: var(--navy); color: #fff; padding: 12px 20px;
  display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 10;
}
header.top .brand { font-weight: 700; font-size: 1.1rem; color: #fff; text-decoration: none; display: flex; align-items: center; gap: 8px; }
header.top .brand .logo { width: 28px; height: 28px; border-radius: 6px; background: var(--teal); display: grid; place-items: center; font-size: 15px; }
header.top .spacer { flex: 1; }
header.top .who { font-size: .9rem; opacity: .85; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

label { display: block; font-size: .85rem; font-weight: 600; margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; background: #fff; color: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--primary); background: var(--primary); color: #fff; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: #fff; color: var(--primary); }
.btn.teal { background: var(--teal); border-color: var(--teal); }
.btn.danger { background: #fff; color: var(--err); border-color: #f0c4c4; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); padding: 6px 8px; }
.btn.small { padding: 5px 10px; font-size: .85rem; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 16px 0; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.6rem; color: var(--primary); }
.stat span { color: var(--muted); font-size: .85rem; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr.revoked td { opacity: .5; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #eef1f8; color: var(--navy); }
.badge.multi { background: #fff1d6; color: #8a5300; }
.badge.ok { background: #dcf5e6; color: #146c3a; }
.badge.err { background: #fbe1e1; color: #a12c2c; }
.badge.info { background: #dff1f5; color: #1d5f71; }

.event-card { cursor: pointer; transition: box-shadow .15s; }
.event-card:hover { box-shadow: 0 4px 16px rgba(21, 37, 74, .1); }
.event-card .meta { color: var(--muted); font-size: .9rem; margin: 4px 0 12px; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

.auth { max-width: 420px; margin: 8vh auto; }
.auth .switch { text-align: center; margin-top: 14px; }
.error-msg { color: var(--err); font-size: .9rem; margin-top: 10px; }

dialog { border: 0; border-radius: var(--radius); padding: 24px; max-width: min(560px, 94vw); width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(21, 37, 74, .5); }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.qr-box { background: #fff; padding: 8px; border-radius: 8px; border: 1px solid var(--border); max-width: 300px; margin: 12px auto; }
.qr-box svg { width: 100%; height: auto; display: block; }
.linkbox { display: flex; gap: 6px; }
.linkbox input { font-family: ui-monospace, monospace; font-size: .8rem; }

#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 340px; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }

.entries-field { display: flex; gap: 6px; }
.entries-field select { flex: 1; min-width: 0; }
.entries-field input { width: 76px; flex: none; }
.inline-form { display: grid; gap: 10px; grid-template-columns: 2fr 2fr 1.8fr 2fr auto; align-items: end; }
.inline-form label { margin-top: 0; }
@media (max-width: 800px) { .inline-form { grid-template-columns: 1fr; } }

footer.sig { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px; }
