/* КДДТ PWA — тема слотов/дашборда */
:where(*, *::before, *::after) { box-sizing: border-box; }
:where(html) { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
:where(body) { margin: 0; line-height: 1.6; overflow-x: hidden; }
img, svg, video { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }

:root {
  --font-sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  --fs-1: clamp(1.75rem, 3vw, 2.25rem);
  --fs-2: clamp(1.25rem, 2vw, 1.5rem);
  --fs-base: 1rem;
  --radius: 10px;
  --space-1: .5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --max-w: 800px;
  --max-w-wide: 1200px;
  --primary: #4a90e2;
  --primary-contrast: #fff;
  --danger: #e94e77;
  --success: #2aca3d;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #222;
  --text-muted: #6a6a6a;
  --border: #e0e0e0;
  --shadow: 0 2px 12px rgba(0, 0, 0, .06);
  --focus: rgba(74, 144, 226, .35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1e2328;
    --text: #e7e9ea;
    --text-muted: #8899a6;
    --border: #2f3336;
    --shadow: 0 2px 14px rgba(0, 0, 0, .8);
    --focus: rgba(74, 144, 226, .55);
  }
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  padding: max(var(--space-2), env(safe-area-inset-top)) max(var(--space-2), env(safe-area-inset-right)) max(var(--space-2), env(safe-area-inset-bottom)) max(var(--space-2), env(safe-area-inset-left));
}

.container {
  max-width: var(--max-w);
  margin-inline: auto;
}

.container-wide {
  max-width: var(--max-w-wide);
  margin-inline: auto;
}

.container-narrow {
  max-width: 480px;
  margin-inline: auto;
}

.container-center {
  min-height: calc(100dvh - 2 * var(--space-2));
  display: flex;
  flex-direction: column;
  justify-content: center;
}

h1, h2 {
  margin: 0 0 var(--space-2);
  color: var(--text);
  line-height: 1.25;
}

h1 {
  font-size: var(--fs-1);
  text-align: center;
}

h2 {
  font-size: var(--fs-2);
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
  margin: 0 0 var(--space-3);
}

.text-muted { color: var(--text-muted); }
.hidden { display: none !important; }
.w-100 { width: 100%; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.page-header h1 {
  text-align: left;
  margin: 0;
  font-size: var(--fs-2);
}

.dashboard-header {
  margin-bottom: var(--space-3);
}

.dashboard-header h1 {
  text-align: left;
  margin: 0 0 .25rem;
  font-size: var(--fs-1);
}

.dashboard-header .teacher-name {
  margin: .25rem 0 .5rem;
  font-size: 1.05rem;
  color: var(--text-muted);
}

.dashboard-help {
  margin: 0 0 var(--space-2);
  font-size: .85rem;
}

.tabs-main {
  margin-bottom: var(--space-3);
}

.card-bvi {
  border-color: color-mix(in srgb, var(--success) 35%, var(--border));
  background: color-mix(in srgb, var(--success) 6%, var(--surface));
}

.card-inline {
  padding: var(--space-2);
  margin: var(--space-2) 0;
  background: var(--bg);
}

.checkbox-card {
  margin: var(--space-3) 0;
}

.checkbox-card-label {
  display: block;
  border: 2px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  border-radius: 18px;
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}

.checkbox-card-label:active {
  transform: scale(.995);
}

.checkbox-card-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.checkbox-card-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 1rem 1.1rem;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--primary) 14%, var(--surface)),
    color-mix(in srgb, var(--primary) 4%, var(--surface))
  );
  border-bottom: 1px solid color-mix(in srgb, var(--primary) 12%, var(--border));
}

.checkbox-card-title {
  display: grid;
  gap: .2rem;
  min-width: 0;
}

.checkbox-card-title strong {
  font-size: 1.12rem;
  line-height: 1.25;
}

.checkbox-card-subtitle {
  font-size: .88rem;
  color: var(--text-muted);
}

.checkbox-card-criteria {
  padding: .95rem 1.1rem 1.1rem;
}

