/* =====================================================================
   Neo — design tokens + base styles. Mobile-first.
   Cambiá las variables de :root para ajustar el tema completo.
   ===================================================================== */

:root {
  /* Background scale */
  --bg:           #000000;
  --bg-1:         #0c0c0c;   /* tarjetas */
  --bg-2:         #141414;   /* tarjetas elevadas / hover */
  --bg-3:         #1c1c1c;   /* inputs / chips */

  /* Foreground */
  --text:         #ffffff;
  --text-muted:   #9a9a9a;
  --text-dim:     #6a6a6a;

  /* Acentos semánticos */
  --positive:     #1fdc7a;   /* subió */
  --negative:     #ff4d4f;   /* bajó */
  --highlight:    #ff8a1a;   /* destacado / valor activo */

  /* Bordes */
  --border:       #232323;
  --border-soft:  #1a1a1a;

  /* Tipografía / radios / spacing */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --header-h: 52px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* Red de seguridad: nunca scroll horizontal de página. */
  overflow-x: hidden;
  max-width: 100vw;
}

body { min-height: 100vh; }

/* Custom scrollbars (themed, slim) ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 999px;
  border: 2px solid var(--bg-1);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,138,26,0.6); }
::-webkit-scrollbar-corner { background: var(--bg); }
/* Firefox */
* { scrollbar-color: var(--bg-3) var(--bg-1); scrollbar-width: thin; }

a { color: inherit; text-decoration: none; }
a.link { color: var(--highlight); }
a.link:hover { text-decoration: underline; }

code, .mono { font-family: var(--font-mono); font-size: 0.92em; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

/* ===================== Layout ===================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}
.app-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
}

.app-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: 17px;
  color: var(--text);
}
.app-header .brand img { height: 28px; width: auto; display: block; }
.app-header .brand-name { /* texto del header — opcional */ }

.brand-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.brand-stack img {
  width: 140px;
  height: 140px;
  object-fit: contain;
}
.brand-stack .brand-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.brand-stack .brand-tag {
  font-size: 12px;
  color: var(--text-muted);
}

.company-logo {
  height: 36px;
  width: 36px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--bg);
  flex: 0 0 auto;
}
.company-logo-lg {
  height: 64px;
  width: 64px;
  border-radius: 12px;
  object-fit: contain;
  background: var(--bg);
}

.app-header .header-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 13px;
  color: var(--text-muted);
}

.app-header .header-user form { display: inline; }
.app-header .header-user button {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 0;
}
.app-header .header-user button:hover { color: var(--text); }

.app-nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}
.app-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  overflow-x: auto;
  overflow-y: hidden;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.app-nav-inner::-webkit-scrollbar { display: none; }

.app-nav a {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 4px 2px;
  border-bottom: 2px solid transparent;
}
.app-nav a.active {
  color: var(--text);
  border-bottom-color: var(--highlight);
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-4);
}

.container-narrow { max-width: 460px; margin: 0 auto; padding: var(--space-5) var(--space-4); }

/* ===================== Cards ===================== */

.card {
  display: block;            /* clave: si el .card es un <a>, sin esto se rompe el layout */
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  color: var(--text);
  text-decoration: none;
}
a.card { transition: background 120ms ease, border-color 120ms ease; }
a.card:hover {
  background: var(--bg-2);
  border-color: rgba(255,138,26,0.3);
}

.card + .card { margin-top: var(--space-3); }
.card-header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.card-title { font-weight: 700; font-size: 16px; color: var(--text); }
.card-sub { color: var(--text-muted); font-size: 12px; }

/* ===================== Forms ===================== */

label.field { display: block; margin-bottom: var(--space-3); }
label.field > .label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="search"], textarea, select {
  width: 100%;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--highlight);
}
textarea { min-height: 84px; font-family: var(--font-mono); font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  min-height: 40px;
}
.btn:hover { background: var(--bg-2); }
.btn-primary {
  background: var(--highlight);
  color: #1a0a00;
  border-color: var(--highlight);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--negative); border-color: rgba(255,77,79,0.35); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; min-height: 32px; }

/* ===================== Flash ===================== */

.flash {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: var(--space-4);
  border: 1px solid;
}
.flash.ok  { color: var(--positive); border-color: rgba(31,220,122,0.35); background: rgba(31,220,122,0.06); }
.flash.err { color: var(--negative); border-color: rgba(255,77,79,0.35); background: rgba(255,77,79,0.06); }

/* ===================== Badges / chips ===================== */

