:root {
  --carbon: #16120F;
  --carbon-2: #211B17;
  --carbon-3: #2E2621;
  --carbon-line: rgba(251, 250, 247, .09);
  --brasa: #E0572A;
  --brasa-700: #B8431D;
  --brasa-50: #FCEDE6;
  --mostaza: #E8B04B;
  --mostaza-50: #FBF1DC;
  --hueso: #FBFAF7;
  --tinta: #2A241F;
  --humo: #8A7F74;
  --humo-2: #6F655B;
  --linea: #E8E3DC;
  --surface: #FFFFFF;
  --ok: #2F7A4D;
  --ok-50: #E5F2EA;
  --bad: #B3261E;
  --bad-50: #FBE9E7;
  --bubble-out: #E3F4D6;
  --bubble-in: #FFFFFF;
  --chat-bg: #F3EFE9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 18, 15, .06), 0 12px 28px -16px rgba(22, 18, 15, .28);
  --display: "Rye", Georgia, serif;
  --sans: "Barlow", "Helvetica Neue", Arial, sans-serif;
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.45; color: var(--tinta); background: var(--hueso); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--mostaza); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; line-height: 1.12; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--mostaza); color: var(--carbon); padding: 8px 14px; border-radius: 8px; font-weight: 700; text-decoration: none; }
.skip:focus { top: 12px; }
.num { font-family: var(--cond); font-variant-numeric: tabular-nums; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); grid-template-rows: 64px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 20px; background: var(--carbon); color: var(--hueso); border-bottom: 1px solid var(--carbon-line); z-index: 40; }
.menu-btn { display: none; background: none; border: 0; color: inherit; padding: 8px; margin-left: -8px; border-radius: 8px; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand img { height: 38px; width: auto; display: block; }
.brand-sep { width: 1px; height: 30px; background: var(--carbon-line); }
.brand-title { font-family: var(--cond); font-weight: 700; font-size: 17px; letter-spacing: .02em; line-height: 1.05; white-space: nowrap; }
.brand-title small { display: block; font-family: var(--sans); font-weight: 500; font-size: 12px; letter-spacing: 0; color: #B9AEA3; }
.spacer { flex: 1; }
.synthetic { font-family: var(--cond); font-weight: 600; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--carbon); background: var(--mostaza); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brasa); color: #fff; font-family: var(--cond); font-weight: 700; font-size: 14px; flex: none; }
.me-txt { font-weight: 600; font-size: 14px; line-height: 1.15; }
.me-txt small { display: block; font-weight: 400; font-size: 12px; color: #B9AEA3; }

.sidebar { background: var(--carbon); color: #E9E2DA; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-label { font-family: var(--cond); font-weight: 600; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: #8F8378; padding: 10px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; color: inherit; text-align: left; padding: 10px 12px; border-radius: 8px; font-family: var(--cond); font-size: 17px; font-weight: 600; letter-spacing: .01em; }
.nav-item svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav-item:hover { background: var(--carbon-2); }
.nav-item[aria-current="page"] { background: var(--carbon-3); color: #fff; box-shadow: inset 3px 0 0 var(--brasa); }
.nav-item .count { margin-left: auto; background: var(--brasa); color: #fff; font-size: 13px; min-width: 22px; height: 22px; border-radius: 999px; display: grid; place-items: center; padding: 0 6px; }
.nav-item .pill { margin-left: auto; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; border: 1px solid #5A4E45; color: #C9BDB1; border-radius: 999px; padding: 1px 7px; }
.side-foot { margin-top: auto; padding: 14px 12px 4px; border-top: 1px solid var(--carbon-line); font-size: 13px; color: #B9AEA3; }
.side-foot b { color: #fff; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #5BC27E; display: inline-block; flex: none; box-shadow: 0 0 0 3px rgba(91, 194, 126, .18); }
.side-foot p { margin: 4px 0 0 16px; line-height: 1.35; }
.scrim { display: none; }

.main { overflow-y: auto; min-width: 0; background: var(--hueso); }
.main:focus { outline: none; }
.page { padding: 28px 32px 48px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-family: var(--cond); font-weight: 700; font-size: 34px; letter-spacing: -.005em; }
.page-head p { margin: 4px 0 0; color: var(--humo-2); }
.page-head .grow { flex: 1; min-width: 220px; }
.eyebrow { font-family: var(--cond); font-weight: 600; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--brasa); }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 8px; border: 1px solid var(--linea); background: var(--surface); padding: 9px 14px; font-weight: 600; font-size: 14px; line-height: 1.1; white-space: nowrap; }
.btn:hover { border-color: #CFC7BD; }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--brasa); border-color: var(--brasa); color: #fff; }
.btn.primary:hover { background: var(--brasa-700); border-color: var(--brasa-700); }
.btn.dark { background: var(--carbon); border-color: var(--carbon); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(22, 18, 15, .05); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--linea); background: var(--surface); border-radius: 8px; padding: 9px 12px; font-size: 14px; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--mostaza); outline-offset: 0; border-color: transparent; }
.textarea { resize: vertical; min-height: 70px; }
.field { display: grid; gap: 6px; }
.field > span { font-family: var(--cond); font-weight: 600; font-size: 14px; letter-spacing: .03em; color: var(--humo-2); }

.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px 3px 8px; font-size: 13px; font-weight: 600; background: var(--hueso); border: 1px solid var(--linea); white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--humo)); display: inline-block; }
button.chip { cursor: pointer; }
button.chip[aria-pressed="true"] { background: var(--carbon); border-color: var(--carbon); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--cond); font-weight: 600; font-size: 13px; letter-spacing: .04em; border-radius: 6px; padding: 2px 8px; background: var(--hueso); border: 1px solid var(--linea); color: var(--humo-2); white-space: nowrap; }
.badge.ok { background: var(--ok-50); border-color: transparent; color: var(--ok); }
.badge.warn { background: var(--mostaza-50); border-color: transparent; color: #8A5E0C; }
.badge.brasa { background: var(--brasa-50); border-color: transparent; color: var(--brasa-700); }
.badge.bad { background: var(--bad-50); border-color: transparent; color: var(--bad); }
.badge.muted { background: #F1EEE9; border-color: transparent; }

.card { background: var(--surface); border: 1px solid var(--linea); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px 0; }
.card-h h2, .card-h h3 { font-family: var(--cond); font-weight: 700; font-size: 20px; }
.card-b { padding: 16px 18px 18px; }

/* ---------- Resumen ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; }
.kpi .lbl { font-family: var(--cond); font-weight: 600; font-size: 14px; letter-spacing: .04em; color: var(--humo-2); }
.kpi .val { font-family: var(--cond); font-weight: 700; font-size: 40px; line-height: 1; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 13px; color: var(--humo-2); margin-top: 6px; }
.kpi .sub b { color: var(--ok); font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; }
.stack { display: grid; gap: 18px; align-content: start; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; align-items: end; height: 210px; padding-top: 10px; }
.bar { display: grid; grid-template-rows: auto 1fr auto; gap: 6px; height: 100%; text-align: center; }
.bar .v { font-family: var(--cond); font-weight: 700; font-size: 15px; }
.bar .col { align-self: end; background: linear-gradient(180deg, var(--brasa) 0%, #C44A22 100%); border-radius: 6px 6px 2px 2px; min-height: 6px; }
.bar.weekend .col { background: linear-gradient(180deg, var(--mostaza), #D19A35); }
.bar .d { font-family: var(--cond); font-weight: 600; color: var(--humo-2); font-size: 14px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--humo-2); margin-top: 12px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cost-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--linea); }
.cost-row:last-of-type { border-bottom: 0; }
.cost-row b { font-family: var(--cond); font-size: 22px; font-weight: 700; white-space: nowrap; }
.cost-row small { display: block; color: var(--humo-2); font-size: 13px; }
.fine { font-size: 12.5px; color: var(--humo); margin: 10px 0 0; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 10px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid #F1EDE8; font-size: 14px; }
.feed li:last-child { border-bottom: 0; }
.feed li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brasa); margin-top: 7px; }
.feed small { display: block; color: var(--humo); font-size: 12.5px; }
.health { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.health div { background: var(--hueso); border-radius: 8px; padding: 10px 12px; }
.health small { display: block; font-size: 12.5px; color: var(--humo-2); }
.health b { font-family: var(--cond); font-size: 20px; }

/* ---------- Bandeja ---------- */
.inbox { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; height: 100%; min-height: 0; }
.inbox.no-panel { grid-template-columns: 320px minmax(0, 1fr); }
.inbox.no-panel .cpanel { display: none; }
.clist { border-right: 1px solid var(--linea); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.clist-top { padding: 16px 14px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--linea); }
.clist-top h1 { font-family: var(--cond); font-weight: 700; font-size: 26px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--humo-2); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--carbon); color: #fff; }
.clist ul { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.citem { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 10px; width: 100%; border: 0; background: none; text-align: left; padding: 12px 14px; border-bottom: 1px solid #F3EFEA; }
.citem:hover { background: #FAF8F5; }
.citem[aria-current="true"] { background: var(--brasa-50); box-shadow: inset 3px 0 0 var(--brasa); }
.citem .avatar { width: 42px; height: 42px; font-size: 15px; background: var(--carbon-3); }
.citem .nm { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.citem .pv { font-size: 13px; color: var(--humo-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.citem .tg { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.citem .tg span { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; color: #fff; background: var(--c); }
.citem .meta { display: grid; justify-items: end; gap: 6px; font-size: 12px; color: var(--humo); }
.citem .un { background: var(--brasa); color: #fff; font-weight: 700; font-size: 12px; min-width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center; padding: 0 5px; }
.citem.unread .nm { color: var(--carbon); }
.citem.unread .pv { color: var(--tinta); font-weight: 600; }

.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--chat-bg); }
.thread-h { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--linea); min-height: 62px; }
.thread-h .avatar { background: var(--carbon-3); }
.thread-h .who { min-width: 0; flex: 1; }
.thread-h .who b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-h .who small { display: block; color: var(--humo-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-h .back-btn, .cpanel .back-btn { display: none; }
.timer { font-family: var(--cond); font-weight: 600; font-size: 13px; color: var(--ok); background: var(--ok-50); border-radius: 6px; padding: 3px 8px; white-space: nowrap; }
.timer.off { color: var(--bad); background: var(--bad-50); }
.thread-h .select { width: auto; padding: 6px 10px; font-size: 13px; }
.msgs { flex: 1; overflow-y: auto; padding: 20px clamp(12px, 3vw, 36px); display: flex; flex-direction: column; gap: 10px; background-image: radial-gradient(rgba(22, 18, 15, .045) 1px, transparent 1px); background-size: 18px 18px; }
.day { align-self: center; font-family: var(--cond); font-weight: 600; font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--humo-2); background: rgba(255, 255, 255, .8); padding: 3px 10px; border-radius: 6px; }
.bubble { max-width: min(520px, 82%); padding: 8px 12px 6px; border-radius: 10px; font-size: 14.5px; box-shadow: 0 1px 1px rgba(22, 18, 15, .08); position: relative; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 3px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-top-right-radius: 3px; }
.bubble .t { display: block; text-align: right; font-size: 11.5px; color: var(--humo); margin-top: 2px; }
.bubble .tpl { font-family: var(--cond); font-weight: 600; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: #4F7A3A; display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.bubble .btns { display: grid; gap: 1px; margin: 8px -12px -6px; border-top: 1px solid rgba(22, 18, 15, .08); }
.bubble .btns span { text-align: center; padding: 8px; color: #2A7AB0; font-weight: 600; font-size: 14px; }
.note { align-self: center; max-width: min(520px, 92%); background: var(--mostaza-50); border: 1px dashed #D9A441; border-radius: 8px; padding: 8px 12px; font-size: 13.5px; }
.note b { font-family: var(--cond); font-weight: 700; letter-spacing: .04em; font-size: 12.5px; text-transform: uppercase; color: #8A5E0C; display: block; }

/* Comanda: el pedido que llega desde BuenaCarta */
.comanda { align-self: flex-start; width: min(330px, 88%); background: #fff; font-family: var(--mono); font-size: 12.5px; color: #221C18; padding: 16px 16px 12px; position: relative; filter: drop-shadow(0 2px 3px rgba(22, 18, 15, .14)); margin: 6px 0 10px;
  -webkit-mask: radial-gradient(circle 5px at 50% 0, transparent 98%, #000) 0 0 / 14px 51% repeat-x, radial-gradient(circle 5px at 50% 100%, transparent 98%, #000) 0 100% / 14px 51% repeat-x;
          mask: radial-gradient(circle 5px at 50% 0, transparent 98%, #000) 0 0 / 14px 51% repeat-x, radial-gradient(circle 5px at 50% 100%, transparent 98%, #000) 0 100% / 14px 51% repeat-x; }
.comanda .src { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #7A6F65; }
.comanda h4 { font-family: var(--mono); font-weight: 600; font-size: 17px; margin: 8px 0 2px; letter-spacing: .02em; }
.comanda .mode { display: inline-block; font-weight: 600; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; background: #221C18; color: #fff; padding: 2px 7px; margin-bottom: 8px; }
.comanda .mode.recoger { background: var(--ok); }
.comanda hr { border: 0; border-top: 1.5px dashed #BDB3A8; margin: 10px 0; }
.comanda .ln { display: grid; grid-template-columns: 26px 1fr auto; gap: 6px; padding: 2px 0; }
.comanda .tot { display: flex; justify-content: space-between; font-weight: 600; font-size: 15px; }
.comanda .dl { color: #5E554D; line-height: 1.5; }
.comanda .t { display: block; text-align: right; font-size: 11px; color: #9A8F85; margin-top: 8px; font-family: var(--sans); }
.comanda .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; font-family: var(--sans); }
.comanda .acts .btn { padding: 6px 10px; font-size: 12.5px; }

.composer { background: var(--surface); border-top: 1px solid var(--linea); padding: 10px 14px 12px; display: grid; gap: 8px; }
.composer .qr { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.composer .qr button { border: 1px solid var(--linea); background: var(--hueso); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; white-space: nowrap; }
.composer form { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 42px; max-height: 120px; border: 1px solid var(--linea); border-radius: 10px; padding: 10px 12px; font-size: 14.5px; background: var(--hueso); }
.composer textarea:focus { outline: 2px solid var(--mostaza); border-color: transparent; }
.icon-btn { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--linea); background: var(--surface); flex: none; color: var(--tinta); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.send { background: var(--brasa); border-color: var(--brasa); color: #fff; }
.empty { margin: auto; text-align: center; color: var(--humo-2); padding: 40px 20px; }
.empty b { display: block; font-family: var(--cond); font-size: 22px; color: var(--tinta); }

.cpanel { border-left: 1px solid var(--linea); background: var(--surface); overflow-y: auto; padding: 18px 16px; display: grid; gap: 18px; align-content: start; }
.cpanel .who { text-align: center; }
.cpanel .who .avatar { width: 64px; height: 64px; font-size: 22px; margin: 0 auto 8px; background: var(--carbon-3); }
.cpanel .who b { display: block; font-size: 16px; }
.cpanel .who small { color: var(--humo-2); }
.cpanel h3 { font-family: var(--cond); font-weight: 700; font-size: 15px; letter-spacing: .06em; text-transform: uppercase; color: var(--humo-2); margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--humo-2); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }
.tag-toggle { border: 1px dashed var(--linea); background: none; }
.tag-toggle[aria-pressed="true"] { background: var(--c); border: 1px solid var(--c); color: #fff; }
.tag-toggle[aria-pressed="true"] i { background: #fff; }
.notes-list { display: grid; gap: 8px; margin-bottom: 8px; }
.notes-list div { background: var(--mostaza-50); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.notes-list small { display: block; color: #8A5E0C; font-weight: 600; font-size: 11.5px; margin-bottom: 2px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-family: var(--cond); font-weight: 600; font-size: 13.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--humo-2); padding: 12px 16px; border-bottom: 1px solid var(--linea); white-space: nowrap; background: #FCFBF9; }
td { padding: 12px 16px; border-bottom: 1px solid #F1EDE8; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #FAF8F5; }
tbody tr.fresh { animation: flash 2.4s ease-out; }
@keyframes flash { from { background: var(--mostaza-50); } to { background: transparent; } }
td .strong { font-weight: 700; }
td small { display: block; color: var(--humo-2); font-size: 12.5px; }
.mini-bar { height: 6px; background: #F0ECE6; border-radius: 99px; overflow: hidden; width: 110px; margin-top: 5px; }
.mini-bar i { display: block; height: 100%; background: var(--brasa); border-radius: 99px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--linea); }
.toolbar .input { max-width: 280px; }

/* ---------- Campañas ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.stat-grid div { background: var(--hueso); border-radius: 8px; padding: 10px 12px; }
.stat-grid small { display: block; font-size: 12.5px; color: var(--humo-2); }
.stat-grid b { font-family: var(--cond); font-weight: 700; font-size: 26px; }
.stat-grid em { font-style: normal; font-size: 12px; color: var(--humo-2); margin-left: 4px; }
.funnel { display: grid; gap: 8px; margin-top: 16px; }
.funnel div { display: grid; grid-template-columns: 110px 1fr 60px; align-items: center; gap: 12px; font-size: 13.5px; }
.funnel .track { height: 12px; background: #F0ECE6; border-radius: 99px; overflow: hidden; }
.funnel .track i { display: block; height: 100%; border-radius: 99px; background: var(--brasa); }
.funnel .track i.m { background: var(--mostaza); }
.funnel .track i.g { background: var(--ok); }

.wizard { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; counter-reset: st; }
.steps button { border: 1px solid var(--linea); background: var(--surface); border-radius: 999px; padding: 6px 14px 6px 8px; font-family: var(--cond); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; counter-increment: st; }
.steps button::before { content: counter(st); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #F0ECE6; font-size: 13px; }
.steps button[aria-current="step"] { border-color: var(--carbon); background: var(--carbon); color: #fff; }
.steps button[aria-current="step"]::before { background: var(--brasa); color: #fff; }
.steps button.done::before { content: "✓"; background: var(--ok); color: #fff; }
.opt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.opt { text-align: left; border: 1.5px solid var(--linea); background: var(--surface); border-radius: 10px; padding: 14px; display: grid; gap: 6px; }
.opt:hover { border-color: #CFC7BD; }
.opt[aria-checked="true"] { border-color: var(--brasa); box-shadow: 0 0 0 3px var(--brasa-50); }
.opt b { font-size: 15px; }
.opt small { color: var(--humo-2); font-size: 13px; }
.img-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.img-opt { border: 2px solid transparent; border-radius: 10px; padding: 0; overflow: hidden; background: var(--surface); position: relative; aspect-ratio: 1; }
.img-opt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-opt span { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(22, 18, 15, .78)); color: #fff; font-size: 12px; font-weight: 600; padding: 14px 6px 5px; text-align: left; }
.img-opt[aria-checked="true"] { border-color: var(--brasa); box-shadow: 0 0 0 3px var(--brasa-50); }
.wiz-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; }
.summary { display: grid; gap: 0; }
.summary div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px dashed var(--linea); font-size: 14px; }
.summary div span { color: var(--humo-2); }

/* Teléfono de vista previa */
.phone { position: sticky; top: 0; background: var(--carbon); border-radius: 34px; padding: 12px; box-shadow: var(--shadow); }
.phone-scr { background: var(--chat-bg); border-radius: 24px; overflow: hidden; min-height: 520px; display: flex; flex-direction: column; }
.phone-top { background: #1E4D3A; color: #fff; display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.phone-top img { width: 34px; height: 34px; border-radius: 50%; background: var(--carbon); object-fit: contain; padding: 3px; }
.phone-top b { font-size: 14px; display: block; }
.phone-top small { font-size: 11.5px; opacity: .8; }
.phone-body { padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; background-image: radial-gradient(rgba(22, 18, 15, .05) 1px, transparent 1px); background-size: 16px 16px; }
.pv-bubble { background: #fff; border-radius: 10px; border-top-left-radius: 3px; overflow: hidden; max-width: 92%; font-size: 13.5px; box-shadow: 0 1px 1px rgba(22, 18, 15, .08); }
.pv-bubble img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.pv-bubble p { margin: 0; padding: 8px 10px 4px; white-space: pre-wrap; }
.pv-bubble .t { display: block; text-align: right; font-size: 10.5px; color: var(--humo); padding: 0 10px 6px; }
.pv-bubble .btns span { display: block; text-align: center; border-top: 1px solid #EFEBE6; padding: 8px; color: #2A7AB0; font-weight: 600; font-size: 13px; }
.carousel { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.carousel .card-c { flex: 0 0 150px; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 1px rgba(22, 18, 15, .08); font-size: 12.5px; }
.carousel .card-c img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.carousel .card-c b { display: block; padding: 6px 8px 0; }
.carousel .card-c small { display: block; padding: 0 8px 6px; color: var(--humo-2); }
.carousel .card-c span { display: block; text-align: center; border-top: 1px solid #EFEBE6; padding: 6px; color: #2A7AB0; font-weight: 600; }

/* ---------- Plantillas ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.tpl-card { display: flex; flex-direction: column; overflow: hidden; align-self: start; }
.tpl-grid { align-items: start; }
.tpl-card .card-h { flex-wrap: wrap; }
.tpl-card code { font-family: var(--mono); font-size: 12.5px; color: var(--humo-2); }
.tpl-prev { background: var(--chat-bg); padding: 16px; margin: 14px 18px 18px; border-radius: 10px; }
.tpl-prev .pv-bubble { max-width: 340px; }

/* ---------- Agente IA ---------- */
.agent { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.switch { display: inline-flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0; font-weight: 600; }
.switch .tr { width: 46px; height: 26px; border-radius: 99px; background: #D8D1C8; position: relative; transition: background .2s; flex: none; }
.switch .tr::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch[aria-checked="true"] .tr { background: var(--ok); }
.switch[aria-checked="true"] .tr::after { transform: translateX(20px); }
.kb { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.kb li { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; background: var(--hueso); border-radius: 8px; }
.kb li .ic { width: 36px; height: 36px; border-radius: 8px; background: var(--carbon); color: var(--mostaza); display: grid; place-items: center; }
.kb li .ic svg { width: 18px; height: 18px; }
.kb li b { display: block; font-size: 14.5px; }
.kb li small { color: var(--humo-2); font-size: 13px; }
.rules { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 14px; }
.test-chat { display: flex; flex-direction: column; height: 560px; overflow: hidden; }
.test-chat .msgs { background-color: var(--chat-bg); }
.ai-tag { font-family: var(--cond); font-weight: 700; font-size: 11px; letter-spacing: .08em; color: #fff; background: var(--carbon); border-radius: 4px; padding: 1px 5px; margin-right: 6px; vertical-align: 1px; }
.typing { align-self: flex-end; background: var(--bubble-out); border-radius: 10px; padding: 10px 14px; display: flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--humo); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.optional { background: var(--carbon); color: #EDE6DE; border-radius: var(--radius); padding: 18px 20px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.optional h2 { font-family: var(--cond); font-weight: 700; font-size: 22px; color: #fff; }
.optional p { margin: 4px 0 0; color: #C9BDB1; font-size: 14px; max-width: 640px; }
.optional .grow { flex: 1; min-width: 240px; }

/* ---------- Diálogo y toasts ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(620px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); box-shadow: 0 30px 80px -20px rgba(22, 18, 15, .5); color: var(--tinta); }
dialog::backdrop { background: rgba(22, 18, 15, .55); }
.dlg-h { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--linea); }
.dlg-h h2 { font-family: var(--cond); font-weight: 700; font-size: 24px; flex: 1; }
.dlg-b { padding: 18px 20px; display: grid; gap: 16px; }
.dlg-f { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 18px; border-top: 1px solid var(--linea); }
.drop { border: 2px dashed #D4CBC0; border-radius: 12px; padding: 26px; text-align: center; background: var(--hueso); display: grid; gap: 8px; justify-items: center; }
.drop svg { width: 34px; height: 34px; color: var(--brasa); }
.drop.ok { border-style: solid; border-color: var(--ok); background: var(--ok-50); }
.hint { font-size: 13px; color: var(--humo-2); background: var(--mostaza-50); border-radius: 8px; padding: 10px 12px; }
.toast-root { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 200; }
.toast { background: var(--carbon); color: #fff; border-radius: 10px; padding: 12px 16px; box-shadow: var(--shadow); font-size: 14px; display: flex; gap: 10px; align-items: center; max-width: 380px; animation: tin .25s ease-out; }
.toast i { width: 8px; height: 8px; border-radius: 50%; background: #5BC27E; flex: none; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.noscript { padding: 30px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .inbox, .inbox.no-panel { grid-template-columns: 290px minmax(0, 1fr); }
  .inbox .cpanel { display: none; }
  .inbox.show-panel { grid-template-columns: 290px minmax(0, 1fr) 290px; }
  .inbox.show-panel .cpanel { display: grid; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wizard, .agent { grid-template-columns: minmax(0, 1fr); }
  .phone { position: static; max-width: 360px; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-grid; place-items: center; }
  .sidebar { position: fixed; top: 64px; bottom: 0; left: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .22s ease; }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 64px 0 0 0; background: rgba(22, 18, 15, .5); z-index: 50; }
  .grid-2, .tpl-grid { grid-template-columns: minmax(0, 1fr); }
  .me-txt, .brand-sep, .brand-title small { display: none; }
  .page { padding: 20px 16px 40px; }
  .inbox, .inbox.show-panel, .inbox.no-panel { grid-template-columns: minmax(0, 1fr); }
  .inbox .thread, .inbox .cpanel { display: none; }
  .inbox.open .clist { display: none; }
  .inbox.open .thread { display: flex; }
  .inbox.open.show-panel .thread { display: none; }
  .inbox.open.show-panel .cpanel { display: grid; }
  .thread-h .back-btn { display: grid; }
  .cpanel .back-btn { display: inline-flex; }
}
@media (max-width: 560px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand img { height: 32px; }
  .brand-title { font-size: 15px; }
  .synthetic { font-size: 11px; padding: 3px 8px; }
  .me .avatar { width: 30px; height: 30px; font-size: 12px; }
  .kpi .val { font-size: 32px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .opt-grid { grid-template-columns: minmax(0, 1fr); }
  .img-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .health { grid-template-columns: minmax(0, 1fr); }
  .page-head h1 { font-size: 28px; }
  .thread-h .select { display: none; }
  .funnel div { grid-template-columns: 90px 1fr 48px; }
  .toast-root { left: 16px; right: 16px; }
  .bars { gap: 6px; }
  th, td { padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
