:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-alt: #eef3f4;
  --ink: #16202a;
  --muted: #60707c;
  --line: #d8e0e4;
  --teal: #19766a;
  --teal-dark: #105f56;
  --blue: #315c9a;
  --amber: #9d6a05;
  --red: #b4233a;
  --green-soft: #e3f4ee;
  --blue-soft: #e6eef9;
  --amber-soft: #fbf0d2;
  --red-soft: #fbe5e9;
  --shadow: 0 18px 50px rgba(20, 33, 45, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(25, 118, 106, 0.08), transparent 260px),
    var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 22px;
}

.auth-brand {
  margin-bottom: 18px;
}

.auth-form {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-art {
  width: 112px;
  height: 76px;
  object-fit: contain;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.7rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.28rem;
  line-height: 1.15;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 10px;
}

.userbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(100%, 260px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  padding: 10px;
}

.userbar div {
  min-width: 0;
  flex: 1;
}

.userbar strong,
.userbar small {
  display: block;
}

.userbar strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.userbar small {
  margin-top: 2px;
  color: var(--muted);
  font-weight: 800;
}

.metric {
  min-width: 86px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
}

.metric small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 18px;
  padding-bottom: 3px;
}

.tab,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.tab {
  padding: 0 16px;
}

.tab span,
.button span {
  width: 18px;
  text-align: center;
  font-weight: 900;
}

.tab.is-active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.button {
  width: 100%;
  padding: 0 14px;
}

.button.compact {
  width: auto;
  min-height: 36px;
}

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

.button.primary:hover,
.tab.is-active:hover {
  background: var(--teal-dark);
}

.button.secondary:hover,
.tab:hover {
  border-color: #aac0c6;
  background: var(--surface-alt);
}

.button.danger {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.button.ghost {
  background: transparent;
  color: var(--red);
}

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

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.workspace-grid,
.editor-layout,
.import-layout,
.quiz-layout,
.users-layout {
  display: grid;
  align-items: start;
  gap: 18px;
}

.workspace-grid {
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr);
}

.editor-layout,
.import-layout,
.quiz-layout,
.users-layout {
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
}

.filter-panel,
.bank-panel,
.editor-main,
.editor-side,
.import-panel,
.import-side,
.quiz-panel,
.quiz-side,
.users-panel,
.user-form-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.filter-panel,
.editor-side,
.import-side,
.quiz-side,
.user-form-panel {
  position: sticky;
  top: 18px;
  padding: 16px;
}

.bank-panel,
.editor-main,
.import-panel,
.quiz-panel,
.users-panel {
  padding: 18px;
}

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

.result-count,
.quiz-score {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.86rem;
  font-weight: 800;
}

label,
fieldset {
  display: grid;
  gap: 7px;
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

fieldset {
  border: 0;
  padding: 0;
}

legend {
  margin-bottom: 8px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(25, 118, 106, 0.16);
}

.filter-actions,
.form-actions,
.import-actions {
  display: grid;
  gap: 10px;
}

.import-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

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

.question-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
}

.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.user-card strong,
.user-card span {
  display: block;
}

.user-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.9rem;
}

.question-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.question-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.question-meta,
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.pronta {
  background: var(--green-soft);
  color: var(--teal-dark);
}

.badge.revisao {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.rascunho {
  background: var(--red-soft);
  color: var(--red);
}

.badge.admin {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge.editor {
  background: var(--green-soft);
  color: var(--teal-dark);
}

.badge.student {
  background: var(--surface-alt);
  color: var(--muted);
}

.card-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
}

.icon-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.option-row {
  grid-template-columns: 18px 28px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  margin-bottom: 9px;
}

.option-row input[type="radio"] {
  width: 18px;
  min-height: 18px;
}

.option-row span {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--teal-dark);
  font-weight: 900;
}

.status-box,
.empty-state {
  border: 1px dashed #b6c6cb;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--muted);
  padding: 14px;
}

.status-box strong,
.empty-state strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.import-side,
.quiz-side {
  display: grid;
  gap: 12px;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-alt);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--teal);
  transition: width 180ms ease;
}

.quiz-content {
  padding-top: 18px;
}

.quiz-question {
  margin-bottom: 16px;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.4;
}

.quiz-options {
  display: grid;
  gap: 10px;
}

.quiz-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
  text-align: left;
  white-space: normal;
}

.quiz-option strong {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--teal-dark);
}

.quiz-option.is-selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 92, 154, 0.14);
}

.quiz-option.is-correct {
  border-color: var(--teal);
  background: var(--green-soft);
}

.quiz-option.is-wrong {
  border-color: var(--red);
  background: var(--red-soft);
}

.quiz-controls {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.quiz-controls .button {
  width: auto;
}

.rationale {
  margin-top: 16px;
  border-left: 4px solid var(--teal);
  border-radius: 6px;
  background: var(--green-soft);
  padding: 12px 14px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .topbar,
  .workspace-grid,
  .editor-layout,
  .import-layout,
  .quiz-layout,
  .users-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .filter-panel,
  .editor-side,
  .import-side,
  .quiz-side,
  .user-form-panel {
    position: static;
  }

  .metric-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .brand {
    align-items: flex-start;
  }

  .brand-art {
    width: 76px;
    height: 58px;
  }

  .metric-strip,
  .import-actions,
  .quiz-controls {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .question-card-header,
  .user-card {
    align-items: stretch;
    flex-direction: column;
  }

  .card-actions {
    width: 100%;
  }

  .icon-button {
    flex: 1;
  }
}
