/* Pinseo Agentes — branding pinseo.tech */
:root {
  --bg: #0a0a0a;
  --card: #111;
  --card2: #141414;
  --line: #1d1d1d;
  --line2: #262626;
  --lime: #b7f542;
  --lime2: #8bc34a;
  --lime-soft: #b7f54233;
  --text: #e8f0f2;
  --muted: #8a9b9e;
  --red: #ff5f6d;
  --amber: #ffc371;
  --grey: #5b6466;
  --r-s: 8px;
  --r-m: 12px;
  --r-l: 20px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Barra superior */
.top { display: flex; align-items: center; gap: 20px; padding: 12px 28px; border-bottom: 1px solid var(--lime-soft); flex-wrap: wrap; }
.logo { font: 32px/1 'Bebas Neue', sans-serif; letter-spacing: 1px; white-space: nowrap; }
.logo b { color: var(--lime); font-weight: 400; }
.logo small { font: 500 13px 'Space Grotesk', sans-serif; color: var(--muted); margin-left: 8px; letter-spacing: 2px; }
.bot-select { background: var(--card); border: 1px solid var(--lime-soft); border-radius: var(--r-s); padding: 6px 10px; color: var(--muted); }
.tabs { display: flex; gap: 6px; }
.tab { background: none; border: 0; padding: 7px 16px; border-radius: var(--r-l); color: var(--muted); font-weight: 500; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--lime); color: #0a0a0a; }
.user { margin-left: auto; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 2px; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn:hover { color: var(--text); }

/* Página */
.wrap { padding: 22px 28px 48px; max-width: 1480px; margin: 0 auto; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
h1 { font: 38px/1 'Bebas Neue', sans-serif; letter-spacing: 1px; margin: 0 0 4px; font-weight: 400; }
.sub { color: var(--muted); margin: 0; }
.label { font: 500 11px 'Space Grotesk', sans-serif; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; min-width: 0; }

.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line2); border-radius: var(--r-l); padding: 3px; }
.seg button { background: none; border: 0; padding: 5px 14px; border-radius: var(--r-l); color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card2); color: var(--lime); outline: 1px solid var(--lime-soft); }

