/* =================================================================
   GastoClaro · Sistema visual
   Concepto: "la boleta ordenada". Verde libro-contable para el dinero bajo control,
   ámbar de ticket térmico para "cerca del límite", rojo solo para "excedido".
   ================================================================= */
@font-face { font-family: 'Plus Jakarta Sans'; src: url('../fonts/PlusJakartaSans-var.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }

:root {
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --bg: #F1F4F3;
  --surface: #FFFFFF;
  --surface-2: #F7F9F8;
  --ink: #1B2430;
  --muted: #667381;
  --line: #E1E7E4;
  --primary: #0F7B6C;
  --primary-ink: #0A5C51;
  --primary-soft: #E2F1ED;
  --amber: #E2961E;
  --amber-soft: #FDF2DE;
  --danger: #D64545;
  --danger-soft: #FBE7E7;
  --paper: #FFFEF9;
  --paper-ink: #2C3440;
  --shadow-1: 0 1px 2px rgba(27, 36, 48, .06), 0 1px 1px rgba(27, 36, 48, .04);
  --shadow-2: 0 10px 30px -12px rgba(16, 60, 52, .28);
  --r-lg: 18px; --r-md: 12px; --r-sm: 8px;
  --sb-w: 264px; --sb-w-c: 78px; --top-h: 64px;
  --bs-body-font-family: var(--font);
  --bs-primary: var(--primary); --bs-primary-rgb: 15, 123, 108;
  --bs-link-color: var(--primary); --bs-link-hover-color: var(--primary-ink); --bs-link-color-rgb: 15, 123, 108; --bs-link-hover-color-rgb: 10, 92, 81;
  --bs-body-bg: var(--bg); --bs-body-color: var(--ink); --bs-border-color: var(--line);
  --bs-secondary-color: var(--muted); --bs-tertiary-bg: var(--surface-2);
  --bs-focus-ring-color: rgba(15, 123, 108, .28);
}
:root:not([data-theme="light"])[data-bs-theme="dark"], :root[data-bs-theme="dark"] {
  --bg: #0F151A;
  --surface: #172027;
  --surface-2: #1D2830;
  --ink: #E6ECEF;
  --muted: #95A3AE;
  --line: #29353E;
  --primary: #39C2A6;
  --primary-ink: #6ED9C3;
  --primary-soft: rgba(57, 194, 166, .14);
  --amber: #F0B04A; --amber-soft: rgba(240, 176, 74, .14);
  --danger: #F06A6A; --danger-soft: rgba(240, 106, 106, .14);
  --paper: #1E2830; --paper-ink: #DCE3E7;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 14px 34px -14px rgba(0, 0, 0, .6);
  --bs-primary-rgb: 57, 194, 166; --bs-link-color-rgb: 57, 194, 166; --bs-link-hover-color-rgb: 110, 217, 195;
  --bs-body-bg: var(--bg); --bs-body-color: var(--ink); --bs-border-color: var(--line);
  --bs-secondary-color: var(--muted); --bs-tertiary-bg: var(--surface-2);
}

html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-feature-settings: 'tnum' 1, 'lnum' 1; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5 { letter-spacing: -.015em; font-weight: 700; }
a { text-decoration: none; }
:focus-visible { outline: 3px solid rgba(var(--bs-primary-rgb), .45); outline-offset: 2px; }
.text-secondary { color: var(--muted) !important; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.brand-word { font-weight: 800; letter-spacing: -.03em; font-size: 1.2rem; color: var(--ink); }

/* ---------- Botones ---------- */
.btn { font-weight: 600; border-radius: var(--r-sm); }
.btn-lg { border-radius: var(--r-md); padding: .72rem 1.15rem; font-size: 1rem; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-ink); --bs-btn-hover-border-color: var(--primary-ink); --bs-btn-active-bg: var(--primary-ink); --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary); --bs-btn-color: #fff; --bs-btn-hover-color: #fff; }
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #062a24; --bs-btn-hover-color: #062a24; --bs-btn-active-color: #062a24; --bs-btn-disabled-color: #062a24; }
.btn-soft { background: var(--primary-soft); color: var(--primary-ink); border: 0; }
.btn-soft:hover { background: var(--primary); color: #fff; }
.btn-icon { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 0; color: var(--muted); background: transparent; font-size: 1.15rem; padding: 0; }
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon.btn-sm { width: 32px; height: 32px; font-size: .95rem; }
.form-control, .form-select { border-radius: var(--r-sm); border-color: var(--line); background-color: var(--surface); }
.form-control-lg, .form-select-lg { border-radius: var(--r-md); font-size: 1rem; padding: .7rem .95rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .18); }
.form-label { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.input-icon { position: relative; }
.input-icon > .bi:first-child { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; z-index: 2; }
.input-icon > .form-control { padding-left: 2.6rem; }
.pass-eye { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); width: 40px; height: 40px; border-radius: 50%; z-index: 2; }
.pass-eye:hover { color: var(--ink); }
.input-icon:has(.pass-eye) .form-control { padding-right: 3rem; }

/* ---------- Estructura ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sb-w); background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 1040; transition: width .22s ease, transform .25s ease;
}
.sidebar-head { height: var(--top-h); display: flex; align-items: center; justify-content: space-between; padding: 0 1rem 0 1.15rem; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: .6rem; }
.sidebar-account { margin: 0 .85rem .5rem; padding: .65rem .7rem; border-radius: var(--r-md); background: var(--surface-2); display: flex; align-items: center; gap: .65rem; min-width: 0; }
.acc-logo { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.acc-logo-txt { display: inline-flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); }
.acc-txt { min-width: 0; line-height: 1.2; }
.acc-txt b { display: block; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-txt small { color: var(--muted); font-size: .75rem; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .35rem .65rem 1rem; }
.nav-group { margin-bottom: .15rem; }
.nav-group-btn {
  width: 100%; display: flex; align-items: center; gap: .7rem; border: 0; background: transparent; color: var(--muted);
  padding: .55rem .7rem; border-radius: var(--r-sm); font-size: .8rem; font-weight: 700; letter-spacing: .01em;
}
.nav-group-btn:hover { color: var(--ink); background: var(--surface-2); }
.nav-group-btn .caret { margin-left: auto; font-size: .75rem; transition: transform .2s; }
.nav-group.open .caret { transform: rotate(180deg); }
.nav-group.has-active > .nav-group-btn { color: var(--ink); }
.nav-group-items { overflow: hidden; max-height: 0; transition: max-height .25s ease; }
.nav-group.open .nav-group-items { max-height: 480px; padding-bottom: .3rem; }
.nav-link-item {
  display: flex; align-items: center; gap: .75rem; padding: .62rem .75rem .62rem 1.05rem; margin: 1px 0; border-radius: var(--r-sm);
  color: var(--ink); font-weight: 500; font-size: .93rem; position: relative; white-space: nowrap;
}
.nav-link-item i { font-size: 1.08rem; color: var(--muted); width: 20px; text-align: center; }
.nav-link-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-link-item.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; }
.nav-link-item.active i { color: var(--primary); }
.nav-link-item.active::before { content: ''; position: absolute; left: 3px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--primary); }
.sidebar-foot { padding: .75rem; border-top: 1px solid var(--line); }
.btn-collapse { width: 100%; align-items: center; gap: .7rem; color: var(--muted); background: transparent; border: 0; padding: .55rem .7rem; font-weight: 600; font-size: .88rem; }
.btn-collapse:hover { background: var(--surface-2); color: var(--ink); }

.main { margin-left: var(--sb-w); transition: margin-left .22s ease; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 1020; height: var(--top-h); display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 1.22rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: .3rem; }
.avatar-btn { padding: 2px; border-radius: 50%; border: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; }
.avatar-txt { background: var(--primary); color: #fff; font-weight: 700; font-size: .85rem; }
[data-bs-theme="dark"] .avatar-txt { color: #062a24; }
.dot-badge { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.content { padding: 1.25rem 1.5rem 2.5rem; max-width: 1440px; outline: 0; }

/* Menú contraído: el contenido crece */
@media (min-width: 992px) {
  body.sb-collapsed .sidebar { width: var(--sb-w-c); }
  body.sb-collapsed .main { margin-left: var(--sb-w-c); }
  body.sb-collapsed .brand-word, body.sb-collapsed .acc-txt, body.sb-collapsed .nav-group-btn span, body.sb-collapsed .nav-group-btn .caret,
  body.sb-collapsed .nav-link-item span, body.sb-collapsed .btn-collapse span { display: none; }
  body.sb-collapsed .sidebar-head { justify-content: center; padding: 0; }
  body.sb-collapsed .sidebar-account { justify-content: center; padding: .45rem; margin: 0 .7rem .5rem; }
  body.sb-collapsed .nav-group-btn { padding: 0; height: 1px; min-height: 0; overflow: hidden; margin: .5rem .6rem; width: auto; border-radius: 0; background: var(--line); pointer-events: none; }
  body.sb-collapsed .nav-group-btn i { display: none; }
  body.sb-collapsed .nav-group-items { max-height: none !important; }
  body.sb-collapsed .nav-link-item { justify-content: center; padding: .7rem; }
  body.sb-collapsed .nav-link-item i { font-size: 1.2rem; }
  body.sb-collapsed .btn-collapse { justify-content: center; }
  body.sb-collapsed .btn-collapse i { transform: scaleX(-1); }
}

/* Celular y tablet */
.sidebar-backdrop { display: none; }
.bottom-nav { display: none; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-102%); width: min(300px, 86vw); box-shadow: var(--shadow-2); }
  body.sb-open .sidebar { transform: none; }
  body.sb-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(10, 20, 18, .45); z-index: 1035; }
  .main { margin-left: 0; }
  .topbar { padding: 0 .75rem; padding-top: env(safe-area-inset-top); height: calc(var(--top-h) + env(safe-area-inset-top)); }
  .content { padding: 1rem 1rem calc(96px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; height: calc(66px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line); align-items: center; justify-content: space-around;
  }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: .7rem; font-weight: 600; padding: 6px 0; }
  .bottom-nav a i { font-size: 1.3rem; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav .scan-fab {
    flex: 0 0 62px; height: 62px; margin-top: -30px; border-radius: 20px; background: var(--primary); color: #fff !important;
    box-shadow: 0 10px 24px -8px rgba(var(--bs-primary-rgb), .7); justify-content: center; border: 4px solid var(--bg);
  }
  [data-bs-theme="dark"] .bottom-nav .scan-fab { color: #062a24 !important; }
  .bottom-nav .scan-fab i { font-size: 1.55rem; }
}

/* ---------- Bloques de contenido ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; }
.page-head p { margin: 0; color: var(--muted); max-width: 64ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.15rem 1.25rem; box-shadow: var(--shadow-1); }
.panel + .panel { margin-top: 1rem; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .9rem; }
.panel-title h2, .panel-title h3 { font-size: 1rem; margin: 0; }
.panel-title a { font-size: .85rem; font-weight: 600; }
.panel-flush { padding: 0; overflow: hidden; }

.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: .9rem 1rem; height: 100%; }
.kpi small { display: block; color: var(--muted); font-size: .8rem; font-weight: 600; }
.kpi b { display: block; font-size: 1.35rem; letter-spacing: -.02em; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: .78rem; font-weight: 600; }
.delta.up { color: var(--danger); } .delta.down { color: var(--primary); }

.chip { --c: var(--primary); display: inline-flex; align-items: center; gap: .3rem; padding: .17rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; font-style: normal;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip-muted { --c: var(--muted); }
.chip i { font-size: .8rem; }

/* Medidor de límite */
.meter { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.meter > i { display: block; height: 100%; border-radius: 6px; background: var(--primary); transition: width .6s ease; }
.meter.warn > i { background: var(--amber); }
.meter.over > i { background: var(--danger); }
.meter-lg { height: 16px; border-radius: 9px; }

/* Listas responsivas (en lugar de tablas) */
.rows { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: .85rem; padding: .8rem 1.25rem; border-top: 1px solid var(--line); color: var(--ink); min-width: 0; }
.row-item:first-child { border-top: 0; }
a.row-item:hover, .row-item.clickable:hover { background: var(--surface-2); cursor: pointer; }
.row-icon { width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; --c: var(--primary); color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); overflow: hidden; }
.row-icon img { width: 100%; height: 100%; object-fit: cover; }
.row-main { flex: 1; min-width: 0; }
.row-main b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-main small { color: var(--muted); font-size: .8rem; display: flex; flex-wrap: wrap; gap: .2rem .55rem; align-items: center; }
.row-end { text-align: right; flex-shrink: 0; }
.row-end b { display: block; font-variant-numeric: tabular-nums; }
.row-end small { color: var(--muted); font-size: .76rem; }
.day-sep { padding: .55rem 1.25rem; background: var(--surface-2); font-size: .8rem; font-weight: 700; color: var(--muted); display: flex; justify-content: space-between; border-top: 1px solid var(--line); }

/* Tarjetas de catálogo */
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1rem; height: 100%; display: flex; flex-direction: column; gap: .6rem; color: var(--ink); cursor: pointer; transition: border-color .15s; position: relative; }
.tile:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); }
.tile-head { display: flex; gap: .75rem; align-items: center; min-width: 0; }
.tile-head b { display: block; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; margin-top: auto; padding-top: .6rem; border-top: 1px dashed var(--line); }
.tile-stats small { display: block; color: var(--muted); font-size: .7rem; font-weight: 600; }
.tile-stats span { font-weight: 700; font-size: .88rem; font-variant-numeric: tabular-nums; }

