/* ═══════════════════════════════════════════════════════════════
   Millennium Energy · Dashboard Solar PPA
   Diseño inspirado en enSights.ai
   ═══════════════════════════════════════════════════════════════ */

:root {
  --primary: #1ea0b8;
  --primary-dark: #157a8d;
  --primary-light: #e7f6f9;
  --accent: #f6c01a;
  --green: #4aa83b;
  --green-light: #e8f5e9;
  --blue-dark: #2a6ab8;
  --red: #dc3545;
  --red-light: #ffebee;
  --orange: #ff9800;
  --orange-light: #fff3e0;
  --bg: #f4f6f9;
  --sidebar-bg: #0d1a2b;
  --sidebar-hover: #1a2a42;
  --sidebar-active: var(--primary);
  --sidebar-text: #c7d0dd;
  --sidebar-text-muted: #8a95a8;
  --card: #ffffff;
  --text: #1f2d3d;
  --muted: #6c757d;
  --border: #e5ebf2;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ═══════ Layout con Sidebar ═══════ */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 18px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 16px;
}
.sidebar-brand img {
  max-width: 160px;
  width: 100%;
  height: auto;
  filter: brightness(1.1);
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-menu li {
  margin: 2px 10px;
}
.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
}
.sidebar-menu a:hover {
  background: var(--sidebar-hover);
  color: white;
  text-decoration: none;
}
.sidebar-menu a.active {
  background: var(--primary);
  color: white;
}
.sidebar-menu .icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
}
.sidebar-menu .badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 10px;
}

.sidebar-section-label {
  padding: 16px 22px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sidebar-text-muted);
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  padding: 20px 22px;
  font-size: 11px;
  color: var(--sidebar-text-muted);
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ═══════ Main Content ═══════ */
.main-content {
  padding: 20px 28px;
  max-width: 100%;
  overflow-x: hidden;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.page-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}
.page-header .spacer { flex: 1; }

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-size: 13px;
}
.user-menu .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--blue-dark));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 13px;
}

/* ═══════ Flash ═══════ */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  border-left: 4px solid;
  background: white;
  box-shadow: var(--shadow-sm);
}
.flash-success { border-color: var(--green); }
.flash-error   { border-color: var(--red); }
.flash-warning { border-color: var(--orange); }
.flash-info    { border-color: var(--primary); }

/* ═══════ KPI Cards ═══════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.kpi-card .kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.kpi-card .kpi-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  font-weight: 600;
}
.kpi-card .kpi-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.kpi-card .kpi-icon svg {
  width: 20px; height: 20px; stroke-width: 2;
}
.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.kpi-card .kpi-unit {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}
.kpi-card .kpi-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.kpi-card .kpi-change {
  font-size: 12px;
  margin-top: 6px;
  font-weight: 600;
}
.kpi-change.up { color: var(--green); }
.kpi-change.down { color: var(--red); }

.kpi-card.primary .kpi-icon { background: var(--primary-light); color: var(--primary); }
.kpi-card.green .kpi-icon { background: var(--green-light); color: var(--green); }
.kpi-card.orange .kpi-icon { background: var(--orange-light); color: var(--orange); }
.kpi-card.accent .kpi-icon { background: #fff8e1; color: #f59e0b; }

/* ═══════ Card ═══════ */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card h3, .card-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* ═══════ Grid layouts ═══════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 2fr 3fr 1.5fr; gap: 20px; }
@media (max-width: 1200px) {
  .grid-3 { grid-template-columns: 1fr; }
}

/* ═══════ Hamburger + sidebar overlay (mobile) ═══════ */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  padding: 0;
  transition: background .15s;
}
.hamburger:hover { background: var(--bg); }
.hamburger svg { width: 22px; height: 22px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 26, 43, 0.5);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

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

  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: 260px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay { display: block; }

  .hamburger { display: inline-flex; }

  .main-content { padding: 14px 16px; }

  .page-header {
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
  }
  .page-header h1 { font-size: 18px; }

  .user-menu { padding: 5px 10px; font-size: 12px; }
  .user-menu-email { display: none; }

  /* Cards con tabla: scroll horizontal en mobile */
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card table { min-width: 640px; }

  .kpi-card .kpi-value { font-size: 22px; }
  .kpi-card { padding: 16px; }

  /* Botones en page-actions más compactos */
  .page-header .btn.small { padding: 6px 10px; font-size: 11px; }

  /* Map más bajo */
  .map-wrap { height: 280px; }
  .chart-wrap { height: 220px; }
}

