/* Solvit — painel administrativo.
   O sistema visual segue front/DESIGN.md: fundo escuro como modo primário,
   superfícies flutuantes com aresta superior iluminada, rosa da marca como
   única cor herói, números sempre em mono. Os tokens abaixo espelham
   front/constants/Colors.ts e front/constants/Tokens.ts.

   Tema: o bloco :root é o escuro. O claro aparece duas vezes de propósito —
   uma vez sob prefers-color-scheme (quando o usuário nunca escolheu) e uma vez
   sob [data-theme="light"] (quando escolheu). Custom properties não podem ser
   herdadas entre regras, então a duplicação é o preço de suportar os dois. */

:root {
  /* superfícies */
  --bg: #14100e;
  --surface: #1e1815;
  --surface-alt: #271f1b;
  --surface-sunk: #191411;

  /* marca e acentos */
  --brand: #f65c93;
  --brand-rgb: 246 92 147;
  --brand-text: #ff93b8;
  --brand-depth: #c23a76;
  --on-brand: #1a0410;
  --cyan: #33c9b0;
  --cyan-rgb: 51 201 176;
  --gold: #e9b84b;
  --gold-rgb: 233 184 75;

  /* texto */
  --text: #ecedee;
  --text-2: #9ba1a6;
  --text-muted: #767e85;
  --text-faint: #8a7a80;

  /* linhas */
  --border: #2e3235;
  --divider: #2a221e;
  --row-alt: rgb(255 255 255 / 2.5%);
  --lit: rgb(255 255 255 / 7%);

  /* estados */
  --success: #18b872;
  --success-rgb: 24 184 114;
  --error: #ff3830;
  --error-rgb: 255 56 48;

  /* profundidade */
  --shadow: 0 6px 12px rgb(0 0 0 / 30%);
  --shadow-lg: 0 18px 40px rgb(0 0 0 / 45%);
  --glow: 0 0 10px rgb(var(--brand-rgb) / 28%);
  --overlay: rgb(6 4 3 / 72%);
  --depth: rgb(0 0 0 / 45%);

  /* espaço, raio, tipo */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --r1: 4px;
  --r2: 8px;
  --r3: 12px;
  --r4: 16px;
  --r5: 24px;
  --r-full: 9999px;
  --fs1: 12px;
  --fs2: 14px;
  --fs3: 16px;
  --fs4: 20px;
  --fs5: 24px;
  --fs6: 32px;

  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "Space Mono", ui-monospace, sfmono-regular, menlo, monospace;

  --sidebar-w: 236px;

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fbf3f7;
    --surface: #fff;
    --surface-alt: #f4e7ee;
    --surface-sunk: #f7eef3;
    --brand: #e0407f;
    --brand-rgb: 224 64 127;
    --brand-text: #c42f6d;
    --brand-depth: #b12a62;
    --on-brand: #fff;
    --cyan: #0fa88e;
    --cyan-rgb: 15 168 142;
    --gold: #c7920f;
    --gold-rgb: 199 146 15;
    --text: #11181c;
    --text-2: #687076;
    --text-muted: #8a9199;
    --text-faint: #a08894;
    --border: #e5e6e8;
    --divider: #f0e4ea;
    --row-alt: rgb(88 40 63 / 3%);
    --lit: #fff;
    --shadow: 0 6px 14px rgb(88 40 63 / 10%);
    --shadow-lg: 0 20px 44px rgb(88 40 63 / 18%);
    --overlay: rgb(38 18 27 / 45%);
    --depth: rgb(88 40 63 / 22%);

    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #fbf3f7;
  --surface: #fff;
  --surface-alt: #f4e7ee;
  --surface-sunk: #f7eef3;
  --brand: #e0407f;
  --brand-rgb: 224 64 127;
  --brand-text: #c42f6d;
  --brand-depth: #b12a62;
  --on-brand: #fff;
  --cyan: #0fa88e;
  --cyan-rgb: 15 168 142;
  --gold: #c7920f;
  --gold-rgb: 199 146 15;
  --text: #11181c;
  --text-2: #687076;
  --text-muted: #8a9199;
  --text-faint: #a08894;
  --border: #e5e6e8;
  --divider: #f0e4ea;
  --row-alt: rgb(88 40 63 / 3%);
  --lit: #fff;
  --shadow: 0 6px 14px rgb(88 40 63 / 10%);
  --shadow-lg: 0 20px 44px rgb(88 40 63 / 18%);
  --overlay: rgb(38 18 27 / 45%);
  --depth: rgb(88 40 63 / 22%);

  color-scheme: light;
}

