/* =============================================
   SEGUIMIENTO – PREMIUM CSS
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0f1a;
  --bg2:       #131626;
  --bg3:       #1a1f35;
  --card:      #1e2540;
  --card2:     #242b4a;
  --border:    #2d3560;
  --accent:    #6c63ff;
  --accent2:   #a78bfa;
  --gas:       #f97316;
  --epe:       #facc15;
  --agua:      #38bdf8;
  --necochea:  #34d399;
  --zeballos:  #f472b6;
  --text:      #e2e8f0;
  --text2:     #94a3b8;
  --text3:     #64748b;
  --green:     #22c55e;
  --red:       #ef4444;
  --radius:    14px;
  --radius-sm: 8px;
  --shadow:    0 8px 32px rgba(0,0,0,0.4);
  --glow:      0 0 20px rgba(108,99,255,0.25);
  --sidebar-w: 220px;
  --topbar-h:  64px;
  --transition: 0.22s cubic-bezier(.4,0,.2,1);
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.4rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 1.2rem;
  box-shadow: var(--glow);
}
.logo-text { font-size: 1.15rem; font-weight: 700; color: var(--text); }

.sidebar-nav {
  flex: 1;
  padding: 1.2rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(108,99,255,.22), rgba(167,139,250,.1));
  color: var(--accent2);
  border-left: 3px solid var(--accent);
  padding-left: calc(1rem - 3px);
  box-shadow: var(--glow);
}
.nav-icon { font-size: 1.1rem; min-width: 1.3rem; text-align: center; }
.nav-badge {
  margin-left: auto;
  min-width: 1.25rem;
  padding: .05rem .42rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  text-align: center;
  color: #fff;
  background: var(--red);
}
.nav-badge.venc-amarillo { background: #f59e0b; color: #1a1a1a; }
.nav-badge.venc-rojo     { background: var(--red); color: #fff; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}
.sidebar-version { font-size: .75rem; color: var(--text3); }

/* ========== MAIN ========== */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0; /* evita que el min-content de hijos fuerce overflow horizontal */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* ========== TOPBAR ========== */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: rgba(13,15,26,.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.75rem;
}
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 1.4rem;
  cursor: pointer;
  padding: .3rem;
}
.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(108,99,255,.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(108,99,255,.5); }
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-danger { background: rgba(239,68,68,.18); color: var(--red); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.3); }
.btn-edit { background: rgba(108,99,255,.18); color: var(--accent2); border: 1px solid rgba(108,99,255,.3); }
.btn-edit:hover { background: rgba(108,99,255,.3); }

/* ========== CONTENT ========== */
.content { padding: 1.75rem; flex: 1; }

/* ========== PAGE ========== */
.page { display: none; animation: fadeIn .3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }

.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.page-subtitle { color: var(--text2); font-size: .9rem; margin-top: .3rem; }

/* ========== FILTER BAR ========== */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1.2rem;
  margin-bottom: 1.5rem;
}
.filter-bar label { font-size: .8rem; color: var(--text2); font-weight: 500; white-space: nowrap; }
.filter-bar select,
.filter-bar input {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .4rem .75rem;
  font-size: .85rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
}
.search-input { min-width: 180px; }
.filter-bar select:focus,
.filter-bar input:focus { outline: 2px solid var(--accent); }

/* ========== CARD ========== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: .95rem; font-weight: 700; color: var(--text); }

/* ========== KPI GRID ========== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-color, var(--accent));
  border-radius: var(--radius) var(--radius) 0 0;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.kpi-label { font-size: .78rem; color: var(--text2); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1; }
.kpi-sub { font-size: .78rem; color: var(--text3); }
.kpi-icon { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); font-size: 2rem; opacity: .12; }
.kpi-delta {
  font-size: .8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: .2rem;
}
.kpi-delta.up { color: var(--red); }
.kpi-delta.down { color: var(--green); }
/* ========== DOMICILIO BLOCKS ========== */
.domicilio-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  position: relative;
}
.domicilio-block.necochea-block {
  border-top: 3px solid var(--necochea);
}
.domicilio-block.zeballos-block {
  border-top: 3px solid var(--zeballos);
}
.domicilio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.domicilio-title-wrap {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.domicilio-icon {
  font-size: 1.6rem;
  line-height: 1;
}
.domicilio-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.domicilio-sub {
  font-size: .8rem;
  color: var(--text3);
}
.kpi-grid.domicilio-kpis {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 1.25rem;
}
.kpi-global {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 1.5rem;
}

/* ========== CHARTS LAYOUT ========== */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1rem;
  margin-bottom: 1rem;
}
.charts-row.two-equal {
  grid-template-columns: 1fr 1fr;
}
.charts-row.three-cols {
  grid-template-columns: 1fr 1fr 1.3fr;
}
@media (max-width: 1080px) {
  .charts-row.two-equal,
  .charts-row.three-cols {
    grid-template-columns: 1fr;
  }
}
.chart-card { min-height: 0; }
.chart-card.wide { grid-column: auto; }
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
  gap: 1rem;
}

