:root {
  --bg: #f9f4e8; --card: #fff; --text: #171717; --muted: #746c64; --line: #eadfcf;
  --primary: #281c11; --primary-dark: #000; --navy: #281c11; --sky: #bc8e5b; --accent: #836c57; --soft: #f3ecda;
  --ok: #15803d; --warn: #b45309; --err: #b91c1c;
  --font: "Karla", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-title: "Futura", "Jost", var(--font);
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 var(--font); background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-title); font-weight: 500; color: var(--navy); letter-spacing: .01em; }
h1 { font-size: 26px; font-weight: 500; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 32px 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
code { background: var(--soft); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

.top { display: flex; align-items: center; gap: 28px; background: #fff; border-bottom: 3px solid var(--sky); padding: 0 24px; height: 72px; }
.top .brand { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.top .brand:hover { text-decoration: none; }
.top .brand img { height: 44px; width: auto; display: block; }
.top nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; font-family: var(--font); }
.top nav a { color: var(--text); font-weight: 600; font-size: 14px; padding: 7px 14px; border-radius: 3px; }
.top nav a:hover { color: var(--sky); text-decoration: none; }
.top nav a.on { background: var(--primary); color: #fff; }
.top .logout .link { color: var(--muted); font-weight: 600; }
.login-logo { display: block; width: 190px; height: auto; margin: 4px auto 24px; }

main { max-width: 1100px; margin: 0 auto; padding: 28px 16px 64px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin: 0 0 16px; }
.card.narrow { max-width: 420px; margin: 10vh auto 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row h1, .row h2, .row h3 { margin-bottom: 8px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.actions, .actions form { display: flex; gap: 8px; align-items: center; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--sky); border-radius: 10px; padding: 14px 16px; }
.tile span { display: block; color: var(--muted); font-size: 13px; }
.tile strong { font-size: 26px; font-weight: 700; color: var(--navy); }
.tile small { font-size: 14px; color: var(--muted); font-weight: 400; }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fcfaf5; }
tr:last-child td { border-bottom: 0; }
td form { margin: 0; }

label { display: block; margin: 0 0 14px; font-weight: 600; font-size: 14px; }
label.check { font-weight: 400; display: flex; gap: 8px; align-items: center; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=file], select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; font-weight: 400;
  border: 1px solid #dccbb5; border-radius: 4px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sky); outline-offset: 0; border-color: var(--primary); }
textarea.code { font: 13px/1.45 ui-monospace, Consolas, monospace; }
.filters { display: flex; gap: 8px; margin: 0 0 16px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; flex: 1; min-width: 160px; margin-top: 0; }

.btn { display: inline-block; padding: 9px 20px; border: 2px solid var(--primary); border-radius: 3px; background: #fff; color: var(--primary); font: inherit; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; cursor: pointer; }
.btn:hover { background: var(--soft); text-decoration: none; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
button.link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #e5e7eb; color: #374151; vertical-align: middle; }
.badge.active, .badge.sent, .badge.finished, .badge.info { background: #dcfce7; color: var(--ok); }
.badge.sending { background: var(--soft); color: var(--primary-dark); }
.badge.paused, .badge.warn, .badge.skipped, .badge.pending { background: #fef3c7; color: var(--warn); }
.badge.bounced, .badge.failed, .badge.error, .badge.unsubscribed { background: #fee2e2; color: var(--err); }

.flash { padding: 12px 16px; border-radius: 8px; margin: 0 0 16px; background: #dcfce7; color: #14532d; }
.flash.error { background: #fee2e2; color: #7f1d1d; }
.bar { height: 10px; background: #e5e7eb; border-radius: 99px; overflow: hidden; margin: 10px 0; }
.bar div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--sky)); }
.preview { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.pager { display: flex; gap: 16px; justify-content: center; align-items: center; color: var(--muted); }

@media (max-width: 640px) {
  .top { height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .top .brand span { display: none; }
  table { display: block; overflow-x: auto; }
}

/* Editor de campaña: HTML a la izquierda, vista previa en vivo a la derecha */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.editor-pane { display: flex; flex-direction: column; margin: 0 0 16px; }
.editor-pane textarea { flex: 1; min-height: 620px; margin: 8px 0; resize: vertical; white-space: pre; overflow: auto; }
.preview-wrap { flex: 1; min-height: 620px; margin: 8px 0; background: #efe7d6; border: 1px solid var(--line); border-radius: 8px; display: flex; justify-content: center; overflow: hidden; }
.preview-wrap iframe { width: 100%; height: 100%; min-height: 620px; border: 0; background: #fff; transition: width .2s; }
.toggle { display: inline-flex; border: 2px solid var(--primary); border-radius: 3px; overflow: hidden; }
.toggle button { border: 0; background: #fff; color: var(--primary); font: inherit; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 5px 14px; cursor: pointer; }
.toggle button.on { background: var(--primary); color: #fff; }
details.card summary { cursor: pointer; font-weight: 600; }
details.card textarea { margin-top: 8px; }
main:has(.editor) { max-width: 1500px; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } }

/* Biblioteca de imágenes */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.image-card { margin: 0; padding: 12px; }
.image-card img { width: 100%; height: 150px; object-fit: cover; border-radius: 6px; display: block; background: #efe7d6; }
.image-card p { margin: 8px 0; }
.image-card input[type=text] { font-size: 12px; padding: 6px 8px; margin: 0 0 10px; }
.image-card .btn { padding: 6px 14px; font-size: 12px; }

input[type=datetime-local] { display: block; width: 100%; padding: 9px 11px; font: inherit; border: 1px solid #dccbb5; border-radius: 4px; background: #fff; color: var(--text); }
label.check input[type=radio] { width: 16px; height: 16px; }

.btn.danger { border-color: var(--err); color: var(--err); }
.btn.danger:hover { background: #fdecec; }
button.link.danger { color: var(--err); }
.row-actions { display: flex; gap: 14px; align-items: center; margin: 0; }

/* Listas y acciones en bloque */
.bulk { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; background: var(--soft); border-color: #e4d0bb; }
.bulk select, .bulk input[type=text] { width: auto; flex: 1; min-width: 170px; margin-top: 0; }
.bulk label.check { margin: 0; flex-basis: 100%; font-size: 13px; }
.badge.list { background: #efe4d3; color: var(--navy); font-weight: 500; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0 0 16px; }
.checks label.check { margin: 0; }
th input[type=checkbox], td input[type=checkbox] { width: 16px; height: 16px; }
