/* ChasquiMail — hoja de estilos principal */

:root {
    --bg:            #0e1117;
    --bg-2:          #151a23;
    --bg-3:          #1b212c;
    --panel:         #141922;
    --panel-2:       #1a2029;
    --border:        #262d3a;
    --border-soft:   #1f2632;
    --text:          #e6e9ef;
    --text-2:        #9aa4b6;
    --text-3:        #6b7688;
    --brand:         #6366f1;
    --brand-2:       #818cf8;
    --brand-soft:    rgba(99, 102, 241, .14);
    --accent:        #22d3ee;
    --ok:            #22c55e;
    --ok-soft:       rgba(34, 197, 94, .13);
    --warn:          #f59e0b;
    --warn-soft:     rgba(245, 158, 11, .13);
    --danger:        #ef4444;
    --danger-soft:   rgba(239, 68, 68, .13);
    --radius:        12px;
    --radius-sm:     8px;
    --shadow:        0 10px 30px rgba(0, 0, 0, .35);
    --shadow-sm:     0 2px 8px rgba(0, 0, 0, .25);
    --mono:          ui-monospace, "Cascadia Code", "Fira Code", Consolas, monospace;
    --sans:          "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

html[data-theme="light"] {
    --bg:          #f4f6fb;
    --bg-2:        #ffffff;
    --bg-3:        #eef1f7;
    --panel:       #ffffff;
    --panel-2:     #f7f9fc;
    --border:      #e2e7f0;
    --border-soft: #eef1f6;
    --text:        #16202f;
    --text-2:      #5a6679;
    --text-3:      #8b95a7;
    --shadow:      0 10px 30px rgba(24, 39, 75, .10);
    --shadow-sm:   0 1px 4px rgba(24, 39, 75, .08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 .8rem; }
.ic { vertical-align: -.18em; flex: none; }

/* ------------------------------------------------------------------ *
 *  Estructura
 * ------------------------------------------------------------------ */

.topbar {
    position: sticky; top: 0; z-index: 60;
    display: flex; align-items: center; gap: 14px;
    height: 56px; padding: 0 16px;
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.05rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .logo {
    width: 30px; height: 30px; border-radius: 9px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    color: #fff; box-shadow: 0 4px 14px rgba(99, 102, 241, .4);
}
.brand small { color: var(--text-3); font-weight: 500; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }

.sidebar { position: sticky; top: 74px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin: 14px 0 4px; padding: 0 12px; font-size: .68rem; letter-spacing: .1em;
             text-transform: uppercase; color: var(--text-3); font-weight: 700; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 9px;
    color: var(--text-2); font-weight: 500; font-size: .9rem;
    transition: background .15s, color .15s;
}
.nav a:hover { background: var(--bg-3); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand-2); font-weight: 600; }
.nav a .badge { margin-left: auto; }

.main { min-width: 0; }

/* ------------------------------------------------------------------ *
 *  Tarjetas y superficies
 * ------------------------------------------------------------------ */

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
    overflow: hidden;
}
.card-head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px; border-bottom: 1px solid var(--border-soft);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px; }
.card.flat { box-shadow: none; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; display: flex; align-items: center; gap: 10px; }
.page-head .spacer { margin-left: auto; }
.subtitle { color: var(--text-2); font-size: .88rem; margin: -6px 0 16px; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.tight { gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* Metricas */
.stat {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; position: relative; overflow: hidden;
}
.stat .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em;
               color: var(--text-3); font-weight: 700; }
.stat .value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat .hint  { font-size: .78rem; color: var(--text-2); margin-top: 2px; }
.stat .spark { position: absolute; right: 0; bottom: 0; opacity: .5; }
.stat.brand  { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); }
.stat.brand .value  { color: var(--brand-2); }
.stat.ok .value     { color: var(--ok); }
.stat.warn .value   { color: var(--warn); }
.stat.danger .value { color: var(--danger); }

/* ------------------------------------------------------------------ *
 *  Formularios
 * ------------------------------------------------------------------ */

label, .lbl { display: block; font-size: .8rem; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.field .help { font-size: .76rem; color: var(--text-3); margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], input[type=search], input[type=datetime-local], input[type=date],
select, textarea {
    width: 100%; padding: 9px 11px;
    background: var(--bg-2); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-family: inherit; font-size: .9rem; outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
textarea.code, input.code, .code { font-family: var(--mono); font-size: .84rem; }
select { appearance: none; background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa4b6' stroke-width='2'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat; background-position: right 9px center; padding-right: 30px; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 15px; height: 15px; }
input[type=color] { width: 46px; height: 34px; padding: 2px; background: var(--bg-2);
                    border: 1px solid var(--border); border-radius: var(--radius-sm); }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: .88rem;
         color: var(--text); font-weight: 500; margin-bottom: 9px; cursor: pointer; }
.check input { margin-top: 2px; }
.check span small { display: block; color: var(--text-3); font-weight: 400; font-size: .78rem; }

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 15px; border-radius: var(--radius-sm);
    background: var(--bg-3); color: var(--text);
    border: 1px solid var(--border); font-weight: 600; font-size: .87rem;
    cursor: pointer; font-family: inherit; transition: filter .15s, transform .05s, background .15s;
    text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.14); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--brand), #7c3aed); border-color: transparent; color: #fff;
               box-shadow: 0 4px 14px rgba(99, 102, 241, .3); }
