/* Clipforge — sala de corte. Claro, sobrio; el color se reserva para lo que significa algo:
   rojo "tally" = acción / en curso, verde = dinero, ámbar = atención. */
:root {
  --bg: #F2F4F7;
  --surface: #FFFFFF;
  --ink: #1B2430;
  --muted: #5E6B7A;
  --line: #D8DEE6;
  --tally: #E23D28;
  --tally-ink: #B42A19;
  --money: #1E8B57;
  --money-soft: #E3F3EA;
  --amber: #B97F00;
  --amber-soft: #FBF1D6;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--font); font-variation-settings: "wdth" 100; }
a { color: inherit; }
img, video { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--tally); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- estructura ---------- */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 20px 12px; border-right: 1px solid var(--line); background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; text-decoration: none; font-weight: 800; font-size: 19px; font-variation-settings: "wdth" 118; letter-spacing: -.01em; }
.navlink { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-s); text-decoration: none; color: var(--muted); font-weight: 560; }
.navlink:hover { color: var(--ink); background: #E7EBF0; }
.navlink.is-active { color: var(--ink); background: var(--surface); box-shadow: inset 3px 0 0 var(--tally); }
.navicon { display: inline-flex; }
.logout { margin-top: auto; padding: 0 10px; }
.main { padding: 28px clamp(16px, 4vw, 48px) 80px; max-width: 1240px; width: 100%; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 20; flex-direction: row; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); background: rgba(242,244,247,.96); backdrop-filter: blur(8px); }
  .brand, .logout { display: none; }
  .navlink { flex-direction: column; gap: 2px; font-size: 11.5px; padding: 6px 8px; }
  .navlink.is-active { box-shadow: inset 0 3px 0 var(--tally); }
  .main { padding: 18px 16px 110px; }
}

