/* Prompts panel: "session sheet" visual system. See DESIGN.md.
   Printed ink (blue) = what the system owns; graphite = what the operator typed.
   Lamps (red / amber / green) carry state, always with a word and a shape. */

@font-face {
  font-family: "Barlow Condensed";
  src: url("fonts/barlow-condensed-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("fonts/barlow-condensed-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --desk: #edf0f4;
  --sheet: #ffffff;
  --sheet-2: #f5f7fa;
  --rule: #cfd8e4;
  --rule-strong: #93a5bf;
  --print: #1b4f9c;
  --print-hover: #143d7a;
  --print-soft: #e6eef9;
  --on-print: #ffffff;
  --graphite: #1b1e23;
  --muted: #545e6d;
  --rec: #c62a1f;
  --rec-soft: #fdecea;
  --rec-ink: #a1221a;
  --amber: #b06a00;
  --amber-soft: #fff3d6;
  --amber-ink: #6b4100;
  --green: #1f7a45;
  --green-soft: #e3f3e9;
  --green-ink: #175f37;
  --shadow: 0 1px 2px rgba(20, 33, 54, .06), 0 4px 14px rgba(20, 33, 54, .06);
  --shadow-up: 0 -2px 6px rgba(20, 33, 54, .06), 0 -10px 24px rgba(20, 33, 54, .08);

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-print: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-xs: .8125rem;  /* 13 */
  --fs-sm: .875rem;   /* 14 */
  --fs-md: .9375rem;  /* 15 */
  --fs-lg: 1.0625rem; /* 17 */
  --fs-xl: 1.375rem;  /* 22 */
  --fs-2xl: 1.75rem;  /* 28 */
  --fs-reel: 2.25rem; /* 36 */

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --radius: 4px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --page: 1240px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --desk: #0e1217;
    --sheet: #161b22;
    --sheet-2: #1b2129;
    --rule: #2b3543;
    --rule-strong: #4a5a70;
    --print: #8fb5ee;
    --print-hover: #b2cdf5;
    --print-soft: #1a2940;
    --on-print: #0e1217;
    --graphite: #e7eaef;
    --muted: #9da8b7;
    --rec: #ff6b5d;
    --rec-soft: #3a1714;
    --rec-ink: #ff9d93;
    --amber: #f0b44a;
    --amber-soft: #31260f;
    --amber-ink: #f5ca7a;
    --green: #5fd08d;
    --green-soft: #12301f;
    --green-ink: #8fe0b1;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .25);
    --shadow-up: 0 -2px 8px rgba(0, 0, 0, .35), 0 -12px 28px rgba(0, 0, 0, .3);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--rule-strong) var(--desk); }
