:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #16202e;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 32, 46, .06), 0 8px 24px rgba(16, 32, 46, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px 16px 64px;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wrap { max-width: 720px; margin: 0 auto; }
.wrap-wide { max-width: 1400px; margin: 0 auto; }

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 16px;
}

label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.hint { font-weight: 400; color: var(--muted); }

input[type="text"], input[type="search"], input[type="date"], select {
  width: 100%;
  padding: 11px 13px;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
input[aria-invalid="true"] { border-color: var(--danger); }

.field { margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 180px; }

button {
  font: inherit;
  font-weight: 600;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
button:hover:not(:disabled) { background: var(--brand-dark); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
button.ghost:hover:not(:disabled) { background: #f1f5f9; }
button.danger { background: var(--danger); }
button.danger:hover:not(:disabled) { background: #b91c1c; }
button.big { width: 100%; padding: 18px; font-size: 18px; }
button.small { padding: 6px 12px; font-size: 13px; font-weight: 500; }

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 52px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 1px;
  margin: 8px 0 2px;
}
.timer.warn { color: var(--warn); }
.timer-note { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 16px; }

.meter { height: 10px; background: #e8edf5; border-radius: 999px; overflow: hidden; margin: 14px 0 18px; }
.meter > i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width .08s linear; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); margin-right: 8px; vertical-align: middle; }
.dot.live { animation: pulse 1.1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.msg { padding: 12px 14px; border-radius: 10px; font-size: 15px; margin-bottom: 16px; }
.msg.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.msg.ok { background: #f0fdf4; color: #14532d; border: 1px solid #bbf7d0; }
.msg.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.msg.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

audio { width: 100%; margin: 6px 0 16px; }
.hidden { display: none !important; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.pending { background: #f1f5f9; color: #475569; }
.badge.processing { background: #eff6ff; color: #1d4ed8; }
.badge.done { background: #f0fdf4; color: var(--ok); }
.badge.error { background: #fef2f2; color: var(--danger); }

.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; min-width: 108px; }
.stat b { display: block; font-size: 22px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 220px; }

.table-scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); position: sticky; top: 0; white-space: nowrap; }
tbody tr:hover { background: #fafcff; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.text { min-width: 320px; max-width: 560px; }
td.text .full { display: none; }
tr.expanded td.text .short { display: none; }
tr.expanded td.text .full { display: block; white-space: pre-wrap; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.link { color: var(--brand); text-decoration: none; }
.link:hover { text-decoration: underline; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.footer-note { color: var(--muted); font-size: 13px; margin-top: 18px; }

@media (max-width: 640px) {
  .timer { font-size: 42px; }
  body { padding: 16px 12px 48px; }
  .card { padding: 18px; }
}

.duration-line { text-align: center; font-size: 18px; margin: 4px 0 20px; }
.duration-line b { font-variant-numeric: tabular-nums; font-size: 22px; }

.report-card { border-left: 4px solid var(--brand); }
.report-card h2 { margin-bottom: 6px; }
.report-path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; }

/* --- сеанс: фазы, вопросы на экране --- */
.phase-card { text-align: center; }
.phase-card.recording { border-color: #fecaca; background: #fffbfb; }
.phase-label {
  font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.phase-card.recording .phase-label { color: var(--danger); }
.phase-note { color: var(--muted); font-size: 14px; margin: 14px 0 0; }

.q-item {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 12px;
}
.q-topic {
  font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--brand); margin-bottom: 6px;
}
.q-text { font-size: 16px; line-height: 1.45; margin: 0 0 8px; }
.q-hint { font-size: 14px; color: var(--muted); margin: 0; }
.q-hint b { font-weight: 600; color: #475569; }

.session-code {
  text-align: center; color: var(--muted); font-size: 12px;
  letter-spacing: .08em; margin-top: 22px;
}

/* --- управление занятием --- */
.session-card { border-left: 4px solid var(--danger); }
.session-grid { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 900px) { .session-grid { grid-template-columns: 1fr 260px; } }
.session-state { font-size: 19px; font-weight: 600; }
.session-state .phase-chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; margin-right: 10px; vertical-align: middle;
}
.phase-chip.idle { background: #f1f5f9; color: #475569; }
.phase-chip.prepare { background: #fffbeb; color: var(--warn); }
.phase-chip.record { background: #fef2f2; color: var(--danger); }
.phase-chip.finished { background: #f0fdf4; color: var(--ok); }
.qr-box { text-align: center; }
.qr-holder {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; min-height: 180px; display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.qr-holder svg { width: 100%; height: auto; max-width: 220px; display: block; }
.qr-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--muted); margin-top: 10px; word-break: break-all;
}
button.danger-text { color: var(--danger); }

/* --- список подключённых --- */
@media (min-width: 1100px) { .session-grid.three { grid-template-columns: 1fr 1fr 240px; } }
.roster-head { font-size: 13px; margin-bottom: 8px; }
.roster { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.roster:empty { display: none; }
.roster-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--line-soft, #eef2f6); font-size: 14px;
}
.roster-row:last-child { border-bottom: 0; }
.roster-id { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 46px; }
.roster-left { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; }
.live-dot.off { background: #cbd5e1; }
.roster-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 14px; }
.dup-warn { color: var(--warn); font-size: 13px; margin-top: 8px; }
