:root {
  --fundo: #f6f4ef;
  --superficie: #ffffff;
  --texto: #1f2328;
  --suave: #5c636b;
  --borda: #e2ddd2;
  --marca: #c2410c;
  --marca-escura: #9a3412;
  --marca-fundo: #fff1e8;
  --ok: #15803d;
  --erro: #b91c1c;
  --raio: 12px;
  --sombra: 0 1px 2px rgba(31, 35, 40, .06), 0 4px 16px rgba(31, 35, 40, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #15130f;
    --superficie: #1e1b16;
    --texto: #f1ede4;
    --suave: #a9a396;
    --borda: #353026;
    --marca: #fb923c;
    --marca-escura: #fdba74;
    --marca-fundo: #2a1a0e;
    --ok: #4ade80;
    --erro: #f87171;
    --sombra: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--marca); }

.carregando { text-align: center; color: var(--suave); padding: 4rem 1rem; }

/* ---------- Cabeçalho ---------- */
.topo {
  background: var(--superficie);
  border-bottom: 1px solid var(--borda);
}
.topo-in {
  max-width: 980px;
  margin: 0 auto;
  padding: .75rem 16px;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.logo { font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; text-decoration: none; color: var(--texto); }
.logo span { color: var(--marca); }
.menu { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.menu a {
  text-decoration: none;
  color: var(--suave);
  padding: .4rem .75rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: .95rem;
}
.menu a:hover { background: var(--marca-fundo); color: var(--marca-escura); }
.menu a.ativo { background: var(--marca-fundo); color: var(--marca-escura); }
.usuario { display: flex; align-items: center; gap: .6rem; font-size: .9rem; color: var(--suave); }

/* ---------- Conteúdo ---------- */
main { max-width: 980px; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.titulo-pagina { margin-bottom: 1.25rem; }
.titulo-pagina p { color: var(--suave); margin: 0; }

.grade { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: 1.5rem; }

.cartao {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--sombra);
}
.cartao + .cartao { margin-top: 1rem; }
.grade .cartao + .cartao { margin-top: 0; }
.rotulo { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--suave); font-weight: 700; margin-bottom: .35rem; }
.numero { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.numero small { font-size: .95rem; font-weight: 600; color: var(--suave); }

.medidor { height: 8px; background: var(--borda); border-radius: 99px; overflow: hidden; margin-top: .6rem; }
.medidor > div { height: 100%; background: var(--marca); border-radius: 99px; }
.medidor.cheio > div { background: var(--erro); }

.selo {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  padding: .15rem .55rem;
  border-radius: 99px;
  background: var(--marca-fundo);
  color: var(--marca-escura);
}
.selo.cinza { background: var(--borda); color: var(--suave); }

.ferramentas { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.ferramentas li {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .7rem .9rem;
  border: 1px dashed var(--borda);
  border-radius: 10px;
}

/* ---------- Formulários ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
input, select {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--borda);
  border-radius: 8px;
  background: var(--superficie);
  color: var(--texto);
  font: inherit;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--marca);
  outline-offset: 1px;
}
.campo { margin-bottom: .9rem; }
.dica { font-size: .82rem; color: var(--suave); margin-top: .25rem; }

button, .botao {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--marca);
  background: var(--marca);
  color: #fff;
  padding: .6rem 1.1rem;
  border-radius: 8px;
}
@media (prefers-color-scheme: dark) { button, .botao { color: #1a1007; } }
button:hover { filter: brightness(.95); }
button:disabled { opacity: .55; cursor: wait; }
button.sec { background: transparent; color: var(--marca-escura); border-color: var(--borda); }
button.sec:hover { background: var(--marca-fundo); }
button.perigo { background: transparent; color: var(--erro); border-color: var(--borda); }
button.pequeno { padding: .35rem .7rem; font-size: .85rem; }
.link { background: none; border: 0; padding: 0; color: var(--marca); text-decoration: underline; font-weight: 600; cursor: pointer; }

/* ---------- Tela de entrada ---------- */
.entrada { max-width: 420px; margin: 0 auto; padding: 2.5rem 16px; }
.entrada .marca { text-align: center; margin-bottom: 1.5rem; }
.entrada .marca .logo { font-size: 1.8rem; }
.entrada .marca p { color: var(--suave); margin-top: .35rem; }
.abas { display: flex; gap: .25rem; margin-bottom: 1rem; background: var(--borda); padding: .25rem; border-radius: 10px; }
.abas button { flex: 1; background: transparent; color: var(--suave); border: 0; padding: .5rem; }
.abas button.ativo { background: var(--superficie); color: var(--texto); box-shadow: var(--sombra); }
.entrada form button[type=submit] { width: 100%; margin-top: .25rem; }
.rodape-form { text-align: center; margin-top: 1rem; font-size: .9rem; }

/* ---------- Tabelas (admin) ---------- */
.rolagem { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .5rem; border-bottom: 1px solid var(--borda); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--suave); }
td input, td select { padding: .4rem .5rem; min-width: 90px; }
td input[type=checkbox] { width: auto; min-width: 0; }
.acoes { white-space: nowrap; }

.vazio { text-align: center; color: var(--suave); padding: 2rem 1rem; border: 1px dashed var(--borda); border-radius: var(--raio); }

/* ---------- Aviso (toast) ---------- */
.aviso {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  max-width: min(92vw, 520px);
  background: var(--texto); color: var(--fundo);
  padding: .7rem 1.1rem; border-radius: 10px; font-weight: 600; font-size: .95rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 50;
}
.aviso.erro { background: var(--erro); color: #fff; }
.aviso[hidden] { display: none; }

.msg { padding: .7rem .9rem; border-radius: 10px; margin-bottom: 1rem; font-size: .92rem; }
.msg.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.msg.erro { background: color-mix(in srgb, var(--erro) 14%, transparent); color: var(--erro); }

@media (max-width: 560px) {
  .usuario span { display: none; }
  .numero { font-size: 1.45rem; }
}