/* Observabilidad */
.obs { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.list-card { position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.search { width: 100%; background: var(--card2); border: 1px solid var(--line2); border-radius: var(--r-s); padding: 8px 10px; margin-bottom: 10px; }
.search::placeholder { color: var(--grey); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { background: none; border: 1px solid var(--line2); border-radius: 14px; padding: 2px 10px; font-size: 12px; color: var(--muted); cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--lime); color: var(--lime); }
.convs { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: var(--r-s); margin-bottom: 2px; cursor: pointer; font-size: 13px; }
.conv:hover { background: var(--card2); }
.conv[aria-current="true"] { background: var(--card2); outline: 1px solid var(--lime-soft); }
.conv-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.conv-when { color: var(--text); font-variant-numeric: tabular-nums; }
.conv-meta { color: var(--muted); }
.conv-preview { color: var(--grey); font-size: 12px; margin: 2px 0 0 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-sep { font: 500 11px 'Space Grotesk', sans-serif; letter-spacing: 1px; color: var(--grey); padding: 10px 10px 4px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--grey); }
.dot.error { background: var(--red); }
.dot.booking_registered { background: var(--lime); }
.dot.handoff, .dot.urgency { background: var(--amber); }
.dot.answered { background: var(--lime2); opacity: .55; }
.dot.abandoned { background: var(--muted); }
.tag { font-size: 11px; border-radius: 10px; padding: 0 7px; border: 1px solid currentColor; }
.tag.bad { color: var(--red); }
.tag.warn { color: var(--amber); }
.empty { color: var(--muted); padding: 24px 8px; text-align: center; }

.detail-empty { color: var(--muted); padding: 60px 20px; text-align: center; }
.conv-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; margin-bottom: 14px; }
.conv-title { font: 26px/1 'Bebas Neue', sans-serif; letter-spacing: 1px; margin: 0; font-weight: 400; }
.conv-sub { color: var(--muted); font-size: 13px; }
.kpis { display: flex; gap: 32px; flex-wrap: wrap; padding: 12px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.kpi b { display: block; font: 30px/1 'Bebas Neue', sans-serif; color: var(--lime); font-weight: 400; letter-spacing: .5px; }
.kpi b.bad { color: var(--red); }
.kpi span { font-size: 12px; color: var(--muted); }

/* Turno: el riel de pasos (lo memorable: dónde falló, a simple vista) */
.turn { padding: 16px 0 8px; border-bottom: 1px solid var(--line); }
.turn:last-child { border-bottom: 0; }
.turn-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.turn-head h3 { margin: 0; font: 500 13px 'Space Grotesk', sans-serif; letter-spacing: 1.5px; color: var(--lime); }
.turn-head .when { color: var(--muted); font-size: 12px; }
.bubble { border-radius: var(--r-m); padding: 10px 14px; max-width: 70ch; margin: 0 0 12px; }
.bubble.patient { background: var(--card2); border: 1px solid var(--line2); color: #d3dadc; }
.bubble.bot { background: #b7f5420d; border: 1px solid var(--lime-soft); margin: 12px 0 0 auto; }
.bubble small { display: block; font: 500 10px 'Space Grotesk', sans-serif; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.rail { list-style: none; margin: 0; padding: 0 0 0 4px; position: relative; }
.rail::before { content: ''; position: absolute; left: 9px; top: 10px; bottom: 10px; width: 2px; background: linear-gradient(var(--lime), var(--lime2)); opacity: .5; }
.step { position: relative; }
.step-row { display: grid; grid-template-columns: 18px 150px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; width: 100%; background: none; border: 0; text-align: left; padding: 5px 6px 5px 0; border-radius: var(--r-s); font-size: 13px; }
button.step-row { cursor: pointer; }
button.step-row:hover { background: var(--card2); }
.node { width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--lime); justify-self: center; align-self: center; position: relative; z-index: 1; }
.step.warn .node { border-color: var(--amber); background: var(--amber); }
.step.error .node { border-color: var(--red); background: var(--red); box-shadow: 0 0 0 4px #ff5f6d2b; }
.step.skip .node { border-color: var(--grey); }
.step-name { color: var(--muted); }
.step-sum { overflow-wrap: anywhere; }
.step.warn .step-sum { color: var(--amber); }
.step.error .step-sum { color: var(--red); }
.step.skip .step-sum, .step.skip .step-name { color: var(--grey); }
.step-metric { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.step-row .caret { display: inline-block; margin-left: 4px; color: var(--grey); transition: transform .15s; }
.step-row[aria-expanded="true"] .caret { transform: rotate(90deg); }
.step-data { margin: 2px 0 8px 28px; background: #070707; border: 1px solid var(--line2); border-radius: var(--r-s); padding: 10px 12px; font: 12px/1.5 ui-monospace, 'Cascadia Mono', Consolas, monospace; color: #c9d0d2; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow: auto; }
.turn-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn { border-radius: var(--r-s); padding: 8px 14px; font-weight: 600; font-size: 13px; cursor: pointer; border: 1px solid var(--lime); }
.btn.primary { background: var(--lime); color: #0a0a0a; }
.btn.outline { background: none; color: var(--lime); }
.btn:disabled { border-color: var(--line2); color: var(--grey); background: none; cursor: not-allowed; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--lime); color: var(--text); border-radius: var(--r-s); padding: 9px 16px; z-index: 10; }

/* Analítica */
.funnel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.fs { background: var(--card2); border: 1px solid var(--line); border-radius: var(--r-m); padding: 14px 16px; position: relative; }
.fs b { font: 44px/1 'Bebas Neue', sans-serif; color: var(--lime); display: block; font-weight: 400; }
.fs span { font-size: 13px; color: var(--muted); }
.fs .rate { position: absolute; top: 12px; right: 14px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.fs-bar { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--lime), var(--lime2)); margin-top: 12px; }
.ana { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { margin-bottom: 10px; }
.bars .row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.bars .row span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 4px; background: var(--line2); margin-top: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--lime), var(--lime2)); }
.bar i.amber { background: var(--amber); }
.bar i.grey { background: var(--grey); }
.big { font: 34px/1 'Bebas Neue', sans-serif; color: var(--lime); }
.ops { display: grid; gap: 14px; }
.ops div span { display: block; font-size: 12px; color: var(--muted); }
.note { color: var(--muted); font-size: 12px; margin-top: 18px; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; }
.login .logo { font-size: 44px; margin-bottom: 4px; }
.login p { color: var(--muted); margin: 0 0 22px; }
.login label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.login input { width: 100%; background: var(--card); border: 1px solid var(--line2); border-radius: var(--r-s); padding: 10px 12px; margin-bottom: 14px; }
.login input:focus { border-color: var(--lime); outline: none; }
.login .btn { width: 100%; padding: 11px; }
.error-msg { color: var(--red); font-size: 13px; min-height: 20px; margin: 10px 0 0; }

@media (max-width: 980px) {
  .obs { grid-template-columns: 1fr; }
  .list-card { position: static; max-height: 46vh; }
  .ana { grid-template-columns: 1fr; }
  .funnel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .top { padding: 10px 16px; gap: 10px; }
  .wrap { padding: 16px 16px 40px; }
  .user { margin-left: 0; width: 100%; justify-content: space-between; }
  .step-row { grid-template-columns: 18px minmax(0, 1fr) auto; }
  .step-name { grid-column: 2; }
  .step-sum { grid-column: 2 / 4; }
  .step-metric { grid-row: 1; grid-column: 3; }
  .kpis { gap: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