body {
  margin: 0;
  font: 400 var(--fs-md)/1.5 var(--font-ui);
  background: var(--desk);
  color: var(--graphite);
  caret-color: var(--print);
  font-variant-numeric: tabular-nums;
}
::selection { background: var(--print); color: var(--on-print); }
a { color: var(--print); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--print-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--print); outline-offset: 2px; border-radius: 2px; }
[tabindex="-1"]:focus { outline: none; }
h1, h2, h3 { text-wrap: balance; }
h1 { font: 600 var(--fs-2xl)/1.15 var(--font-print); letter-spacing: .005em; margin: 0; color: var(--print); }
h2 { font: 600 var(--fs-xl)/1.2 var(--font-print); margin: 0 0 var(--sp-3); color: var(--print); }
h3 { font: 600 var(--fs-lg)/1.25 var(--font-print); margin: var(--sp-5) 0 var(--sp-2); color: var(--print); }
p { margin: 0 0 var(--sp-3); }
ul, ol { margin: 0 0 var(--sp-3); padding-left: 1.25rem; }
li { margin: 2px 0; }
code, .key { font-family: var(--font-mono); font-size: .8em; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: var(--sp-3); top: -60px; z-index: 50; background: var(--print); color: var(--on-print); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius); }
.skip:focus { top: var(--sp-2); }
main { display: block; max-width: var(--page); margin: 0 auto; padding: var(--sp-5) var(--sp-5) var(--sp-7); outline: none; }
main:focus-visible { outline: none; }
.icon { width: 1em; height: 1em; flex: none; vertical-align: -.14em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Console strip ---------- */
.console { background: var(--sheet); border-bottom: 1px solid var(--rule); position: relative; z-index: 5; }
/* Two rows: brand and session on top, the tabs below (they wrap). The admin tabs no
   longer fit beside the brand and the session on one line (since "Idiomas"), and a
   single row let the tabs overflow onto the session label. */
.console-inner { max-width: var(--page); margin: 0 auto; padding: var(--sp-2) var(--sp-5) 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--sp-5); }
.brand { order: 1; display: flex; align-items: center; gap: var(--sp-3); text-decoration: none; color: var(--graphite); flex: none; min-height: 44px; }
.brand:hover { color: var(--graphite); }
.brand-mark { display: inline-flex; align-items: center; gap: 3px; height: 22px; }
.brand-mark span { width: 3px; border-radius: 2px; background: var(--print); }
.brand-mark span:nth-child(1) { height: 8px; }
.brand-mark span:nth-child(2) { height: 20px; }
.brand-mark span:nth-child(3) { height: 13px; }
.brand-mark span:nth-child(4) { height: 6px; background: var(--rec); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font: 600 var(--fs-lg)/1.05 var(--font-print); text-transform: uppercase; letter-spacing: .04em; color: var(--print); }
.brand-org { font-size: var(--fs-xs); color: var(--muted); }
.nav { order: 3; display: flex; flex-wrap: wrap; align-items: stretch; gap: 0 var(--sp-1); flex: 1 1 100%; min-width: 0; margin: 0 calc(-1 * var(--sp-3)); }
.nav a {
  display: flex; align-items: center; padding: 0 var(--sp-3); min-height: 44px; white-space: nowrap;
  font: 600 var(--fs-lg)/1 var(--font-print); letter-spacing: .02em;
  color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.nav a:hover { color: var(--print); }
.nav a[aria-current="page"] { color: var(--print); border-bottom-color: var(--print); }
.nav a[hidden] { display: none; }
.session { order: 2; margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); flex: 0 1 auto; min-width: 0; min-height: 44px; font-size: var(--fs-sm); color: var(--muted); }
.session-user { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.session-logout { flex: none; white-space: nowrap; }
.session-user strong { color: var(--graphite); font-weight: 600; }
.session-logout { font-size: var(--fs-sm); }

/* ---------- Login (T21) ---------- */
.login-page { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; }
.login { width: 100%; max-width: 440px; padding: var(--sp-7) var(--sp-4) var(--sp-7); }
.login-brand { margin: 0 0 var(--sp-5); }
.login-card { padding: var(--sp-6) var(--sp-5); border-top: 3px solid var(--print); }
.login-card h1 { margin-bottom: var(--sp-2); }
.login-card .msg { margin: var(--sp-4) 0; }
.login-google { width: 100%; min-height: 44px; margin: var(--sp-4) 0 var(--sp-5); font-size: var(--fs-lg); }
.login-fallback { border-top: 1px solid var(--rule); padding-top: var(--sp-4); }
.login-fallback summary { cursor: pointer; color: var(--print); font-size: var(--fs-sm); text-decoration: underline; text-underline-offset: 3px; width: fit-content; }
.login-fallback summary:hover { color: var(--print-hover); }
.login-fallback[open] summary { margin-bottom: var(--sp-2); }
.login-fallback form .actions { margin-top: var(--sp-4); }
/* Account pages (T29): QR for the authenticator app, manual key, recovery codes. The QR
   keeps a white sheet in dark mode too, so phone cameras can read it. */
.qr-box { display: flex; justify-content: center; margin: var(--sp-4) 0; }
.qr { width: 208px; height: 208px; background: #ffffff; border: 1px solid var(--rule); border-radius: var(--radius); }
.totp-secret { font-family: var(--font-mono); font-size: var(--fs-sm); word-break: break-all; }
.recovery-codes { columns: 2; column-gap: var(--sp-5); padding-left: var(--sp-5); margin: var(--sp-4) 0; }
.recovery-code { font-family: var(--font-mono); font-size: var(--fs-md); letter-spacing: .04em; }

/* ---------- Lamps (state = shape + word + hue) ---------- */
.pill, .lamp-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 var(--fs-sm)/1.2 var(--font-print); letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap; color: var(--muted);
}
.pill::before, .lamp-tag::before {
  content: ""; width: 9px; height: 9px; flex: none; border-radius: 50%;
  border: 1.5px solid currentColor; background: transparent;
}
/* on: lit and solid */
.pill.on, .lamp-tag.on { color: var(--green-ink); }
.pill.on::before, .lamp-tag.on::before { background: var(--green); border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
/* warn: half-lit ring */
.pill.warn, .lamp-tag.warn { color: var(--amber-ink); }
.pill.warn::before, .lamp-tag.warn::before { border-color: var(--amber); background: linear-gradient(90deg, var(--amber) 50%, transparent 50%); box-shadow: 0 0 0 3px var(--amber-soft); }
/* bad: square red lamp */
.pill.bad, .lamp-tag.bad { color: var(--rec-ink); }
.pill.bad::before, .lamp-tag.bad::before { border-radius: 1px; background: var(--rec); border-color: var(--rec); box-shadow: 0 0 0 3px var(--rec-soft); }
/* off: hollow, dashed */
.pill.off::before, .lamp-tag.off::before { border-style: dashed; }
.lamp-tag[hidden] { display: none; }
.lamp-tag { padding: 4px 8px; border: 1px solid var(--rule); border-radius: 999px; background: var(--sheet); }
.lamp-tag.warn { border-color: color-mix(in srgb, var(--amber) 45%, var(--rule)); background: var(--amber-soft); }
.lamp-tag.on { border-color: color-mix(in srgb, var(--green) 40%, var(--rule)); }

.badge {
  display: inline-flex; align-items: center; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  font: 600 var(--fs-xs)/1.4 var(--font-print); letter-spacing: .04em; text-transform: uppercase;
  background: var(--amber-soft); color: var(--amber-ink); border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent);
  vertical-align: 2px; white-space: nowrap;
}
/* Voice engine (E1): neutral tag, not a warning. */
.badge.engine { background: var(--print-soft); color: var(--print); border-color: color-mix(in srgb, var(--print) 30%, transparent); }

/* ---------- State bands (one message, one action) ---------- */
.bands:empty { display: none; }
.banner { border-bottom: 1px solid var(--rule); font-size: var(--fs-sm); }
.banner-inner { max-width: var(--page); margin: 0 auto; padding: var(--sp-2) var(--sp-5); display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; min-height: 44px; }
.banner .lamp-tag { background: transparent; border: 0; padding: 0; }
.banner-text { flex: 1 1 320px; }
.banner-text strong { font-weight: 600; }
.banner.info { background: var(--print-soft); color: var(--graphite); }
.banner.warn { background: var(--amber-soft); color: var(--amber-ink); }
.banner.warn .banner-text strong { color: var(--amber-ink); }
.banner a { color: inherit; font-weight: 600; }
.banner button { padding: 5px 12px; }

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin: 0 0 var(--sp-4); }
.page-head .lede { margin: var(--sp-2) 0 0; color: var(--muted); max-width: 72ch; }
.page-head .tools { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 var(--sp-3); font-size: var(--fs-sm); }
.back a { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.back a:hover { text-decoration: underline; }

/* ---------- Sheets (the ruled paper) ---------- */
.card {
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: var(--sp-5); margin-bottom: var(--sp-4); box-shadow: var(--shadow);
}
.card > h2:first-child { margin-top: 0; }
.card h3:first-child { margin-top: 0; }
.card.preview { border-color: var(--print); box-shadow: 0 0 0 3px var(--print-soft), var(--shadow); }
.card .card { box-shadow: none; }

/* ---------- Tables: the ruled grid ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--sheet); font-size: var(--fs-md); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; overflow-wrap: anywhere; }
thead th {
  font: 600 var(--fs-sm)/1.2 var(--font-print); text-transform: uppercase; letter-spacing: .06em; color: var(--print);
  border-bottom: 1.5px solid var(--print); padding-top: 10px; padding-bottom: 8px; white-space: nowrap; background: var(--sheet);
}
tbody th { font-weight: 600; color: var(--print); font: 600 var(--fs-md)/1.4 var(--font-print); letter-spacing: .02em; width: 34%; }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:hover > td { background: var(--sheet-2); }
table.sheet { border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); border-collapse: separate; border-spacing: 0; overflow: hidden; }
.card table { border: 0; box-shadow: none; }
td .hint { margin-top: 2px; }
.reel { font: 600 var(--fs-lg)/1.2 var(--font-print); letter-spacing: .03em; white-space: nowrap; }
a.reel { text-decoration: none; }
a.reel:hover { text-decoration: underline; }
tr.is-off td { color: var(--muted); }
tr.is-off .reel { text-decoration: line-through; text-decoration-thickness: 1px; }
.empty-row td { text-align: center; color: var(--muted); padding: var(--sp-5); }

/* ---------- Text and hints ---------- */
.hint { font-weight: 400; font-size: var(--fs-sm); color: var(--muted); line-height: 1.45; }
.hint.default { font-style: italic; }
.hint.warning { color: var(--amber-ink); background: var(--amber-soft); padding: 3px 8px; border-radius: var(--radius); display: inline-block; }
.hint.bad { color: var(--rec-ink); background: var(--rec-soft); padding: 3px 8px; border-radius: var(--radius); display: inline-block; }
div.hint.warning, div.hint.bad { display: block; margin-top: var(--sp-2); }
.hint:empty { display: none; }

/* Messages (role=status / alert). A lamp plus tint; no thick side rules. */
.msg { margin: 0 0 var(--sp-3); padding: 10px 14px 10px 34px; border-radius: var(--radius); position: relative; border: 1px solid transparent; }
.msg::before { content: ""; position: absolute; left: 13px; top: 16px; width: 9px; height: 9px; border-radius: 50%; }
.msg.error { background: var(--rec-soft); color: var(--rec-ink); border-color: color-mix(in srgb, var(--rec) 30%, transparent); }
.msg.error::before { background: var(--rec); border-radius: 1px; }
.msg.ok { background: var(--green-soft); color: var(--green-ink); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.msg.ok::before { background: var(--green); }
.msg.warn { background: var(--amber-soft); color: var(--amber-ink); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.msg.warn::before { background: linear-gradient(90deg, var(--amber) 50%, transparent 50%); border: 1.5px solid var(--amber); }
.msg .hint { color: inherit; opacity: .9; }
.msg ul { margin: var(--sp-2) 0; }
.msg .actions { margin-top: var(--sp-3); }

/* ---------- Form controls ---------- */
label { display: block; font-weight: 600; margin: var(--sp-4) 0 var(--sp-1); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--rule-strong); border-radius: var(--radius);
  font: inherit; color: var(--graphite); background: var(--sheet);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--print); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--print); box-shadow: 0 0 0 3px var(--print-soft); }
