@font-face { font-family: 'Bricolage Grotesque'; src: url(/fonts/bricolage-grotesque-normal-300-800.woff2) format('woff2'); font-weight: 300 800; font-display: swap; }
@font-face { font-family: 'DM Sans'; src: url(/fonts/dm-sans-latin-wght.woff2) format('woff2'); font-weight: 100 1000; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url(/fonts/jetbrains-mono-normal-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }

:root {
  --canvas: #0F1B2D;
  --panel: #16243A;
  --panel-2: #1C2D47;
  --line: rgba(169, 180, 198, .16);
  --accent: #3D5AFE;
  --accent-hover: #5A73FF;
  --accent-muted: rgba(61, 90, 254, .18);
  --hielo: #A8B8FF;
  --plata: #C9D0DB;
  --text: #F6F4EE;
  --text-2: #A9B4C6;
  --ok: #4ADE80;
  --bad: #F87171;
  --radius: 14px;
  --font-title: 'Bricolage Grotesque', system-ui, sans-serif;
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--canvas); color: var(--text); font: 15px/1.5 var(--font); }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-title); font-weight: 800; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 28px; }
h1 b { color: var(--accent-hover); }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.eyebrow { font: 12px var(--mono); color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.ok-text { color: var(--ok); } .bad-text { color: var(--bad); }

/* botones y campos */
.btn { appearance: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 10px;
  padding: 9px 16px; font: 500 14px var(--font); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; justify-content: center; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.primary.danger { background: #B4363F; border-color: #B4363F; color: #fff; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: none; border: 0; color: var(--text-2); cursor: pointer; padding: 4px 6px; border-radius: 8px; font-size: 14px; }
.icon-btn:hover { color: var(--text); background: var(--panel-2); }
:focus-visible { outline: 2px solid var(--hielo); outline-offset: 2px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); cursor: pointer; }
input, select, textarea { background: var(--canvas); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; font: 15px var(--font); width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
.form-error { color: var(--bad) !important; min-height: 1.2em; font-size: 14px; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12.5px; color: var(--text-2); }
.hint code, .code-inline { font: 12px var(--mono); background: var(--panel-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; color: var(--hielo); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 30% 20%, var(--accent-muted), transparent 50%), var(--canvas); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px; display: grid; gap: 16px; }
.login-card p { color: var(--text-2); }

/* estructura */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 600 19px var(--font-title); color: var(--plata); }
.brand b { color: var(--text); font-weight: 800; }
#nav { display: grid; gap: 2px; flex: 1; align-content: start; }
#nav a { text-decoration: none; padding: 9px 12px; border-radius: 10px; color: var(--text-2); display: flex; align-items: center; gap: 10px; position: relative; }
#nav a:hover { background: var(--panel-2); color: var(--text); }
#nav a.active { background: var(--accent-muted); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.ni { width: 18px; text-align: center; font-size: 13px; color: var(--hielo); }
.badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 99px; font: 600 11px var(--mono); padding: 1px 7px; }
.badge.warn { background: var(--panel-2); color: var(--hielo); border: 1px solid var(--hielo); }
.main { padding: 28px clamp(16px, 3vw, 36px) 60px; min-width: 0; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-head p { color: var(--text-2); margin-top: 4px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar select { width: auto; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.empty { color: var(--text-2); padding: 26px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
  background: linear-gradient(90deg, var(--accent-muted), transparent); border: 1px solid rgba(61, 90, 254, .4); border-radius: var(--radius); padding: 14px 18px; }
.banner p { color: var(--text-2); font-size: 14px; }

/* inicio */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .v { font: 800 28px var(--font-title); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 13px; color: var(--text-2); }
.dash { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; align-items: start; }
.chart { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; align-items: end; height: 150px; padding-top: 8px; }
.chart .day { height: 100%; position: relative; }
.chart .b { border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .b.c { background: var(--panel-2); border: 1px solid var(--line); border-bottom: 0; }
.chart .b.d { background: linear-gradient(180deg, var(--hielo), var(--accent)); }
.chart .bars { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; align-items: end; height: 100%; }
.chart-x { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; font: 10px var(--mono); color: var(--text-2); margin-top: 6px; text-align: center; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* listas y actividad */
.list { display: grid; }
.ev { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); align-items: start; }
.ev:last-child { border-bottom: 0; }
.ev .who { font-weight: 600; }
.ev .txt { color: var(--text); overflow-wrap: anywhere; }
.ev .meta { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.ev .when { font: 12px var(--mono); color: var(--text-2); white-space: nowrap; }
.ev details { margin-top: 6px; }
.ev summary { cursor: pointer; font-size: 13px; color: var(--hielo); }
.ev .dm { margin-top: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; white-space: pre-line; font-size: 14px; }
.plat { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); color: var(--hielo); }
.plat svg { width: 17px; height: 17px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--plata); white-space: nowrap; }
.pill.sent { border-color: rgba(74, 222, 128, .4); color: var(--ok); }
.pill.simulated { border-color: rgba(168, 184, 255, .45); color: var(--hielo); }
.pill.failed { border-color: rgba(248, 113, 113, .45); color: var(--bad); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; padding: 3px 9px; border-radius: 99px; background: var(--accent-muted); color: var(--hielo); margin: 2px 4px 2px 0; }

/* automatizaciones */
.rules { display: grid; gap: 12px; }
.rule { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; }
.rule.off { opacity: .62; }
.rule h3 { font-size: 16px; }
.rule h3 a { text-decoration: none; }
.rule h3 a:hover { color: var(--hielo); }
.rule .sum { font-size: 13.5px; color: var(--text-2); margin-top: 3px; }
.rule .nums { display: flex; gap: 18px; text-align: right; }
.rule .nums b { display: block; font: 800 20px var(--font-title); font-variant-numeric: tabular-nums; }
.rule .nums span { font-size: 12px; color: var(--text-2); }
.rule .acts { display: flex; gap: 2px; margin-top: 6px; justify-content: flex-end; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; transition: .15s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--plata); transition: .15s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--hielo); outline-offset: 2px; }
.templates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; text-align: left; }
.tpl { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: pointer; display: grid; gap: 6px; color: var(--text); font: inherit; text-align: left; }
.tpl:hover { border-color: var(--accent); }
.tpl b { font-family: var(--font-title); font-size: 15px; }
.tpl span { font-size: 13px; color: var(--text-2); }

/* editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; }
.step + .step { margin-top: 14px; }
.step-head { display: flex; gap: 12px; align-items: center; }
.step-n { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-muted); color: var(--hielo); display: grid; place-items: center; font: 600 13px var(--mono); flex: none; }
.seg { display: inline-flex; background: var(--canvas); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg label { display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 8px; color: var(--text-2); cursor: pointer; font-size: 14px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent-muted); color: var(--text); box-shadow: inset 0 0 0 1px rgba(61, 90, 254, .6); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--hielo); }
.seg svg { width: 15px; height: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--canvas); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.chips:focus-within { border-color: var(--accent); }
.chips input { border: 0; background: none; padding: 4px; flex: 1; min-width: 140px; }
.chips .tag { margin: 0; }
.chips .tag button { background: none; border: 0; color: var(--hielo); cursor: pointer; padding: 0 0 0 2px; font-size: 14px; line-height: 1; }
.picked { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.post { position: relative; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 12px; color: var(--text-2); }
.post .ph { aspect-ratio: 1; background: var(--canvas) center / cover no-repeat; display: grid; place-items: center; color: var(--text-2); font: 11px var(--mono); }
.post .cap { padding: 6px 8px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 34px; }
.post .x { position: absolute; top: 4px; right: 4px; background: rgba(10, 18, 34, .85); border: 0; color: #fff; border-radius: 99px; width: 24px; height: 24px; cursor: pointer; }
.post .k { position: absolute; top: 6px; left: 6px; background: rgba(10, 18, 34, .85); color: var(--plata); border-radius: 99px; padding: 1px 7px; font: 10px var(--mono); }
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; max-height: 52vh; overflow-y: auto; padding: 2px; }
.post-grid label { display: block; cursor: pointer; }
.post-grid input { position: absolute; opacity: 0; }
.post-grid label:has(input:checked) .post { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.post-grid label:has(input:focus-visible) .post { outline: 2px solid var(--hielo); }
.vars { display: flex; gap: 6px; flex-wrap: wrap; }
.vars button { font: 12px var(--mono); background: var(--panel-2); border: 1px solid var(--line); color: var(--hielo); border-radius: 7px; padding: 3px 8px; cursor: pointer; }
.vars button:hover { border-color: var(--accent); }
.replies { display: grid; gap: 8px; }
.reply-row { display: grid; grid-template-columns: 1fr 34px; gap: 6px; }
.save-bar { position: sticky; bottom: 0; display: flex; gap: 8px; justify-content: flex-end; padding: 14px 0 4px; background: linear-gradient(transparent, var(--canvas) 35%); margin-top: 10px; flex-wrap: wrap; }
.save-bar .form-error { margin-right: auto; align-self: center; }

/* vista previa tipo teléfono */
.preview { position: sticky; top: 20px; }
.phone { background: #0A1222; border: 1px solid var(--line); border-radius: 30px; padding: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.phone-top { display: flex; align-items: center; gap: 10px; padding: 6px 6px 12px; border-bottom: 1px solid var(--line); }
.phone-top img { border-radius: 50%; }
.phone-top b { font-size: 14px; display: block; }
.phone-top span { font-size: 11.5px; color: var(--text-2); }
.thread { display: grid; gap: 10px; padding: 14px 4px 6px; min-height: 300px; align-content: start; }
.sys { font: 11px var(--mono); color: var(--text-2); text-align: center; text-transform: uppercase; letter-spacing: .05em; }
.comment { display: grid; grid-template-columns: 28px 1fr; gap: 8px; font-size: 13.5px; }
.comment .av { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font: 600 11px var(--font-title); color: var(--hielo); }
.comment .reply-to { margin: 8px 0 0 0; }
.bubble { max-width: 86%; padding: 9px 13px; border-radius: 18px; font-size: 14px; line-height: 1.4; white-space: pre-line; overflow-wrap: anywhere; }
.bubble.me { justify-self: end; background: linear-gradient(135deg, var(--accent), #5A4BF0); color: #fff; border-bottom-right-radius: 6px; }
.bubble.them { justify-self: start; background: var(--panel-2); border-bottom-left-radius: 6px; }
.bubble .btnlink { display: block; margin: 9px -13px -9px; padding: 9px 13px; border-top: 1px solid rgba(255, 255, 255, .25); text-align: center; font-weight: 600; }
.preview-note { font-size: 12.5px; color: var(--text-2); margin-top: 10px; text-align: center; }

/* probar */
.sim { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.result { margin-top: 14px; }

/* conexión */
.acc { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.acc:last-child { border-bottom: 0; }
.acc img, .acc .plat { width: 40px; height: 40px; border-radius: 50%; flex: none; object-fit: cover; }
.acc .grow { flex: 1; min-width: 0; }
.checklist { display: grid; gap: 0; counter-reset: c; }
.checklist li { list-style: none; display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist li::before { counter-increment: c; content: counter(c); width: 26px; height: 26px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; font: 12px var(--mono); color: var(--hielo); }
.checklist li.done::before { content: '✓'; background: var(--accent); border-color: var(--accent); color: #fff; }
.checklist ol { margin: 0; padding: 0; }
.copyrow { display: flex; gap: 6px; margin-top: 6px; }
.copyrow input { font: 12.5px var(--mono); }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }

/* página de privacidad */
.doc { max-width: 680px; margin: 0 auto; padding: 48px 20px; display: grid; gap: 16px; }
.doc a { color: var(--hielo); }

/* modal y aviso */
.modal { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-x: hidden; }
.modal.wide { width: min(760px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(5, 10, 20, .7); }
.modal form { padding: 22px; display: grid; gap: 14px; }
.modal .m-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; flex-wrap: wrap; }
.modal .m-actions .left { margin-right: auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 12px; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--bad); }

@media (max-width: 1100px) {
  .editor, .sim { grid-template-columns: 1fr; }
  .preview { position: static; max-width: 400px; }
  .dash, .settings { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .templates { grid-template-columns: 1fr; }
  .rule { grid-template-columns: auto 1fr; }
  .rule .right { grid-column: 1 / -1; }
  .rule .nums { justify-content: flex-start; text-align: left; }
  .rule .acts { justify-content: flex-start; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 20; border-right: 0; border-top: 1px solid var(--line); gap: 0; }
  .side .brand, .side #quickAdd, .side #logoutBtn { display: none; }
  #nav { grid-auto-flow: column; grid-auto-columns: 1fr; overflow-x: auto; }
  #nav a { flex-direction: column; gap: 2px; font-size: 10px; padding: 6px 4px; text-align: center; }
  #nav a.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .badge { position: absolute; top: 2px; margin: 0 0 0 22px; font-size: 9px; }
  .main { padding: 18px 16px 100px; }
  .grid2 { grid-template-columns: 1fr; }
  .ev { grid-template-columns: 34px 1fr; }
  .ev .when { grid-column: 2; }
  .save-bar { bottom: 64px; }
  h1 { font-size: 24px; }
}