/* Filtros */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.filters .search { flex: 1 1 220px; }
.filters .form-control, .filters .form-select { height: 42px; }
.filters .f-w { flex: 0 1 180px; }
@media (max-width: 575.98px) { .filters .f-w { flex: 1 1 calc(50% - .5rem); } }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 3px; gap: 3px; width: 100%; }
.seg .btn { flex: 1; border: 0; border-radius: 9px; color: var(--muted); font-size: .9rem; }
.seg .btn-check:checked + .btn { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* Estados vacíos y carga */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); max-width: 440px; margin: 0 auto; }
.empty-state > i { font-size: 2.4rem; color: var(--primary); display: block; margin-bottom: .6rem; }
.empty-state h3 { color: var(--ink); font-size: 1.15rem; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: var(--r-md); }
.h-title { height: 28px; width: 40%; margin-bottom: 1rem; } .h-card { height: 96px; } .h-big { height: 260px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { transition: none !important; } }

/* ---------- La boleta (revisión del escaneo) ---------- */
.ticket { background: var(--paper); color: var(--paper-ink); border-radius: 4px 4px 0 0; position: relative; padding: 1.25rem 1.25rem 1.6rem; box-shadow: var(--shadow-2); }
.ticket::after { content: ''; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px;
  background: linear-gradient(-45deg, transparent 7px, var(--paper) 0) 0 0 / 14px 10px repeat-x, linear-gradient(45deg, transparent 7px, var(--paper) 0) 0 0 / 14px 10px repeat-x; }
