/* Vera. Mundo: papel y tinta. Una sola tinta de acento (verde inglés) para la acción;
   ámbar solo para lo que espera tu decisión; rojo solo para bloqueo y denegación. */

@font-face { font-family: "Public Sans"; src: url("../fonts/public-sans-latin.woff2") format("woff2"); font-weight: 100 900; 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+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Public Sans"; src: url("../fonts/public-sans-latin-ext.woff2") format("woff2"); font-weight: 100 900; font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Code Pro"; src: url("../fonts/source-code-pro-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Source Code Pro"; src: url("../fonts/source-code-pro-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #f5f4f0; --surface: #ffffff; --surface-2: #efede7; --sunken: #e9e6df;
  --line: #e0ddd5; --line-strong: #cbc7bd;
  --ink: #17181b; --ink-2: #4b4f57; --ink-3: #676b73;
  --accent: #1d5a4e; --accent-hover: #164a40; --on-accent: #ffffff; --accent-soft: #e1ece8;
  --warn: #8a5300; --warn-bg: #fbefd9; --warn-line: #ecd2a2;
  --danger: #ad2a20; --danger-bg: #fbe8e5; --danger-line: #f0c4be;
  --ok: #1f6a3b; --ok-bg: #e2f0e6;
  --shadow: 0 1px 2px rgb(23 24 27 / 0.05), 0 6px 20px -8px rgb(23 24 27 / 0.12);
  --shadow-high: 0 2px 4px rgb(23 24 27 / 0.06), 0 18px 40px -12px rgb(23 24 27 / 0.22);
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  --r-s: 8px; --r-m: 12px; --r-l: 18px;
  --sans: "Public Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "Source Code Pro", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sidebar-w: 248px;
}

/* Tema oscuro: mismas proporciones, tinta clara sobre carbón cálido. `data-theme` lo resuelve app.js
   (preferencia guardada o la del sistema) antes de pintar. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111214; --surface: #18191c; --surface-2: #202226; --sunken: #0c0d0e;
  --line: #2b2e33; --line-strong: #3b3f45;
  --ink: #ecebe6; --ink-2: #b0b3b9; --ink-3: #8f939a;
  --accent: #79c2ad; --accent-hover: #93d1bf; --on-accent: #0b1d18; --accent-soft: #1a2c27;
  --warn: #e9b45f; --warn-bg: #2a2113; --warn-line: #4a3a1d;
  --danger: #f28b81; --danger-bg: #2d1916; --danger-line: #57302b;
  --ok: #7fcf98; --ok-bg: #15271b;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px -10px rgb(0 0 0 / 0.6);
  --shadow-high: 0 2px 6px rgb(0 0 0 / 0.35), 0 20px 44px -12px rgb(0 0 0 / 0.7);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 400 15px/1.5 var(--sans); font-feature-settings: "kern";
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-s); }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 17px; line-height: 1.3; }
h3 { font-size: 15px; }
p { margin: 0; text-wrap: pretty; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono, code, .num { font-family: var(--mono); font-size: 0.92em; }
.num { font-variant-numeric: tabular-nums; }
.ink-2 { color: var(--ink-2); }
.ink-3 { color: var(--ink-3); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.icon { width: 18px; height: 18px; flex: none; stroke-width: 1.75; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 22px; height: 22px; }

.skip-link { position: fixed; left: 12px; top: -48px; z-index: 50; background: var(--accent); color: var(--on-accent);
  padding: 8px 14px; border-radius: var(--r-s); transition: top .2s var(--ease); }
.skip-link:focus { top: 12px; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: var(--r-s); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, color .15s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger-line); background: var(--surface); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon-only { width: 40px; padding: 0; }
.btn.large { min-height: 48px; font-size: 16px; padding: 0 22px; }
.btn.wide { width: 100%; }
.btn .spin { animation: spin-kf .9s linear infinite; }
@keyframes spin-kf { to { transform: rotate(360deg); } }

/* ---------- Estructura ---------- */
.app { min-height: 100dvh; display: grid; grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.main { min-width: 0; padding: 20px 16px 96px; }
.main:focus { outline: none; }
.content { max-width: 760px; margin: 0 auto; }
.content.wide { max-width: 1040px; }

.sidebar { display: none; }
.tabbar { position: fixed; inset: auto 0 0 0; z-index: 20; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0;
  border-radius: var(--r-s); color: var(--ink-3); text-decoration: none; font-size: 11.5px; font-weight: 500; }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar .badge { position: absolute; top: 2px; left: calc(50% + 6px); }

.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--warn); color: var(--surface); font: 600 11px/1 var(--sans); font-variant-numeric: tabular-nums; }

@media (min-width: 960px) {
  .app { grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: auto 1fr; }
  .sidebar { display: flex; flex-direction: column; grid-row: 1 / -1; position: sticky; top: 0; height: 100dvh;
    padding: 18px 14px; border-right: 1px solid var(--line); background: var(--surface); }
  .sidebar .brand { padding: 4px 10px 22px; }
  .sidebar nav { display: grid; gap: 2px; }
  .sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r-s);
    color: var(--ink-2); text-decoration: none; font-weight: 500; }
  .sidebar nav a:hover { background: var(--surface-2); color: var(--ink); }
  .sidebar nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
  .sidebar nav a .badge { margin-left: auto; }
  .sidebar .sidebar-footer { margin-top: auto; display: grid; gap: 10px; padding: 12px 10px 0; border-top: 1px solid var(--line); }
  .person { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .person .info { min-width: 0; }
  .person .info strong, .person .info span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .person .info span { font-size: 12.5px; color: var(--ink-3); }
  .tabbar { display: none; }
  .topbar { padding: 0 28px; height: 64px; }
  .main { padding: 28px 28px 48px; }
  .topbar .brand { display: none; }
}