.btn.ok      { background: var(--ok); border-color: transparent; color: #05230f; }
.btn.danger  { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.btn.ghost   { background: transparent; }
.btn.sm      { padding: 6px 10px; font-size: .8rem; }
.btn.lg      { padding: 12px 22px; font-size: .95rem; }
.btn.block   { width: 100%; justify-content: center; }
.btn-group   { display: inline-flex; gap: 6px; }

.seg { display: inline-flex; background: var(--bg-3); border: 1px solid var(--border);
       border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.seg button, .seg a { border: 0; background: transparent; color: var(--text-2); padding: 6px 12px;
                      border-radius: 6px; font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; }
.seg button.active, .seg a.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ *
 *  Tablas
 * ------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .87rem; }
table.tbl th {
    text-align: left; padding: 10px 12px; font-size: .72rem; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-3); font-weight: 700;
    border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--panel-2);
    position: sticky; top: 0; z-index: 1;
}
table.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--panel-2); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl.compact td, table.tbl.compact th { padding: 6px 9px; font-size: .82rem; }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700;
    background: var(--bg-3); color: var(--text-2); border: 1px solid var(--border);
    white-space: nowrap;
}
.badge.ok      { background: var(--ok-soft);     color: var(--ok);     border-color: transparent; }
.badge.warn    { background: var(--warn-soft);   color: var(--warn);   border-color: transparent; }
.badge.danger  { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.brand   { background: var(--brand-soft);  color: var(--brand-2);border-color: transparent; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.empty { text-align: center; padding: 44px 20px; color: var(--text-3); }
.empty .ic { opacity: .35; margin-bottom: 10px; }
.empty h3 { color: var(--text-2); }

.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px;
    font-size: .88rem; border: 1px solid transparent;
}
.alert.info    { background: var(--brand-soft);  color: var(--brand-2); }
.alert.success { background: var(--ok-soft);     color: var(--ok); }
.alert.warning { background: var(--warn-soft);   color: var(--warn); }
.alert.error   { background: var(--danger-soft); color: var(--danger); }
.alert strong { font-weight: 700; }

.progress { height: 9px; border-radius: 99px; background: var(--bg-3); overflow: hidden; }
.progress > i {
    display: block; height: 100%; border-radius: 99px;
    background: linear-gradient(90deg, var(--brand), var(--accent));
    transition: width .4s ease;
}
.progress.thin { height: 5px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .87rem; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    font-family: var(--mono); font-size: .76rem; padding: 3px 9px;
    background: var(--bg-3); border: 1px solid var(--border);
    border-radius: 999px; cursor: pointer; color: var(--text-2);
    transition: all .13s;
}
.chip:hover { background: var(--brand-soft); color: var(--brand-2); border-color: var(--brand); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a, .tabs button {
    padding: 9px 14px; border: 0; background: transparent; color: var(--text-2);
    font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs a.active, .tabs button.active { color: var(--brand-2); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--text); }

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(4, 7, 14, .7);
    display: none; place-items: center; z-index: 200; padding: 20px; backdrop-filter: blur(3px);
}
.modal-backdrop.open { display: grid; }
.modal {
    background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
    box-shadow: var(--shadow); width: min(760px, 100%); max-height: 88vh; overflow: auto;
}
.modal .card-head { position: sticky; top: 0; background: var(--panel); z-index: 2; }

pre.log {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 12px; font-family: var(--mono); font-size: .78rem; max-height: 320px;
    overflow: auto; white-space: pre-wrap; word-break: break-word; color: var(--text-2); margin: 0;
}
.mono { font-family: var(--mono); }
.muted { color: var(--text-3); }
.small { font-size: .8rem; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.hidden { display: none !important; }

/* Vista de acceso */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
             background: radial-gradient(1000px 500px at 20% -10%, rgba(99,102,241,.22), transparent 60%),
                         radial-gradient(900px 500px at 110% 110%, rgba(34,211,238,.16), transparent 55%), var(--bg); }
.auth-card { width: min(430px, 100%); background: var(--panel); border: 1px solid var(--border);
             border-radius: 16px; box-shadow: var(--shadow); padding: 30px; }
.auth-card .brand { justify-content: center; margin-bottom: 6px; font-size: 1.3rem; }

/* Editor de campania */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1050px) { .editor-grid { grid-template-columns: minmax(0, 1fr); } }
.preview-frame { width: 100%; height: 560px; border: 1px solid var(--border);
                 border-radius: var(--radius-sm); background: #fff; }
.mini-frame { width: 100%; height: 220px; border: 0; background: #fff; pointer-events: none; }

.dropzone {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 38px 20px; text-align: center; color: var(--text-2);
    background: var(--panel-2); cursor: pointer; transition: all .18s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-2); }

.map-row { display: grid; grid-template-columns: 1fr 26px 1fr; gap: 10px; align-items: center; margin-bottom: 8px; }
.map-row .arrow { text-align: center; color: var(--text-3); }

.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 99px;
        background: var(--bg-3); border: 1px solid var(--border); font-size: .82rem; color: var(--text-3); font-weight: 600; }
