/* ============================================================
   Contacto BCSMS — estilos
   ============================================================ */
:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #dbe1ea;
  --primary: #4f46e5;
  --primary-d: #4338ca;
  --primary-soft: #eef2ff;
  --green: #16a34a; --green-bg: #dcfce7;
  --blue: #2563eb; --blue-bg: #dbeafe;
  --red: #dc2626; --red-bg: #fee2e2;
  --amber: #d97706; --amber-bg: #fef3c7;
  /* radios reducidos: formas más nítidas / menos suavizadas */
  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 8px;
  --pill: 4px;
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 6px 18px rgba(15,23,42,.05);
  --sidebar-w: 244px;
}
html[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #131a2a;
  --ink: #e7ecf3;
  --muted: #93a1b5;
  --line: #263247;
  --primary: #6366f1;
  --primary-d: #818cf8;
  --primary-soft: #20264a;
  --green: #34d399; --green-bg: rgba(16,185,129,.16);
  --blue: #60a5fa; --blue-bg: rgba(59,130,246,.16);
  --red: #f87171; --red-bg: rgba(239,68,68,.16);
  --amber: #fbbf24; --amber-bg: rgba(217,119,6,.18);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 22px rgba(0,0,0,.45);
}
html[data-theme="dark"] .topbar { background: rgba(19,26,42,.85); }
html[data-theme="dark"] .field,
html[data-theme="dark"] .dstat,
html[data-theme="dark"] .perm-grid { background: rgba(255,255,255,.03); }
html[data-theme="dark"] .auth { background: radial-gradient(1200px 600px at 70% -10%, #1e1b4b55, transparent), linear-gradient(135deg, #0b1120, #131a2a); }
html[data-theme="dark"] .table td { border-bottom-color: rgba(255,255,255,.05); }
html[data-theme="dark"] .table--hover tbody tr:hover,
html[data-theme="dark"] .clickable:hover,
html[data-theme="dark"] .nav__item:hover,
html[data-theme="dark"] .btn--ghost:hover,
html[data-theme="dark"] .icon-btn:hover { background: rgba(255,255,255,.05); }

/* icono de línea */
.ic { display: inline-block; vertical-align: -0.18em; flex: 0 0 auto; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { text-decoration: none; color: inherit; }
.muted { color: var(--muted); }
.micro { font-size: 12px; }
.strong { font-weight: 600; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- botones ---------- */
.btn {
  border: 1px solid transparent; border-radius: var(--radius); padding: 9px 16px;
  font-weight: 600; font-size: 13.5px; transition: .15s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; background: #fff; color: var(--ink);
}
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-d); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn--ghost:hover { background: #f8fafc; color: var(--ink); }
.btn--danger { background: var(--red); color: #fff; }
.btn--danger:hover { filter: brightness(.93); }
.btn--danger-soft { background: var(--red-bg); color: var(--red); }
.btn--danger-soft:hover { background: #fecaca; }
.btn--block { width: 100%; justify-content: center; padding: 12px; margin-top: 6px; }
.btn--back { margin-bottom: 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn {
  border: none; background: transparent; border-radius: var(--radius-sm); padding: 6px 8px;
  font-size: 15px; line-height: 1; color: var(--muted); transition: .15s;
}
.icon-btn:hover { background: #f1f5f9; color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ---------- badges / tags ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: var(--pill); font-size: 11.5px; font-weight: 600; background: #f1f5f9; color: var(--muted); }
.badge--green { background: var(--green-bg); color: var(--green); }
.badge--blue  { background: var(--blue-bg); color: var(--blue); }
.badge--red   { background: var(--red-bg); color: var(--red); }
.badge--amber { background: var(--amber-bg); color: var(--amber); }
.tag { display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm); font-size: 11.5px; background: var(--primary-soft); color: var(--primary-d); font-weight: 500; margin: 1px 0; }

/* ============================================================
   LOGIN
   ============================================================ */
.auth { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 70% -10%, #c7d2fe55, transparent), linear-gradient(135deg, #eef2ff, #f8fafc); padding: 20px; }
body.logged .auth { display: none; }
.auth__card { width: 400px; max-width: 100%; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 34px 32px; }
.auth__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand__logo { width: 38px; height: 38px; border-radius: var(--radius); background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 800; }
.brand__name { font-weight: 800; font-size: 18px; }
.brand__name span { color: var(--primary); }
.auth__title { font-size: 22px; }
.auth__sub { color: var(--muted); margin-bottom: 18px; }
.auth__label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
.auth__input { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius); transition: .15s; }
.auth__input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.auth__btn { width: 100%; justify-content: center; margin-top: 18px; padding: 12px; }
.auth__error { color: var(--red); font-size: 13px; min-height: 18px; font-weight: 500; }
.auth__hint { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.auth__demo { text-align: left; background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12px; color: var(--ink); transition: .15s; }
.auth__demo:hover { border-color: var(--primary); background: var(--primary-soft); }

/* ============================================================
   SHELL (sidebar + main)
   ============================================================ */
.sidebar, .main { display: none; }
body.logged .sidebar { display: flex; }
body.logged .main { display: block; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: #fff;
  border-right: 1px solid var(--line); flex-direction: column; padding: 18px 14px; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav__item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius); color: var(--muted); font-weight: 500; transition: .15s; cursor: pointer; }
.nav__item:hover { background: #f8fafc; color: var(--ink); }
.nav__item.is-active { background: var(--primary-soft); color: var(--primary-d); font-weight: 600; }
.nav__icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar__user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--line); }
.avatar { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
.sidebar__user-info { flex: 1; min-width: 0; }
.sidebar__user-info strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__user-info small { color: var(--muted); font-size: 11.5px; }

.main { margin-left: var(--sidebar-w); min-height: 100%; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 14px 26px; display: flex; align-items: center; gap: 14px; }
.topbar__menu { display: none; font-size: 20px; }
.topbar__title h1 { font-size: 19px; }
.topbar__title p { color: var(--muted); font-size: 12.5px; }
.content { padding: 24px 26px 60px; max-width: 1280px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.card__title { font-size: 16px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.kpi__icon { width: 42px; height: 42px; border-radius: var(--radius); background: var(--primary-soft); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.kpi__val { font-size: 24px; font-weight: 800; }
.kpi__label { color: var(--muted); font-size: 12.5px; }
.kpi--green .kpi__icon { background: var(--green-bg); }
.kpi--blue .kpi__icon { background: var(--blue-bg); }
.kpi--red .kpi__icon { background: var(--red-bg); }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table--hover tbody tr:hover, .clickable:hover { background: #f8fafc; cursor: pointer; }
.table .num, .table th.num { text-align: right; }
.table .center { text-align: center; }
.col-check { width: 36px; }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 30px !important; }

/* ---------- toolbar / filtros ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar__filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar__actions { display: flex; gap: 10px; }
.field { display: flex; align-items: center; gap: 7px; background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 11px; }
.field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background: #fff; }
.field input { border: none; background: transparent; padding: 9px 0; outline: none; width: 170px; }
.field span { color: var(--muted); }

.bulkbar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--amber-bg); border: 1px solid #fde68a; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; font-weight: 500; color: #92400e; }
.bulkbar span { flex: 1; }

/* ---------- pager ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; gap: 12px; flex-wrap: wrap; }
.pager__info { color: var(--muted); font-size: 12.5px; }
.pager__btns { display: flex; gap: 4px; align-items: center; }
.pager__btn { min-width: 32px; height: 32px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius-sm); color: var(--ink); font-size: 13px; }
.pager__btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pager__btn.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager__btn:disabled { opacity: .4; cursor: not-allowed; }
.pager__dots { padding: 0 4px; color: var(--muted); }

/* ---------- formularios ---------- */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.form-row > span small { font-weight: 400; }
.form-row input, .form-row select, .form-row textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); transition: .15s; background: #fff; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-row textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-row--full { grid-column: 1 / -1; }
.form-err { color: var(--red); font-size: 12.5px; font-weight: 500; min-height: 16px; }
.form-sub { font-weight: 600; font-size: 13px; margin: 6px 0 10px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 2px 0 10px; }
.hint strong { color: var(--ink); }

.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.check--block { margin-top: 12px; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; background: #f8fafc; border-radius: var(--radius); }
.import-stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 6px; }
.perm-mod { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.perm-mod__head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.perm-mod__sub { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; padding-left: 26px; }
.perm-mod__sub .check { font-size: 13px; color: var(--muted); }

/* ---------- módulo enviar ---------- */
.send-layout { display: grid; grid-template-columns: 1fr 360px; gap: 22px; align-items: start; }
.send-form { margin-bottom: 0; }
.sms-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: -8px 0 14px; }
.send-preview { position: sticky; top: 90px; }
.preview__label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 12px; text-align: center; }

/* ---------- "Personalizar" cantidad ---------- */
.pers { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 2px 0 12px; background: #f8fafc; }
.pers__tabs { display: flex; gap: 20px; margin-bottom: 12px; }
.pers__box { margin: 0; }
.pers__box .form-row { margin-bottom: 0; }
.pers__search input { width: 100%; }
.pers__lista { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px; margin-top: 10px; background: #fff; }
.pers__item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.pers__item:hover { background: var(--primary-soft); }
.pers__item input { width: 16px; height: 16px; accent-color: var(--primary); flex: 0 0 auto; }
.pers__item-main { display: flex; flex-direction: column; line-height: 1.3; font-size: 13.5px; }
.pers__item-main .mono { font-size: 12.5px; }
.linklike { background: none; border: none; color: var(--primary); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
html[data-theme="dark"] .pers { background: rgba(255,255,255,.03); }
html[data-theme="dark"] .pers__lista { background: rgba(0,0,0,.18); }

/* ---------- detalle reporte ---------- */
.detail__grid { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
.detail__stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.dstat { background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; min-width: 96px; }
.dstat__val { font-size: 22px; font-weight: 800; }
.dstat__label { font-size: 12px; color: var(--muted); }
.dstat.is-green .dstat__val { color: var(--green); }
.dstat.is-blue .dstat__val { color: var(--blue); }
.dstat.is-red .dstat__val { color: var(--red); }
.dstat.is-amber .dstat__val { color: var(--amber); }
.detail__list { max-height: 460px; overflow-y: auto; }
.detail__side { position: sticky; top: 90px; }
.detail__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card__title .badge { vertical-align: middle; margin-left: 6px; }

/* ---------- empty-state ---------- */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state__icon { font-size: 44px; margin-bottom: 12px; }
.loading { padding: 40px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- config ---------- */
.cfg__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   MOCKUP DE TELÉFONO (preview en pantalla)
   ============================================================ */
.phone { width: 300px; max-width: 100%; margin: 0 auto; background: #111827; border-radius: 20px; padding: 11px; box-shadow: 0 20px 50px rgba(15,23,42,.25); position: relative; }
.phone__notch { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); width: 120px; height: 22px; background: #111827; border-radius: 0 0 14px 14px; z-index: 3; }
.phone__screen { background: #fff; border-radius: 12px; overflow: hidden; height: 540px; display: flex; flex-direction: column; }
.phone__statusbar { display: flex; justify-content: space-between; padding: 12px 22px 6px; font-size: 12px; font-weight: 600; }
.phone__header { display: flex; align-items: center; gap: 10px; padding: 8px 16px 12px; border-bottom: 1px solid #eef2f7; }
.phone__avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.phone__contact strong { display: block; font-size: 13.5px; }
.phone__contact small { color: var(--muted); font-size: 11.5px; }
.phone__body { flex: 1; padding: 16px 14px; background: #fff; overflow-y: auto; }
.phone__daysep { text-align: center; font-size: 11px; color: #9ca3af; margin-bottom: 14px; }
.bubble { background: #e9e9eb; color: #111827; border-radius: 18px; padding: 11px 14px; font-size: 13.5px; line-height: 1.4; max-width: 80%; width: fit-content; word-wrap: break-word; white-space: pre-wrap; min-height: 20px; }
.bubble__time { font-size: 10.5px; color: #9ca3af; margin-top: 5px; margin-left: 6px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-backdrop.show { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 480px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.modal--lg { width: 620px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal__head h3 { font-size: 16px; }
.modal__body { padding: 20px 22px; overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); }

/* ============================================================
   TOAST
   ============================================================ */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 30px); background: #0f172a; color: #fff; padding: 12px 20px; border-radius: var(--radius); font-size: 13.5px; font-weight: 500; box-shadow: 0 12px 30px rgba(0,0,0,.3); opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: #b45309; }
.toast.err { background: var(--red); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* ============================================================
   GRÁFICOS (SVG inline)
   ============================================================ */
.chart-row { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; }
.chart-legend { display: flex; flex-direction: column; gap: 10px; }
.chart-legend__item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.chart-legend__dot { width: 12px; height: 12px; border-radius: 2px; flex: 0 0 auto; }
.chart-legend__val { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-legend__pct { color: var(--muted); font-size: 12px; min-width: 42px; text-align: right; }
.detail__chart { margin: 4px 0 18px; }
.donut__center { font-weight: 800; }
.bars { width: 100%; }
.bars__label { font-size: 11px; fill: var(--muted); }
.bars__val { font-size: 11px; fill: var(--muted); font-weight: 600; }

/* ============================================================
   AUDITORÍA / botón de tema
   ============================================================ */
.theme-toggle { margin-left: auto; }
.audit-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.audit-toolbar .field input { width: 220px; }
.audit-act { font-weight: 600; }

@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .chart-row { grid-template-columns: 1fr; justify-items: center; }
  .send-layout, .detail__grid { grid-template-columns: 1fr; }
  .send-preview, .detail__side { position: static; max-width: 340px; }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar__menu { display: inline-flex; }
  .content { padding: 16px; }
  .form-grid, .form-grid2, .perm-grid { grid-template-columns: 1fr; }
  .field input { width: 100%; }
  .toolbar__filters { width: 100%; }
}
