/* JERA Email — a dispatch desk for collection mail (visual redesign, odd/tasks/jera-email-rediseno-visual.md).
   Navy sidebar, one teal action color, status colors only for status. Everything is served from 'self' (CSP):
   no inline styles, no CDN, no icon fonts. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../fonts/schibsted-grotesk-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../fonts/schibsted-grotesk-latin-ext.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ================================================================== tokens */
:root {
  /* neutrals */
  --ink: #142b44;
  --ink-soft: #4b6075;
  --ink-faint: #6f8295;          /* AA on white for small text */
  --paper: #f3f6f9;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --line: #d3dce5;
  --line-soft: #e6ecf1;

  /* sidebar */
  --nav: #10284a;
  --nav-deep: #0b1f3a;
  --nav-text: #c9d6e4;
  --nav-muted: #8ea4bb;
  --nav-active: #1d4a73;

  /* the one action color */
  --action: #0b7672;
  --action-strong: #075955;
  --action-tint: #e1f3f1;
  --action-line: #a9dbd5;

  /* status tones (always with text, never color alone) */
  --ok: #1e7a45;      --ok-tint: #e3f4ea;     --ok-dot: #22a35a;
  --warn: #8a5300;    --warn-tint: #fdf1d8;   --warn-dot: #e3920b;   --warn-line: #f0d39a;
  --bad: #b3261e;     --bad-tint: #fde8e6;    --bad-dot: #dc3b2f;    --bad-line: #f2c3be;
  --info: #1f5f9e;    --info-tint: #e5f0fb;   --info-dot: #3b82c4;   --info-line: #bcd6f0;
  --idle: #4b6075;    --idle-tint: #edf1f5;   --idle-dot: #8496a8;

  --focus: #2563c9;

  /* shape */
  --r-input: 8px;
  --r-panel: 12px;
  --r-envelope: 14px;
  --shadow-1: 0 1px 2px rgba(16, 40, 74, .06);
  --shadow-2: 0 1px 2px rgba(16, 40, 74, .05), 0 8px 24px -12px rgba(16, 40, 74, .18);
  --shadow-3: 0 24px 64px -16px rgba(11, 31, 58, .45);

  /* spacing */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;

  /* type scale */
  --t-xs: 0.75rem;        /* 12 */
  --t-small: 0.8125rem;   /* 13 */
  --t-body: 0.9375rem;    /* 15 */
  --t-lead: 1.125rem;     /* 18 */
  --t-h2: 1.25rem;        /* 20 */
  --t-h1: 1.875rem;       /* 30 */
  --t-kpi: 2rem;          /* 32 */
  --mono: ui-monospace, "Cascadia Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace;
}

/* ================================================================== base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Schibsted Grotesk", system-ui, sans-serif;
  font-size: var(--t-body);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.015em; }
h1 { font-size: var(--t-h1); font-weight: 750; }
h2 { font-size: var(--t-h2); font-weight: 700; }
h3 { font-size: var(--t-lead); font-weight: 650; }
p { margin: 0; }
a { color: var(--action); text-underline-offset: 2px; }
a:hover { color: var(--action-strong); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-soft); }
.small { font-size: var(--t-small); }
.num, table.data td.num, .tally b, .kpi b { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 50; background: #fff; color: var(--ink); padding: 8px 12px; border-radius: var(--r-input); }
.skip:focus { left: 8px; }

/* ================================================================== shell: sidebar + workspace */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.menu-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.topbar { display: none; }
.rail {
  background: linear-gradient(180deg, var(--nav) 0%, var(--nav-deep) 100%);
  color: var(--nav-text);
  padding: var(--s5) var(--s3) var(--s4);
  display: flex; flex-direction: column; gap: var(--s5);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.mark { display: flex; align-items: center; gap: var(--s3); color: #fff; text-decoration: none; padding: 0 var(--s2); }
.mark:hover { color: #fff; }
.mark svg { flex: none; }
.mark-name { font-weight: 750; font-size: 1.25rem; letter-spacing: -0.01em; }
.mark-name span { font-weight: 500; color: #fff; }
.rail .nav-group {
  margin: var(--s4) var(--s3) var(--s2); font-size: 0.6875rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--nav-muted);
}
.rail nav > .nav-group:first-child { margin-top: 0; }
.rail nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rail nav a {
  display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s3); border-radius: var(--r-input);
  color: var(--nav-text); text-decoration: none; font-weight: 500;
}
.rail nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.rail nav a[aria-current="page"] { background: var(--nav-active); color: #fff; font-weight: 650; box-shadow: inset 3px 0 0 #5fd0c4; }
.rail nav a:focus-visible, .rail-foot a:focus-visible, .rail-foot button:focus-visible { outline-color: #8cc3ff; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail-foot {
  margin-top: auto; font-size: var(--t-small); color: var(--nav-muted); display: grid; gap: var(--s2);
  border-top: 1px solid rgba(255, 255, 255, .1); padding: var(--s4) var(--s2) 0;
}
.rail-foot .who { display: flex; gap: var(--s3); align-items: center; min-width: 0; }
.rail-foot .who > div { min-width: 0; }
.rail-foot .who span:not(.avatar) { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-foot strong { color: #fff; font-weight: 600; display: block; font-size: var(--t-body); }
.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: #2c5a85; color: #fff; font-weight: 700;
}
.rail-foot a, .rail-foot button { color: var(--nav-text); }
.rail-foot a:hover, .rail-foot button:hover { color: #fff; }
.rail-foot a[aria-current="page"] { color: #fff; font-weight: 650; }

/* content column, centered and bounded on wide screens */
.workspace { padding: var(--s6) clamp(var(--s5), 3.5vw, var(--s7)) var(--s7); width: 100%; min-width: 0; }
.workspace-inner { max-width: 1320px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; }
.page-head p { margin-top: var(--s2); color: var(--ink-soft); max-width: 70ch; }
.page-head .actions { margin-top: 0; }
.title-row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }

/* breadcrumbs */
.crumbs { margin: 0 0 var(--s2); padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: var(--s2); font-size: var(--t-small); color: var(--ink-soft); }
.crumbs li + li::before { content: "/"; margin-right: var(--s2); color: var(--ink-faint); }
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--action); text-decoration: underline; }
.crumbs [aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ================================================================== panels, grids */
.panel { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-panel); padding: var(--s5); box-shadow: var(--shadow-1); }
.panel + .panel, .stack > * + * { margin-top: var(--s4); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); margin-bottom: var(--s4); flex-wrap: wrap; }
.panel-head h2 { display: flex; align-items: center; gap: var(--s2); }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > .panel-head { padding: var(--s4) var(--s5) 0; margin-bottom: var(--s3); }
.panel.flush > .table-wrap { border: 0; border-radius: 0; border-top: 1px solid var(--line-soft); }
.panel.flush > .empty { border-top: 1px solid var(--line-soft); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s4); }
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--s5); align-items: start; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: var(--s4); align-items: start; margin-top: var(--s4); }
.section-title { margin: var(--s5) 0 var(--s2); }
.panel.section-title { margin: var(--s4) 0 0; }
.panel > h2 + p, .panel > h3 + p { margin: 6px 0 var(--s4); }
.panel > h2 + form, .panel > p + form { margin-top: var(--s4); }
.count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  font-size: var(--t-xs); font-weight: 700; background: var(--idle-tint); color: var(--idle); font-variant-numeric: tabular-nums;
}
.count.bad { background: var(--bad); color: #fff; }

/* ================================================================== forms */
label.field { display: grid; gap: 6px; font-weight: 600; font-size: var(--t-small); color: var(--ink); }
label.field + label.field, .field-row + .field-row { margin-top: var(--s4); }
/* in a two-column form the grid gap spaces the fields; the stacking margin would misalign the second column */
.grid-2 > label.field + label.field { margin-top: 0; }
.panel > h2 + .grid-2 { margin-top: var(--s4); }
.panel + .table-wrap { margin-top: var(--s4); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date],
input[type=time], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; font-size: var(--t-body); font-weight: 400; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-input); padding: 9px 12px; min-height: 40px;
}
textarea { min-height: 220px; resize: vertical; font-size: 0.875rem; line-height: 1.55; }
textarea.code { font-family: var(--mono); font-size: 0.8125rem; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-faint); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(37, 99, 201, .35); outline-offset: 0; border-color: var(--focus); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--action); vertical-align: -3px; min-height: 0; }
.check { display: inline-flex; gap: var(--s2); align-items: center; font-weight: 500; }
fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.plain legend { margin-bottom: var(--s2); }
fieldset.plain .check { display: flex; margin: 6px 0; }
fieldset.plain[disabled] textarea, fieldset.plain[disabled] input, fieldset.plain[disabled] select { background: var(--surface-soft); color: var(--ink-soft); }
.search-input { position: relative; }
.search-input input { padding-left: 38px; }
.search-input svg { position: absolute; left: 12px; bottom: 11px; width: 18px; height: 18px; color: var(--ink-faint); pointer-events: none; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  font: inherit; font-weight: 650; font-size: var(--t-body); line-height: 1.2;
  padding: 10px 18px; min-height: 40px; border-radius: var(--r-input); border: 1px solid transparent;
  background: var(--action); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-1);
}
.btn:hover { background: var(--action-strong); color: #fff; }
.btn .ico { width: 18px; height: 18px; }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--ink-faint); background: var(--surface-soft); color: var(--ink); }
.btn.quiet { background: none; color: var(--action); padding: 6px 10px; min-height: 0; box-shadow: none; }
.btn.quiet:hover { background: var(--action-tint); color: var(--action-strong); }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad-tint); color: var(--bad); }
.btn.quiet.danger { border: 0; }
.btn.small { padding: 5px 12px; min-height: 32px; font-size: var(--t-small); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; color: var(--action); }
.actions { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; margin-top: var(--s5); }
.actions.flush { margin: 0; }
form.inline { display: inline; }

