/* Radar de Anuncios - one stylesheet, no build step. Classes are listed in app/README_DEV.md. */
:root {
  --bg: #f5f5f4; --card: #ffffff; --text: #1c1917; --muted: #6b6560; --line: #e7e5e4;
  --accent: #2563eb; --accent-text: #ffffff; --hot: #dc2626; --warm: #b45309; --chip: #f0efed;
  --ok: #15803d; --bad: #b91c1c; --info: #1d4ed8; --focus: #2563eb;
  --st-nuevo: #15803d; --st-sigue: #2563eb; --st-reactivado: #7c3aed; --st-termino: #57534e;
  --ok-bg: #dcfce7; --bad-bg: #fee2e2; --info-bg: #dbeafe; --warn-bg: #fef3c7;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0a09; --card: #1c1917; --text: #f5f5f4; --muted: #a8a29e; --line: #2e2a27;
    --accent: #60a5fa; --accent-text: #0c0a09; --hot: #f87171; --warm: #fbbf24; --chip: #292524;
    --ok: #4ade80; --bad: #f87171; --info: #93c5fd; --focus: #93c5fd;
    /* white text on these stays >= 4.5:1 (WCAG AA) */
    --st-nuevo: #15803d; --st-sigue: #2563eb; --st-reactivado: #7c3aed; --st-termino: #78716c;
    --ok-bg: #052e16; --bad-bg: #450a0a; --info-bg: #172554; --warn-bg: #422006;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-wrap: anywhere; }
a { color: var(--accent); }
img, video { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
           clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* top bar */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 8px 16px; display: flex; flex-wrap: wrap;
                gap: 8px 16px; align-items: center; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 16px; white-space: nowrap; }
.nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1 1 auto; }
.nav a { color: var(--text); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.nav a:hover { background: var(--chip); }
.nav a[aria-current="page"] { background: var(--chip); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.nav .count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px;
              background: var(--accent); color: var(--accent-text); font-size: 11px; text-align: center; }
.userbox { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.userbox form { margin: 0; }

.container { max-width: 1280px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 760px; }
.page-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
             margin: 4px 0 16px; }
h1 { font-size: 22px; margin: 0; line-height: 1.25; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line);
         border-radius: var(--radius); background: var(--card); }

/* boxes */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel + .panel { margin-top: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 24px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; }
.list-card { display: flex; flex-direction: column; gap: 6px; }
.list-card a.title { font-weight: 600; font-size: 16px; color: var(--text); text-decoration: none; }
.list-card a.title:hover { text-decoration: underline; }
.nums { color: var(--muted); font-size: 13px; }
.nums b { color: var(--text); }

/* messages */
.flash, .banner { border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); border-color: var(--ok); }
.flash-error { background: var(--bad-bg); border-color: var(--bad); }
.flash-info { background: var(--info-bg); border-color: var(--info); }
.banner { background: var(--warn-bg); border-color: var(--warm); }

/* buttons and forms */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 14px; cursor: pointer;
       border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px;
       padding: 7px 12px; text-decoration: none; line-height: 1.3; min-height: 36px; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn-small { padding: 3px 9px; font-size: 13px; min-height: 30px; }
/* body breaks long words anywhere (ad copy, URLs); controls only wrap between words */
.btn, .pill, .nav a, .more { overflow-wrap: normal; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline { display: inline; margin: 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
                          border-radius: 8px; padding: 7px 10px; max-width: 100%; min-height: 36px; }
textarea { width: 100%; min-height: 70px; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); align-items: end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span, .field > label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; }
.field input[type=checkbox], .field input[type=radio] { width: 18px; min-height: 0; flex: none; }
.check { display: flex; gap: 8px; align-items: center; }
.help { color: var(--muted); font-size: 12px; margin: 2px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; }
details > summary { cursor: pointer; color: var(--accent); }
details.edit[open] { background: var(--bg); border-radius: 8px; padding: 8px; margin-top: 6px; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }
@media (max-width: 640px) {
  .table.stack-sm thead { display: none; }
  .table.stack-sm tr { display: block; border-bottom: 1px solid var(--line); padding: 6px 0; }
  .table.stack-sm td { display: block; position: relative; border: 0; padding: 4px 10px 4px 124px; min-height: 28px; }
  .table.stack-sm td::before { content: attr(data-label); position: absolute; left: 10px; top: 6px; width: 106px;
                               color: var(--muted); font-size: 12px; }
  .table.stack-sm td.num { text-align: left; }
}

