:root,
[data-theme="dark"] {
  --tilin: #ff9f43;
  --tilin-light: #ffb86c;
  --tilin-soft: #ffc98a;
  --tilin-glow: rgba(255, 159, 67, 0.35);
  --bg: #14110f;
  --surface: #1e1a17;
  --surface-2: #2a241f;
  --border: #3d342c;
  --text: #f5f0eb;
  --muted: #a89888;
  --accent: var(--tilin);
  --accent-2: var(--tilin-light);
  --accent-soft: rgba(255, 159, 67, 0.14);
  --warning: #e8a030;
  --danger: #e05a4f;
  --validado: #6bc97a;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --hero-total-bg: linear-gradient(135deg, rgba(255, 159, 67, 0.16), rgba(255, 159, 67, 0.04));
  --hero-validado-bg: linear-gradient(135deg, rgba(107, 201, 122, 0.14), rgba(107, 201, 122, 0.03));
  --hero-excluido-bg: linear-gradient(135deg, rgba(232, 160, 48, 0.12), rgba(232, 160, 48, 0.03));
}

[data-theme="light"] {
  --bg: #fffaf5;
  --surface: #ffffff;
  --surface-2: #fff3e8;
  --border: #f0dcc8;
  --text: #2c2218;
  --muted: #7a6555;
  --accent-soft: rgba(255, 159, 67, 0.12);
  --shadow: 0 12px 40px rgba(255, 159, 67, 0.1);
  --hero-total-bg: linear-gradient(135deg, #fff3e8, #ffffff);
  --hero-validado-bg: linear-gradient(135deg, #eef9f0, #ffffff);
  --hero-excluido-bg: linear-gradient(135deg, #fff6e8, #ffffff);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background 0.25s, color 0.25s;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 15% -10%, rgba(255, 159, 67, 0.14), transparent),
    radial-gradient(ellipse 55% 40% at 95% 5%, rgba(255, 184, 108, 0.08), transparent);
  pointer-events: none;
  z-index: 0;
}

[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse 70% 45% at 10% -5%, rgba(255, 159, 67, 0.18), transparent),
    radial-gradient(ellipse 50% 35% at 90% 0%, rgba(255, 200, 138, 0.15), transparent);
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(255, 122, 0, 0.28);
}

.brand h1 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--tilin);
}

.brand p {
  color: var(--muted);
  margin-top: 0.35rem;
  max-width: 520px;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}

.badge.accent {
  color: var(--tilin);
  border-color: rgba(255, 159, 67, 0.45);
  background: var(--accent-soft);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.theme-toggle:hover {
  border-color: var(--tilin);
  background: var(--accent-soft);
}

.hero-triple {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 800px) {
  .hero-triple { grid-template-columns: 1fr; }
}

.hero-card {
  border-radius: 18px;
  padding: 1.75rem 1.5rem;
  text-align: center;
}

.hero-card.total {
  background: var(--hero-total-bg);
  border: 2px solid rgba(255, 159, 67, 0.4);
}

.hero-card.validado {
  background: var(--hero-validado-bg);
  border: 2px solid rgba(107, 201, 122, 0.4);
}

.hero-card.excluido {
  background: var(--hero-excluido-bg);
  border: 2px solid rgba(232, 160, 48, 0.35);
}

.hero-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.4rem;
}

.hero-card.total .hero-label { color: var(--tilin); }
.hero-card.validado .hero-label { color: var(--validado); }
.hero-card.excluido .hero-label { color: var(--warning); }

.hero-value {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.hero-card.total .hero-value { color: var(--tilin); }
.hero-card.validado .hero-value { color: var(--validado); }
.hero-card.excluido .hero-value { color: var(--warning); }

.hero-sub {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

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

.tab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  color: var(--muted);
  transition: border-color 0.28s ease, background 0.28s ease, color 0.28s ease, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease;
}

.tab:hover {
  color: var(--text);
  border-color: rgba(255, 159, 67, 0.35);
  transform: translateY(-1px);
}

.tab.active {
  border-color: rgba(255, 159, 67, 0.55);
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(255, 122, 0, 0.12);
}

.tab-label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
}