/* ---------- tipografía ---------- */
h1, h2, h3 { margin: 0; line-height: 1.15; font-variation-settings: "wdth" 116; letter-spacing: -.012em; }
h1 { font-size: clamp(26px, 3.4vw, 34px); font-weight: 780; }
h2 { font-size: 19px; font-weight: 720; }
h3 { font-size: 16px; font-weight: 680; }
.lede { color: var(--muted); margin: 6px 0 0; max-width: 62ch; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.section { margin-top: 34px; }
.section > h2 { margin-bottom: 12px; }

/* ---------- controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid var(--ink); border-radius: var(--radius-s); background: var(--ink); color: #fff; font: 600 14px var(--font); text-decoration: none; cursor: pointer; }
.btn:hover { background: #2B3747; }
.btn.rec { background: var(--tally); border-color: var(--tally); }
.btn.rec:hover { background: var(--tally-ink); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.sm { min-height: 32px; padding: 0 11px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; }
input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font: 15px var(--font);
}
textarea { min-height: 84px; resize: vertical; }
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.inline { display: inline; }

.toast { margin: 0 0 18px; padding: 11px 14px; border-radius: var(--radius-s); font-weight: 560; }
.toast.ok { background: var(--money-soft); color: #145C3A; }
.toast.err { background: #FDE8E5; color: var(--tally-ink); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 9px 12px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.is-active { color: var(--ink); border-color: var(--tally); }
.tabs .count { color: var(--muted); font-weight: 500; margin-left: 4px; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: #E7EBF0; color: var(--ink); white-space: nowrap; }
.chip.money { background: var(--money-soft); color: #145C3A; }
.chip.warn { background: var(--amber-soft); color: #7A5300; }
.chip.bad { background: #FDE8E5; color: var(--tally-ink); }
.chip.on::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--money); }
.chip.off::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #A9B3BF; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px; }

/* ---------- inicio: la tira hacia 2.000 vistas (el elemento protagonista) ---------- */
.strip { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 92px; gap: 10px; overflow-x: auto; padding: 18px 16px 16px; background: var(--ink); border-radius: var(--radius-m); scroll-snap-type: x proximity; }
.strip::before, .strip::after { content: ""; position: absolute; left: 0; right: 0; height: 8px; background: repeating-linear-gradient(90deg, transparent 0 10px, rgba(242,244,247,.22) 10px 18px); }
.strip::before { top: 5px; } .strip::after { bottom: 3px; }
.frame { scroll-snap-align: start; display: flex; flex-direction: column; gap: 6px; color: #fff; text-decoration: none; }
.frame-media { position: relative; aspect-ratio: 9 / 16; border-radius: 5px; overflow: hidden; background: #2B3747; }
.frame-media img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(.55) brightness(.8); }
.frame-fill { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(to top, rgba(30,139,87,.92), rgba(30,139,87,.55)); mix-blend-mode: normal; }
.frame.is-paid .frame-media img { filter: none; }
.frame.is-paid .frame-fill { background: none; box-shadow: inset 0 0 0 3px #3DDC84; }
.frame-line { position: absolute; left: 0; right: 0; top: 0; border-top: 2px dashed rgba(255,255,255,.7); }
.frame-meta { font-size: 12px; line-height: 1.25; color: #C9D2DC; }
.frame-meta b { color: #fff; font-weight: 700; }
.strip-empty { color: #C9D2DC; padding: 26px 8px; grid-column: 1 / -1; max-width: 52ch; }
.strip-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--muted); }

.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; margin-top: 18px; }
.figure { background: var(--surface); padding: 14px 16px; }
.figure .value { font-size: 26px; font-weight: 760; font-variation-settings: "wdth" 112; font-variant-numeric: tabular-nums; }
.figure .label { color: var(--muted); font-size: 13px; }
.figure.money .value { color: var(--money); }
@media (max-width: 640px) { .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; }
@media (max-width: 960px) { .cols { grid-template-columns: 1fr; } }

.status-list { list-style: none; margin: 0; padding: 0; }
.status-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.status-list li:last-child { border-bottom: 0; }

/* ---------- campañas ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-height: 38px; }
.camp { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); margin-bottom: 8px; }
.camp.is-working { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--tally); }
.camp.is-excluded { opacity: .62; }
.score { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-weight: 780; font-variation-settings: "wdth" 110; font-variant-numeric: tabular-nums;
  background: conic-gradient(var(--ink) calc(var(--p) * 1%), #E7EBF0 0); position: relative; }
.score::after { content: attr(data-v); position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 16px; }
.camp-title { font-weight: 680; font-size: 16px; line-height: 1.3; }
.camp-title a { text-decoration: none; }
.camp-title a:hover { text-decoration: underline; }
.camp-org { color: var(--muted); font-size: 13px; }
.camp-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13.5px; }
.camp-facts span b { font-weight: 680; font-variant-numeric: tabular-nums; }
.camp-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.camp-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.why { margin-top: 8px; font-size: 13px; }
.why summary { cursor: pointer; color: var(--muted); }
.why dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 4px 12px; margin: 8px 0 0; }
.why dt { color: var(--muted); font-size: 12px; } .why dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .camp { grid-template-columns: 44px minmax(0, 1fr); }
  .score { width: 44px; height: 44px; } .score::after { font-size: 14px; inset: 4px; }
  .camp-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
}

/* ---------- clips ---------- */
.clip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 16px; }
.clip { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.clip-media { position: relative; aspect-ratio: 9 / 16; background: var(--ink); }
.clip-media img, .clip-media video { width: 100%; height: 100%; object-fit: cover; }
.clip-media button.play { position: absolute; inset: 0; border: 0; background: transparent; cursor: pointer; }
.clip-media button.play::after { content: ""; position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: rgba(27,36,48,.72) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 7v10l8-5z' fill='white'/%3E%3C/svg%3E") center/30px no-repeat; }
.clip-badge { position: absolute; top: 8px; left: 8px; display: flex; gap: 6px; }
.clip-badge .chip { background: rgba(27,36,48,.78); color: #fff; }
.clip-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.clip-hook { font-weight: 700; line-height: 1.3; }
.clip-why { color: var(--muted); font-size: 13px; }
.clip-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.clip details { font-size: 13.5px; }
.clip details summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 4px 0; }
.posts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.posts li { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.bar { height: 6px; border-radius: 3px; background: #E7EBF0; overflow: hidden; margin-top: 3px; }
.bar > i { display: block; height: 100%; background: var(--money); }
.review { font-size: 13px; padding: 8px 10px; border-radius: var(--radius-s); }
.review.ok { background: var(--money-soft); color: #145C3A; }
.review.bad { background: #FDE8E5; color: var(--tally-ink); }

/* ---------- tablas ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-weight: 650; color: var(--muted); font-size: 13px; background: #F7F8FA; }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.err-text { color: var(--tally-ink); font-size: 12.5px; max-width: 46ch; overflow-wrap: anywhere; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .panel { width: min(380px, 100%); padding: 28px; }
.login h1 { font-size: 26px; margin-bottom: 4px; }

.empty { padding: 34px 18px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-m); }
.empty .btn { margin-top: 12px; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
