:root {
  --fundo: #F4F6F4;
  --cartao: #FFFFFF;
  --borda: #E2E7E3;
  --linha: #EEF1EF;
  --texto: #17211B;
  --suave: #56615A;
  --medio: #3D4842;
  --verde: #2E6B3A;
  --verde-escuro: #1F4D29;
  --azul: #2A78D6;
  --aviso-fundo: #FFF4E5;
  --aviso-borda: #F3D3A6;
  --aviso-texto: #6B3A00;
  --aviso-forte: #8A4B00;
  --info-fundo: #EAF1FB;
  --info-texto: #1F5FAF;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fundo); color: var(--texto); font-family: Inter, system-ui, -apple-system, sans-serif; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--verde); }

.tela { max-width: 560px; margin: 0 auto; padding: 20px 16px calc(96px + env(safe-area-inset-bottom)) 16px; display: flex; flex-direction: column; gap: 12px; }
.sem-menu { padding-bottom: 32px; }

.topo { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.topo-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rotulo-app { font-size: 12px; font-weight: 500; color: var(--suave); }
.atualizado { font-size: 12px; color: var(--suave); padding-top: 2px; text-align: right; }
.atualizado.velho { color: var(--aviso-forte); font-weight: 600; }
h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.sub { font-size: 13px; color: var(--suave); }

.seletor { position: relative; display: inline-flex; align-items: center; }
.seletor select { appearance: none; -webkit-appearance: none; min-height: 44px; padding: 0 38px 0 14px; border: 1px solid #D5DDD7; border-radius: 22px; background: var(--cartao); font-size: 15px; font-weight: 600; max-width: 100%; }
.seletor svg { position: absolute; right: 14px; width: 16px; height: 16px; pointer-events: none; }

.aviso { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--aviso-fundo); border: 1px solid var(--aviso-borda); }
.aviso svg { flex: 0 0 auto; width: 20px; height: 20px; stroke: var(--aviso-forte); margin-top: 1px; }
.aviso-titulo { font-size: 14px; font-weight: 600; color: var(--aviso-texto); }
.aviso-texto { font-size: 13px; line-height: 1.4; color: var(--aviso-texto); }

.grade-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grade-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.cartao-lista { background: var(--cartao); border: 1px solid var(--borda); border-radius: 14px; display: flex; flex-direction: column; }
.metrica-rotulo { font-size: 12px; font-weight: 500; color: var(--suave); }
.metrica-valor { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.metrica-valor small { font-size: 15px; font-weight: 500; color: var(--suave); }
.metrica-valor.vazio { color: #8A948D; }
.metrica-nota { font-size: 12px; color: var(--suave); }
.metrica-nota.alerta { font-weight: 600; color: var(--aviso-forte); }
.resumo-valor { font-size: 20px; font-weight: 700; }

.cabeca { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cabeca-titulo { font-size: 14px; font-weight: 600; }
.cabeca-extra { font-size: 12px; color: var(--suave); }
.linha-dupla { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.linha-dupla span:last-child { color: var(--suave); text-align: right; }

.selo-alerta { flex: 0 0 auto; padding: 3px 10px; border-radius: 12px; background: var(--aviso-fundo); border: 1px solid var(--aviso-borda); color: var(--aviso-texto); font-size: 12px; font-weight: 600; }
.periodos-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 4px; }
.graf-caixa { position: relative; padding-top: 30px; }
.graf { width: 100%; display: block; touch-action: pan-y; }
.graf-grade { stroke: var(--linha); stroke-width: 1; }
.graf-base { stroke: #C9D2CC; stroke-width: 1; }
.graf-rotulo { fill: var(--suave); font-size: 11px; font-family: inherit; }
.graf-faixa { fill: #2E6B3A; fill-opacity: 0.09; }
.graf-faixa-txt { fill: var(--verde); font-size: 11px; font-weight: 600; font-family: inherit; }
.graf-limite { stroke: var(--aviso-forte); stroke-width: 1; stroke-dasharray: 4 3; }
.graf-linha { fill: none; stroke: var(--azul); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.graf-ponto { fill: var(--azul); stroke: var(--cartao); stroke-width: 2; }
.graf-cursor { stroke: var(--medio); stroke-width: 1; stroke-dasharray: 3 3; }
.graf-ponto-ativo { fill: var(--azul); stroke: var(--cartao); stroke-width: 2; }
.graf-dica { position: absolute; top: 0; left: 0; padding: 4px 10px; border-radius: 8px; background: var(--texto); color: #FFFFFF; font-size: 13px; font-weight: 600; white-space: nowrap; pointer-events: none; }
.graf-dica[hidden] { display: none; }

.secao { font-size: 12px; font-weight: 600; color: var(--suave); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--linha); }
.item:last-child { border-bottom: 0; }
.item-col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-nome { font-size: 15px; font-weight: 600; }
.item-meta { font-size: 12px; color: var(--suave); }
.item-dose { font-size: 14px; color: var(--medio); text-align: right; white-space: nowrap; }

.periodos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; background: #E6EBE7; border-radius: 12px; }
.periodos button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--medio); font-size: 13px; font-weight: 500; cursor: pointer; }
.periodos button[aria-pressed="true"] { background: var(--cartao); color: var(--texto); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08); }

.botao { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 18px; border: 0; border-radius: 24px; background: var(--verde); color: #FFFFFF; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; }
.botao:hover { background: var(--verde-escuro); }
.botao[disabled] { opacity: 0.6; cursor: default; }
.botao-claro { background: var(--cartao); color: var(--texto); border: 1px solid #D5DDD7; }
.botao-claro:hover { background: #EEF1EF; }

.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; gap: 20px; }
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo label { font-size: 13px; font-weight: 600; color: var(--medio); }
.campo input { min-height: 48px; padding: 0 14px; border: 1px solid #C9D2CC; border-radius: 12px; background: var(--cartao); font-size: 16px; }
.campo input:focus, .seletor select:focus, .botao:focus-visible, .periodos button:focus-visible, .menu a:focus-visible { outline: 3px solid #9CC7A5; outline-offset: 2px; }
.erro { font-size: 14px; color: #A12A1F; min-height: 20px; }

.vazio-msg { padding: 20px 14px; text-align: center; font-size: 14px; color: var(--suave); }
.carregando { padding: 40px 0; text-align: center; font-size: 14px; color: var(--suave); }

.menu { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--cartao); border-top: 1px solid var(--borda); padding: 6px 4px calc(10px + env(safe-area-inset-bottom)) 4px; }
.menu[hidden] { display: none; }
.menu a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; text-decoration: none; color: var(--suave); font-size: 11px; font-weight: 500; }
.menu a[aria-current="page"] { color: var(--verde); font-weight: 600; }
.menu svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icone { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