.tab.active .tab-label { color: var(--tilin); }

.tab-content-panel {
  position: relative;
  min-height: 280px;
  will-change: opacity, transform, filter;
}

.tab-content-panel.is-leaving {
  animation: tabExit 0.24s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

.tab-content-panel.is-entering {
  animation: tabEnter 0.48s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tab-content-inner > *,
.tab-content-panel.is-settled .tab-content-inner > * {
  opacity: 1;
  transform: none;
}

.tab-content-panel.is-entering .tab-content-inner > * {
  opacity: 0;
  transform: translateY(14px);
  animation: staggerIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tab-content-inner > *:nth-child(1) { animation-delay: 0.04s; }
.tab-content-inner > *:nth-child(2) { animation-delay: 0.1s; }
.tab-content-inner > *:nth-child(3) { animation-delay: 0.16s; }
.tab-content-inner > *:nth-child(4) { animation-delay: 0.22s; }
.tab-content-inner > *:nth-child(5) { animation-delay: 0.28s; }

@keyframes tabExit {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.985);
    filter: blur(5px);
  }
}

@keyframes tabEnter {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .tab,
  .tab-content-panel,
  .tab-content-panel.is-entering .tab-content-inner > * {
    transition: none !important;
    animation: none !important;
  }
  .tab-content-inner > * {
    opacity: 1 !important;
    transform: none !important;
  }
}

.tab-desc {
  display: block;
  font-size: 0.72rem;
  margin-top: 0.2rem;
  opacity: 0.8;
}

.section-header { margin-bottom: 1.25rem; }
.section-header h2 { font-size: 1.35rem; font-weight: 700; }
.section-header p { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }

.resumen-table { width: 100%; border-collapse: collapse; }

.resumen-table th,
.resumen-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.resumen-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.resumen-table .positive-cell {
  color: var(--tilin);
  font-weight: 700;
  font-family: var(--mono);
}

.row-total { background: var(--accent-soft); }
.row-validado { background: rgba(107, 201, 122, 0.08); }
.row-excluido { background: rgba(232, 160, 48, 0.07); }

.sources-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

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

.source-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.source-num {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--tilin);
}

.source-name { font-weight: 600; margin-top: 0.3rem; }
.source-file { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }

.gmv-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
}

.gmv-badge.val {
  color: var(--validado);
  background: rgba(107, 201, 122, 0.15);
}

.gmv-badge.exc {
  color: var(--warning);
  background: rgba(232, 160, 48, 0.12);
}

.positive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.pos-card {
  background: var(--surface);
  border: 1px solid rgba(255, 159, 67, 0.22);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.pos-card.hero-mini {
  border-color: rgba(255, 159, 67, 0.45);
  background: var(--accent-soft);
}

.pos-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.pos-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--tilin);
  font-variant-numeric: tabular-nums;
}

.pos-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

.positive {
  color: var(--tilin);
  font-weight: 600;
}

.zero { color: var(--muted); opacity: 0.5; }

.table-count {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--tilin);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

tbody tr.row-positive { border-left: 3px solid transparent; }
tbody tr.row-positive:hover {
  background: var(--accent-soft);
  border-left-color: var(--tilin);
}

.charts-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.chart-wrap {
  position: relative;
  height: 280px;
  min-height: 280px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.table-section { margin-top: 0.5rem; }

.table-toolbar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: center;
}

.table-toolbar input,
.table-toolbar select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  font-family: var(--font);
  font-size: 0.9rem;
}

.table-toolbar input { flex: 1; min-width: 200px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: var(--surface-2);
  position: sticky;
  top: 0;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.8rem;
}

tbody tr:hover { background: var(--accent-soft); }

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill.active {
  color: var(--validado);
  background: rgba(107, 201, 122, 0.12);
}

.status-pill.cancel {
  color: var(--danger);
  background: rgba(224, 90, 79, 0.12);
}

a.link {
  color: var(--tilin);
  text-decoration: none;
  font-size: 0.8rem;
}

a.link:hover { text-decoration: underline; }

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.pagination button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
}

.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--muted);
}