/* ---------- base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs2);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.025em;
}

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

a {
  color: var(--brand-text);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
  border-radius: var(--r1);
}

.icon {
  flex: none;
  display: block;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--s3);
  z-index: 90;
  padding: var(--s2) var(--s3);
  border-radius: var(--r2);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.skip-link:focus {
  left: var(--s3);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.row-wrap {
  flex-wrap: wrap;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.grow {
  flex: 1;
  min-width: 0;
}

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

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- estrutura ---------- */

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  padding: var(--s5) var(--s4);
  border-right: 1px solid var(--divider);
  background: var(--bg);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s2);
}

.brand-name {
  font-family: var(--font-display);
  font-size: var(--fs4);
  line-height: 1.1;
}

.brand-island {
  width: 48px;
  height: 48px;
  flex: none;
  object-fit: contain;
  transform: scale(1.3);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px var(--s3);
  border: 0;
  border-radius: var(--r3);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs2);
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  transition:
    background 0.15s,
    color 0.15s;
}

.nav-item:hover {
  background: var(--surface-alt);
  color: var(--text);
  text-decoration: none;
}

.nav-item[aria-current="page"] {
  background: rgb(var(--brand-rgb) / 12%);
  color: var(--brand-text);
}

.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: var(--r-full);
  background: var(--brand);
}

.nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs1);
  color: var(--brand-text);
}

.sidebar-foot {
  border-top: 1px solid var(--divider);
  padding-top: var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.session {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s2);
  min-width: 0;
}

.session-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  background: var(--surface-alt);
  color: var(--brand-text);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: var(--fs1);
  flex: none;
}

.session-email {
  font-size: var(--fs1);
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  min-width: 0;
  padding: var(--s5) var(--s6) var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s4);
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: var(--fs5);
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  animation: rise 0.28s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- superfícies ---------- */

.card {
  background: var(--surface);
  border-radius: var(--r4);
  border-top: 1px solid var(--lit);
  box-shadow: var(--shadow);
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.card--flush {
  padding: var(--s5) 0 0;
  gap: var(--s3);
  overflow: hidden;
}

.card--flush:not(:has(> .card-head)) {
  padding-top: 0;
}

.card--flush > .card-head,
.card--flush > .toolbar {
  padding: 0 var(--s5);
}

.card--flush > .toolbar:last-child:not(:empty) {
  padding-bottom: var(--s4);
}

.card--accent {
  border-top-color: var(--accent, var(--brand));
  border-top-width: 2px;
}

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

.section-title {
  font-family: var(--font-display);
  font-size: var(--fs3);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
}

/* ---------- números ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--s4);
}

.tile {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s4) var(--s4) var(--s5);
  background: var(--surface);
  border-radius: var(--r4);
  border-top: 1px solid var(--lit);
  box-shadow: var(--shadow);
  color: inherit;
  position: relative;
  overflow: hidden;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}

a.tile:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.tile-label {
  font-size: var(--fs1);
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.tile-value {
  font-family: var(--font-mono);
  font-size: var(--fs6);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.tile-sub {
  font-size: var(--fs1);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tile--brand .tile-value {
  color: var(--brand-text);
}

.tile--cyan .tile-value {
  color: var(--cyan);
}

.tile--gold .tile-value {
  color: var(--gold);
}

/* "warn" e "info" são apelidos de gold e cyan: as telas de conteúdo pedem esses
   nomes e o painel só tem uma paleta. */
.tile--warn .tile-value {
  color: var(--gold);
}

.tile--info .tile-value {
  color: var(--cyan);
}

.tile--success .tile-value {
  color: var(--success);
}

.tile--error .tile-value {
  color: var(--error);
}

.tile--cta {
  background: linear-gradient(
    160deg,
    rgb(var(--brand-rgb) / 10%),
    var(--surface) 62%
  );
}

.tile--cta .tile-sub {
  color: var(--brand-text);
}

.tile--glow {
  box-shadow: var(--shadow), var(--glow);
}

/* ---------- botões ---------- */

.btn {
  --btn-bg: var(--surface-alt);
  --btn-fg: var(--text);
  --btn-depth: var(--depth);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 10px var(--s4);
  border: 0;
  border-bottom: 4px solid var(--btn-depth);
  border-radius: var(--r3);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-display);
  font-size: var(--fs2);
  cursor: pointer;
  white-space: nowrap;
  transition:
    filter 0.15s,
    transform 0.06s;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn:active:not(:disabled) {
  border-bottom-width: 1px;
  margin-bottom: 3px;
  transform: translateY(3px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  --btn-bg: var(--brand);
  --btn-fg: var(--on-brand);
  --btn-depth: var(--brand-depth);

  box-shadow: var(--glow);
}

.btn-danger {
  --btn-bg: rgb(var(--error-rgb) / 14%);
  --btn-fg: var(--error);
  --btn-depth: rgb(var(--error-rgb) / 30%);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--text-muted);

  border-bottom-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  --btn-fg: var(--text);

  background: var(--surface-alt);
}

.btn-sm {
  padding: 6px var(--s3);
  font-size: var(--fs1);
  border-radius: var(--r2);
  border-bottom-width: 3px;
}

.btn-sm:active:not(:disabled) {
  margin-bottom: 2px;
  transform: translateY(2px);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--r3);
}

