/* ───────── Tokens (tema claro por defecto) ───────── */
:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f2f2f5;
  --surface-3: #e9e9ee;
  --border: #e3e3e8;
  --border-strong: #cfcfd8;
  --text: #17171c;
  --text-2: #4a4a55;
  --muted: #7a7a87;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-soft: #f1eafe;
  --primary-text: #ffffff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --err: #dc2626;
  --err-soft: #fee2e2;
  --test: #f59e0b;
  --test-soft: #fff7e6;
  --test-text: #7c4a03;
  --brand: linear-gradient(135deg, #f58529 0%, #dd2a7b 50%, #8134af 100%);
  --bubble-out: #3b82f6;
  --bubble-in: #efeff3;
  --shadow: 0 1px 2px rgba(16, 16, 24, 0.05), 0 1px 3px rgba(16, 16, 24, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 16, 24, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0c0c10;
    --surface: #15151b;
    --surface-2: #1c1c24;
    --surface-3: #25252f;
    --border: #272731;
    --border-strong: #363642;
    --text: #ececf2;
    --text-2: #c2c2cc;
    --muted: #8d8d9b;
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-soft: #241a3d;
    --ok: #4ade80;
    --ok-soft: #12301f;
    --warn: #fbbf24;
    --warn-soft: #33270b;
    --err: #f87171;
    --err-soft: #3a1414;
    --test: #f59e0b;
    --test-soft: #2b1f08;
    --test-text: #fcd34d;
    --bubble-in: #26262f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0c0c10;
  --surface: #15151b;
  --surface-2: #1c1c24;
  --surface-3: #25252f;
  --border: #272731;
  --border-strong: #363642;
  --text: #ececf2;
  --text-2: #c2c2cc;
  --muted: #8d8d9b;
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-soft: #241a3d;
  --ok: #4ade80;
  --ok-soft: #12301f;
  --warn: #fbbf24;
  --warn-soft: #33270b;
  --err: #f87171;
  --err-soft: #3a1414;
  --test: #f59e0b;
  --test-soft: #2b1f08;
  --test-text: #fcd34d;
  --bubble-in: #26262f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* ───────── Base ───────── */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14.5px/1.5 ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; word-break: break-all; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; align-content: start; }
.stack-lg { display: grid; gap: 20px; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 22px; height: 22px; }

/* ───────── Formularios ───────── */
label.field { display: grid; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.hint { font-weight: 400; font-size: 12.5px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { min-height: 76px; resize: vertical; }
input[type='checkbox'] { width: auto; accent-color: var(--primary); }
input[type='number'] { max-width: 110px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-weight: 600;
  white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--err); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.icon { padding: 7px; }
.btn.test { background: var(--test); border-color: var(--test); color: #1c1200; }

/* Interruptor */
.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-weight: 600; font-size: 13px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 36px; height: 21px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: background 0.2s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.2s; }
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::after { transform: translateX(15px); }
.switch.test input:checked + .track { background: var(--test); border-color: var(--test); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--primary-soft); }

/* Control segmentado */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-2); padding: 6px 12px; border-radius: 7px; cursor: pointer; font: inherit; font-weight: 600; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.full { display: flex; }
.seg.full button { flex: 1; justify-content: center; }

/* Chips de palabras clave */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); min-height: 42px; cursor: text; }
.chips:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.chips input { border: 0; box-shadow: none !important; padding: 4px; flex: 1; min-width: 120px; background: transparent; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-soft); color: var(--primary); border-radius: 99px; padding: 3px 6px 3px 11px; font-weight: 600; font-size: 13px; }
.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 4px; font-size: 15px; line-height: 1; opacity: 0.7; }
.chip button:hover { opacity: 1; }
.chip.static { padding: 3px 10px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.test { background: var(--test-soft); color: var(--test-text); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ───────── Estructura ───────── */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 14px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; font-weight: 750; font-size: 17px; letter-spacing: -0.02em; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; color: #fff; }
.logo svg { width: 17px; height: 17px; }
.acct { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); position: relative; }
.acct .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; overflow: hidden; }
.acct .avatar img { width: 100%; height: 100%; object-fit: cover; }
.acct select { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.acct .small { display: block; }
.acct .name { display: block; font-weight: 650; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--text-2); font-weight: 550; text-decoration: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a .count { margin-left: auto; }
.sidebar .bottom { margin-top: auto; display: grid; gap: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.modebox { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); display: grid; gap: 4px; }
.modebox.on { background: var(--test-soft); border-color: var(--test); }
.who { display: flex; align-items: center; gap: 8px; padding: 0 4px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.testbar { background: var(--test); color: #1c1200; font-weight: 650; font-size: 13px; padding: 7px 20px; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.testbar a { color: #1c1200; text-decoration: underline; }
.content { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 28px 80px; }
.pagehead { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 22px; }
.pagehead p { color: var(--muted); margin-top: 4px; }
.mobilebar { display: none; }

/* ───────── Tarjetas ───────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h3 { margin-bottom: 4px; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 550; display: flex; gap: 6px; align-items: center; }
.stat .value { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; margin-top: 4px; }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 13.5px; }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.callout.test { background: var(--test-soft); border-color: transparent; color: var(--test-text); }
.empty { text-align: center; padding: 42px 20px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty .big { width: 52px; height: 52px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }

/* Lista de automatizaciones */
.auto-card { display: grid; gap: 12px; cursor: pointer; transition: border-color 0.15s, transform 0.15s; }
.auto-card:hover { border-color: var(--border-strong); }
.auto-card .ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.auto-card .title { font-weight: 650; font-size: 15px; }
.auto-card .meta { display: flex; gap: 14px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--border); padding-top: 10px; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 5px; display: grid; }
.menu button { display: flex; gap: 9px; align-items: center; border: 0; background: transparent; color: var(--text); padding: 8px 10px; border-radius: 8px; cursor: pointer; font: inherit; text-align: left; }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--err); }