.badge {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge.role-super { color: var(--highlight); border-color: rgba(255,138,26,0.5); }
.badge.role-admin { color: var(--text); }
.badge.state-on  { color: var(--positive); border-color: rgba(31,220,122,0.35); }
.badge.state-off { color: var(--negative); border-color: rgba(255,77,79,0.35); }

/* Horizontal scrollable chip row (sort selector) */
.chip-row {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  overflow-y: hidden;
  padding: var(--space-2) 0 var(--space-3);
  max-width: 100%;
  /* Mantenemos scroll silencioso en chip-rows porque son micro-controles */
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  background: var(--bg-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.chip:hover { color: var(--text); }
.chip.active {
  background: var(--highlight);
  color: #1a0a00;
  border-color: var(--highlight);
}

/* ===================== Period strip ===================== */

.period-strip {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin: var(--space-3) 0;
}
.period-strip-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-soft);
}
.period-strip-head .title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 700; }
.period-strip-head .sub   { font-size: 12px; color: var(--text-dim); }
.period-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
.period-stat {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 92px;
}
.period-stat .lbl {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.period-stat .val {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--text);
}
.period-stat .delta {
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.03);
  align-self: flex-start;
}
.period-stat .delta.pos { background: rgba(31,220,122,0.10); }
.period-stat .delta.neg { background: rgba(255,77,79,0.10); }

/* ===================== Filter row ===================== */

.filter-row {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  overflow-y: hidden;
  padding: var(--space-1) 0 var(--space-3);
  max-width: 100%;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.filter-chip.on {
  background: rgba(255,138,26,0.10);
  color: var(--highlight);
  border-color: var(--highlight);
}

/* ===================== Tier badges on reel card ===================== */

.tier-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid;
}
.tier-outlier { color: var(--highlight); border-color: var(--highlight); }
.tier-fuerte  { color: var(--positive); border-color: rgba(31,220,122,0.5); }
.tier-normal  { color: var(--text-muted); border-color: var(--border); }
.tier-bajo    { color: var(--negative); border-color: rgba(255,77,79,0.5); }
.tier-na      { display: none; }

.reel-card .badges {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* ===================== Insights page ===================== */

.insights-grid { display: grid; gap: var(--space-4); }

.heatmap-wrap {
  width: 100%;
  max-width: 100%;
  margin-top: var(--space-3);
  overflow: hidden;
}
.heatmap {
  display: grid;
  /* minmax(0,1fr) es CRÍTICO: deja a las celdas encogerse por debajo del contenido,
     evitando que el grid expanda el contenedor. */
  grid-template-columns: 32px repeat(7, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
}
.heatmap .h-label, .heatmap .h-dow {
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0;
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.heatmap .h-label { text-align: right; padding-right: 4px; font-family: var(--font-mono); font-size: 9px; }
.heatmap .h-cell {
  border-radius: 6px;
  aspect-ratio: 1.4 / 1;     /* uniformidad visual */
  min-height: 44px;
  background: var(--bg-2);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  overflow: hidden;
  min-width: 0;
}
.heatmap .h-cell.empty {
  background: var(--bg-1);
}
.heatmap .h-cell .val {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.heatmap .h-cell.empty .val { color: var(--text-dim); text-shadow: none; }
.heatmap .h-cell .n {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,0.75);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-size: 11px;
  color: var(--text-muted);
}
.heatmap-legend .scale {
  display: inline-flex;
  height: 8px;
  width: 80px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(255,138,26,0.10), rgba(255,138,26,0.95));
}

@media (min-width: 500px) {
  .heatmap { grid-template-columns: 44px repeat(7, minmax(0, 1fr)); gap: 5px; }
  .heatmap .h-label { font-size: 10px; padding-right: 6px; }
}

/* Compact rank-list (top/bottom/gems) */
.tb-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
.tb-grid .tb-section .tb-section-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: var(--space-2);
}
.tb-list { display: flex; flex-direction: column; }
.tb-list .tb-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: start;
  gap: var(--space-2);
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.tb-list .tb-row:last-child { border-bottom: none; }
.tb-list .rank {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-weight: 700;
  padding-top: 2px;
}
.tb-list .tb-body { min-width: 0; }
.tb-list .cap {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
  font-weight: 600;
  line-height: 1.35;
}
.tb-list .tb-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.tb-list .vals {
  text-align: right;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.tb-list .vals .v-main {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}
.tb-list .vals .v-main.hl { color: var(--highlight); }
.tb-list .vals .v-sub {
  font-size: 11px;
  color: var(--text-muted);
}

@media (min-width: 720px) {
  .tb-grid { grid-template-columns: 1fr 1fr; }
  .period-grid { grid-template-columns: repeat(4, 1fr); }
  .heatmap { min-width: 0; }
}

/* ===================== Playbook (patrones, receta, repost queue) ===================== */

.lift-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--space-2) var(--space-3);
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.lift-row:last-child { border-bottom: none; }
.lift-row .label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.lift-row .rates {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.lift-row .lift-pill {
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 60px;
}
.lift-pill.high     { background: rgba(31,220,122,0.18);  color: var(--positive); border: 1px solid rgba(31,220,122,0.35); }
.lift-pill.med      { background: rgba(255,138,26,0.15);  color: var(--highlight); border: 1px solid rgba(255,138,26,0.35); }
.lift-pill.low      { background: var(--bg-3);             color: var(--text-muted); border: 1px solid var(--border-soft); }
.lift-pill.negative { background: rgba(255,77,79,0.15);   color: var(--negative); border: 1px solid rgba(255,77,79,0.35); }
.lift-row .conf {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
}
.conf-alta { background: rgba(31,220,122,0.15); color: var(--positive); }
.conf-media { background: rgba(255,138,26,0.10); color: var(--highlight); }
.conf-baja { background: var(--bg-3); color: var(--text-dim); }

.member-lift-card {
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--highlight);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
}
.member-lift-card .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.member-lift-card .name { font-size: 16px; font-weight: 800; color: var(--text); }
.member-lift-card .pill-lift {
  font-size: 13px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.member-lift-card .stats {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.member-lift-card .stats b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.member-lift-card .best-setting {
  margin-top: 6px;
  font-size: 12px;
}

.repost-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}
.repost-card .repost-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.repost-card .score-pill {
  background: var(--highlight);
  color: #1a0a00;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
}
.repost-card .cap {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}
.repost-card .rationale {
  margin-top: 8px;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text);
}
.repost-card .rationale li { margin: 2px 0; }
.repost-card .mini-frames {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  margin-top: 8px;
}
.repost-card .mini-frames img {
  width: 100%;
  aspect-ratio: 9/16;
  object-fit: cover;
  border-radius: 3px;
}
.repost-card .meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ===================== Format breakdown bars ===================== */

.fmt-list { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-3); }
.fmt-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2) var(--space-3);
}
.fmt-row .name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.fmt-row .count {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.fmt-row .bar-wrap {
  grid-column: 1 / -1;
  height: 8px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
}
.fmt-row .bar {
  height: 100%;
  background: linear-gradient(90deg, var(--highlight), #ffb066);
  border-radius: 999px;
}
.fmt-row .stats {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.fmt-row .stats b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Format badge en card de reel */
.fmt-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,138,26,0.10);
  color: var(--highlight);
  border: 1px solid rgba(255,138,26,0.35);
}
.hook-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-3);
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
}

