:root {
  --primaria: #08575B;
  --primaria-escura: #053F42;
  --destaque: #689898;
  --destaque-claro: #E6F0F0;
  --cinza: #989898;
  --texto: #1F2A2C;
  --texto-suave: #5E6B6E;
  --fundo: #F4F7F7;
  --cartao: #FFFFFF;
  --borda: #DCE4E4;
  --perigo: #C0392B;
  --sucesso: #1D8A4E;
  --alerta: #D98B18;
  --raio: 12px;
  --sombra: 0 1px 2px rgba(8, 87, 91, .06), 0 4px 14px rgba(8, 87, 91, .06);
  --fonte: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--fonte); font-size: 15px; line-height: 1.45; color: var(--texto); background: var(--fundo);
  -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
a { color: var(--primaria); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.12rem; } h3 { font-size: 1rem; }
[hidden] { display: none !important; }

/* topo e menu */
.topo {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: #fff; border-bottom: 1px solid var(--borda);
}
.topo-logo img { height: 34px; display: block; }
.sino { position: relative; color: var(--primaria); display: inline-flex; padding: 6px; }
.sino-n { position: absolute; top: 0; right: 0; background: var(--perigo); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 5px; }
.app { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
.menu {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: #fff; border-top: 1px solid var(--borda);
  padding-bottom: env(safe-area-inset-bottom);
}
.menu a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; text-decoration: none;
  color: var(--texto-suave); font-size: 11px; font-weight: 600;
}
.menu a svg { width: 22px; height: 22px; }
.menu a.ativo { color: var(--primaria); }

/* blocos */
.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); padding: 14px; box-shadow: var(--sombra); margin-bottom: 12px; }
.cabecalho { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.cabecalho h1 { margin: 0; }
.suave { color: var(--texto-suave); }
.pequeno { font-size: 12.5px; }
.linha { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.linha.entre { justify-content: space-between; }
.grade2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grade3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 420px) { .grade2.quebra { grid-template-columns: 1fr; } }
.vazio { text-align: center; color: var(--texto-suave); padding: 28px 8px; }
.carregando { text-align: center; color: var(--texto-suave); padding: 40px 0; }
hr { border: 0; border-top: 1px solid var(--borda); margin: 14px 0; }

/* formulários */
label { display: block; font-size: 13px; font-weight: 600; color: var(--texto-suave); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--texto); background: #fff; border: 1px solid var(--borda); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--destaque); outline-offset: 1px; border-color: var(--destaque); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--texto); }
.opcoes { display: flex; flex-wrap: wrap; gap: 6px; }
.opcoes button { min-height: 38px; }
.chip-sel { border: 1px solid var(--borda); background: #fff; color: var(--texto); border-radius: 20px; padding: 6px 12px; font: inherit; font-size: 13.5px; cursor: pointer; }
.chip-sel.on { background: var(--primaria); border-color: var(--primaria); color: #fff; }

/* botões */
.bt {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14.5px;
  border-radius: 10px; padding: 10px 16px; min-height: 44px; border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background: var(--primaria); color: #fff;
}
.bt:hover { background: var(--primaria-escura); }
.bt:disabled { opacity: .55; cursor: not-allowed; }
.bt.sec { background: #fff; color: var(--primaria); border-color: var(--primaria); }
.bt.sec:hover { background: var(--destaque-claro); }
.bt.leve { background: var(--destaque-claro); color: var(--primaria); }
.bt.perigo { background: var(--perigo); }
.bt.sucesso { background: var(--sucesso); }
.bt.peq { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.bt.cheio { width: 100%; }
.bt.grande { min-height: 58px; font-size: 17px; border-radius: 14px; }

/* abas */
.abas { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.abas::-webkit-scrollbar { display: none; }
.abas a {
  flex: none; padding: 7px 12px; border-radius: 20px; background: #fff; border: 1px solid var(--borda); text-decoration: none;
  color: var(--texto-suave); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.abas a.ativo { background: var(--primaria); color: #fff; border-color: var(--primaria); }
.abas .n { opacity: .8; font-weight: 500; }

/* listas */
.lista { display: flex; flex-direction: column; gap: 8px; }
.item { display: block; background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); padding: 12px 14px; text-decoration: none; color: inherit; }
.item:hover { border-color: var(--destaque); }
.item .titulo { font-weight: 600; }
.selo { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 10px; color: #fff; background: var(--cinza); white-space: nowrap; }
.selo.contorno { background: transparent; color: var(--texto-suave); border: 1px solid var(--borda); }
.selo.alerta { background: var(--alerta); }
.selo.perigo { background: var(--perigo); }
.selo.ok { background: var(--sucesso); }

/* tabela */
.tabela-wrap { overflow-x: auto; border: 1px solid var(--borda); border-radius: var(--raio); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--borda); vertical-align: top; }
th { background: var(--destaque-claro); color: var(--primaria); font-weight: 700; font-size: 12.5px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* números */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 12px; }
.kpi { background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); padding: 12px; }
.kpi .v { font-size: 1.45rem; font-weight: 700; color: var(--primaria); font-variant-numeric: tabular-nums; }
.kpi .r { font-size: 12px; color: var(--texto-suave); font-weight: 600; }
.barra { height: 8px; background: var(--destaque-claro); border-radius: 6px; overflow: hidden; position: relative; }
.barra > span { display: block; height: 100%; background: var(--primaria); border-radius: 6px; }
.barra > i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--alerta); }

/* histórico */
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { padding: 10px 0; border-bottom: 1px solid var(--borda); white-space: pre-wrap; }
.hist li:last-child { border-bottom: 0; }
.hist .quando { font-size: 12px; color: var(--texto-suave); }
.hist li.auto { color: var(--texto-suave); font-size: 13px; }

/* login */
.login { max-width: 400px; margin: 6vh auto 0; }
.login .logo { display: block; margin: 0 auto 18px; max-width: 240px; width: 70%; }
.login .cartao { padding: 20px; }

/* toast e modal */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--texto); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px);
  transition: .2s; pointer-events: none; z-index: 60; text-align: center;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.erro { background: var(--perigo); }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(15, 30, 32, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal .caixa {
  background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) { .modal { align-items: center; } .modal .caixa { border-radius: 16px; } }

/* ação */
.obter { text-align: center; padding: 18px 14px; background: linear-gradient(135deg, var(--primaria), var(--primaria-escura)); color: #fff; border-radius: 16px; margin-bottom: 12px; }
.obter .bt { background: #fff; color: var(--primaria); }
.obter .bt:hover { background: var(--destaque-claro); }
.obter .contagem { font-size: 13px; opacity: .9; margin-top: 8px; }
.regra { border: 1px solid var(--borda); border-left: 4px solid var(--destaque); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.grafico svg { width: 100%; height: auto; display: block; }
.legenda { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12.5px; margin-top: 6px; }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.dica { position: absolute; pointer-events: none; background: var(--texto); color: #fff; font-size: 12px; padding: 6px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -110%); }
.aviso { background: #FFF6E5; border: 1px solid #F2D49B; color: #7A5410; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 12px; }
.aviso.perigo { background: #FDECEA; border-color: #F3B8B1; color: #8E2A1F; }
.aviso.ok { background: #E8F5EE; border-color: #A9D8BD; color: #155F37; }
code { background: var(--destaque-claro); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; word-break: break-all; }
.grade2 > *, .grade3 > * { min-width: 0; }
.regra .linha.entre { flex-wrap: nowrap; }
.regra .linha.entre > input { min-width: 0; }
.regra .linha.entre .bt.peq { padding: 6px 9px; }
details > summary { cursor: pointer; }
