:root {
      --bg: #f0f0ee;
      --white: #ffffff;
      --dark: #161618;
      --mid: #3a3a3a;
      --muted: #8c8c8c;
      --border: #e2e2de;
      --accent: #e84c30;
      --accent-l: rgba(232, 76, 48, 0.1);
      --green: #16a34a;
      --green-l: rgba(22, 163, 74, 0.1);
      --blue: #1877f2;
      --blue-l: rgba(24, 119, 242, 0.1);
      --ig: #e1306c;
      --ig-l: rgba(225, 48, 108, 0.1);
      --yellow: #d97706;
      --yellow-l: rgba(217, 119, 6, 0.1);
      --purple: #7c3aed;
      --purple-l: rgba(124, 58, 237, 0.1);
    }

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

    body {
      font-family: 'Manrope', sans-serif;
      background: var(--bg);
      color: var(--dark);
      min-height: 100vh;
    }

    .shell {
      display: grid;
      grid-template-columns: 224px 1fr;
      min-height: 100vh;
    }

    /* Sidebar */
    .sidebar {
      background: var(--dark);
      padding: 28px 18px;
      display: flex;
      flex-direction: column;
      gap: 20px;
      position: sticky;
      top: 0;
      height: 100vh;
      overflow-y: auto;
    }

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

    .logo-mark {
      width: 34px;
      height: 34px;
      background: var(--accent);
      border-radius: 9px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 15px;
      font-weight: 900;
      color: #fff;
    }

    .logo-name {
      font-size: 13px;
      font-weight: 800;
      color: #fff;
      line-height: 1.2;
    }

    .logo-sub {
      font-size: 9px;
      color: rgba(255, 255, 255, 0.35);
      font-weight: 500;
    }

    .nav-section {
      display: flex;
      flex-direction: column;
      gap: 2px;
    }

    .nav-label {
      font-size: 9px;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: rgba(255, 255, 255, 0.25);
      font-weight: 700;
      margin-bottom: 6px;
      padding: 0 10px;
    }

    .nav-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 9px 12px;
      border-radius: 8px;
      font-size: 12px;
      font-weight: 600;
      color: rgba(255, 255, 255, 0.45);
      cursor: pointer;
      transition: all 0.15s;
      user-select: none;
    }

    .nav-item:hover {
      color: #fff;
      background: rgba(255, 255, 255, 0.06);
    }

    .nav-item.active {
      color: #fff;
      background: var(--accent);
    }

    .filter-box {
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid rgba(255, 255, 255, 0.07);
      border-radius: 12px;
      padding: 16px;
      margin-top: auto;
    }

    .filter-box-title {
      font-size: 9px;
      font-weight: 700;
      color: rgba(255, 255, 255, 0.3);
      text-transform: uppercase;
      letter-spacing: 0.1em;
      margin-bottom: 12px;
    }

    .filter-group {
      margin-bottom: 10px;
    }

    .filter-group:last-child {
      margin-bottom: 0;
    }

    .filter-label {
      font-size: 9px;
      font-weight: 700;
      color: rgba(255, 255, 255, 0.3);
      text-transform: uppercase;
      letter-spacing: 0.1em;
      margin-bottom: 5px;
    }

    .filter-select {
      width: 100%;
      background: rgba(255, 255, 255, 0.07);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 7px;
      padding: 7px 10px;
      font-size: 11px;
      font-weight: 600;
      color: #fff;
      font-family: 'Manrope', sans-serif;
      cursor: pointer;
      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='rgba(255,255,255,0.3)'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 10px center;
    }

    .filter-select:focus {
      outline: none;
      border-color: var(--accent);
    }

    .filter-select option {
      background: #1a1a1a;
      color: #fff;
    }

    .filter-reset {
      width: 100%;
      margin-top: 10px;
      padding: 7px;
      border-radius: 7px;
      border: 1px solid rgba(255, 255, 255, 0.1);
      background: transparent;
      color: rgba(255, 255, 255, 0.35);
      font-family: 'Manrope', sans-serif;
      font-size: 10px;
      font-weight: 700;
      cursor: pointer;
      transition: all 0.15s;
      letter-spacing: 0.05em;
    }

    .filter-reset:hover {
      background: rgba(255, 255, 255, 0.06);
      color: #fff;
    }

    /* Main */
    .main {
      display: flex;
      flex-direction: column;
      min-width: 0;
    }

    .topbar {
      background: var(--white);
      border-bottom: 1px solid var(--border);
      padding: 0 32px;
      height: 58px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: sticky;
      top: 0;
      z-index: 20;
    }

    .tab-label {
      font-size: 14px;
      font-weight: 800;
      color: var(--dark);
    }

    .topbar-r {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .chip {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 5px 12px;
      border-radius: 20px;
      font-size: 11px;
      font-weight: 700;
    }

    .chip-dark {
      background: var(--dark);
      color: #fff;
    }

    .chip-accent {
      background: var(--accent-l);
      color: var(--accent);
    }

    .chip-green {
      background: var(--green-l);
      color: var(--green);
    }

    .chip-blue {
      background: var(--blue-l);
      color: var(--blue);
    }

    .chip-purple {
      background: var(--purple-l);
      color: var(--purple);
    }

    .topbar-btn {
      border: 1px solid var(--border);
      background: var(--white);
      color: var(--mid);
      border-radius: 999px;
      font-size: 11px;
      font-weight: 700;
      padding: 6px 12px;
      cursor: pointer;
      transition: all 0.15s ease;
    }

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

    .content {
      padding: 32px 36px;
      display: flex;
      flex-direction: column;
      gap: 36px;
    }

    .screen {
      display: none;
    }

    .screen.active {
      display: flex;
      flex-direction: column;
      gap: 36px;
    }

    .screen-content {
      display: flex;
      flex-direction: column;
      gap: 36px;
    }

    /* Loading/Error/Empty */
    .loading {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 60px;
      flex-direction: column;
      gap: 12px;
    }

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

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

    .loading-text {
      font-size: 12px;
      color: var(--muted);
      font-weight: 600;
    }

    .error-box {
      background: #fff5f5;
      border: 1px solid #fecaca;
      border-radius: 12px;
      padding: 20px;
      font-size: 12px;
      color: #dc2626;
      font-weight: 600;
    }

    .empty-box {
      background: var(--white);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 48px;
      text-align: center;
    }

    .empty-box-icon {
      font-size: 32px;
      margin-bottom: 12px;
    }

    .empty-box-text {
      font-size: 13px;
      font-weight: 700;
      color: var(--mid);
      margin-bottom: 4px;
    }

    .empty-box-sub {
      font-size: 11px;
      color: var(--muted);
    }

    /* Card */
    .card {
      background: var(--white);
      border: 1px solid var(--border);
      border-radius: 14px;
      overflow: hidden;
    }

    .card-head {
      padding: 24px 28px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid var(--border);
    }

    .card-title {
      font-size: 14px;
      font-weight: 800;
    }

    .card-body {
      padding: 28px 28px;
    }

    /* Hero */
    .hero {
      display: flex;
      justify-content: space-between;
      align-items: flex-end;
    }

    .hero-eyebrow {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      background: var(--accent-l);
      color: var(--accent);
      border-radius: 20px;
      padding: 4px 12px;
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      margin-bottom: 8px;
    }

    .hero-eyebrow::before {
      content: '';
      width: 5px;
      height: 5px;
      border-radius: 50%;
      background: var(--accent);
    }

    h1 {
      font-size: clamp(28px, 4vw, 46px);
      font-weight: 900;
      letter-spacing: -0.03em;
      line-height: 0.95;
    }

    h1 .dim {
      color: var(--muted);
      font-weight: 400;
    }

    /* KPIs */
    .kpis {
      display: grid;
      gap: 24px;
    }

    .kpis-5 {
      grid-template-columns: repeat(5, 1fr);
    }

    .kpis-4 {
      grid-template-columns: repeat(4, 1fr);
    }

    .kpis-3 {
      grid-template-columns: repeat(3, 1fr);
    }

    .kpi {
      background: var(--white);
      border: 1px solid var(--border);
      border-radius: 14px;
      padding: 20px;
      position: relative;
      transition: transform 0.18s, box-shadow 0.18s;
    }

    .kpi:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
    }

    .kpi.dark {
      background: var(--dark);
      border-color: transparent;
    }

    .kpi-icon {
      width: 32px;
      height: 32px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      margin-bottom: 14px;
    }

    .kpi-val {
      font-size: 26px;
      font-weight: 900;
      letter-spacing: -0.03em;
      line-height: 1;
      margin-bottom: 4px;
    }

    .kpi.dark .kpi-val {
      color: #fff;
    }

    .kpi-name {
      font-size: 10px;
      font-weight: 600;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: 0.08em;
    }

    .kpi.dark .kpi-name {
      color: rgba(255, 255, 255, 0.35);
    }

    /* Pill */
    .pill {
      padding: 3px 9px;
      border-radius: 20px;
      font-size: 9px;
      font-weight: 700;
      letter-spacing: 0.05em;
      text-transform: uppercase;
    }

    .pill-dark {
      background: var(--dark);
      color: #fff;
    }

    .pill-green {
      background: var(--green-l);
      color: var(--green);
    }

    .pill-orange {
      background: var(--accent-l);
      color: var(--accent);
    }

    .pill-blue {
      background: var(--blue-l);
      color: var(--blue);
    }

    .pill-purple {
      background: var(--purple-l);
      color: var(--purple);
    }

    /* Plat badge */
    .plat {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 3px 8px;
      border-radius: 5px;
      font-size: 9px;
      font-weight: 700;
    }

    .plat.ig {
      background: var(--ig-l);
      color: var(--ig);
    }

    .plat.fb {
      background: var(--blue-l);
      color: var(--blue);
    }

    /* Table */
    .tbl-wrap {
      overflow-x: auto;
    }

    .tbl {
      width: 100%;
      border-collapse: collapse;
    }

    .tbl th {
      padding: 8px 14px;
      text-align: left;
      font-size: 9px;
      font-weight: 700;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--muted);
      border-bottom: 1px solid var(--border);
      white-space: nowrap;
    }

    .tbl td {
      padding: 12px 14px;
      border-bottom: 1px solid var(--border);
      font-size: 12px;
      white-space: nowrap;
    }

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

    /* Gráficos Interativos */
    .svg-elem {
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      cursor: crosshair;
    }

    .svg-elem:hover {
      opacity: 0.85;
      filter: brightness(1.1);
    }

    .svg-elem.bar {
      transform-origin: bottom;
    }

    .svg-elem.bar:hover {
      transform: scaleY(1.02);
    }

    .tbl tr:hover td {
      background: var(--bg);
    }

    .tbl th[onclick] {
      cursor: pointer;
      user-select: none;
      transition: background 0.2s, color 0.2s;
    }

    .tbl th[onclick]:hover {
      background: rgba(0, 0, 0, 0.03);
    }

    .tbl th.active-sort {
      color: var(--accent);
      background: rgba(0, 0, 0, 0.02);
    }

    .tbl td:nth-child(even),
    .tbl th:nth-child(even) {
      background: rgba(0, 0, 0, 0.015);
    }

    .n {
      font-weight: 700;
    }

    .n.or {
      color: var(--accent);
    }

    .n.gr {
      color: var(--green);
    }

    .n.bl {
      color: var(--blue);
    }

    .n.pu {
      color: var(--purple);
    }

    /* Bars */
    .bar-inline {
      height: 4px;
      background: var(--border);
      border-radius: 2px;
      overflow: hidden;
      margin-top: 5px;
    }

    .bar-inline-f {
      height: 100%;
      border-radius: 2px;
      transition: width 0.8s ease;
    }

    .comp-item {
      margin-bottom: 16px;
    }

    .comp-item:last-child {
      margin-bottom: 0;
    }

    .comp-head {
      display: flex;
      justify-content: space-between;
      margin-bottom: 6px;
    }

    .comp-name {
      font-size: 11px;
      font-weight: 700;
    }

    .comp-val {
      font-size: 11px;
      font-weight: 800;
    }

    .comp-bar {
      height: 6px;
      background: var(--border);
      border-radius: 3px;
      overflow: hidden;
    }

    .comp-fill {
      height: 100%;
      border-radius: 3px;
      transition: width 0.8s ease;
    }

    /* Grid */
    .grid2 {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 24px;
    }

    .grid3 {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 24px;
    }

    .grid4 {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 24px;
    }

    /* Conv cards */
    .conv-card {
      background: var(--white);
      border: 1px solid var(--border);
      border-radius: 14px;
      padding: 28px;
      position: relative;
      overflow: hidden;
    }

    .conv-card::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 3px;
    }

    .conv-card.c1::before {
      background: var(--accent);
    }

    .conv-card.c2::before {
      background: var(--green);
    }

    .conv-card.c3::before {
      background: var(--blue);
    }

    .conv-card.c4::before {
      background: var(--purple);
    }

    .conv-label {
      font-size: 10px;
      font-weight: 700;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: 0.1em;
      margin-bottom: 8px;
    }

    .conv-val {
      font-size: 40px;
      font-weight: 900;
      letter-spacing: -0.04em;
      line-height: 1;
    }

    .conv-card.c1 .conv-val {
      color: var(--accent);
    }

    .conv-card.c2 .conv-val {
      color: var(--green);
    }

    .conv-card.c3 .conv-val {
      color: var(--blue);
    }

    .conv-card.c4 .conv-val {
      color: var(--purple);
    }

    .conv-sub {
      font-size: 11px;
      color: var(--muted);
      margin-top: 4px;
    }

    .conv-detail {
      margin-top: 12px;
      border-top: 1px solid var(--border);
      padding-top: 12px;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .cdr {
      display: flex;
      justify-content: space-between;
      font-size: 11px;
    }

    .cdr span:first-child {
      color: var(--muted);
    }

    .cdr span:last-child {
      font-weight: 700;
    }

    /* Sum grid */
    .sum-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 1px;
      background: var(--border);
    }

    .sum-cell {
      background: var(--white);
      padding: 24px 28px;
    }

    .sum-label {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: var(--muted);
      margin-bottom: 8px;
    }

    .sum-val {
      font-size: 20px;
      font-weight: 900;
      letter-spacing: -0.02em;
    }

    /* Rank */
    .rank-item {
      display: flex;
      align-items: center;
      gap: 14px;
      padding: 12px 0;
      border-bottom: 1px solid var(--border);
    }

    .rank-item:last-child {
      border-bottom: none;
    }

    .rank-num {
      width: 24px;
      height: 24px;
      border-radius: 6px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      font-weight: 900;
      flex-shrink: 0;
    }

    .rank-info {
      flex: 1;
      min-width: 0;
    }

    .rank-name {
      font-size: 12px;
      font-weight: 700;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .rank-sub {
      font-size: 10px;
      color: var(--muted);
      margin-top: 2px;
    }

    .rank-val {
      font-size: 15px;
      font-weight: 900;
      flex-shrink: 0;
    }

    /* Chart */
    .chart-area {
      position: relative;
    }

    svg.chart {
      width: 100%;
      overflow: visible;
    }

    .tooltip {
      position: absolute;
      background: var(--dark);
      color: #fff;
      border-radius: 8px;
      padding: 7px 12px;
      font-size: 10px;
      font-weight: 600;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.15s;
      white-space: nowrap;
      z-index: 50;
      box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    }

    /* Active filter strip */
    .filter-strip {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 10px 14px;
      background: var(--white);
      border: 1px solid var(--border);
      border-radius: 10px;
      flex-wrap: wrap;
    }

    .filter-strip-label {
      font-size: 9px;
      font-weight: 700;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: 0.1em;
      flex-shrink: 0;
    }

    .filter-tag {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px 10px;
      border-radius: 20px;
      font-size: 10px;
      font-weight: 700;
    }

    .filter-tag.t-plat {
      background: var(--green-l);
      color: var(--green);
    }

    .filter-tag.t-camp {
      background: var(--blue-l);
      color: var(--blue);
    }

    .filter-tag.t-tipo {
      background: var(--purple-l);
      color: var(--purple);
    }

    .filter-tag.t-dia {
      background: var(--accent-l);
      color: var(--accent);
    }

    @keyframes fadeUp {
      from {
        opacity: 0;
        transform: translateY(10px)
      }

      to {
        opacity: 1;
        transform: translateY(0)
      }
    }

    .screen.active>* {
      animation: fadeUp 0.3s ease both;
    }

    .screen.active>*:nth-child(2) {
      animation-delay: .05s
    }

    .screen.active>*:nth-child(3) {
      animation-delay: .1s
    }

    .screen.active>*:nth-child(4) {
      animation-delay: .15s
    }

    .screen.active>*:nth-child(5) {
      animation-delay: .2s
    }

    .screen.active>*:nth-child(6) {
      animation-delay: .25s
    }
/* Login Overlay */
#login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background:
    radial-gradient(circle at 15% 15%, rgba(255, 127, 0, 0.2), transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(255, 127, 0, 0.12), transparent 44%),
    #050505;
  align-items: center;
  justify-content: center;
  display: flex;
  padding: 22px;
}