.ticket-head { text-align: center; border-bottom: 1px dashed color-mix(in srgb, var(--paper-ink) 30%, transparent); padding-bottom: .9rem; margin-bottom: .9rem; }
.ticket-head input { text-align: center; }
.ticket .mono, .ticket-raw { font-family: var(--mono); font-size: .78rem; letter-spacing: .02em; color: color-mix(in srgb, var(--paper-ink) 65%, transparent); }
.ticket-total { display: flex; justify-content: space-between; align-items: center; border-top: 2px dashed color-mix(in srgb, var(--paper-ink) 35%, transparent); margin-top: 1rem; padding-top: .9rem; font-weight: 800; font-size: 1.15rem; }
.t-input { border: 0; border-bottom: 1px dashed color-mix(in srgb, var(--paper-ink) 25%, transparent); background: transparent; color: inherit; border-radius: 0; padding: .2rem .1rem; width: 100%; font-weight: 600; }
.t-input:focus { outline: 0; border-bottom: 2px solid var(--primary); }

.scan-item { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: .85rem .9rem; margin-bottom: .7rem; position: relative; }
.scan-item.doubt { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.scan-item.resolved { border-color: color-mix(in srgb, var(--primary) 50%, var(--line)); }
.scan-item .grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
@media (max-width: 575.98px) { .scan-item .grid-4 { grid-template-columns: repeat(2, 1fr); } }
.scan-item label { font-size: .72rem; font-weight: 700; color: var(--muted); margin-bottom: .15rem; }
.doubt-box { background: var(--amber-soft); border-radius: var(--r-sm); padding: .65rem .75rem; margin-bottom: .7rem; font-size: .9rem; }
.doubt-box b { display: block; margin-bottom: .45rem; }
.doubt-box .btn { font-size: .85rem; }
.match-tag { font-size: .76rem; font-weight: 600; display: inline-flex; align-items: center; gap: .3rem; }
.match-tag.new { color: var(--primary); } .match-tag.exist { color: #2B8FD6; }

.dropzone { border: 2px dashed color-mix(in srgb, var(--primary) 45%, var(--line)); border-radius: var(--r-lg); background: var(--surface); text-align: center; padding: 2.2rem 1.25rem; cursor: pointer; transition: background .15s; display: block; }
.dropzone:hover, .dropzone.drag { background: var(--primary-soft); }
.dropzone .cam { width: 76px; height: 76px; border-radius: 24px; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 2rem; margin-bottom: .9rem; }
[data-bs-theme="dark"] .dropzone .cam { color: #062a24; }
.scan-progress { text-align: center; padding: 2rem 1rem; }
.scan-photo { position: relative; max-width: 320px; margin: 0 auto 1.2rem; border-radius: var(--r-md); overflow: hidden; }
.scan-photo img { width: 100%; display: block; }
.scan-photo::after { content: ''; position: absolute; left: 0; right: 0; height: 3px; background: var(--primary); box-shadow: 0 0 16px 3px var(--primary); animation: scanline 1.8s ease-in-out infinite alternate; }
@keyframes scanline { from { top: 4%; } to { top: 94%; } }
.sticky-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); padding: .75rem 0; margin-top: .5rem; z-index: 5; display: flex; gap: .5rem; align-items: center; }
@media (max-width: 991.98px) { .sticky-actions { bottom: calc(66px + env(safe-area-inset-bottom)); } }

/* ---------- Inicio ---------- */
.hero-budget { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.35rem 1.4rem; position: relative; overflow: hidden; }
.hero-budget .left-amt { font-size: clamp(2rem, 5vw, 2.9rem); font-weight: 800; letter-spacing: -.035em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.hero-budget .left-amt.over { color: var(--danger); }
.hero-budget .sub { color: var(--muted); font-weight: 500; }
.hero-budget .meter { margin: 1rem 0 .5rem; }
.hero-legend { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .3rem; font-size: .82rem; color: var(--muted); font-weight: 600; }
.hero-legend b { color: var(--ink); }
.hero-tip { display: inline-flex; align-items: center; gap: .45rem; margin-top: .8rem; padding: .4rem .75rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; font-size: .85rem; }
.hero-tip.warn { background: var(--amber-soft); color: color-mix(in srgb, var(--amber) 70%, var(--ink)); }
.hero-tip.over { background: var(--danger-soft); color: var(--danger); }
.chart-box { position: relative; height: 260px; }
.cat-legend .row-item { padding: .55rem 0; border: 0; }

/* ---------- Asistente ---------- */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - var(--top-h) - 3.5rem); min-height: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
@media (max-width: 991.98px) { .chat-wrap { height: calc(100vh - var(--top-h) - 120px - env(safe-area-inset-bottom)); } }
.chat-log { flex: 1; overflow-y: auto; padding: 1.1rem; display: flex; flex-direction: column; gap: .75rem; }
.bubble { max-width: min(78ch, 86%); padding: .7rem .95rem; border-radius: 16px; line-height: 1.5; font-size: .95rem; }
.bubble.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 5px; }
[data-bs-theme="dark"] .bubble.user { color: #062a24; }
.bubble.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 5px; }
.bubble.assistant p:last-child, .bubble.assistant ul:last-child { margin-bottom: 0; }
.chat-input { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--line); background: var(--surface); }
.chat-input textarea { resize: none; max-height: 140px; }
.suggest { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1.1rem .75rem; }
.suggest button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; font-size: .82rem; padding: .35rem .8rem; color: var(--ink); font-weight: 500; }
.suggest button:hover { border-color: var(--primary); color: var(--primary); }
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin: 0 2px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- Avisos ---------- */
.alert-menu { width: min(360px, 92vw); padding: 0; max-height: 70vh; overflow-y: auto; border-radius: var(--r-md); border-color: var(--line); }
.alert-menu-head { padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.alert-item { display: flex; gap: .7rem; padding: .7rem 1rem; color: var(--ink); border-bottom: 1px solid var(--line); font-size: .88rem; }
.alert-item:hover { background: var(--surface-2); color: var(--ink); }
.alert-item.unread { background: var(--primary-soft); }
.alert-item small { display: block; color: var(--muted); font-size: .75rem; }
.alert-empty { padding: 1.5rem; text-align: center; color: var(--muted); font-size: .88rem; }
.alert-empty i { font-size: 1.6rem; }
.status-pill { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; padding: .25rem .65rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.status-pill.on { background: var(--primary-soft); color: var(--primary-ink); }
.status-pill.off { background: var(--danger-soft); color: var(--danger); }

/* ---------- Instalación PWA ---------- */
.install-banner { position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 140%); width: min(460px, calc(100vw - 24px)); z-index: 1090; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: .8rem .9rem; display: flex; align-items: center; gap: .75rem; transition: transform .35s ease; }
.install-banner.show { transform: translate(-50%, 0); }
.install-banner img { border-radius: 12px; }
.install-banner b { display: block; } .install-banner small { color: var(--muted); font-size: .8rem; line-height: 1.3; display: block; }
@media (max-width: 991.98px) { .app-body .install-banner { bottom: calc(80px + env(safe-area-inset-bottom)); } }

/* ---------- Integraciones visuales ---------- */
.gc-swal { border-radius: var(--r-lg) !important; background: var(--surface) !important; color: var(--ink) !important; font-family: var(--font); }
.gc-swal .swal2-title { font-size: 1.3rem; } .gc-swal .swal2-html-container { color: var(--muted); font-size: .98rem; }
.gc-toast { background: var(--surface) !important; color: var(--ink) !important; box-shadow: var(--shadow-2) !important; }
.modal-content { border-radius: var(--r-lg); border-color: var(--line); background: var(--surface); }
.modal-header, .modal-footer { border-color: var(--line); }
@media (max-width: 575.98px) { .modal-content { border-radius: 0; } }
.select2-container--bootstrap-5 .select2-selection { border-color: var(--line); background-color: var(--surface); border-radius: var(--r-sm); min-height: 42px; }
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { color: var(--ink); }
.select2-container--bootstrap-5 .select2-dropdown { background: var(--surface); border-color: var(--line); color: var(--ink); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--highlighted { background: var(--primary-soft); color: var(--primary-ink); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--selected { background: var(--primary); color: #fff; }
.select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.select2-container--bootstrap-5.select2-container--focus .select2-selection, .select2-container--bootstrap-5.select2-container--open .select2-selection { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .18); }
.select2-container { z-index: 1060; }
.s2-opt { display: flex; align-items: center; gap: .5rem; } .s2-opt small { color: var(--muted); margin-left: auto; }
.img-pick { display: flex; align-items: center; gap: .9rem; }
.img-pick img, .img-pick .ph { width: 76px; height: 76px; border-radius: 16px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1.6rem; }
.receipt-thumb { width: 100%; max-height: 360px; object-fit: contain; border-radius: var(--r-md); background: var(--surface-2); cursor: zoom-in; }
.loader-block { padding-top: .25rem; }
.help-doc { max-width: 76ch; }
.help-doc h2 { font-size: 1.15rem; margin-top: 1.6rem; } .help-doc h3 { font-size: 1rem; margin-top: 1.1rem; }
.help-doc li { margin-bottom: .3rem; }
.toc a { display: block; padding: .3rem 0; font-weight: 600; font-size: .9rem; }
.pct-badge { font-weight: 700; font-size: .85rem; }
.pct-badge.ok { color: var(--primary); } .pct-badge.aviso { color: var(--amber); } .pct-badge.excedido { color: var(--danger); }
.min-w-0{min-width:0}
.btn-outline-primary { --bs-btn-color: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary); --bs-btn-hover-border-color: var(--primary); --bs-btn-hover-color: #fff; --bs-btn-active-bg: var(--primary-ink); --bs-btn-active-border-color: var(--primary-ink); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--primary); --bs-nav-link-color: var(--muted); --bs-nav-link-hover-color: var(--ink); }
.text-primary { color: var(--primary) !important; }
.form-range::-webkit-slider-thumb { background: var(--primary); } .form-range::-moz-range-thumb { background: var(--primary); }
