:root {
  --bg: #f3f4f6;
  --card: #fff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --sidebar: #fff;
  --header: #fff;
  --select: #f3f4f6;
}
html.dark {
  --bg: #111827;
  --card: #1f2937;
  --text: #f9fafb;
  --muted: #9ca3af;
  --line: #374151;
  --sidebar: #1f2937;
  --header: #111827;
  --select: #374151;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: ui-sans-serif, system-ui, Segoe UI, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--blue); text-decoration: none; }
.header {
  height: 56px; background: var(--header); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; color: var(--blue); display: flex; align-items: center; gap: 10px; }
.logo-header { height: 40px; width: auto; display: block; }
.logo-login { width: 200px; height: auto; display: block; margin: 0 auto 4px; }
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 220px; background: var(--sidebar); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 12px 0;
}
.sidebar a {
  display: block; padding: 10px 16px; color: var(--text); border-radius: 8px; margin: 2px 8px;
}
.sidebar a.active { background: var(--select); font-weight: 600; }
.sidebar .foot { margin-top: auto; padding: 12px 16px; font-size: 11px; color: var(--muted); }
.main { flex: 1; padding: 24px 28px; }
h1 { font-size: 28px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.card { background: var(--card); border-radius: 12px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.card h3 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 500; }
.card .num { font-size: 32px; font-weight: 700; margin-top: 10px; }
.card .cap { color: var(--muted); font-size: 13px; margin-top: 6px; }
.row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; }
.pill { background: #dcfce7; color: #166534; border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.pill.down { background: #fee2e2; color: #991b1b; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 8px; }
.dot.down { background: #dc2626; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 500; }
.plate { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: 0.04em; }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 12px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text);
}
label { display: block; font-size: 13px; margin: 10px 0 4px; }
.btn {
  background: var(--blue); color: #fff; border: 0; border-radius: 8px; padding: 10px 16px;
  font-weight: 600; cursor: pointer;
}
.btn.gray { background: #9ca3af; cursor: not-allowed; }
.btn.danger { background: var(--red); }
.btn.locked { background: var(--red); cursor: not-allowed; }
.btn.ready { background: var(--green); }
.btn.outline { background: transparent; color: var(--text); border: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.search-bar { border: 2px solid var(--blue); }
.search-bar h2 { font-size: 20px; margin: 0 0 12px; color: var(--text); font-weight: 700; }
.search-fields { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.search-fields > div { flex: 1; min-width: 160px; }
.search-when { flex: 1 1 280px; min-width: 280px; }
.search-when-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.search-when-row { display: flex; gap: 8px; }
.search-when-row > div { flex: 1; min-width: 0; }
.search-when-row label { margin-top: 0; }
.search-when-row input[type="time"] { min-width: 108px; }
.search-fields .search-actions { flex: 0 0 auto; min-width: auto; display: flex; gap: 8px; }
.err { background: #fef2f2; color: #991b1b; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.ok { color: var(--green); font-size: 13px; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #eef2f7; }
.login-card {
  width: 420px; background: #fff; border-radius: 16px; padding: 36px 32px; text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.06);
}
.login-card h2 { color: var(--blue); margin: 8px 0 4px; }
.login-card p { color: var(--muted); font-size: 13px; }
.login-card form { text-align: left; margin-top: 16px; }
.login-card .btn { width: 100%; margin-top: 12px; }
.mark {
  width: 64px; height: 48px; margin: 0 auto; background: #111827; color: #60a5fa; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-weight: 800; letter-spacing: 1px;
}
.top-right { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.qlink { display: block; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 8px 0; color: var(--text); }
.portal-top { background: var(--header); padding: 16px 20px 0; }
.portal-nav { display: flex; gap: 18px; padding: 8px 20px 0; border-bottom: 1px solid var(--line); }
.portal-nav a { color: var(--muted); padding-bottom: 10px; }
.portal-nav a.on { color: var(--blue); border-bottom: 2px solid var(--blue); font-weight: 600; }
.door-btn {
  display: inline-block; min-width: 220px; padding: 20px 28px; margin: 8px; border-radius: 12px;
  background: #16a34a; border: 0; font-size: 20px; font-weight: 700; color: #fff; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.door-btn:hover { background: #15803d; }
#actBtn { width: 100%; min-height: 52px; font-size: 18px; }
.popup-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; }
.popup { background: var(--card); border-radius: 16px; padding: 16px; width: min(920px, 96vw); }
.popup img { width: 100%; max-height: 50vh; object-fit: contain; background: #111; border-radius: 8px; }
.session-chip { font-size: 13px; color: var(--muted); min-width: 110px; }
.session-chip strong { color: var(--text); font-variant-numeric: tabular-nums; }
.session-bar, .wait-bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.session-bar > span, .wait-bar > span { display: block; height: 100%; width: 0; background: var(--blue); }
.wait-wrap { margin: 12px 0; text-align: center; }
.wait-num { font-size: 56px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.wait-label { color: var(--muted); margin-top: 4px; font-size: 15px; }
.wait-bar { height: 12px; margin-top: 10px; }
.wait-bar > span { background: var(--blue); transition: width 0.2s linear; }
@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .cards { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .door-btn { width: 100%; margin: 8px 0; font-size: 20px; padding: 22px; }
  select, input, .btn { font-size: 16px; min-height: 48px; }
}

#player {
  display: block;
  width: 100%;
  min-height: 360px;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: 8px;
}