.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px; }

/* Insignia «Demo» y su menú */
.demo { position: relative; }
.demo > button { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 9px; border-radius: 14px;
  border: 1px dashed var(--line-strong); background: transparent; color: var(--ink-2); font-size: 12.5px; font-weight: 600;
  letter-spacing: .02em; cursor: pointer; }
.demo > button::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.demo > button:hover { color: var(--ink); border-color: var(--ink-3); }
.menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 280px; padding: 8px; border-radius: var(--r-m);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-high);
  transform-origin: top right; animation: pop .18s var(--ease); }
.menu[hidden] { display: none; }
.menu p { padding: 8px 10px 10px; font-size: 13px; color: var(--ink-2); }
.menu .menu-group { padding: 6px 10px 4px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.menu [role="menuitemradio"], .menu a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0;
  border-radius: 6px; background: none; text-align: left; cursor: pointer; color: var(--ink); text-decoration: none; font-size: 14px; }
.menu [role="menuitemradio"]:hover, .menu a:hover, .menu [role="menuitemradio"]:focus-visible { background: var(--surface-2); box-shadow: none; }
.menu [role="menuitemradio"] .radio-mark { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-strong); flex: none; }
.menu [aria-checked="true"] .radio-mark { border: 5px solid var(--accent); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(-4px); } }

/* ---------- Estados ---------- */
.skeleton { display: grid; gap: 12px; }
.skeleton i { display: block; height: 14px; border-radius: 7px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--sunken) 50%, var(--surface-2) 100%) 0 0 / 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite; }
.skeleton i.tall { height: 64px; border-radius: var(--r-m); }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty, .failure { display: grid; justify-items: center; gap: 10px; padding: 48px 16px; text-align: center; }
.empty > .icon, .failure > .icon { width: 28px; height: 28px; color: var(--ink-3); margin-bottom: 4px; }
.empty p, .failure p { max-width: 42ch; color: var(--ink-2); }
.failure > .icon { color: var(--danger); }
.failure .btn { margin-top: 6px; }

/* ---------- Avisos efímeros ---------- */
.toasts { position: fixed; z-index: 40; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); translate: -50% 0;
  display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
@media (min-width: 960px) { .toasts { bottom: 28px; left: calc(50% + var(--sidebar-w) / 2); } }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-m);
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-high); font-size: 14px; pointer-events: auto;
  animation: rise .3s var(--ease); }
