:root {
  --bg: #0c0c0e;
  --bg-elevated: #131316;
  --card: #18181c;
  --card-hover: #1f1f24;
  --ink: #f2ece2;
  --muted: #9a9488;
  --border: #2e2a24;
  --border-gold: rgba(212, 175, 55, 0.28);
  --gold: #d4af37;
  --gold-light: #e8c75a;
  --gold-dark: #9a7720;
  --gold-glow: rgba(212, 175, 55, 0.12);
  --primary: var(--gold);
  --primary-dark: var(--gold-dark);
  --green: #6ee7a0;
  --red: #f87171;
  --amber: #fbbf24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(212, 175, 55, 0.06) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, #0a0a0c 100%);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

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

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-gold);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  padding: 0.85rem 1.5rem;
  padding-top: calc(0.85rem + env(safe-area-inset-top));
  padding-left: calc(1.5rem + env(safe-area-inset-left));
  padding-right: calc(1.5rem + env(safe-area-inset-right));
}
.nav-brand {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 50%, var(--gold-dark) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  max-width: 320px;
  line-height: 1.3;
}
.nav-links { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.nav-links a { color: var(--ink); font-size: 0.9rem; }
.nav-links a:hover { color: var(--gold-light); text-decoration: none; }
.nav-user { color: var(--muted); font-size: 0.85rem; }
.nav-logout { color: var(--red) !important; }

.container { max-width: 1100px; margin: 1.5rem auto; padding: 0 1.5rem; padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); }
.container-wide { max-width: 1280px; }

h1 {
  font-size: 1.5rem;
  margin: 0.5rem 0 1rem;
  color: var(--ink);
  font-weight: 600;
}

.muted { color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 1.25rem;
  max-width: 560px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

label {
  display: block;
  font-weight: 600;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.9rem;
  color: var(--gold-light);
}
input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--bg-elevated);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
textarea { resize: vertical; }

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.paste-zone {
  border: 2px dashed var(--border-gold);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  background: var(--bg-elevated);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.paste-zone:hover,
.paste-zone:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--gold-glow);
  box-shadow: 0 0 20px var(--gold-glow);
}
.paste-zone.has-image {
  padding: 0.75rem;
}
.paste-zone-text { margin: 0; color: var(--muted); font-size: 0.9rem; }
.paste-zone.has-image .paste-zone-text { display: none; }
.paste-zone kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  background: var(--card);
  color: var(--gold-light);
  font-size: 0.8rem;
  font-family: inherit;
}
.screenshot-preview img {
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
  border: 1px solid var(--border-gold);
  display: block;
  margin: 0 auto 0.5rem;
}