/* ---------- formulários ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > label,
.label {
  font-size: var(--fs1);
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r3);
  background: var(--surface-sunk);
  color: var(--text);
  font-size: var(--fs2);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgb(var(--brand-rgb) / 16%);
}

.select {
  appearance: none;
  padding-right: var(--s5);
  background-image: linear-gradient(
      45deg,
      transparent 50%,
      currentcolor 50%,
      currentcolor 58%,
      transparent 58%
    ),
    linear-gradient(
      -45deg,
      transparent 50%,
      currentcolor 50%,
      currentcolor 58%,
      transparent 58%
    );
  background-position:
    right 18px center,
    right 12px center;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-body);
  line-height: 1.6;
}

.hint {
  font-size: var(--fs1);
  color: var(--text-muted);
}

.field-error {
  font-size: var(--fs1);
  color: var(--error);
  display: flex;
  align-items: center;
  gap: 6px;
}

.search {
  position: relative;
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
}

.search .icon {
  position: absolute;
  left: var(--s3);
  color: var(--text-muted);
  pointer-events: none;
}

.search .input {
  padding-left: 42px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--s2);
  max-height: 280px;
  overflow-y: auto;
  padding: var(--s2);
  background: var(--surface-sunk);
  border-radius: var(--r3);
  border: 1px solid var(--border);
}

.check {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 8px 10px;
  border-radius: var(--r2);
  cursor: pointer;
  user-select: none;
  font-size: var(--fs2);
}

.check:hover {
  background: var(--surface-alt);
}

.check input {
  accent-color: var(--brand);
  width: 16px;
  height: 16px;
  flex: none;
  cursor: pointer;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border-radius: var(--r-full);
  background: rgb(var(--brand-rgb) / 14%);
  color: var(--brand-text);
  font-size: var(--fs1);
}

.chip-plain {
  background: var(--surface-alt);
  color: var(--text-2);
  padding: 4px 10px;
}

.chip button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  padding: 2px;
}

.chip button:hover {
  background: rgb(var(--brand-rgb) / 22%);
}

/* opções de resposta */
.option {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s3);
  border-radius: var(--r3);
  background: var(--surface-sunk);
  border: 1px solid var(--border);
}

.option[data-correct="true"] {
  border-color: rgb(var(--success-rgb) / 55%);
  background: rgb(var(--success-rgb) / 8%);
}

.option-mark {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 9px;
  font-family: var(--font-mono);
  font-size: var(--fs1);
  color: var(--text-muted);
}

.option-mark input {
  accent-color: var(--success);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.option-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.dropzone {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3);
  border: 1px dashed var(--border);
  border-radius: var(--r3);
  background: var(--surface-sunk);
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--fs2);
}

.dropzone:hover {
  border-color: var(--brand);
  color: var(--brand-text);
}

/* invisível mas ainda focável pelo teclado — display:none tiraria o campo da
   ordem de tabulação e o botão viraria só um alvo de mouse */
.dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.dropzone:focus-within {
  border-color: var(--brand);
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
}

.thumb {
  position: relative;
  align-self: flex-start;
  border-radius: var(--r3);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-sunk);
  padding: var(--s2);
}

.thumb img {
  max-width: 100%;
  max-height: 220px;
  display: block;
  border-radius: var(--r2);
}

/* ---------- tabela ---------- */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--r4);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs2);
}

thead th {
  text-align: left;
  padding: var(--s2) var(--s4);
  font-size: var(--fs1);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  background: var(--surface-sunk);
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
}

.card--flush thead th:first-child,
.card--flush tbody td:first-child {
  padding-left: var(--s5);
}

.card--flush thead th:last-child,
.card--flush tbody td:last-child {
  padding-right: var(--s5);
}

tbody td {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
  color: var(--text);
}

tbody tr:nth-child(even) td {
  background: var(--row-alt);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: var(--surface-alt);
}

td.num,
th.num {
  text-align: right;
}

td.mono {
  font-family: var(--font-mono);
  font-size: var(--fs1);
  color: var(--text-2);
}

td .row {
  gap: var(--s2);
}

.cell-strong {
  color: var(--text);
  font-weight: 600;
}

/* ---------- selos ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r2);
  font-size: var(--fs1);
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-alt);
  color: var(--text-2);
}

.badge--brand {
  background: rgb(var(--brand-rgb) / 14%);
  color: var(--brand-text);
}

.badge--cyan {
  background: rgb(var(--cyan-rgb) / 14%);
  color: var(--cyan);
}

.badge--gold,
.badge--warn {
  background: rgb(var(--gold-rgb) / 16%);
  color: var(--gold);
}

.badge--info {
  background: rgb(var(--cyan-rgb) / 14%);
  color: var(--cyan);
}

.badge--success {
  background: rgb(var(--success-rgb) / 14%);
  color: var(--success);
}

.badge--error {
  background: rgb(var(--error-rgb) / 14%);
  color: var(--error);
}

/* ---------- paginação ---------- */

.paginator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  padding: var(--s4) 0 var(--s2);
}

.paginator-status {
  font-family: var(--font-mono);
  font-size: var(--fs1);
  color: var(--text-muted);
}

/* ---------- estados ---------- */

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  padding: var(--s6) var(--s4);
  color: var(--text-muted);
  font-size: var(--fs2);
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--surface-alt);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}

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

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s3);
  padding: var(--s6) var(--s4);
}

.state-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r4);
  display: grid;
  place-items: center;
  background: var(--surface-alt);
  color: var(--text-muted);
}

.state--error .state-icon {
  background: rgb(var(--error-rgb) / 12%);
  color: var(--error);
}

.state h3 {
  font-size: var(--fs4);
}

.state p {
  color: var(--text-muted);
  max-width: 420px;
  font-size: var(--fs2);
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r3);
  font-size: var(--fs2);
  background: var(--surface-alt);
  color: var(--text-2);
}

.notice--warn {
  background: rgb(var(--gold-rgb) / 12%);
  color: var(--gold);
}

.notice--error {
  background: rgb(var(--error-rgb) / 12%);
  color: var(--error);
}

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--s5);
  overflow-y: auto;
  animation: fade 0.18s ease both;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  width: 100%;
  max-width: 560px;
  margin: auto;
  background: var(--surface);
  border-radius: var(--r5);
  border-top: 1px solid var(--lit);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--s6));
  animation: rise 0.22s ease both;
}

.modal--wide {
  max-width: 820px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s5) var(--s5) var(--s4);
  border-bottom: 1px solid var(--divider);
}

.modal-head h2 {
  font-size: var(--fs4);
}

.modal-body {
  padding: var(--s5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--s3);
  padding: var(--s4) var(--s5) var(--s5);
  border-top: 1px solid var(--divider);
  flex-wrap: wrap;
}

.modal-foot .spacer {
  margin-right: auto;
}

/* ---------- avisos flutuantes ---------- */

.toasts {
  position: fixed;
  right: var(--s5);
  bottom: var(--s5);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  max-width: min(380px, calc(100vw - var(--s6)));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r3);
  background: var(--surface);
  border-top: 1px solid var(--lit);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: var(--fs2);
  animation: slide-in 0.22s ease both;
}

