:root {
  --bg: #f4f8ff;
  --surface: #ffffff;
  --surface-alt: #eef4ff;
  --text: #17304f;
  --muted: #60738d;
  --line: #d8e3f5;
  --primary: #2f6fed;
  --primary-soft: #e6efff;
  --primary-border: #cfe0ff;
  --field-bg: #fbfdff;
  --shadow: 0 18px 48px rgba(23, 48, 79, 0.14);
  --focus-shadow: 0 0 0 3px rgba(47, 111, 237, 0.14);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --container: 1180px;
}

body[data-theme-mode="dark"] {
  --bg: #101725;
  --surface: #172033;
  --surface-alt: #202b42;
  --text: #edf4ff;
  --muted: #a9b8ce;
  --line: #34435c;
  --field-bg: #121b2b;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

body[data-theme-color="blue"] {
  --primary: #2f6fed;
  --primary-soft: #e6efff;
  --primary-border: #cfe0ff;
  --focus-shadow: 0 0 0 3px rgba(47, 111, 237, 0.14);
}

body[data-theme-color="green"] {
  --primary: #218a5d;
  --primary-soft: #e2f6ed;
  --primary-border: #c2ead8;
  --focus-shadow: 0 0 0 3px rgba(33, 138, 93, 0.16);
}

body[data-theme-color="rose"] {
  --primary: #c04470;
  --primary-soft: #fde8f0;
  --primary-border: #f5c9d9;
  --focus-shadow: 0 0 0 3px rgba(192, 68, 112, 0.16);
}

body[data-theme-color="amber"] {
  --primary: #a86708;
  --primary-soft: #fff1d2;
  --primary-border: #efd39c;
  --focus-shadow: 0 0 0 3px rgba(168, 103, 8, 0.16);
}

body[data-theme-color="violet"] {
  --primary: #7457d6;
  --primary-soft: #eee9ff;
  --primary-border: #d8ceff;
  --focus-shadow: 0 0 0 3px rgba(116, 87, 214, 0.16);
}

body[data-theme-mode="dark"][data-theme-color="blue"] {
  --primary-soft: rgba(71, 128, 255, 0.18);
  --primary-border: rgba(105, 153, 255, 0.38);
}

body[data-theme-mode="dark"][data-theme-color="green"] {
  --primary-soft: rgba(54, 183, 125, 0.18);
  --primary-border: rgba(87, 207, 151, 0.38);
}

body[data-theme-mode="dark"][data-theme-color="rose"] {
  --primary-soft: rgba(221, 92, 136, 0.2);
  --primary-border: rgba(236, 132, 169, 0.42);
}

body[data-theme-mode="dark"][data-theme-color="amber"] {
  --primary-soft: rgba(226, 154, 28, 0.2);
  --primary-border: rgba(238, 181, 70, 0.42);
}

body[data-theme-mode="dark"][data-theme-color="violet"] {
  --primary-soft: rgba(140, 111, 232, 0.2);
  --primary-border: rgba(166, 143, 245, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  transition: background-color 0.18s ease, color 0.18s ease;
}

html,
body {
  height: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button:disabled {
  cursor: progress;
  opacity: 0.72;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar__nav,
.topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar__actions {
  justify-content: flex-end;
}

.mobile-menu-button {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 13px;
  cursor: pointer;
  font-weight: 700;
}

.mobile-menu-button__lines,
.mobile-menu-button__lines::before,
.mobile-menu-button__lines::after {
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: var(--primary);
  display: block;
}

.mobile-menu-button__lines {
  position: relative;
}

.mobile-menu-button__lines::before,
.mobile-menu-button__lines::after {
  content: "";
  position: absolute;
  left: 0;
}

.mobile-menu-button__lines::before {
  top: -5px;
}

.mobile-menu-button__lines::after {
  top: 5px;
}

.nav-link,
.button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
}

.nav-link.is-active,
.button--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.button--ghost {
  background: var(--surface);
}

.theme-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.theme-button__mark {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--primary) 0 50%, var(--primary-soft) 50% 100%);
  border: 1px solid var(--primary-border);
}

.button--loading {
  position: relative;
  padding-left: 38px;
}

.button--loading::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: button-spin 0.7s linear infinite;
}