input:disabled, select:disabled, textarea:disabled { background: var(--sheet-2); color: var(--muted); cursor: not-allowed; }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--print); }
input[type=checkbox] { width: 16px; height: 16px; }
input[type=file] { font: inherit; font-size: var(--fs-sm); max-width: 100%; }
select { appearance: auto; }
textarea {
  min-height: 7rem; resize: vertical; line-height: 1.6;
  font: 400 var(--fs-md)/1.6 var(--font-ui);
  field-sizing: content; max-height: 70vh;
}
textarea.big { min-height: 22rem; font-size: 1rem; line-height: 1.65; padding: 14px 16px; }
input.num { width: 120px; flex: none; }
input.secret-value { font-family: var(--font-mono); }
.hint.counter { display: block; margin-top: 4px; text-align: right; font-size: var(--fs-xs); }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
  padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--rule-strong);
  background: var(--sheet); color: var(--graphite); font: 500 var(--fs-md)/1.2 var(--font-ui);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
button:hover:not(:disabled), .button:hover { border-color: var(--print); color: var(--print); background: var(--print-soft); text-decoration: none; }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary, .button.primary { background: var(--print); border-color: var(--print); color: var(--on-print); font-weight: 600; }
button.primary:hover:not(:disabled), .button.primary:hover { background: var(--print-hover); border-color: var(--print-hover); color: var(--on-print); }
button.danger { color: var(--rec-ink); border-color: color-mix(in srgb, var(--rec) 55%, var(--rule)); }
button.danger:hover:not(:disabled) { background: var(--rec-soft); border-color: var(--rec); color: var(--rec-ink); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.link { border: 0; background: none; padding: 4px 0; min-height: 0; color: var(--print); text-decoration: underline; text-underline-offset: 3px; font-weight: 400; }
button.link:hover:not(:disabled) { background: none; color: var(--print-hover); }
button[aria-busy="true"] { cursor: progress; }

.actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-top: var(--sp-4); }
.inline { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin-top: var(--sp-1); }
.inline input[type=text], .inline input[type=password], .inline select { flex: 1 1 240px; width: auto; }
.inline label { margin: 0; }
.row { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.row > div { flex: 1 1 260px; min-width: 0; }
.row > div.right { flex: 0 0 auto; text-align: right; }

.slider { display: flex; gap: var(--sp-3); align-items: center; margin: 6px 0 2px; }
.slider input[type=range] { flex: 1 1 auto; min-width: 0; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: var(--sp-2) 0; cursor: pointer; }
label.check input { margin-top: 3px; flex: none; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 var(--sp-4); max-height: 280px; overflow: auto; border: 1px solid var(--rule); border-radius: var(--radius); padding: 2px var(--sp-3); background: var(--sheet-2); }

/* ---------- Fields (a channel on the sheet) ---------- */
.field { position: relative; padding: var(--sp-4) 0 var(--sp-4) 22px; border-bottom: 1px solid var(--rule); }
.field:last-child { border-bottom: 0; }
.field::before {
  content: ""; position: absolute; left: 2px; top: calc(var(--sp-4) + 8px); width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px dashed var(--rule-strong); transition: background-color .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.field.is-armed::before { background: var(--rec); border: 1.5px solid var(--rec); box-shadow: 0 0 0 3px var(--rec-soft); }
.field > label:first-child { margin-top: 0; font: 600 var(--fs-lg)/1.25 var(--font-print); letter-spacing: .01em; color: var(--print); }
.field > label:first-child .hint { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0; margin-left: 4px; }
.field > .hint { max-width: 80ch; }
.field textarea, .field select, .field .slider, .field .inline, .field > div > table { margin-top: var(--sp-2); }
.field .armed-note { display: none; }
.field.is-armed .armed-note { display: inline-flex; }

/* Sections: collapsible groups on the sheet */
details.section { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); margin-bottom: var(--sp-3); box-shadow: var(--shadow); padding: 0; }
details.section > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5); min-height: 52px;
  font: 600 var(--fs-xl)/1.2 var(--font-print); color: var(--print);
}
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::before {
  content: ""; width: 8px; height: 8px; flex: none; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .2s var(--ease); margin-right: 2px;
}
details.section[open] > summary::before { transform: rotate(45deg); }
details.section > summary:hover { background: var(--sheet-2); }
details.section > summary .armed-count { margin-left: auto; }
details.section[open] > summary { border-bottom: 1px solid var(--rule); }
details.section > :not(summary) { margin-left: var(--sp-5); margin-right: var(--sp-5); }
details.section > :last-child { margin-bottom: var(--sp-4); }
details.section > p.hint:first-of-type, details.section > .msg:first-of-type { margin-top: var(--sp-4); }
details.section.advanced > summary { color: var(--amber-ink); }
details.draft { margin: var(--sp-3) 0; padding: var(--sp-3) var(--sp-4); border: 1px dashed var(--amber); border-radius: var(--radius); background: var(--amber-soft); }
details.draft > summary { cursor: pointer; font-weight: 600; color: var(--amber-ink); }
details:not(.section):not(.draft) > summary { cursor: pointer; color: var(--print); font-weight: 600; margin: var(--sp-3) 0 var(--sp-2); }