.toast.error { background: var(--danger); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Entrada ---------- */
.login { min-height: 100dvh; display: grid; grid-template-rows: 1fr auto; padding: 24px; }
.login .login-card { align-self: center; justify-self: center; width: min(400px, 100%); display: grid; gap: 28px; }
.login .brand svg { width: 40px; height: 40px; }
.login h1 { font-size: 30px; line-height: 1.15; letter-spacing: -0.03em; font-weight: 600; }
.login .lead { font-size: 16px; color: var(--ink-2); line-height: 1.55; }
.login ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; color: var(--ink-2); font-size: 14px; }
.login li { display: flex; gap: 10px; align-items: flex-start; }
.login li .icon { color: var(--accent); margin-top: 2px; }
.btn-microsoft { gap: 12px; }
.btn-microsoft svg { width: 18px; height: 18px; }
.login .footer { justify-self: center; text-align: center; font-size: 12.5px; color: var(--ink-3); display: grid; gap: 4px; }
.error-box { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-m); background: var(--danger-bg);
  border: 1px solid var(--danger-line); color: var(--danger); font-size: 14px; }
.error-box .icon { margin-top: 1px; }

/* ---------- Chat ---------- */
.chat { display: grid; grid-template-rows: 1fr auto; min-height: calc(100dvh - 56px - 20px - 96px); }
@media (min-width: 960px) { .chat { min-height: calc(100dvh - 64px - 76px); } }
.thread { display: grid; align-content: start; gap: 18px; padding-bottom: 24px; }
.day-divider { justify-self: center; font-size: 12px; font-weight: 500; color: var(--ink-3); padding: 2px 10px;
  border-radius: 10px; background: var(--surface-2); }
.msg { display: grid; gap: 6px; max-width: 100%; animation: enter .35s var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
.msg .meta { font-size: 12px; color: var(--ink-3); }
.msg.user { justify-items: end; }
.msg.user .bubble { max-width: min(88%, 560px); padding: 10px 14px; border-radius: var(--r-l) var(--r-l) 6px var(--r-l);
  background: var(--surface-2); border: 1px solid var(--line); }
.msg.assistant .text { max-width: 62ch; font-size: 15.5px; line-height: 1.6; }
.msg.assistant .text code { padding: 1px 5px; border-radius: 4px; background: var(--surface-2); }
.assistant-sign { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.assistant-sign svg { width: 18px; height: 18px; }
.voice { display: grid; gap: 8px; min-width: 220px; }
.voice .player { display: flex; align-items: center; gap: 10px; }
.voice .wave { display: flex; align-items: center; gap: 2px; height: 26px; flex: 1; }
.voice .wave i { width: 3px; border-radius: 2px; background: var(--ink-3); }
.voice .duration { font-size: 12.5px; color: var(--ink-2); }
.voice .transcript { font-size: 14.5px; color: var(--ink); }
.voice .transcript.waiting { color: var(--ink-3); font-style: italic; }
.voice .voice-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }

.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite var(--ease); }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-2px); } }

.composer { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 5; padding-top: 8px;
  background: linear-gradient(to bottom, transparent, var(--bg) 30%); }
@media (min-width: 960px) { .composer { bottom: 20px; } }
.composer form { display: flex; align-items: flex-end; gap: 8px; padding: 8px; border-radius: var(--r-l);
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.composer form:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; min-height: 40px; max-height: 160px; padding: 9px 8px; border: 0; background: none; resize: none;
  outline: none; line-height: 1.45; }
.composer textarea::placeholder { color: var(--ink-3); }
.composer .btn { border-radius: 12px; }
.composer .send { width: 40px; padding: 0; }
.recording { flex: 1; display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 8px; }
.recording .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.recording .live-wave { display: flex; align-items: center; gap: 2px; height: 22px; flex: 1; overflow: hidden; }
.recording .live-wave i { width: 3px; border-radius: 2px; background: var(--danger); opacity: .8; transition: height .12s; }
.suggestions { display: flex; gap: 8px; overflow-x: auto; padding: 0 2px 10px; scrollbar-width: none; }
.suggestions button { flex: none; height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: 13.5px; cursor: pointer; }
.suggestions button:hover { color: var(--ink); border-color: var(--line-strong); }