/* ========== GRAFICOS PAGE SECTIONS ========== */
.graficos-section {
  margin-bottom: 2rem;
}
.graficos-section-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
  padding-bottom: .6rem;
  border-bottom: 2px solid var(--border);
}
.graficos-section-header.necochea { border-color: var(--necochea); }
.graficos-section-header.zeballos { border-color: var(--zeballos); }
.graficos-section-icon { font-size: 1.4rem; }
.graficos-section-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.graficos-section-sub { font-size: .8rem; color: var(--text3); }

/* ========== TABLE ========== */
.table-wrapper { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.data-table th {
  padding: .7rem 1rem;
  text-align: left;
  background: var(--bg3);
  color: var(--text2);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: .7rem 1rem;
  border-bottom: 1px solid rgba(45,53,96,.5);
  color: var(--text);
  white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg3); }

/* ========== BADGES ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .22rem .6rem;
  border-radius: 99px;
  font-size: .73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-gas    { background: rgba(249,115,22,.2);  color: var(--gas);  }
.badge-epe    { background: rgba(250,204,21,.2);  color: var(--epe);  }
.badge-agua   { background: rgba(56,189,248,.2);  color: var(--agua); }
.badge-tgi    { background: rgba(167,139,250,.2); color: #a78bfa; }
.badge-otro   { background: rgba(108,99,255,.2);  color: var(--accent2); }
.badge-nec    { background: rgba(52,211,153,.15); color: var(--necochea); }
.badge-zeb    { background: rgba(244,114,182,.15);color: var(--zeballos); }
.badge-r      { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-e      { background: rgba(250,204,21,.15); color: var(--epe); }
.badge-a      { background: rgba(56,189,248,.15); color: var(--agua); }
.badge-rojo   { background: rgba(239,68,68,.15);  color: var(--red); }
.badge-verde  { background: rgba(34,197,94,.15);  color: var(--green); }

/* ========== PAGINATION ========== */
.table-pagination {
  display: flex;
  align-items: center;
  gap: .5rem;
  justify-content: flex-end;
  padding: .75rem .5rem 0;
  border-top: 1px solid var(--border);
  margin-top: .5rem;
}
.page-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: .35rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  cursor: pointer;
  transition: all var(--transition);
}
.page-btn:hover, .page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-info { font-size: .8rem; color: var(--text3); margin: 0 .5rem; }

/* ========== TABS ========== */
.tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.tab {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: .55rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.tab:hover { background: var(--bg3); color: var(--text); }
.tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(108,99,255,.35);
}

.comp-panel { display: none; }
.comp-panel.active { display: block; }

/* ========== SERVICES GRID ========== */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.service-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
.service-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  background: var(--svc-color, var(--accent));
}
.service-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.svc-card-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
}
.svc-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 1.3rem;
  background: var(--svc-bg, rgba(108,99,255,.2));
}
.svc-name { font-size: 1rem; font-weight: 700; }
.svc-desc { font-size: .8rem; color: var(--text2); margin-bottom: .75rem; }
.svc-stats {
  display: flex;
  gap: 1rem;
  font-size: .82rem;
  color: var(--text3);
}
.svc-stat span { color: var(--text); font-weight: 600; }

/* ========== MODAL ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  z-index: 400;
}
.modal-overlay.active { display: block; }
.modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: min(680px, 95vw);
  max-height: 90vh;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 500;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
  animation: modalIn .25s ease;
}
.modal.active { display: flex; flex-direction: column; }
@keyframes modalIn { from{opacity:0;transform:translate(-50%,-46%)} to{opacity:1;transform:translate(-50%,-50%)} }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none; border: none;
  color: var(--text2); font-size: 1.2rem;
  cursor: pointer; padding: .3rem .5rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg3);
}

/* ========== FORM ========== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; }
.form-group input,
.form-group select {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .55rem .85rem;
  font-size: .9rem;
  font-family: 'Inter', sans-serif;
  transition: border-color var(--transition);
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,.2);
}
.form-group input::placeholder { color: var(--text3); }

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1.25rem;
  color: var(--text);
  font-size: .875rem;
  font-weight: 500;
  z-index: 999;
  box-shadow: var(--shadow);
  transform: translateY(120%);
  transition: transform .3s ease;
  pointer-events: none;
}
.toast.show { transform: translateY(0); }
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }

/* ========== OFFLINE BANNER ========== */
.offline-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--red);
  color: #fff;
  text-align: center;
  padding: .5rem 1rem;
  font-size: .8rem;
  font-weight: 600;
  z-index: 1200;
  transform: translateY(-100%);
  transition: transform .3s ease;
}
.offline-banner.show { transform: translateY(0); }