/* ---------- Before / after ---------- */
pre.value {
  white-space: pre-wrap; word-break: break-word; font: 400 var(--fs-sm)/1.55 var(--font-ui);
  background: var(--sheet-2); padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--rule);
  margin: 4px 0 var(--sp-2); max-height: 260px; overflow: auto;
}
pre.value.big { max-height: 480px; }
pre.value.diff-before { background: var(--rec-soft); border-color: color-mix(in srgb, var(--rec) 30%, transparent); }
pre.value.diff-after { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.change { padding: var(--sp-3) 0; border-bottom: 1px solid var(--rule); }
.change:last-child { border-bottom: 0; }
.change > strong, .diff-title { display: block; font: 600 var(--fs-lg)/1.25 var(--font-print); color: var(--print); margin-bottom: var(--sp-2); }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.diff > div { min-width: 0; }
.diff .hint { font: 600 var(--fs-xs)/1.2 var(--font-print); letter-spacing: .08em; text-transform: uppercase; }

/* ---------- Tenant detail ---------- */
.label-block {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, .8fr) minmax(0, 1fr);
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: var(--sp-4);
}
.label-block > div { padding: var(--sp-3) var(--sp-4); border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); min-width: 0; }
.label-block > div:nth-child(4n) { border-right: 0; }
.label-block > div.wide { grid-column: 1 / -1; border-right: 0; border-bottom: 0; display: flex; gap: var(--sp-2) var(--sp-4); align-items: baseline; flex-wrap: wrap; }
.label-block .cap { display: block; font: 600 var(--fs-xs)/1.2 var(--font-print); letter-spacing: .08em; text-transform: uppercase; color: var(--print); margin-bottom: 4px; }
.label-block .reel-big { font: 600 var(--fs-reel)/1 var(--font-print); letter-spacing: .02em; color: var(--graphite); overflow-wrap: anywhere; }
.label-block .title { grid-row: span 1; }
.label-block .title { display: flex; align-items: center; }
.label-block .title h1 { color: var(--graphite); font: 600 var(--fs-xl)/1.25 var(--font-ui); letter-spacing: -.01em; margin: 0; }
.label-block .val { overflow-wrap: anywhere; }