.checkbox-card-lead {
  margin: 0 0 .65rem;
  font-size: .92rem;
  font-weight: 600;
  color: var(--text);
}

.checkbox-visual {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 2.5px solid color-mix(in srgb, var(--primary) 45%, var(--border));
  border-radius: 12px;
  background: var(--surface);
  position: relative;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
  transition: background .2s, border-color .2s, box-shadow .2s, transform .15s;
}

.checkbox-card-input:focus-visible + .checkbox-card-head .checkbox-visual {
  box-shadow: 0 0 0 4px var(--focus);
}

.checkbox-card-input:checked + .checkbox-card-head .checkbox-visual {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.04);
  box-shadow: 0 4px 14px rgba(74, 144, 226, .35);
}

.checkbox-card-input:checked + .checkbox-card-head .checkbox-visual::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 6px;
  width: 9px;
  height: 18px;
  border: solid #fff;
  border-width: 0 3.5px 3.5px 0;
  transform: rotate(45deg);
}

.checkbox-card-input:checked + .checkbox-card-head {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--primary) 24%, var(--surface)),
    color-mix(in srgb, var(--success) 12%, var(--surface))
  );
}

.checkbox-card-input:checked ~ .checkbox-card-criteria {
  background: color-mix(in srgb, var(--success) 5%, var(--surface));
}

.checkbox-card-label:has(.checkbox-card-input:checked) {
  border-color: var(--primary);
  box-shadow: 0 10px 28px rgba(74, 144, 226, .16);
}

.checkbox-card-list {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--text-muted);
  font-size: .9rem;
  line-height: 1.5;
}

.checkbox-card-list li + li {
  margin-top: .5rem;
}

@media (max-width: 480px) {
  .checkbox-card-head {
    padding: 1.05rem 1rem;
  }

  .checkbox-visual {
    width: 44px;
    height: 44px;
    border-radius: 13px;
  }

  .checkbox-card-input:checked + .checkbox-card-head .checkbox-visual::after {
    left: 13px;
    top: 7px;
  }

  .checkbox-card-title strong {
    font-size: 1.08rem;
  }

  .checkbox-card-list {
    font-size: .88rem;
  }
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
}

.header-actions .btn { margin: 0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 1000;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  padding: var(--space-2);
  overflow: auto;
}

.modal[hidden], .modal-backdrop[hidden] { display: none !important; }

.modal-content {
  background: var(--surface);
  color: var(--text);
  padding: var(--space-3);
  border-radius: calc(var(--radius) + 2px);
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  box-shadow: var(--shadow);
  animation: fadeIn .2s ease-out;
}

.modal-content-wide { max-width: 640px; }

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  justify-content: flex-end;
  margin-top: var(--space-2);
}

.status-fieldset {
  border: 1px solid var(--border);
  padding: var(--space-2);
  margin-bottom: var(--space-2);
  border-radius: var(--radius);
}

.status-fieldset legend {
  font-weight: 700;
  padding: 0 .5rem;
}

.status-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-1);
  font-size: .9rem;
  color: var(--text-muted);
}

body.modal-open { overflow: hidden; }

.top-links {
  text-align: center;
  margin-bottom: var(--space-2);
}

.top-links a {
  color: var(--primary);
  text-decoration: none;
  font-size: .95rem;
}

.top-links a:hover { text-decoration: underline; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  animation: fadeIn .25s ease-out;
}

