:root {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border-light: #e2e8f0;
  --border-active: #8b5cf6;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  
  --brand-navy: #0f172a;
  --brand-green: #10b981;
  --brand-green-bg: #ecfdf5;
  --brand-amber: #f59e0b;
  --brand-amber-bg: #fffbeb;
  --brand-purple: #8b5cf6;
  --brand-purple-bg: #f5f3ff;
  --brand-blue: #2563eb;
  --brand-blue-bg: #eff6ff;
  --brand-red: #ef4444;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Avenir Next", Helvetica, Arial, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Header */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
  padding: 0.85rem 2rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.app-header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-brand-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-brand-title h1 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--brand-navy);
  letter-spacing: -0.01em;
}

.header-brand-title p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green {
  background: var(--brand-green-bg);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-purple {
  background: var(--brand-purple-bg);
  color: #5b21b6;
  border: 1px solid #ddd6fe;
}

.badge-amber {
  background: var(--brand-amber-bg);
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-dark {
  background: #0f172a;
  color: #ffffff;
}

.btn-sync {
  background: #ffffff;
  border: 1px solid var(--border-light);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn-sync:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* Container */
.main-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 2rem 4rem 2rem;
}

/* Top KPI Cards */
.top-kpis-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
  .top-kpis-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .top-kpis-grid {
    grid-template-columns: 1fr;
  }
}

.kpi-white-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 1.2rem 1.35rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-white-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.kpi-white-title {
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kpi-main-number {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--brand-navy);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 0.35rem;
}

.kpi-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #f1f5f9;
}

.kpi-progress-bar {
  width: 100%;
  height: 6px;
  background: #f1f5f9;
  border-radius: 9999px;
  overflow: hidden;
  margin: 0.4rem 0;
}

.kpi-progress-bar-fill {
  height: 100%;
  background: var(--brand-green);
  border-radius: 9999px;
}

/* ============================================================== */
/* SECCIÓN FILA 2: VENTAS DE HOY (Compacta y bien proporcionada) */
/* ============================================================== */
.today-split-section {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  align-items: stretch;
}

@media (max-width: 1024px) {
  .today-split-section {
    grid-template-columns: 1fr;
  }
}

/* Tarjeta Oscura Izquierda */
.dark-today-card {
  background: #0b1329;
  border-radius: 16px;
  padding: 1.35rem 1.5rem;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 4px 15px -3px rgba(11, 19, 41, 0.25);
}

.dark-card-top-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0.75rem;
}

.green-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

.dark-card-amount {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1.1;
  margin-bottom: 0.35rem;
}

.dark-card-subtitle {
  font-size: 0.75rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dark-card-breakdown {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1rem;
  margin-top: 1.25rem;
}

.dark-breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 0.5rem;
}

.dark-breakdown-row strong {
  color: #ffffff;
}

/* Panel de Tiendas (Grid compacto de 2 a 3 columnas para evitar estiramiento) */
.stores-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.stores-panel-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--brand-navy);
}

.stores-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 1rem;
}

.store-interactive-card {
  background: #ffffff;
  border: 1.5px solid #ddd6fe;
  border-radius: 14px;
  padding: 1rem 1.25rem;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.store-card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.store-name-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: #6d28d9;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.store-today-total {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--brand-navy);
  margin: 0.15rem 0;
}

.store-pills-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Tarjetas de Asesores dentro de la Tienda */
.store-sellers-accordion {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--border-light);
}

.sellers-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.65rem;
}

.seller-mini-card {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
}

.seller-mini-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.seller-avatar-initials {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #334155;
  font-weight: 800;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seller-mini-name {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--brand-navy);
}

.seller-mini-stats {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.seller-mini-amount {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--brand-navy);
}

.seller-invoices-mini-list {
  border-top: 1px solid #e2e8f0;
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.invoice-mini-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

/* Filter Controls Bar */
.filter-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-btn-pill {
  background: #ffffff;
  border: 1px solid var(--border-light);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn-pill.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.filter-btn-pill.active-green {
  background: var(--brand-green);
  color: #ffffff;
  border-color: var(--brand-green);
}

/* Card Sections */
.dashboard-section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 1.35rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  margin-bottom: 1.5rem;
}

.section-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-card-title-group h2 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--brand-navy);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-card-title-group p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Charts Containers */
.chart-container-box {
  width: 100%;
  height: 240px;
  position: relative;
}

/* Weekly Days Row below Weekly Chart */
.weekly-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.75rem;
  margin-top: 1.25rem;
}

