/* ══════════════════════════════════════════════════════════════════════
   Regio Poder — Dashboard de Inteligencia Digital
   Tema oscuro. Sin frameworks.
   Basado en el design system de HubOne (Roboto títulos + Inter texto,
   primario #4D42F8) adaptado a fondo oscuro.
   ══════════════════════════════════════════════════════════════════════ */

:root {
  --bg:         #0b0d16;
  --surface:    #141728;
  --surface-2:  #1b1f34;
  --surface-3:  #232842;
  --border:     #272c45;
  --border-soft:#1e2338;

  --text:       #e9ebf5;
  --text-dim:   #a3a9c4;
  --text-mute:  #6e7595;

  --primary:    #6c5cff;
  --primary-dim:#4d42f8;
  --primary-glow: rgba(108, 92, 255, .28);

  /* Color de marca de Regio Poder, tomado del propio logo (#c8dd00) */
  --brand:      #c8dd00;
  --brand-soft: rgba(200, 221, 0, .10);
  --brand-line: rgba(200, 221, 0, .24);

  --instagram:  #f0568f;
  --facebook:   #3d8bff;
  --success:    #3ddc97;
  --warning:    #ffb454;
  --danger:     #ff5c7a;
  --cyan:       #38d6e0;

  --radius:     14px;
  --sidebar-w:  258px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand-text strong, .kpi-value {
  font-family: 'Roboto', 'Inter', sans-serif;
  letter-spacing: -.02em;
}

/* ══ SIDEBAR ════════════════════════════════════════════════════════ */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.brand-mark {
  width: 42px; height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  display: grid; place-items: center;
  box-shadow: 0 4px 16px rgba(200, 221, 0, .12);
}

.brand-mark img {
  display: block;
  width: 20px;
  height: auto;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; font-weight: 700; }
.brand-text span { font-size: 11px; color: var(--text-mute); letter-spacing: .04em; }

.nav {
  flex: 1;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 13px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); }

.nav-item.active {
  background: linear-gradient(90deg, rgba(108,92,255,.20), rgba(108,92,255,.05));
  color: #fff;
  box-shadow: inset 2px 0 0 var(--primary);
}

.nav-ico {
  font-size: 11px;
  width: 14px;
  text-align: center;
  color: var(--primary);
  opacity: .75;
}
.nav-item.active .nav-ico { opacity: 1; }

.sidebar-foot {
  padding: 16px 20px;
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  color: var(--text-mute);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.badge-draft {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(255, 180, 84, .12);
  border: 1px solid rgba(255, 180, 84, .3);
  color: var(--warning);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
}

/* ══ MAIN ═══════════════════════════════════════════════════════════ */

.main {
  margin-left: var(--sidebar-w);
  padding: 26px 30px 60px;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.topbar h1 { font-size: 25px; font-weight: 700; }
.topbar p  { color: var(--text-mute); font-size: 13px; margin-top: 2px; }

.range-picker {
  display: flex;
  gap: 3px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.range-picker button {
  padding: 7px 15px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.range-picker button:hover { color: var(--text); }
.range-picker button.active {
  background: var(--primary-dim);
  color: #fff;
  box-shadow: 0 2px 10px var(--primary-glow);
}

/* ══ TABS ═══════════════════════════════════════════════════════════ */

.tab { display: none; }
.tab.active { display: block; animation: fade .25s ease; }

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ══ KPI CARDS ══════════════════════════════════════════════════════ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi {
  position: relative;
  padding: 17px 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

.kpi::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--accent, var(--primary));
  opacity: .85;
}

.kpi-label {
  font-size: 11.5px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}

.kpi-value {
  font-size: 27px;
  font-weight: 700;
  margin-top: 6px;
  line-height: 1.15;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.kpi-sub .up   { color: var(--success); font-weight: 600; }
.kpi-sub .down { color: var(--danger);  font-weight: 600; }

/* ══ CARDS / GRID ═══════════════════════════════════════════════════ */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 19px 20px 22px;
  margin-bottom: 18px;
}

.card h3 {
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 18px;
}
.grid-2 > .card { margin-bottom: 18px; }

.chart-wrap { position: relative; height: 260px; }
.chart-wrap.tall  { height: 340px; }
.chart-wrap.xtall { height: 430px; }

/* ══ TABLAS ═════════════════════════════════════════════════════════ */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-mute);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-dim);
}

tbody tr:hover td { background: var(--surface-2); color: var(--text); }
tbody tr:last-child td { border-bottom: 0; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.strong { color: var(--text); font-weight: 600; }

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.pill.instagram { background: rgba(240, 86, 143, .14); color: var(--instagram); }
.pill.facebook  { background: rgba(61, 139, 255, .14); color: var(--facebook); }

/* barra de progreso dentro de tablas */
.bar {
  position: relative;
  height: 6px;
  min-width: 90px;
  background: var(--surface-3);
  border-radius: 4px;
  overflow: hidden;
}
.bar span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 4px;
  background: var(--primary);
}
.bar span.ok   { background: var(--success); }
.bar span.warn { background: var(--warning); }
.bar span.bad  { background: var(--danger); }

/* ══ AVISOS / ESTADOS ═══════════════════════════════════════════════ */

.note {
  padding: 13px 16px;
  margin-bottom: 18px;
  background: rgba(255, 180, 84, .07);
  border: 1px solid rgba(255, 180, 84, .25);
  border-left: 3px solid var(--warning);
  border-radius: 10px;
  color: #f0d5a8;
  font-size: 12.5px;
}

.loader {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  color: var(--text-mute);
  font-size: 13px;
}
.loader span {
  width: 15px; height: 15px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  padding: 13px 16px;
  margin-bottom: 18px;
  background: rgba(255, 92, 122, .08);
  border: 1px solid rgba(255, 92, 122, .3);
  border-radius: 10px;
  color: #ffb3c1;
  font-size: 13px;
}

.hidden { display: none !important; }

/* ══ RESPONSIVE ═════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: 100%;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
  }
  .brand { border-bottom: 0; padding: 14px 16px; }
  .nav { flex-direction: row; padding: 10px; }
  .nav-item { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .main { margin-left: 0; padding: 20px 16px 50px; }
  .grid-2 { grid-template-columns: 1fr; }
}
