:root {
  /* Paleta de marca Gestión Beta */
  --navy: #123f67;          /* Azul secundario */
  --navy-2: #1b5688;
  --agua: #8ccfc9;          /* Verde agua */
  --agua-dark: #2f8f89;     /* verde agua oscurecido para texto/íconos sobre blanco */
  --celeste: #eef8f7;       /* tinte de verde agua para encabezados y fondos suaves */
  --celeste-2: #d7eeec;
  --bg: #f5f8f9;
  --card: #ffffff;          /* Blanco */
  --text: #4a4a4a;          /* Gris oscuro */
  --muted: #7d8288;
  --line: #e3e8eb;
  --accent: #123f67;
  --green: #2a8c85;
  --green-bg: #ddf1ef;
  --red: #c0473f;
  --red-bg: #fbe9e7;
  --amber: #a9700f;
  --amber-bg: #fcf1dc;
  --purple: #1b5688;
  --purple-bg: #e3ecf4;
  --gray-bg: #eef1f3;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; color: var(--navy); }
h2 { font-size: 16px; margin: 0 0 12px; color: var(--navy); }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

.shell { display: flex; min-height: 100vh; }
.side { width: 236px; flex: none; background: #fff; border-right: 3px solid var(--agua); display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 16px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.brand img { width: 52px; height: 52px; object-fit: contain; flex: none; }
.brand .t { font-weight: 700; font-size: 15px; line-height: 1.2; color: var(--navy); }
.brand .t small { display: block; font-weight: 500; font-size: 11px; color: var(--agua-dark); margin-top: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--text); padding: 9px 10px; border-radius: 8px; margin-bottom: 2px; text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--celeste); color: var(--navy); }
.nav a.on { background: var(--navy); color: #fff; }
.nav .ic { width: 18px; height: 18px; flex: none; color: var(--agua-dark); }
.nav a.on .ic { color: var(--agua); }
.nav .count { margin-left: auto; background: var(--agua); color: var(--navy); border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.side-foot { margin-top: auto; padding: 10px 6px 0; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.side-foot button { background: none; border: 0; color: var(--navy); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.conn { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 8px; color: var(--text); word-break: break-all; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #b5bcc2; display: inline-block; flex: none; }
.dot.ok { background: var(--agua-dark); }
.dot.err { background: var(--red); }

.main { flex: 1; min-width: 0; padding: 22px 28px 40px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card.flush { padding: 0; overflow: hidden; }
.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) 320px; align-items: start; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 13px; border-radius: 8px; cursor: pointer; font: inherit; text-decoration: none; }
.btn:hover { background: var(--celeste); text-decoration: none; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-danger { color: var(--red); border-color: #f1c4c4; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--gray-bg); color: #475569; white-space: nowrap; }
.b-green { background: var(--green-bg); color: var(--green); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-blue { background: var(--celeste-2); color: var(--navy-2); }
.b-purple { background: var(--purple-bg); color: var(--purple); }
.chip { display: inline-block; background: var(--gray-bg); color: #3b4a5c; border-radius: 6px; padding: 0 8px; font-size: 12px; font-weight: 500; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

table.t { width: 100%; border-collapse: collapse; }
table.t th { background: var(--celeste); text-align: left; font-weight: 600; font-size: 12px; color: var(--navy); padding: 9px 12px; border-bottom: 1px solid var(--celeste-2); white-space: nowrap; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: #fafcfe; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 3px; }
.field .err, .errorlist { color: var(--red); font-size: 12px; margin: 3px 0 0; padding: 0; list-style: none; }
input[type=text], input[type=email], input[type=number], input[type=url], input[type=time], input[type=search], input[type=password], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff; color: inherit;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--celeste-2); border-color: var(--accent); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 14px; }
.checks label { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 0; }
.checks input { width: auto; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 150px; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 8px; margin-bottom: 6px; background: var(--celeste); border: 1px solid var(--celeste-2); }
.messages li.error { background: var(--red-bg); border-color: #f1c4c4; color: #8f2a2a; }
.messages li.success { background: var(--green-bg); border-color: #bfe6d1; color: #14683f; }
.messages li.warning { background: var(--amber-bg); border-color: #f2d9a8; color: #7a4e07; }
.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--amber-bg); border: 1px solid #f2d9a8; color: #7a4e07; }
.banner.red { background: var(--red-bg); border-color: #f1c4c4; color: #8f2a2a; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 28px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi .p { font-size: 12px; font-weight: 600; }
.kpi.green .v { color: var(--green); }
.kpi.red .v { color: var(--red); }
.kpi.amber .v { color: var(--amber); }
.kpi.purple .v { color: var(--purple); }

.progress { height: 7px; background: var(--gray-bg); border-radius: 6px; overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: var(--agua-dark); }
.bar-row { display: grid; grid-template-columns: 170px 1fr 56px; gap: 10px; align-items: center; margin-bottom: 8px; }
.bar-row .bar { height: 22px; background: var(--gray-bg); border-radius: 6px; overflow: hidden; }
.bar-row .bar > span { display: block; height: 100%; background: var(--navy); border-radius: 6px; }
.bar-row.warm .bar > span { background: var(--agua-dark); }
.bar-row.cold .bar > span { background: var(--agua); }
.days { display: flex; align-items: flex-end; gap: 4px; height: 120px; }
.days .d { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; height: 100%; }
.days .col { width: 100%; background: var(--navy); border-radius: 3px 3px 0 0; min-height: 1px; }
.days .col.r { background: var(--agua); }
.days .lbl { font-size: 10px; color: var(--muted); }

/* Flujo de la secuencia */
.flow { display: flex; flex-direction: column; align-items: center; gap: 0; }
.node { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; width: 380px; max-width: 100%; box-shadow: 0 1px 2px rgba(18, 53, 91, .06); }
.node .tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 10px; border-radius: 20px; margin-bottom: 6px; }
.node .subj { font-weight: 600; }
.node .prev { color: var(--muted); font-size: 12px; margin-top: 4px; white-space: pre-line; max-height: 54px; overflow: hidden; }
.node.start .tag { background: var(--green-bg); color: var(--green); }
.node.mail .tag { background: var(--celeste-2); color: var(--navy-2); }
.node.cond .tag { background: var(--red-bg); color: var(--red); }
.node.meta-ok .tag { background: var(--purple-bg); color: var(--purple); }
.node.meta-no .tag { background: var(--gray-bg); color: #475569; }
.node.vacio { border-style: dashed; color: var(--muted); }
.link-v { width: 2px; height: 22px; background: #9db2c8; position: relative; }
.link-v::after { content: ""; position: absolute; bottom: -2px; left: -4px; border: 5px solid transparent; border-top: 7px solid #9db2c8; }
.branches { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; width: 100%; max-width: 820px; margin-top: 4px; }
.branch { display: flex; flex-direction: column; align-items: center; }
.branch h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.branch.no h4 { color: var(--red); }
.branch.si h4 { color: var(--green); }

/* Buzón */
.inbox { display: grid; grid-template-columns: 310px minmax(0, 1fr) 280px; gap: 14px; align-items: start; }
.inbox.sin-hilo { grid-template-columns: minmax(0, 1fr); }
.folders-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.folders-bar a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 20px; background: #fff; border: 1px solid var(--line); color: var(--text); text-decoration: none; font-weight: 500; }
.folders-bar a:hover { background: var(--celeste); color: var(--navy); }
.folders-bar a.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.folders-bar .n { background: var(--agua); color: var(--navy); border-radius: 10px; font-size: 11px; font-weight: 700; padding: 0 7px; }
.folders-bar .n.warn { background: var(--amber-bg); color: var(--amber); }
.folders a { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 8px; color: var(--text); margin-bottom: 2px; text-decoration: none; }
.folders a:hover { background: var(--celeste); }
.folders a.on { background: var(--celeste-2); font-weight: 600; }
.hilo { display: block; padding: 11px 14px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.hilo:hover { background: #f7fbfb; text-decoration: none; }
.hilo.on { background: var(--celeste); }
.hilo .who { display: flex; justify-content: space-between; gap: 8px; font-weight: 500; }
.hilo.unread .who { font-weight: 700; }
.hilo .subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hilo .snip { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star { background: none; border: 0; cursor: pointer; font-size: 17px; line-height: 1; color: #c3ccd6; padding: 0 2px; }
.star.on { color: #f5a623; }
.msg { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; background: #fff; overflow: hidden; }
.msg-h { padding: 9px 14px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--navy); }
.msg.out .msg-h { background: var(--celeste); }
.msg.in .msg-h { background: var(--gray-bg); }
.msg-b { padding: 12px 14px; white-space: pre-wrap; word-break: break-word; }
.msg.draft { border-style: dashed; }
.panel-side dt { color: var(--muted); font-size: 12px; margin-top: 10px; }
.panel-side dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--celeste-2); }
.timeline li { position: relative; padding: 0 0 12px 12px; font-size: 12px; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--navy); border: 2px solid #fff; }
.timeline li.t-respuesta::before, .timeline li.t-estado::before { background: var(--agua-dark); }
.timeline li.t-rebote::before, .timeline li.t-baja::before { background: var(--red); }
.timeline li.t-aviso::before { background: var(--amber); }
.timeline .when { color: var(--muted); display: block; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 18px; padding: 20px; background: linear-gradient(180deg, #ffffff 0%, #eef2f4 100%); }
.login-stack { width: 440px; max-width: 100%; }
.login-banner { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 14px; background: #fff; }
.login-banner img { display: block; width: 100%; height: auto; }
.login-card { width: 100%; }
.empty { text-align: center; color: var(--muted); padding: 38px 16px; }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 12px; }
.sel-all { margin-right: 6px; }
.codebox { background: var(--navy); color: #d7e6f7; padding: 10px 12px; border-radius: 8px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; overflow-x: auto; white-space: pre; }
.steps { padding-left: 18px; }
.steps li { margin-bottom: 6px; }

@media (max-width: 1280px) {
  .inbox { grid-template-columns: 300px minmax(0, 1fr); }
  .inbox .panel-col { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; border-right: 0; border-bottom: 3px solid var(--agua); }
  .brand { border-bottom: 0; margin: 0; padding: 2px 6px; }
  .side-foot { border-top: 0; padding: 0; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .side-foot { margin: 0 0 0 auto; }
  .main { padding: 16px; }
  .g2, .g3, .g4, .g-side, .inbox, .inbox.sin-hilo { grid-template-columns: 1fr; }
  .branches { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 46px; }
}

/* Editor de mails */
.ed { border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.ed-top { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--celeste); border-radius: 10px 10px 0 0; }
.ed-body { min-height: 280px; max-height: 60vh; overflow: auto; padding: 14px 16px; outline: none; font: 14px/1.5 Roboto, Arial, sans-serif; color: #2b2b2b; }
.ed-body:empty::before { content: "Escribí el mensaje…"; color: #a0a7ae; }
.ed-body p { margin: 0 0 10px; }
.ed-body img { max-width: 100%; height: auto; }
.ed-body table { border-collapse: collapse; }
.ed-code { width: 100%; min-height: 280px; border: 0; border-radius: 0; font: 12px/1.5 ui-monospace, Consolas, monospace; padding: 14px 16px; background: #fbfcfd; }
.ed-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; padding: 6px 10px; border-top: 1px solid var(--line); background: #fff; border-radius: 0 0 10px 10px; position: relative; }
.ed-bar.off { opacity: .45; pointer-events: none; }
.ed-btn { position: relative; border: 0; background: none; color: var(--text); border-radius: 6px; min-width: 30px; height: 30px; padding: 0 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font: inherit; }
.ed-btn:hover { background: var(--celeste); color: var(--navy); }
.ed-btn.disabled { opacity: .35; }
.ed-btn.txt { font-size: 13px; font-weight: 500; color: var(--navy); background: #fff; border: 1px solid var(--celeste-2); height: 28px; }
.ed-btn.txt:hover { background: var(--celeste-2); }
.ed-btn.txt-b { font-weight: 700; } .ed-btn.txt-i { font-style: italic; font-family: Georgia, serif; } .ed-btn.txt-u { text-decoration: underline; }
.ed-sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }
.ed-select { width: auto; height: 28px; padding: 0 6px; font-size: 13px; border: 1px solid var(--line); background: #fff; }
.ed-menu { position: absolute; bottom: 34px; left: 0; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(18, 63, 103, .15); padding: 4px; min-width: 170px; text-align: left; }
.ed-top .ed-menu { top: 32px; bottom: auto; }
.ed-menu.cols { display: grid; grid-template-columns: repeat(5, 1fr); min-width: 0; width: 190px; }
.ed-menu-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; font: inherit; color: var(--text); }
.ed-menu.cols .ed-menu-item { text-align: center; padding: 4px; font-size: 18px; }
.ed-menu-item:hover { background: var(--celeste); }
.ed-adjuntos { padding: 0 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.ed-adjuntos:not(:empty) { padding: 8px 12px; border-top: 1px solid var(--line); }
.ed-adj { background: var(--gray-bg); border-radius: 6px; padding: 2px 8px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }
.ed-adj-x { border: 0; background: none; cursor: pointer; color: var(--red); padding: 0 2px; }
.var-chip { display: inline-block; background: var(--celeste-2); color: var(--navy); border: 1px solid var(--agua); border-radius: 12px; padding: 0 9px; margin: 0 1px; font-size: 12.5px; font-weight: 500; line-height: 1.6; user-select: all; cursor: default; }

/* Pantalla de secuencia: flujo a la izquierda, editor a la derecha */
.seq-layout { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 18px; align-items: start; }
.seq-flow { position: sticky; top: 14px; max-height: calc(100vh - 28px); overflow: auto; }
.seq-flow .node { width: 100%; cursor: pointer; text-decoration: none; display: block; color: inherit; }
.seq-flow .node:hover { border-color: var(--agua-dark); text-decoration: none; }
.seq-flow .node.activo { border-color: var(--navy); box-shadow: 0 0 0 2px var(--agua); }
.seq-flow .node.cond { cursor: default; }
.seq-flow .flow { align-items: stretch; }
.seq-flow .link-v { align-self: center; }
.seq-panel h2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.asunto-auto { background: var(--gray-bg); border-radius: 8px; padding: 9px 12px; color: var(--muted); }
.vista-previa { width: min(760px, 94vw); border: 0; border-radius: 12px; padding: 0; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.vista-previa::backdrop { background: rgba(18, 63, 103, .45); }
.vista-previa .vp-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.vista-previa .vp-body { padding: 16px 18px; max-height: 62vh; overflow: auto; font: 14px/1.5 Roboto, Arial, sans-serif; }
.vista-previa .vp-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mail-html { word-break: break-word; }
.mail-html p { margin: 0 0 8px; }
.mail-html img { max-width: 100%; height: auto; }
.mail-html table { border-collapse: collapse; }
@media (max-width: 1100px) { .seq-layout { grid-template-columns: 1fr; } .seq-flow { position: static; max-height: none; } }
