/* Design tokens e componentes compartilhados entre as telas (dashboard e
   reprovados). Mobile-first: estilos base valem pra telas pequenas, media
   queries min-width adicionam/ajustam pra telas maiores. */

:root {
  --bg: #f5f6f8;
  --fg: #1d1f24;
  --muted: #666;
  --muted-2: #999;
  --border: #e3e5e8;
  --card-bg: #fff;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .2);
  --radius: 10px;
  --radius-lg: 12px;
  --blue: #3b5bdb;
  --blue-bg: #eef1ff;
  --blue-bg-strong: #e7ecff;
  --green: #1e7a34;
  --green-bg: #e6f4ea;
  --green-bg-strong: #f0f9f2;
  --red: #c0392b;
  --red-bg: #fbeae8;
  --orange: #8a5a10;
  --orange-2: #c9821f;
  --orange-bg: #fdf0da;
  --revalidacao: #1c5cbd;
  --revalidacao-bg: #e7f0fe;
  --gray-bg: #f1f2f4;
  --font: -apple-system, "Segoe UI", Arial, sans-serif;
  --touch: 40px;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  margin: 0;
  padding: 16px;
  -webkit-text-size-adjust: 100%;
}

@media (min-width: 640px) {
  body { padding: 24px; }
}
@media (min-width: 1024px) {
  body { padding: 32px; }
}

h1 { font-size: 19px; margin: 0 0 4px; line-height: 1.3; }
h2 { font-size: 15px; margin: 0 0 10px; }
@media (min-width: 640px) { h1 { font-size: 21px; } }

a { color: var(--blue); }