.toast--success {
  color: var(--success);
}

.toast--error {
  color: var(--error);
}

.toast--info {
  color: var(--cyan);
}

.toast span {
  color: var(--text);
  flex: 1;
}

.toast button {
  border: 0;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
}

/* ---------- login ---------- */

.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s5);
}

.login-wrap::before {
  content: "";
  position: absolute;
  width: 620px;
  height: 620px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgb(var(--brand-rgb) / 18%),
    transparent 68%
  );
  filter: blur(12px);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--r5);
  border-top: 1px solid var(--lit);
  box-shadow: var(--shadow-lg), var(--glow);
  padding: var(--s6) var(--s5) var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  animation: rise 0.3s ease both;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s2);
}

.login-island-wrap {
  width: 164px;
  height: 164px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 65%,
    rgb(var(--brand-rgb) / 14%),
    transparent 69%
  );
}

.login-island {
  width: 164px;
  height: 164px;
  object-fit: contain;
  transform: scale(1.32);
}

.login-title {
  font-family: var(--font-display);
  font-size: var(--fs5);
}

.code-input {
  font-family: var(--font-mono);
  font-size: var(--fs5);
  letter-spacing: 0.42em;
  text-align: center;
  padding: var(--s3);
}

.login-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  font-size: var(--fs1);
  color: var(--text-muted);
}

.link-btn {
  border: 0;
  background: none;
  color: var(--brand-text);
  font-size: var(--fs1);
  cursor: pointer;
  padding: 2px;
}

.link-btn:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ---------- prévia de enunciado ---------- */

/* Contêiner isolado para o HTML já compilado da questão. O conteúdo é
   higienizado em views/questions.js antes de entrar aqui. */
.stmt {
  font-size: var(--fs2);
  line-height: 1.6;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.stmt img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r2);
  margin: var(--s2) 0;
}

.stmt p {
  margin: 0 0 var(--s2);
}

.stmt table {
  width: auto;
  font-size: var(--fs1);
}

.stmt td,
.stmt th {
  border: 1px solid var(--border);
  padding: 4px 8px;
}

.stmt-cell {
  max-width: 420px;
  max-height: 3.2em;
  overflow: hidden;
}

.stmt-cell img {
  max-height: 40px;
  margin: 0;
}

.stmt-preview {
  padding: var(--s3);
  border-radius: var(--r3);
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  max-height: 260px;
  overflow-y: auto;
}

/* ---------- jobs ---------- */

.job-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--s2) var(--s4);
  margin: 0;
}

.job-facts dt {
  color: var(--text-muted);
}

.job-facts dd {
  margin: 0;
}

.job-json {
  margin: 0;
  padding: var(--s3);
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  font-family: var(--font-mono);
  font-size: var(--fs1);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}

.job-log {
  max-height: 480px;
  overflow: auto;
  padding: var(--s2) var(--s3);
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  font-family: var(--font-mono);
  font-size: var(--fs1);
}

.job-log-line {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  padding: var(--s1) 0;
  color: var(--text-2);
}

.job-log-line--warn {
  color: var(--gold);
}

.job-log-line--error {
  color: var(--error);
}

.job-log-time {
  flex: none;
  color: var(--text-muted);
}

.job-log-msg {
  font-family: var(--font-body);
  font-size: var(--fs2);
  white-space: pre-wrap;
  word-break: break-word;
}

.logs-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s4);
}

.logs-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

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

.costs-name a {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
}

.costs-name .icon {
  color: var(--text-muted);
}

.costs-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs3);
  color: var(--text);
  margin-bottom: var(--s1);
}

.costs-error {
  font-size: var(--fs1);
  color: var(--error);
}

.costs-form-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: var(--s3);
}

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

/* ---------- responsivo ---------- */

@media (width <= 1020px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--s3);
    border-right: 0;
    border-bottom: 1px solid var(--divider);
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1;
    overflow: visible;
  }

  .nav-item[aria-current="page"]::before {
    inset: auto 9px 0;
    top: auto;
    width: auto;
    height: 3px;
  }

  .sidebar-foot {
    border-top: 0;
    padding-top: 0;
    flex-direction: row;
    align-items: center;
  }

  .main {
    padding: var(--s4);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