.card h2:first-child { margin-top: 0; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message, .error-banner {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: var(--space-2);
  font-size: .95rem;
}

.message.success, .error-banner.success {
  background: #e6f4ea;
  color: #1e4620;
}

.message.error, .error-banner.error {
  background: #fdecea;
  color: #611a15;
}

.btn {
  --btn-bg: var(--primary);
  --btn-fg: var(--primary-contrast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .65rem 1.2rem;
  font-size: .95rem;
  font-weight: 600;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s, transform .1s;
  white-space: nowrap;
}

.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-secondary {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  border: 1px solid var(--border);
}
.btn-danger { --btn-bg: var(--danger); }

.role-btn {
  display: block;
  width: 100%;
  margin-bottom: var(--space-1);
  text-align: left;
  padding: .85rem 1rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: background .15s, border-color .15s;
}

.role-btn:hover {
  border-color: var(--primary);
  background: rgba(74, 144, 226, .08);
}

form label {
  display: block;
  margin-bottom: .5rem;
  font-weight: 600;
  font-size: .875rem;
  color: var(--text);
}

.form-field {
  margin-bottom: var(--space-3);
}

.form-field:last-child {
  margin-bottom: 0;
}

.form-field > label {
  display: block;
  margin-bottom: .5rem;
  font-weight: 600;
  font-size: .875rem;
  color: var(--text);
}

.form-control,
form input:not([type="hidden"]):not([type="checkbox"]),
form textarea,
form select,
.auth-card input:not([type="hidden"]),
.auth-card select,
.auth-card textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: .875rem 1rem;
  min-height: 48px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: calc(var(--radius) + 2px);
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
  transition: border-color .2s, box-shadow .2s, background .2s;
  -webkit-appearance: none;
  appearance: none;
}

form input:not([type="hidden"]):not([type="checkbox"]),
form textarea,
form select {
  margin-bottom: 0;
}

.form-control:focus,
form input:focus,
form textarea:focus,
form select:focus,
.auth-card input:focus,
.auth-card select:focus,
.auth-card textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--focus);
}

.form-control::placeholder,
form input::placeholder,
form textarea::placeholder,
.auth-card input::placeholder {
  color: var(--text-muted);
  opacity: .85;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-1);
}

.form-actions .btn {
  min-height: 48px;
  font-size: 1rem;
  padding: .85rem 1.25rem;
}

form textarea { min-height: 120px; resize: vertical; padding-top: .875rem; }

.form-group { margin-bottom: var(--space-1); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: var(--space-2);
}

.checkbox-row input { width: auto; margin: 0; }

.checkbox-row label {
  margin-bottom: 0;
  font-weight: normal;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tabs button {
  position: relative;
  padding: .75rem 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  font-weight: 500;
  transition: color .2s;
}

.tabs button::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: transparent;
  border-radius: 3px 3px 0 0;
}

.tabs button:hover { color: var(--text); }

.tabs button.active {
  color: var(--text);
  font-weight: 600;
}

.tabs button.active::after { background: var(--primary); }

.slots {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.slot-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
  transition: transform .2s, box-shadow .2s;
}

.slot-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.slot-card .slot-actions {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.slot-card strong {
  display: block;
  word-break: break-word;
}

.slot-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-1);
}

.slot-status {
  font-size: .75rem;
  font-weight: 600;
  padding: .15rem .45rem;
  border-radius: 999px;
  white-space: nowrap;
}

.slot-status.free {
  background: color-mix(in srgb, var(--success) 18%, transparent);
  color: var(--success);
}

.slot-status.booked {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
}

.slot-actions-inline {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  align-items: center;
}

.label {
  font-weight: 600;
  margin-right: .35rem;
  color: var(--text-muted);
}

.link-inline {
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
}

.link-inline:hover { text-decoration: underline; }

.table-wrap {
  overflow: auto;
  margin-top: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 60vh;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th, td {
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: .95rem;
}

tbody tr:hover { background: rgba(74, 144, 226, .06); }

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child { border-bottom: none; }

.inline-form {
  display: grid;
  gap: var(--space-2);
}

@media (min-width: 640px) {
  .inline-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
  }
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-2) 0;
}