/* pills, statuses, progress */
.pill { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600;
        background: var(--chip); color: var(--text); white-space: nowrap; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-warn { background: var(--warn-bg); color: var(--warm); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-clave { background: var(--warn-bg); color: var(--warm); }
.st { color: #fff; }
.st-nuevo { background: var(--st-nuevo); } .st-sigue { background: var(--st-sigue); }
.st-reactivado { background: var(--st-reactivado); } .st-termino { background: var(--st-termino); }
.job-queued { background: var(--chip); } .job-running { background: var(--info-bg); color: var(--info); }
.job-done { background: var(--ok-bg); color: var(--ok); } .job-error { background: var(--bad-bg); color: var(--bad); }
.job-cancelled { background: var(--chip); color: var(--muted); }
.progress { height: 6px; background: var(--chip); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }
pre.log { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 60vh;
          overflow: auto; white-space: pre-wrap; font-size: 12px; margin: 0; }

/* ad browser */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 16px; }
.filters .field { flex: 0 1 auto; }
.filters .field.grow { flex: 1 1 200px; }
.filters input[type=number] { width: 90px; }
.ads-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
@media (max-width: 400px) { .ads-grid { grid-template-columns: 1fr; } }
.ad-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
           overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.ad-card.ended { opacity: .6; filter: grayscale(.6); }
.ad-card.ended:hover, .ad-card.ended:focus-within { opacity: 1; filter: none; }
.ad-media { position: relative; background: #000; aspect-ratio: 1; }
.ad-media img, .ad-media video { width: 100%; height: 100%; object-fit: contain; display: block; }
.ad-media .no-media { color: #a8a29e; display: grid; place-items: center; height: 100%; }
.ad-media .days { position: absolute; top: 8px; left: 8px; border-radius: 999px; padding: 3px 9px; font-weight: 600;
                  font-size: 12px; color: #fff; background: rgba(0,0,0,.65); }
.ad-media .days.hot { background: #dc2626; } .ad-media .days.warm { background: #b45309; }
.ad-media .st { position: absolute; top: 8px; right: 8px; border-radius: 999px; padding: 3px 9px; font-weight: 700;
                font-size: 11px; letter-spacing: .03em; }
/* sits above the native video controls */
.ad-media .carousel { position: absolute; bottom: 56px; right: 8px; display: flex; gap: 4px; }
.ad-media .carousel button { border: 0; border-radius: 6px; background: rgba(0,0,0,.65); color: #fff; padding: 4px 10px;
                             cursor: pointer; font: inherit; min-height: 30px; }
.ad-info { padding: 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.ad-page { font-weight: 600; color: var(--text); text-decoration: none; }
.ad-page:hover { text-decoration: underline; }
.ad-meta { color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: var(--chip); border-radius: 6px; padding: 2px 7px; font-size: 12px; }
.chip.outline { background: none; border: 1px solid var(--line); }
.ad-badge { border-radius: 6px; padding: 2px 7px; font-size: 12px; font-weight: 600; background: var(--info-bg); color: var(--info); }
.ad-badge.ok { background: var(--ok-bg); color: var(--ok); } .ad-badge.warn { background: var(--warn-bg); color: var(--warm); }
.ad-badge.hot { background: var(--bad-bg); color: var(--bad); }
.ad-body { white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 5;
           -webkit-box-orient: vertical; }
.ad-body.open { display: block; }
.more { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; font: inherit; align-self: flex-start; }
.ad-links { margin-top: auto; display: flex; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 8px; font-size: 13px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 20px 0; flex-wrap: wrap; }

/* ad detail */
.detail { display: grid; gap: 16px; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .detail { grid-template-columns: minmax(0, 1fr); } }
.media-list { display: grid; gap: 8px; }
.media-list img, .media-list video { width: 100%; border-radius: 8px; background: #000; }
dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 13px; }
dl.kv dd { margin: 0; }
@media (max-width: 480px) { dl.kv { grid-template-columns: minmax(0, 1fr); } dl.kv dd { margin-bottom: 6px; } }

/* login */
.login-box { max-width: 380px; margin: 10vh auto; }
.login-box h1 { margin-bottom: 4px; }