/* ========== LOGOUT ========== */
.logout-btn {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  text-align: left;
}
.logout-btn:hover { color: var(--red); }

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text3);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { font-size: .9rem; }

/* ========== DELTA CELLS ========== */
.delta-up   { color: var(--red);   font-weight: 600; }
.delta-down { color: var(--green); font-weight: 600; }
.delta-zero { color: var(--text3); }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.7); }
  .main-wrapper { margin-left: 0; }
  .hamburger { display: block; }
  .charts-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .content { padding: 1rem; }
  .kpi-value { font-size: 1.3rem; }
}

/* ========== PLANES DE AHORRO ========== */
.plan-header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--plan-color, var(--accent));
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.plan-header-left { display: flex; align-items: center; gap: 1.25rem; }
.plan-icon-big {
  width: 58px; height: 58px;
  font-size: 2rem;
  border-radius: 14px;
  background: var(--plan-bg, rgba(108,99,255,.15));
  display: grid; place-items: center;
  flex-shrink: 0;
}
.plan-nombre { font-size: 1.15rem; font-weight: 800; margin-bottom: .3rem; }
.plan-desc { font-size: .82rem; color: var(--text2); margin-bottom: .5rem; }
.plan-tags { display: flex; flex-wrap: wrap; gap: .4rem; }

.plan-progress-wrap { min-width: 220px; }
.plan-progress-label { font-size: .78rem; color: var(--text2); margin-bottom: .4rem; font-weight: 500; }
.plan-progress-bar-outer {
  width: 100%;
  height: 8px;
  background: var(--bg3);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: .4rem;
}
.plan-progress-bar-inner {
  height: 100%;
  border-radius: 99px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.plan-progress-pct { font-size: .9rem; font-weight: 700; }

/* KPIs de plan */
.plan-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}
.plan-kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--plan-color, var(--accent));
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  transition: all var(--transition);
}
.plan-kpi-card:hover { background: var(--card2); transform: translateY(-2px); }
.plan-kpi-icon { font-size: 1.5rem; }
.plan-kpi-label { font-size: .72rem; color: var(--text2); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.plan-kpi-value { font-size: 1.05rem; font-weight: 800; color: var(--text); }

/* Pending row */
.row-pending td { opacity: .7; font-style: italic; }

/* =============================================
   QUINI 6 STYLES
   ============================================= */

/* Quini Segmented Tabs */
.quini-tabs {
  display: inline-flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.75);
  padding: 0.35rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 20px -4px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.05);
  margin-bottom: 2rem;
  gap: 0.35rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.quini-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1.4rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  user-select: none;
}
.quini-tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}
.quini-tab-btn.active {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  font-weight: 700;
  border-color: rgba(165, 180, 252, 0.35);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}
.quini-tab-icon {
  font-size: 1.15rem;
  transition: transform 0.2s ease;
}
.quini-tab-btn:hover .quini-tab-icon {
  transform: scale(1.15);
}
.quini-tab-btn.active .quini-tab-icon {
  transform: scale(1.1);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Hero / Banner Pozo */
.quini-hero-card {
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.9) 0%, rgba(20, 15, 45, 0.95) 100%);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  box-shadow: 0 10px 30px -10px rgba(99, 102, 241, 0.25);
  position: relative;
  overflow: hidden;
}
.quini-hero-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  pointer-events: none;
}
.quini-badge-sorteo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.35rem 0.85rem;
  border-radius: 99px;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.quini-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse-green 1.8s infinite;
}
@keyframes pulse-green {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}
.quini-pozo-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #94a3b8;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.quini-pozo-val {
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #facc15 0%, #f59e0b 50%, #f43f5e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(250, 204, 21, 0.25);
  line-height: 1.1;
  margin-bottom: 0.5rem;
}
.quini-prox-sorteo {
  font-size: 0.9rem;
  color: #cbd5e1;
  font-weight: 500;
}
.quini-hero-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
}
.btn-quini-refresh {
  padding: 0.75rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(108, 99, 255, 0.35);
}
.quini-sync-time {
  font-size: 0.75rem;
  color: var(--text2);
}