.push-banner {
  background: linear-gradient(135deg, var(--primary), #357abd);
  border-radius: var(--radius);
  padding: var(--space-2);
  color: #fff;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.push-banner.granted { background: var(--success); }
.push-banner.denied { background: var(--danger); opacity: .85; }

.push-banner-icon { font-size: 1.75rem; flex-shrink: 0; }
.push-banner-text { flex: 1; }
.push-banner-title { font-weight: 700; }
.push-banner-desc { font-size: .875rem; opacity: .9; margin-top: .15rem; }

.push-banner-btn {
  background: rgba(255, 255, 255, .25);
  border: none;
  color: #fff;
  font-weight: 600;
  padding: .5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  padding: .85rem 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child { border-bottom: none; }

.settings-row-label { font-weight: 600; }
.settings-row-desc { font-size: .875rem; color: var(--text-muted); margin-top: .15rem; }

.channel-toggles {
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}

.channel-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  font-size: .7rem;
  color: var(--text-muted);
}

.toggle {
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}

.toggle.on { background: var(--primary); }

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}

.toggle.on::after { transform: translateX(18px); }

.channel-hint {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.registration-form label {
  display: block;
  margin-bottom: var(--space-2);
}

.field-required > input,
.field-required > select,
.field-required > textarea,
.field-required .combobox > input[type="text"] {
  margin-top: .35rem;
}

.field-hint {
  display: block;
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: .35rem;
  line-height: 1.45;
}

.form-section-title {
  margin: var(--space-3) 0 var(--space-2);
  font-size: var(--fs-2);
}

.combobox {
  position: relative;
  margin-top: .35rem;
}

.combobox-list {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.combobox-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: .65rem .85rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: .9rem;
  line-height: 1.35;
  color: var(--text);
}

.combobox-item:hover,
.combobox-item:focus {
  background: rgba(74, 144, 226, .08);
}

.combobox-item-other {
  font-weight: 600;
  border-top: 1px solid var(--border);
}

/* ===== Auth & registration pages ===== */
.auth-body,
.register-body {
  min-height: 100dvh;
}

.auth-shell {
  max-width: 420px;
  margin-inline: auto;
  min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: var(--space-3);
}

.auth-brand {
  text-align: center;
  margin-bottom: var(--space-3);
}

.auth-brand-icon {
  font-size: 2.75rem;
  line-height: 1;
  margin-bottom: var(--space-1);
}

.app-logo {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto var(--space-1);
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
}

.app-logo-sm {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin: 0;
  flex-shrink: 0;
}

.register-header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.register-header-brand h1 {
  margin: 0;
}

.register-header-brand .register-subtitle {
  margin: .1rem 0 0;
}

.auth-brand-title {
  margin: 0 0 .25rem;
  font-size: clamp(1.5rem, 5vw, 1.85rem);
  color: var(--primary);
  font-weight: 700;
}

.auth-brand-tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: .95rem;
}

.auth-card {
  margin-bottom: 0;
  padding: var(--space-3) calc(var(--space-3) + .25rem);
}

.auth-card .error-banner {
  margin-bottom: var(--space-2);
}

.auth-step-title {
  margin: 0 0 .5rem;
  font-size: var(--fs-2);
  text-align: left;
}

.auth-step-desc {
  margin: 0 0 var(--space-3);
  color: var(--text-muted);
  font-size: .9rem;
  line-height: 1.5;
}

.auth-step-desc strong {
  color: var(--text);
  word-break: break-all;
}

.code-input {
  font-size: 1.35rem;
  letter-spacing: .35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 1rem .75rem;
  min-height: 56px;
}

.register-shell {
  max-width: var(--max-w);
  margin-inline: auto;
  padding-bottom: env(safe-area-inset-bottom);
}

.register-header {
  margin-bottom: var(--space-2);
}

.register-header h1 {
  text-align: left;
  margin: .35rem 0 0;
  font-size: var(--fs-1);
}

.register-subtitle {
  margin: .15rem 0 0;
  color: var(--text-muted);
  font-size: .95rem;
}

.register-back {
  display: inline-flex;
  align-items: center;
  color: var(--primary);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
  min-height: 44px;
}

.register-back:active { opacity: .75; }

.role-cards {
  display: grid;
  gap: var(--space-2);
}

.role-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: .15rem .85rem;
  align-items: center;
  width: 100%;
  padding: 1rem 1.1rem;
  text-align: left;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
  min-height: 72px;
  -webkit-tap-highlight-color: transparent;
}

.role-card:active { transform: scale(.985); }

.role-card:hover,
.role-card:focus-visible {
  border-color: var(--primary);
  background: rgba(74, 144, 226, .06);
  outline: none;
}