/* ---------- Tarjeta de confirmación ---------- */
.confirmation { width: 100%; max-width: 520px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); overflow: hidden; }
.confirmation.pending { border-color: var(--warn-line); }
.confirmation header { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.confirmation.pending header { background: var(--warn-bg); color: var(--warn); border-bottom-color: var(--warn-line); }
.confirmation header .expires { margin-left: auto; font-weight: 500; font-variant-numeric: tabular-nums; }
.confirmation .body { display: grid; gap: 14px; padding: 16px; }
.confirmation .summary { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; }
.confirmation dl { display: grid; grid-template-columns: minmax(0, max-content) minmax(55%, 1fr); gap: 6px 16px; margin: 0; font-size: 14px; }
.confirmation dt { color: var(--ink-3); }
.confirmation dd { margin: 0; overflow-wrap: anywhere; }
.confirmation .why { display: flex; gap: 8px; font-size: 13px; color: var(--ink-2); }
.confirmation .why .icon { color: var(--ink-3); margin-top: 1px; }
.confirmation .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.confirmation .actions .btn { flex: 1 1 140px; }
.confirmation .decided { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.confirmation .decided.approved { color: var(--ok); }
.confirmation .decided.rejected, .confirmation .decided.expired { color: var(--ink-2); }
.step-up { display: grid; gap: 10px; padding: 14px; border-radius: var(--r-s); background: var(--surface-2); font-size: 14px; }

/* ---------- Listas, segmentos y tablas ---------- */
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; }
.section-title p { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line);
  max-width: 100%; overflow-x: auto; }
.segmented button { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 0; border-radius: 7px;
  background: none; color: var(--ink-2); font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap; }