/* ================================================================== notices */
.notice {
  border-radius: var(--r-input); padding: var(--s3) var(--s4); border: 1px solid; border-left-width: 4px;
  display: block;
}
.notice.error { background: var(--bad-tint); border-color: var(--bad-line); border-left-color: var(--bad-dot); color: #7d1a14; }
.notice.warn { background: var(--warn-tint); border-color: var(--warn-line); border-left-color: var(--warn-dot); color: #5c3c00; }
.notice.ok { background: var(--ok-tint); border-color: #bcdcc8; border-left-color: var(--ok-dot); color: #1f5332; }
.notice.info { background: var(--info-tint); border-color: var(--info-line); border-left-color: var(--info-dot); color: #173f66; }
.notice ul { margin: var(--s2) 0 0; padding-left: 1.2em; }
.notice + * { margin-top: var(--s4); }
.notice a { color: inherit; font-weight: 600; }
.banner { display: flex; gap: var(--s3); align-items: flex-start; }
.banner .ico { margin-top: 1px; }
.notice.secret code { display: block; margin-top: var(--s2); padding: var(--s2) var(--s3); background: #fff; border-radius: var(--r-input); font-size: 0.875rem; overflow-wrap: anywhere; user-select: all; }

/* notices list (dashboard "Avisos") */
ul.alerts { list-style: none; margin: 0; padding: 0; }
ul.alerts > li { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: var(--s3); padding: var(--s4) 0; border-top: 1px solid var(--line-soft); }
ul.alerts > li:first-child { border-top: 0; padding-top: 0; }
ul.alerts strong { display: block; }
ul.alerts span:has(> .info) { display: flex; align-items: center; }
ul.alerts span:has(> .info) > strong { display: inline; }
ul.alerts ul { margin: var(--s1) 0 0; padding-left: 1.1em; font-size: var(--t-small); }
.alert-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; }
.alert-icon .ico { width: 20px; height: 20px; }
.alert-icon.bad { background: var(--bad-tint); color: var(--bad); }
.alert-icon.warn { background: var(--warn-tint); color: var(--warn); }
.alert-icon.info { background: var(--info-tint); color: var(--info); }

/* ================================================================== wizard route */
.route { display: flex; list-style: none; padding: 0; margin: 0 0 var(--s5); gap: 0; counter-reset: step; }
.route li { flex: 1; position: relative; padding-top: 22px; font-size: var(--t-small); color: var(--ink-faint); font-weight: 550; }
.route li::before {
  counter-increment: step; content: counter(step);
  position: absolute; top: 0; left: 0; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 700;
  background: var(--paper); border: 2px solid var(--line); color: var(--ink-faint); z-index: 1;
}
.route li::after { content: ""; position: absolute; top: 11px; left: 24px; right: 0; height: 2px; background: var(--line); }
.route li:last-child::after { display: none; }
.route li span { display: block; padding-top: 10px; }
.route li.done { color: var(--ink-soft); }
.route li.done::before { background: var(--action); border-color: var(--action); color: #fff; content: "✓"; }
.route li.done::after { background: var(--action); }
.route li.current { color: var(--ink); font-weight: 650; }
.route li.current::before { border-color: var(--action); color: var(--action); background: #fff; }

/* ================================================================== tables */
/* a wide table scrolls inside its own box, never the page; the edge shadows (CSS-only scroll shadows: the white
   covers travel with the content, the shadows stay at the box edges) show there is more to the left or right */
.table-wrap {
  max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line-soft); border-radius: var(--r-panel); box-shadow: var(--shadow-1);
  background:
    linear-gradient(to right, #fff 30%, rgba(255, 255, 255, 0)) left center / 40px 100% no-repeat local,
    linear-gradient(to left, #fff 30%, rgba(255, 255, 255, 0)) right center / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(16, 37, 58, .18), rgba(16, 37, 58, 0)) left center / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(16, 37, 58, .18), rgba(16, 37, 58, 0)) right center / 14px 100% no-repeat scroll,
    #fff;
}
table.data { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data th, table.data td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data thead th { background: var(--surface-soft); color: var(--ink-soft); font-weight: 650; font-size: var(--t-small); position: sticky; top: 0; white-space: nowrap; }
table.data th .key { display: block; font-weight: 450; font-size: 0.75rem; color: var(--ink-faint); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #f6f9fb; }
table.data td.num, table.data th.num { text-align: right; }
table.data tr.clickable { cursor: pointer; }
table.data tr[aria-selected="true"] td { background: var(--action-tint); }
table.data td a:not(.btn) { font-weight: 600; }
table.data td .sub { display: block; font-size: var(--t-small); color: var(--ink-soft); font-weight: 400; }
table.data select { min-width: 140px; }
table.data td.go { width: 1%; white-space: nowrap; text-align: right; }
.empty { padding: var(--s6); text-align: center; color: var(--ink-soft); }
.empty .btn { margin-top: var(--s4); }
.panel.empty { padding: var(--s7) var(--s5); }

/* ================================================================== status badges: dot + text, tone by status */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 650; white-space: nowrap; line-height: 1.6;
  background: var(--idle-tint); color: var(--idle);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--idle-dot); flex: none; }
.chip.big { font-size: 0.8125rem; padding: 4px 12px 4px 10px; }
/* green: running, valid, published, done */
.chip.EN_CURSO, .chip.VALIDA, .chip.VALIDADO, .chip.PUBLICADA, .chip.COMPLETADA, .chip.VALIDADA, .chip.ok { background: var(--ok-tint); color: var(--ok); }
.chip.EN_CURSO::before, .chip.VALIDA::before, .chip.VALIDADO::before, .chip.PUBLICADA::before, .chip.COMPLETADA::before,
.chip.VALIDADA::before, .chip.ok::before { background: var(--ok-dot); }
/* amber: paused, partial, provisional */
.chip.PAUSADA, .chip.PAUSADA_AUTO, .chip.EXCLUIDA, .chip.DUPLICADO_EXACTO, .chip.PROVISIONAL,
.chip.COMPLETADA_CON_INCIDENCIAS, .chip.CANCELANDO, .chip.warn { background: var(--warn-tint); color: var(--warn); }
.chip.PAUSADA::before, .chip.PAUSADA_AUTO::before, .chip.EXCLUIDA::before, .chip.DUPLICADO_EXACTO::before, .chip.PROVISIONAL::before,
.chip.COMPLETADA_CON_INCIDENCIAS::before, .chip.CANCELANDO::before, .chip.warn::before { background: var(--warn-dot); }
/* red: review needed, errors, uncertain */
.chip.ERROR, .chip.CONFLICTO, .chip.RECHAZADO, .chip.VALIDADO_CON_ERRORES, .chip.INCIERTO, .chip.INCIERTO_SIN_EVIDENCIA,
.chip.bad { background: var(--bad-tint); color: var(--bad); }
.chip.ERROR::before, .chip.CONFLICTO::before, .chip.RECHAZADO::before, .chip.VALIDADO_CON_ERRORES::before,
.chip.INCIERTO::before, .chip.INCIERTO_SIN_EVIDENCIA::before, .chip.bad::before { background: var(--bad-dot); }
/* blue: approved / scheduled, waiting for a start */
.chip.APROBADA, .chip.PROGRAMADA, .chip.info { background: var(--info-tint); color: var(--info); }
.chip.APROBADA::before, .chip.PROGRAMADA::before, .chip.info::before { background: var(--info-dot); }
/* grey (default): draft, waiting for approval, cancelled, withdrawn, loaded, excluded */
.reasons { display: flex; flex-wrap: wrap; gap: 4px; }
.reason { font-size: 0.75rem; background: var(--surface-soft); border: 1px solid var(--line-soft); border-radius: 4px; padding: 0 6px; color: var(--ink-soft); }

/* ================================================================== progress bars */
progress {
  appearance: none; -webkit-appearance: none; width: 100%; height: 8px; border: 0; border-radius: 999px;
  background: var(--line-soft); overflow: hidden; vertical-align: middle; color: var(--action);
}
progress::-webkit-progress-bar { background: var(--line-soft); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--action); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--action); border-radius: 999px; }
progress.big { height: 14px; }
.progress-cell { display: grid; grid-template-columns: minmax(80px, 1fr) auto; gap: 2px var(--s3); align-items: center; min-width: 180px; }
.progress-cell b { font-size: var(--t-small); font-variant-numeric: tabular-nums; }
.progress-cell .small { grid-column: 1 / -1; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.progress-cell .bad-text { grid-column: 1 / -1; font-size: var(--t-small); }
table.data progress { width: 100%; margin: 0; }
.big-progress { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s4); align-items: center; margin: var(--s3) 0 var(--s4); }
.big-progress b { font-size: 2rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.big-progress span { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ================================================================== KPI cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: var(--s3); margin: 0; }
.kpi {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); grid-template-areas: "icon label" "value value" "sub sub" "bar bar";
  align-items: center; column-gap: var(--s3); row-gap: 6px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-panel); padding: var(--s4) var(--s4) var(--s4);
  color: var(--ink); text-decoration: none; box-shadow: var(--shadow-1);
}
a.kpi:hover { border-color: var(--action-line); box-shadow: var(--shadow-2); color: var(--ink); }
.kpi-icon { grid-area: icon; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--info-tint); color: var(--info); }
.kpi.valid .kpi-icon { background: var(--ok-tint); color: var(--ok); }
.kpi.bad .kpi-icon { background: var(--bad-tint); color: var(--bad); }
.kpi.warn .kpi-icon { background: var(--warn-tint); color: var(--warn); }
.kpi.quota .kpi-icon { background: var(--action-tint); color: var(--action); }
.kpi-label { grid-area: label; font-weight: 600; font-size: 0.875rem; line-height: 1.25; }
.kpi b { grid-area: value; font-size: var(--t-kpi); font-weight: 750; line-height: 1.1; letter-spacing: -0.02em; margin-top: var(--s2); }
.kpi .kpi-sub { grid-area: sub; font-size: var(--t-small); color: var(--ink-soft); }
.kpi .kpi-sub + .kpi-sub { grid-area: auto; grid-column: 1 / -1; }
.kpi progress { grid-area: bar; margin-top: var(--s1); }
.kpis.small { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); }
.kpis.small .kpi { grid-template-columns: 1fr; grid-template-areas: "label" "value"; padding: var(--s3) var(--s4); box-shadow: none; }
.kpis.small .kpi b { font-size: 1.5rem; margin-top: 0; }
.kpis.small .kpi-label { font-weight: 500; color: var(--ink-soft); font-size: var(--t-small); }
.kpis.small .kpi.bad b { color: var(--bad); }
.kpis.small .kpi.warn b { color: var(--warn); }

/* ---------- tally: totals as one ruler (reports, batch validation) ---------- */
.tally { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line-soft); border-radius: var(--r-panel); background: #fff; overflow: hidden; box-shadow: var(--shadow-1); }
.tally a { padding: var(--s4); text-decoration: none; color: var(--ink); border-right: 1px solid var(--line-soft); display: grid; gap: 2px; }
.tally a:last-child { border-right: 0; }
.tally a:hover { background: var(--surface-soft); }
.tally a[aria-current="true"] { box-shadow: inset 0 -3px 0 var(--action); }
.tally b { font-size: 1.75rem; font-weight: 750; line-height: 1.1; }
.tally span { font-size: var(--t-small); color: var(--ink-soft); }
.tally .valid b { color: var(--ok); }
.tally .bad b { color: var(--bad); }
.tally .warn b { color: var(--warn); }
.tally.dash { grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); }
.bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line-soft); margin-top: var(--s3); }
.bar i { display: block; }
.bar .valid { background: var(--ok-dot); } .bar .bad { background: var(--bad-dot); } .bar .warn { background: var(--warn-dot); }
.ruler { display: block; margin: var(--s2) 0 var(--s5); border-radius: 3px; overflow: hidden; }
.ruler .seg.valid { fill: var(--ok-dot); } .ruler .seg.bad { fill: var(--bad-dot); } .ruler .seg.warn { fill: var(--warn-dot); }