/* Alerta de Ganador */
.quini-alert-win {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(5, 150, 105, 0.3) 100%);
  border: 1px solid #10b981;
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}
.quini-alert-icon { font-size: 2rem; }
.quini-alert-win strong { font-size: 1.05rem; color: #34d399; }
.quini-alert-win p { margin: 0; font-size: 0.9rem; color: #e2e8f0; }

/* Bolillas de Lotería */
.quini-balls-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.quini-balls-wrap {
  gap: 0.45rem;
}
.quini-ball {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
  color: #ffffff;
  position: relative;
  background: radial-gradient(circle at 35% 30%, #334155, #0f172a);
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.3), 0 4px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
}
.quini-ball:hover {
  transform: translateY(-2px) scale(1.05);
}
.quini-ball-official {
  background: radial-gradient(circle at 35% 30%, #4338ca, #1e1b4b);
  border-color: rgba(99, 102, 241, 0.6);
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.4), 0 4px 10px rgba(99, 102, 241, 0.3);
}

/* Bolilla acertada por el usuario (HIT) */
.quini-ball-hit {
  background: radial-gradient(circle at 35% 30%, #10b981, #065f46) !important;
  border-color: #34d399 !important;
  color: #ffffff !important;
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.6), 0 0 16px rgba(16, 185, 129, 0.6) !important;
  animation: hit-pulse 2s infinite ease-in-out;
}
@keyframes hit-pulse {
  0% { box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.6), 0 0 10px rgba(16, 185, 129, 0.4); }
  50% { box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.6), 0 0 22px rgba(16, 185, 129, 0.8); }
  100% { box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.6), 0 0 10px rgba(16, 185, 129, 0.4); }
}
.quini-ball-check {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #34d399;
  color: #064e3b;
  font-size: 0.65rem;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.quini-ball-placeholder {
  background: transparent;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  color: var(--text-light);
  box-shadow: none;
}
.quini-ball-selected {
  background: radial-gradient(circle at 35% 30%, #6366f1, #3730a3);
  border-color: #a5b4fc;
  cursor: pointer;
}

/* Modalidades Grid */
.quini-mod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.25rem;
}
.quini-mod-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  transition: all var(--transition);
}
.quini-mod-card:hover {
  background: var(--card2);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}
.quini-mod-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.quini-mod-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.quini-mod-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  letter-spacing: 0.04em;
}

/* Boletas Grid & Card */
.quini-boletas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
}
.quini-boleta-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: all var(--transition);
}
.quini-boleta-card:hover {
  border-color: rgba(99, 102, 241, 0.35);
  transform: translateY(-2px);
}
.quini-boleta-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.quini-boleta-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
  display: block;
}
.quini-boleta-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}
.quini-boleta-actions {
  display: flex;
  gap: 0.4rem;
}

/* Escrutinio por modalidad en la boleta */
.quini-cotejo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.quini-cotejo-col {
  text-align: center;
  padding: 0.35rem 0.25rem;
  border-radius: 6px;
}
.quini-cotejo-name {
  font-size: 0.72rem;
  color: var(--text2);
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quini-aciertos-pill {
  font-size: 0.78rem;
  padding: 0.2rem 0.4rem;
  border-radius: 99px;
  font-weight: 600;
  display: inline-block;
}
.quini-acierto-zero {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-light);
}
.quini-acierto-med {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}
.quini-acierto-high {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.5);
  font-weight: 800;
}
.quini-winner-col {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.quini-premio-tag {
  font-size: 0.7rem;
  font-weight: 800;
  color: #34d399;
  margin-top: 0.3rem;
  line-height: 1.1;
}

/* Selector numérico táctil (Picker) */
.quini-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 0.5rem;
  max-height: 250px;
  overflow-y: auto;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.quini-picker-ball {
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--card2);
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.quini-picker-ball:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  transform: scale(1.1);
}
.quini-picker-ball.selected {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border-color: #34d399;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
  transform: scale(1.05);
}
.quini-balls-preview-row {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.85rem;
  border-radius: var(--radius-sm);
}

/* Spinner */
.quini-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 0.4rem;
}
.quini-spinner-large {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0 auto 1rem;
}
.quini-loading-spinner {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  color: var(--text2);
}

/* Tabla de ganadores */
.quini-table tbody tr td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
}
.quini-jackpot-row {
  background: rgba(250, 204, 21, 0.05);
}
.quini-vacante-tag {
  color: #fbbf24;
  font-weight: 700;
  font-size: 0.85rem;
}
.quini-ganador-tag {
  color: #34d399;
  font-weight: 700;
  font-size: 0.85rem;
}
.quini-empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text2);
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Estilos de Historial Quini */
.quini-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}
.quini-hist-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}
.quini-hist-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
}
.quini-hist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.quini-hist-boletas-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.quini-hist-boleta-row {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid transparent; /* override por JS */
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  transition: background var(--transition), transform 0.15s ease;
}
.quini-hist-boleta-row:hover {
  transform: translateX(2px);
  filter: brightness(1.08);
}
.quini-hist-boleta-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Panel de Importación Histórica */
.quini-import-panel {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.85) 0%, rgba(30, 27, 75, 0.6) 100%);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 24px -8px rgba(99, 102, 241, 0.2);
}
.quini-import-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.quini-import-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.25rem;
}
.quini-import-desc {
  font-size: 0.82rem;
  color: var(--text2);
  margin: 0;
}
.quini-import-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.quini-import-select {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.quini-import-select:focus {
  border-color: var(--accent);
}
.quini-import-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.88rem;
  color: var(--text2);
}
.quini-import-icon {
  font-size: 1rem;
}

