/* ===== Reset & base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2e3250;
  --accent:    #f97316;
  --accent2:   #3b82f6;
  --green:     #22c55e;
  --red:       #ef4444;
  --text:      #e2e8f0;
  --text-muted:#94a3b8;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,.35);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  zoom: 1;
  min-height: 100vh;
}

/* Estado de fuente de datos (live/cache) */
.source-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  padding: 4px 8px;
  border: 1px solid var(--border, #2a2a3a);
  border-radius: 999px;
  background: rgba(17, 17, 24, 0.55);
  line-height: 1;
}

.source-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
}

.source-dot--live {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.source-dot--cache {
  background: #eab308;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.18);
}

.source-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, #9191a4);
  white-space: nowrap;
}

@media (max-width: 1024px) {
  .source-indicator {
    margin-left: 6px;
    padding: 3px 7px;
  }

  .source-text {
    font-size: 10px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ============================================================
   Rediseño visual 2026-04-22 (desktop + móvil)
   Mantiene funcionalidad, solo capa visual
   ============================================================ */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #111118;
  --bg-card: #16161f;
  --bg-card-hover: #1c1c28;
  --border: #2a2a3a;
  --border-light: #333345;
  --accent: #f97316;
  --accent-hover: #ea6c0a;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --blue: #3b82f6;
  --text-primary: #f1f1f3;
  --text-secondary: #9191a4;
  --text-muted: #5a5a6e;

  /* compat con variables existentes */
  --bg: var(--bg-primary);
  --surface: var(--bg-card);
  --surface2: var(--bg-secondary);
  --text: var(--text-primary);
  --accent2: var(--blue);
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .32);
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.app {
  grid-template-rows: 60px 1fr;
}

header {
  height: 60px;
  min-height: 60px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 130;
}

.logo {
  min-width: 170px;
  gap: 10px;
}

.logo-img {
  height: 28px;
  max-height: 28px;
  max-width: 146px;
}

.logo-sub {
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .1px;
}

.header-right {
  margin-left: auto;
  gap: 10px;
}

.header-right > * + * {
  position: relative;
}

.header-right > * + *::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  width: 1px;
  height: 20px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, .08);
}

#fecha-hoy {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  text-transform: lowercase;
  pointer-events: none;
  white-space: nowrap;
}

.date-nav {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 6px;
  background: var(--bg-card);
}

.date-nav-label {
  display: none !important;
}

.date-input {
  color: var(--text-primary);
}

.btn-refresh,
.btn-secondary,
.btn-logout,
.btn-clear-filtros,
.btn-export {
  height: 36px;
  border-radius: 8px;
}

.btn-refresh {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  padding: 0 14px;
}