/* ===================== Metric explainer ===================== */

.metric-explain {
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--highlight);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
}
.metric-explain-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.metric-explain-body {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}

/* ===================== Reels list ===================== */

.section-title {
  font-size: 18px;
  font-weight: 800;
  margin: var(--space-3) 0 var(--space-2);
  letter-spacing: 0.01em;
}

.section-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: var(--space-3);
}

.account-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.account-stats .stat {
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  text-align: center;
}
.account-stats .stat .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.account-stats .stat .value {
  font-size: 18px;
  font-weight: 800;
}

.reel-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.reel-card .top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.reel-card .rank {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  min-width: 36px;
}
.reel-card .title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  flex: 1;
  /* truncar a 3 líneas */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.reel-card .open-ig {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: underline;
}
.reel-card .meta-row {
  margin-top: var(--space-2);
  font-size: 12px;
  color: var(--text-muted);
}

/* highlighted metric strip: la métrica activa grande, las demás chicas */
.reel-card .primary-metric {
  margin-top: var(--space-3);
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.reel-card .primary-metric .value {
  font-size: 28px;
  font-weight: 800;
  color: var(--highlight);
  font-variant-numeric: tabular-nums;
}
.reel-card .primary-metric .name {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-grid {
  margin-top: var(--space-3);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2) var(--space-3);
}
.metric-grid .metric {
  display: flex;
  flex-direction: column;
}
.metric-grid .metric .label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.metric-grid .metric .value {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.metric-grid .metric.active .value { color: var(--highlight); }
.metric-grid .metric .value.dim { color: var(--text-dim); }

/* deltas (positivo / negativo) -- los uso cuando tengamos snapshot anterior */
.delta-up   { color: var(--positive); }
.delta-down { color: var(--negative); }

/* ===================== Daily bars (audiencia / tráfico) ===================== */

.daily-bars {
  display: grid;
  grid-template-columns: repeat(29, minmax(0, 1fr));
  gap: 2px;
  align-items: end;
  height: 110px;
  margin-top: var(--space-3);
  padding: 0 4px;
}
.daily-bars .bar-col {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}
.daily-bars .bar {
  width: 100%;
  background: var(--highlight);
  border-radius: 3px 3px 0 0;
  min-height: 1px;
  transition: opacity 120ms;
}
.daily-bars .bar.neg { background: var(--negative); }
.daily-bars .bar.pos { background: var(--positive); }
.daily-bars .bar-col:hover .bar { opacity: 0.8; }
.daily-bars .bar-col .tip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  color: var(--text);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  border: 1px solid var(--border);
  transition: opacity 100ms;
  z-index: 10;
}
.daily-bars .bar-col:hover .tip { opacity: 1; }

.daily-axis {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 4px;
  padding: 0 4px;
  font-family: var(--font-mono);
}

.daily-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.daily-summary .mini-stat {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.daily-summary .mini-stat .l { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.daily-summary .mini-stat .v { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }

@media (min-width: 720px) {
  .daily-summary { grid-template-columns: repeat(4, 1fr); }
}

/* ===================== Clean days table ===================== */

.clean-day {
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--highlight);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
}
.clean-day .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.clean-day .cap {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
  display: block;
  color: var(--text);
}
.clean-day .stats {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-size: 12px;
}
.clean-day .stats span b {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ===================== Visual analysis (frames + badges) ===================== */

.visual-strip {
  margin-top: var(--space-3);
  padding: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.visual-frames {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 8px;
}
.visual-frames img {
  width: 100%;
  aspect-ratio: 9/16;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-3);
  display: block;
}
.visual-frames .ts {
  font-size: 9px;
  color: var(--text-dim);
  text-align: center;
  font-family: var(--font-mono);
  margin-top: 2px;
}
.visual-meta {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
}
.visual-hookline {
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.visual-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.v-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
  white-space: nowrap;
}
.v-badge.member {
  background: rgba(255,138,26,0.10);
  color: var(--highlight);
  border-color: rgba(255,138,26,0.35);
}
.v-badge.text-on { color: var(--positive); border-color: rgba(31,220,122,0.35); }
.v-badge.shot { color: var(--text); }

@media (max-width: 480px) {
  .visual-frames { grid-template-columns: repeat(3, 1fr); }
}

/* ===================== Manual annotation (per reel) ===================== */

.manual-strip {
  margin-top: var(--space-3);
  padding: 10px 12px;
  background: rgba(255,138,26,0.06);
  border: 1px solid rgba(255,138,26,0.25);
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  color: var(--text);
}
.manual-strip .manual-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255,138,26,0.18);
  color: var(--highlight);
}
.manual-strip b { font-variant-numeric: tabular-nums; }
.manual-strip .manual-notes {
  width: 100%;
  color: var(--text-muted);
  font-style: italic;
  padding-top: 4px;
  border-top: 1px dashed rgba(255,138,26,0.20);
}

details.annotate {
  margin-top: var(--space-3);
  border-top: 1px solid var(--border-soft);
  padding-top: var(--space-3);
}
details.annotate summary {
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0;
}
details.annotate summary:hover { color: var(--text); }
details.annotate summary::-webkit-details-marker { display: none; }
details.annotate[open] summary { color: var(--highlight); margin-bottom: 8px; }

.annotate-form { margin-top: var(--space-2); }
.annotate-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.annotate-fields input,
.annotate-form input[type="text"] {
  padding: 8px 10px;
  font-size: 14px;
}

@media (max-width: 480px) {
  .annotate-fields { grid-template-columns: 1fr; }
}

/* ===================== Tables (super-admin) ===================== */

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th, .tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
}
.tbl th {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  background: var(--bg-1);
}
.tbl tr:hover td { background: var(--bg-1); }

