:root {
  --navy: #12325b;
  --navy-2: #0d2340;
  --gold: #c9a227;
  --ink: #1a2230;
  --soft: #5b6472;
  --line: #e4e8f0;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --green: #1f9d55;
  --green-bg: #e6f6ec;
  --red: #c0392b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 6px 20px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--navy); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--panel); border-radius: 16px;
  box-shadow: var(--shadow); padding: 32px; border-top: 4px solid var(--gold);
}
.login-card h1 { font-size: 1.25rem; margin: 0 0 4px; color: var(--navy); }
.login-card .sub { color: var(--soft); font-size: .9rem; margin: 0 0 22px; }
.login-card label { display: block; font-size: .82rem; color: var(--soft); margin-bottom: 6px; }
input[type=text], input[type=password], select {
  width: 100%; font-size: 1rem; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 9px; outline: none; background: #fff; color: var(--ink);
}
input:focus, select:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(18,50,91,.12); }

/* ---------- App shell ---------- */
.topbar {
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #fff; border-bottom: 3px solid var(--gold);
}
.topbar-in { max-width: 1120px; margin: 0 auto; padding: 16px 22px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; flex-direction: column; }
.brand .b1 { font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; }
.brand .b2 { font-size: .78rem; color: #b9c7dc; }
.spacer { flex: 1; }
.chip { background: rgba(255,255,255,.12); color: #eaf1fb; border-radius: 999px; padding: 5px 12px; font-size: .8rem; }
.container { max-width: 1120px; margin: 0 auto; padding: 24px 22px 60px; }

/* ---------- Buttons ---------- */
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 9px; padding: 8px 14px; font-size: .88rem; font-weight: 500; }
.btn:hover { border-color: var(--navy); }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-2); }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.3); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-sm { padding: 6px 10px; font-size: .8rem; }
.btn-danger { color: var(--red); border-color: #f0d3cf; }
.btn-danger:hover { background: #fdecea; border-color: var(--red); }

/* ---------- Cards / grid ---------- */
.grid { display: grid; grid-template-columns: 1fr 1.35fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1rem; margin: 0; }
.panel-body { padding: 16px 18px; }

/* Live board */
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(31,157,85,.5); animation: pulse 2s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(31,157,85,.5);} 70%{box-shadow:0 0 0 8px rgba(31,157,85,0);} 100%{box-shadow:0 0 0 0 rgba(31,157,85,0);} }
.big-num { font-size: 2.4rem; font-weight: 700; color: var(--navy); line-height: 1; }
.live-list { list-style: none; margin: 14px 0 0; padding: 0; }
.live-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--green-bg); color: var(--green); display: grid; place-items: center; font-weight: 600; font-size: .8rem; flex: 0 0 auto; }
.live-item .who { font-weight: 500; }
.live-item .grp { color: var(--soft); font-size: .8rem; }
.muted { color: var(--soft); }
.empty { color: var(--soft); text-align: center; padding: 22px 0; }

/* Group cards */
.group { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.group:last-child { margin-bottom: 0; }
.group-top { display: flex; align-items: center; gap: 10px; }
.group .name { font-weight: 600; font-size: 1rem; }
.badge { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 6px; }
.badge-booklets { background: #eef3fb; color: var(--navy); }
.badge-test { background: #fbf1d9; color: #7a5c00; }
.badge-live { background: var(--green-bg); color: var(--green); display: inline-flex; align-items: center; gap: 5px; }
.code-row { display: flex; align-items: center; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.5rem; font-weight: 700; letter-spacing: .12em; color: var(--navy); background: #f5f7fc; border: 1px dashed var(--line); border-radius: 8px; padding: 4px 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(10,18,32,.5); display: grid; place-items: center; padding: 20px; z-index: 40; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 420px; padding: 24px; }
.modal h3 { margin: 0 0 14px; }
.field { margin-bottom: 14px; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.err { color: var(--red); font-size: .85rem; min-height: 1.1em; margin-top: 6px; }
.hint { font-size: .8rem; color: var(--soft); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .88rem; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; z-index: 60; }
.toast.show { opacity: 1; }
.hidden { display: none !important; }