.segmented button[aria-selected="true"], .segmented button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.list { display: grid; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.row { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; }
.row .icon { color: var(--ink-3); margin-top: 2px; }
.row .row-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.row .row-main strong { font-weight: 500; }
.row .secondary { font-size: 13px; color: var(--ink-3); }
.row a.cover { color: inherit; text-decoration: none; }
.row a.cover::after { content: ""; position: absolute; inset: 0; }
.row.link { position: relative; }
.row.link:hover { background: var(--surface-2); }
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 12px; font-size: 12.5px;
  font-weight: 500; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.free { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.confirm, .chip.waiting, .chip.pending { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.chip.forbidden, .chip.denied, .chip.failed, .chip.suspended, .chip.frozen, .chip.blocked { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.chip.ok, .chip.done, .chip.approved, .chip.active, .chip.active, .chip.granted { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip .icon { width: 13px; height: 13px; margin: 0; color: currentColor; }

.table-wrap { border-radius: var(--r-m); border: 1px solid var(--line); background: var(--surface); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: var(--surface-2); }
td .hash { color: var(--ink-3); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.chain-state { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }
.chain-state.intact { color: var(--ok); }
.chain-state.broken { color: var(--danger); }

/* Auditoría como lista en móvil, tabla en escritorio */
.desktop-only { display: none; }
@media (min-width: 760px) { .desktop-only { display: block; } .mobile-only { display: none; } }

/* ---------- Formularios (panel) ---------- */
.panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 20px; }
.panel-head .person { flex: 1; min-width: 220px; }
.panel-head .avatar { width: 44px; height: 44px; font-size: 16px; }
.panel-head h2 { font-size: 20px; }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; color: var(--ink-2); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--ink); }
.sections { display: grid; gap: 16px; }
@media (min-width: 960px) {
  .detail { display: grid; grid-template-columns: 200px 1fr; gap: 28px; align-items: start; }
  .toc { position: sticky; top: 88px; display: grid; gap: 2px; }
  .toc a { padding: 7px 10px; border-radius: var(--r-s); color: var(--ink-2); text-decoration: none; font-size: 14px; }
  .toc a:hover { background: var(--surface-2); color: var(--ink); }
}
@media (max-width: 959px) {
  .toc { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 16px; padding: 0 16px; scrollbar-width: none; }
  .toc a { flex: none; height: 32px; display: inline-flex; align-items: center; padding: 0 12px; border-radius: 16px;
    border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; font-size: 13.5px; background: var(--surface); }
}
.section { padding: 18px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); scroll-margin-top: 84px; }
.section > header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.section > header .icon { color: var(--ink-3); margin-top: 2px; }
.section > header div { flex: 1; }
.section > header p { font-size: 13.5px; color: var(--ink-2); margin-top: 3px; }
.grid { display: grid; gap: 14px; }

.field { display: grid; gap: 6px; align-content: start; }
.field label, .field .label { font-size: 13.5px; font-weight: 500; }
.field .hint { font-size: 12.5px; color: var(--ink-3); }
.field .error { font-size: 12.5px; color: var(--danger); display: flex; gap: 6px; }
.field input, .field select, .field textarea { width: 100%; min-height: 40px; padding: 8px 12px; border-radius: var(--r-s);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.field input::placeholder { color: var(--ink-3); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field [aria-invalid="true"] { border-color: var(--danger); }
.field input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.with-suffix { position: relative; }
.with-suffix input { padding-right: 32px; text-align: right; font-variant-numeric: tabular-nums; }
.with-suffix span { position: absolute; right: 12px; top: 50%; translate: 0 -50%; color: var(--ink-3); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.secret { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r-s); background: var(--surface-2);
  font-size: 13.5px; color: var(--ink-2); }
.secret .icon { color: var(--ink-3); }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.level-select { min-height: 34px !important; padding: 4px 8px !important; width: auto !important; }
.danger-zone { border-color: var(--danger-line); }
.inline-confirm { display: grid; gap: 10px; padding: 14px; border-radius: var(--r-s); background: var(--danger-bg);
  border: 1px solid var(--danger-line); color: var(--ink); font-size: 14px; }
.inline-confirm .form-actions { margin-top: 0; justify-content: flex-start; }

.settings { display: grid; gap: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { background: var(--surface-2); }
/* Las rejillas no deben crecer con el contenido desplazable (sugerencias, tablas): columnas con mínimo 0 */
.chat, .sections, .grid, .thread { grid-template-columns: minmax(0, 1fr); }
.thread > *, .composer, .section { min-width: 0; }
@media (min-width: 640px) { .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .detail { grid-template-columns: 200px minmax(0, 1fr); } }
.row { flex-wrap: wrap; }
.row .row-main { flex: 1 1 200px; }
.row > .chip { margin-left: auto; }
.steps .chip { white-space: normal; height: auto; min-height: 24px; padding-block: 2px; overflow-wrap: anywhere; }
.composer textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer textarea:focus-visible { box-shadow: none; }
.chip.running { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.cancelled, .chip.expired { background: var(--surface-2); color: var(--ink-2); }
.msg.assistant .text p + p { margin-top: 10px; }
.login h2 { letter-spacing: -0.01em; }
.assistant-sign [data-activity] { font-weight: 500; color: var(--ink-3); }

/* ---------- Guided tour ---------- */
.tour { position: fixed; inset: 0; z-index: 60; }
.tour-spot { position: fixed; border-radius: var(--r-m); box-shadow: 0 0 0 9999px rgb(10 12 14 / 0.55); transition: all .3s var(--ease); pointer-events: none; }
.tour-card { position: fixed; width: min(360px, calc(100vw - 24px)); padding: 18px; border-radius: var(--r-m); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-high); display: grid; gap: 8px; animation: pop .2s var(--ease); }
.tour-card.centered { top: 50%; left: 50%; translate: -50% -50%; box-shadow: 0 0 0 9999px rgb(10 12 14 / 0.55), var(--shadow-high); }
.tour-card h2 { font-size: 17px; }
.tour-card p { color: var(--ink-2); font-size: 14.5px; }
.tour-card .tour-count { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.tour-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.tour-actions .spacer { flex: 1; }
.tour-offer { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: start; padding: 14px 16px; border-radius: var(--r-m);
  background: var(--accent-soft); border: 1px solid transparent; }
.tour-offer > .icon { color: var(--accent); margin-top: 2px; }
.tour-offer p { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.tour-offer .form-actions { grid-column: 1 / -1; justify-content: flex-start; margin-top: 4px; }
.tour-actions { flex-wrap: nowrap; }
.tour-actions .btn { padding: 0 12px; min-height: 38px; }

/* ---------- Phone fit: no zoom, safe areas, 16 px inputs (iOS zooms the page on smaller ones) ---------- */
html, body { touch-action: manipulation; overscroll-behavior-y: none; }
body { overflow-x: hidden; }
input, select, textarea { font-size: 16px; }
.composer textarea { font-size: 16px; }
.topbar { padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
.login { padding-top: calc(24px + env(safe-area-inset-top)); padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.tour-card { max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; }
@media (min-width: 960px) { .topbar { height: 64px; padding-top: 0; } .main { padding-left: 28px; padding-right: 28px; } }
/* Long unbreakable strings (event types, hashes, e-mails) must wrap instead of widening the list. */
.list { grid-template-columns: minmax(0, 1fr); }
.row-main { min-width: 0; }
.row-main > *, .secondary, .mono, .person .info, .panel-head .info { overflow-wrap: anywhere; min-width: 0; }
.panel-head .person, .panel-head .info { min-width: 0; }
.section-title { flex-wrap: wrap; }
.section-title > div { flex: 1 1 240px; }
.row .row-main { flex: 1 1 140px; }
.msg.assistant .text ul, .msg.assistant .text ol { margin: 8px 0; padding-left: 22px; display: grid; gap: 4px; }
.msg.assistant .text > * + * { margin-top: 10px; }
.msg.assistant .text strong { font-weight: 600; }

/* The assistant's browser, live */
.webview { margin: 0; width: min(560px, 100%); border: 1px solid var(--line-strong); border-radius: var(--r-m, 12px); overflow: hidden; background: var(--surface); }
.webview-bar { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line); color: var(--ink-3); }
.webview-bar svg { flex: none; width: 14px; height: 14px; }
.webview-url { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--ink-2); text-decoration: none; }
.webview-url:hover, .webview-url:focus-visible { text-decoration: underline; }
.webview img { display: block; width: 100%; height: auto; aspect-ratio: 1100 / 760; background: var(--sunken); }
.webview figcaption { display: flex; align-items: center; gap: 8px; padding: 7px 10px; font-size: 12.5px; color: var(--ink-2); border-top: 1px solid var(--line); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger, #c0392b); animation: blink 1.4s infinite var(--ease); }
.webview.done .live-dot { background: var(--ink-3); animation: none; }
.webview.done img { opacity: .92; }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

.assistant-sign .speak { width: 28px; height: 28px; min-height: 0; padding: 0; margin-left: 2px; color: var(--ink-3); }
.assistant-sign .speak[aria-pressed="true"] { color: var(--accent); }

/* Attachments */
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 8px; }
.msg.assistant .attachments { margin: 10px 0 0; }
.attachments .thumb { display: block; width: 132px; height: 132px; border-radius: var(--r-s); overflow: hidden; border: 1px solid var(--line); background: var(--sunken); }
.attachments .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 8px 12px; border-radius: var(--r-s); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); text-decoration: none; font-size: 13.5px; }
.file-chip:hover, .file-chip:focus-visible { background: var(--surface-2); }
.file-chip .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-chip .size { color: var(--ink-3); flex: none; }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.pending-file { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 4px 4px 6px; border-radius: var(--r-s); border: 1px solid var(--line-strong); background: var(--surface); font-size: 13px; }
.pending-file img { width: 28px; height: 28px; border-radius: 4px; object-fit: cover; }
.pending-file .name { min-width: 0; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-file.uploading { opacity: .75; }
.pending-file.failed { border-color: var(--danger-line); color: var(--danger); }
.pending-file .btn { width: 26px; height: 26px; min-height: 0; padding: 0; }
.pending-files[hidden] { display: none; }
.attachments { max-width: 100%; min-width: 0; }
.attachments .file-chip { min-width: 0; }

/* Memory */
.memory-intro { margin: 0 0 12px; font-size: 14px; }
.memory-h { margin: 18px 0 8px; font-size: 15px; }
.memory-sub { margin: 10px 0 6px; font-size: 12.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.dots { display: inline-flex; gap: 3px; flex: none; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.dots i.on { background: var(--accent); }
.progress { display: block; height: 5px; margin-top: 6px; max-width: 220px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.row.note.proposed { border-left: 3px solid var(--warn-line); }
.warn-text { color: var(--warn) !important; display: inline-flex; gap: 6px; align-items: center; }
details.run { border: 1px solid var(--line); border-radius: var(--r-s); padding: 8px 12px; margin-bottom: 8px; background: var(--surface); }
details.run summary { cursor: pointer; font-size: 14px; }
details.run ul { margin: 8px 0 2px; padding-left: 18px; font-size: 13.5px; color: var(--ink-2); }
#s-soul textarea { width: 100%; font: inherit; line-height: 1.5; }

.notice-box { display: inline-flex; gap: 8px; align-items: flex-start; max-width: min(88%, 560px); padding: 10px 14px; border-radius: var(--r-m);
  border: 1px dashed var(--line-strong); background: var(--surface); color: var(--ink-2); font-size: 14px; }
.notice-box svg { flex: none; margin-top: 2px; color: var(--accent); }
