:root {
  --bg: #f7f6f2;
  --panel: #ffffff;
  --panel-2: #f1efe8;
  --ink: #17160f;
  --ink-2: #5d5a4f;
  --ink-3: #8f8b7d;
  --line: #e4e1d6;
  --accent: #e0a100;
  --accent-ink: #1b1400;
  --accent-soft: #fff4d1;
  --ok: #1f8a4c;
  --warn: #b25e00;
  --bad: #c0392b;
  --hl: #fff0b3;
  --shadow: 0 1px 2px rgba(20, 18, 8, .04), 0 8px 24px rgba(20, 18, 8, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e0b; --panel: #17170f; --panel-2: #1f1e15; --ink: #f3f1e8; --ink-2: #b9b5a6; --ink-3: #807c6e;
    --line: #2c2b20; --accent: #f5b301; --accent-ink: #1b1400; --accent-soft: #2e2608; --hl: #3d3308;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e0b; --panel: #17170f; --panel-2: #1f1e15; --ink: #f3f1e8; --ink-2: #b9b5a6; --ink-3: #807c6e;
  --line: #2c2b20; --accent: #f5b301; --accent-ink: #1b1400; --accent-soft: #2e2608; --hl: #3d3308;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.55 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; min-height: 100vh; }
.glow { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 25%, transparent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 20px color-mix(in srgb, var(--accent) 5%, transparent); } }

/* Layout */
.top {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1180px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; letter-spacing: -.01em; }
.brand .glow { width: 11px; height: 11px; box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 25%, transparent); animation: none; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { text-decoration: none; padding: 6px 12px; border-radius: 999px; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.nav a.on, .nav a:hover { background: var(--panel-2); color: var(--ink); }
.spacer { flex: 1; }
.iconbtn { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.iconbtn:hover { color: var(--ink); }
main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 80px; }

h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 6px; }
h2 { font-size: 18px; letter-spacing: -.01em; margin: 0 0 12px; }
.sub { color: var(--ink-2); margin: 0 0 22px; }
.muted { color: var(--ink-3); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 20px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer; border-radius: 10px;
  padding: 10px 16px; font-weight: 600; background: var(--accent); color: var(--accent-ink);
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: var(--panel-2); color: var(--ink); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], input[type=url], textarea, select {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 30px; }
.login h1 { font-size: 24px; display: flex; gap: 10px; align-items: center; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; }

/* Home */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.searchbar { display: flex; gap: 10px; margin-bottom: 14px; }
.searchbar input { font-size: 16px; padding: 12px 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.list { display: grid; gap: 10px; }
.row {
  display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 16px; text-decoration: none; transition: border-color .15s;
}
.row:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.date { text-align: center; line-height: 1.1; }
.date b { display: block; font-size: 20px; }
.date span { font-size: 11px; text-transform: uppercase; color: var(--ink-3); letter-spacing: .04em; }
.row h3 { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row p { margin: 3px 0 0; color: var(--ink-2); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); white-space: nowrap; }
.tag.venta { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 70%, var(--ink)); }
.tag.cliente { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.tag.err { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.tag.wait { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.score { font-weight: 700; font-size: 13px; padding: 2px 8px; border-radius: 8px; border: 1px solid var(--line); }
mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 2px; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-2); }

/* Chat */
.ask { position: sticky; top: 76px; }
.ask .log { max-height: 52vh; overflow: auto; display: grid; gap: 10px; margin: 12px 0; }
.bubble { padding: 10px 12px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; }
.bubble.me { background: var(--panel-2); justify-self: end; max-width: 90%; }
.bubble.ai { background: var(--accent-soft); }
.bubble a.ref { font-weight: 600; text-decoration: none; border-bottom: 1px dashed currentColor; }
.ask form { display: flex; gap: 8px; }
.ask textarea { resize: none; height: 44px; }

/* Detalle */
.back { text-decoration: none; color: var(--ink-2); font-size: 14px; }
.detail-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin: 10px 0 18px; }
.detail-head input.title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; border: 0; background: transparent; padding: 0; width: 100%; }
.detail-head input.title:focus { box-shadow: none; border-bottom: 2px solid var(--accent); border-radius: 0; }
.player { position: sticky; top: 58px; z-index: 5; padding: 10px 14px; margin-bottom: 18px; display: flex; gap: 12px; align-items: center; }
.player audio { width: 100%; height: 40px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 20px; align-items: start; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 12px 10px; cursor: pointer; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-color: var(--accent); }
.tabbody { padding: 18px 20px; }
.tabbody ul { padding-left: 18px; margin: 6px 0 16px; }
.tabbody li { margin: 4px 0; }
.next { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; margin: 14px 0; }
.next b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); margin-bottom: 2px; }
.action { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.action input { margin-top: 4px; accent-color: var(--accent); width: 16px; height: 16px; }
.action.done span { text-decoration: line-through; color: var(--ink-3); }
.action small { display: block; color: var(--ink-3); }
.bar { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.talk-row { display: grid; grid-template-columns: 130px 1fr 44px; gap: 10px; align-items: center; margin: 8px 0; font-size: 14px; }
.crit { display: grid; grid-template-columns: 1fr 40px; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.crit .bar { grid-column: 1 / -1; }
.crit small { grid-column: 1 / -1; color: var(--ink-2); }
.bigscore { font-size: 44px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.alert { background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad); padding: 8px 12px; border-radius: 10px; margin: 6px 0; font-size: 14px; }

.transcript { max-height: calc(100vh - 170px); overflow: auto; }
.tsearch { position: sticky; top: 0; background: var(--panel); padding: 12px 14px; border-bottom: 1px solid var(--line); z-index: 2; }
.seg { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 8px 14px; border-left: 3px solid transparent; }
.seg.now { background: var(--accent-soft); border-left-color: var(--accent); }
.seg button.ts { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; text-align: left; align-self: start; margin-top: 2px; }
.seg button.ts:hover { color: var(--accent); }
.seg .spk { font-weight: 600; font-size: 13px; }
.seg .txt { font-size: 14.5px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; }

table.team { width: 100%; border-collapse: collapse; font-size: 14px; }
table.team td, table.team th { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }

@media (max-width: 960px) {
  .home-grid, .detail-grid { grid-template-columns: 1fr; }
  .ask { position: static; }
  .transcript { max-height: none; }
}
@media (max-width: 600px) {
  .top-in { padding: 10px 16px; gap: 10px; }
  .nav a { padding: 6px 8px; }
  .brand span.txt { display: none; }
  main { padding: 20px 16px 60px; }
  h1 { font-size: 24px; }
  .row { grid-template-columns: 46px minmax(0, 1fr); }
  .row .meta { grid-column: 2; justify-content: flex-start; }
  .talk-row { grid-template-columns: 90px 1fr 38px; }
}