/* ================================================================== tabs and filter bar */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--line); margin: var(--s5) 0 var(--s4); overflow-x: auto; }
.tabs a {
  display: inline-flex; align-items: center; gap: var(--s2); padding: 10px var(--s4); margin-bottom: -1px;
  color: var(--ink-soft); font-weight: 600; text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--action-strong); border-bottom-color: var(--action); }
.tabs a[aria-current="page"] .count { background: var(--action-tint); color: var(--action-strong); }
form.filter-bar { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(150px, 1fr)) auto; gap: var(--s3) var(--s4); align-items: end; }
form.filter-bar .btn { min-height: 42px; }
form.filters { display: flex; gap: var(--s3); align-items: end; flex-wrap: wrap; }
form.filters label { min-width: 200px; }
form.search-inline { display: flex; gap: var(--s3); align-items: end; }
form.search-inline label { flex: 1; }
.search { margin-top: var(--s2); }

/* ================================================================== campaign detail */
.campaign-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: var(--s5); }
.campaign-hero .side { border-left: 1px solid var(--line-soft); padding-left: var(--s5); }
dl.inline-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s3) var(--s5); margin: var(--s4) 0 0; padding-top: var(--s4); border-top: 1px solid var(--line-soft); }
dl.inline-facts dt { color: var(--ink-soft); font-size: var(--t-small); }
dl.inline-facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
ol.steps { list-style: none; margin: var(--s3) 0 0; padding: 0; }
ol.steps li { position: relative; padding: 0 0 var(--s4) 34px; }
ol.steps li::before {
  content: "✓"; position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ok-dot); color: #fff; font-size: 0.75rem; font-weight: 800; display: grid; place-items: center;
}
ol.steps li::after { content: ""; position: absolute; left: 10px; top: 24px; bottom: 2px; width: 2px; background: var(--ok-tint); }
ol.steps li:last-child::after { display: none; }
ol.steps strong { display: block; font-weight: 600; line-height: 1.3; }
ol.steps time { font-size: var(--t-small); color: var(--ink-soft); font-variant-numeric: tabular-nums; }