.capture-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.capture-btn {
  min-height: 44px;
  min-width: 44px;
  flex: 1 1 140px;
}
.paste-zone-mobile {
  min-height: 120px;
  cursor: default;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.paste-zone-mobile.has-image {
  min-height: auto;
}

.pwa-install-banner {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  background: var(--gold-glow);
}
.pwa-install-body {
  font-size: 0.9rem;
  line-height: 1.45;
}
.pwa-install-body strong { color: var(--gold-light); }
.pwa-install-hint {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.pwa-install-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.pwa-install-actions .btn {
  min-height: 44px;
  margin-top: 0;
}

.pwa-install-toast {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 1100;
  max-width: min(92vw, 420px);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border-gold);
  background: var(--card);
  color: var(--ink);
  font-size: 0.9rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}
.pwa-install-toast[hidden] { display: none !important; }

.nav-install {
  font-weight: 600;
  color: var(--gold-light) !important;
}
body.is-pwa-installed .nav-install,
body.is-pwa-installed .pwa-install-banner {
  display: none !important;
}
.nav-minimal {
  margin-bottom: 0;
}
.install-login-hint {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  text-align: center;
}

.pwa-diagnostics { margin-bottom: 1rem; }
.pwa-diag-list {
  margin: 0;
  padding-left: 1.25rem;
}
.pwa-diag-list li { margin: 0.35rem 0; }
.pwa-diag-list li.ok { color: var(--green); }
.pwa-diag-list li.bad { color: var(--red); }
.pwa-steps-big {
  margin: 0.75rem 0;
  padding-left: 1.25rem;
  font-size: 1rem;
  line-height: 1.6;
}
.pwa-steps-big li { margin-bottom: 0.65rem; }
.pwa-install-note {
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}
.pwa-android-manual,
.pwa-ios-manual {
  margin-bottom: 1rem;
  border-color: var(--border-gold);
}
.pwa-manual-highlight {
  box-shadow: 0 0 0 3px var(--gold-glow), 0 0 24px var(--gold-glow);
  border-color: var(--gold);
}
.pwa-android-manual h2,
.pwa-ios-manual h2 {
  margin: 0 0 0.5rem;
  color: var(--gold-light);
}

.pwa-install-actions-page {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.pwa-install-actions-page .btn { min-height: 44px; margin-top: 0; }

.btn {
  display: inline-block;
  border: 1px solid var(--border-gold);
  background: var(--card-hover);
  color: var(--ink);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover {
  background: var(--gold-glow);
  border-color: var(--gold);
  color: var(--gold-light);
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
  border-color: var(--gold);
  color: #1a1508;
  font-weight: 600;
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  border-color: var(--gold-dark);
  color: #0d0b06;
}
.btn-danger {
  border-color: var(--red);
  color: var(--red);
  background: transparent;
}
.btn-danger:hover {
  background: rgba(248, 113, 113, 0.12);
  border-color: var(--red);
  color: var(--red);
  text-decoration: none;
}
.btn-danger-muted {
  opacity: 0.85;
  font-size: 0.82rem;
}
.btn-archive {
  border-color: var(--gold);
  color: var(--gold-light);
  background: rgba(212, 175, 55, 0.08);
}
.btn-archive:hover {
  background: rgba(212, 175, 55, 0.18);
  border-color: var(--gold-light);
  color: var(--gold-light);
  text-decoration: none;
}
.report-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.report-actions form { margin: 0; }
.action-hint { font-size: 0.8rem; margin: 0.25rem 0 0; }
.day-group-archived { opacity: 0.95; }
.report-card-archived { border-color: var(--border-gold); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; margin: 0; }

.flash {
  padding: 0.7rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.flash-success {
  background: rgba(110, 231, 160, 0.1);
  color: var(--green);
  border-color: rgba(110, 231, 160, 0.25);
}
.flash-danger {
  background: rgba(248, 113, 113, 0.1);
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.25);
}
.flash-warning {
  background: rgba(251, 191, 36, 0.1);
  color: var(--amber);
  border-color: rgba(251, 191, 36, 0.25);
}

.login-card {
  max-width: 400px;
  margin: 8vh auto;
  background: var(--card);
  border: 1px solid var(--border-gold);
  border-radius: 14px;
  padding: 2rem;
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.4),
    0 0 60px var(--gold-glow);
}
.login-card h1 {
  margin-top: 0;
  font-size: 1.25rem;
  line-height: 1.35;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.9rem;
}
.table th, .table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  background: var(--bg-elevated);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gold);
}
.table tr:hover td { background: rgba(212, 175, 55, 0.04); }
.table tr:last-child td { border-bottom: none; }
.desc { max-width: 240px; }

.thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-gold);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-nuevo {
  background: rgba(251, 191, 36, 0.12);
  color: var(--amber);
  border-color: rgba(251, 191, 36, 0.3);
}
.badge-resuelto {
  background: rgba(212, 175, 55, 0.12);
  color: var(--gold-light);
  border-color: var(--border-gold);
}
.badge-sirve {
  background: rgba(110, 231, 160, 0.12);
  color: var(--green);
  border-color: rgba(110, 231, 160, 0.3);
}
.badge-no_sirve {
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.3);
}
.badge-pendiente_agente {
  background: rgba(96, 165, 250, 0.12);
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.3);
}
.badge-pendiente_admin {
  background: rgba(251, 191, 36, 0.12);
  color: var(--amber);
  border-color: rgba(251, 191, 36, 0.3);
}
.badge-visor {
  background: rgba(167, 139, 250, 0.12);
  color: #a78bfa;
  border-color: rgba(167, 139, 250, 0.3);
}

