:root {
  --app-sidebar-width: 260px;
  --app-border: #d7dee8;
  --app-muted: #667085;
  --app-bg: #f5f7fb;
  --app-ink: #172033;
  --app-primary: #2357c6;
  --app-accent: #198754;
}

body {
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--app-ink);
}

.app-loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: rgba(245, 247, 251, .78);
  backdrop-filter: blur(2px);
}

.busy-box {
  min-width: 220px;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(23, 32, 51, .16);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
}

.auth-panel {
  background: linear-gradient(145deg, #0f3b84, #126c73);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem;
}

.auth-form {
  background: #fff;
  display: flex;
  align-items: center;
  padding: 2rem;
}

.auth-form-inner {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--app-sidebar-width) minmax(0, 1fr);
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--app-border);
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1rem;
}

.sidebar-brand {
  height: 56px;
  display: flex;
  align-items: center;
  gap: .75rem;
  font-weight: 700;
}

.nav-link {
  color: #344054;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: .65rem;
}

.nav-link.active,
.nav-link:hover {
  background: #edf4ff;
  color: var(--app-primary);
}

.main-area {
  min-width: 0;
}

.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.content {
  padding: 1.25rem;
}

.metric-card {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 1rem;
  height: 100%;
}

.metric-card .metric {
  font-size: 1.75rem;
  font-weight: 700;
}

.data-card {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
}

.data-card-header {
  min-height: 56px;
  padding: 1rem;
  border-bottom: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.question-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 1rem;
}

.question-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .5rem;
}

.question-nav button {
  aspect-ratio: 1;
  min-width: 0;
}

.timer-pill {
  font-variant-numeric: tabular-nums;
  background: #fff4e5;
  color: #9a4b00;
  border: 1px solid #ffd8a8;
  border-radius: 999px;
  padding: .35rem .75rem;
  font-weight: 700;
}

.table td,
.table th {
  vertical-align: middle;
}

.muted {
  color: var(--app-muted);
}

.form-section-label {
  color: #344054;
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: .15rem;
}

.question-media-fields {
  border-top: 1px solid var(--app-border);
  border-bottom: 1px solid var(--app-border);
  padding: 1rem 0;
}

.question-media {
  margin: 1rem 0;
  width: min(100%, 900px);
}

.question-media img,
.question-media video {
  background: #0b1220;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: block;
  height: auto;
  max-height: min(64vh, 620px);
  max-width: 100%;
  object-fit: contain;
  width: 100%;
}

.question-media figcaption {
  color: var(--app-muted);
  font-size: .85rem;
  margin-top: .45rem;
}

.result-answer-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.option-prefix {
  min-width: 86px;
  justify-content: center;
  font-weight: 600;
}

.member-picker {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  max-height: calc((4.25rem * 5) + .7rem);
  overflow: auto;
  padding: .35rem;
  background: #fff;
  scrollbar-gutter: stable;
}

.student-search {
  margin-bottom: .55rem;
  position: relative;
}

.student-search .fa-magnifying-glass {
  color: var(--app-muted);
  left: .8rem;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.student-search .form-control {
  padding-left: 2.25rem;
}

.member-row {
  align-items: flex-start;
  border-radius: 6px;
  display: flex;
  gap: .7rem;
  margin: 0;
  min-height: 4.25rem;
  min-width: 0;
  padding: .6rem .65rem;
  width: 100%;
}

.member-row:hover {
  background: #f5f7fb;
}

.member-check {
  flex: 0 0 auto;
  margin: .2rem 0 0;
}

.member-copy {
  display: grid;
  gap: .15rem;
  min-width: 0;
}

.member-copy .small {
  overflow-wrap: anywhere;
}

.member-copy .badge {
  font-size: .68rem;
  vertical-align: baseline;
}

.member-empty {
  padding: .9rem;
  text-align: center;
}

.quiz-audience-panel {
  border-top: 1px solid var(--app-border);
  border-bottom: 1px solid var(--app-border);
  padding: 1rem 0;
}

.is-muted {
  opacity: .62;
}

.quiz-status-panel {
  border: 1px solid var(--app-border);
  border-left-width: 4px;
  border-radius: 8px;
  margin-top: 1rem;
  max-width: 720px;
  padding: .85rem 1rem;
}

.attempt-status-panel {
  border: 1px solid var(--app-border);
  border-left-width: 4px;
  border-radius: 8px;
  margin-top: 1rem;
  padding: .9rem 1rem;
}

.attempt-status-ready {
  background: #ecfdf3;
  border-left-color: #198754;
}

.attempt-status-done {
  background: #f4f0ff;
  border-left-color: #7048e8;
}

.attempt-status-blocked {
  background: #eef7ff;
  border-left-color: #2357c6;
}

.status-draft {
  background: #f8fafc;
  border-left-color: #667085;
}

.status-published {
  background: #eef7ff;
  border-left-color: #2357c6;
}

.status-live {
  background: #ecfdf3;
  border-left-color: #198754;
}

.status-ended {
  background: #fff7ed;
  border-left-color: #f59f00;
}

.status-results {
  background: #f4f0ff;
  border-left-color: #7048e8;
}

@media (max-width: 900px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    padding: 2rem;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--app-border);
  }

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

  .question-shell {
    grid-template-columns: 1fr;
  }

  .result-answer-grid {
    grid-template-columns: 1fr;
  }

  .question-media img,
  .question-media video {
    max-height: 54vh;
  }
}

@media (max-width: 540px) {
  .content {
    padding: .75rem;
  }

  .sidebar .nav {
    grid-template-columns: 1fr;
  }

  .data-card-header {
    align-items: stretch;
    flex-direction: column;
  }
}
