/* SAX · panel web. Pensado primero para móvil; tema claro y oscuro. */
:root {
  --fondo: #f4f4f1;
  --tarjeta: #ffffff;
  --tarjeta-2: #f0efeb;
  --borde: #e3e2dc;
  --texto: #111214;
  --texto-2: #5b5a56;
  --texto-3: #8a8984;
  --acento: #2a78d6;
  --acento-suave: rgba(42, 120, 214, .12);
  --gasto: #e2602b;
  --ingreso: #12a06d;
  --peligro: #d23b3b;
  --sombra: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --radio: 16px;
  --barra: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo: #141814; --tarjeta: #1E241E; --tarjeta-2: #262D25; --borde: #2F382E;
    --texto: #ECEFE6; --texto-2: #A7B0A0; --texto-3: #8A9484;
    --acento: #B5C98A; --acento-suave: rgba(181, 201, 138, .14);
    --gasto: #E8925A; --ingreso: #8FCB6E; --peligro: #D9614C;
    --sombra: none; --radio: 6px; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fondo: #141814; --tarjeta: #1E241E; --tarjeta-2: #262D25; --borde: #2F382E;
  --texto: #ECEFE6; --texto-2: #A7B0A0; --texto-3: #8A9484;
  --acento: #B5C98A; --acento-suave: rgba(181, 201, 138, .14);
  --gasto: #E8925A; --ingreso: #8FCB6E; --peligro: #D9614C;
  --sombra: none; --radio: 6px; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- estructura */
.cabecera {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--fondo) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
}
.cabecera h1 { font-size: 22px; margin: 0; flex: 1; letter-spacing: -.01em; }
.boton-icono {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--borde);
  background: var(--tarjeta); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.boton-icono svg { width: 20px; height: 20px; }
main { padding: 8px 16px calc(var(--barra) + env(safe-area-inset-bottom) + 96px); max-width: 1100px; margin: 0 auto; }

.pestanas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(56px, 1fr);
  overflow-x: auto; scrollbar-width: none;
  padding: 6px 2px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--tarjeta) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--borde);
}
.pestanas a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; color: var(--texto-3); text-decoration: none; font-size: 10px; font-weight: 500;
  border-radius: 12px; -webkit-tap-highlight-color: transparent; min-width: 0;
}
.pestanas a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pestanas a svg { width: 22px; height: 22px; }
.tachado { text-decoration: line-through; color: var(--texto-3); }
.lista input[type="checkbox"], label.check input { width: 22px; height: 22px; accent-color: var(--acento); flex: none; }
label.check { display: flex !important; align-items: center; gap: 10px; }
.tarjeta.pin h2 svg { width: 18px; height: 18px; }
.tarjeta.pin .campo { width: 140px; letter-spacing: .2em; text-align: center; }
.pestanas a.activa { color: var(--acento); }
.marca { display: none; }

@media (min-width: 900px) {
  body { display: grid; grid-template-columns: 232px 1fr; }
  .pestanas {
    position: sticky; top: 0; height: 100vh; grid-template-columns: none; grid-auto-rows: min-content;
    grid-auto-flow: row; grid-auto-columns: auto; overflow-x: visible;
    align-content: start; gap: 4px; padding: 20px 12px; border-top: 0; border-right: 1px solid var(--borde);
    grid-row: 1 / span 2;
  }
  .pestanas a { flex-direction: row; gap: 12px; padding: 10px 12px; font-size: 15px; color: var(--texto-2); }
  .pestanas a.activa { background: var(--acento-suave); }
  .marca { display: flex; align-items: center; gap: 10px; padding: 4px 12px 18px; font-weight: 800; font-size: 20px; }
  .marca img { width: 32px; height: 32px; border-radius: 9px; }
  .contenido { grid-column: 2; min-width: 0; }
  main { padding: 8px 32px 110px; }
  .cabecera { padding: 18px 32px 12px; }
}