dl.facts { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 10px var(--s4); margin: 0; }
dl.facts dt { color: var(--ink-soft); font-size: var(--t-small); padding-top: 2px; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
dl.facts dd.hash { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-soft); }
details.more { margin-top: var(--s4); }
details.more > summary { cursor: pointer; font-weight: 600; color: var(--action); }
details.more > summary + * { margin-top: var(--s3); }
fieldset.group { border: 0; padding: 0; margin: 0 0 var(--s5); min-width: 0; }
fieldset.group legend { font-weight: 700; font-size: var(--t-lead); margin-bottom: var(--s3); padding: 0; }
fieldset.group + fieldset.group { border-top: 1px solid var(--line-soft); padding-top: var(--s5); }
fieldset.group .grid-2 { align-items: end; }
.policy-list { display: grid; gap: 6px; margin: var(--s4) 0 var(--s2); font-size: 0.875rem; }
.policy { display: flex; gap: var(--s3); align-items: baseline; flex-wrap: wrap; }
.policy strong { min-width: 170px; }
.panel.approval { border-color: var(--action-line); box-shadow: inset 4px 0 0 var(--action), var(--shadow-1); }
form.reject { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line-soft); display: grid; gap: var(--s3); justify-items: start; }
form.reject label { width: 100%; }
ul.counts { list-style: none; padding: 0; margin: var(--s3) 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--s3); }
ul.counts li { border: 1px solid var(--line-soft); border-radius: var(--r-input); padding: var(--s3); }
ul.counts b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
ul.counts span { color: var(--ink-soft); font-size: var(--t-small); }
ul.counts li.warn { background: var(--warn-tint); border-color: var(--warn-line); }
ul.counts li.warn b { color: var(--warn); }
ul.counts li.bad { background: var(--bad-tint); border-color: var(--bad-line); }
ul.counts li.bad b { color: var(--bad); }
.panel.progress .meter { margin: var(--s2) 0 var(--s3); border-radius: 6px; overflow: hidden; }
.panel.progress .seg.valid { fill: var(--action); }
form.schedule { display: flex; gap: var(--s3); align-items: end; margin-top: var(--s4); flex-wrap: wrap; }
form.schedule label { flex: 1; min-width: 220px; }
form.resolve { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
form.resolve input { width: 160px; padding: 6px 8px; min-height: 34px; }

/* ================================================================== file drop, mapping */
.drop {
  display: grid; place-items: center; text-align: center; gap: var(--s2);
  border: 2px dashed var(--line); border-radius: var(--r-panel); padding: var(--s7) var(--s5);
  background: var(--surface-soft); cursor: pointer; position: relative;
}
.drop:hover, .drop.over { border-color: var(--action); background: var(--action-tint); }
.drop:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop strong { font-size: var(--t-lead); }
.drop .chosen { font-weight: 650; color: var(--action-strong); }
.map-row { display: grid; grid-template-columns: minmax(0, 5fr) 24px minmax(0, 6fr); gap: var(--s3); align-items: center; padding: var(--s3) 0; border-bottom: 1px solid var(--line-soft); }
.map-row:last-child { border-bottom: 0; }
.map-row .target { font-weight: 650; }
.map-row .target small { display: block; font-weight: 450; color: var(--ink-faint); font-size: 0.75rem; }
.map-row .arrow { color: var(--ink-faint); text-align: center; }
.var { font-family: var(--mono); font-size: 0.8125rem; background: #eaf1f6; border-radius: 4px; padding: 0 5px; color: var(--ink); }

/* ================================================================== the envelope (email previews) */
.envelope {
  background: #fff; border-radius: var(--r-envelope); border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-2); overflow: hidden; position: relative;
}
.envelope-head {
  padding: var(--s4) var(--s5); padding-right: 132px;
  background:
    repeating-linear-gradient(135deg, var(--nav) 0 10px, #fff 10px 20px, var(--action) 20px 30px, #fff 30px 40px) top / 100% 5px no-repeat,
    var(--surface-soft);
  border-bottom: 1px solid var(--line-soft);
  display: grid; grid-template-columns: 64px minmax(0, 1fr); row-gap: 4px; column-gap: var(--s3);
  font-size: 0.875rem; margin: 0;
}
.envelope-head dt { color: var(--ink-faint); }
.envelope-head dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.envelope-head dd.subject { font-weight: 700; font-size: 1rem; }
.postmark {
  position: absolute; top: 18px; right: 20px; width: 96px; height: 96px; border-radius: 50%;
  border: 2px solid var(--action); color: var(--action);
  display: grid; place-items: center; text-align: center; transform: rotate(-9deg);
  font-size: 0.6875rem; font-weight: 700; line-height: 1.25; background: rgba(255, 255, 255, .85);
}
.postmark::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; border: 1px dashed var(--action); }
.postmark b { display: block; font-size: 1.25rem; line-height: 1; }
.postmark.frozen { border-color: var(--ink); color: var(--ink); }
.postmark.frozen::before { border-color: var(--ink); }
.envelope iframe { display: block; width: 100%; height: 460px; border: 0; background: #fff; }
.envelope-tabs { display: flex; gap: var(--s1); padding: var(--s2) var(--s4) 0; border-bottom: 1px solid var(--line-soft); }
.envelope-tabs button { background: none; border: 0; font: inherit; font-weight: 600; color: var(--ink-soft); padding: 8px 10px; border-bottom: 3px solid transparent; cursor: pointer; }
.envelope-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--action); }
.envelope pre { margin: 0; padding: var(--s5); white-space: pre-wrap; font-family: inherit; font-size: 0.9375rem; max-height: 460px; overflow: auto; }
.envelope .problems { padding: var(--s5); }

.sample-list { list-style: none; padding: 0; margin: var(--s3) 0 0; display: grid; gap: 2px; max-height: 420px; overflow: auto; }
.sample-list button {
  width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: var(--r-input);
  padding: 8px 10px; font: inherit; color: var(--ink); cursor: pointer; display: grid; gap: 1px;
}
.sample-list button:hover { background: var(--surface-soft); }
.sample-list button[aria-pressed="true"] { background: var(--action-tint); border-color: var(--action-line); }
.sample-list small { color: var(--ink-faint); }
.version-link { display: flex; gap: var(--s3); align-items: center; padding: 8px 10px; border-radius: var(--r-input); text-decoration: none; color: var(--ink); }
.version-link:hover { background: var(--surface-soft); color: var(--ink); }
.version-link[aria-current="true"] { background: var(--action-tint); }
.version-link small { margin-left: auto; color: var(--ink-faint); }

/* ================================================================== template editor (reference 03) */
.editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.editor-head .head-actions { display: grid; justify-items: end; gap: var(--s2); }
.editor-head .head-actions .actions { margin: 0; }
.panel.editor {
  position: relative; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(400px, 1fr);
  column-gap: var(--s5); align-items: stretch;
}
/* the fieldset only groups the disabled state: its parts are cells of the editor grid */
.panel.editor > fieldset.plain { display: contents; }
.editor-top { grid-column: 1 / -1; }
.editor-main { grid-column: 1; display: flex; flex-direction: column; min-width: 0; }
.editor-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s2) var(--s4); flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-top: var(--s4); }
.editor-bar .editor-tabs { border-bottom: 0; margin-top: 0; }
.editor-bar .code-tools { margin: 0 0 6px; }
.tab-radio { position: absolute; top: 0; left: 0; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.editor-tabs { display: flex; gap: var(--s1); margin-top: var(--s4); border-bottom: 1px solid var(--line); }
.editor-tabs label {
  padding: 8px var(--s4); margin-bottom: -1px; cursor: pointer; font-weight: 650; font-size: var(--t-small);
  color: var(--ink-soft); border-bottom: 3px solid transparent;
}
.editor-tabs label:hover { color: var(--ink); }
.editor-pane { display: none; margin-top: var(--s3); flex: 1; flex-direction: column; }
.editor-pane .small { margin-top: var(--s2); }
#pestana-html:checked ~ fieldset .pane-html,
#pestana-texto:checked ~ fieldset .pane-texto { display: flex; }
.pane-html .code-area { flex: 1; min-height: 520px; }
.pane-texto textarea { flex: 1; min-height: 420px; }
#pestana-html:checked ~ fieldset label[for="pestana-html"],
#pestana-texto:checked ~ fieldset label[for="pestana-texto"] { color: var(--action-strong); border-bottom-color: var(--action); }
#pestana-html:focus-visible ~ fieldset label[for="pestana-html"],
#pestana-texto:focus-visible ~ fieldset label[for="pestana-texto"] { outline: 3px solid var(--focus); outline-offset: 2px; }
/* code look: dark, monospace, generous line height; app.js adds the line-number gutter */
.code-area { position: relative; display: flex; border-radius: var(--r-input); overflow: hidden; background: #0f1b2d; border: 1px solid #0f1b2d; }
.code-area:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.code-gutter {
  flex: none; margin: 0; padding: 12px 10px 12px 12px; min-width: 44px; text-align: right; user-select: none;
  font-family: var(--mono); font-size: 0.8125rem; line-height: 1.7; color: #5f7590; background: #0b1524;
  border-right: 1px solid #1d2c42; overflow: hidden; white-space: pre;
}
textarea.code {
  flex: 1; min-height: 460px; border: 0; border-radius: 0; background: #0f1b2d; color: #e3ebf5; caret-color: #5fd0c4;
  font-family: var(--mono); font-size: 0.8125rem; line-height: 1.7; padding: 12px 14px; white-space: pre; overflow: auto; tab-size: 2;
}
textarea.code:hover { border: 0; }
textarea.code:focus-visible { outline: 0; }
textarea.code::selection { background: #2a4a72; }
fieldset.plain[disabled] textarea.code { background: #18263a; color: #b9c7d8; }
/* CodeMirror (S1): replaces the textarea and its gutter; Darcula theme, variables in their own color */
.code-area.has-editor { display: block; background: #2b2b2b; border-color: #2b2b2b; }
.code-area.has-editor .code-gutter { display: none; }
.code-area .CodeMirror { position: absolute; inset: 0; height: auto; font-family: var(--mono); font-size: 0.8125rem; line-height: 1.6; }
.code-area .CodeMirror-gutters { border-right: 1px solid #3c3f41; }
/* closer to IntelliJ's Darcula for HTML: yellow tags without underline, grey attributes, green values */
.code-area .cm-s-darcula span.cm-tag { color: #e8bf6a; font-style: normal; text-decoration: none; }
.code-area .cm-s-darcula span.cm-bracket { color: #e8bf6a; }
.code-area .cm-s-darcula span.cm-attribute { color: #bababa; font-style: normal; }
.code-area .cm-s-darcula span.cm-string { color: #a5c261; }
.code-area .cm-s-darcula .CodeMirror-matchingtag { background: rgba(255, 239, 40, .16); border-bottom: 1px solid #ffef28; }
.code-area .cm-s-darcula .cm-jera-var { color: #ffc66d; background: rgba(255, 198, 109, .14); border-radius: 3px; font-weight: 700; }
.CodeMirror-hints { font-family: var(--mono); font-size: 0.8125rem; z-index: 50; }
.CodeMirror-dialog input.CodeMirror-search-field { width: 14em; }
.code-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4); margin-bottom: var(--s2); }
.code-tools label { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 600; }
.code-tools select { width: auto; }
.code-tools p { margin: 0; }
/* variables: one chip each; the chip opens a small panel with its type and whether it may be empty */
.var-bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.var-bar-label { font-weight: 650; font-size: var(--t-small); margin-right: var(--s1); }
.var-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.var-chip { position: relative; }
.var-chip summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: var(--s2); padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: var(--t-small);
}
.var-chip summary::-webkit-details-marker { display: none; }
.var-chip summary:hover { border-color: var(--action-line); }
.var-chip details[open] summary { border-color: var(--action); box-shadow: var(--shadow-1); }
.var-chip .var { font-weight: 700; color: var(--action-strong); background: none; padding: 0; }
.var-chip .var-meta { color: var(--ink-soft); }
.var-pop {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: 300px; display: grid; gap: var(--s3);
  padding: var(--s3) var(--s4); background: #fff; border: 1px solid var(--line); border-radius: var(--r-input); box-shadow: var(--shadow-2);
}
.var-pop .field { margin: 0; font-size: var(--t-small); }
.var-pop select { min-height: 34px; padding-top: 5px; padding-bottom: 5px; font-size: var(--t-small); }
.var-pop .btn { justify-self: start; }
/* live variable detection (app.js): a declared variable no longer used is dropped on save */
.var-chip.is-unused summary { border-style: dashed; border-color: var(--warn-line); background: var(--warn-tint); }
.var-chip.is-unused .var { color: var(--warn); text-decoration: line-through; }
.var-unused-note { margin: 0; color: var(--warn); font-weight: 600; }
.var-chip.var-new summary { border-color: var(--action-strong); }
/* preview: the column next to the code, as tall as the code */
.preview-col { grid-column: 2; display: flex; flex-direction: column; min-width: 0; padding-left: var(--s5); border-left: 1px solid var(--line-soft); margin-top: var(--s4); }
.preview-col .panel-head { margin-bottom: var(--s2); }
.preview-col .phone-frame { flex: 1; display: flex; }
.preview-col .phone-frame iframe { height: auto; min-height: 520px; }
.preview-open { margin: var(--s2) 0 0; }
.preview-modes { display: inline-flex; background: var(--surface-soft); border: 1px solid var(--line-soft); border-radius: var(--r-input); padding: 3px; gap: 3px; }
.preview-modes a, .preview-modes button, .preview-modes > span {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px; border: 1px solid transparent;
  font: inherit; font-size: var(--t-small); font-weight: 600; color: var(--ink-soft); background: none; cursor: pointer; text-decoration: none;
}
.preview-modes [aria-pressed="true"], .preview-modes .current { background: #fff; color: var(--action-strong); border-color: var(--action-line); box-shadow: var(--shadow-1); }
.preview-modes .ico { width: 16px; height: 16px; }
.phone-frame { margin: var(--s3) auto 0; width: 375px; max-width: 100%; border: 1px solid var(--line); border-radius: 18px; padding: 10px 0; background: var(--surface-soft); }
.phone-frame iframe { display: block; width: 375px; max-width: 100%; height: 620px; border: 0; background: #fff; }
.preview-subject { font-size: var(--t-small); color: var(--ink-soft); margin-top: var(--s3); overflow-wrap: anywhere; }
.preview-subject b { color: var(--ink); }
/* "Escritorio": a wide overlay above the editor, opened with :target (no script needed) */
.preview-overlay { display: none; position: fixed; inset: 0; z-index: 40; background: rgba(11, 31, 58, .55); padding: var(--s5); }
.preview-overlay:target, .preview-overlay.open { display: grid; place-items: center; }
.preview-overlay .sheet { background: #fff; border-radius: var(--r-panel); box-shadow: var(--shadow-3); width: min(760px, 100%); height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
.preview-overlay .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.preview-overlay .sheet-body { overflow: auto; background: var(--surface-soft); padding: var(--s4); }
.preview-overlay iframe { display: block; width: 640px; max-width: none; height: calc(100vh - 140px); min-height: 400px; margin: 0 auto; border: 1px solid var(--line-soft); background: #fff; }
details.history { margin-top: var(--s4); padding: 0; }
details.history > summary { cursor: pointer; font-weight: 700; padding: var(--s4) var(--s5); list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.history > summary::-webkit-details-marker { display: none; }
details.history > summary::after { content: "▾"; color: var(--ink-soft); transition: transform .15s; }
details.history[open] > summary::after { transform: rotate(180deg); }
details.history > p, details.history > ul { margin-left: var(--s5); margin-right: var(--s5); }
details.history ul { list-style: none; margin-top: var(--s3); margin-bottom: var(--s4); padding: 0; display: grid; gap: 0; border: 1px solid var(--line-soft); border-radius: var(--r-input); overflow: hidden; }
details.history li { display: grid; grid-template-columns: 70px 130px minmax(0, 1fr) auto; align-items: center; gap: var(--s3); font-size: 0.875rem; padding: 10px var(--s4); border-top: 1px solid var(--line-soft); }
details.history li:first-child { border-top: 0; }
details.history li .ver { font-weight: 700; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions form { margin: 0; }

/* ================================================================== results, timelines */
.bad-text { color: var(--bad); font-weight: 600; }
tr.timeline-row td { padding: 0 16px; border-bottom: 0; }
tr.timeline-row td:not(:empty) { padding: 8px 16px 14px; background: var(--surface-soft); }
ol.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: grid; gap: 6px; }
ol.timeline li { position: relative; font-size: 0.875rem; }
ol.timeline li::before { content: ""; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
ol.timeline time { color: var(--ink-faint); margin-right: var(--s2); font-variant-numeric: tabular-nums; }
ol.timeline .ses { color: var(--action-strong); }
.result-split { grid-template-columns: minmax(0, 6fr) minmax(0, 6fr); }

/* ================================================================== configuration */
.creditor-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.creditor-head h3 { margin-right: auto; }
.creditor .section-title { margin-top: var(--s4); }
ul.portfolio-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line-soft); }
ul.portfolio-list li { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
ul.portfolio-list .portfolio-name { margin-right: auto; }
ul.portfolio-list li form { flex: 1 1 100%; }
.creditor-foot { margin-top: var(--s3); }
form.inline-edit { align-items: end; }
form.inline-edit .actions { grid-column: 1 / -1; }
.start-again { display: inline-flex; margin: 0; }
.start-again-row { margin-top: var(--s4); }

/* ================================================================== login, opt-out */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 480px); }
.login-art { background: linear-gradient(160deg, var(--nav) 0%, var(--nav-deep) 100%); color: var(--nav-text); padding: var(--s7); display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; position: relative; }
.login-art h1 { color: #fff; font-size: 2.5rem; max-width: 14ch; font-weight: 750; }
.login-art p { max-width: 42ch; color: #a9bccd; margin-top: var(--s4); font-size: var(--t-lead); }
.login-art .route-art { position: absolute; right: -40px; bottom: 80px; opacity: .9; }
.login-art .note { color: var(--nav-muted); }
.login-form { background: var(--surface); padding: var(--s7) var(--s6); display: flex; flex-direction: column; justify-content: center; }
.login-form h2 { margin-bottom: var(--s5); font-size: 1.5rem; }
.login-form .btn { width: 100%; justify-content: center; margin-top: var(--s5); padding: 12px 16px; }
body.optout { display: grid; place-items: center; min-height: 100vh; padding: var(--s4); }
.optout-card { max-width: 440px; margin: 0; display: grid; gap: var(--s4); }

/* ================================================================== htmx */
.htmx-request.loading-row, .htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ================================================================== responsive */
@media (max-width: 1280px) {
  .panel.editor { grid-template-columns: minmax(0, 1fr); }
  .preview-col { grid-column: 1; padding-left: 0; border-left: 0; border-top: 1px solid var(--line-soft); padding-top: var(--s4); margin-top: var(--s5); }
}
@media (max-width: 1100px) {
  .dash-grid, .campaign-hero { grid-template-columns: minmax(0, 1fr); }
  .campaign-hero .side { border-left: 0; padding-left: 0; border-top: 1px solid var(--line-soft); padding-top: var(--s4); }
  form.filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  form.filter-bar > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
  .split, .grid-2, .result-split { grid-template-columns: minmax(0, 1fr); }
  .tally { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tally a { border-bottom: 1px solid var(--line-soft); }
  details.history li { grid-template-columns: 60px minmax(0, 1fr); }
}
/* narrow screens: the sidebar collapses behind a menu button (CSS-only checkbox toggle) */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; align-content: start; }
  .topbar {
    display: flex; align-items: center; gap: var(--s3); position: sticky; top: 0; z-index: 30;
    background: var(--nav); color: #fff; padding: var(--s2) var(--s4);
  }
  .menu-button { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-input); cursor: pointer; color: #fff; }
  .menu-button:hover { background: rgba(255, 255, 255, .1); }
  .menu-toggle:focus-visible ~ .topbar .menu-button { outline: 3px solid #8cc3ff; outline-offset: 2px; }
  .rail { display: none; position: static; height: auto; padding: var(--s3) var(--s3) var(--s4); }
  .rail > .mark { display: none; }
  .menu-toggle:checked ~ .rail { display: flex; }
  .workspace { padding: var(--s5) var(--s4) var(--s6); }
  .login-page { grid-template-columns: 1fr; }
  .login-art { padding: var(--s6) var(--s4); }
  .login-art .route-art { display: none; }
  .map-row { grid-template-columns: 1fr; }
  .map-row .arrow { display: none; }
  .envelope-head { padding-right: var(--s5); }
  .postmark { display: none; }
  dl.facts { grid-template-columns: 1fr; gap: 2px; }
  dl.facts dd { margin-bottom: var(--s2); }
  form.filter-bar { grid-template-columns: 1fr; }
  .big-progress { grid-template-columns: auto minmax(0, 1fr); }
  .big-progress span { grid-column: 1 / -1; }
  .preview-overlay { padding: var(--s2); }
  h1 { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.code-gutter:empty { display: none; }
[hidden] { display: none !important; }
/* grid children align at the top: the stacking margin only applies inside a single column */
.split > .panel, .dash-grid > .panel, .campaign-hero > .stack, .split > .stack { margin-top: 0; }
/* a column with nothing to show (e.g. no approval, exclusions or uncertain sends) gives its width to the other */
.split > .stack:not(:has(> *)) { display: none; }
.split:has(> .stack:not(:has(> *))) { grid-template-columns: minmax(0, 1fr); }
.rail-foot button.link { color: var(--nav-text); }
.rail-foot button.link:hover { color: #fff; }
label.field + .field-row, .field-row + label.field { margin-top: var(--s4); }

/* campaign detail: recipients beside the rendered email on wide screens, stacked below 960px */
.preview-grid { display: grid; grid-template-columns: minmax(260px, 4fr) minmax(0, 8fr); gap: var(--s5); align-items: start; }
.preview-grid > * { margin-top: 0; min-width: 0; }
@media (max-width: 960px) { .preview-grid { grid-template-columns: minmax(0, 1fr); } }
.stack.section-title:not(:has(> *)) { display: none; }

/* phones: tables marked .stack-sm show one card per row, each cell with its column name (data-label) */
@media (max-width: 700px) {
  table.data.stack-sm, table.data.stack-sm tbody, table.data.stack-sm tr, table.data.stack-sm td { display: block; width: 100%; }
  table.data.stack-sm thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  table.data.stack-sm tr { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line-soft); }
  table.data.stack-sm tbody tr:last-child { border-bottom: 0; }
  table.data.stack-sm tbody tr:hover td { background: none; }
  table.data.stack-sm td {
    display: grid; grid-template-columns: minmax(96px, 35%) minmax(0, 1fr); gap: var(--s3); align-items: baseline;
    padding: 6px 0; border-bottom: 0; text-align: left; overflow-wrap: anywhere;
  }
  table.data.stack-sm td::before {
    content: attr(data-label); grid-column: 1; grid-row: 1 / span 3; color: var(--ink-faint); font-size: var(--t-small); font-weight: 600;
  }
  /* every piece of the cell (name and its sub-line, a badge, the progress) stays in the value column */
  table.data.stack-sm td[data-label] { justify-items: start; row-gap: 2px; }
  table.data.stack-sm td[data-label] > * { grid-column: 2; }
  table.data.stack-sm td:not([data-label]) { display: block; padding-top: var(--s2); }
  table.data.stack-sm td:not([data-label])::before { content: none; }
  table.data.stack-sm td.go { width: auto; text-align: left; }
  table.data.stack-sm td.num { text-align: left; }
  table.data.stack-sm .progress-cell { min-width: 0; justify-self: stretch; }
  .table-wrap:has(> table.stack-sm) { background: #fff; }
}

/* ================================================================== info "i"
   Explanations live behind a small "i": shown on hover, on keyboard focus and on click (touch). The text stays in the
   page for screen readers. Markup: <span class="info"><button type="button" class="info-btn" aria-label="Más
   información"></button><span class="info-text" role="tooltip">…</span></span> */
.info { position: relative; display: inline-flex; vertical-align: middle; margin-left: 6px; line-height: 1; }
.info-btn {
  width: 18px; height: 18px; min-height: 0; padding: 0; border-radius: 50%; border: 1.5px solid var(--ink-faint);
  background: #fff; color: var(--ink-soft); display: inline-grid; place-items: center; cursor: help; flex: none;
}
.info-btn::before { content: "i"; font: italic 700 11px/1 Georgia, "Times New Roman", serif; }
.info-btn:hover, .info.open .info-btn { border-color: var(--action); color: var(--action-strong); background: var(--action-tint); }
.info-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.info-text {
  position: absolute; z-index: 60; top: calc(100% + 8px); left: 50%; transform: translate(-50%, -4px);
  width: max-content; max-width: min(300px, 80vw); padding: 8px 12px; border-radius: 8px;
  background: var(--nav); color: #fff; box-shadow: var(--shadow-2);
  font-size: var(--t-small); font-weight: 450; font-style: normal; line-height: 1.45; text-align: left; white-space: normal;
  text-transform: none; letter-spacing: normal;
  opacity: 0; pointer-events: none; transition: opacity .12s ease, transform .12s ease;
}
.info:hover .info-text, .info:focus-within .info-text, .info.open .info-text { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
/* near a screen edge app.js anchors the bubble to the icon's side instead of centering it */
.info-text.info-start { left: -6px; transform: translate(0, -4px); }
.info-text.info-end { left: auto; right: -6px; transform: translate(0, -4px); }
.info:hover .info-text.info-start, .info:focus-within .info-text.info-start, .info.open .info-text.info-start,
.info:hover .info-text.info-end, .info:focus-within .info-text.info-end, .info.open .info-text.info-end { transform: none; }
.info-text a { color: #9fe0d9; }
.info-text .var, .info-text code { color: #ffd98a; background: rgba(255, 255, 255, .08); }
@media (prefers-reduced-motion: reduce) { .info-text { transition: none; } }

/* Configuración → Dominios: DNS records are long; they wrap instead of widening the page */
table.dns code { overflow-wrap: anywhere; white-space: normal; font-size: 0.8125rem; }
table.dns td:nth-child(3), table.dns td:nth-child(4) { min-width: 220px; }
table.dns td:nth-child(2) code { white-space: nowrap; }
.panel.domain h2 { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
code.dmarc { display: block; margin-top: var(--s2); overflow-wrap: anywhere; }