@media (max-width: 840px) {
  .weekly-days-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.day-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.day-card:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.day-card.selected-day {
  border: 2px solid var(--brand-blue);
  background: #f8fafc;
}

.day-card.is-today {
  border: 2px solid var(--brand-amber);
  background: #fffdf5;
}

.day-name {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.day-date {
  font-size: 0.68rem;
  color: var(--text-dim);
}

.day-amount {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--brand-navy);
  margin: 0.25rem 0 0.1rem 0;
}

.day-tickets {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Table Card for Sellers Ranking */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.leaderboard-table th {
  padding: 0.75rem 1rem;
  font-size: 0.725rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-light);
}

.leaderboard-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
}

.leaderboard-table tr:hover td {
  background: #f8fafc;
}

/* ============================================================== */
/* MODAL MODO ADMIN                                              */
/* ============================================================== */
.admin-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.admin-modal-overlay.active {
  display: flex;
}

.admin-modal-box {
  background: #ffffff;
  border-radius: 20px;
  width: 100%;
  max-width: 760px;
  height: 86vh;
  max-height: 820px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.2s ease-out;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.admin-modal-header {
  padding: 1.15rem 1.75rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  flex-shrink: 0;
}

.admin-modal-header h3 {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--brand-navy);
  margin: 0;
}

.admin-modal-header p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0.2rem 0 0 0;
}

/* Tabs Bar */
.admin-modal-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.75rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.admin-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-tab-btn:hover {
  background: #e2e8f0;
  color: var(--brand-navy);
}

.admin-tab-btn.active {
  background: #ffffff;
  color: var(--brand-purple);
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Form Container */
#formAdminTargets {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* Scrollable Body */
.admin-modal-body {
  padding: 1.25rem 1.75rem;
  overflow-y: auto !important;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
}

.admin-modal-body::-webkit-scrollbar {
  width: 7px;
}
.admin-modal-body::-webkit-scrollbar-track {
  background: #f8fafc;
}
.admin-modal-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.admin-modal-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Sections inside Modal Body (Continuous Scroll) */
.admin-tab-pane {
  display: block !important;
  margin-bottom: 1.75rem;
  scroll-margin-top: 0.5rem;
}

/* Helper Cards and Banners */
.admin-info-banner {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-quick-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.admin-helper-btn {
  background: var(--brand-purple-bg);
  color: var(--brand-purple);
  border: 1px solid #ddd6fe;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.admin-helper-btn:hover {
  background: #ede9fe;
  transform: translateY(-1px);
}

.admin-fieldset {
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1.1rem;
  margin-bottom: 1.25rem;
  background: #ffffff;
}

.admin-fieldset legend {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-navy);
  padding: 0 8px;
}

.admin-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.admin-input-group {
  margin-bottom: 0.85rem;
}

.admin-input-group label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
}

.admin-input {
  width: 100%;
  border: 1.5px solid var(--border-light);
  background: #ffffff;
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  transition: all 0.15s;
}

.admin-input:focus {
  border-color: var(--brand-purple);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.12);
}

/* Card in grid for stores / sellers */
.admin-card-row {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-card-row:hover {
  border-color: #cbd5e1;
  background: #ffffff;
}

.admin-card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-modal-footer {
  padding: 1rem 1.75rem;
  border-top: 1px solid var(--border-light);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.btn-admin-save {
  background: var(--brand-navy);
  color: #ffffff;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-admin-save:hover {
  background: #1e293b;
  transform: translateY(-1px);
}

/* ============================================================== */
/* Tarjeta Flotante Informativa Derecha (Factura Nueva en Vivo)   */
/* ============================================================== */
.floating-invoice-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 99999;
  width: 380px;
  max-width: calc(100vw - 2.5rem);
  background: #0f172a;
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: 14px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.7), 0 0 25px rgba(16, 185, 129, 0.25);
  color: #ffffff;
  padding: 1rem 1.25rem;
  animation: slideInRightToast 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.floating-invoice-toast.hidden {
  display: none !important;
}

.floating-invoice-toast.fade-out {
  opacity: 0;
  transform: translateX(110%);
  pointer-events: none;
}

@keyframes slideInRightToast {
  from {
    opacity: 0;
    transform: translateX(110%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.floating-toast-content {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.floating-toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.5rem;
}

.floating-toast-badge-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.floating-toast-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #34d399;
}

.floating-toast-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}

.floating-toast-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.floating-toast-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.floating-toast-amount {
  font-size: 1.65rem;
  font-weight: 900;
  color: #10b981;
  letter-spacing: -0.02em;
}

.floating-toast-details {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  text-align: right;
}

.floating-toast-seller {
  font-size: 0.82rem;
  color: #cbd5e1;
}

.floating-toast-seller strong {
  color: #ffffff;
}

.floating-toast-store {
  display: flex;
  align-items: center;
  gap: 6px;
}

.floating-toast-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
}

.floating-toast-client strong {
  color: #e2e8f0;
}