.header-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; position: relative; z-index: 2; }
.reports-by-day,
.campaigns-tree,
.detail-grid,
.report-actions,
.form-actions {
  position: relative;
  z-index: 1;
}
.stats-row { display: flex; gap: 1rem; margin: 1rem 0; flex-wrap: wrap; }
.stat {
  background: var(--card);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.stat-num {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold-light);
}

.filters { display: flex; gap: 0.75rem; margin: 1rem 0; flex-wrap: wrap; }
.filters select { width: auto; min-width: 180px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.detail-screenshot img {
  width: 100%;
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}
.detail-info { max-width: none; }
.desc-box {
  background: var(--bg-elevated);
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}
hr { border: none; border-top: 1px solid var(--border-gold); margin: 1rem 0; }

.bar-wrap {
  display: inline-block;
  width: 100px;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 0.4rem;
}
.bar { height: 100%; }
.bar-ok { background: var(--green); }
.bar-bad { background: var(--red); }

/* --- Vista campanas (arbol agrupado) --- */
.campaigns-toolbar { margin-bottom: 0.5rem; }
.campaigns-toolbar h1 { margin-bottom: 0.25rem; }
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.toolbar-actions form { margin: 0; }
.toolbar-actions .btn { margin-top: 0; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}
.summary-chip {
  background: var(--card);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  text-align: center;
}
.summary-num {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold-light);
  line-height: 1.1;
}
.summary-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-panel {
  max-width: none;
  margin-bottom: 1.25rem;
  padding: 1.1rem 1.25rem;
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}
.chart-header h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--gold-light);
}
.chart-subtitle { margin: 0.25rem 0 0; font-size: 0.85rem; }
.chart-filter select {
  width: auto;
  min-width: 170px;
}
.chart-wrap {
  position: relative;
  height: 320px;
  overflow: hidden;
  z-index: 0;
}
.chart-wrap-sm { height: 220px; }
.chart-empty {
  padding: 1.5rem 0.5rem;
  text-align: center;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* --- Reportes agrupados por dia --- */
.reports-toolbar { margin-bottom: 0.5rem; }
.reports-toolbar h1 { margin-bottom: 0.25rem; }
.reports-filters { margin-bottom: 1rem; }
.reports-chart { margin-bottom: 1.25rem; }

.reports-by-day {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.day-group {
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.22);
}

.day-group > summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.day-group > summary::-webkit-details-marker { display: none; }
.day-group > summary::after {
  content: "▾";
  color: var(--gold);
  font-size: 1rem;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.day-group:not([open]) > summary::after {
  transform: rotate(-90deg);
}

.day-group-title h2 {
  margin: 0.15rem 0 0;
  font-size: 1.1rem;
  color: var(--gold-light);
}

.day-group-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}
.day-group-stats .meta-pill.ok { color: var(--green); }
.day-group-stats .meta-pill.bad { color: var(--red); }
.day-group-stats .meta-pill strong { color: var(--ink); }

.day-group-body { padding: 0 1rem 1rem; }
.day-group-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}
.day-group-actions form { margin: 0; }

.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
}