.tenant-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--sp-5); align-items: start; }
.toc { position: sticky; top: var(--sp-4); display: flex; flex-direction: column; gap: 2px; padding-top: var(--sp-1); }
.toc .cap { font: 600 var(--fs-xs)/1.2 var(--font-print); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 var(--sp-2) 10px; }
.toc button {
  justify-content: flex-start; gap: var(--sp-2); width: 100%; border: 0; background: none; min-height: 32px; padding: 4px 10px;
  font: 600 var(--fs-lg)/1.15 var(--font-print); color: var(--muted); text-align: left; white-space: normal; border-radius: var(--radius);
}
.toc button:hover:not(:disabled) { color: var(--print); background: var(--print-soft); }
.toc button .dot { width: 7px; height: 7px; border-radius: 50%; border: 1.5px dashed var(--rule-strong); flex: none; }
.toc button.has-armed .dot { background: var(--rec); border: 1.5px solid var(--rec); }
.sheet-name { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--sp-1) var(--sp-5); margin-bottom: var(--sp-3); }
.sheet-name .field { border: 0; }
.notice-hint { margin: 0 0 var(--sp-3); }

/* Transport bar: counts armed fields and holds the save action */
.transport {
  position: sticky; bottom: 0; z-index: 4; margin: var(--sp-4) 0 var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-up);
  padding: var(--sp-3) var(--sp-4);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.transport .count { flex: 1 1 200px; display: flex; align-items: center; gap: var(--sp-2); font: 600 var(--fs-lg)/1.2 var(--font-print); color: var(--muted); }
