/* PowerBank — tokens del prototipo "Mis cuentas": verde petróleo, tarjetas limpias, poco número y mucho gráfico. */
:root {
    --bg: #f3f6f5; --surface: #ffffff; --ink: #0c2533; --muted: #5b6b76; --line: #dfe6e7;
    --accent: #07805b; --accent-soft: #d5f2e6; --on-accent: #ffffff;
    --cuotas: #07805b; --fijos: #2a78d6; --comision: #eb6834; --nuevas: #c8e3d8;
    --ok: #1f8a4c; --ok-soft: #dcf1e3; --warn: #b7700d; --warn-soft: #fbecd2; --bad: #c2372e; --bad-soft: #f9dedb;
    --logo-ink: #0c2533; --logo-green: #08ad7a; --logo-bg: var(--surface);
    --shadow: 0 1px 2px rgba(12, 37, 51, .05), 0 4px 16px rgba(12, 37, 51, .04);
    --display: "Sora", "Segoe UI", system-ui, sans-serif;
    --body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    --radius: 14px;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0a1820; --surface: #10232e; --ink: #e3edf0; --muted: #93a6b0; --line: #1f3642;
        --accent: #3ddc97; --accent-soft: #123a2e; --on-accent: #06251a; --cuotas: #1fa874; --fijos: #3987e5; --comision: #d95926; --nuevas: #1f4a3c;
        --ok: #5ccf8a; --ok-soft: #173424; --warn: #f0b04a; --warn-soft: #3a2c12; --bad: #f07a70; --bad-soft: #3d1c19;
        --logo-ink: #e3edf0; --logo-green: #3ddc97; --logo-bg: var(--surface);
        --shadow: none; color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0a1820; --surface: #10232e; --ink: #e3edf0; --muted: #93a6b0; --line: #1f3642;
        --accent: #3ddc97; --accent-soft: #123a2e; --on-accent: #06251a; --cuotas: #1fa874; --fijos: #3987e5; --comision: #d95926; --nuevas: #1f4a3c;
        --ok: #5ccf8a; --ok-soft: #173424; --warn: #f0b04a; --warn-soft: #3a2c12; --bad: #f07a70; --bad-soft: #3d1c19;
        --logo-ink: #e3edf0; --logo-green: #3ddc97; --logo-bg: var(--surface);
        --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); margin: 0; text-wrap: balance; }