.report-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.report-card-media {
  display: block;
  aspect-ratio: 16 / 10;
  background: #000;
  border-bottom: 1px solid var(--border);
}
.report-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.report-card-body { padding: 0.75rem; }
.report-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}
.report-time {
  font-size: 0.85rem;
  color: var(--gold-light);
  font-weight: 600;
}
.report-agent { margin: 0 0 0.2rem; font-size: 0.9rem; }
.report-type {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.report-desc {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.55rem;
}
.report-card .btn { margin-top: 0; }
.report-card-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.report-card-actions form { margin: 0; }

@media (max-width: 720px) {
  .day-group > summary { flex-direction: column; }
  .day-group-stats { justify-content: flex-start; }
  .report-cards { grid-template-columns: 1fr; }
}

.campaigns-tree { display: flex; flex-direction: column; gap: 1rem; }

.tree-campaign,
.tree-adset {
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}
.tree-campaign { box-shadow: 0 6px 28px rgba(0, 0, 0, 0.22); }
.tree-adset {
  border-color: var(--border);
  background: var(--bg-elevated);
  margin-top: 0.75rem;
}

.tree-campaign > summary,
.tree-adset > summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.tree-campaign > summary::-webkit-details-marker,
.tree-adset > summary::-webkit-details-marker { display: none; }
.tree-campaign > summary::after,
.tree-adset > summary::after {
  content: "▾";
  color: var(--gold);
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 0.15rem;
  transition: transform 0.15s;
}
.tree-campaign:not([open]) > summary::after,
.tree-adset:not([open]) > summary::after {
  transform: rotate(-90deg);
}

.tree-campaign-body { padding: 0 1rem 1rem; }
.tree-adset-body { padding: 0 0.85rem 0.85rem; }

.tree-title-wrap h2,
.tree-adset-summary h3 {
  margin: 0.15rem 0 0.35rem;
  font-size: 1.15rem;
  color: var(--gold-light);
}
.tree-adset-summary h3 { font-size: 1rem; color: var(--ink); }

.tree-level {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-weight: 700;
}

.tree-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}
.meta-pill {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--muted);
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

.tree-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  min-width: 180px;
}
.quality-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.quality-item strong { color: var(--ink); }
.quality-item.ok strong { color: var(--green); }
.quality-item.bad strong { color: var(--red); }

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.85rem;
  padding: 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.info-cell-wide { grid-column: 1 / -1; }
.info-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 0.2rem;
}
.info-value {
  display: block;
  font-size: 0.86rem;
  color: var(--ink);
  line-height: 1.35;
}

.ads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}
.ad-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-height: 100%;
}
.ad-card-media {
  aspect-ratio: 16 / 9;
  background: #000;
  border-bottom: 1px solid var(--border);
}
.ad-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ad-card-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
  background: var(--bg-elevated);
}
.ad-card-body { padding: 0.75rem; }
.ad-card-body h4 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--gold-light);
  line-height: 1.3;
}
.ad-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.badge-sm {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  flex-shrink: 0;
}
.ad-card-title {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}
.ad-card-text {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  max-width: none;
  text-align: center;
  padding: 2rem;
}
.footer-note { margin-top: 1rem; font-size: 0.85rem; }
.nested-empty { margin: 0.25rem 0 0; font-size: 0.85rem; }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .tree-campaign > summary,
  .tree-adset > summary { flex-direction: column; }
  .tree-side { align-items: flex-start; min-width: 0; }
  .quality-stats { justify-content: flex-start; }
}

@media (max-width: 720px) {
  .detail-grid { grid-template-columns: 1fr; }
  .nav { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
  .nav-brand { max-width: none; }
  .info-grid { grid-template-columns: 1fr; }
  .ads-grid { grid-template-columns: 1fr; }
  .paste-zone:not(.has-image) { min-height: 100px; }
  .btn, .btn-primary, .btn-sm { min-height: 44px; }
}

.nav-badge {
  display: inline-block;
  min-width: 1.1rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--gold);
  color: #1a1500;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.1rem;
}

.report-card-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