/* Botón acento (morado/indigo) */
.btn-accent {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.btn-accent:hover {
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}
.btn-accent:active {
  transform: translateY(0);
}
.btn-accent:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Acordeón y detalles en Historial */
.quini-hist-details {
  margin: 1rem 0;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.quini-hist-summary {
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: all var(--transition);
}
.quini-hist-summary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.quini-hist-summary::-webkit-details-marker {
  display: none;
}
.quini-hist-details[open] .quini-summary-arrow {
  transform: rotate(180deg);
}
.quini-summary-arrow {
  transition: transform 0.2s ease;
  font-size: 0.75rem;
}
.quini-hist-official-grid {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}
.quini-hist-mod-box {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.quini-hist-mod-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Buscador y Controles en Historial */
.quini-hist-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.quini-hist-search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  gap: 0.5rem;
  flex: 1;
  max-width: 380px;
  transition: border-color var(--transition);
}
.quini-hist-search-box:focus-within {
  border-color: var(--accent);
}
.quini-hist-search-box input {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  width: 100%;
}
.quini-search-clear {
  background: transparent;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 0.2rem;
}
.quini-search-clear:hover {
  color: var(--text);
}

/* Bola de número oficial jugado por una boleta específica */
.quini-ball-jugado {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 800;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: default;
}
.quini-ball-jugado:hover {
  transform: scale(1.18);
}

/* Badge: Jugué / Importado */
.quini-jugado-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.quini-jugado-si {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.quini-jugado-no {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.quini-hist-card-nojugado {
  opacity: 0.75;
}
.quini-hist-card-nojugado:hover {
  opacity: 1;
}

/* Toggle botón jugado — clickeable */
button.quini-jugado-btn {
  cursor: pointer;
  font-family: inherit;
  transition: all 0.18s ease;
  user-select: none;
}
button.quini-jugado-btn:hover {
  transform: scale(1.05);
  filter: brightness(1.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
button.quini-jugado-btn:active {
  transform: scale(0.97);
}

/* Badge de cuántos números jugados coincidieron en cada modalidad */
.quini-mod-match-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  margin-left: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Leyenda inferior del acordeón oficial */
.quini-official-legend {
  padding: 0.6rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.05);
  font-size: 0.78rem;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* =============================================
   RESPONSIVE MÓVIL (mejoras pantallas chicas)
   ============================================= */
@media (max-width: 900px) {
  /* Grids con mínimos que desbordan en tablets/celu */
  .quini-boletas-grid { grid-template-columns: 1fr; gap: 1rem; }
  .quini-mod-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  /* Estructura general */
  .topbar { padding: 0 .85rem; gap: .6rem; }
  .topbar-title { font-size: .95rem; }
  .topbar .btn { padding: .45rem .8rem; font-size: .8rem; white-space: nowrap; }
  .page-header h1 { font-size: 1.3rem; }
  .page-subtitle { font-size: .82rem; }
  .card { padding: 1rem; }
  .domicilio-block { padding: 1rem; }

  /* KPIs en 2 columnas compactas */
  .kpi-grid, .kpi-global, .kpi-grid.domicilio-kpis {
    grid-template-columns: repeat(2, 1fr);
    gap: .6rem;
  }
  .kpi-card { padding: .85rem; }
  .kpi-value { font-size: 1.1rem; word-break: break-word; }
  .kpi-label { font-size: .68rem; }
  .kpi-icon { font-size: 1.4rem; right: .6rem; }

  /* Filtros */
  .filter-bar { padding: .7rem .8rem; gap: .5rem; }
  .search-input { min-width: 0; flex: 1; }

  /* Tablas más densas */
  .data-table th, .data-table td { padding: .5rem .6rem; font-size: .8rem; }

  /* Modales a pantalla completa */
  .modal {
    top: 0; left: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    animation: none;
  }
  .modal-body { padding: 1rem; }
  .modal-header, .modal-footer { padding: .85rem 1rem; }

  /* Toast ancho completo */
  .toast { left: 1rem; right: 1rem; bottom: 1rem; text-align: center; }

  /* Quini: tabs a ancho completo */
  .quini-tabs { display: flex; width: 100%; margin-bottom: 1.25rem; }
  .quini-tab-btn { flex: 1; justify-content: center; padding: .6rem .4rem; font-size: .82rem; gap: .35rem; }
  .quini-tab-icon { font-size: 1rem; }

  /* Quini: banner */
  .quini-hero-card { padding: 1.25rem; gap: 1rem; }
  .quini-hero-right { align-items: stretch; width: 100%; }
  .btn-quini-refresh { width: 100%; justify-content: center; }
  .quini-pozo-val { font-size: 1.9rem; }

  /* Quini: bolillas más chicas */
  .quini-ball { width: 38px; height: 38px; font-size: .92rem; }
  .quini-balls-row { gap: .4rem; }
  .quini-balls-preview-row { flex-wrap: wrap; gap: .5rem; }

  /* Quini: tarjetas más compactas */
  .quini-boleta-card { padding: 1rem; }
  .quini-hist-card { padding: 1rem; }
  .quini-hist-boleta-row { padding: .75rem .8rem; }
  .quini-hist-header { gap: .5rem; }
  .quini-import-panel { padding: 1rem; }
  .quini-cotejo-grid { gap: .35rem; padding: .5rem; }

  /* Selector de números: ocupa mejor el alto disponible */
  .quini-picker-grid { max-height: 45vh; }
}

@media (max-width: 380px) {
  .quini-ball { width: 34px; height: 34px; font-size: .85rem; }
  .kpi-grid, .kpi-global, .kpi-grid.domicilio-kpis { grid-template-columns: 1fr 1fr; }
}

/* Hijos de grids/flex: permitir que se achiquen (evita overflow por min-content) */
.charts-row > *, .charts-grid > *, .kpi-grid > *,
.quini-mod-grid > *, .quini-boletas-grid > *, .services-grid > *,
.quini-hist-official-grid > *, .quini-kpi-grid > * { min-width: 0; }

/* ========== RECIBOS: variación mensual ========== */
.rec-var-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 600px) {
  .rec-var-grid { grid-template-columns: 1fr; }
}

/* ========== SIDEBAR OVERLAY (móvil) ========== */
.sidebar-overlay { display: none; }
@media (max-width: 900px) {
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
  }
  .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
}

/* ========== TABLAS: columnas secundarias ocultas en móvil ========== */
@media (max-width: 600px) {
  /* Registros: queda Fecha, Servicio, Estado, Total, Acciones */
  #registros-table th:nth-child(2), #registros-table td:nth-child(2),
  #registros-table th:nth-child(4), #registros-table td:nth-child(4),
  #registros-table th:nth-child(5), #registros-table td:nth-child(5),
  #registros-table th:nth-child(6), #registros-table td:nth-child(6),
  #registros-table th:nth-child(9), #registros-table td:nth-child(9) { display: none; }

  /* Dashboard "Últimos pagos": queda Fecha, Servicio, Total */
  #recent-table th:nth-child(3), #recent-table td:nth-child(3),
  #recent-table th:nth-child(4), #recent-table td:nth-child(4),
  #recent-table th:nth-child(5), #recent-table td:nth-child(5) { display: none; }

  /* Recibos: queda Período, Persona, Tipo, Neto, Acciones */
  #rec-table th:nth-child(4), #rec-table td:nth-child(4),
  #rec-table th:nth-child(5), #rec-table td:nth-child(5) { display: none; }
}





/* ========== GASTOS: alta rápida ========== */
.gasto-quick-card {
  background: linear-gradient(135deg, var(--card) 0%, rgba(108,99,255,.12) 100%);
  border: 1px solid rgba(108,99,255,.35);
  padding: 1.25rem;
}
.gasto-quick-row {
  display: flex;
  gap: .75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.gasto-quick-row + .gasto-quick-row { margin-top: .85rem; }
.gasto-quick-monto {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .4rem .85rem;
  flex: 1 1 200px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.gasto-quick-monto:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,.2);
}
.gasto-quick-monto label {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent2);
}
.gasto-quick-monto input {
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-size: 1.7rem;
  font-weight: 800;
  font-family: 'Inter', sans-serif;
  width: 100%;
  min-width: 0;
}
.gasto-quick-monto input::placeholder { color: var(--text3); font-weight: 600; }
/* Chrome: quitar spinners para un look limpio */
.gasto-quick-monto input::-webkit-outer-spin-button,
.gasto-quick-monto input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.gasto-quick-monto input[type=number] { -moz-appearance: textfield; appearance: textfield; }

.gasto-quick-fecha { display: flex; flex-direction: column; gap: .3rem; }
.gasto-quick-fecha label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.gasto-quick-fecha input {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .55rem .7rem;
  font-size: .9rem;
  font-family: 'Inter', sans-serif;
  color-scheme: dark;
}
.gasto-quick-fecha input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,.2);
}

.gasto-quick-categoria,
.gasto-quick-medio { display: flex; flex-direction: column; gap: .3rem; }
.gasto-quick-categoria label,
.gasto-quick-medio label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.gasto-quick-categoria select,
.gasto-quick-medio select {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .55rem .7rem;
  font-size: .9rem;
  font-family: 'Inter', sans-serif;
  color-scheme: dark;
  cursor: pointer;
  width: 100%;
}
.gasto-quick-categoria select:focus,
.gasto-quick-medio select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,.2);
}