@media (max-width: 480px) {
  .main-content { padding: 12px; }
  .kpi-grid { gap: 10px; }
  .kpi-card .kpi-value { font-size: 20px; }
  .page-header h1 { font-size: 16px; }
}

/* ═══════ Tables ═══════ */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
  position: sticky;
  top: 0;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: var(--bg); }
tfoot td { background: #f8fafc; font-weight: 700; }

/* ═══════ Map ═══════ */
.map-wrap {
  height: 420px;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
#stations-map {
  height: 100%;
  width: 100%;
}

/* ═══════ Ring (donut) ═══════ */
.ring-container {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.ring-inner {
  position: absolute;
  text-align: center;
}
.ring-inner .pct { font-size: 22px; font-weight: 700; color: var(--text); }
.ring-inner .label { font-size: 11px; color: var(--muted); text-transform: uppercase; }

/* ═══════ Alerts panel ═══════ */
.alerts-panel { max-height: 420px; overflow-y: auto; }
.alert-row {
  padding: 10px 12px;
  border-left: 3px solid;
  margin-bottom: 6px;
  background: #f8fafc;
  border-radius: 6px;
  font-size: 13px;
}
.alert-row.critical, .alert-row.error { border-color: var(--red); }
.alert-row.warning { border-color: var(--orange); }
.alert-row.info { border-color: var(--primary); }
.alert-row .title { font-weight: 600; margin-bottom: 2px; }
.alert-row .meta { font-size: 11px; color: var(--muted); }

/* ═══════ Buttons ═══════ */
.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s;
}
.btn:hover { background: var(--primary-dark); color: white; text-decoration: none; }
.btn.secondary { background: #e0e6ed; color: var(--text); }
.btn.secondary:hover { background: #c8d0d8; }
.btn.danger { background: var(--red); }
.btn.success { background: var(--green); }
.btn.accent { background: var(--accent); color: #2d2d2d; }
.btn.small { padding: 5px 10px; font-size: 12px; }

/* ═══════ Forms ═══════ */
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  background: white;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,160,184,.1);
}
textarea { min-height: 80px; }
label {
  display: block; margin-top: 12px;
  font-size: 12px; font-weight: 600;
  color: var(--muted); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: .3px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* ═══════ Login ═══════ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, #e8f4f8 0%, #f4f6f9 100%);
}
.login-left {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.login-right {
  flex: 1;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 40px;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}
@media (min-width: 900px) { .login-right { display: flex; } }

.login-box {
  max-width: 400px;
  width: 100%;
  padding: 40px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.login-box h1 {
  text-align: center; color: var(--primary); margin: 0 0 8px;
  font-size: 22px;
}
.login-logo {
  display: flex; justify-content: center;
  margin-bottom: 20px;
}
.login-logo img { max-width: 200px; width: 100%; height: auto; }

/* ═══════ Toolbar ═══════ */
.toolbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.toolbar h2 { margin: 0; font-size: 20px; font-weight: 600; }

/* ═══════ Badge ═══════ */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge.green { background: var(--green-light); color: var(--green); }
.badge.red   { background: var(--red-light); color: var(--red); }
.badge.orange{ background: var(--orange-light); color: var(--orange); }
.badge.gray  { background: #f0f0f0; color: var(--muted); }
.badge.blue  { background: var(--primary-light); color: var(--primary-dark); }

/* ═══════ Chart ═══════ */
.chart-wrap { position: relative; height: 260px; }

/* Filtros de rango (7/30/90d) */
.range-filters {
  display: flex;
  gap: 4px;
  background: #f0f4f8;
  padding: 3px;
  border-radius: 999px;
}
.range-btn {
  background: transparent;
  border: none;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.range-btn:hover { color: var(--text); }
.range-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* Mini sparklines en KPI cards */
.kpi-spark {
  margin-top: 10px;
  height: 28px;
  position: relative;
}
.kpi-spark canvas {
  width: 100% !important;
  height: 28px !important;
}

/* Ranking list (Top 5 con medallas) */
.ranking-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ranking-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.ranking-list li:last-child { border-bottom: none; }

.rank-badge {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: white;
  background: #8a95a8;  /* default: gray */
}
.rank-badge.rank-1 {
  background: linear-gradient(135deg, #f6c01a, #d89b00);  /* oro */
  box-shadow: 0 2px 6px rgba(246, 192, 26, .4);
}
.rank-badge.rank-2 {
  background: linear-gradient(135deg, #c0c5cc, #8a95a8);  /* plata */
}
.rank-badge.rank-3 {
  background: linear-gradient(135deg, #cd7f32, #8b5a2b);  /* bronce */
}

.rank-body { flex: 1; min-width: 0; }
.rank-body a {
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-body a:hover { color: var(--primary); }
.rank-sub {
  font-size: 11px;
  color: var(--muted);
}
.rank-value {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ═══════ Reportes (index + daily + monthly) ═══════ */
.reports-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 26px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-radius: var(--radius);
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.reports-hero-content h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
  color: white;
}
.reports-hero-content p {
  margin: 0;
  font-size: 14px;
  opacity: 0.9;
  line-height: 1.5;
}
.reports-hero-icon {
  width: 72px; height: 72px;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.reports-hero-icon svg {
  width: 36px; height: 36px;
  color: white;
  stroke-width: 1.5;
}

.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.report-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform .15s, box-shadow .15s;
}
.report-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.report-card-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.report-card-header h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.report-card-header p {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
}

.report-card-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.report-card-icon svg {
  width: 22px; height: 22px;
  stroke-width: 2;
}
.report-card-icon.accent-primary { background: var(--primary-light); color: var(--primary); }
.report-card-icon.accent-green { background: var(--green-light); color: var(--green); }
.report-card-icon.accent-orange { background: var(--orange-light); color: var(--orange); }

.report-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.report-form label {
  margin-top: 0;
  margin-bottom: 4px;
}
.report-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.report-form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.report-form-actions .btn {
  flex: 1;
  justify-content: center;
  display: inline-flex;
  align-items: center;
}
.report-info {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.report-info svg {
  width: 16px; height: 16px;
  color: var(--primary);
  flex-shrink: 0;
  margin-top: 1px;
}

.months-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.month-chip {
  padding: 7px 14px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}
.month-chip:hover {
  background: var(--primary);
  color: white;
  text-decoration: none;
}
.month-chip b { font-weight: 700; }

/* Navegación del reporte (daily/monthly) */
.report-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.report-nav-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.report-nav-form input, .report-nav-form select {
  padding: 7px 12px;
  font-size: 13px;
  width: auto;
}
.report-nav-form input[type="date"] { min-width: 140px; }
.report-nav-form select { min-width: 120px; }
.report-nav-form .btn svg { width: 14px; height: 14px; }

.report-nav-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
}
.report-nav-title svg {
  width: 18px; height: 18px;
  color: var(--primary);
}

/* Tabla del reporte */
.report-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.report-table thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
}
.report-table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.report-table tbody tr:hover td {
  background: #f8fafc;
}
.report-table tfoot td {
  background: var(--primary-light);
  font-weight: 700;
  font-size: 14px;
  padding: 12px;
  color: var(--primary-dark);
  border-top: 2px solid var(--primary);
}
.report-table .num { font-variant-numeric: tabular-nums; text-align: right; }

.backfill-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 500;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
}
.backfill-tag svg { width: 11px; height: 11px; }

/* Banner de estado de sincronización */
.sync-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  flex-wrap: wrap;
}
.sync-status.fresh {
  background: var(--green-light);
  border-left: 4px solid var(--green);
  color: var(--text);
}
.sync-status.stale {
  background: var(--orange-light);
  border-left: 4px solid var(--orange);
  color: var(--text);
}
.sync-status-left {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex: 1;
  min-width: 260px;
}
.sync-status-left > svg {
  width: 22px; height: 22px;
  flex-shrink: 0;
  margin-top: 2px;
}
.sync-status.fresh .sync-status-left > svg { color: var(--green); }
.sync-status.stale .sync-status-left > svg { color: var(--orange); }
.sync-status-title {
  font-weight: 600;
  margin-bottom: 2px;
}
.sync-status-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.sync-status-action {
  margin: 0;
}

/* Grid de charts múltiples en reportes */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 18px;
  margin-top: 20px;
}
.charts-grid .card { margin-bottom: 0; }
@media (max-width: 768px) {
  .charts-grid { grid-template-columns: 1fr; }
}

/* ═══════ FAQ (página de ayuda) ═══════ */
.faq-intro {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 14px;
  color: var(--text);
}
.faq-intro p { margin: 0; }

.faq-sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 900px;
}

.faq-section {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.faq-section > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  user-select: none;
  transition: background .15s;
}
.faq-section > summary::-webkit-details-marker { display: none; }
.faq-section > summary:hover { background: var(--bg); }
.faq-section > summary > svg:first-child {
  width: 20px; height: 20px;
  color: var(--primary);
  flex-shrink: 0;
}
.faq-section > summary > span {
  flex: 1;
}
.faq-chevron {
  width: 18px; height: 18px;
  color: var(--muted);
  transition: transform .2s;
}
.faq-section[open] .faq-chevron {
  transform: rotate(180deg);
}

.faq-body {
  padding: 4px 20px 16px 52px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.faq-q {
  border-top: 1px solid var(--border);
}
.faq-q > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 0;
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
  user-select: none;
  position: relative;
  padding-left: 20px;
}
.faq-q > summary::-webkit-details-marker { display: none; }
.faq-q > summary::before {
  content: "›";
  position: absolute;
  left: 0;
  top: 10px;
  color: var(--primary);
  font-weight: 700;
  font-size: 18px;
  transition: transform .2s;
}
.faq-q[open] > summary::before {
  transform: rotate(90deg);
}
.faq-q > summary:hover { color: var(--primary); }

.faq-q > div {
  padding: 4px 0 14px 20px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}
.faq-q > div b { color: var(--text); }
.faq-q > div p:first-child { margin-top: 0; }
.faq-q > div p:last-child { margin-bottom: 0; }
.faq-q > div ul, .faq-q > div ol {
  margin: 6px 0;
  padding-left: 22px;
}
.faq-q > div li { margin-bottom: 4px; }
.faq-q > div code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--primary-dark);
}

/* ═══════ Help panel (colapsable) ═══════ */
.help-panel {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  overflow: hidden;
}
.help-panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  user-select: none;
  transition: background .15s;
}
.help-panel > summary::-webkit-details-marker { display: none; }
.help-panel > summary:hover { background: var(--bg); }
.help-panel > summary > svg:first-child {
  width: 20px; height: 20px;
  color: var(--primary);
  flex-shrink: 0;
}
.help-panel > summary > span {
  flex: 1;
}
.help-chevron {
  width: 18px; height: 18px;
  color: var(--muted);
  transition: transform .2s;
}
.help-panel[open] .help-chevron {
  transform: rotate(180deg);
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  padding: 0 20px 20px;
}

.help-item {
  padding: 14px 16px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}
.help-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.help-item-header svg {
  width: 16px; height: 16px;
  color: var(--primary);
  flex-shrink: 0;
}
.help-item h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.help-item p {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.help-item p b {
  color: var(--text);
  font-weight: 600;
}
.help-item code {
  background: #e7f6f9;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--primary-dark);
}
.help-when {
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  line-height: 1.5;
}
.help-when b { color: var(--text); }

/* ═══════ Backfill note (reporte diario / mensual) ═══════ */
.backfill-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: #e7f6f9;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 18px;
}
.backfill-note svg {
  flex-shrink: 0;
  width: 22px; height: 22px;
  color: var(--primary);
  margin-top: 2px;
}
.backfill-note b { color: var(--primary-dark); }

/* ═══════ Card link + empty state + button icon ═══════ */
.card-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
}
.card-link svg { width: 14px; height: 14px; }
.card-link:hover { text-decoration: none; color: var(--primary-dark); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.empty-state svg {
  width: 32px; height: 32px;
  color: var(--green);
  stroke-width: 1.5;
}

.btn-icon {
  width: 14px; height: 14px;
  vertical-align: -2px;
  margin-right: 4px;
}

/* ═══════ Util ═══════ */
.muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }


/* ═══════════════════════════════════════════════════════════
   VISTA OPERACIONAL — grid de tiendas con curva del día
   ═══════════════════════════════════════════════════════════ */
.ops-overview {
  margin-bottom: 24px;
  padding: 22px 24px 24px;
  background:
    radial-gradient(ellipse at top right, rgba(30,160,184,.06), transparent 50%),
    #fff;
}

.ops-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.ops-header h3 { font-size: 17px; font-weight: 700; }
.ops-time {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: #f3f4f6;
  padding: 3px 10px;
  border-radius: 100px;
  font-variant-numeric: tabular-nums;
}
.ops-pulse {
  display: inline-flex;
  width: 10px; height: 10px;
  position: relative;
}
.ops-pulse > span {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  position: absolute; inset: 0;
}
.ops-pulse::before {
  content: '';
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  position: absolute; inset: 0;
  animation: opsPulse 1.6s ease-out infinite;
}
@keyframes opsPulse {
  0%   { transform: scale(1);   opacity: .6; }
  100% { transform: scale(2.6); opacity: 0;  }
}

.ops-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.ops-controls input[type="date"] {
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}
.ops-filter {
  display: flex;
  background: #f3f4f6;
  border-radius: 100px;
  padding: 3px;
  gap: 2px;
}
.ops-chip {
  padding: 6px 14px;
  border: 0;
  background: transparent;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.ops-chip:hover { color: #111827; }
.ops-chip.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* KPI strip — 6 mini KPIs en una fila */
.ops-kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 22px;
}
.ops-kpi {
  background: #fff;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}
.ops-kpi .kpi-num {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: #111827;
}
.ops-kpi .kpi-lbl {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.ops-kpi.total       { background: linear-gradient(135deg, #ecfeff, #f0f9ff); }
.ops-kpi.total .kpi-num { color: var(--primary-dark); }
.ops-kpi.today       { background: linear-gradient(135deg, #f0fdf4, #ecfdf5); }
.ops-kpi.today .kpi-num { color: #047857; }
.ops-kpi.st-critical .kpi-num { color: #dc2626; }
.ops-kpi.st-warning  .kpi-num { color: #d97706; }
.ops-kpi.st-offline  .kpi-num { color: #6b7280; }
.ops-kpi.st-ok       .kpi-num { color: #059669; }

@media (max-width: 980px) {
  .ops-kpi-strip { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 540px) {
  .ops-kpi-strip { grid-template-columns: repeat(2, 1fr); }
}

/* Tabs / filtros tipo Deye */
.ops-filters {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0;
  overflow-x: auto;
}
.ops-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
  white-space: nowrap;
}
.ops-tab:hover { color: #111827; background: #f9fafb; }
.ops-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.ops-tab .count {
  font-size: 11.5px;
  font-weight: 700;
  background: #f3f4f6;
  color: #4b5563;
  padding: 1px 7px;
  border-radius: 100px;
  font-variant-numeric: tabular-nums;
}
.ops-tab.active .count {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* Search input */
.ops-search {
  padding: 7px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  width: 200px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.ops-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,160,184,.15);
}

/* Status dots universales */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  vertical-align: middle;
}
.dot.ok       { background: #10b981; box-shadow: 0 0 0 2px #d1fae5; }
.dot.warning  { background: #f59e0b; box-shadow: 0 0 0 2px #fef3c7; }
.dot.critical { background: #dc2626; box-shadow: 0 0 0 2px #fee2e2; }
.dot.offline  { background: #9ca3af; box-shadow: 0 0 0 2px #e5e7eb; }

/* Tabla de operaciones */
.ops-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid #f1f5f9;
}
.ops-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.ops-table thead {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.ops-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: #64748b;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
  user-select: none;
}
.ops-table th.center { text-align: center; }
.ops-table th.num { text-align: right; }
.ops-table th .u {
  font-size: 10.5px;
  color: #94a3b8;
  font-weight: 500;
  margin-left: 2px;
}
.ops-table th.sortable { cursor: pointer; }
.ops-table th.sortable:hover { color: var(--primary); }
.ops-table th.sortable::after { content: ''; opacity: 0; }
.ops-table th.sortable.asc::after  { content: ' ▲'; opacity: .6; font-size: 9px; }
.ops-table th.sortable.desc::after { content: ' ▼'; opacity: .6; font-size: 9px; }

.ops-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background .12s;
  cursor: pointer;
}
.ops-table tbody tr:last-child { border-bottom: 0; }
.ops-table tbody tr:hover {
  background: #f0f9fb;
}
.ops-table tbody tr.critical {
  background: rgba(254, 226, 226, .35);
}
.ops-table tbody tr.critical:hover {
  background: rgba(254, 226, 226, .55);
}
.ops-table tbody tr.warning {
  background: rgba(254, 243, 199, .25);
}
.ops-table tbody tr.warning:hover {
  background: rgba(254, 243, 199, .45);
}
.ops-table tbody tr.offline td:first-child::before {
  content: '';
  display: inline-block;
  width: 3px; height: 24px;
  background: #9ca3af;
  margin-right: 8px;
  vertical-align: middle;
  border-radius: 2px;
}
.ops-table tbody tr.critical td:first-child::before {
  content: '';
  display: inline-block;
  width: 3px; height: 24px;
  background: #dc2626;
  margin-right: 8px;
  vertical-align: middle;
  border-radius: 2px;
}

.ops-table td {
  padding: 12px 14px;
  vertical-align: middle;
  color: #1f2937;
}
.ops-table td.center { text-align: center; }
.ops-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ops-name {
  font-weight: 600;
  color: #111827;
  font-size: 13.5px;
}
.ops-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.trend-spark {
  width: 120px;
  height: 36px;
  margin: 0 auto;
}
.trend-spark canvas { width: 100% !important; height: 100% !important; }
.trend-empty { color: var(--muted); font-size: 13px; }
