:root {
  color-scheme: light dark;
  --bg: #f6f7f9; --surface: #fff; --ink: #1b1f24; --muted: #5d6673; --line: #dde1e6;
  --brand: #2453d6; --brand-ink: #fff; --danger: #b42318; --new: #fff4d6; --new-ink: #7a4b00;
  --ok-bg: #e6f4ea; --ok-ink: #1e6b34; --arch-bg: #eceef1; --arch-ink: #4a525d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --surface: #1a1e24; --ink: #e8eaed; --muted: #a0a8b3; --line: #2c323a;
    --brand: #7aa2ff; --brand-ink: #0b1020; --danger: #ff8a80; --new: #3a2e10; --new-ink: #ffd27a;
    --ok-bg: #16301f; --ok-ink: #8fd6a4; --arch-bg: #262b32; --arch-ink: #b4bcc6;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.top { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.top__brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; display: grid; gap: 1rem; }
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem; margin: 0; }
.grid { display: grid; gap: 1rem; }
@media (min-width: 860px) { .grid { grid-template-columns: 1fr 1fr; } }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.inline { display: flex; flex-wrap: wrap; gap: .5rem; }

.btn { display: inline-flex; align-items: center; min-height: 38px; padding: .4rem .9rem; border: 1px solid var(--brand); border-radius: 8px; background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn--ghost { background: transparent; color: var(--brand); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }

input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .7rem; min-height: 38px; }
textarea { width: 100%; resize: vertical; margin-bottom: .75rem; }

.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: .5rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; }
.filters input[type="search"] { flex: 1 1 260px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-new td { font-weight: 600; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; vertical-align: middle; }
.badge--nuevo { background: var(--new); color: var(--new-ink); }
.badge--leido { background: var(--ok-bg); color: var(--ok-ink); }
.badge--archivado { background: var(--arch-bg); color: var(--arch-ink); }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: .75rem; }

.login { max-width: 360px; margin: 3rem auto; display: grid; gap: .9rem; }
.login label { display: grid; gap: .3rem; font-weight: 600; }
.alert { margin: 0; padding: .6rem .8rem; border-radius: 8px; background: var(--new); color: var(--danger); font-weight: 600; }

.top__nav { display: flex; align-items: center; gap: 1rem; }
.top__nav a { text-decoration: none; font-weight: 600; }
.notice { margin: 0; padding: .6rem .8rem; border-radius: 8px; background: var(--ok-bg); color: var(--ok-ink); font-weight: 600; }
.settings { display: grid; gap: 1rem; }
.settings h2 { margin: 0; text-transform: capitalize; }
.settings label { display: grid; gap: .3rem; font-weight: 600; }
.settings textarea { margin: 0; }
.settings .check { display: flex; align-items: center; gap: .5rem; }
.settings .check input { min-height: 0; width: 18px; height: 18px; }
.hint { font-weight: 400; font-size: .85rem; color: var(--muted); }
code { font-size: .9em; }
.sub { font-size: .95rem; margin: .5rem 0 0; }
.sent { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.sent li { border-top: 1px solid var(--line); padding-top: .4rem; }
.sent summary { font-weight: 400; }
.sent p { margin: .5rem 0 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--sm { min-height: 32px; padding: .2rem .7rem; font-size: .85rem; }
.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; }

/* ---------- Campañas ---------- */
.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.campana { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 1100px) { .campana { grid-template-columns: minmax(0, 1fr) 620px; } }
.campana__main { display: grid; gap: 1rem; min-width: 0; }
.campana__preview { position: sticky; top: 1rem; display: grid; gap: .5rem; }
.campana__preview iframe { width: 100%; height: calc(100vh - 6rem); min-height: 520px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.settings input:not([type="checkbox"]):not([type="radio"]), .settings select { width: 100%; }
.filters select, .filters input { width: auto; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.radios { border: 0; padding: 0; margin: 0; display: grid; gap: .5rem; }
.radios .check { font-weight: 400; flex-wrap: wrap; }
.radios select { width: auto !important; }
.picker { display: grid; gap: .5rem; }
.picker__list { list-style: none; margin: 0; padding: .5rem; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; display: grid; gap: .25rem; }
.picker__list .check { font-weight: 400; }
.send { padding-top: .75rem; border-top: 1px solid var(--line); }
.progress { height: 10px; border-radius: 999px; background: var(--arch-bg); overflow: hidden; }
.progress span { display: block; height: 100%; width: var(--pct); background: var(--brand); }

.editor { display: grid; gap: .75rem; }
.bloque { border: 1px solid var(--line); border-radius: 10px; padding: .75rem; display: grid; gap: .6rem; background: var(--bg); }
.bloque__head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.bloque__tipo { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.bloque__tools { display: flex; gap: .25rem; }
.bloque__tools button { min-height: 30px; min-width: 30px; padding: 0 .5rem; }
.bloque label { display: grid; gap: .25rem; font-size: .9rem; font-weight: 600; }
.bloque textarea { margin: 0; min-height: 110px; }
.bloque img { max-width: 220px; max-height: 140px; border-radius: 6px; border: 1px solid var(--line); }
.editor__add { display: flex; flex-wrap: wrap; gap: .4rem; }
.medios { display: flex; flex-wrap: wrap; gap: .4rem; }
.medios button { padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; cursor: pointer; }
.medios button:focus-visible, .medios button:hover { border-color: var(--brand); }
.medios img { width: 72px; height: 54px; object-fit: cover; border-radius: 4px; border: 0; }