.login-layout {
  width: 100%;
  max-width: 980px;
  min-height: 520px;
  border-radius: 22px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  background: #0b0b0b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.48);
}

.login-brand {
  position: relative;
  padding: 48px;
  background:
    linear-gradient(135deg, #0f0f0f 0%, #111 30%, #181818 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 26px;
}

.login-brand-orb {
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 127, 0, 0.4) 0%, rgba(255, 127, 0, 0) 72%);
  top: -80px;
  right: -70px;
  pointer-events: none;
}

.login-brand-logo {
  width: min(100%, 352px);
  object-fit: contain;
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.4));
}

.login-brand-copy h1 {
  font-size: clamp(26px, 3vw, 34px);
  color: #fff;
  margin-bottom: 10px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.login-brand-copy p {
  max-width: 380px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  line-height: 1.55;
}

.login-box {
  background: #ffffff;
  padding: 52px 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-box h2 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -0.02em;
  color: #111;
}

.login-sub {
  margin: 0 0 24px;
  font-size: 13px;
  color: #666;
}

.login-box input {
  padding: 12px 14px;
  border: 1px solid #dadad6;
  border-radius: 10px;
  margin-bottom: 10px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  background: #fafaf8;
}

.login-box input:focus {
  border-color: #ff7f00;
  box-shadow: 0 0 0 4px rgba(255, 127, 0, 0.13);
  background: #fff;
}

.login-box button {
  margin-top: 6px;
  background: linear-gradient(90deg, #ff7f00, #ff9d29);
  color: #111;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.login-box button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(255, 127, 0, 0.36);
}

#login-error {
  color: #b91c1c;
  font-size: 12px;
  margin-top: 12px;
  text-align: left;
  display: none;
}

@media (max-width: 900px) {
  .login-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .login-brand {
    padding: 28px;
    min-height: 220px;
  }

  .login-brand-logo {
    width: min(100%, 240px);
  }

  .login-box {
    padding: 30px 24px;
  }
}
