/* =====================================================================
   Estilos comuns — cores, tipografia, botões, formulários, tabelas
   ===================================================================== */
:root {
  --azul-900: #0b1f3a;
  --azul-800: #12305a;
  --azul-700: #1a4178;
  --azul-600: #23539a;
  --azul-100: #e6edf7;
  --azul-50: #f2f6fc;
  --fundo: #f4f6fa;
  --superficie: #ffffff;
  --borda: #dbe2ec;
  --texto: #1b2433;
  --texto-suave: #5b6779;
  --verde: #1e8a52;
  --verde-claro: #e3f4ea;
  --vermelho: #c62828;
  --vermelho-claro: #fbe7e7;
  --ambar: #b7791f;
  --ambar-claro: #fff4d6;
  --laranja: #c75b12;
  --roxo: #6b3fa0;
  --vinho: #8e2445;
  --raio: 12px;
  --raio-p: 8px;
  --sombra: 0 1px 2px rgba(16, 32, 64, .06), 0 4px 14px rgba(16, 32, 64, .06);
  --sombra-forte: 0 10px 40px rgba(11, 31, 58, .18);
  --fonte: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--fonte); color: var(--texto); background: var(--fundo);
  font-size: 15px; line-height: 1.45;
}
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; color: var(--azul-900); }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
a { color: var(--azul-600); }
small, .suave { color: var(--texto-suave); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.oculto { display: none !important; }

.icone { width: 1.2em; height: 1.2em; flex-shrink: 0; vertical-align: -0.2em; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  border: 1px solid transparent; border-radius: var(--raio-p); padding: .6em 1.1em;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--azul-800); color: #fff; transition: background .15s, transform .05s, box-shadow .15s;
  min-height: 42px;
}
.btn:hover { background: var(--azul-700); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #8fb3ec; outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sec { background: var(--superficie); color: var(--azul-800); border-color: var(--borda); }
.btn-sec:hover { background: var(--azul-50); }
.btn-verde { background: var(--verde); } .btn-verde:hover { background: #18774a; }
.btn-vermelho { background: var(--vermelho); } .btn-vermelho:hover { background: #a82020; }
.btn-texto { background: none; color: var(--azul-600); padding: .4em .6em; min-height: 0; }
.btn-texto:hover { background: var(--azul-50); }
.btn-p { padding: .35em .7em; min-height: 32px; font-size: .88rem; }

/* ---------- Formulários ---------- */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3em; color: var(--azul-900); }
input, select, textarea {
  width: 100%; font: inherit; padding: .55em .7em; border: 1px solid var(--borda);
  border-radius: var(--raio-p); background: #fff; color: var(--texto); min-height: 42px;
}
textarea { min-height: 80px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--azul-700); transform: scale(1.15); }
.campo { margin-bottom: .9rem; }
.campo .ajuda { font-size: .8rem; color: var(--texto-suave); margin-top: .25em; }
.check { display: flex; gap: .6em; align-items: center; font-weight: 500; }
.grade { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ---------- Cartões e etiquetas ---------- */
.cartao { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra); padding: 1.2rem; }
.etiqueta {
  display: inline-flex; align-items: center; gap: .3em; padding: .15em .6em; border-radius: 999px;
  font-size: .78rem; font-weight: 700; background: var(--azul-100); color: var(--azul-800); white-space: nowrap;
}
.etiqueta.verde { background: var(--verde-claro); color: var(--verde); }
.etiqueta.vermelho { background: var(--vermelho-claro); color: var(--vermelho); }
.etiqueta.ambar { background: var(--ambar-claro); color: #8a5a0b; }
.etiqueta.cinza { background: #eceff3; color: #555f6d; }

.aviso { border-radius: var(--raio-p); padding: .8rem 1rem; display: flex; gap: .7rem; align-items: flex-start; margin-bottom: 1rem; }
.aviso .icone { margin-top: .1em; }
.aviso.info { background: var(--azul-50); border: 1px solid #c9d8ee; color: var(--azul-900); }
.aviso.ambar { background: var(--ambar-claro); border: 1px solid #f0d58a; color: #6b4a07; }
.aviso.vermelho { background: var(--vermelho-claro); border: 1px solid #f2b8b8; color: #7d1717; }
.aviso.verde { background: var(--verde-claro); border: 1px solid #b4dfc5; color: #13532f; }

/* Faixa permanente de protótipo */
.faixa-prototipo {
  background: repeating-linear-gradient(45deg, #ffe08a, #ffe08a 12px, #ffd45c 12px, #ffd45c 24px);
  color: #4d3600; font-weight: 700; font-size: .82rem; text-align: center; padding: .35rem .8rem;
  letter-spacing: .01em;
}

/* ---------- Tabelas ---------- */
.tabela-rolagem { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--borda); border-radius: var(--raio-p); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .55rem .7rem; border-bottom: 1px solid #edf1f6; text-align: left; vertical-align: top; }
th { background: var(--azul-50); color: var(--azul-900); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
tbody tr:hover { background: #fafcff; }
tr.anulada td { color: #98a1ad; text-decoration: line-through; }
tr.linha-folga td { background: #f8f9fb; color: var(--texto-suave); }
tr.linha-alerta td:first-child { box-shadow: inset 3px 0 0 var(--vermelho); }

/* ---------- Janela modal ---------- */
.modal-fundo { position: fixed; inset: 0; background: rgba(11, 31, 58, .55); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: var(--raio); box-shadow: var(--sombra-forte); width: 100%; max-width: 640px; }
.modal.largo { max-width: 960px; }
.modal-topo { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem; border-bottom: 1px solid var(--borda); }
.modal-topo h2 { margin: 0; }
.modal-corpo { padding: 1.2rem; }
.modal-rodape { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.2rem; border-top: 1px solid var(--borda); flex-wrap: wrap; }

/* ---------- Aviso rápido (toast) ---------- */
.toast-area { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 460px); }
.toast { background: var(--azul-900); color: #fff; padding: .8rem 1rem; border-radius: var(--raio-p); box-shadow: var(--sombra-forte); display: flex; gap: .6rem; align-items: center; animation: entrar .2s ease-out; }
.toast.verde { background: var(--verde); } .toast.vermelho { background: var(--vermelho); }
@keyframes entrar { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
body.admin { padding-top: env(safe-area-inset-top); }
