/* ---------------------------------------------------------------
   Тема: строгий, деловой минимализм. Акцент — только там, где
   нужно привлечь внимание (кнопки, статусы, важные подписи).
   --------------------------------------------------------------- */

:root {
  --ink: #1a1d24;
  --ink-soft: #545a68;
  --ink-faint: #8a90a0;
  --line: #e2e4ea;
  --line-strong: #cbcedb;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --accent: #26317a;
  --accent-hover: #1c2560;
  --accent-soft: #eef0fb;
  --danger: #a4231c;
  --danger-soft: #fbeceb;
  --success-bg: #e6f4ea;
  --success-ink: #1d5a30;
  --error-bg: #fbeceb;
  --error-ink: #7c231c;
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

a { color: var(--accent); }

/* ---------- Header ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  color: var(--ink);
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  gap: 8px;
}

.topbar .brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.topbar nav a {
  color: var(--ink-soft);
  text-decoration: none;
  margin-left: 20px;
  font-size: 0.92rem;
  font-weight: 500;
}

.topbar nav a:hover { color: var(--accent); }

/* ---------- Layout ---------- */

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}

h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 32px 0 12px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

h2:first-of-type { border-top: none; padding-top: 0; }

p { color: var(--ink-soft); }

/* ---------- Forms ---------- */

form { margin-bottom: 16px; }
form.narrow { max-width: 460px; }

.field {
  display: block;
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.field input, .field textarea {
  display: block;
  width: 100%;
  padding: 9px 11px;
  margin-top: 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 400;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
}

.field input:focus, .field textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

textarea.wide { width: 100%; font-family: ui-monospace, monospace; font-size: 0.9rem; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover { background: var(--accent-hover); }

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
}

button.danger:hover { background: var(--danger-soft); }

/* ---------- Subject cards (index) ---------- */

.cards { list-style: none; padding: 0; display: grid; gap: 10px; margin: 20px 0; }

.card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  transition: border-color .12s ease;
}

.card:hover { border-color: var(--accent); }

.card-title { font-weight: 600; font-size: 1rem; }

.card-progress {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.card-progress.muted { color: var(--ink-faint); background: var(--line); }

/* ---------- Topic list (public selection page) ---------- */

.topics { list-style: none; padding: 0; margin: 18px 0; }

.topics li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.topics li label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.topics li label input { margin-top: 4px; flex-shrink: 0; }

.topics li.taken { background: #fafafb; }
.topics li.taken span:not(.badge) { color: var(--ink-faint); }

.taken-info { margin-top: 8px; margin-left: 26px; }

.taken-info summary {
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}

.taken-info summary::-webkit-details-marker { display: none; }
.taken-info summary::before { content: "▸ "; }
.taken-info[open] summary::before { content: "▾ "; }

.taken-names {
  list-style: none;
  padding: 6px 0 0 14px;
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.taken-names li { padding: 2px 0; }

/* ---------- Admin topic list ---------- */

.topic-admin-list { list-style: none; padding: 0; margin: 0; }

.topic-admin-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 11px 14px;
  border-radius: var(--radius);
  margin-bottom: 6px;
}

.topic-admin-list li form { margin: 0; }
.topic-admin-text { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Tables (admin) ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 12px 0;
}

th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

tr:last-child td { border-bottom: none; }

td.actions { display: flex; gap: 10px; align-items: center; }
td.actions form { margin: 0; }

/* ---------- Flash messages ---------- */

.flashes { margin-bottom: 20px; }
.flash {
  padding: 11px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  border: 1px solid transparent;
}
.flash-success { background: var(--success-bg); color: var(--success-ink); border-color: #bfe3c9; }
.flash-error { background: var(--error-bg); color: var(--error-ink); border-color: #f1c3bf; }

@media (max-width: 480px) {
  .container { padding: 20px 14px 48px; }
  .topbar { padding: 12px 16px; }
}