.thread {
  margin: 0.5rem 0;
}
.thread-title {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}
.thread-messages {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 420px;
  overflow-y: auto;
  padding: 0.25rem;
}
.msg {
  max-width: 85%;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.msg-agent {
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.msg-admin {
  align-self: flex-end;
  background: var(--gold-glow);
  border-color: var(--border-gold);
  border-bottom-right-radius: 2px;
}
.msg-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.msg-author { font-weight: 600; }
.msg-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.form-card { max-width: 480px; }
.form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}
.form-actions .btn { margin-top: 0; }
.table-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}
.inline-form { display: inline; margin: 0; }
.inline-form .btn { margin-top: 0; }
.thread-form {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lightbox-trigger { cursor: zoom-in; }
.detail-screenshot .lightbox-trigger { display: block; }
body.lightbox-open { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}
.lightbox[hidden] {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1001;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--border-gold);
  border-radius: 999px;
  background: rgba(24, 24, 28, 0.95);
  color: var(--gold-light);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.lightbox-close:hover {
  background: var(--gold-glow);
  color: var(--ink);
}

.lightbox-dialog {
  max-width: min(95vw, 1200px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.lightbox-image {
  max-width: 100%;
  max-height: calc(90vh - 3rem);
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border-gold);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Exportacion de reportes para reclamo a Facebook */
.export-summary {
  padding: 0.85rem 1rem;
  margin: 1rem 0 1.5rem;
}
.export-summary p { margin: 0.2rem 0; }

.export-index { margin: 1.5rem 0; }
.export-index h2 { margin-bottom: 0.75rem; }

.export-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.export-table th,
.export-table td {
  border: 1px solid var(--border-gold);
  padding: 0.45rem 0.6rem;
  text-align: left;
  vertical-align: top;
}
.export-table th { background: var(--gold-glow); color: var(--ink); }

.export-cases { display: flex; flex-direction: column; gap: 1.25rem; }
.export-case {
  background: var(--card);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 1rem;
}
.export-case-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border-gold);
  padding-bottom: 0.5rem;
  margin-bottom: 0.85rem;
}
.export-case-head h3 { margin: 0; }
.export-case-date { color: var(--muted); font-size: 0.85rem; }
.export-case-grid { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.export-case-media { flex: 0 0 320px; max-width: 320px; }
.export-case-media img {
  width: 100%;
  border: 1px solid var(--border-gold);
  border-radius: 8px;
}
.export-case-noimg {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border-gold);
  border-radius: 8px;
}
.export-case-data { flex: 1; min-width: 240px; }
.export-case-data p { margin: 0.3rem 0; }

@media (max-width: 720px) {
  .export-case-media { flex-basis: 100%; max-width: 100%; }
}

.viewer-period select {
  width: auto;
  min-width: 11rem;
}
.viewer-summary { margin-bottom: 1.25rem; }
.viewer-note { margin: 0 0 1rem; font-size: 0.9rem; }
.viewer-fb-note { margin-bottom: 1rem; }
.viewer-section {
  max-width: none;
  margin-bottom: 1.25rem;
}
.viewer-section h2 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}
.section-hint { margin: 0 0 1rem; font-size: 0.88rem; }
.viewer-table-wrap { overflow-x: auto; }
.viewer-table .num { text-align: right; white-space: nowrap; }
.viewer-table .ok { color: var(--green); }
.viewer-table .bad { color: var(--red); }
.cell-sub { font-size: 0.78rem; margin-top: 0.15rem; }
.quality-chip-ok .summary-num { color: var(--green); }
.quality-chip-warn .summary-num { color: var(--amber); }
.quality-chip-bad .summary-num { color: var(--red); }
.quality-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.25rem;
  max-width: 120px;
}
.quality-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}
.quality-ok .quality-bar-fill { background: var(--green); }
.quality-bar-fill.quality-bar-good { background: var(--green); }
.quality-warn .quality-bar-fill { background: var(--amber); }
.quality-bad .quality-bar-fill { background: var(--red); }
.quality-pct { font-size: 0.8rem; font-weight: 600; }
.quality-pct.quality-ok { color: var(--green); }
.quality-pct.quality-warn { color: var(--amber); }
.quality-pct.quality-bad { color: var(--red); }

@media print {
  .nav, .no-print, .flash, .lightbox { display: none !important; }
  body { background: #fff; color: #000; }
  .export-case, .export-table { page-break-inside: avoid; }
  .export-case {
    background: #fff;
    border: 1px solid #ccc;
  }
  .export-table th { background: #eee; color: #000; }
  a { color: #000; }
}