/* ---------- tarjetas y rejillas */
.tarjeta { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; box-shadow: var(--sombra); }
.tarjeta + .tarjeta, .bloque + .bloque { margin-top: 14px; }
.tarjeta h2 { font-size: 15px; margin: 0 0 12px; color: var(--texto-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tarjeta h2 .der { margin-left: auto; }
.rejilla { display: grid; gap: 14px; }
.rejilla > * { min-width: 0; }
.rejilla > .tarjeta + .tarjeta { margin-top: 0; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; box-shadow: var(--sombra); min-width: 0; }
.kpi .etiqueta { font-size: 13px; color: var(--texto-2); }
.kpi .valor { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; overflow-wrap: anywhere; }
.kpi .extra { font-size: 12px; color: var(--texto-3); margin-top: 2px; }
.kpi.grande { grid-column: 1 / -1; }
.kpi.grande .valor { font-size: 30px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(3, 1fr); } .kpi.grande { grid-column: auto; } }
@media (min-width: 1000px) {
  .kpis.cinco { grid-template-columns: repeat(5, 1fr); }
  .kpis.cinco .kpi.grande .valor { font-size: 22px; }
  .dos-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.gasto { color: var(--gasto); } .ingreso { color: var(--ingreso); } .negativo { color: var(--peligro); }
.saludo { margin: 4px 0 14px; color: var(--texto-2); }
.saludo strong { color: var(--texto); font-size: 20px; display: block; }

/* ---------- listas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--borde); }
.lista li:first-child { border-top: 0; }
.lista .princ { flex: 1; min-width: 0; }
.lista .titulo { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista .sub { font-size: 13px; color: var(--texto-3); }
.lista .importe { font-weight: 650; white-space: nowrap; }
.lista li.toca { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.lista li.toca:active { opacity: .6; }
.punto { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; font-size: 15px; font-weight: 700; }
.punto.gasto { background: color-mix(in srgb, var(--gasto) 14%, transparent); }
.punto.ingreso { background: color-mix(in srgb, var(--ingreso) 14%, transparent); }
.dia-cabecera { font-size: 13px; font-weight: 600; color: var(--texto-2); padding: 14px 0 4px; text-transform: capitalize; }
.vacio { color: var(--texto-3); text-align: center; padding: 18px 8px; font-size: 14px; }
.hora { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 54px; color: var(--acento); font-size: 14px; }

/* ---------- barras horizontales */
.barras { display: grid; gap: 12px; }
.barra-fila .cab { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 5px; }
.barra-fila .cab span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pista { position: relative; height: 10px; border-radius: 6px; background: var(--tarjeta-2); }
.relleno { height: 100%; border-radius: 6px; background: var(--gasto); min-width: 3px; }
.marca-media { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 1px; background: var(--texto); opacity: .55; }
.leyenda { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--texto-2); margin-top: 10px; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- gráficas SVG */
.grafica { width: 100%; height: auto; display: block; overflow: visible; }
.grafica text { fill: var(--texto-3); font-size: 11px; }
.grafica .rejilla-l { stroke: var(--borde); stroke-width: 1; }
.grafica .b-ing { fill: var(--ingreso); } .grafica .b-gas { fill: var(--gasto); }
.grafica .linea { fill: none; stroke: var(--acento); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.grafica .area { fill: var(--acento-suave); }
.grafica .punto-l { fill: var(--tarjeta); stroke: var(--acento); stroke-width: 2; }

/* ---------- controles */
.barra-herr { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.campo, select.campo, input.campo, textarea.campo {
  height: 42px; padding: 0 12px; border: 1px solid var(--borde); border-radius: 12px; background: var(--tarjeta);
  min-width: 0; -webkit-appearance: none; appearance: none;
}
select.campo { padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--texto-3) 50%), linear-gradient(135deg, var(--texto-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
textarea.campo { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
.campo:focus { outline: 2px solid var(--acento); outline-offset: 0; border-color: transparent; }
.crece { flex: 1 1 160px; }
.boton {
  height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--borde); background: var(--tarjeta);
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.boton.primario { background: var(--acento); border-color: var(--acento); color: #fff; }
.boton.peligro { color: var(--peligro); }
.boton.pequeno { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.boton:disabled { opacity: .5; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--borde); background: var(--tarjeta); font-size: 14px; cursor: pointer; text-transform: capitalize; }
.chip.activo { background: var(--texto); color: var(--fondo); border-color: var(--texto); }
.segmento { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--tarjeta-2); border-radius: 12px; padding: 3px; gap: 3px; }
.segmento button { height: 36px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; cursor: pointer; color: var(--texto-2); }
.segmento button.activo { background: var(--tarjeta); color: var(--texto); box-shadow: var(--sombra); }
.selector-mes { display: flex; align-items: center; gap: 6px; }
.selector-mes .mes { min-width: 130px; text-align: center; font-weight: 650; }
.flotante {
  position: fixed; right: 18px; bottom: calc(var(--barra) + env(safe-area-inset-bottom) + 18px); z-index: 15;
  width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--acento); color: #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); display: grid; place-items: center; cursor: pointer;
}
.flotante svg { width: 26px; height: 26px; }
@media (min-width: 900px) { .flotante { bottom: 28px; right: 32px; } }
.estado-idea { height: 32px; font-size: 13px; padding: 0 28px 0 10px; border-radius: 10px; background-position: calc(100% - 14px) 14px, calc(100% - 9px) 14px; }
.idea-texto { white-space: pre-wrap; overflow-wrap: anywhere; }
.etiq { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--tarjeta-2); color: var(--texto-2); text-transform: capitalize; }

/* ---------- formularios en hoja inferior */
dialog {
  border: 0; padding: 0; background: var(--tarjeta); color: var(--texto); width: 100%; max-width: 520px;
  border-radius: 22px 22px 0 0; margin: auto auto 0; max-height: 92vh;
}
dialog::backdrop { background: rgba(0,0,0,.45); }
@media (min-width: 640px) { dialog { border-radius: 22px; margin: auto; } }
.hoja { padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px); display: grid; gap: 12px; }
.hoja h3 { margin: 0; font-size: 18px; }
.hoja label { display: grid; gap: 6px; font-size: 13px; color: var(--texto-2); font-weight: 550; }
.hoja .campo { width: 100%; font-size: 16px; color: var(--texto); }
.hoja .acciones { display: flex; gap: 8px; margin-top: 4px; }
.hoja .acciones .boton { flex: 1; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- avisos */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--barra) + env(safe-area-inset-bottom) + 86px);
  background: var(--texto); color: var(--fondo); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100% - 32px); box-shadow: var(--sombra);
}
.nota { font-size: 14px; color: var(--texto-2); background: var(--tarjeta-2); border-radius: 12px; padding: 12px 14px; }
.cargando { color: var(--texto-3); padding: 30px 0; text-align: center; }