.btn-refresh:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary,
.btn-logout,
.btn-clear-filtros {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.user-info {
  border-left: none;
  padding-left: 0;
}

.user-name {
  color: var(--text-secondary);
}

.tabs {
  background: transparent;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  gap: 0;
  margin-bottom: 18px;
  height: auto;
}

.tab-btn {
  font-size: 14px;
  font-weight: 600;
  padding: 12px 16px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-btn .ico {
  display: none !important;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: none;
}

.kpi-card.clickable:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: none;
}

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.kpi-delta {
  margin-top: 10px;
  font-size: 11px;
  display: inline-flex;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 600;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
}

.chart-card > h3 {
  margin: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.chart-card > .chart-wrap,
.chart-card > .table-wrap,
.chart-card > .kpi-grid,
.chart-card > .filtros-bar,
.chart-card > p,
.chart-card > div:not(h3) {
  padding: 14px 20px;
}

.table-wrap {
  border: 0;
  border-radius: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

thead th {
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  background: var(--bg-card);
}

tbody tr:nth-child(even) {
  background: #1a1a24;
}

tbody tr:hover {
  background: var(--bg-card-hover);
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.badge {
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
}

.badge--red    { background: rgba(239,68,68,.15); color: #ef4444; }
.badge--red-light { background: rgba(248,113,113,.15); color: #f87171; }
.badge--orange { background: rgba(234,179,8,.15); color: #eab308; }
.badge--yellow { background: rgba(59,130,246,.15); color: #3b82f6; }
.badge--blue   { background: rgba(59,130,246,.15); color: #3b82f6; }
.badge--green  { background: rgba(34,197,94,.15); color: #22c55e; }

.btn-export {
  height: 36px;
  border-radius: 8px;
  border: 0;
}

.btn-export--xlsx {
  background: #16a34a;
}

.btn-export--pdf {
  background: #dc2626;
}

.btn-cache-indicator {
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
}

.modal-drawer {
  border-radius: 12px;
  background: var(--bg-card);
  border-color: var(--border);
}

.modal-header {
  border-bottom-color: var(--border);
  background: var(--bg-card);
}

.modal-body {
  background: var(--bg-card);
}

@media (max-width: 768px) {
  .app {
    grid-template-rows: auto 1fr;
  }

  header {
    height: auto;
    min-height: 0;
    padding: 8px 10px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "logo user"
      "date date";
    row-gap: 8px;
    align-items: center;
  }

  .mobile-header-row {
    display: none !important;
  }

  .logo {
    grid-area: logo;
    min-width: 0;
  }

  .logo-img {
    height: 24px;
    max-height: 24px;
    max-width: 120px;
  }

  .logo-sub {
    font-size: 16px;
  }

  .header-right {
    grid-area: date;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-left: 0;
  }

  .header-right > * + *::before {
    display: none;
  }

  #fecha-hoy {
    position: static;
    transform: none;
    text-align: center;
    font-size: 13px;
  }

  .date-nav {
    justify-self: center;
  }

  .auto-refresh-wrap,
  #btn-cache-clear,
  #btn-alertas-live {
    justify-self: center;
  }

  .user-info {
    grid-area: user;
    justify-self: end;
    gap: 6px;
  }

  .user-info .user-name,
  .user-info .btn-secondary {
    display: none !important;
  }

  .tabs {
    margin-bottom: 12px;
    overflow-x: auto;
    white-space: nowrap;
  }

  .tab-btn {
    font-size: 14px;
    padding: 12px 14px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .kpi-card {
    padding: 14px 12px;
  }

  .kpi-value {
    font-size: 28px;
  }

  .table-wrap table.mobile-adapted td.mobile-extra-cell {
    display: none;
  }

  .table-wrap table.mobile-adapted tr.mobile-row-open td.mobile-extra-cell {
    display: grid;
  }
}

/* ===== Layout ===== */
.app {
  display: grid;
  grid-template-rows: 72px 1fr;
  min-height: 100vh;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
  flex: 0 0 auto;
}

.logo-img {
  height: 34px;
  max-height: 34px;
  max-width: 220px;
  width: auto;
  object-fit: contain;
  display: block;
}

.logo-sub {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

#fecha-hoy {
  color: var(--text-muted);
  font-size: 14px;
}

.main {
  padding: 24px;
  max-width: 1460px;
  margin: 0 auto;
  width: 100%;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  overflow: hidden;
  overflow-y: hidden;
  overflow-x: hidden;
  height: 46px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* Evita que aparezca barra de scroll en el contenedor del menu */
.tabs, .tabs * { scrollbar-width: none; }
.tabs *::-webkit-scrollbar { width: 0; height: 0; display: none; }

.inicio-subtabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}

.inicio-subtabs .tab-btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  margin-bottom: 0;
}

.inicio-subtabs .tab-btn.active {
  background: rgba(249, 115, 22, .12);
  border-color: rgba(249, 115, 22, .45);
  border-bottom-color: rgba(249, 115, 22, .45);
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 20px;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-btn .ico {
  width: 14px;
  height: 14px;
  display: inline-block;
  font-size: 14px;
  line-height: 1;
}

.tab-btn .ico svg { display: none; }

/* ===== KPI cards ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.kpi-card.clickable {
  cursor: pointer;
  transition: transform .12s ease, border-color .15s ease, box-shadow .15s ease;
}

.kpi-card.clickable:hover {
  transform: translateY(-1px);
  border-color: rgba(249, 115, 22, .45);
  box-shadow: 0 10px 22px rgba(0,0,0,.28);
}

.kpi-card.clickable:focus-visible {
  outline: 2px solid rgba(249, 115, 22, .75);
  outline-offset: 2px;
}

.kpi-hint-tooltip {
  position: fixed;
  z-index: 700;
  display: none;
  max-width: min(280px, calc(100vw - 20px));
  background: rgba(15, 23, 42, .96);
  color: #fff;
  border: 1px solid rgba(249, 115, 22, .45);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.3;
  box-shadow: 0 12px 28px rgba(0,0,0,.4);
  pointer-events: none;
}

.kpi-label {
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 10px;
}

.kpi-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.kpi-value.accent  { color: var(--accent); }
.kpi-value.green   { color: var(--green);  }
.kpi-value.blue    { color: var(--accent2);}

.kpi-delta {
  margin-top: 10px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-delta.up   { color: var(--green); }
.kpi-delta.down { color: var(--red);   }
.kpi-delta.neutral { color: var(--text-muted); }

/* ===== Chart grid ===== */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.chart-grid.wide { grid-template-columns: 1fr; }

@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.chart-grid > .chart-card {
  min-width: 0;
}

.chart-card h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 18px;
}

.chart-wrap {
  position: relative;
  height: 250px;
}

/* ===== Loader ===== */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  color: var(--text-muted);
  font-size: 13px;
  gap: 8px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Error ===== */
.error-msg {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 8px;
  color: var(--red);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ===== Table ===== */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

.embed-pane {
  padding: 0;
  overflow: hidden;
}

.embed-frame {
  width: 100%;
  border: 0;
  display: block;
  min-height: 1100px;
  background: transparent;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .5px;
}

td { color: var(--text); }

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(255,255,255,.02); }

.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Antifraude: evitar roturas de layout en tablas anchas */
.af-grid-2 {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

#tab-antifraude .chart-card {
  min-width: 0;
  overflow: hidden;
}

#tab-antifraude .table-wrap table {
  min-width: 980px;
}

#tab-antifraude table th,
#tab-antifraude table td {
  white-space: nowrap;
}

#tab-antifraude table th:last-child,
#tab-antifraude table td:last-child {
  white-space: normal;
  min-width: 220px;
}

@media (max-width: 1400px) {
  .af-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ===== Tab alert variant ===== */
.tab-btn--alert { color: #f59e0b; }
.tab-btn--alert.active { color: #f59e0b; border-bottom-color: #f59e0b; }
.tab-btn--alert:hover  { color: #fbbf24; }

/* ===== KPI color variants ===== */
.kpi-value.color-red    { color: var(--red);    }
.kpi-value.color-orange { color: #f97316;       }
.kpi-value.color-yellow { color: #eab308;       }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge--red    { background: rgba(239,68,68,.15);   color: #ef4444; }
.badge--red-light { background: rgba(248,113,113,.15); color: #f87171; }
.badge--danger-strong { background: rgba(239, 68, 68, .28); color: #fecaca; border: 1px solid rgba(239,68,68,.65); }
.badge--orange { background: rgba(249,115,22,.15);  color: #f97316; }
.badge--yellow { background: rgba(234,179,8,.15);   color: #eab308; }
.badge--green  { background: rgba(34,197,94,.15);   color: #22c55e; }
.badge--blue   { background: rgba(59,130,246,.15);  color: #3b82f6; }
.badge--teal   { background: rgba(20,184,166,.15);  color: #14b8a6; }
.badge--purple { background: rgba(168,85,247,.15);  color: #a855f7; }
.badge--gray   { background: rgba(100,116,139,.15); color: #94a3b8; }

.legend-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.table-pager {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.table-pager-left,
.table-pager-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.table-pager select {
  min-width: 62px;
  background: var(--bg-dark);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
}

.table-pager button {
  background: var(--bg-dark);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  cursor: pointer;
}

.table-pager button:hover:not(:disabled) {
  border-color: var(--accent);
  color: #fff;
}

.table-pager button:disabled {
  opacity: .45;
  cursor: default;
}

/* ===== Cuadre de caja ===== */
.cuadre-card { transition: border-color .4s; }

.cuadre-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}

.cuadre-meta { display: flex; align-items: center; gap: 10px; }

.cuadre-grid {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 0 24px;
  margin-bottom: 16px;
}

.cuadre-sep { background: var(--border); }

.cuadre-col-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.cuadre-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.cuadre-row--total {
  border-bottom: none;
  padding-top: 10px;
  margin-top: 4px;
}

.cuadre-row--total .cuadre-label,
.cuadre-row--total .cuadre-val {
  font-weight: 700;
  color: var(--text);
}

.cuadre-label { color: var(--text-muted); font-size: 13px; }
.cuadre-val   { font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }

.cuadre-diferencia {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
  padding: 14px 18px;
  margin-top: 4px;
  gap: 12px;
  flex-wrap: wrap;
}

.cuadre-dif-label { font-size: 13px; color: var(--text-muted); }
.cuadre-dif-val   { font-size: 22px; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .cuadre-grid { grid-template-columns: 1fr; }
  .cuadre-sep  { display: none; }
}

/* ===== Cuadre — página dedicada ===== */
.cuadre-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.cuadre-hero-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}

.cuadre-hero-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.cuadre-hero-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.cuadre-badge-big {
  font-size: 13px;
  padding: 6px 16px;
  font-weight: 700;
  letter-spacing: .5px;
}

.cuadre-ts-txt {
  font-size: 12px;
  color: var(--text-muted);
}

.cuadre-bloques {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.cuadre-bloque {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
}

.cuadre-bloque-titulo {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.cuadre-resultado {
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 28px 32px;
  text-align: center;
  transition: border-color .4s, background .4s;
}

.cuadre-resultado-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

@media (max-width: 640px) {
  .cuadre-bloques { grid-template-columns: 1fr; }
  .cuadre-hero-right { align-items: flex-start; }
}

/* ===== Modal / Drawer ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 500;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.modal-overlay.open { display: flex; }

.modal-drawer {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  width: min(800px, calc(100vw - 32px));
  max-width: 800px;
  max-height: 85vh;
  height: auto;
  overflow: hidden;
  transform: scale(.95);
  opacity: 0;
  transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .2s ease;
  border-radius: 12px;
  min-height: 0;
}

.modal-overlay.open .modal-drawer {
  transform: scale(1);
  opacity: 1;
  animation: modal-fade-scale .2s ease-out;
}

@keyframes modal-fade-scale {
  from { transform: scale(.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Ticket detail drawers: mas ancho para reducir scroll horizontal en tablas */
.modal-drawer--ticket,
#modal-overlay .modal-drawer,
#tickets-modal-overlay .modal-drawer {
  width: min(800px, calc(100vw - 32px));
  max-width: 800px;
  max-height: 85vh;
  border-radius: 12px;
}

.modal-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface);
}

.modal-titulo   { font-size: 18px; font-weight: 700; margin: 0; }
.modal-subtitulo { color: var(--text-muted); font-size: 13px; margin: 4px 0 0; }

.modal-close {
  background: rgba(15,23,42,.9);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
}

.modal-close:hover { color: var(--red); border-color: var(--red); }

.modal-body {
  overflow-y: auto;
  padding: 20px 24px;
  flex: 1;
  min-height: 0;
}

.modal-section { margin-bottom: 24px; }

.modal-section-title {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.modal-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.modal-meta-item { }
.modal-meta-label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.modal-meta-val   { font-size: 14px; font-weight: 500; margin-top: 2px; }

.modal-total {
  background: var(--surface2);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin-top: 8px;
}

.modal-total-label { font-weight: 600; }
.modal-total-val   { font-size: 20px; font-weight: 700; color: var(--accent); }

/* Tabla dentro del modal */
.modal-body table { font-size: 13px; }
.modal-body th    { font-size: 11px; }

/* Filas clicables */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(249,115,22,.06); }

.ticket-incidencias {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
  background: rgba(249, 115, 22, 0.08);
}

.ticket-incidencias__title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.ticket-incidencias__list {
  margin: 0;
  padding-left: 16px;
  display: grid;
  gap: 6px;
}

.ticket-incidencias__list li {
  color: var(--text-primary);
  font-size: 13px;
}

.ticket-line--eliminada td {
  background: rgba(239,68,68,0.1);
}

.ticket-line--eliminada td:first-child {
  border-left: 3px solid var(--red);
}

.ticket-line--anulada td {
  background: rgba(234,179,8,0.1);
}

.ticket-line--anulada td:first-child {
  border-left: 3px solid var(--yellow);
}

.ticket-line--precio td {
  background: rgba(59,130,246,0.1);
}

.ticket-line--precio td:first-child {
  border-left: 3px solid var(--blue);
}

.af-row-danger td {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
}

.af-drill-ticket {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
}

.af-drill-ticket > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(59,130,246,.06);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.af-drill-ticket > summary::-webkit-details-marker { display: none; }

/* ===== Export bar ===== */
.export-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.export-label {
  color: var(--text-muted);
  font-size: 14px;
  margin-right: 2px;
}

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  padding: 8px 14px;
  transition: color .15s, border-color .15s;
}
.btn-secondary:hover { color: var(--text); border-color: var(--text-muted); }

.btn-export {
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  transition: opacity .15s;
}

.btn-export:hover { opacity: .8; }

.btn-export--xlsx {
  background: #1D6F42;
  border-color: #1D6F42;
  color: #fff;
}

.btn-export--pdf {
  background: #C0392B;
  border-color: #C0392B;
  color: #fff;
}

/* ===== Filtros bar ===== */
.filtros-bar {
  display: none;               /* oculto por defecto, JS lo muestra solo en pestaña Hoy */
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
}

.filtros-bar.visible { display: flex; }

.filtro-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filtro-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}

.filtro-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 30px 8px 12px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  min-width: 160px;
}

.filtro-select:focus { border-color: var(--accent); }

.filtro-select option { background: var(--surface2); }

.btn-clear-filtros {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 8px 12px;
  margin-left: auto;
  transition: color .15s, border-color .15s;
}

.btn-clear-filtros:hover { color: var(--red); border-color: var(--red); }

/* ===== Date picker ===== */
.date-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
}

.date-nav-btn {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 6px 10px;
  transition: border-color .15s, color .15s, background .15s;
}
.date-nav-btn:hover { color: var(--accent); border-color: var(--accent); background: rgba(249,115,22,.08); }

.date-nav-center {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
}

.date-nav-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.date-input {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  cursor: pointer;
  width: 130px;
  color-scheme: dark;   /* native date picker dark en Chromium */
}

/* ===== Auto-refresh ===== */
.auto-refresh-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.auto-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: pulse-dot 1.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%       { opacity: .3; transform: scale(.7); }
}

/* ===== Toasts ===== */
.toast-container {
  position: fixed;
  top: 68px;
  right: 20px;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  align-items: flex-start;
  background: var(--surface);
  border-left: 4px solid;
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,.45);
  display: flex;
  gap: 10px;
  max-width: 340px;
  min-width: 260px;
  padding: 14px 16px;
  pointer-events: all;
  animation: toast-in .25s cubic-bezier(.4,0,.2,1);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.toast-out {
  animation: toast-out .3s cubic-bezier(.4,0,.2,1) forwards;
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(40px); max-height: 0; padding: 0; margin: 0; }
}

.toast--alert  { border-color: var(--red);    }
.toast--warning{ border-color: #eab308;        }
.toast--ok     { border-color: var(--green);   }

.toast-icon { font-size: 18px; line-height: 1.2; flex-shrink: 0; }

.toast-body  { flex: 1; }
.toast-title { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.toast-msg   { color: var(--text-muted); font-size: 12px; }

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

/* ===== User info / logout ===== */
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 1px solid var(--border);
  padding-left: 12px;
}

.user-name {
  color: var(--text-muted);
  font-size: 14px;
}

.btn-logout {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 12px;
  text-decoration: none;
  transition: color .15s, border-color .15s;
}

.btn-logout:hover { color: var(--red); border-color: var(--red); }

/* ===== Refresh btn ===== */
.btn-refresh {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  padding: 8px 16px;
  transition: background .15s;
}

.btn-refresh:hover { background: var(--border); }

.btn-cache-indicator {
  background: rgba(34, 197, 94, 0.08);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn-cache-indicator:hover {
  background: rgba(34, 197, 94, 0.14);
}

.btn-alertas-live {
  position: relative;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 10px;
  color: var(--text);
  min-width: 40px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-alertas-live .bell {
  font-size: 16px;
  line-height: 1;
}

.badge-count {
  position: absolute;
  top: -7px;
  right: -7px;
  background: var(--red);
  color: #fff;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
}

.alertas-live-panel {
  position: fixed;
  top: 64px;
  right: 14px;
  width: min(420px, calc(100vw - 24px));
  max-height: min(70vh, 620px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
  z-index: 560;
  display: none;
  overflow: hidden;
}

.alertas-live-panel.open {
  display: flex;
  flex-direction: column;
}

.alertas-live-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.alertas-live-list {
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.alerta-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, .02);
}

.alerta-item.nivel-rojo { border-color: rgba(239, 68, 68, .45); }
.alerta-item.nivel-naranja { border-color: rgba(249, 115, 22, .45); }
.alerta-item.nivel-amarillo { border-color: rgba(234, 179, 8, .45); }

.alerta-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.alerta-item-msg {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.alerta-item-foot {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 5px;
}

.alerta-empty {
  color: var(--green);
  font-weight: 700;
  padding: 6px 2px;
}

@media (min-width: 1200px) {
  body { zoom: 1; }
}

/* ===== Mobile overhaul (global) ===== */
html, body {
  overflow-x: hidden;
}

@media (max-width: 900px) {
  .app {
    grid-template-rows: auto 1fr;
  }

  .main {
    max-width: 100%;
    padding: 14px;
  }

  header {
    position: sticky;
    top: 0;
    z-index: 120;
    padding: 10px 12px;
    gap: 10px;
  }

  .logo {
    width: 100%;
    justify-content: space-between;
  }

  .logo-img {
    max-width: 170px;
    height: auto;
  }

  .logo-sub {
    font-size: 12px;
  }

  .header-right {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .header-right > * {
    min-width: 0;
  }

  #fecha-hoy {
    width: 100%;
    font-size: 12px;
  }

  .date-nav {
    width: 100%;
    border-radius: 12px;
    padding: 6px;
    gap: 6px;
  }

  .date-nav-center {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  .date-input {
    width: 100%;
    min-width: 0;
    max-width: 170px;
  }

  .auto-refresh-wrap {
    width: 100%;
    display: flex;
    gap: 8px;
  }

  .auto-refresh-wrap .filtro-select,
  .btn-refresh {
    width: 100%;
  }

  .user-info {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    border-left: 0;
    padding-left: 0;
  }

  .user-name {
    grid-column: 1 / -1;
    font-size: 13px;
  }

  .user-info .btn-secondary,
  .user-info .btn-logout {
    width: 100%;
    text-align: center;
  }

  .tabs {
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: thin;
    height: auto;
    padding-bottom: 4px;
    gap: 4px;
  }

  .tab-btn {
    border-radius: 8px 8px 0 0;
    padding: 9px 11px;
    font-size: 13px;
    flex: 0 0 auto;
  }

  .filtros-bar {
    width: 100%;
    gap: 10px;
    padding: 12px;
  }

  .filtro-group {
    width: 100%;
    flex: 1 1 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .filtro-label {
    font-size: 11px;
    min-width: 0;
  }

  .filtro-select,
  .date-input {
    width: 100%;
    min-width: 0;
  }

  .btn-clear-filtros,
  #btn-buscar,
  #btn-limpiar,
  #btn-buscar-rec {
    width: 100%;
    margin-left: 0;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .kpi-card {
    padding: 14px;
  }

  .kpi-value {
    font-size: 26px;
  }

  .chart-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .chart-card {
    padding: 14px;
    min-width: 0;
  }

  .chart-wrap {
    height: 220px;
  }

  .export-bar {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  .export-bar .btn-export,
  .export-bar .btn-secondary {
    flex: 1 1 calc(50% - 4px);
    text-align: center;
  }

  .table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table {
    min-width: 620px;
  }

  .table-pager {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .table-pager-left,
  .table-pager-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  th, td {
    padding: 8px 10px;
    font-size: 12px;
  }

  .num {
    font-variant-numeric: tabular-nums;
  }

  .embed-frame {
    min-height: calc(100vh - 190px);
  }

  /* Antifraude en movil: menos ancho minimo para evitar "pantalla rota" */
  #tab-antifraude .table-wrap table {
    min-width: 620px;
  }

  #tab-antifraude table th:last-child,
  #tab-antifraude table td:last-child {
    min-width: 170px;
  }

  /* Páginas embebidas (tickets/recaudaciones): navegación compacta */
  #tickets-main-nav.tabs .tab-btn,
  #recaudaciones-main-nav.tabs .tab-btn {
    font-size: 12px;
    padding: 8px 10px;
  }

  /* Drawer principal del dashboard con altura acotada */
  #modal-overlay .modal-drawer {
    max-height: 85vh;
  }
}

@media (max-width: 700px) {
  .modal-overlay {
    align-items: center;
    justify-content: center;
    padding: 12px !important;
  }

  .modal-drawer,
  #modal-overlay .modal-drawer,
  #tickets-modal-overlay .modal-drawer {
    width: 95vw !important;
    max-width: 95vw !important;
    height: 90vh !important;
    max-height: 90vh !important;
    border-radius: 12px !important;
    border: 1px solid var(--border) !important;
  }

  .modal-header {
    padding: 14px 14px 10px;
    padding-right: 58px;
  }

  .modal-titulo {
    font-size: 17px;
  }

  .modal-subtitulo {
    font-size: 12px;
  }

  .modal-close {
    position: absolute;
    right: 12px;
    top: 12px;
  }

  .modal-body {
    padding: 12px 12px 20px;
  }

  .modal-meta-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .modal-body table {
    min-width: 560px;
  }

  .toast-container {
    right: 10px;
    left: 10px;
    top: 62px;
  }

  .toast {
    min-width: 0;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .main {
    padding: 10px;
  }

  .logo-img {
    max-width: 146px;
  }

  .tab-btn {
    font-size: 12px;
    padding: 9px 10px;
  }

  .kpi-label {
    font-size: 11px;
  }

  .kpi-value {
    font-size: 24px;
  }

  .chart-card h3 {
    font-size: 13px;
  }

  .table-wrap table {
    min-width: 560px;
  }

  .tab-btn .ico {
    display: none;
  }
}

/* =========================================================
   Rediseño móvil/tablet (Dashboard)
   Breakpoints:
   - móvil: <768
   - tablet: 768-1024
   - escritorio: >1024
========================================================= */
.mobile-header-row,
.mobile-tab-menu,
.mobile-user-menu,
.mobile-bottom-nav,
.mobile-filter-toggle,
.mobile-filter-close {
  display: none;
}

.mobile-top-controls {
  display: none;
}

.mobile-logo-img {
  height: 30px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
}

.mobile-header-date {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  letter-spacing: .2px;
}

.mobile-menu-btn {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mobile-menu-btn:active {
  transform: translateY(1px);
}

.mobile-header-actions {
  display: none;
}

.mobile-date-picker-input {
  display: none;
}

.mobile-date-nav {
  display: none;
}

.mobile-date-nav-btn {
  display: none;
}

@media (max-width: 767px) {
  .app {
    grid-template-rows: 64px 1fr;
  }

  header {
    height: 64px;
    min-height: 64px;
    padding: 8px 10px;
  }

  .logo,
  .header-right {
    display: none !important;
  }

  .mobile-header-row {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
  }

  .mobile-header-row .mobile-logo-img {
    justify-self: start;
  }

  .mobile-header-row .mobile-header-date {
    justify-self: center;
  }

  .mobile-header-row .mobile-menu-btn {
    justify-self: end;
  }

  .mobile-tab-menu {
    position: sticky;
    top: 64px;
    z-index: 115;
    display: none;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 10px 10px;
    gap: 6px;
    grid-template-columns: 1fr 1fr;
  }

  .mobile-tab-menu.open {
    display: grid;
  }

  .mobile-top-controls {
    display: block;
    position: sticky;
    top: 64px;
    z-index: 112;
    background: var(--bg);
    padding: 8px 10px 6px;
    border-bottom: 1px solid var(--border);
  }

  .mobile-date-toolbar {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 6px;
    align-items: center;
    min-width: 0;
  }

  .mobile-date-input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    background: var(--surface2);
  }

  .mobile-btn-refresh {
    padding: 8px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  .mobile-menu-tab {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    padding: 9px 10px;
    text-align: center;
    cursor: pointer;
  }

  .mobile-menu-tab.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(249, 115, 22, .08);
  }

  .main {
    padding: 12px 10px;
    max-width: 100%;
  }

  .tabs {
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    flex-wrap: nowrap;
    gap: 4px;
    height: auto;
    padding-bottom: 6px;
    margin-bottom: 10px;
    margin-top: 4px;
  }

  .tab-btn {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 12px;
  }

  .tab-btn .ico {
    display: none !important;
  }

  .tab-btn.active {
    border-bottom-width: 3px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
  }

  .kpi-card {
    padding: 12px;
  }

  .kpi-value {
    font-size: 24px;
    line-height: 1.05;
  }

  .chart-card {
    padding: 12px;
    overflow: hidden;
  }

  .chart-card h3 {
    white-space: normal;
    line-height: 1.25;
    margin-bottom: 10px;
  }

  .chart-grid {
    gap: 10px;
    margin-bottom: 14px;
  }

  .export-bar {
    justify-content: flex-start;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .export-bar .export-label {
    margin-right: 4px;
    white-space: nowrap;
    font-size: 13px;
  }

  .export-bar .btn-export {
    flex: 0 0 auto;
    width: 120px;
    max-width: 120px;
    padding: 7px 10px;
    font-size: 13px;
  }

  .chart-wrap {
    height: 200px !important;
    max-height: 200px !important;
  }

  .chart-card canvas {
    max-height: 200px !important;
  }

  .filtros-bar,
  .filtros-bar.visible,
  #filtros-dia,
  #filtros-antifraude {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    padding: 12px;
    overflow: visible;
  }

  .filtro-group {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    align-items: stretch;
    min-width: 0;
  }

  .filtro-select,
  .btn-clear-filtros,
  #filtros-antifraude input,
  #filtros-antifraude button {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .filtro-label {
    white-space: normal;
    line-height: 1.2;
  }

  #filtros-dia .filtro-group,
  #filtros-antifraude .filtro-group {
    min-width: 0;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table {
    min-width: 680px;
  }

  .table-wrap th,
  .table-wrap td {
    padding: 12px 10px;
    font-size: 13px;
  }

  /* Modo tarjetas para tablas en movil: mejora legibilidad */
  .table-wrap table.mobile-adapted {
    min-width: 0 !important;
    width: 100% !important;
    border-collapse: separate;
    border-spacing: 0 8px;
  }

  .table-wrap table.mobile-adapted thead {
    display: none;
  }

  .table-wrap table.mobile-adapted tbody,
  .table-wrap table.mobile-adapted tr,
  .table-wrap table.mobile-adapted td {
    display: block;
    width: 100%;
  }

  .table-wrap table.mobile-adapted tr {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, .02);
    overflow: hidden;
  }

  .table-wrap table.mobile-adapted td {
    border-bottom: 1px solid var(--border);
    padding: 9px 10px;
    white-space: normal;
    overflow-wrap: anywhere;
    display: grid;
    grid-template-columns: minmax(95px, 42%) 1fr;
    align-items: start;
    gap: 8px;
    text-align: left !important;
  }

  .table-wrap table.mobile-adapted td:last-child {
    border-bottom: none;
  }

  .table-wrap table.mobile-adapted td.mobile-extra-cell {
    display: none;
  }

  .table-wrap table.mobile-adapted tr.mobile-row-open td.mobile-extra-cell {
    display: grid;
  }

  .table-wrap table.mobile-adapted td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .35px;
    line-height: 1.2;
  }

  .mobile-row-toggle {
    margin-top: 8px;
    width: fit-content;
    border: 1px solid var(--border);
    background: rgba(100, 116, 139, .14);
    color: var(--text-muted);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    cursor: pointer;
  }

  .mobile-row-toggle:active {
    transform: translateY(1px);
  }

  #modal-overlay,
  #tickets-modal-overlay {
    padding: 12px !important;
    align-items: center !important;
    justify-content: center !important;
  }

  #modal-overlay .modal-drawer,
  #tickets-modal-overlay .modal-drawer,
  #modal-drawer.modal-drawer,
  #tickets-modal-drawer.modal-drawer {
    width: 95vw !important;
    max-width: 95vw !important;
    height: 90vh !important;
    max-height: 90vh !important;
    border-radius: 12px !important;
    border: 1px solid var(--border) !important;
  }

  #modal-overlay .modal-header,
  #tickets-modal-overlay .modal-header {
    padding: 14px 16px;
    padding-right: 56px;
    position: sticky;
    top: 0;
    z-index: 5;
  }

  #modal-overlay .modal-close,
  #tickets-modal-overlay .modal-close {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 20px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #modal-overlay .modal-body,
  #tickets-modal-overlay .modal-body {
    height: calc(90vh - 72px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .btn-cache-indicator {
    display: none;
  }

  .alertas-live-panel {
    top: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .mobile-header-row,
  .mobile-tab-menu {
    display: none !important;
  }

  .main {
    padding: 18px;
    max-width: 100%;
  }

  .tabs {
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .tab-btn {
    flex: 0 0 auto;
    font-size: 13px;
    padding: 9px 12px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .chart-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .chart-wrap {
    height: 220px;
  }

  .filtros-bar,
  .filtros-bar.visible,
  #filtros-dia,
  #filtros-antifraude {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: 10px;
  }
}

/* =========================================================
   Mobile-first app layout (<768)
   No cambia escritorio
========================================================= */
@media (max-width: 768px) {
  .app {
    display: block;
    min-height: 100dvh;
  }

  header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    min-height: 56px;
    padding: 0 10px;
    z-index: 220;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .logo,
  .header-right,
  .mobile-tab-menu,
  .mobile-top-controls,
  .tabs,
  .export-bar {
    display: none !important;
  }

  .mobile-header-row {
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    width: 100%;
    height: 56px;
    gap: 0;
    justify-items: center;
  }

  .mobile-date-picker-input {
    display: inline-flex;
    width: 140px;
    min-width: 140px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface2);
    color: var(--text);
    font-size: 12px;
    padding: 0 8px;
  }

  .mobile-date-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .mobile-date-nav-btn {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface2);
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    padding: 0;
  }

  .mobile-user-menu {
    position: fixed;
    top: 56px;
    right: 8px;
    width: min(220px, calc(100vw - 16px));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    box-shadow: var(--shadow);
    display: none;
    z-index: 230;
  }

  .mobile-user-menu.open {
    display: block;
  }

  .mobile-user-menu-name {
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }

  .mobile-user-menu-link {
    display: inline-block;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 0;
  }

  .main {
    max-width: 100%;
    margin: 0;
    padding: 64px 10px 82px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
  }

  .kpi-card {
    padding: 10px 12px;
    border-radius: 10px;
  }

  .kpi-label {
    font-size: 10px;
    margin-bottom: 6px;
  }

  .kpi-value {
    font-size: 24px;
    line-height: 1.05;
  }

  .chart-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 10px;
  }

  .chart-card {
    padding: 10px 12px;
    border-radius: 10px;
    margin-top: 0 !important;
  }

  .chart-card h3 {
    font-size: 12px;
    margin-bottom: 8px;
    letter-spacing: .35px;
  }

  .chart-wrap {
    height: 180px !important;
    max-height: 180px !important;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table {
    min-width: 700px;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 62px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    z-index: 215;
    padding: 4px 6px max(4px, env(safe-area-inset-bottom));
    gap: 4px;
  }

  .mobile-bottom-tab {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 2px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
  }

  .mobile-bottom-tab::before {
    display: block;
    font-size: 12px;
    line-height: 1;
  }
  .mobile-bottom-tab[data-tab="dia"]::before { content: "◔"; }
  .mobile-bottom-tab[data-tab="semana"]::before { content: "▦"; }
  .mobile-bottom-tab[data-tab="mes"]::before { content: "◫"; }
  .mobile-bottom-tab[data-tab="antifraude"]::before { content: "!"; }
  .mobile-bottom-tab[data-tab="caja"]::before { content: "€"; }
  .mobile-bottom-tab[data-tab="reposiciones"]::before { content: "+"; }
  .mobile-bottom-tab[data-tab="productos"]::before { content: "*"; }
  .mobile-bottom-tab[data-tab="empleados"]::before { content: "E"; }

  .mobile-bottom-tab.active {
    color: var(--accent);
    border-color: rgba(249,115,22,.45);
    background: rgba(249,115,22,.12);
  }

  /* Override para menu inferior con mas pestañas */
  .mobile-bottom-nav {
    height: 64px;
    display: flex;
    align-items: stretch;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .mobile-bottom-nav::-webkit-scrollbar { display: none; }
  .mobile-bottom-tab { flex: 0 0 74px; }

  .mobile-bottom-tab[data-tab="inicio"]::before { content: "I"; }
  .mobile-bottom-tab[data-tab="dia"]::before { content: "H"; }
  .mobile-bottom-tab[data-tab="semana"]::before { content: "S"; }
  .mobile-bottom-tab[data-tab="mes"]::before { content: "M"; }
  .mobile-bottom-tab[data-tab="antifraude"]::before { content: "!"; }
  .mobile-bottom-tab[data-tab="caja"]::before { content: "€"; }
  .mobile-bottom-tab[data-tab="reposiciones"]::before { content: "+"; }
  .mobile-bottom-tab[data-tab="productos"]::before { content: "P"; }
  .mobile-bottom-tab[data-tab="empleados"]::before { content: "E"; }
  .mobile-bottom-tab[data-tab="cuadre"]::before { content: "="; }
  .mobile-bottom-tab[data-tab="comparativas"]::before { content: "C"; }
  .mobile-bottom-tab[data-tab="tickets"]::before { content: "T"; }
  .mobile-bottom-tab[data-tab="recaudaciones"]::before { content: "R"; }
  .mobile-bottom-tab[data-tab="alertas"]::before { content: "A"; }

  /* Fuerza menu movil abajo (evita que suba arriba por overrides) */
  #mobile-bottom-nav.mobile-bottom-nav {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 999 !important;
  }

  .mobile-filter-toggle,
  .mobile-filter-close {
    position: fixed;
    right: 10px;
    bottom: 74px;
    z-index: 216;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    background: var(--surface2);
    color: var(--text);
    display: none;
  }

  .mobile-filter-toggle {
    display: inline-flex;
  }

  .mobile-filter-close {
    display: none;
  }

  body.mobile-filters-open .mobile-filter-toggle {
    display: none !important;
  }

  body.mobile-filters-open .mobile-filter-close {
    display: inline-flex !important;
  }

  #filtros-dia,
  #filtros-antifraude {
    display: none !important;
  }

  #filtros-dia.mobile-filter-drawer-open,
  #filtros-antifraude.mobile-filter-drawer-open {
    display: grid !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 62px;
    top: auto;
    z-index: 214;
    max-height: min(65dvh, 560px);
    overflow: auto;
    gap: 8px;
    border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    background: var(--surface);
    padding: 12px;
    box-shadow: 0 -16px 36px rgba(0,0,0,.45);
  }

  #filtros-dia.mobile-filter-drawer-open .filtro-group,
  #filtros-antifraude.mobile-filter-drawer-open .filtro-group {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  #filtros-dia.mobile-filter-drawer-open .filtro-select,
  #filtros-antifraude.mobile-filter-drawer-open .filtro-select,
  #filtros-antifraude.mobile-filter-drawer-open input,
  #filtros-antifraude.mobile-filter-drawer-open button,
  #filtros-dia.mobile-filter-drawer-open button {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .inicio-subtabs {
    display: flex !important;
    position: sticky;
    top: 58px;
    z-index: 205;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    margin: 0 0 10px 0 !important;
    padding: 6px 0 4px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
  }

  .inicio-subtabs .tab-btn {
    border: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12px;
  }
}

/* =========================================================
   Recaudaciones (nuevo diseno en dashboard)
========================================================= */
.header-date-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#btn-hoy.btn-hoy-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.recaudaciones-cards {
  display: grid;
  gap: 12px;
}

.recaudacion-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, .01);
  overflow: hidden;
}

.recaudacion-card-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.recaudacion-card-summary::-webkit-details-marker {
  display: none;
}

.recaudacion-card-meta {
  min-width: 0;
}

.recaudacion-card-hora {
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
}

.recaudacion-card-op {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

.recaudacion-card-total {
  color: var(--accent);
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.recaudacion-card-body {
  border-top: 1px solid var(--border);
  padding: 0;
}

.recaudacion-card[open] {
  border-color: var(--border-light);
}

@media (max-width: 768px) {
  .header-date-left {
    display: none !important;
  }

  .recaudacion-card-summary {
    padding: 10px 12px;
  }

  .recaudacion-card-total {
    font-size: 20px;
  }
}

/* =========================================================
   Fixes móviles (2026-04-23)
   - Forzar visibilidad del selector de fecha móvil
   - Header móvil en 2 líneas
   - Botón Hoy funcional en móvil
========================================================= */
@media (max-width: 768px) {
  header {
    height: 92px !important;
    min-height: 92px !important;
    padding: 6px 10px !important;
    display: block !important;
  }

  .mobile-header-row {
    display: grid !important;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 6px;
    width: 100%;
    height: 80px;
  }

  .mobile-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
  }

  .mobile-header-top-title {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .2px;
  }

  .mobile-btn-hoy {
    height: 30px;
    min-width: 56px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 8px;
  }

  .mobile-date-nav {
    display: grid !important;
    grid-template-columns: 34px 1fr 34px;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
  }

  .mobile-date-picker-input {
    display: block !important;
    width: 100%;
    min-width: 0;
    height: 34px;
  }

  .mobile-date-nav-btn {
    display: inline-flex !important;
    width: 34px;
    height: 34px;
  }

  .mobile-user-menu {
    top: 92px;
  }

  .main {
    padding-top: 104px !important;
  }

  .inicio-subtabs {
    top: 94px !important;
    z-index: 210;
  }

  .inicio-subtabs .tab-btn {
    touch-action: manipulation;
  }
}


/* ===== Fix navegación web + alertas ===== */
.main > .tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  white-space: nowrap;
  height: auto !important;
  min-height: 44px;
  padding-bottom: 2px;
  padding-right: 20px;
  width: 100%;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.main > .tabs .tab-btn {
  flex: 0 0 auto;
}
.main > .tabs .tab-btn .ico {
  display: inline-flex !important;
  margin-right: 6px;
}

@media (min-width: 1025px) {
  .main > .tabs {
    margin-bottom: 16px;
    gap: 2px;
  }
  .main > .tabs .tab-btn {
    font-size: 14px;
    padding: 10px 14px;
  }
}

#tab-alertas,
#tab-alertas .chart-card,
#tab-alertas .table-wrap {
  max-width: 100%;
  overflow-x: auto;
}