.step b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
          background: var(--border); color: var(--text-2); font-size: .72rem; }
.step.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-2); }
.step.active b { background: var(--brand); color: #fff; }
.step.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.step.done b { background: var(--ok); color: #05230f; }

.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 500;
              display: flex; flex-direction: column; gap: 9px; }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--brand);
         border-radius: var(--radius-sm); padding: 11px 15px; box-shadow: var(--shadow);
         font-size: .87rem; min-width: 240px; animation: slidein .25s ease; }
.toast.ok    { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.send-console {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-family: var(--mono); font-size: .78rem; height: 300px; overflow-y: auto; padding: 10px;
}
.send-console div { padding: 2px 0; border-bottom: 1px solid var(--border-soft); }
.send-console .ok   { color: var(--ok); }
.send-console .err  { color: var(--danger); }

.var-list { max-height: 260px; overflow: auto; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 60px; }
.bars i { flex: 1; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .8; }
.bars i:hover { opacity: 1; }

/* ------------------------------------------------------------------ *
 *  Publicidad: cuatro huecos (arriba, abajo, izquierda, derecha)
 * ------------------------------------------------------------------ */

.ad { display: block; }

.ad-h {                                   /* arriba y abajo */
    max-width: 1720px;
    margin: 14px auto 0;
    padding: 0 16px;
    min-height: 92px;
}
.ad-abajo { margin: 22px auto 0; }

.ad-v {                                   /* izquierda y derecha */
    position: sticky;
    top: 74px;
    width: 160px;
    min-height: 600px;
}

.ad-vacio {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; height: 100%; min-height: inherit; text-decoration: none;
    border: 1px dashed var(--border); border-radius: var(--radius);
    background: repeating-linear-gradient(45deg, transparent, transparent 9px,
                var(--border-soft) 9px, var(--border-soft) 10px);
    color: var(--text-3); transition: border-color .18s, color .18s;
}
.ad-h .ad-vacio { min-height: 90px; flex-direction: row; gap: 14px; }
.ad-vacio:hover { border-color: var(--brand); color: var(--brand-2); text-decoration: none; }
.ad-tag { font-size: .6rem; letter-spacing: .16em; text-transform: uppercase; font-weight: 800; }
.ad-medida { font-family: var(--mono); font-size: .8rem; opacity: .75; }
.ad-cta { font-size: .72rem; font-weight: 600; }

.shell {
    display: grid;
    grid-template-columns: 232px 160px minmax(0, 1fr) 160px;
    gap: 18px;
    max-width: 1720px;
    margin: 0 auto;
    padding: 18px 16px 20px;
    align-items: start;
}

@media (max-width: 1400px) {
    .shell { grid-template-columns: 232px minmax(0, 1fr) 160px; }
    .ad-izquierda { display: none; }
}
@media (max-width: 1150px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .ad-v { display: none; }
    .sidebar { position: static; }
    .nav { flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
    .nav-group { display: none; }
    .nav a { white-space: nowrap; }
    .ad-h { min-height: 60px; }
    .ad-h .ad-vacio { min-height: 58px; }
}

.pie {
    max-width: 1720px; margin: 26px auto 0; padding: 18px 16px 34px;
    border-top: 1px solid var(--border-soft);
    color: var(--text-3); font-size: .78rem; text-align: center;
}

/* Aviso de privacidad de la sesion */
.aviso-sesion {
    display: flex; gap: 11px; align-items: flex-start;
    background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 32%, transparent);
    border-radius: var(--radius); padding: 13px 16px; margin-bottom: 18px;
    font-size: .86rem; color: var(--text);
}
.aviso-sesion b { color: var(--brand-2); }

/* Marca */
.cm-logo { display: block; flex: none; border-radius: 9px;
           box-shadow: 0 4px 14px rgba(99, 102, 241, .32); }
.brand { gap: 11px; }
