/* NEXA Dashboard — Lavall */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #fafafa;
  color: #1a1a1a;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  background: #111;
  color: #fff;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; }
.tabs a {
  color: #aaa;
  margin-left: 16px;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 14px;
}
.tabs a.active { color: #fff; background: #2a2a2a; }
.tabs a:hover { color: #fff; }

main { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* Hero */
.hero {
  text-align: center;
  margin-bottom: 24px;
  padding: 24px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.hero-fecha { color: #888; font-size: 14px; }
.hero-amount { font-size: 48px; font-weight: 700; margin: 8px 0; }
.hero-delta { margin: 8px 0; font-size: 14px; color: #666; }
.hero-meta { color: #666; }

/* Delta badges */
.delta {
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 14px;
  display: inline-block;
}
.delta-up { background: #e8f5e9; color: #1b5e20; }
.delta-down { background: #ffebee; color: #b71c1c; }
.delta-na { background: #f0f0f0; color: #666; }

/* Sucursal cards */
.grid-sucursales {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.card-suc {
  display: block;
  padding: 16px;
  background: #fff;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: transform 0.1s;
}
.card-suc:hover { transform: translateY(-2px); }
.card-name { font-size: 14px; color: #666; }
.card-amount { font-size: 24px; font-weight: 700; margin: 6px 0; }
.card-delta { margin-bottom: 6px; }
.card-meta { font-size: 12px; color: #888; }

/* Footer */
.footer {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px;
  background: #fff;
  border-radius: 8px;
  font-size: 14px;
  color: #666;
}
.clima-item { margin-right: 16px; }

/* Detalle sucursal */
.detalle-header {
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.back { color: #666; text-decoration: none; font-size: 14px; }
.back:hover { color: #1a1a1a; }
.detalle-header h1 { margin: 8px 0 16px; font-size: 24px; }

.metric-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.metric-cards > div { display: flex; flex-direction: column; }
.m-label { font-size: 12px; color: #888; }
.m-value { font-size: 22px; font-weight: 700; margin-top: 4px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.card {
  background: #fff;
  padding: 16px;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card h2 {
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  font-weight: 600;
}
.card table { width: 100%; border-collapse: collapse; }
.card td, .card th {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}
.card th { font-weight: 600; color: #666; font-size: 12px; }

/* Bar chart afluencia */
.bar-chart {
  display: flex;
  align-items: flex-end;
  height: 120px;
  gap: 3px;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.bar {
  width: 100%;
  background: #1976d2;
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: height 0.2s;
}
.bar-label { font-size: 10px; color: #666; margin-top: 4px; }

/* Comparativos grid */
.cmp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  text-align: center;
}
.cmp-grid > div { padding: 8px; }
.cmp-grid span { display: block; font-size: 12px; color: #888; margin-bottom: 4px; }

/* Clientes stats */
.cli-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.cli-stats div { text-align: center; padding: 8px; }
.cli-stats span { display: block; font-size: 12px; color: #888; }
.cli-stats strong { font-size: 24px; }

/* Clean card rows */
.clean-card .cc-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
}
.clean-card .cc-row:last-child { border-bottom: none; }

.muted { color: #888; font-style: italic; text-align: center; }

/* Comparador */
.comparar {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: flex-start;
}
.sidebar {
  background: #fff;
  padding: 16px;
  border-radius: 10px;
  position: sticky;
  top: 80px;
}
.sidebar h2 {
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.sidebar label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: #555;
}
.sidebar input, .sidebar select {
  width: 100%;
  padding: 6px;
  margin-top: 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}
.sidebar fieldset {
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 12px;
}
.sidebar legend { font-size: 12px; color: #888; padding: 0 4px; }
#suc-checks { display: flex; flex-direction: column; gap: 4px; }
#suc-checks input { width: auto; margin-right: 6px; }
#suc-checks label { display: inline; margin: 0; font-size: 13px; }
#suc-checks > div { display: flex; align-items: center; }
.sidebar button {
  width: 100%;
  padding: 10px;
  background: #1976d2;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.sidebar button:hover { background: #1565c0; }

.main-compare {
  background: #fff;
  padding: 16px;
  border-radius: 10px;
  min-height: 400px;
}
.main-compare canvas { max-height: 320px; }
#tabla-compare { margin-top: 16px; }
#tabla-compare table { width: 100%; border-collapse: collapse; }
#tabla-compare td, #tabla-compare th {
  padding: 6px 8px;
  text-align: right;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}
#tabla-compare td:first-child, #tabla-compare th:first-child { text-align: left; }

/* Mobile */
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .metric-cards { grid-template-columns: repeat(2, 1fr); }
  .comparar { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .hero-amount { font-size: 36px; }
  .topbar { padding: 12px 16px; }
  .brand { font-size: 14px; }
  .tabs a { margin-left: 8px; padding: 4px 8px; font-size: 13px; }
  main { padding: 12px; }
}

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(180deg, #fafafa, #ececec); }
.login-main { width: 100%; max-width: 400px; padding: 20px; }
.login-card { background: #fff; padding: 32px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-sub { color: #666; font-size: 14px; margin-bottom: 20px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: #555; }
.login-card input { width: 100%; padding: 10px; margin-top: 4px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.login-card input:focus { outline: none; border-color: #1976d2; }
.login-card button { width: 100%; padding: 12px; background: #1976d2; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 14px; margin-top: 8px; }
.login-card button:hover { background: #1565c0; }
.login-card .error { background: #ffebee; color: #b71c1c; padding: 10px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }

/* Tendencias view */
.tendencias-header { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.cruce-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.cruce-pill {
  padding: 6px 14px; background: #fff; color: #555; text-decoration: none;
  border-radius: 20px; font-size: 14px; font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: background 0.1s, color 0.1s;
}
.cruce-pill:hover { background: #f0f0f0; }
.cruce-pill.active { background: #1976d2; color: #fff; }
.cruce-meta { color: #666; font-size: 14px; flex: 1; min-width: 200px; }
#suc-filter { padding: 6px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; background: #fff; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; padding: 16px; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.kpi-label { font-size: 12px; color: #888; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-actual { font-size: 24px; font-weight: 700; margin: 6px 0; }
.kpi-meta { font-size: 13px; color: #666; }
.kpi-comparable { color: #999; font-size: 12px; }

.chart-section {
  background: #fff; padding: 16px; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05); margin-bottom: 16px;
}
.chart-section canvas { max-height: 320px; }

.suc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.suc-card {
  display: block; padding: 14px; background: #fff; border-radius: 10px;
  text-decoration: none; color: inherit; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: transform 0.1s;
}
.suc-card:hover { transform: translateY(-2px); }
.suc-name { font-size: 13px; color: #666; }
.suc-amount { font-size: 20px; font-weight: 700; margin: 4px 0; }
.suc-delta { margin-bottom: 8px; }
.suc-spark { display: flex; align-items: flex-end; height: 36px; gap: 2px; }
.suc-spark .spark-bar { flex: 1; background: #1976d2; min-height: 2px; border-radius: 1px 1px 0 0; }

@media (max-width: 768px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .tendencias-header { flex-direction: column; align-items: stretch; }
  #suc-filter { width: 100%; }
}

/* Análisis page */
.analisis-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.analisis-header h2 { font-size: 22px; }
#analisis-suc { padding: 6px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; background: #fff; }

.analisis-section { margin-bottom: 24px; }
.analisis-section h3 {
  font-size: 12px; color: #888; text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 12px; font-weight: 600;
}

.chart-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card {
  background: #fff; padding: 16px; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.chart-card h4 { font-size: 14px; color: #444; margin-bottom: 12px; }
.chart-card canvas { max-height: 280px; }

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

/* Pareto table */
.pareto-table { width: 100%; border-collapse: collapse; }
.pareto-table th, .pareto-table td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid #f0f0f0; font-size: 14px;
}
.pareto-table th { font-weight: 600; color: #666; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.pareto-table td:nth-child(1) { width: 40px; color: #888; }
.pareto-table td:nth-child(3),
.pareto-table td:nth-child(4),
.pareto-table td:nth-child(5) { text-align: right; }
.pareto-footer { padding: 12px 10px 0; font-size: 13px; color: #666; font-style: italic; }

/* Heatmap container needs explicit height */
#chart-heatmap { min-height: 280px; }