.transport .count::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 1.5px dashed var(--rule-strong); flex: none; }
.transport.is-armed { border-color: color-mix(in srgb, var(--rec) 50%, var(--rule)); }
.transport.is-armed .count { color: var(--rec-ink); }
.transport.is-armed .count::before { background: var(--rec); border: 1.5px solid var(--rec); box-shadow: 0 0 0 3px var(--rec-soft); animation: lamp-on .25s var(--ease); }
@keyframes lamp-on { from { box-shadow: 0 0 0 9px transparent; transform: scale(.6); } to { box-shadow: 0 0 0 3px var(--rec-soft); transform: scale(1); } }

.danger-zone { border-color: color-mix(in srgb, var(--rec) 35%, var(--rule)); }
.danger-zone h2 { color: var(--rec-ink); }
.danger-list { display: grid; gap: 0; }
.danger-list > div { display: grid; grid-template-columns: 240px 1fr; gap: var(--sp-4); align-items: center; padding: var(--sp-3) 0; border-bottom: 1px solid var(--rule); }
.danger-list > div:last-child { border-bottom: 0; }
.danger-list button { justify-self: start; }

.transport .bar-msg { flex-basis: 100%; order: -1; }
.transport .bar-msg:empty { display: none; }
.transport .bar-msg .msg { margin: 0; }
.field .badge.armed-note { background: var(--rec-soft); color: var(--rec-ink); border-color: color-mix(in srgb, var(--rec) 35%, transparent); }
.group-label { font-weight: 600; margin: var(--sp-4) 0 var(--sp-1); }
.label-block .links { margin-left: auto; align-self: center; }
.label-block code.val { font-size: var(--fs-sm); }
table.kv tbody th { white-space: normal; }

/* ---------- Onboarding steps ---------- */
.step { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 0 var(--sp-4); }
.step > .step-no {
  grid-row: 1 / span 20; font: 600 2.5rem/1 var(--font-print); color: var(--print); opacity: .9;
  border-right: 1px solid var(--rule); padding-right: var(--sp-3); text-align: right;
}
.step > :not(.step-no) { grid-column: 2; }
.step > h2 { margin-top: 4px; }

