:root {
  --bg: #f5f5f7; --card: #fff; --tx: #18181b; --mut: #6b6b75; --lin: #e4e4e9;
  --rojo: #ED1C24; --critica: #d4111a; --aviso: #c26a00; --info: #6b6b75; --ok: #0f8a5f;
  --redmach: #ED1C24; --gi: #0A1D3F; --zenkai: #e8890c; --personal: #5b5bd6;
  --radio: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111114; --card: #1c1c21; --tx: #ececf1; --mut: #9b9ba6; --lin: #2c2c34; --gi: #6f8fd1; --personal: #9d9df0; --aviso: #f0a33a; --critica: #ff5a60; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--tx); font: 15px/1.45 Montserrat, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.cargando { text-align: center; color: var(--mut); padding: 40vh 0 0; }

/* Encabezado + navegación inferior */
header { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 3px solid var(--rojo); padding: calc(env(safe-area-inset-top) + 12px) 16px 10px; }
header h1 { margin: 0; font-size: 18px; }
header p { margin: 2px 0 0; color: var(--mut); font-size: 13px; }
.filtros { display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; scrollbar-width: none; }
.filtros button { flex: none; border: 1px solid var(--lin); background: var(--bg); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.filtros button.on { background: var(--tx); color: var(--bg); border-color: var(--tx); }
main { padding: 12px 16px calc(env(safe-area-inset-bottom) + 84px); max-width: 760px; margin: 0 auto; }
nav.abajo { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: var(--card); border-top: 1px solid var(--lin); padding-bottom: env(safe-area-inset-bottom); }
nav.abajo a { flex: 1; text-align: center; padding: 10px 0 8px; font-size: 12px; text-decoration: none; color: var(--mut); }
nav.abajo a b { display: block; font-size: 20px; line-height: 1.1; }
@media (max-width: 380px) { nav.abajo a { font-size: 11px; } }
nav.abajo a.on { color: var(--rojo); font-weight: 600; }

/* Tarjetas y avisos */
.seccion { margin: 16px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--mut); font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--lin); border-radius: var(--radio); padding: 14px; margin-bottom: 10px; }
.aviso { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--lin); border-left: 4px solid var(--info); border-radius: var(--radio); padding: 12px; margin-bottom: 8px; }
.aviso.critica { border-left-color: var(--critica); }
.aviso.aviso-sev { border-left-color: var(--aviso); }
.aviso .cuerpo { flex: 1; min-width: 0; }
.aviso .t { font-weight: 600; overflow-wrap: anywhere; }
.aviso .d { color: var(--mut); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.aviso .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--mut); }
.aviso .acciones { display: flex; flex-direction: column; gap: 6px; }
.chip { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 4px; padding: 1px 6px; color: #fff; background: var(--redmach); }
.chip.G\&I, .chip[data-e="G&I"] { background: var(--gi); }
.chip[data-e="Zenkai"] { background: var(--zenkai); }
.chip[data-e="Personal"] { background: var(--personal); }
.vence { font-weight: 600; }
.vence.rojo { color: var(--critica); }
.vacio { color: var(--mut); text-align: center; padding: 28px 8px; }

/* Resumen de arriba */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--card); border: 1px solid var(--lin); border-radius: var(--radio); padding: 10px; text-align: center; }
.kpi b { display: block; font-size: 24px; }
.kpi span { font-size: 12px; color: var(--mut); }
.kpi.rojo b { color: var(--critica); }

/* Botones y formularios */
.btn { border: 1px solid var(--lin); background: var(--card); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-size: 14px; }
.btn.chico { padding: 4px 8px; font-size: 12px; }
.btn.prim { background: var(--rojo); color: #fff; border-color: var(--rojo); font-weight: 600; }
.btn:disabled { opacity: .5; }
form.f { display: grid; gap: 10px; }
form.f label { display: grid; gap: 4px; font-size: 13px; color: var(--mut); }
form.f input, form.f select, form.f textarea { width: 100%; border: 1px solid var(--lin); background: var(--bg); border-radius: 10px; padding: 10px; font-size: 16px; color: var(--tx); }
.fila2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.error { color: var(--critica); font-size: 14px; }
.nota { color: var(--mut); font-size: 13px; }
details.card > summary { cursor: pointer; font-weight: 600; }
details.card[open] > summary { margin-bottom: 10px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t td, table.t th { padding: 6px 4px; border-top: 1px solid var(--lin); text-align: left; vertical-align: top; }
table.t th { color: var(--mut); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; white-space: nowrap; }
.pagada { color: var(--mut); text-decoration: line-through; }
.fuente { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--lin); font-size: 14px; }
.fuente:first-child { border-top: 0; }
.ok { color: var(--ok); }
.copiar { display: flex; gap: 6px; }
.copiar input { flex: 1; min-width: 0; border: 1px solid var(--lin); background: var(--bg); color: var(--tx); border-radius: 10px; padding: 8px 10px; font-size: 13px; }

/* Login */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { text-align: center; }
.login .logo { display: block; width: 64px; height: 64px; margin: 0 auto 8px; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 76px); transform: translateX(-50%); background: var(--tx); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 14px; z-index: 10; max-width: calc(100% - 32px); }
form.f label.check { display: flex; gap: 8px; align-items: center; color: var(--tx); font-size: 14px; }
form.f label.check input { width: auto; }