.gasto-quick-row #gq-desc {
  flex: 1 1 220px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .6rem .85rem;
  font-size: .9rem;
  font-family: 'Inter', sans-serif;
}
.gasto-quick-row #gq-desc:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,.2);
}
.gasto-quick-row #gq-desc::placeholder { color: var(--text3); }
.gasto-quick-btn { padding: .6rem 1.6rem; font-size: .95rem; font-weight: 700; }

.card-sub { font-size: .8rem; color: var(--text2); font-weight: 600; }

/* ========== GASTOS: modal de categorías ========== */
.cat-add-row {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.cat-add-row input[type=text] {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .88rem;
  font-family: 'Inter', sans-serif;
}
.cat-add-row input[type=text]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,.2);
}
.cat-add-row input[type=text]:first-child { flex: 1 1 180px; }
.cat-add-row input[type=color] {
  width: 42px;
  height: 36px;
  padding: 2px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.cat-icon-input { width: 54px; text-align: center; }

.cat-list { display: flex; flex-direction: column; gap: .5rem; max-height: 46vh; overflow-y: auto; }
.cat-row {
  display: flex;
  gap: .5rem;
  align-items: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .6rem;
}
.cat-row-color {
  width: 38px;
  height: 32px;
  padding: 2px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.cat-row-icon {
  width: 58px;
  text-align-last: center;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: .3rem .1rem;
  font-size: 1rem;
  line-height: 1.2;
  cursor: pointer;
  flex-shrink: 0;
}
.cat-row-nombre {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: .4rem .6rem;
  font-size: .88rem;
  font-family: 'Inter', sans-serif;
}
.cat-row-nombre:focus, .cat-row-icon:focus, .cat-row-color:focus {
  outline: none;
  border-color: var(--accent);
}
.cat-row-count {
  font-size: .72rem;
  color: var(--text3);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ========== GASTOS: responsive ========== */
@media (max-width: 600px) {
  /* Gastos: ocultar columna "Tipo" (ya se ve en la badge de categoría) */
  #gastos-table th:nth-child(4), #gastos-table td:nth-child(4) { display: none; }

  .cat-add-row input[type=text]:first-child { flex: 1 1 100%; }
}

/* ========== MULTI-USUARIO ========== */
.hidden { display: none !important; }

/* Usuario logueado en la sidebar */
.sidebar-user {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .75rem;
  margin-bottom: .4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg3);
  cursor: pointer;
  transition: border-color var(--transition);
}
.sidebar-user:hover { border-color: var(--accent); }
.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
  border: 2px solid var(--uc, var(--accent));
  background: color-mix(in srgb, var(--uc, var(--accent)) 16%, transparent);
}
.sidebar-user-nombre { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Badge "quién" en la tabla de gastos */
.quien-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  background: color-mix(in srgb, var(--qc, var(--accent)) 15%, transparent);
  color: var(--qc, var(--accent));
  border-radius: 999px;
  padding: .15rem .6rem .15rem .15rem;
  font-size: .78rem; font-weight: 600;
  white-space: nowrap;
}
.quien-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .75rem;
  background: color-mix(in srgb, var(--qc, var(--accent)) 25%, transparent);
}
.quien-none { color: var(--text3); }