/* ---------- Lines and status ---------- */
.line-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.line-head h2 { margin: 0; display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.line-head .pill { font-size: var(--fs-md); }
.status-text { margin-bottom: var(--sp-3); }
.toolbar { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; margin: 0 0 var(--sp-4); }

/* ---------- Transcript: read like a script ---------- */
.turn { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--sp-3); padding: 10px 0; border-bottom: 1px solid var(--rule); }
.turn:last-child { border-bottom: 0; }
.turn > .hint { font: 600 var(--fs-sm)/1.3 var(--font-print); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.turn.agent > .hint { color: var(--print); }
.turn .text { white-space: pre-wrap; word-break: break-word; max-width: 75ch; }
.gdpr { display: flex; gap: var(--sp-3); align-items: flex-start; }
.gdpr .icon { width: 18px; height: 18px; margin-top: 2px; }

/* Filter */
.filter { position: relative; flex: 1 1 260px; max-width: 340px; }
.filter .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filter input { padding-left: 32px; }

.pager { justify-content: space-between; }
.transfers input[type=text] { width: 100%; }
.transfers td { vertical-align: top; }
.transfers label.check { margin: 6px 0; white-space: nowrap; }
.loading { padding: var(--sp-6) 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .tenant-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; flex-direction: row; flex-wrap: wrap; gap: var(--sp-1); }
  .toc .cap { display: none; }
  .toc button { width: auto; border: 1px solid var(--rule); background: var(--sheet); font-size: var(--fs-md); min-height: 32px; }
}
@media (max-width: 900px) {
  .console-inner { gap: 0 var(--sp-4); padding: var(--sp-2) var(--sp-4) 0; }
  .nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--sp-4)); padding: 0 var(--sp-2); }
  .label-block { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .label-block > div:nth-child(4n) { border-right: 1px solid var(--rule); }
  .label-block > div:nth-child(2n) { border-right: 0; }
}
@media (max-width: 720px) {
  main { padding: var(--sp-4) var(--sp-4) var(--sp-6); }
  .banner-inner { padding: var(--sp-2) var(--sp-4); }
  .card { padding: var(--sp-4); }
  details.section > summary { padding: var(--sp-3) var(--sp-4); }
  details.section > :not(summary) { margin-left: var(--sp-4); margin-right: var(--sp-4); }
  .sheet-name { padding: var(--sp-1) var(--sp-4); }
  .session-user .role { display: none; }
  .diff { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .danger-list > div { grid-template-columns: minmax(0, 1fr); gap: var(--sp-2); }
  .turn { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .step { grid-template-columns: minmax(0, 1fr); }
  .step > .step-no { grid-row: auto; border-right: 0; text-align: left; font-size: 2rem; padding: 0; }
  .step > :not(.step-no) { grid-column: 1; }
  .page-head .tools, .filter { max-width: none; width: 100%; }
  .row > div.right { text-align: left; }
  tbody th { width: 40%; }
  .label-block { grid-template-columns: minmax(0, 1fr); }
  .label-block > div { border-right: 0 !important; }
  .field { padding-left: 18px; }

  /* Ruled tables become stacked records */
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack tr { padding: var(--sp-2) 0; border-bottom: 1px solid var(--rule); }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 4px var(--sp-3) 4px calc(38% + var(--sp-3)); position: relative; min-height: 28px; }
  table.stack td::before { content: attr(data-label); position: absolute; left: var(--sp-3); top: 6px; width: calc(38% - var(--sp-3)); font: 600 var(--fs-xs)/1.4 var(--font-print); letter-spacing: .06em; text-transform: uppercase; color: var(--print); }
  table.stack td[data-label=""] { padding-left: var(--sp-3); }
  table.stack td[data-label=""]::before { display: none; }
  table.stack td[colspan] { display: block; }
  table.stack td[colspan]::before { display: none; }
  table.stack tbody tr:hover > td { background: none; }
  .card table.stack td { padding-right: 0; }
  .card table.stack td::before { left: 0; }
  .card table.stack td[data-label=""] { padding-left: 0; }
}

/* ---------- "Probar prompt" (T26) and "Mejorar prompt" (T28) ---------- */
.improve-btn { margin-top: var(--sp-2); }
.prompt-test .chat-options { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-5); align-items: center; margin-top: var(--sp-3); }
.prompt-test fieldset { border: 0; padding: 0; margin: 0; display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.prompt-test legend { float: left; margin-right: var(--sp-2); font: 600 var(--fs-sm)/1.2 var(--font-print); letter-spacing: .06em; text-transform: uppercase; color: var(--print); }
.prompt-test label.inline { display: inline-flex; gap: 6px; align-items: center; color: var(--graphite); }
.chat-log { list-style: none; margin: var(--sp-4) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); max-height: 60vh; overflow-y: auto; }
.chat-log:empty { display: none; }
.chat-turn { max-width: 80ch; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); color: var(--graphite); white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-turn .who { display: block; font: 600 var(--fs-xs)/1.3 var(--font-print); letter-spacing: .08em; text-transform: uppercase; color: var(--print); margin-bottom: 2px; }
.chat-turn.model { background: var(--sheet-2); }
.chat-turn.user { align-self: flex-end; border-color: var(--rule-strong); }
.chat-turn.call { background: var(--print-soft); border-color: color-mix(in srgb, var(--print) 35%, transparent); color: var(--print); }
.chat-turn.note { border-style: dashed; color: var(--muted); font-size: var(--fs-sm); }
.chat-meta { margin-top: var(--sp-2); }
.chat-input { margin-top: var(--sp-4); }
.chat-input textarea { width: 100%; min-height: 3.2rem; }
dialog.improve-dialog { width: min(1080px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; padding: var(--sp-5); border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--sheet); color: var(--graphite); box-shadow: 0 0 0 3px var(--print-soft), var(--shadow); }
dialog.improve-dialog::backdrop { background: rgba(14, 18, 23, .55); }
dialog.improve-dialog h2 { margin-top: 0; }
dialog.improve-dialog h3 { font: 600 var(--fs-lg)/1.25 var(--font-print); color: var(--print); margin: var(--sp-4) 0 var(--sp-2); }
dialog.improve-dialog textarea { width: 100%; }
.change-list { margin: 0 0 var(--sp-3); padding-left: 1.2em; }
@media (max-width: 720px) {
  dialog.improve-dialog { padding: var(--sp-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; }
}

@media print {
  .console, .bands, .transport, .toc { display: none; }
  body { background: #fff; }
}

/* ---------- Client area (T29): "Tu asistente telefónico" ---------- */
/* Section tabs under the label block: printed-ink underline like the console nav. */
.tabs { display: flex; flex-wrap: wrap; gap: 0 var(--sp-5); border-bottom: 1px solid var(--rule); margin: var(--sp-4) 0 var(--sp-5); }
.tabs a { display: inline-block; padding: var(--sp-2) 0; font: 600 var(--fs-lg)/1.2 var(--font-print); color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--print); }
.tabs a[aria-current="page"] { color: var(--print); border-bottom-color: var(--print); }
.client-section > .lede { margin: 0 0 var(--sp-4); max-width: 70ch; }
.client-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-4); }
.client-card { display: flex; flex-direction: column; gap: var(--sp-1); text-decoration: none; color: var(--graphite); }
.client-card:hover { border-color: var(--print); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-4); }
.stat-row .stat { margin: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--sp-4); align-items: start; }
.stats-table meter { width: 120px; height: 10px; vertical-align: middle; }
.gdpr-card .msg { margin: var(--sp-3) 0; }

