:root {
  --brand: #0b7d5b;
  --brand-dark: #095f45;
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #14201c;
  --muted: #6b7a75;
  --line: #e2e8e5;
  --wa-bg: #e5ddd5;
  --wa-out: #d9fdd3;
  --wa-in: #ffffff;
  --ok: #1a9d5c;
  --warn: #d98a00;
  --bad: #d64545;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

/* ---------- Top bar ---------- */
.topbar {
  background: var(--brand);
  color: #fff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 60px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
}
.logo-badge {
  width: 38px; height: 38px; border-radius: 10px;
  background: #fff; color: var(--brand);
  font-weight: 800; font-size: 15px;
  display: grid; place-items: center;
  letter-spacing: .5px;
}
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 12px; opacity: .85; margin-top: -2px; }
.powered { margin-left: auto; font-size: 11px; opacity: .8; text-align: right; }
.powered b { font-weight: 700; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 6px;
  background: var(--card);
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 60px; z-index: 15;
  overflow-x: auto;
}
.tab {
  border: none; background: transparent;
  padding: 9px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--muted);
  cursor: pointer; white-space: nowrap;
  transition: all .15s;
}
.tab:hover { background: var(--bg); }
.tab.active { background: var(--brand); color: #fff; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 16px 60px; }
.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

h2.section { font-size: 20px; margin: 4px 0 4px; }
p.lede { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

/* ---------- WhatsApp simulator ---------- */
.wa-shell {
  max-width: 420px; margin: 0 auto;
  background: var(--wa-bg);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  height: 640px;
  display: flex; flex-direction: column;
}
.wa-head {
  background: #075e54; color: #fff;
  padding: 12px 14px; display: flex; align-items: center; gap: 12px;
}
.wa-avatar { width: 40px; height: 40px; border-radius: 50%; background: #cfd8d4; display: grid; place-items: center; font-size: 20px; }
.wa-name { font-weight: 600; font-size: 15px; }
.wa-status { font-size: 12px; opacity: .85; }
.wa-body {
  flex: 1; overflow-y: auto; padding: 16px 12px;
  background-image: linear-gradient(rgba(229,221,213,.6), rgba(229,221,213,.6)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M0 39h40M39 0v40' stroke='%23d3ccc2' stroke-width='.5'/%3E%3C/svg%3E");
  display: flex; flex-direction: column; gap: 8px;
}
.msg { max-width: 82%; padding: 8px 10px 6px; border-radius: 10px; font-size: 14px; box-shadow: 0 1px 1px rgba(0,0,0,.08); position: relative; }
.msg .time { font-size: 10px; color: #667; text-align: right; margin-top: 2px; }
.msg.in { background: var(--wa-in); align-self: flex-start; border-top-left-radius: 2px; }
.msg.out { background: var(--wa-out); align-self: flex-end; border-top-right-radius: 2px; }
.msg .rcpt-img {
  width: 190px; height: 130px; border-radius: 8px; margin-bottom: 4px;
  background: linear-gradient(135deg,#e8e2d5,#cdc4b2);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  color: #7a7060; font-size: 12px; text-align: center; gap: 4px;
  border: 1px solid #bdb4a2;
}
.msg .rcpt-img .big { font-size: 30px; }
.msg b.tag { color: var(--brand-dark); }
.entry-card {
  background: #f0f7f3; border: 1px solid #cfe6db; border-radius: 8px; padding: 8px 10px; margin-top: 4px; font-size: 13px;
}
.entry-card .row { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.entry-card .row span:first-child { color: var(--muted); }
.conf-pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; font-weight: 700; }
.conf-hi { background: #d7f5e3; color: var(--ok); }
.conf-mid { background: #fdeecd; color: var(--warn); }
.conf-lo { background: #fbdada; color: var(--bad); }
.wa-actions { display: flex; gap: 6px; margin-top: 6px; }
.wa-btn { flex: 1; border: 1px solid var(--brand); background: #fff; color: var(--brand); border-radius: 8px; padding: 7px; font-size: 13px; font-weight: 600; cursor: pointer; }
.wa-btn.primary { background: var(--brand); color: #fff; }
.wa-btn:disabled { opacity: .5; cursor: default; }
.typing { align-self: flex-start; background: #fff; padding: 10px 14px; border-radius: 10px; border-top-left-radius: 2px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.typing span { display: inline-block; width: 7px; height: 7px; margin: 0 1px; background: #9aa5a0; border-radius: 50%; animation: blink 1.2s infinite; }
.typing span:nth-child(2){ animation-delay: .2s; } .typing span:nth-child(3){ animation-delay: .4s; }
@keyframes blink { 0%,60%,100%{ opacity:.3; transform: translateY(0);} 30%{ opacity:1; transform: translateY(-3px);} }
.wa-foot { padding: 10px 12px; background: #f0f0f0; display: flex; gap: 8px; }
.wa-foot button { border: none; background: var(--brand); color: #fff; border-radius: 999px; padding: 9px 16px; font-weight: 600; font-size: 13px; cursor: pointer; flex: 1; }
.wa-foot button:disabled { opacity: .5; cursor: default; }

/* ---------- Panel firma ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 800; margin-top: 2px; }
.stat .v.small { font-size: 18px; }

.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card h3 { margin: 0; padding: 14px 16px; font-size: 15px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.card .body { padding: 6px 0; }

.rcpt-item { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.rcpt-item:last-child { border-bottom: none; }
.rcpt-thumb { width: 40px; height: 40px; border-radius: 8px; background: linear-gradient(135deg,#e8e2d5,#cdc4b2); display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.rcpt-main { flex: 1; min-width: 0; }
.rcpt-top { display: flex; justify-content: space-between; gap: 8px; }
.rcpt-sup { font-weight: 600; font-size: 14px; }
.rcpt-amt { font-weight: 700; font-size: 14px; white-space: nowrap; }
.rcpt-meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.rcpt-cat { display: inline-block; margin-top: 6px; font-size: 12px; background: #eef4f1; color: var(--brand-dark); padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.rcpt-note { font-size: 12px; color: var(--muted); margin-top: 6px; font-style: italic; }
.rcpt-btns { display: flex; gap: 6px; margin-top: 8px; }
.mini-btn { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 5px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.mini-btn.ok { border-color: var(--ok); color: var(--ok); }
.mini-btn.ok:hover { background: var(--ok); color: #fff; }
.mini-btn.fix { border-color: var(--warn); color: var(--warn); }
.mini-btn.fix:hover { background: var(--warn); color: #fff; }
.badge-approved { font-size: 12px; color: var(--ok); font-weight: 700; }

.filter-chips { display: flex; gap: 6px; padding: 10px 16px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.alert-item { padding: 11px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.alert-item:last-child { border-bottom: none; }
.alert-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.sev-alta { background: var(--bad); } .sev-media { background: var(--warn); } .sev-baja { background: #9aa5a0; }
.alert-txt { font-size: 13px; }
.alert-cli { font-size: 12px; color: var(--muted); }
.alert-when { font-size: 11px; font-weight: 700; }
.when-alta { color: var(--bad); } .when-media { color: var(--warn); } .when-baja { color: var(--muted); }

.catbar { padding: 8px 16px 14px; }
.catbar .cat-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; font-size: 13px; }
.catbar .cat-label { width: 150px; color: var(--ink); }
.catbar .cat-track { flex: 1; height: 10px; background: #eef2f0; border-radius: 999px; overflow: hidden; }
.catbar .cat-fill { height: 100%; background: var(--brand); border-radius: 999px; }
.catbar .cat-val { width: 78px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Pipeline view ---------- */
.pipe-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.pipe-step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); text-align: center; position: relative; }
.pipe-step .icon { font-size: 26px; }
.pipe-step .lbl { font-weight: 700; font-size: 13px; margin-top: 4px; }
.pipe-step .desc { font-size: 11px; color: var(--muted); margin-top: 2px; }
.pipe-step .arrow { position: absolute; right: -8px; top: 50%; transform: translateY(-50%); color: var(--brand); font-weight: 800; z-index: 2; }
pre.json { background: #0f1e19; color: #d7f0e5; padding: 16px; border-radius: var(--radius); overflow-x: auto; font-size: 12.5px; line-height: 1.55; box-shadow: var(--shadow); }
pre.json .k { color: #7fd8b0; } pre.json .s { color: #ffd999; } pre.json .n { color: #93c5fd; }
.metric-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin: 16px 0; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow); }
.metric .mv { font-size: 26px; font-weight: 800; color: var(--brand); }
.metric .mk { font-size: 12px; color: var(--muted); margin-top: 2px; }
.callout { background: #eef7f2; border: 1px solid #cfe6db; border-left: 4px solid var(--brand); border-radius: 10px; padding: 14px 16px; font-size: 14px; margin-top: 8px; }

@media (max-width: 820px) {
  .stat-row { grid-template-columns: repeat(2,1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .pipe-steps { grid-template-columns: repeat(2,1fr); }
  .metric-row { grid-template-columns: 1fr; }
  .powered { display: none; }
}