/* Lista de usuarios (Config) */
.usr-list { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.usr-row {
  display: flex; align-items: center; gap: .7rem;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .55rem .8rem;
}
.usr-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; flex-shrink: 0;
  border: 2px solid var(--uc, var(--accent));
  background: color-mix(in srgb, var(--uc, var(--accent)) 16%, transparent);
}
.usr-info { flex: 1; min-width: 0; }
.usr-nombre { font-weight: 600; font-size: .92rem; }
.usr-badge {
  background: rgba(108,99,255,.18); color: #8b83ff;
  border-radius: 999px; padding: .05rem .5rem;
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  vertical-align: middle; margin-left: .3rem;
}
.usr-badge-off { background: rgba(239,68,68,.15); color: #f87171; }

/* Form Mi PIN — grilla 2x2 alineada: actual | nuevo / repetir | guardar */
.pin-form { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.pin-form input {
  width: 100%;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  padding: .62rem .8rem; font-size: .95rem; outline: none;
  transition: border-color var(--transition);
}
.pin-form input:focus { border-color: var(--accent); }
.pin-form .btn { width: 100%; padding: .62rem .8rem; font-size: .95rem; }

@media (max-width: 600px) {
  /* Gastos: en móvil el badge "Quién" muestra solo el avatar */
  .quien-badge { padding: .15rem; }
  .quien-nombre { display: none; }
}

/* Modal usuario: preview de avatar + grilla de emojis */
.uf-color-row { display: flex; align-items: center; gap: .5rem; }
.uf-color-row input[type=color] {
  width: 44px; height: 36px; padding: 0 2px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
}
.uf-color-row input[type=text] {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text2);
  padding: .45rem .6rem; font-size: .8rem; width: 76px;
  font-family: monospace;
}
.uf-avatar-preview {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  border: 2px solid var(--uc, var(--accent));
  background: color-mix(in srgb, var(--uc, var(--accent)) 18%, transparent);
  transition: border-color var(--transition), background var(--transition);
}
.uf-emoji-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: .4rem; max-height: 148px; overflow-y: auto;
  padding: .25rem; background: var(--bg3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.uf-emoji {
  background: none; border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 1.25rem; padding: .35rem 0;
  cursor: pointer; line-height: 1;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.uf-emoji:hover { background: var(--bg2); }
.uf-emoji:active { transform: scale(.9); }
.uf-emoji.active {
  border-color: var(--accent);
  background: rgba(108,99,255,.18);
}

/* ========== GASTOS: pantalla de entrada (solo alta) ========== */
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.topbar-gastos-only { padding: .5rem .9rem; }

#page-gastos { max-width: 760px; margin: 0 auto; }
.page-back-btn { margin-top: .85rem; }

/* Formulario en columna: monto a todo el ancho (protagonista), luego Fecha +
   Categoría en la misma fila, descripción a todo el ancho y botón al final */
#page-gastos .gasto-quick-row {
  flex-direction: column;
  align-items: stretch;
  gap: .75rem;
}
#page-gastos .gasto-quick-monto { flex: none; padding: .75rem 1.1rem; }
#page-gastos .gasto-quick-monto label { font-size: 1.9rem; }
#page-gastos .gasto-quick-monto input { font-size: 2.2rem; }
/* En PC: Fecha y Categoría comparten la misma fila */
#page-gastos .gasto-quick-row.gasto-quick-fecha-cat {
  flex-direction: row;
  align-items: flex-end;
}
#page-gastos .gasto-quick-fecha { flex: 1 1 0; min-width: 0; }
#page-gastos .gasto-quick-fecha input { max-width: none; width: 100%; }
#page-gastos .gasto-quick-categoria { flex: 1 1 0; min-width: 0; }
#page-gastos .gasto-quick-categoria select { max-width: none; width: 100%; }
#page-gastos .gasto-quick-medio { flex: 1 1 0; min-width: 0; }
#page-gastos .gasto-quick-medio select { max-width: none; width: 100%; }
#page-gastos #gq-desc { flex: none !important; }
#page-gastos .gasto-quick-btn {
  width: 100%;
  justify-content: center;
  padding: .85rem 1rem;
  font-size: 1rem;
}