.button--success {
  background: #2f8f60;
  border-color: #2f8f60;
  color: white;
}

.user-pill,
.badge {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  font-size: 0.92rem;
}

.user-pill {
  max-width: 120px;
  justify-content: center;
  color: var(--text);
}

.badge--soft {
  background: #edf5ff;
}

.page-shell {
  width: min(calc(100% - 32px), var(--container));
  margin: 24px auto 40px;
  flex: 1 0 auto;
}

.screen {
  display: none;
}

.screen--active {
  display: grid;
  gap: 20px;
}

.panel,
.intro-block,
.subpanel,
.event-card,
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
}

.panel,
.intro-block {
  padding: 24px;
}

#screen-profile > .panel {
  padding: 28px 24px 24px;
}

.intro-block {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.intro-block h1,
.section-header h2 {
  margin: 0;
}

.intro-text,
.section-label,
.empty-state,
.list-block {
  color: var(--muted);
}

.section-label {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  font-weight: 700;
}

.intro-stats {
  display: grid;
  gap: 12px;
}

.stat-box {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
  border: 1px solid var(--line);
}

.stat-box span {
  display: block;
  font-size: 2rem;
  font-weight: 700;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

#screen-profile .section-header {
  margin-bottom: 14px;
}

.guest-banner {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  color: var(--muted);
}

.filters-row,
.form-grid,
.profile-grid,
.events-grid,
.admin-users {
  display: grid;
  gap: 16px;
}

.filters-row {
  grid-template-columns: 2fr 1fr;
  margin-bottom: 18px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid--wide {
  align-items: start;
}

.form-grid__full {
  grid-column: 1 / -1;
}

.profile-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.subpanel {
  padding: 18px 20px;
}

.subpanel h3 {
  margin-top: 0;
}

#participants-panel {
  margin-top: 0;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--field-bg);
  color: var(--text);
}

select {
  appearance: none;
  background-color: var(--field-bg);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 50%,
    calc(100% - 14px) 50%;
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
  padding-right: 42px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-shadow);
}

input[type="file"] {
  padding: 8px;
  color: var(--muted);
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 9px 13px;
  border: 1px solid var(--primary-border);
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

input[type="file"]::file-selector-button:hover {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

textarea {
  resize: vertical;
}

.checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.category-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.category-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.category-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--field-bg);
}

.category-item span {
  font-weight: 700;
}

.auth-screen {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 180px);
}

.auth-card {
  width: min(100%, 620px);
  padding: 24px;
  display: grid;
  gap: 16px;
}

.auth-card .section-header {
  margin-bottom: 0;
}

.auth-card .button[type="submit"] {
  justify-self: start;
  margin-top: 4px;
}

.events-grid {
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
}

.event-card {
  overflow: hidden;
  display: grid;
}

.event-card__cover-wrap {
  min-height: 180px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--line);
}

.event-card__cover {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.event-card__top,
.event-card__body,
.event-card__actions {
  padding: 18px 18px 0;
}

.event-card__actions {
  padding-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.event-card__title {
  margin: 0 0 10px;
  padding: 0 18px;
}

.event-card__summary {
  margin: 0;
  padding: 0 18px;
  color: var(--muted);
}

.event-card__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.event-card__meta {
  display: grid;
  gap: 10px;
  margin: 16px 18px 0;
}

.event-card__meta div {
  display: grid;
  gap: 4px;
}

.event-card__meta dt {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.event-card__meta dd {
  margin: 0;
  font-weight: 600;
}

.event-card__capacity--full {
  color: #b54848;
}

.list-block {
  display: grid;
  gap: 12px;
}

.list-item {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--field-bg);
  border: 1px solid var(--line);
}

.list-item__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.admin-users-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) minmax(160px, 220px);
  gap: 12px;
  margin-bottom: 14px;
}

.admin-users-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--field-bg);
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  color: var(--text);
}

.admin-users-table th,
.admin-users-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-users-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-alt);
}

.admin-users-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-users-table tbody tr {
  background: var(--field-bg);
}

.admin-users-table tbody tr:hover {
  background: var(--surface-alt);
}