.role-card-icon {
  grid-row: 1 / span 2;
  font-size: 1.75rem;
}

.role-card-label {
  font-weight: 700;
  font-size: 1rem;
}

.role-card-desc {
  grid-column: 2;
  color: var(--text-muted);
  font-size: .85rem;
  line-height: 1.35;
}

.registration-form label.field-required > input,
.registration-form label.field-required > select,
.registration-form label.field-required > textarea,
.registration-form label.field-required .combobox > input[type="text"] {
  margin-bottom: 0;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: .875rem 1rem;
  min-height: 48px;
  font-size: 1rem;
}

.registration-form label.field-required > select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236a6a6a' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.registration-form label.field-required {
  margin-bottom: var(--space-3);
  display: block;
}

.registration-form label.field-required > input:focus,
.registration-form label.field-required > select:focus,
.registration-form label.field-required > textarea:focus,
.registration-form label.field-required .combobox > input[type="text"]:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus);
}

.registration-form .field-hint {
  margin-top: .5rem;
  margin-bottom: 0;
}

.form-submit-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin-top: var(--space-4);
  padding: var(--space-3) 0 calc(var(--space-2) + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--surface) 75%, transparent);
  border-top: 1px solid var(--border);
}

.form-submit-bar .btn {
  min-height: 48px;
  font-size: 1rem;
}

@media (max-width: 480px) {
  .card { padding: var(--space-3) var(--space-2); }
  .auth-card { padding: var(--space-3) var(--space-2); }
  .auth-shell { padding-block: var(--space-2); }
  .form-control,
  form input:not([type="hidden"]):not([type="checkbox"]),
  form textarea,
  form select,
  .auth-card input:not([type="hidden"]) {
    font-size: 16px;
    min-height: 48px;
  }
  .code-input { font-size: 1.25rem; letter-spacing: .25em; min-height: 56px; }
}

.pwa-version-badge {
  position: fixed;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 40;
  padding: .35rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

.pwa-update-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(52px + env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--primary);
  box-shadow: var(--shadow);
}

.pwa-update-banner-text {
  display: grid;
  gap: .15rem;
  min-width: 0;
}

.pwa-update-banner-text strong {
  font-size: .95rem;
}

.pwa-update-banner-text span {
  font-size: .82rem;
  color: var(--text-muted);
}

.pwa-update-banner .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

body.pwa-update-pending .pwa-version-badge {
  bottom: calc(96px + env(safe-area-inset-bottom));
}

body.pwa-install-open {
  overflow: hidden;
}

.pwa-install-banner {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.pwa-install-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
}

.pwa-install-sheet {
  position: relative;
  z-index: 1;
  width: min(100%, 480px);
  max-height: calc(100vh - 24px);
  overflow: auto;
  margin: 12px;
  padding: var(--space-3);
  padding-top: calc(var(--space-3) + 8px);
  border-radius: 20px 20px 16px 16px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(15, 23, 42, .22);
  animation: pwa-install-slide-up .28s ease-out;
}

@keyframes pwa-install-slide-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.pwa-install-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.pwa-install-sheet-head {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-3);
  padding-right: 28px;
}

.pwa-install-app-icon {
  border-radius: 14px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(74, 144, 226, .25);
}

.pwa-install-sheet-head h2 {
  margin: 0 0 .25rem;
  font-size: 1.1rem;
}