/* ElevenLabs agent editor (E2) */
.el-group { margin-top: var(--sp-3); border-top: 1px solid var(--rule); padding-top: var(--sp-2); }
.el-group > summary { cursor: pointer; font: 600 var(--fs-lg)/1.3 var(--font-print); color: var(--print); }
.el-field input[type=number] { max-width: 12ch; }
.el-rows { display: grid; gap: var(--sp-3); margin-top: var(--sp-2); }
.el-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-2); align-items: end; padding: var(--sp-2); border: 1px solid var(--rule); border-radius: 6px; }
.el-cell { display: grid; gap: 4px; margin: 0; }
.el-cell textarea { min-height: 4em; }
.el-voices { margin-top: var(--sp-2); }
.el-voice-list { list-style: none; padding: 0; margin: var(--sp-2) 0 0; display: grid; gap: 6px; max-height: 320px; overflow: auto; }
.el-bind { margin-top: var(--sp-4); }
/* Knowledge base (E4) */
.kb-table { width: 100%; }
.kb-table select { max-width: 100%; }
.kb-rag { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.kb-preview { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto; margin: var(--sp-2) 0; padding: var(--sp-3); border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); font-size: var(--fs-sm); }
.el-bind > summary { cursor: pointer; color: var(--graphite); }

/* ---------- Switches and languages (E3b) ---------- */
/* role="switch" button: printed-ink track when on, a word beside it (never colour alone). */
.switch { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 32px; padding: 2px 4px; margin: 0; background: transparent; border: 0; border-radius: var(--radius); color: var(--graphite); font: inherit; cursor: pointer; }
button.switch:hover:not(:disabled) { background: transparent; border: 0; color: var(--print); }
.switch-track { position: relative; flex: none; width: 36px; height: 20px; border-radius: 999px; border: 1px solid var(--rule-strong); background: var(--desk); transition: background .15s var(--ease), border-color .15s var(--ease); }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--sheet); border: 1px solid var(--rule-strong); transition: transform .15s var(--ease); }
.switch[aria-checked="true"] .switch-track { background: var(--print); border-color: var(--print); }
.switch[aria-checked="true"] .switch-track::after { transform: translateX(16px); border-color: var(--print); }
.switch-state { font-size: var(--fs-sm); color: var(--muted); min-width: 6.5em; text-align: left; }
.switch:disabled { cursor: not-allowed; color: var(--muted); }
.switch:disabled .switch-track { opacity: .5; }
@media (prefers-reduced-motion: reduce) { .switch-track, .switch-track::after { transition: none; } }
.lang-count { font-size: var(--fs-sm); color: var(--muted); }
.lang-table th[scope="row"] { font-weight: 400; text-align: left; }
.lang-name { color: var(--graphite); font-weight: 600; }
.lang-rows { display: grid; gap: var(--sp-2); margin-top: var(--sp-2); }
.lang-row { padding: var(--sp-2) var(--sp-3); border: 1px solid var(--rule); border-radius: var(--radius); }
.lang-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.lang-head .switch { margin-left: auto; }
.lang-note { margin: var(--sp-1) 0 0; }
.lang-details { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-2); margin-top: var(--sp-2); }
.lang-details[hidden], .lang-note[hidden] { display: none; }