.admin-user-main {
  display: grid;
  gap: 3px;
}

.admin-user-email {
  color: var(--muted);
  font-size: 13px;
}

.admin-user-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-user-actions select {
  min-width: 140px;
  padding: 8px 10px;
  padding-right: 34px;
  font-size: 13px;
  border-radius: 12px;
  background-position:
    calc(100% - 16px) 50%,
    calc(100% - 10px) 50%;
}

.button--tiny {
  padding: 8px 10px;
  min-height: auto;
  border-radius: 12px;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #16365b;
  color: white;
  z-index: 20;
}

.theme-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(9, 18, 32, 0.48);
}

.theme-modal {
  width: min(100%, 480px);
  padding: 22px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}

.theme-modal__header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.theme-modal__header h2 {
  margin: 0;
}

.theme-modal__section {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.theme-choice-grid {
  display: grid;
  gap: 12px;
}

.theme-choice-grid--mode {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.theme-choice-grid--colors {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.theme-mode-card,
.theme-color-card {
  border: 1px solid var(--line);
  background: var(--field-bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.theme-mode-card:hover,
.theme-color-card:hover {
  transform: translateY(-1px);
}

.theme-mode-card.is-selected,
.theme-color-card.is-selected {
  border-color: var(--primary);
  box-shadow: var(--focus-shadow);
}

.theme-mode-card {
  min-height: 126px;
  border-radius: 18px;
  padding: 14px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
}

.theme-mode-card__preview {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.theme-mode-card__preview--light {
  background:
    linear-gradient(135deg, #ffffff 0 48%, #eaf1ff 48% 100%),
    #ffffff;
}

.theme-mode-card__preview--dark {
  background:
    linear-gradient(135deg, #121b2b 0 48%, #2a3750 48% 100%),
    #121b2b;
}

.theme-color-card {
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 16px;
}

.theme-color-card[data-theme-color="blue"] {
  background: #2f6fed;
}

.theme-color-card[data-theme-color="green"] {
  background: #218a5d;
}

.theme-color-card[data-theme-color="rose"] {
  background: #c04470;
}

.theme-color-card[data-theme-color="amber"] {
  background: #d28a16;
}

.theme-color-card[data-theme-color="violet"] {
  background: #7457d6;
}

.theme-modal__hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.button--danger {
  color: #9f2f2f;
  border-color: #efcaca;
}

.inline-link {
  border: none;
  background: transparent;
  color: var(--primary);
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
}

.legal-consent {
  align-items: start;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.legal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.legal-card {
  display: grid;
  align-content: start;
  gap: 12px;
}

.legal-card h3,
.legal-card p,
.legal-document p {
  margin: 0;
}

.legal-document {
  display: grid;
  gap: 14px;
  line-height: 1.65;
}

.site-footer {
  width: min(calc(100% - 32px), var(--container));
  margin: 0 auto 32px;
  padding: 18px 4px 0;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer__brand {
  display: grid;
  gap: 4px;
}

.site-footer__brand strong {
  color: var(--text);
  font-size: 0.98rem;
}

.site-footer__links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.footer-link {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
}

.footer-link:hover {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

@keyframes button-spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .filters-row,
  .profile-grid,
  .form-grid,
  .category-row,
  .admin-users-toolbar,
  .legal-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .mobile-menu-button {
    display: inline-flex;
  }

  .topbar__nav,
  .topbar__actions {
    grid-column: 1 / -1;
    display: none;
    justify-content: stretch;
  }

  .topbar.is-menu-open .topbar__nav,
  .topbar.is-menu-open .topbar__actions {
    display: grid;
    gap: 8px;
  }

  .topbar.is-menu-open .topbar__nav {
    padding-top: 12px;
  }

  .topbar.is-menu-open .topbar__actions {
    padding-top: 2px;
  }

  .topbar__nav .nav-link,
  .topbar__actions .button {
    width: 100%;
    border-radius: 14px;
    text-align: center;
  }

  .topbar__actions .theme-button {
    justify-content: center;
  }

  .site-footer__links {
    justify-content: flex-start;
  }

  .site-footer {
    align-items: flex-start;
  }

  .admin-users-table {
    min-width: 760px;
  }
}