.main-menu { margin-bottom: 18px; }
.main-menu-states {
  display: flex; gap: 4px; margin-bottom: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.main-menu-pill {
  display: inline-block; flex-shrink: 0; padding: 6px 16px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); text-decoration: none; white-space: nowrap; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card-bg);
}
.main-menu-pill:hover { color: var(--fg); }
.main-menu-pill.active { color: #fff; background: var(--blue); border-color: var(--blue); }
.main-menu-tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.main-menu-tab {
  display: inline-block; flex-shrink: 0; padding: 9px 12px; font-size: 13px; font-weight: 600;
  color: var(--muted); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.main-menu-tab:hover { color: var(--fg); }
.main-menu-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.main-menu-user {
  display: flex; align-items: center; gap: 8px; margin: 0 0 0 auto; padding-bottom: 6px; flex-shrink: 0;
}
.main-menu-username { font-size: 12px; color: var(--muted-2); white-space: nowrap; }
.main-menu-user button {
  font-size: 12px; padding: 5px 10px; min-height: auto;
}

.badge-state { background: var(--blue-bg); color: var(--blue); margin-left: 6px; vertical-align: middle; }

.subtitle { color: var(--muted); margin-bottom: 10px; font-size: 13px; }

.status-line { font-size: 12px; color: var(--muted-2); margin-bottom: 16px; }
.status-line.error { color: var(--red); }

/* ---- cards ---- */
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 20px; }
@media (min-width: 480px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .cards { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card .value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.card .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 2px; }
.card .desc { font-size: 11px; color: var(--muted-2); margin-top: 6px; line-height: 1.4; }

/* ---- tables ---- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--card-bg);
  -webkit-overflow-scrolling: touch;
}
table { border-collapse: collapse; width: 100%; background: var(--card-bg); }
th, td { padding: 9px 12px; text-align: center; border-bottom: 1px solid #eee; font-size: 13px; white-space: nowrap; }
th { background: #fafbfc; font-weight: 600; }
tfoot td { font-weight: 700; background: #fafbfc; }
td.left, th.left { text-align: left; }

/* Tabelas "responsivas em cards": em telas estreitas a tabela vira uma
   lista de cards (uma linha = um card, cada célula rotulada por
   data-label). Ative com a classe .table-cards-mobile no <table>. */
@media (max-width: 720px) {
  .table-cards-mobile.table-wrap { overflow-x: visible; box-shadow: none; background: none; }
  .table-cards-mobile thead { display: none; }
  .table-cards-mobile table { background: none; }
  .table-cards-mobile tbody { display: flex; flex-direction: column; gap: 10px; }
  .table-cards-mobile tr {
    display: block; background: var(--card-bg); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 12px 14px;
  }
  .table-cards-mobile td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    text-align: right; white-space: normal; border-bottom: 1px solid #f2f2f2;
    padding: 6px 0;
  }
  .table-cards-mobile td:last-child { border-bottom: none; }
  .table-cards-mobile td::before {
    content: attr(data-label); font-size: 11px; font-weight: 600; color: var(--muted);
    text-align: left; flex-shrink: 0;
  }
  .table-cards-mobile td.no-label::before { display: none; }
  .table-cards-mobile tfoot { display: block; }
  .table-cards-mobile tfoot tr { display: block; background: #fafbfc; }
}

/* ---- buttons / inputs ---- */
button, .btn {
  font: inherit; font-size: 13px; padding: 8px 12px; border-radius: 8px;
  border: 1px solid #d8dae0; background: #fafbfc; cursor: pointer; color: var(--fg);
  min-height: var(--touch);
}
button:hover, .btn:hover { background: #f1f2f4; }
button:disabled { opacity: .5; cursor: default; }
input[type=date], select {
  font: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid #d8dae0;
  border-radius: 8px; background: #fff; min-height: var(--touch);
}
label.checkbox { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }

/* ---- badges ---- */
.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; white-space: nowrap; font-weight: 600; display: inline-block; }
.badge-oficial { background: var(--green-bg); color: var(--green); }
.badge-revalidacao { background: var(--revalidacao-bg); color: var(--revalidacao); }
.badge-inferido { background: var(--orange-bg); color: var(--orange); }
.badge-sem_categoria { background: var(--gray-bg); color: #888; }
.badge-clickable { cursor: pointer; border: 1px solid transparent; }
.badge-revalidacao.badge-clickable { border-color: #a8c6f5; }
.badge-revalidacao.badge-clickable:hover { background: #d4e3fc; }
.badge-inferido.badge-clickable { border-color: #f0c674; }
.badge-inferido.badge-clickable:hover { background: #fbe4b8; }

/* ---- modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 20, 30, .45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
  padding: 0;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 20px; }
}
.modal-box {
  background: #fff; border-radius: 16px 16px 0 0; max-width: none; width: 100%;
  max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
@media (min-width: 640px) {
  .modal-box { border-radius: var(--radius-lg); max-width: 640px; max-height: 80vh; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid #eee; position: sticky; top: 0;
  background: #fff; border-radius: 16px 16px 0 0;
}
@media (min-width: 640px) { .modal-header { border-radius: var(--radius-lg) var(--radius-lg) 0 0; } }
.modal-header h2 { font-size: 15px; margin: 0; }
.modal-header button { border: none; background: transparent; font-size: 18px; padding: 4px 8px; min-height: auto; color: #888; }
.modal-header button:hover { color: var(--fg); background: transparent; }
.modal-body { padding: 16px 18px 22px; font-size: 13px; line-height: 1.6; }
.modal-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  color: var(--muted-2); font-size: 12px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid #eee;
}
.modal-meta strong { font-size: 14px; color: var(--fg); }
.pill { font-size: 11px; font-weight: 600; color: #555; background: var(--gray-bg); padding: 3px 10px; border-radius: 999px; white-space: nowrap; }

/* ---- misc ---- */
.legend { font-size: 12px; color: var(--muted-2); margin: -6px 0 16px; line-height: 1.5; }
.panel {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-top: 8px;
}
@media (min-width: 640px) { .panel { padding: 20px 24px; } }
.filter-chip { font-size: 12px; background: var(--blue-bg); color: var(--blue); padding: 4px 10px; border-radius: 999px; }
.empty-state { color: var(--muted-2); font-size: 13px; }
.spin { display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
