/* CAJA 4R — estilos */
:root {
  --bg: #f3f4f6; --panel: #ffffff; --ink: #14171c; --ink2: #3b4250; --mute: #6b7280; --line: #e3e6eb; --line2: #eef0f3;
  --acc: #1d3f6e; --acc2: #2c5aa0; --accbg: #e8eef8;
  --c1: #1d4ed8; --c1bg: #e3ebff; --c2: #a34a06; --c2bg: #fff0dd;
  --in: #087443; --out: #b42318; --warn: #b54708; --warnbg: #fff6e5; --okbg: #e9f7ef; --badbg: #fdecea;
  --hold: #6d28d9; --holdbg: #f1eaff;
  --r: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --side: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--acc2); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 650; color: var(--ink2); }
.num, td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mute { color: var(--mute); } .small { font-size: 12px; } .tiny { font-size: 11px; }
.in { color: var(--in); } .out { color: var(--out); } .warn { color: var(--warn); }
.nowrap { white-space: nowrap; } .ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; } .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
@media (max-width: 900px) { .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 560px) { .grid2, .grid3, .grid4 { grid-template-columns: minmax(0,1fr); } }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.side { width: var(--side); background: #0f1f36; color: #cdd6e4; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40; transition: transform .2s; }
.side .brand { padding: 16px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side .brand b { color: #fff; font-size: 16px; letter-spacing: .02em; } .side .brand span { font-size: 11px; color: #93a4bf; margin-left: 6px; }
.side nav { padding: 8px; overflow-y: auto; flex: 1; }
.side .sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #7d8ea9; margin: 14px 10px 4px; }
.side a { display: flex; align-items: center; gap: 9px; color: #cdd6e4; padding: 7px 10px; border-radius: 6px; font-size: 13.5px; text-decoration: none; }
.side a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side a.on { background: rgba(255,255,255,.12); color: #fff; }
.side a .cnt { margin-left: auto; background: #d97706; color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; }
.side .foot { padding: 10px 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #93a4bf; }
.main { margin-left: var(--side); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 30; background: rgba(243,244,246,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); padding: 8px 20px; display: flex; gap: 12px; align-items: center; }
.top .burger { display: none; }
.content { padding: 18px 20px 60px; max-width: 1500px; width: 100%; }
.page-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-h .sp { flex: 1; }
@media (max-width: 960px) {
  .side { transform: translateX(-100%); } .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .main { margin-left: 0; } .top .burger { display: inline-flex; } .content { padding: 14px 12px 70px; } .top { padding: 8px 12px; }
}
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 35; }

/* Controles */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 7px; padding: 7px 12px; font-family: inherit; font-weight: 500; font-size: 13.5px; line-height: 1.2; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c9ced6; background: #fafbfc; }
.btn.pri { background: var(--acc); border-color: var(--acc); color: #fff; } .btn.pri:hover { background: var(--acc2); }
.btn.danger { color: var(--out); } .btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 8px; font-size: 12.5px; } .btn:disabled { opacity: .5; cursor: default; }
.btn.icon { padding: 6px 8px; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b8cbe9; border-color: var(--acc2); }
input[type=checkbox], input[type=radio] { width: auto; }
input.n { text-align: right; font-variant-numeric: tabular-nums; }
label.f { display: block; } label.f > span { display: block; font-size: 12px; color: var(--mute); margin-bottom: 3px; }
label.f > span b { color: var(--out); font-weight: 600; }
.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 6px 11px; font-family: inherit; font-weight: 600; font-size: 12.5px; cursor: pointer; color: var(--ink2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--acc); color: #fff; }
.seg button.on.c1 { background: var(--c1); } .seg button.on.c2 { background: var(--c2); }

/* Tarjetas y tablas */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card > .hd { padding: 12px 14px; border-bottom: 1px solid var(--line2); display: flex; align-items: center; gap: 8px; }
.card > .hd h2, .card > .hd h3 { margin: 0; }
.card > .bd { padding: 14px; }
.card.pad { padding: 14px; }
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { border-collapse: collapse; width: 100%; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; font-size: 11.5px; color: var(--mute); text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafbfc; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
table.t th.n { text-align: right; }
table.t td { padding: 7px 10px; border-bottom: 1px solid var(--line2); vertical-align: top; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: #f7f9fc; }
table.t tr.anul td { opacity: .45; text-decoration: line-through; }
table.t tr.sel td { background: #eef4ff; }
table.t tfoot td { font-weight: 650; border-top: 1px solid var(--line); background: #fafbfc; }
table.t tr.grp td { background: #f6f7f9; font-weight: 650; color: var(--ink2); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
table.t tr.sub td { font-weight: 650; background: #fbfbfc; }
table.t.dense td { padding: 5px 8px; } table.t.dense th { padding: 6px 8px; }

/* Etiquetas */
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 5px; padding: 1px 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--line2); color: var(--ink2); }
.badge.c1 { background: var(--c1bg); color: var(--c1); } .badge.c2 { background: var(--c2bg); color: var(--c2); }
.badge.est { outline: 1px dashed currentColor; outline-offset: -1px; }
.badge.ok { background: var(--okbg); color: var(--in); } .badge.bad { background: var(--badbg); color: var(--out); } .badge.warn { background: var(--warnbg); color: var(--warn); }
.badge.hold { background: var(--holdbg); color: var(--hold); } .badge.blue { background: var(--accbg); color: var(--acc2); }
.pill { display: inline-block; padding: 0 6px; border-radius: 10px; background: var(--line2); font-size: 11px; color: var(--ink2); }
.alert { border-radius: 8px; padding: 10px 12px; border: 1px solid; font-size: 13.5px; }
.alert.warn { background: var(--warnbg); border-color: #fbd59a; color: #7a2e0e; }
.alert.bad { background: var(--badbg); border-color: #f5b6b0; color: #7a1a12; }
.alert.ok { background: var(--okbg); border-color: #a6e3c0; color: #064e2b; }
.alert.info { background: var(--accbg); border-color: #c4d4ee; color: #17325a; }

/* Saldos */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 13px; box-shadow: var(--shadow); }
.kpi .l { font-size: 11.5px; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; }
.kpi .v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .s { font-size: 12px; color: var(--mute); }
.soc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
@media (max-width: 560px) { .soc-grid { grid-template-columns: minmax(0,1fr); } }
.acc-row { display: flex; align-items: baseline; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line2); }
.acc-row:last-child { border-bottom: 0; }
.acc-row .nm { flex: 1; min-width: 0; }
.acc-row .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.acc-units { margin: 2px 0 6px 12px; font-size: 12px; }
.acc-units div { display: flex; gap: 8px; color: var(--ink2); } .acc-units div span:first-child { flex: 1; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 760px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 1080px; } .modal.narrow { max-width: 480px; }
.modal > .hd { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal > .hd h2 { margin: 0; flex: 1; }
.modal > .bd { padding: 16px; }
.modal > .ft { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; background: #fafbfc; border-radius: 0 0 12px 12px; }
@media (max-width: 560px) { .modal-bg { padding: 0; } .modal { border-radius: 0; min-height: 100vh; } .modal > .ft { position: sticky; bottom: 0; } }

/* Formulario de movimiento */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; font-family: inherit; font-weight: 600; font-size: 13px; color: var(--mute); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--acc); border-bottom-color: var(--acc); }
.lines { border: 1px solid var(--line); border-radius: 8px; }
.lines .ln { display: grid; grid-template-columns: 1.1fr 1.4fr 150px 30px; gap: 6px; padding: 6px; border-bottom: 1px solid var(--line2); align-items: center; }
.lines .ln:last-child { border-bottom: 0; }
@media (max-width: 640px) { .lines .ln { grid-template-columns: 1fr 1fr; } .lines .ln > :nth-child(3) { grid-column: 1; } }
.fact { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fcfcfd; }
.fact + .fact { margin-top: 8px; }
.section-t { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--mute); font-weight: 650; margin: 16px 0 8px; display: flex; gap: 8px; align-items: center; }
.section-t::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.cbar { display: flex; gap: 0; }
.cbar button { flex: 1; border: 2px solid var(--line); background: #fff; padding: 9px 10px; font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer; color: var(--mute); }
.cbar button:first-child { border-radius: 8px 0 0 8px; } .cbar button:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.cbar button.on.c1 { border-color: var(--c1); background: var(--c1bg); color: var(--c1); }
.cbar button.on.c2 { border-color: var(--c2); background: var(--c2bg); color: var(--c2); }
.cbar button small { display: block; font-weight: 500; font-size: 11px; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #0f1f36 0%, #1d3f6e 100%); }
.login { background: #fff; border-radius: 14px; padding: 26px; width: 100%; max-width: 380px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login h1 { font-size: 22px; } .login .ver { color: var(--mute); font-size: 12px; margin-bottom: 18px; }
.login .stack > * + * { margin-top: 12px; }
.qrbox { display: flex; justify-content: center; padding: 10px; } .qrbox img, .qrbox svg { width: 190px; height: 190px; }
.code-in { font-size: 24px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toast { background: #1f2937; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 13.5px; }
.toast.err { background: #8a1c12; } .toast.ok { background: #0b5b36; }
.loading { padding: 30px; text-align: center; color: var(--mute); }
.empty { padding: 26px; text-align: center; color: var(--mute); }
.hide-sm { } @media (max-width: 760px) { .hide-sm { display: none !important; } }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.flujo td:first-child, .flujo th:first-child { position: sticky; left: 0; background: #fff; z-index: 2; min-width: 230px; }
.flujo tr.grp td:first-child { background: #f6f7f9; } .flujo tr.sub td:first-child, .flujo tfoot td:first-child { background: #fbfbfc; }
.diffbox { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; white-space: pre-wrap; background: #f8f9fb; border-radius: 6px; padding: 8px; max-height: 240px; overflow: auto; }
kbd { font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: #fff; }
