:root {
  --bg: #f5efe6;
  --bg-soft: #fbf8f2;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
  --text: #1f2a37;
  --muted: #687385;
  --line: #ddd1bf;
  --accent: #b24a2e;
  --accent-dark: #8f3620;
  --accent-soft: #f2dfd6;
  --success-bg: #e7f5eb;
  --success-text: #1f6b3d;
  --danger-bg: #fde8e4;
  --danger-text: #9c2f1f;
  --shadow: 0 18px 50px rgba(72, 47, 24, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(178, 74, 46, 0.16), transparent 32%),
    radial-gradient(circle at top right, rgba(91, 128, 90, 0.14), transparent 28%),
    linear-gradient(180deg, #f7f2ea 0%, #ede4d5 100%);
}

body.is-page-loading {
  cursor: progress;
}

body.is-page-loading a,
body.is-page-loading button,
body.is-page-loading input,
body.is-page-loading select {
  cursor: progress;
}

.page-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 24px;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 18px 22px;
  margin-bottom: 24px;
  border: 1px solid rgba(221, 209, 191, 0.7);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

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

.site-brand--login {
  margin-bottom: 20px;
}

.site-brand__logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.site-brand__eyebrow,
.hero-card__eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.76rem;
  font-weight: 700;
}

.site-brand__title,
.hero-card__title,
.section-head__title {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.site-nav__link,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.site-nav__link {
  color: var(--text);
  background: var(--bg-soft);
  border-color: var(--line);
}

.site-nav__link:hover,
.button:hover {
  transform: translateY(-1px);
}

.site-nav__link.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.site-main {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.page-loading-indicator {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(221, 209, 191, 0.82);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 36px rgba(39, 32, 26, 0.18);
  color: var(--text);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

body.is-page-loading .page-loading-indicator {
  opacity: 1;
  transform: translateY(0);
}

.page-loading-indicator__spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(178, 74, 46, 0.22);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: page-loading-spin 0.75s linear infinite;
}

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

.site-footer {
  margin-top: 28px;
  padding: 10px 0 2px;
}

.site-footer__line {
  height: 1px;
  margin-bottom: 16px;
  background: linear-gradient(90deg, transparent 0%, rgba(178, 74, 46, 0.28) 18%, rgba(178, 74, 46, 0.5) 50%, rgba(178, 74, 46, 0.28) 82%, transparent 100%);
}

.site-footer__content {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 14px 18px 10px;
  border: 1px solid rgba(221, 209, 191, 0.72);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.48);
  backdrop-filter: blur(8px);
  box-shadow: 0 14px 36px rgba(72, 47, 24, 0.08);
  text-align: center;
}

.site-footer__brand {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  font-weight: 800;
}

.site-footer__meta {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

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

.login-card,
.hero-card,
.panel-card,
.stat-card {
  border: 1px solid rgba(221, 209, 191, 0.75);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.login-card {
  width: min(100%, 520px);
  padding: 34px;
}

.login-card--wide {
  width: min(100%, 580px);
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 22px 0 20px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(221, 209, 191, 0.42);
}

.mode-switch__button {
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.mode-switch__button.is-active {
  background: var(--surface);
  box-shadow: 0 10px 22px rgba(39, 32, 26, 0.1);
}

.login-mode[hidden] {
  display: none;
}

.login-card__text,
.hero-card__meta,
.section-head__text,
.qr-placeholder small,
.chooser-hero__text,
.school-card__meta {
  color: var(--muted);
}

.chooser-hero {
  padding: 24px 4px 8px;
}

.chooser-hero__title,
.school-card__title {
  margin: 8px 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.school-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.school-card {
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid rgba(221, 209, 191, 0.75);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.school-card__eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
}

.hero-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 24px 28px;
}

.hero-card__status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(39, 32, 26, 0.06);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill--ok {
  background: rgba(41, 127, 78, 0.12);
  color: #1f6d47;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  min-height: 200px;
  padding: 22px;
}

.stat-card--tab {
  width: 100%;
  border: 1px solid rgba(221, 209, 191, 0.75);
  background: var(--surface);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.stat-card--link {
  color: inherit;
  text-decoration: none;
}

.stat-card--active {
  border-color: rgba(178, 74, 46, 0.45);
  background:
    linear-gradient(180deg, rgba(178, 74, 46, 0.08), rgba(178, 74, 46, 0.03)),
    var(--surface);
}

.stat-card--link:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(39, 32, 26, 0.12);
}

.stat-card__label {
  color: var(--muted);
  font-size: 0.95rem;
}

.stat-card__value {
  margin-top: 22px;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 800;
  line-height: 1;
}

.stat-card__value--small {
  font-size: 1.6rem;
  line-height: 1.2;
}

.stat-card__button-row {
  margin-top: auto;
  padding-top: 16px;
}

.stat-card__action {
  margin-top: auto;
  align-self: flex-start;
  pointer-events: none;
}

.stat-card__caption {
  margin-top: auto;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.dashboard-tab-panel--hidden {
  display: none;
}

.qr-placeholder {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 124px;
  margin-top: 18px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: repeating-linear-gradient(
    45deg,
    rgba(178, 74, 46, 0.06),
    rgba(178, 74, 46, 0.06) 12px,
    rgba(255, 255, 255, 0.8) 12px,
    rgba(255, 255, 255, 0.8) 24px
  );
  text-align: center;
}

.qr-preview {
  display: block;
  width: 132px;
  height: 132px;
  margin: 18px auto 0;
  border-radius: var(--radius-md);
  border: 1px solid rgba(221, 209, 191, 0.75);
  background: #fff;
  object-fit: contain;
  padding: 8px;
}

.qr-preview-button {
  display: block;
  width: fit-content;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.qr-actions {
  margin-top: 12px;
  justify-content: center;
}

.qr-upload-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.qr-modal[hidden] {
  display: none;
}

.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.qr-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 12, 8, 0.7);
  backdrop-filter: blur(3px);
}

.qr-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(92vw, 720px);
  max-height: calc(100vh - 48px);
  margin: 24px auto;
  padding: 24px;
  overflow: auto;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.qr-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: rgba(39, 32, 26, 0.08);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.qr-modal__image {
  display: block;
  width: 100%;
  max-height: 70vh;
  margin: 0 auto 18px;
  border-radius: var(--radius-md);
  background: #fff;
  object-fit: contain;
}

body.qr-modal-open {
  overflow: hidden;
}

.panel-card {
  padding: 24px;
}

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

.two-column-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 22px;
}

.two-column-grid--balanced {
  grid-template-columns: 1fr 1fr;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid--inline {
  grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(140px, 180px)) auto;
  align-items: end;
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field--inline {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.field__label {
  font-size: 0.92rem;
  font-weight: 600;
}

.field__control {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  font: inherit;
  color: var(--text);
}

.password-field {
  position: relative;
  display: block;
}

.password-field__control {
  padding-right: 54px;
}

.password-field__toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transform: translateY(-50%);
}

.password-field__toggle:hover,
.password-field__toggle:focus-visible {
  color: var(--accent);
  background: var(--accent-soft);
}

.password-field__toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.password-field__icon {
  position: relative;
  width: 22px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 999px 999px 8px 8px;
  transform: rotate(45deg);
}

.password-field__icon::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.password-field__toggle[aria-pressed="true"] .password-field__icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -4px;
  width: 28px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: translateY(-50%) rotate(90deg);
}

.field__control:disabled,
.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.field__hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.checkbox-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.checkbox-chip input {
  margin: 0;
}

.search-field {
  position: relative;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 8;
  display: grid;
  gap: 6px;
  max-height: 260px;
  padding: 8px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 18px 40px rgba(39, 32, 26, 0.12);
}

.search-dropdown[hidden] {
  display: none;
}

.search-option,
.search-dropdown__empty {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.search-option {
  display: grid;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.search-option:hover,
.search-option:focus-visible {
  background: rgba(178, 74, 46, 0.08);
  outline: none;
}

.search-option__name {
  font-weight: 600;
}

.search-option__meta,
.search-dropdown__empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.detail-list--spaced {
  padding: 16px 18px;
  border: 1px solid rgba(221, 209, 191, 0.75);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.55);
}

.filter-toolbar {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.filter-toolbar--inline {
  align-items: end;
}

.filter-toolbar__date {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.filter-toolbar__compact {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.filter-toolbar__field {
  min-width: 180px;
}

.event-search-field {
  width: min(100%, 420px);
  margin: 0 0 18px;
}

.filter-toolbar__range {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--text);
  font-weight: 600;
}

.field__control--compact {
  min-width: 0;
  max-width: 220px;
}

.table-sort-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}

.table-sort-button {
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-transform: inherit;
}

.table-sort-link__hint {
  color: var(--muted);
  font-size: 0.9em;
}

.table-sort-link.is-active .table-sort-link__hint,
.table-sort-link:hover .table-sort-link__hint {
  color: var(--color-accent);
}

.deploy-status-card {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
}

.deploy-status-card__summary {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.deploy-status-card__progress {
  width: 100%;
  height: 14px;
}

.deploy-status-card__log {
  max-height: 260px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border-radius: var(--radius-sm);
  background: rgba(39, 32, 26, 0.06);
  border: 1px solid rgba(221, 209, 191, 0.75);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.45;
}

.button--primary {
  color: #fff;
  background: var(--accent);
}

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

.button--ghost,
.button--tiny {
  color: var(--text);
  background: var(--bg-soft);
  border-color: var(--line);
}

.button--danger {
  color: var(--danger-text);
  background: var(--danger-bg);
}

.button--tiny,
.button--danger {
  min-height: 36px;
  padding: 0 14px;
}

.table-wrap {
  max-height: min(58vh, 520px);
  overflow-x: auto;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.table-wrap--compact {
  margin-top: 20px;
  max-height: min(46vh, 420px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table--report {
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(221, 209, 191, 0.75);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.data-table__meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.data-table__empty {
  color: var(--muted);
  text-align: center;
}

.data-table--report tbody tr:nth-child(even) {
  background: rgba(221, 209, 191, 0.14);
}

.table-actions {
  white-space: nowrap;
  text-align: right;
}

.table-actions__group--double {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.inline-form {
  display: inline-flex;
}

.inline-edit-grid {
  display: contents;
}

tr.is-selected {
  background: rgba(178, 74, 46, 0.08);
}

.flash-stack {
  display: grid;
  gap: 10px;
}

.flash {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
}

.flash--success {
  color: var(--success-text);
  background: var(--success-bg);
}

.flash--error {
  color: var(--danger-text);
  background: var(--danger-bg);
}

@media (max-width: 980px) {
  .two-column-grid {
    grid-template-columns: 1fr;
  }

  .form-grid--inline {
    grid-template-columns: 1fr;
  }

  .hero-card,
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 16px;
  }

  .login-card,
  .panel-card,
  .hero-card,
  .stat-card {
    padding: 20px;
    border-radius: 22px;
  }

  .site-nav,
  .button-row {
    width: 100%;
  }

  .site-nav__link,
  .button {
    width: 100%;
  }
}
