/* Tema Latinos FM (idéntico al CRM de latinosia) */
:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F5F5F5;
  --ink: #111111;
  --ink-soft: #333333;
  --muted: #888888;
  --rule: #E5E5E5;
  --rule-soft: #F0F0F0;
  --accent: #FF6600;
  --accent-2: #FF8800;
  --accent-soft: #FFE9D6;
  --accent-ink: #FFFFFF;
  --danger: #e63d32;
  --shadow: 0 1px 0 rgba(26,26,26,.04), 0 14px 38px -16px rgba(26,26,26,.22);
  --radius: 10px;
  --radius-lg: 16px;
  --font-display: 'Outfit', system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ui: 'Nunito Sans', system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-ui); background: var(--bg); color: var(--ink); font-size: 15px; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--surface-2); }
.login-card { background: var(--surface); padding: 36px 32px; border-radius: var(--radius-lg); box-shadow: var(--shadow); width: 100%; max-width: 360px; text-align: center; }
.login-card h1 { margin: 0 0 4px; font-family: var(--font-display); font-size: 24px; }
.login-card .brand-dot { color: var(--accent); }
.login-card p { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.login-card input { width: 100%; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; font-size: 15px; margin-bottom: 12px; }
.login-card .err { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

.btn { border: none; border-radius: 10px; padding: 11px 16px; font-weight: 700; font-size: 14px; background: var(--accent); color: #fff; }
.btn:hover { background: var(--accent-2); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 11px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid #e6c9c7; }

/* Topbar */
header.topbar { background: var(--surface); border-bottom: 1px solid var(--rule); padding: 12px 22px; display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 20; }
header.topbar h1 { font-family: var(--font-display); font-size: 19px; margin: 0; font-weight: 800; }
header.topbar h1 .brand-dot { color: var(--accent); }
header.topbar .spacer { flex: 1; }
.nav-tabs { display: flex; gap: 4px; }
.nav-tab { background: transparent; border: none; color: var(--muted); padding: 7px 14px; border-radius: 8px; font-size: 14px; font-weight: 700; }
.nav-tab.active { background: var(--accent-soft); color: var(--accent); }
.nav-tab:hover { color: var(--ink); }

main { padding: 0; }

/* ===== CRM (réplica latinosia) ===== */
.crm-canvas { padding: 22px 26px 60px; max-width: 1040px; margin: 0 auto; width: 100%; }
.crm-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; }
.crm-tab { background: none; border: none; cursor: pointer; font: inherit; padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 8px 8px 0 0; }
.crm-tab:hover { color: var(--ink); background: var(--surface-2); }
.crm-tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.crm-stats { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.crm-stat { background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 12px 18px; min-width: 110px; }
.crm-stat-num { font-size: 26px; font-weight: 700; line-height: 1.1; }
.crm-stat-lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.crm-stat.ok .crm-stat-num { color: #1a8f4c; }
.crm-stat.warn .crm-stat-num { color: #c9871f; }
.crm-stats--gestion { margin-top: -6px; }
.crm-stats--gestion .crm-stat { padding: 9px 14px; min-width: 96px; }
.crm-stats--gestion .crm-stat-num { font-size: 20px; }
.crm-stat.clickable { cursor: pointer; transition: border-color .12s, background .12s; }
.crm-stat.clickable:hover { border-color: var(--accent); }
.crm-stat.clickable.active { border-color: var(--accent); background: var(--accent-soft); }
.crm-stat.clickable.active .crm-stat-num { color: var(--accent); }

.crm-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.crm-search { display: flex; align-items: center; gap: 8px; flex: 1 1 240px; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 10px; padding: 7px 12px; color: var(--muted); }
.crm-search input { border: none; background: none; outline: none; font: inherit; color: var(--ink); width: 100%; }
.crm-select { font: inherit; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); cursor: pointer; }
.crm-select.sm { padding: 4px 6px; font-size: 12px; }
.crm-btn { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font: inherit; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); }
.crm-btn:hover { background: var(--surface-2); }
.crm-btn.primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 700; }
.crm-btn[disabled] { opacity: .55; cursor: default; }

.crm-list { display: flex; flex-direction: column; gap: 8px; }
.crm-row { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 12px 14px; }
.crm-ava { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%; overflow: hidden; background: var(--surface-2); color: var(--muted); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.crm-ava img { width: 100%; height: 100%; object-fit: cover; }
.crm-main { flex: 1 1 auto; min-width: 0; }
.crm-name { font-weight: 600; }
.crm-name a { color: inherit; text-decoration: none; }
.crm-name a:hover { text-decoration: underline; }
.crm-sub { font-size: 13px; color: var(--ink-soft); margin-top: 1px; }
.crm-contact { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.crm-status { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 0 0 auto; }

.crm-flags { margin-top: 7px; display: flex; gap: 8px; flex-wrap: wrap; }
.crm-flag { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--rule); background: var(--surface-2); color: var(--muted); cursor: pointer; white-space: nowrap; transition: background .12s, color .12s, border-color .12s; }
.crm-flag:hover { border-color: var(--accent); color: var(--ink-soft); }
.crm-flag.on { background: rgba(26,143,76,.14); color: #1a8f4c; border-color: rgba(26,143,76,.35); }
.crm-flag.on.warn { background: rgba(200,60,60,.14); color: var(--danger); border-color: rgba(200,60,60,.35); }

.crm-email-input { font-size: 12px; padding: 2px 8px; border-radius: 8px; border: 1px solid var(--rule); background: var(--surface-2); color: var(--ink-soft); min-width: 180px; max-width: 260px; flex: 0 1 auto; }
.crm-email-input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.crm-notes { display: block; width: 100%; margin-top: 8px; resize: vertical; font: inherit; font-size: 12px; line-height: 1.4; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--rule); background: var(--surface-2); color: var(--ink-soft); min-height: 34px; }
.crm-notes:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.crm-notes::placeholder { color: var(--muted); }

.crm-badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.crm-badge--publicado { background: rgba(26,143,76,.14); color: #1a8f4c; }
.crm-badge--activo { background: rgba(26,143,76,.14); color: #1a8f4c; }
.crm-badge--contactado { background: rgba(201,135,31,.16); color: #c9871f; }
.crm-badge--pendiente { background: var(--surface-2); color: var(--muted); }
.crm-badge--baja { background: rgba(200,60,60,.14); color: var(--danger); }

.crm-empty { padding: 28px; text-align: center; color: var(--muted); }
.crm-hint { margin-top: 14px; padding: 12px 14px; font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: var(--radius-lg); }

@media (max-width: 640px) {
  .crm-canvas { padding: 16px 12px 50px; }
  .crm-row { flex-wrap: wrap; }
  .crm-status { flex-direction: row; align-items: center; width: 100%; justify-content: space-between; }
}

/* ===== Newsletter (mismo tema) ===== */
.nl-tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--rule); }
.nl-tab { background: transparent; border: none; padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.nl-tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.data-list { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--rule); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--rule); cursor: pointer; }
.row:last-child { border-bottom: none; }
.row:hover { background: var(--surface-2); }
.row .nm { font-weight: 600; }
.row .em { color: var(--muted); font-size: 13px; }
.row .spacer { flex: 1; }
.row .pill { font-size: 11px; padding: 2px 9px; border-radius: 999px; background: rgba(26,143,76,.14); color: #1a8f4c; font-weight: 600; }
.row .pill.off { background: rgba(200,60,60,.14); color: var(--danger); }
.row .pill.sent { background: rgba(26,143,76,.14); color: #1a8f4c; }
.row .pill.draft { background: var(--accent-soft); color: var(--accent); }

/* Drawer (campañas / suscriptor) */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: none; }
.drawer-bg.open { display: block; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: 440px; max-width: 100vw; background: var(--surface); z-index: 41; box-shadow: -4px 0 24px rgba(0,0,0,.18); transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer .dh { padding: 16px 20px; border-bottom: 1px solid var(--rule); display: flex; align-items: center; gap: 10px; }
.drawer .dh h2 { margin: 0; font-size: 17px; flex: 1; font-family: var(--font-display); }
.drawer .db { padding: 18px 20px; overflow-y: auto; flex: 1; }
.drawer .df { padding: 14px 20px; border-top: 1px solid var(--rule); display: flex; gap: 10px; flex-wrap: wrap; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .02em; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--rule); border-radius: 8px; font-size: 14px; font-family: inherit; }
.field textarea { resize: vertical; min-height: 60px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--accent); margin: 18px 0 8px; font-weight: 700; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search], .toolbar input[type=text], .toolbar select { padding: 9px 12px; border: 1px solid var(--rule); border-radius: 9px; font-size: 14px; background: var(--surface); }
.toolbar .spacer { flex: 1; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 60; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } .crm-canvas { padding: 14px; } }
