:root {
  --bg: #f6f7f5; --surface: #ffffff; --surface-2: #eef1ee; --text: #1c2421; --muted: #5d6a64;
  --line: #d8dfdb; --accent: #1f6f5c; --accent-ink: #ffffff; --accent-soft: #dcefe8;
  --warn: #9a5b00; --warn-soft: #fbeed8; --bad: #a3302a; --bad-soft: #f8e1df; --ok: #2c7a3f; --ok-soft: #e0f2e4;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121715; --surface: #1a211e; --surface-2: #222b27; --text: #e6ece9; --muted: #9aa8a1;
    --line: #2f3a35; --accent: #5cc1a3; --accent-ink: #0d1412; --accent-soft: #1e3a32;
    --warn: #f0b45a; --warn-soft: #3a2c15; --bad: #f08a83; --bad-soft: #3b1f1d; --ok: #7ccf8e; --ok-soft: #1d3424;
  }
}
:root[data-theme="dark"] {
  --bg: #121715; --surface: #1a211e; --surface-2: #222b27; --text: #e6ece9; --muted: #9aa8a1;
  --line: #2f3a35; --accent: #5cc1a3; --accent-ink: #0d1412; --accent-soft: #1e3a32;
  --warn: #f0b45a; --warn-soft: #3a2c15; --bad: #f08a83; --bad-soft: #3b1f1d; --ok: #7ccf8e; --ok-soft: #1d3424;
}
* { box-sizing: border-box; }
.sprite { display: none; }
.hidden { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
nav.side { background: var(--surface); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
nav.side .brand { font-weight: 700; padding: 4px 10px 14px; font-size: 15px; }
nav.side .brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
nav.side a { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; }
nav.side a:hover { background: var(--surface-2); }
nav.side a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar { display: none; }
main.content { padding: 24px 28px 60px; max-width: 1180px; width: 100%; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 24px 0 10px; } h3 { font-size: 15px; margin: 16px 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.stat .n { font-size: 26px; font-weight: 700; } .stat .l { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; text-decoration: none; }
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; max-width: 100%; }
textarea { width: 100%; min-height: 140px; resize: vertical; }
textarea.manuscript { min-height: 60vh; font: 16px/1.7 var(--serif); }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 3px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.b-CONFIRMADO, .b-aprobado, .b-aprobada, .b-terminado, .b-done, .b-transcrito, .b-procesado { background: var(--ok-soft); color: var(--ok); }
.b-PENDIENTE, .b-propuesta, .b-esperando_aprobacion, .b-queued, .b-running, .b-corriendo, .b-abierta { background: var(--warn-soft); color: var(--warn); }
.b-CONTRADICTORIO, .b-dead, .b-error, .b-rechazada { background: var(--bad-soft); color: var(--bad); }
.notice { border-left: 3px solid var(--warn); background: var(--warn-soft); padding: 10px 12px; border-radius: 6px; }
.notice.bad { border-color: var(--bad); background: var(--bad-soft); }
.msg { padding: 10px 12px; border-radius: 10px; max-width: 80%; white-space: pre-wrap; word-wrap: break-word; }
.msg.in { background: var(--surface-2); } .msg.out { background: var(--accent-soft); margin-left: auto; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.chat { display: flex; flex-direction: column; gap: 8px; }
.prose { font: 16px/1.75 var(--serif); white-space: pre-wrap; max-width: 72ch; }
.quote { border-left: 3px solid var(--line); padding-left: 10px; color: var(--muted); font-style: italic; }
del { background: var(--bad-soft); color: var(--bad); } ins { background: var(--ok-soft); color: var(--ok); text-decoration: none; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 14px 0; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; }
.tabs button.on { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.toast { position: fixed; right: 16px; bottom: 16px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; z-index: 9; max-width: calc(100vw - 32px); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
pre.json { background: var(--surface-2); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 12px; white-space: pre-wrap; }
audio { width: 100%; max-width: 420px; }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  nav.side { display: none; position: fixed; inset: 0 30% 0 0; z-index: 8; height: 100vh; box-shadow: 0 0 30px rgba(0,0,0,.3); }
  nav.side.open { display: block; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
  main.content { padding: 16px 16px 60px; }
  .msg { max-width: 92%; }
  th.hide-sm, td.hide-sm { display: none; }
}
.login-card input, .login-card button { width: 100%; justify-content: center; }
.grow { flex: 1; min-width: 200px; }