.pwa-install-sheet-head p {
  margin: 0;
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.pwa-install-steps {
  list-style: none;
  margin: 0 0 var(--space-2);
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.pwa-install-steps li {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  font-size: .95rem;
  line-height: 1.45;
}

.pwa-install-step-num {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
}

.pwa-install-note {
  margin: 0 0 var(--space-2);
  padding: .75rem .9rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  color: var(--text-muted);
  font-size: .85rem;
  line-height: 1.45;
}

.pwa-install-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.pwa-install-actions .btn {
  flex: 1 1 140px;
}

.pwa-install-icon {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  vertical-align: -2px;
  margin-inline: .1rem;
  background: currentColor;
  opacity: .85;
}

.pwa-install-icon-share {
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='black' d='M11 2.5a2.5 2.5 0 1 1 .603 1.629l-6.718 3.12a2.5 2.5 0 0 1 0 1.838l6.718 3.12a2.5 2.5 0 1 1-.488.876l-6.718-3.12a2.5 2.5 0 1 1 0-3.752l6.718-3.12A2.5 2.5 0 0 1 11 2.5z'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='black' d='M11 2.5a2.5 2.5 0 1 1 .603 1.629l-6.718 3.12a2.5 2.5 0 0 1 0 1.838l6.718 3.12a2.5 2.5 0 1 1-.488.876l-6.718-3.12a2.5 2.5 0 1 1 0-3.752l6.718-3.12A2.5 2.5 0 0 1 11 2.5z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.pwa-install-icon-plus {
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='black' d='M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='black' d='M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.pwa-install-icon-menu {
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='black' d='M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='black' d='M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ===== Custom date picker ===== */
.mhk-datepicker {
  position: relative;
  width: 100%;
}

.mhk-datepicker-native {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

.mhk-datepicker-display {
  width: 100%;
  min-height: 52px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: .02em;
  padding: .85rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, #fff), var(--surface));
  color: var(--text);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4);
}

.mhk-datepicker-display:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus);
}

.mhk-datepicker.is-open .mhk-datepicker-display {
  border-color: var(--primary);
}

.mhk-datepicker-popover {
  display: none;
  position: absolute;
  z-index: 80;
  top: calc(100% + 8px);
  left: 0;
  width: min(100vw - 24px, 360px);
  padding: 1rem;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(15, 23, 42, .18);
}

.mhk-datepicker.is-open .mhk-datepicker-popover {
  display: block;
  animation: pwa-install-slide-up .2s ease-out;
}

.mhk-datepicker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .85rem;
}

.mhk-datepicker-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.mhk-datepicker-nav {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.mhk-datepicker-nav:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.mhk-datepicker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .25rem;
  margin-bottom: .4rem;
  text-align: center;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.mhk-datepicker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .35rem;
}

.mhk-datepicker-day {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.mhk-datepicker-day.is-empty {
  pointer-events: none;
}

.mhk-datepicker-day:hover:not(.is-empty) {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.mhk-datepicker-day.is-today {
  box-shadow: inset 0 0 0 1.5px var(--primary);
}

.mhk-datepicker-day.is-selected {
  background: var(--primary);
  color: #fff;
}

.mhk-datepicker-footer {
  display: flex;
  gap: .5rem;
  margin-top: .9rem;
}

.mhk-datepicker-footer .btn {
  flex: 1;
  min-height: 44px;
}

.modal-content .mhk-datepicker-popover,
.inline-form .mhk-datepicker-popover {
  width: min(100%, 360px);
}

body.pwa-install-open .pwa-version-badge {
  opacity: 0;
  pointer-events: none;
}

.role-choice {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.role-choice-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .2rem;
  width: 100%;
  padding: 1rem 1.15rem;
  border: 1.5px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .15s;
}

.role-choice-btn:hover,
.role-choice-btn:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus);
}

.role-choice-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.role-choice-desc {
  font-size: .875rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.broadcast-card h2 {
  margin-bottom: .35rem;
}

.broadcast-composer {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  background: color-mix(in srgb, var(--bg) 70%, var(--surface));
}

.broadcast-label {
  display: block;
  margin-bottom: .5rem;
  font-weight: 600;
  font-size: .875rem;
}

.broadcast-input {
  min-height: 160px;
  resize: vertical;
  line-height: 1.55;
  border-radius: 14px;
  padding-top: 1rem;
}

.broadcast-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: .85rem;
}

.broadcast-hint {
  font-size: .8rem;
  color: var(--text-muted);
}

@media (max-width: 560px) {
  .broadcast-footer {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 480px) {
  .pwa-update-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .pwa-update-banner .btn {
    width: 100%;
  }

  .pwa-install-sheet {
    margin: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    max-height: 88vh;
  }
}