h1 { font-size: clamp(24px, 4vw, 32px); font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
h1:focus { outline: none; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sub { font-size: 13px; color: var(--muted); }
.note { font-size: 12.5px; color: var(--muted); }
.big { font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -.01em; margin-top: 4px; }
code { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }

/* ---------- App chrome ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px;
    padding: 10px max(16px, calc((100% - 1080px) / 2)); background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; text-decoration: none; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--logo-ink); }
.logo-mark { width: 34px; height: 34px; flex: 0 0 auto; }
.logo-text { display: grid; gap: 2px; }
.logo-word { font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: -.02em; line-height: 1; }
.logo-power { color: var(--logo-ink); }
.logo-bank { color: var(--logo-green); }
.logo-tag { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.logo-lg { gap: 14px; }
.logo-lg .logo-mark { width: 56px; height: 56px; }
.logo-lg .logo-word { font-size: 32px; }
.logo-lg .logo-tag { font-size: 10.5px; }
.nav-top { display: flex; gap: 4px; flex: 1; }
.nav-top a { color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14px; padding: 6px 12px; border-radius: 999px; }
.nav-top a:hover { color: var(--ink); background: var(--surface); }
.nav-top a.active { color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
.top-actions { display: flex; gap: 6px; margin-left: auto; }
.top-actions form { margin: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--ink); }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 24px 16px 56px; display: grid; gap: 20px; align-content: start; flex: 1; }

.nav-bottom { display: none; }
@media (max-width: 760px) {
    .nav-top { display: none; }
    .wrap { padding-bottom: calc(88px + env(safe-area-inset-bottom)); padding-top: 18px; }
    .nav-bottom {
        display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
        background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    }
    .nav-bottom a { display: grid; justify-items: center; gap: 2px; padding: 4px 0; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500; border-radius: 10px; }
    .nav-bottom svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    .nav-bottom a.active { color: var(--accent); font-weight: 600; }
}

/* ---------- Estructura ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: end; justify-content: space-between; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; box-shadow: var(--shadow); }
.panel-head { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; }
.grid2-eq { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 860px) { .grid3, .grid2, .grid2-eq { grid-template-columns: minmax(0, 1fr); } }
.stack { display: grid; gap: 12px; }

/* ---------- Estado / chips ---------- */
.status { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 14px; }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.info { background: var(--accent-soft); color: var(--accent); }

/* ---------- Barras ---------- */
.bar { height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; display: flex; }
.bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Tabla simple (vista detalle) ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.data tr:last-child td { border-bottom: 0; }
table.data .r { text-align: right; }

/* ---------- Formularios y botones ---------- */
.btn { font: inherit; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--accent); }
.btn-block { width: 100%; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field input, .field select, input.input, select.input {
    font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
.field input:focus, .field select:focus, .input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-error { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 0; }
.form-ok { background: var(--ok-soft); color: var(--ok); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 0; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 16px; padding: 28px; }
.login-logo { display: flex; justify-content: center; padding: 4px 0 8px; }

/* ---------- Blazor ---------- */
#blazor-error-ui { background: var(--bad-soft); color: var(--bad); bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2); display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--ok); }
.invalid { outline: 1px solid var(--bad); }
.validation-message { color: var(--bad); }

/* ---------- Botones extra ---------- */
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost-danger { color: var(--bad); background: transparent; border-color: transparent; padding-inline: 8px; }
.btn-add { width: 100%; margin-top: 10px; border-style: dashed; color: var(--muted); font-weight: 500; }
.btn-add:hover { color: var(--accent); border-color: var(--accent); }
.link-danger { justify-self: center; background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }
.link-danger:hover { color: var(--bad); }
.icon-btn.is-disabled { opacity: .35; pointer-events: none; }
.tabs { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tabs button { white-space: nowrap; font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--muted); padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.tabs-block { display: flex; }
.tabs-block button { flex: 1; padding: 9px 12px; font-size: 14px; }
.num.neg { color: var(--bad); }
.num.pos { color: var(--ok); }
.ok-txt { color: var(--ok); }

/* ---------- Checklist ---------- */
.lista { list-style: none; margin: 0; padding: 0; }
.fila { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); }
.fila:first-child { border-top: 0; }
.fila-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 11px 4px; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: 8px; }
button.fila-main:hover { background: color-mix(in srgb, var(--bg) 70%, transparent); }
.fila-txt { flex: 1; min-width: 0; display: grid; }
.fila-titulo { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-monto { white-space: nowrap; font-size: 14px; }
.fila.hecha .fila-titulo, .fila.hecha .fila-monto { color: var(--muted); }
.check { flex: 0 0 auto; width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; padding: 0; cursor: pointer; }
.check svg { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); fill: none; stroke: transparent; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; padding: 3px; transition: background .15s, border-color .15s; }
.check:hover svg { border-color: var(--accent); }
.check[aria-pressed="true"] svg { background: var(--accent); border-color: var(--accent); stroke: var(--on-accent); }
.check.auto svg { border-style: dashed; stroke: var(--muted); stroke-width: 2; }
.fila-auto .fila-titulo { color: var(--muted); }
.vacio { text-align: center; padding: 16px 0 6px; margin: 0; }
.lista-panel .panel-head { align-items: center; }

/* ---------- Secciones plegables ---------- */
.plegable { padding: 0; }
.plegable-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 16px 20px; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: var(--radius); }
.plegable-head > span:first-child { flex: 1; display: grid; }
.plegable-head .num { font-size: 15px; font-weight: 500; }
.chev { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.plegable-head[aria-expanded="true"] .chev { transform: rotate(180deg); }
.plegable > :not(.plegable-head) { margin-inline: 20px; }
.plegable > :last-child:not(.plegable-head) { margin-bottom: 18px; }
.plegable .note { margin-top: 8px; }
/* Dentro de una sección plegable el botón lleva margen lateral: ancho automático para no salirse. */
.plegable > .btn-add { width: calc(100% - 40px); }

/* ---------- Panel inferior (bottom sheet) ---------- */
.sheet-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(6, 18, 24, .45); animation: pb-fade .15s ease-out; }
.sheet {
    position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 92dvh; display: flex; flex-direction: column;
    background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 32px rgba(0, 0, 0, .18);
    padding-bottom: env(safe-area-inset-bottom); animation: pb-up .22s cubic-bezier(.2, .8, .2, 1);
}
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px 6px; }
.sheet-body { overflow-y: auto; padding: 8px 20px 20px; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; padding-top: 6px; }
.sheet-actions .btn-primary { min-width: 130px; }
.sheet-actions .btn-ghost-danger { margin-right: auto; }
@keyframes pb-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pb-pop { from { transform: translate(-50%, 24px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes pb-fade { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 761px) {
    .sheet { left: 50%; right: auto; width: 520px; transform: translateX(-50%); bottom: 24px; border-radius: 20px; animation-name: pb-pop; }
    .sheet-handle { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-overlay { animation: none; } }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grid-form { grid-template-columns: 1fr; } }
.cuota-inputs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.monto-input { position: relative; display: block; }
.monto-prefijo { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-family: var(--mono); pointer-events: none; }
.field .monto-input input { padding-left: 28px; font-family: var(--mono); font-size: 18px; }
.resumen-copia { margin: 0; padding-left: 20px; display: grid; gap: 4px; }

/* ---------- Importar / revisar movimientos ---------- */
.drop { display: flex; align-items: center; gap: 12px; padding: 18px; border: 1.5px dashed var(--line); border-radius: 12px; cursor: pointer; color: var(--muted); font-size: 14px; }
.drop:hover { border-color: var(--accent); color: var(--ink); }
.drop input[type=file] { max-width: 100%; font: inherit; font-size: 13px; }
.import-row { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 12px; max-width: 520px; }
.log { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); align-self: end; padding-bottom: 10px; }
.check-line input { width: 18px; height: 18px; accent-color: var(--accent); }
.facturado { text-align: right; }
.status-block { display: flex; border-radius: 12px; padding: 10px 14px; font-weight: 500; }
.status-block .dot { flex: 0 0 auto; margin-top: 7px; align-self: flex-start; }
.cuadres { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.cuadres li { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.resumen-ec { display: flex; flex-wrap: wrap; gap: 12px 28px; }
.resumen-ec div { display: grid; }
.resumen-ec .num { font-size: 14px; }
.usd { max-width: 320px; }
.rev-head { margin-bottom: 6px; }
.rev-grupo { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-family: var(--body); font-weight: 600; margin: 18px 0 6px; }
.movs { list-style: none; margin: 0; padding: 0; }
.mov { display: grid; grid-template-columns: minmax(0, 1fr) 240px; grid-template-areas: "top cat" "sub cat" "regla regla"; column-gap: 16px; padding: 10px 0 10px 10px; border-top: 1px solid var(--line); border-left: 3px solid transparent; }
.mov:first-child { border-top: 0; }
.mov-sin { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn-soft) 45%, transparent); }
.mov-top { grid-area: top; min-width: 0; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.mov-nombre { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mov-monto { white-space: nowrap; font-size: 14px; }
.mov-sub { grid-area: sub; font-size: 12.5px; color: var(--muted); }
.mov-cat { grid-area: cat; align-self: center; font-size: 14px !important; padding: 8px 10px !important; }
.regla { grid-area: regla; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 13.5px; }
.regla-clave { width: 150px; font-family: var(--mono); text-transform: uppercase; padding: 6px 10px !important; font-size: 14px !important; }
.regla-acciones { display: flex; gap: 6px; margin-left: auto; }
.acciones, .acciones-fijas { display: flex; flex-wrap: wrap; gap: 10px; }
.acciones-fijas { position: sticky; bottom: 0; z-index: 5; justify-content: flex-end; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.sugerencia { padding: 14px; border-radius: 12px; background: var(--accent-soft); display: grid; gap: 10px; justify-items: start; }
.sugerencia p { margin: 0; }
@media (max-width: 760px) {
    .mov { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "sub" "cat" "regla"; row-gap: 6px; }
    .acciones-fijas { bottom: calc(64px + env(safe-area-inset-bottom)); }
    .acciones-fijas .btn { flex: 1; }
    .facturado { text-align: left; }
    .import-row { grid-template-columns: 1fr 1fr; }
    .import-row label:first-child { grid-column: 1 / -1; }
}

/* ---------- Selector de color ---------- */
.colores { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.color-op { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.color-op[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.color-libre { width: 36px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }

/* ---------- Aviso ---------- */
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); }
@media (min-width: 761px) { .toast { bottom: 24px; } }
