/* Casa: mismo esquema que Reparto (una columna en el celu, menú al costado en la compu), en violeta. */

:root {
  color-scheme: light;
  --bg: #f5f3f8;
  --surface: #ffffff;
  --surface-2: #efebf6;
  --ink: #18151f;
  --ink-2: #4c4658;
  --muted: #857e92;
  --line: #e6e1ee;
  --accent: #6b3fd4;
  --accent-ink: #5428b8;
  --accent-soft: rgba(107, 63, 212, 0.1);
  --on-accent: #ffffff;
  --good: #1a9d55;
  --good-ink: #127a41;
  --good-soft: rgba(26, 157, 85, 0.12);
  --warn: #c98300;
  --warn-soft: rgba(232, 163, 23, 0.14);
  --bad: #d23c3c;
  --bad-ink: #b02a2a;
  --bad-soft: rgba(210, 60, 60, 0.1);
  --shadow: 0 1px 2px rgba(24, 21, 31, 0.05), 0 6px 20px rgba(24, 21, 31, 0.05);
  --radius: 18px;
  --g1: #6b3fd4; --g2: #e2620c; --g3: #1f8fbf; --g4: #8a847a;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #110f15; --surface: #1b1820; --surface-2: #25212c; --ink: #f2eff6; --ink-2: #c8c1d3; --muted: #8f879c;
    --line: #2e2a36; --accent: #9b76f0; --accent-ink: #b9a0f6; --accent-soft: rgba(155, 118, 240, 0.16);
    --good-ink: #3ccb7f; --good-soft: rgba(60, 203, 127, 0.14); --bad-ink: #ef7676; --bad-soft: rgba(239, 118, 118, 0.12);
    --warn-soft: rgba(232, 163, 23, 0.16); --shadow: none;
    --g1: #9b76f0; --g2: #f27a2a; --g3: #4fb3e0; --g4: #a39d92;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 Manrope, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 16px; font-weight: 800; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.neg { color: var(--bad-ink); }
.pos { color: var(--good-ink); }
[hidden] { display: none !important; }

#app { max-width: 560px; margin: 0 auto; padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.top p { margin-top: 2px; color: var(--muted); font-size: 13px; }
.stack > * + * { margin-top: 12px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border: 1px solid var(--line); }
.card h2 { margin-bottom: 10px; }
.card-t { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-t h2 { margin: 0; }

/* Tarjeta grande del mes */
.hero { background: linear-gradient(135deg, var(--accent), #8f5cf0); color: var(--on-accent); border: 0; }
.hero.mal { background: linear-gradient(135deg, #b8325d, #6b3fd4); }
.hero .k { font-size: 13px; opacity: 0.85; font-weight: 600; }
.hero .v { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin: 2px 0 10px; }
.hero .fila { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; }
.hero .fila b { display: block; font-size: 16px; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.kpi .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 20px; font-weight: 800; margin-top: 2px; }
.kpi .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.alerta { background: var(--warn-soft); border-color: transparent; }

/* Selector de mes */
.meses { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; margin-bottom: 6px; scrollbar-width: none; }
.meses::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 6px 12px; font: 600 13px Manrope, sans-serif; white-space: nowrap; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Filas y listas */
.lista { display: flex; flex-direction: column; }
.fila-p { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.fila-p:first-child { border-top: 0; }
.fila-p .tx { flex: 1; min-width: 0; cursor: pointer; }
.fila-p .tx b { display: block; font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-p .tx span { font-size: 12px; color: var(--muted); }
.fila-p .m { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fila-p.pagado .tx b, .fila-p.pagado .m { color: var(--muted); text-decoration: line-through; }
.check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; flex: none; color: transparent; font-weight: 900; }
.check.on { background: var(--good); border-color: var(--good); color: #fff; }
.renglon { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 14px; }
.renglon + .renglon { border-top: 1px dashed var(--line); }
.renglon .num { font-weight: 700; }
.renglon.total { font-weight: 800; border-top: 1px solid var(--line) !important; margin-top: 4px; padding-top: 8px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.tag.vence { background: var(--warn-soft); color: var(--warn); }
.tag.ok { background: var(--good-soft); color: var(--good-ink); }
.grupo-t { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 2px; }
.grupo-t h3 { color: var(--ink-2); }

/* Barras de progreso y de reparto */
.barra { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.barra i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.apilada { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--surface-2); margin: 6px 0 10px; }
.apilada i { display: block; height: 100%; }
.ley { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); }
.ley span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; background: var(--c); }

/* Gráfico del año */
.grafico svg { width: 100%; height: auto; display: block; }
.grafico .b-neg { fill: var(--bad); opacity: 0.85; }
.grafico .b-pos { fill: var(--good); opacity: 0.85; }
.grafico .b-sel { opacity: 1; stroke: var(--ink); stroke-width: 1.5; }
.grafico text { fill: var(--muted); font: 600 10px Manrope, sans-serif; }
.grafico .cero { stroke: var(--line); stroke-width: 1; }

/* Mili */
.mili { display: flex; gap: 12px; align-items: flex-start; }
.mili img { width: 52px; height: 52px; border-radius: 50%; background: var(--accent-soft); flex: none; object-fit: cover; }
.mili p { font-size: 14px; color: var(--ink-2); }
.mili b { color: var(--ink); }

/* Botones y formularios */
.btn { appearance: none; border: 0; background: var(--accent); color: var(--on-accent); font: 700 14px Manrope, sans-serif; padding: 11px 16px; border-radius: 12px; cursor: pointer; }
.btn.sec { background: var(--surface-2); color: var(--ink); }
.btn.peligro { background: var(--bad-soft); color: var(--bad-ink); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.campo { display: block; margin-bottom: 12px; }
.campo > span { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.campo input, .campo select, .campo textarea { width: 100%; font: 500 15px Manrope, sans-serif; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.paso { display: flex; align-items: center; gap: 8px; }
.paso input { flex: 1; min-width: 70px; text-align: center; font-weight: 800; }
.dash > .col { min-width: 0; }
.paso button { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font: 800 20px Manrope, sans-serif; color: var(--ink); cursor: pointer; flex: none; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Tabla simple */
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th { text-align: right; color: var(--muted); font-weight: 700; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.tabla th:first-child, .tabla td:first-child { text-align: left; }
.tabla td { text-align: right; padding: 7px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tabla tr.sel td { background: var(--accent-soft); font-weight: 700; }
.scroll-x { overflow-x: auto; }

/* Hoja (formulario que sube desde abajo) */
.velo { position: fixed; inset: 0; background: rgba(10, 8, 14, 0.45); z-index: 40; }
.hoja { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--surface); border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; max-width: 560px; margin: 0 auto; }
.hoja h2 { margin-bottom: 14px; }
.hoja .acciones { display: flex; gap: 8px; margin-top: 6px; }
.hoja .acciones .btn { flex: 1; }

/* Entrar */
.entrar { max-width: 360px; margin: 10vh auto 0; text-align: center; }
.entrar img { width: 90px; height: 90px; border-radius: 50%; background: var(--accent-soft); }
.entrar h1 { margin: 12px 0 4px; }
.entrar input { text-align: center; letter-spacing: 0.4em; font-size: 22px; font-weight: 800; }

/* Barra de abajo */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabbar a { flex: 1; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; }
.tabbar a .ic { font-size: 20px; line-height: 1; }
.tabbar a.on { color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; opacity: 0; transition: 0.25s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.aviso { background: var(--accent-soft); color: var(--accent-ink); border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 600; }

/* Compu: menú al costado y dos columnas */
@media (min-width: 1024px) {
  .tabbar { display: none !important; }
  .side { position: fixed; top: 0; left: 0; bottom: 0; width: 240px; background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 14px; }
  .marca { display: flex; gap: 10px; align-items: center; text-decoration: none; font-weight: 800; font-size: 18px; }
  .marca small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
  .marca-i { font-size: 26px; }
  .side nav { display: flex; flex-direction: column; gap: 2px; }
  .side nav a { text-decoration: none; padding: 10px 12px; border-radius: 10px; font-weight: 700; color: var(--ink-2); display: flex; gap: 10px; }
  .side nav a.on { background: var(--accent-soft); color: var(--accent-ink); }
  .side-foot { margin-top: auto; }
  body.con-side #app { margin-left: 240px; max-width: 1040px; padding: 28px 32px 40px; }
  .dash { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; align-items: start; }
  .dash > .col > * + * { margin-top: 14px; }
  .kpis.cuatro { grid-template-columns: repeat(4, 1fr); }
  .hoja { bottom: auto; top: 50%; transform: translateY(-50%); border-radius: 22px; max-width: 460px; }
  .toast { bottom: 30px; }
}
@media (max-width: 1023px) {
  .dash > .col > * + * { margin-top: 12px; }
  .dash > .col + .col { margin-top: 12px; }
}
