/* Saosao — panel administrativo. Paleta de marca:
   chocolate #6B4A3B · ocre #D9A760 · ciruela #8B4B5A · crema #F8F3EA */
:root {
  --blue: #6b4a3b;   /* chocolate natural (primario) */
  --yellow: #d9a760; /* ocre luminoso */
  --red: #8b4b5a;    /* ciruela artesanal */
  --graphite: #3a2820;
  --ink: #3a2820;
  --muted: #7d6a5c;
  --line: #e7dccd;
  --bg: #f8f3ea;
  --card: #ffffff;
  --green: #15803d;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}
a { color: var(--blue); text-decoration: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }

.app { display: flex; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 244px;
  flex-shrink: 0;
  background: var(--graphite);
  color: #e2d4c4;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 8px 18px;
}
.sidebar__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue);
  color: var(--yellow);
  font-weight: 800;
}
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #e2d4c4;
  font-weight: 500;
}
.sidebar__link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar__link.is-active { background: var(--blue); color: #fff; }
.sidebar__icon {
  width: 20px;
  text-align: center;
  opacity: 0.9;
}
.sidebar__foot {
  margin-top: auto;
  padding: 12px 10px 0;
  font-size: 12px;
  color: #b39e8c;
}
.sidebar__foot code { color: var(--yellow); }

/* ---------------- Content ---------------- */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 18px 28px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.topbar h1 { margin: 0; font-size: 20px; }
.topbar__env { color: var(--muted); font-size: 12px; }
.page { padding: 24px 28px 48px; }

.banner {
  margin: 18px 28px 0;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
}
.banner--warn {
  background: #fef3c7;
  border: 1px solid var(--yellow);
  color: #92400e;
}
.banner--ok {
  background: #dcfce7;
  border: 1px solid var(--green);
  color: #166534;
}

/* ---------------- Stats ---------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat__label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat__value { font-size: 22px; font-weight: 700; }
.stat--good .stat__value { color: var(--green); }
.stat--bad .stat__value { color: var(--red); }

/* ---------------- Cards & tables ---------------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 18px;
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.card__head h2 { margin: 0; font-size: 15px; }
.card__body { padding: 18px; }

.pager {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 0 4px;
  font-size: 13px;
}
.pager a { text-decoration: none; }

/* ---------------- Edición masiva ---------------- */
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--blue);
  background: #f3eadf;
  border-radius: 10px;
  font-size: 13px;
}
.bulk-bar select,
.bulk-bar input {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}
.bulk-bar input[type='number'] { width: 150px; }
.bulk-bar__count { margin-right: 4px; }
.bulk-bar__msg { color: var(--red); font-size: 12px; }

th.chk, td.chk { width: 34px; text-align: center; padding-left: 12px; padding-right: 4px; }
th.chk input, td.chk input { cursor: pointer; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: #fafbfc;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f9fafb; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.pos { color: var(--green); }
.neg { color: var(--red); }
td.empty { text-align: center; color: var(--muted); padding: 26px; }
.row--alert { background: #fff7ed; }
.row--alert:hover { background: #ffedd5; }

/* ---------------- Tags ---------------- */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #f3eadf;
  color: var(--blue);
  text-transform: capitalize;
}
.tag--active, .tag--sent, .tag--completed, .tag--subscribed, .tag--income { background: #dcfce7; color: var(--green); }
.tag--draft, .tag--pending, .tag--paused { background: #fef9c3; color: #854d0e; }
.tag--archived, .tag--cancelled, .tag--void, .tag--unsubscribed, .tag--bounced, .tag--expense { background: #fee2e2; color: var(--red); }
.tag--scheduled, .tag--sending { background: #efe2d3; color: var(--blue); }

.code {
  background: var(--graphite);
  color: var(--yellow);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ---------------- Filters ---------------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.filters input,
.filters select {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}
.filters button,
.btn {
  padding: 9px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.filters button:hover, .btn:hover { background: #4f3529; }

.hint { color: var(--muted); font-size: 12px; }
.hint code { background: #f3eadf; padding: 2px 6px; border-radius: 5px; color: var(--blue); }

/* ---------------- Error page ---------------- */
.error-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.error-card { max-width: 420px; text-align: center; padding: 32px; }
.error-card h2 { font-size: 48px; margin: 0 0 8px; color: var(--blue); }
.error-card .btn { display: inline-block; margin-top: 14px; }

@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar__nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar__foot { display: none; }
}

/* ---------------- Botones extra ---------------- */
.btn--ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn--ghost:hover { background: #f3f4f6; }
.btn--danger { background: var(--red); }
.btn--danger:hover { background: #b91c1c; }
.btn--danger-ghost { background: #fff; color: var(--red); border: 1px solid #fecaca; }
.btn--danger-ghost:hover { background: #fef2f2; }
.btn--sm { padding: 6px 11px; font-size: 12px; }
.btn.is-busy { opacity: 0.6; pointer-events: none; }
.btn[disabled] { opacity: 0.6; cursor: default; }

td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 6px; }

/* ---------------- Modales ---------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  background: rgba(58, 40, 32, 0.55);
  overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal__box {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.4);
  animation: modal-in 0.14s ease-out;
}
.modal__box--sm { max-width: 420px; }
@keyframes modal-in {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal__head h3 { margin: 0; font-size: 16px; }
.modal__x {
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.modal__x:hover { color: var(--ink); }
.modal__body { padding: 18px 20px; }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
  border-radius: 0 0 14px 14px;
}
.modal__error {
  list-style: none;
  margin: 0 0 14px;
  padding: 10px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 8px;
  font-size: 13px;
}
.modal__error li { margin-left: 14px; list-style: disc; }
.modal__error[hidden] { display: none; }

/* ---------------- Formularios ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.field[hidden] { display: none; }
.field--wide { grid-column: 1 / -1; }
.field > span { color: var(--muted); font-weight: 600; }
.field input,
.field select,
.field textarea {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid #d8c6b4;
  border-color: var(--blue);
}
.field--check { flex-direction: row; align-items: center; gap: 8px; }
.field--check input { width: auto; }
.field--check span { color: var(--ink); font-weight: 500; }
.field select[multiple] { height: 120px; padding: 4px; }
.field small { color: var(--muted); font-size: 11px; }

/* ---------------- Login ---------------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--graphite);
}
.login-card h1 { margin: 8px 0 0; font-size: 18px; }
.login-sub { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}
.btn--block { width: 100%; margin-top: 6px; }

.sidebar__logout {
  margin-top: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: transparent;
  color: #e2d4c4;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.sidebar__logout:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar__who { font-size: 12px; color: #b39e8c; padding: 0 10px 6px; }

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------------- Widget de subida de imágenes ---------------- */
.upload-widget__row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.upload-widget__preview {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f3f4f6;
  flex-shrink: 0;
}
.upload-widget__actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.upload-widget label.btn {
  align-self: flex-start;
  cursor: pointer;
}
.upload-widget__status {
  font-size: 12px;
  color: var(--muted);
}
.upload-widget__status.is-error { color: var(--red); }
.upload-widget__hint { font-size: 11px; color: var(--muted); }