/* Plantillas */
.tpl { align-content: start; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 18px; cursor: pointer; display: grid; gap: 8px; font: inherit; color: var(--text); transition: border-color 0.15s, box-shadow 0.15s; }
.tpl:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.tpl .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.tpl b { font-size: 15px; }
.tpl span { color: var(--muted); font-size: 13px; }

/* ───────── Editor ───────── */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.edit-head { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 12px 0; margin: -12px 0 10px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--border); }
.edit-head .name-input { font-size: 19px; font-weight: 700; border: 1px solid transparent; background: transparent; padding: 5px 8px; max-width: 520px; }
.edit-head .name-input:hover { border-color: var(--border); }
.flow { display: grid; gap: 0; }
.block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.block-head { display: flex; gap: 11px; align-items: center; padding: 14px 16px; }
.block-head .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.block-head .kicker { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.block-head .title { font-weight: 650; }
.block-body { padding: 0 16px 16px; display: grid; gap: 12px; }
.block.off .block-body { display: none; }
.ico.trigger { background: #fde7f3; color: #be185d; }
.ico.public { background: #e0f2fe; color: #0369a1; }
.ico.dm { background: var(--primary-soft); color: var(--primary); }
.ico.step { background: var(--surface-2); color: var(--text-2); }
.ico.wait { background: var(--warn-soft); color: var(--warn); }
:root[data-theme='dark'] .ico.trigger { background: #3a1029; color: #f9a8d4; }
:root[data-theme='dark'] .ico.public { background: #0c2a3d; color: #7dd3fc; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .ico.trigger { background: #3a1029; color: #f9a8d4; }
  :root:not([data-theme='light']) .ico.public { background: #0c2a3d; color: #7dd3fc; }
}
.connector { display: grid; justify-items: center; height: 34px; position: relative; }
.connector::before { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: var(--border-strong); }
.add-step { position: relative; z-index: 2; align-self: center; border: 1px dashed var(--border-strong); background: var(--surface); color: var(--text-2); border-radius: 99px; padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; gap: 5px; align-items: center; }
.add-step:hover { border-color: var(--primary); color: var(--primary); }
.variant { display: flex; gap: 6px; align-items: center; }
.variant .n { width: 22px; color: var(--muted); font-size: 12px; text-align: center; flex: none; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; max-height: 280px; overflow: auto; }
.post { border: 2px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--surface-2); position: relative; padding: 0; font: inherit; color: var(--text); text-align: left; }
.post.sel { border-color: var(--primary); }
.post .thumb { aspect-ratio: 1; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.post img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post .cap { font-size: 11px; padding: 4px 6px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post .tick { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--primary); color: #fff; display: none; place-items: center; }
.post.sel .tick { display: grid; }
details.adv { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
details.adv summary { cursor: pointer; padding: 14px 16px; font-weight: 650; list-style: none; display: flex; gap: 8px; align-items: center; }
details.adv summary::-webkit-details-marker { display: none; }
details.adv[open] summary { border-bottom: 1px solid var(--border); }
details.adv .inner { padding: 16px; display: grid; gap: 16px; }
.step-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; min-width: 420px; }
.step-menu button { align-items: flex-start; }
.step-menu small { display: block; color: var(--muted); font-size: 12px; }

/* ───────── Teléfono (vista previa y Probar) ───────── */
.phone-wrap { position: sticky; top: 76px; display: grid; gap: 10px; }
.phone { width: 100%; max-width: 340px; margin: 0 auto; border-radius: 34px; border: 9px solid #111; background: var(--surface); box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; height: 620px; }
:root[data-theme='dark'] .phone { border-color: #2e2e38; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .phone { border-color: #2e2e38; } }
.phone .top { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; gap: 9px; align-items: center; font-weight: 650; font-size: 13.5px; }
.phone .top .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); flex: none; }
.phone .tabs { display: flex; border-bottom: 1px solid var(--border); }
.phone .tabs button { flex: 1; border: 0; background: transparent; padding: 9px; font: inherit; font-weight: 650; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.phone .tabs button.on { color: var(--text); border-bottom-color: var(--text); }
.phone .screen { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.phone .compose { border-top: 1px solid var(--border); padding: 8px; display: flex; gap: 6px; }
.phone .compose input { border-radius: 99px; padding: 8px 14px; }
.phone .compose button { border-radius: 99px; }
.sep { text-align: center; color: var(--muted); font-size: 11.5px; margin: 6px 0; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; font-size: 13.5px; line-height: 1.4; }
.bubble.in { align-self: flex-start; background: var(--bubble-in); color: var(--text); border-bottom-left-radius: 6px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); color: #fff; border-bottom-right-radius: 6px; }
.bubble .tag { display: block; font-size: 11px; opacity: 0.75; margin-bottom: 3px; }
.bubble .time { display: block; font-size: 10.5px; opacity: 0.6; margin-top: 3px; }
.bubble.card-msg { padding: 0; overflow: hidden; background: var(--bubble-in); color: var(--text); align-self: flex-end; }
.bubble.card-msg .txt { padding: 9px 12px; }
.bubble.card-msg a, .bubble.card-msg .lb { display: block; text-align: center; padding: 8px; border-top: 1px solid var(--border-strong); color: var(--bubble-out); font-weight: 650; text-decoration: none; }
.bubble img { display: block; max-width: 200px; border-radius: 14px; }
.qrs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.qrs button, .qrs span { border: 1px solid var(--bubble-out); color: var(--bubble-out); background: var(--surface); border-radius: 99px; padding: 5px 12px; font: inherit; font-size: 12.5px; font-weight: 650; cursor: pointer; }
.qrs span { cursor: default; }
.qrs button:hover { background: var(--bubble-out); color: #fff; }
.wait-pill { align-self: center; display: inline-flex; gap: 5px; align-items: center; font-size: 11.5px; color: var(--muted); background: var(--surface-2); border-radius: 99px; padding: 3px 10px; }
.typing { align-self: flex-start; background: var(--bubble-in); border-radius: 18px; padding: 10px 14px; display: flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Publicación simulada */
.ig-post { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.ig-post .img { aspect-ratio: 16 / 9; background: var(--brand); display: grid; place-items: center; color: #fff; font-weight: 750; font-size: 18px; text-align: center; padding: 14px; }
.ig-post .cap { padding: 8px 10px; font-size: 13px; }
.ig-comment { display: flex; gap: 8px; font-size: 13px; }
.ig-comment .av { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--text-2); }
.ig-comment.reply { margin-left: 34px; }
.ig-comment.reply .av { background: var(--brand); color: #fff; }
.post-tabs { display: flex; gap: 6px; overflow-x: auto; }
.post-tabs button { flex: none; }

/* Tablas, conversaciones, registro */
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 650; }
.inbox { display: grid; grid-template-columns: 300px 1fr; gap: 14px; }
.convs { max-height: 640px; overflow: auto; padding: 6px; }
.conv { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.conv:hover, .conv.sel { background: var(--surface-2); }
.conv .av { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-weight: 700; color: var(--text-2); flex: none; }
.chat { height: 560px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 14px; }
.log { display: grid; }
.log-row { display: grid; grid-template-columns: 150px 110px 1fr; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--border); font-size: 13px; align-items: start; }
.log-row .k { font-weight: 650; }
.log-row.warn .k { color: var(--warn); }
.log-row.error .k { color: var(--err); }
.log-row pre { white-space: pre-wrap; font-size: 12px; background: var(--surface-2); padding: 8px; border-radius: 8px; overflow: auto; max-height: 260px; }

/* Modal y avisos */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(760px, 94vw); max-height: 90vh; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(10, 10, 16, 0.5); backdrop-filter: blur(2px); }
.modal-body { padding: 24px; display: grid; gap: 18px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; z-index: 100; max-width: 90vw; box-shadow: var(--shadow-lg); font-weight: 550; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; padding: 28px; }
.login-card .brand { padding: 0; font-size: 20px; }

/* ───────── Responsive ───────── */
@media (max-width: 1100px) {
  .editor { grid-template-columns: 1fr; }
  .phone-wrap { position: static; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform 0.2s; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .mobilebar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
  .content { padding: 18px 16px 70px; }
  .inbox { grid-template-columns: 1fr; }
  .log-row { grid-template-columns: 1fr; gap: 2px; }
  .step-menu { grid-template-columns: 1fr; min-width: 260px; }
}

/* ───────── Gráficos del panel de uso ───────── */
.chart { position: relative; display: grid; grid-template-columns: 34px 1fr; grid-template-rows: 1fr 20px; gap: 0 6px; }
.chart .yaxis { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); text-align: right; }
.chart .plot { position: relative; border-bottom: 1px solid var(--border-strong); }
.chart .grid-line { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--border); }
.chart .bar-hit { position: absolute; bottom: 0; top: 0; display: flex; align-items: flex-end; justify-content: center; padding: 0 1px; cursor: default; }
.chart .bar { width: 100%; max-width: 22px; min-height: 0; background: var(--primary); border-radius: 4px 4px 0 0; transition: opacity 0.1s; }
.chart .bar-hit:hover .bar { opacity: 0.75; }
.chart .xaxis { grid-column: 2; position: relative; font-size: 11px; color: var(--muted); }
.chart .xaxis span { position: absolute; transform: translateX(-50%); white-space: nowrap; top: 3px; }
.chart-tip { position: fixed; z-index: 200; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 600; padding: 5px 9px; border-radius: 8px; box-shadow: var(--shadow-lg); }
.meter { height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter > div { height: 100%; background: var(--primary); border-radius: 99px; }
.meter > div.hot { background: var(--warn); }
.meter.sm { height: 6px; width: 90px; flex: none; }
.tips { display: grid; gap: 8px; }
.tips:empty { display: none; }

/* App instalada (PWA): respeta la muesca del móvil */
@media (max-width: 860px) {
  .mobilebar { padding-top: max(10px, env(safe-area-inset-top)); }
  .sidebar { padding-top: max(16px, env(safe-area-inset-top)); }
}

/* Los mensajes no se encogen cuando la conversación no cabe: se hace scroll */
.phone .screen > * { flex-shrink: 0; }