/* ---------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: 100%; max-width: 360px; display: grid; gap: 14px; text-align: center; }
.login img { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 4px; }
.login h1 { margin: 0; font-size: 26px; }
.login p { margin: 0; color: var(--texto-2); }
.login .campo { width: 100%; height: 50px; font-size: 17px; text-align: center; }
.login .boton { height: 50px; font-size: 17px; }
.login .aviso { color: var(--peligro); font-weight: 600; }

/* apartado GEO */
.geo-jornada { margin-bottom: 14px; }
.geo-mapa { display: block; width: 100%; max-width: 760px; margin: 10px auto; border-radius: 12px; border: 1px solid var(--borde); background: #fff; }
.geo-texto { white-space: pre-line; line-height: 1.5; margin: 8px 0 0; }
.geo-detalle h4 { margin: 14px 0 0; }
.geo-detalle .kpis { margin-bottom: 4px; }

/* ---------- Inicio táctico («parte diario») */
:root { --letra-tac: "Barlow Condensed", "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", sans-serif; }
.tac { display: grid; gap: 12px; }
.tac-letra, .tac h2, .tac-etq { font-family: var(--letra-tac); text-transform: uppercase; }
.tac-cab { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border-bottom: 2px solid var(--borde); padding-bottom: 12px; }
.tac-cab .linea1 { font-family: var(--letra-tac); font-size: 13px; font-weight: 600; letter-spacing: 3px; color: var(--acento); }
.tac-cab .linea2 { font-family: var(--letra-tac); font-size: 28px; font-weight: 700; letter-spacing: .5px; line-height: 1.1; }
.tac-cab .linea3 { font-family: var(--letra-tac); font-size: 15px; letter-spacing: 1px; color: var(--texto-2); }
.sello { font-family: var(--letra-tac); font-weight: 700; letter-spacing: 2px; font-size: 15px; padding: 4px 10px;
  border: 2px solid currentColor; transform: rotate(-4deg); white-space: nowrap; }
.nivel-0 { color: #8FCB6E; } .nivel-1 { color: #E0A93B; } .nivel-2 { color: #D9614C; } .nivel-3 { color: #5fa8c8; }
.nivel-x { color: var(--texto-3); }
.tac-caja { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; }
.tac-caja h2 { margin: 0 0 10px; font-size: 14px; font-weight: 600; letter-spacing: 3px; color: var(--texto-2);
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tac-caja h2 .der { letter-spacing: 1px; color: var(--texto); font-size: 16px; }
.tac-ambar { border-left: 6px solid #E0A93B; }
.tac-ambar h2 { color: #E0A93B; }
.tac-fila-op { display: grid; grid-template-columns: minmax(150px, 48%) 1fr; gap: 12px; align-items: stretch; }
.tac-dato { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; padding: 3px 0; }
.tac-dato b { font-weight: 600; }
.tac-barra { height: 10px; background: var(--borde); overflow: hidden; }
.tac-barra i { display: block; height: 100%; background: var(--acento); }
.tac-sub { font-size: 13px; color: var(--texto-2); margin-top: 6px; }
.tac-orden { display: flex; gap: 10px; font-size: 15px; line-height: 1.4; padding: 3px 0; }
.tac-orden b { font-family: var(--letra-tac); color: #E0A93B; font-size: 18px; line-height: 1.2; }
.tac-cuenta { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tac-cuenta .grande { font-family: var(--letra-tac); font-size: 52px; font-weight: 700; line-height: .9; color: #E0A93B; }
.tac-evento { display: flex; gap: 12px; align-items: baseline; font-size: 15px; padding: 3px 0; }
.tac-evento .cuando { font-family: var(--letra-tac); font-size: 17px; font-weight: 600; color: var(--acento);
  min-width: 96px; text-transform: uppercase; }
.tac-tarea { display: flex; gap: 12px; align-items: center; min-height: 40px; font-size: 15px; cursor: pointer; }
.tac-tarea input { width: 20px; height: 20px; accent-color: var(--acento); }
.tac-rapidos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tac-boton { min-height: 48px; border: 1px solid var(--acento); background: transparent; color: var(--acento);
  font-family: var(--letra-tac); font-size: 17px; font-weight: 700; letter-spacing: 1px; border-radius: var(--radio);
  cursor: pointer; text-transform: uppercase; }
.tac-boton.lleno { background: var(--acento); color: #141814; font-size: 19px; letter-spacing: 2px; min-height: 52px; }
.tac-pequeno { font-size: 13px; color: var(--texto-3); text-align: center; }
.tac-enlace { background: none; border: 0; padding: 0; color: var(--acento); font: inherit; cursor: pointer;
  text-decoration: underline; }
@media (min-width: 900px) {
  .tac-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .tac-cols > div { display: grid; gap: 12px; }
}
@media (max-width: 899px) { .tac-cols, .tac-cols > div { display: grid; gap: 12px; } }

/* el operador (dibujo de Victor): cambia con el estado */
.geo-op { border: 1px solid var(--borde); background: transparent; border-radius: var(--radio);
  display: grid; place-items: center; padding: 6px; }
.geo-op svg { width: 100%; height: auto; max-width: 280px; display: block; }
.geo-op .ring { transition: stroke .4s; }
.geo-op.est-0 .ring { stroke: #3F7F2E; }
.geo-op.est-1 .ring { stroke: #B07A12; animation-duration: 5s; }
.geo-op.est-2 .ring { stroke: #B23A26; animation-duration: 7s; }
.geo-op.est-3 .ring { stroke: #2A6F92; animation-duration: 1.4s; }
.geo-op.est-0 .glow { fill: #7fd36b; } .geo-op.est-1 .glow { fill: #E0A93B; }
.geo-op.est-2 .glow { fill: #D9614C; } .geo-op.est-3 .glow { fill: #5fc8ff; }
.geo-op.est-1 .breathe { animation-duration: 1.6s; }
.geo-op.est-1 .eye { animation: none; transform: scaleY(.62); }
.geo-op.est-2 .breathe { animation-duration: 6.5s; }
.geo-op.est-2 .eye { animation: none; transform: scaleY(.22); }
.geo-op.est-2 .beam { animation: none; opacity: 0; }
.geo-op.est-2 .dot { animation: none; opacity: .25; }
@keyframes geobote { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.geo-op.est-3 .breathe { animation: geobote .42s ease-in-out infinite; }
.geo-op.est-3 .beam { animation-duration: .9s; }
@media (prefers-reduced-motion: reduce) { .geo-op * { animation: none !important; } }
.tac-cuenta-cuerpo { display: flex; align-items: center; gap: 14px; }
.tac-cuenta-num { font-family: var(--letra-tac); font-size: 76px; font-weight: 700; line-height: .85; color: #E0A93B; }
.tac-cuenta-etq { font-family: var(--letra-tac); font-size: 19px; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; line-height: 1.1; }
.tac-fichas { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.tac-fichas i { width: 18px; height: 18px; border: 1px solid #E0A93B; background: rgba(224, 169, 59, .2); }
.tac-fichas i:last-child { background: #E0A93B; }
.tac-barra.ambar { margin-top: 12px; }
.tac-barra.ambar i { background: #E0A93B; }
