/* Gestión de Caja Menor — sistema visual
   Monte (sidebar) #0B2F50 · Pasto (acción) #0F4C81 · Rocío (tinte) #EAF1F8
   Papel (fondo) #F4F6F9 · Tinta (texto) #1F2937 · Trigo (atención) #A86B12 */
:root {
  --monte: #0B2F50; --monte-2: #123C63; --pasto: #0F4C81; --pasto-2: #0C3F6B; --rocio: #EAF1F8;
  --papel: #F4F6F9; --surface: #FFFFFF; --linea: #E1E6ED; --linea-2: #EEF1F5;
  --tinta: #1F2937; --tinta-2: #4B5563; --muted: #6B7280;
  --trigo: #A86B12; --trigo-bg: #FBF1DF;
  --ok: #1E7A4C; --ok-bg: #E4F4EA; --err: #B42318; --err-bg: #FDECEA;
  --info: #2457A6; --info-bg: #E8EFFB; --gray-bg: #EEF1F5;
  --r-panel: 14px; --r-ctl: 8px;
  --font: "Albert Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14.5px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--papel); color: var(--tinta); line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--pasto); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin: 0; }
h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; margin: 0 0 14px; }
h3 { font-size: .95rem; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono, .t-value, .kpi .value, td.right { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--pasto); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Estructura ---------- */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--monte); color: #C9D6E3; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; padding: 4px 8px 22px; margin-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand .logo { width: 38px; height: 38px; flex: none; display: grid; place-items: center; }
.brand .logo svg { width: 38px; height: 38px; }
.brand b { display: block; font-size: 1rem; line-height: 1.15; letter-spacing: -.01em; }
.brand small { display: block; color: #8FA7BF; font-size: .76rem; margin-top: 3px; }
.nav-title { font-size: .76rem; color: #7D97B1; margin: 20px 12px 6px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 11px; color: #D5E0EA; padding: 9px 12px; border-radius: var(--r-ctl); margin-bottom: 2px; font-weight: 500; position: relative; }
.nav a svg { opacity: .8; flex: none; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: var(--monte-2); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: #7DB8F0; }
.nav a.active svg { opacity: 1; }
.nav .count { margin-left: auto; background: #F2C46D; color: #3B2A06; font-size: .72rem; font-weight: 700; border-radius: 10px; padding: 1px 8px; }
.main { min-width: 0; }
.topbar { height: 62px; background: rgba(244,246,249,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--linea); display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 0 28px; position: sticky; top: 0; z-index: 5; }
.topbar .menu-btn { display: none; margin-right: auto; }
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 6px; }
.user-chip .name > div:first-child { font-weight: 600; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--rocio); color: var(--pasto-2); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.bell { position: relative; background: none; border: 0; cursor: pointer; padding: 7px; border-radius: var(--r-ctl); color: var(--tinta-2); }
.bell:hover { background: var(--rocio); }
.bell .dot { position: absolute; top: 1px; right: 1px; background: var(--err); color: #fff; border-radius: 9px; font-size: .66rem; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; font-weight: 700; border: 2px solid var(--papel); }
.content { padding: 30px 32px 48px; max-width: 1340px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .muted { margin-top: 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--muted); margin-top: 6px; }
.meta b { color: var(--tinta-2); font-weight: 600; }

/* ---------- Paneles ---------- */
.card { background: var(--surface); border: 1px solid var(--linea); border-radius: var(--r-panel); padding: 20px 22px; margin-bottom: 18px; }
.card.p0 { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--linea); }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 18px; }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.kpi { padding: 18px 20px; }
.kpi .label { color: var(--tinta-2); font-size: .86rem; font-weight: 600; }
.kpi .value { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; margin-top: 4px; line-height: 1.1; }
.kpi .sub { color: var(--muted); font-size: .86rem; margin-top: 2px; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--linea); background: var(--surface); color: var(--tinta); padding: 9px 15px; border-radius: var(--r-ctl); cursor: pointer; font: inherit; font-weight: 600; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--rocio); border-color: #C3D3E6; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--pasto); border-color: var(--pasto); color: #fff; }
.btn.primary:hover { background: var(--pasto-2); border-color: var(--pasto-2); }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.success:hover { background: #17633D; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.warn { background: var(--surface); border-color: #E3C48F; color: var(--trigo); }
.btn.warn:hover { background: var(--trigo-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--rocio); }
.btn.sm { padding: 5px 10px; font-size: .84rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Formularios ---------- */
label.f { display: block; font-size: .84rem; font-weight: 600; color: var(--tinta-2); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #CDD5DF; border-radius: var(--r-ctl); background: #fff; color: var(--tinta); transition: border-color .12s, box-shadow .12s; }
input::placeholder, textarea::placeholder { color: #9CA3AF; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pasto); box-shadow: 0 0 0 3px rgba(15,76,129,.16); }
input[type=checkbox] { width: auto; accent-color: var(--pasto); }
textarea { min-height: 76px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span3 { grid-column: span 3; }
.form-grid .span4 { grid-column: 1 / -1; }
.input-group { display: flex; gap: 6px; }
.input-group > input { flex: 1; }
.filters { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 12px; align-items: end; }
.help { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.dropzone { border: 1.5px dashed #B8C4D2; border-radius: var(--r-ctl); padding: 10px; text-align: center; color: var(--muted); cursor: pointer; background: #FAFBFC; font-size: .86rem; transition: background .12s, border-color .12s; }
.dropzone:hover { border-color: var(--pasto); }
.dropzone.drag { border-color: var(--pasto); background: var(--rocio); }
.dropzone.has { border-style: solid; border-color: #9CCDB1; color: var(--ok); background: var(--ok-bg); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8rem; color: var(--tinta-2); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--linea); background: #F8FAFC; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--linea-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #F5F8FC; }
tfoot td { font-weight: 700; background: #F8FAFC; border-top: 1px solid var(--linea); border-bottom: 0; }
.empty { text-align: center; color: var(--muted); padding: 34px; }

/* ---------- Estados ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 20px; font-size: .78rem; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-BORRADOR { background: var(--gray-bg); color: #4B5563; }
.b-PENDIENTE_JEFE { background: var(--trigo-bg); color: var(--trigo); }
.b-PENDIENTE_FINANCIERO { background: var(--info-bg); color: var(--info); }
.b-APROBADO { background: #E2F3EF; color: #146356; }
.b-PAGADO { background: var(--ok-bg); color: var(--ok); }
.b-DEVUELTO { background: #FDEEE3; color: #B4500F; }
.b-RECHAZADO { background: var(--err-bg); color: var(--err); }
.b-rol { background: var(--rocio); color: var(--pasto-2); }
.b-off { background: var(--gray-bg); color: var(--muted); }

/* ---------- Fondo de caja: medidor tipo regla ---------- */
.meter { position: relative; height: 12px; background: var(--gray-bg); border-radius: 3px; overflow: hidden; display: flex; }
.meter::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), rgba(255,255,255,.9) calc(25% - 1px) 25%); }
.meter > span { display: block; height: 100%; }
.meter .m-this { background: var(--pasto); }
.meter .m-other { background: #E2B866; }
.meter.over .m-this { background: var(--err); }
.totals { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 14px; }
.totals > div { padding-left: 12px; border-left: 2px solid var(--linea); }
.totals > div:first-child { border-left-color: var(--pasto); }
.totals .t-label { font-size: .82rem; color: var(--tinta-2); font-weight: 600; }
.totals .t-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; }
.alert { padding: 11px 15px; border-radius: var(--r-ctl); margin-bottom: 14px; font-size: .92rem; border: 1px solid transparent; }
.alert.err { background: var(--err-bg); color: var(--err); border-color: #F6C7C2; }
.alert.warn { background: var(--trigo-bg); color: #7A4D0C; border-color: #EED39F; }
.alert.info { background: var(--info-bg); color: var(--info); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- Pasos del flujo ---------- */
.steps { display: flex; margin: 2px 0; }
.step { flex: 1; text-align: center; position: relative; font-size: .82rem; color: var(--muted); }
.step::before { content: ""; position: absolute; top: 12px; left: -50%; width: 100%; height: 2px; background: var(--linea); z-index: 0; }
.step:first-child::before { display: none; }
.step .c { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 2px solid var(--linea); display: grid; place-items: center; margin: 0 auto 6px; position: relative; z-index: 1; font-weight: 700; font-size: .75rem; }
.step.done .c { background: var(--pasto); border-color: var(--pasto); color: #fff; }
.step.done::before, .step.current::before { background: var(--pasto); }
.step.current .c { border-color: var(--pasto); color: var(--pasto); box-shadow: 0 0 0 4px var(--rocio); }
.step.current { color: var(--tinta); font-weight: 600; }

/* ---------- Historial ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 24px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--pasto); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 19px; bottom: 0; width: 2px; background: var(--linea); }
.timeline li:last-child::after { display: none; }

/* ---------- Tarjetas de caja ---------- */
.caja-card .top { display: flex; justify-content: space-between; align-items: start; gap: 8px; margin-bottom: 14px; }
.caja-card .top b { font-size: 1.02rem; }
.caja-card .amt { display: flex; justify-content: space-between; font-size: .84rem; color: var(--muted); margin-top: 8px; font-variant-numeric: tabular-nums; }

/* ---------- Modal y avisos ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(11,25,45,.45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s ease; }
.modal { background: #fff; border-radius: var(--r-panel); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; box-shadow: 0 24px 60px rgba(11,25,45,.28); animation: pop .18s ease; }
.modal.lg { max-width: 840px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--linea); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--linea); display: flex; justify-content: flex-end; gap: 8px; background: #FAFBFC; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.99); } }
#toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--monte); color: #fff; padding: 11px 16px; border-radius: var(--r-ctl); box-shadow: 0 10px 30px rgba(11,25,45,.25); max-width: 380px; font-weight: 500; animation: pop .18s ease; }
.toast.err { background: var(--err); }
.toast.ok { background: var(--pasto); }

/* ---------- Ingreso: libro de caja ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr); background: #fff; }
.login-side { position: relative; background: var(--monte); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden;
  background-image: repeating-linear-gradient(180deg, transparent 0 39px, rgba(255,255,255,.07) 39px 40px),
                    linear-gradient(90deg, transparent 0 26px, rgba(242,196,109,.4) 26px 27px, transparent 27px 31px, rgba(242,196,109,.4) 31px 32px, transparent 32px); }
.login-side .marca { display: flex; align-items: center; gap: 12px; font-weight: 600; color: #CFDDEB; }
.login-side .marca svg { width: 40px; height: 40px; }
.login-side h1 { font-size: clamp(2.6rem, 5vw, 4.4rem); line-height: .98; letter-spacing: -.045em; font-weight: 800; max-width: 9ch; margin: 0 0 18px; }
.login-side p { color: #BCCBDB; max-width: 40ch; font-size: 1.02rem; margin: 0; }
.login-side .pie { color: #8FA7BF; font-size: .86rem; }
.login-form-wrap { display: grid; place-items: center; padding: 32px 24px; }
.login { width: 100%; max-width: 360px; }
.login h2 { font-size: 1.5rem; letter-spacing: -.02em; margin-bottom: 6px; }
.login .muted { margin: 0 0 26px; }
.login .btn { width: 100%; padding: 11px; margin-top: 8px; }

/* ---------- Otros ---------- */
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px 18px; max-height: 280px; overflow: auto; border: 1px solid var(--linea); border-radius: var(--r-ctl); padding: 12px; }
.perm-grid .suc { grid-column: 1 / -1; font-weight: 700; font-size: .84rem; color: var(--pasto-2); margin-top: 6px; }
.perm-grid label { display: flex; gap: 8px; align-items: center; font-size: .9rem; }
.notif { display: flex; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--linea-2); cursor: pointer; }
.notif:last-child { border-bottom: 0; }
.notif.unread { background: #F3F7FC; box-shadow: inset 3px 0 0 var(--pasto); }
.notif.unread .t { font-weight: 700; }
.notif:hover { background: #EEF3FA; }

/* Buscador de terceros */
.combo { position: relative; flex: 1; min-width: 0; }
.combo input { padding-right: 30px; }
.combo.selected input { background: var(--ok-bg); border-color: #9CCDB1; font-weight: 600; }
.combo.error input { border-color: var(--err); box-shadow: 0 0 0 3px rgba(180,35,24,.14); }
.combo-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .85rem; padding: 4px; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--linea); border-radius: var(--r-ctl); box-shadow: 0 14px 34px rgba(11,25,45,.16); max-height: 300px; overflow-y: auto; z-index: 30; }
.combo-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--linea-2); }
.combo-item:hover, .combo-item.active { background: var(--rocio); }
.combo-item mark { background: #FBE3AE; color: inherit; padding: 0; border-radius: 2px; }
.combo-new { color: var(--pasto); font-weight: 600; position: sticky; bottom: 0; background: #FAFBFC; }
.combo-empty { padding: 10px 12px; color: var(--muted); font-size: .88rem; }

[hidden] { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g3 { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid .span3 { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { padding: 32px 24px; min-height: 240px; }
  .login-side h1 { font-size: 2.4rem; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -270px; width: 248px; z-index: 40; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .topbar { padding: 0 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 20px 16px 40px; }
  h1 { font-size: 1.45rem; }
  .g2, .g3, .g4, .totals { grid-template-columns: 1fr 1fr; }
  .filters, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2, .form-grid .span3 { grid-column: auto; }
  .user-chip .name { display: none; }
}