@media (max-width: 600px) {
  /* Entrada compacta en móvil: el topbar ya dice "Gastos", todo va a la vista sin scroll */
  #page-gastos .page-header { display: none; }

  #page-gastos .gasto-quick-card { padding: .8rem; }
  #page-gastos .gasto-quick-row { gap: .55rem; }
  #page-gastos .gasto-quick-row.gasto-quick-fecha-cat { flex-direction: column; align-items: stretch; }
  #page-gastos .gasto-quick-row + .gasto-quick-row { margin-top: .6rem; }
  #page-gastos .gasto-quick-monto { padding: .55rem .9rem; }
  #page-gastos .gasto-quick-monto label { font-size: 1.5rem; }
  #page-gastos .gasto-quick-monto input { font-size: 1.9rem; }
  #page-gastos .gasto-quick-fecha input { padding: .5rem .7rem; font-size: .9rem; }
  #page-gastos .gasto-quick-categoria select { padding: .5rem .7rem; }
  #page-gastos .gasto-quick-medio select { padding: .5rem .7rem; }
  #page-gastos #gq-desc { padding: .5rem .7rem; }
  #page-gastos .gasto-quick-btn { padding: .75rem 1rem; font-size: .95rem; }

  /* Tres botones en el topbar: los de Gastos quedan solo con ícono */
  .topbar-actions { gap: .4rem; }
  .topbar-btn-label { display: none; }
  .topbar .topbar-gastos-only { padding: .5rem .6rem; }
}

/* ========== POR VENCER (pagos recurrentes) ========== */
.venc-date { font-size: .8rem; color: var(--text2); font-weight: 600; }
.venc-badge {
  display: inline-block;
  margin-top: .2rem;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
}
.venc-rojo     { background: rgba(239,68,68,.18);  color: #f87171; }
.venc-naranja  { background: rgba(249,115,22,.18); color: #fb923c; }
.venc-amarillo { background: rgba(234,179,8,.18);  color: #facc15; }
.venc-verde    { background: rgba(52,211,153,.16); color: #34d399; }

.pagos-alert {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .9rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: .92rem;
  border-left: 4px solid transparent;
}
.pagos-alert-icon { font-size: 1.4rem; }
.pagos-alert.alert-rojo     { background: rgba(239,68,68,.15); border-left-color: var(--red); }
.pagos-alert.alert-amarillo { background: rgba(234,179,8,.12); border-left-color: #eab308; }

.btn-pagar { background: rgba(52,211,153,.18); color: #34d399; border: 1px solid rgba(52,211,153,.3); }

@media (max-width: 600px) {
  #page-pagos .filter-bar { gap: .5rem; }
  #page-pagos .filter-bar .btn { width: 100%; margin-left: 0 !important; }
}