.tbl-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}

/* ===================== Helpers ===================== */

.row     { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.row-end { display: flex; gap: var(--space-3); align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.spaced  { display: flex; gap: var(--space-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack-2 > * + * { margin-top: var(--space-2); }
.stack-3 > * + * { margin-top: var(--space-3); }
.stack-4 > * + * { margin-top: var(--space-4); }

.muted { color: var(--text-muted); }
.dim   { color: var(--text-dim); }
.bold  { font-weight: 700; }
.hl    { color: var(--highlight); }
.pos   { color: var(--positive); }
.neg   { color: var(--negative); }

.small { font-size: 12px; }
.tiny  { font-size: 11px; }

.hide-mobile { display: none; }

/* ===================== Detail / expand ===================== */

.collapsible summary {
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  padding: var(--space-2) 0;
}
.collapsible summary::-webkit-details-marker { display: none; }
.collapsible summary::before { content: "+ "; color: var(--highlight); }
.collapsible[open] summary::before { content: "− "; }

/* ===================== Wider screens ===================== */

@media (min-width: 640px) {
  body { font-size: 15px; }
  .container { padding: var(--space-5); }

  .account-stats { grid-template-columns: repeat(5, minmax(0,1fr)); }

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

  .hide-mobile { display: revert; }
}

@media (min-width: 920px) {
  .reel-card .primary-metric .value { font-size: 32px; }
}
