:root {
  --primary: #0f766e; --accent: #f59e0b; --sidebar: #0b1f2a;
  --primary-soft: color-mix(in srgb, var(--primary) 10%, white);
  --primary-dark: color-mix(in srgb, var(--primary) 80%, black);
  --accent-soft: color-mix(in srgb, var(--accent) 15%, white);
  --bg: #f4f6f8; --card: #fff; --text: #1d2939; --muted: #667085; --line: #e4e7ec;
  --ok: #12b76a; --ok-soft: #ecfdf3; --warn: #f79009; --warn-soft: #fffaeb;
  --err: #f04438; --err-soft: #fef3f2; --info: #2e90fa; --info-soft: #eff8ff;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 14px;
       color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; background: linear-gradient(90deg, var(--sidebar) 248px, var(--bg) 248px); }
.sidebar { background: var(--sidebar); color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand img { max-height: 38px; max-width: 120px; border-radius: 6px; background: #fff; padding: 3px; }
.brand .logo-fallback { width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; }
.brand .name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.15; }
.brand .tag { font-size: 11.5px; color: #94a3b8; }
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav .section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #cbd5e1; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; background: var(--accent); color: #111; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.side-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.07); font-size: 12px; }
.side-foot .who { color: #fff; font-weight: 600; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 28px 6px; }
.content { padding: 14px 28px 40px; }
.content.full { padding: 0; flex: 1; }

/* ---------- componentes ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-side { grid-template-columns: minmax(0,1fr) 340px; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g-side, .g3 { grid-template-columns: 1fr; } }

.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.accent { border-left: 4px solid var(--primary); }
.kpi.danger { border-left: 4px solid var(--err); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 13.5px; cursor: pointer; font-family: inherit; line-height: 1.2; white-space: nowrap; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #111; }
.btn-danger { color: var(--err); border-color: #fecdca; }
.btn-danger:hover { background: var(--err-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #f9fafb; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfcfd; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.card .table-wrap { border: 0; border-radius: 0; margin: -6px -18px -18px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-pagado, .b-read, .b-ok, .b-sent, .b-APPROVED { background: var(--ok-soft); color: #027a48; }
.b-proximo, .b-hoy, .b-warn, .b-PENDING, .b-simulado { background: var(--warn-soft); color: #b54708; }
.b-atrasado, .b-failed, .b-err, .b-REJECTED, .b-PAUSED, .b-DISABLED { background: var(--err-soft); color: #b42318; }
.b-pendiente, .b-neutral, .b-received { background: #f2f4f7; color: #344054; }
.b-delivered, .b-info { background: var(--info-soft); color: #175cd3; }
.b-primary { background: var(--primary-soft); color: var(--primary-dark); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }

.field { margin-bottom: 14px; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=search], input[type=tel], input[type=url], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d0d5dd; border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }
input[type=color] { width: 48px; height: 38px; border: 1px solid #d0d5dd; border-radius: 8px; padding: 3px; background: #fff; cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters input, .filters select { width: auto; min-width: 180px; }
.copy { display: flex; gap: 6px; }
.copy input { font-family: ui-monospace, monospace; font-size: 12.5px; background: #f9fafb; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; border: 1px solid; }
.flash.ok { background: var(--ok-soft); color: #027a48; border-color: #abefc6; }
.flash.err { background: var(--err-soft); color: #b42318; border-color: #fecdca; }
.flash.warn { background: var(--warn-soft); color: #b54708; border-color: #fedf89; }
.banner { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 45%, white); color: #7a4b00; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }

.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; }
.steps { margin: 0; padding-left: 18px; line-height: 1.7; }
.steps code, code { background: #f2f4f7; padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
details summary { cursor: pointer; }
.empty { text-align: center; padding: 30px; color: var(--muted); }

/* barras dashboard */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .stack { width: 100%; max-width: 26px; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; }
.bars .out { background: var(--primary); }
.bars .in { background: var(--accent); }
.bars .lbl { font-size: 10px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1200px 500px at 10% -10%, var(--primary-soft), transparent), var(--bg); padding: 20px; }
.login { width: 100%; max-width: 380px; }
.login .brand-lg { text-align: center; margin-bottom: 22px; }
.login .brand-lg img { max-height: 64px; max-width: 200px; }
.login .brand-lg .logo-fallback { width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 10px; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 700; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal.open { display: flex; }
.modal .box { background: #fff; border-radius: 14px; width: 100%; max-width: 880px; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal .box.sm { max-width: 480px; }
.modal .mhead { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal .mbody { padding: 18px 20px; overflow: auto; }
.modal .mfoot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }

/* ---------- inbox ---------- */
.inbox { display: grid; grid-template-columns: 330px minmax(0,1fr) 310px; height: calc(100vh - 0px); background: #fff; }
.inbox .col-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.inbox .list-head { padding: 16px 16px 10px; border-bottom: 1px solid var(--line); }
.inbox .list-head h1 { font-size: 18px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.seg { display: flex; background: #f2f4f7; border-radius: 8px; padding: 3px; gap: 2px; margin-top: 8px; }
.seg button { flex: 1; border: 0; background: none; padding: 6px; border-radius: 6px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.conv-list { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid #f2f4f7; cursor: pointer; }
.conv:hover { background: #f9fafb; }
.conv.on { background: var(--primary-soft); }
.conv .meta { min-width: 0; flex: 1; }
.conv .top { display: flex; justify-content: space-between; gap: 6px; }
.conv .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .tm { font-size: 11px; color: var(--muted); white-space: nowrap; }
.conv .pv { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv .un { background: var(--primary); color: #fff; border-radius: 99px; font-size: 11px; min-width: 19px; height: 19px; display: grid; place-items: center; font-weight: 700; padding: 0 5px; }
.conv.unread .nm, .conv.unread .pv { color: var(--text); font-weight: 700; }

.col-chat { display: flex; flex-direction: column; min-height: 0; background: #efeae2; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: #fff; border-bottom: 1px solid var(--line); }
.chat-head .nm { font-weight: 700; }
.chat-body { flex: 1; overflow-y: auto; padding: 18px 8%; display: flex; flex-direction: column; gap: 6px;
  background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 18px 18px; }
.bubble { max-width: 72%; padding: 7px 10px 5px; border-radius: 10px; box-shadow: 0 1px .5px rgba(0,0,0,.13); white-space: pre-wrap; word-wrap: break-word; line-height: 1.4; font-size: 13.8px; }
.bubble.in { background: #fff; align-self: flex-start; border-top-left-radius: 2px; }
.bubble.out { background: #d9fdd3; align-self: flex-end; border-top-right-radius: 2px; }
.bubble.out.tpl { background: #e7f8e3; }
.bubble.out.sim { background: #fff4d6; }
.bubble.out.fail { background: #fde4e1; }
.bubble .ft { display: flex; justify-content: flex-end; gap: 6px; align-items: center; font-size: 10.5px; color: #667781; margin-top: 3px; white-space: nowrap; }
.bubble .tk { font-size: 12px; letter-spacing: -3px; padding-right: 3px; }
.bubble .tk.read { color: #53bdeb; }
.bubble .tag { font-size: 10.5px; font-weight: 700; color: var(--primary-dark); margin-bottom: 3px; display: block; }
.bubble .err { font-size: 11px; color: #b42318; margin-top: 4px; white-space: normal; }
.bubble img { max-width: 240px; border-radius: 8px; display: block; margin-bottom: 4px; }
.bubble .btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.bubble .btns span { flex: 1; text-align: center; background: rgba(255,255,255,.75); border-radius: 7px; color: #027eb5; font-weight: 600; font-size: 12.5px; padding: 6px 8px; }
.day-sep { align-self: center; background: #fff; color: #54656f; font-size: 11.5px; padding: 4px 10px; border-radius: 7px; box-shadow: 0 1px .5px rgba(0,0,0,.1); margin: 8px 0; }
.composer { background: #f0f2f5; padding: 10px 14px; border-top: 1px solid var(--line); }
.composer .win { font-size: 12px; margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.composer .bar { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 140px; border-radius: 10px; resize: none; }
.chat-empty { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 30px; }

.col-info { border-left: 1px solid var(--line); overflow-y: auto; padding: 18px; background: #fff; }
.col-info .head { text-align: center; padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.col-info .head .avatar { margin: 0 auto 8px; }
.col-info .dl { grid-template-columns: 96px 1fr; font-size: 13px; }

.tpl-grid { display: grid; grid-template-columns: 260px 1fr; gap: 18px; min-height: 360px; }
.tpl-list { border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 52vh; }
.tpl-item { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.tpl-item:hover { background: #f9fafb; }
.tpl-item.on { background: var(--primary-soft); }
.tpl-item.dis { opacity: .55; }
.tpl-item .n { font-weight: 600; font-size: 13px; word-break: break-all; }
.phone-prev { background: #efeae2; border-radius: 12px; padding: 14px; }
@media (max-width: 1200px) { .inbox { grid-template-columns: 290px minmax(0,1fr); } .col-info { display: none; } }

.preview-brand { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: grid; grid-template-columns: 120px 1fr; height: 170px; }
.preview-brand .ps { background: var(--sidebar); padding: 12px 10px; }
.preview-brand .ps div { height: 9px; border-radius: 4px; background: rgba(255,255,255,.15); margin-bottom: 8px; }
.preview-brand .ps div.on { background: var(--primary); }
.preview-brand .pm { padding: 14px; background: var(--bg); }

.superbar { background: #eef2ff; border: 1px solid #c7d2fe; color: #3730a3; padding: 9px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.superbar a { color: #4338ca; font-weight: 600; }
.tcard { display: flex; gap: 14px; align-items: center; }
.tlogo { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; overflow: hidden; }
.tlogo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.ok-i { color: #12b76a; } .no-i { color: #98a2b3; }
pre.code { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: 12px; line-height: 1.5; }
.map-table td { vertical-align: top; }
.map-table select { min-width: 220px; }
.req { color: var(--err); }
.rep-grid { display: grid; grid-template-columns: 260px 1fr; gap: 20px; }
.rep-media img { width: 100%; max-height: 340px; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); background: #f9fafb; }
.nomedia { border: 2px dashed var(--line); border-radius: 10px; padding: 28px 14px; text-align: center; color: var(--muted); font-weight: 600; }
.pay-it { display: grid !important; grid-template-columns: 18px 1fr auto; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; font-weight: 500; }
.pay-it:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.pay-foot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.pay-foot > div { margin-right: auto; }
details.reject[open] summary { margin-bottom: 0; }
.subs-mini { margin-top: 10px; }
.subs-mini div { display: flex; justify-content: space-between; gap: 6px; font-size: 12.5px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
@media (max-width: 900px) { .rep-grid { grid-template-columns: 1fr; } }
