/* Leonidas — hoja de estilos precompilada (enterprise look, sin CDN ni build).
   Diseño utilitario + componentes. Pensada para contadores, no técnicos. */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;

  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff4ff;

  --success: #15803d;
  --success-soft: #ecfdf3;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --warning: #b45309;
  --warning-soft: #fffbeb;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

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

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

/* ── Layout ─────────────────────────────────────────────────────────── */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 24px;
  height: 60px; display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text); letter-spacing: -.01em; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  color: #fff; display: grid; place-items: center; font-size: 17px; font-weight: 800;
}
.brand .brand-sub { font-weight: 400; font-size: 12px; color: var(--text-muted); display: block; margin-top: -2px; }
.brand .logo-img { width: 34px; height: 34px; border-radius: 8px; object-fit: contain; flex: none; }

.nav { display: flex; gap: 4px; }
.nav a {
  padding: 8px 14px; border-radius: var(--radius-sm); color: var(--text-muted);
  font-weight: 500; font-size: 14px; text-decoration: none; transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }

.main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }

.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--text-muted); font-size: 14px; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 24px; margin-bottom: 20px;
}
.card h2 { font-size: 16px; font-weight: 600; margin: 0 0 16px; }
.card h2:not(:first-child) { margin-top: 8px; }
.card .card-sub { color: var(--text-muted); font-size: 13px; margin: -10px 0 16px; }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-family: var(--font); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s; text-decoration: none;
}
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #991b1b; text-decoration: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #166534; text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { display: flex; width: 100%; }

/* ── Forms ──────────────────────────────────────────────────────────── */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.help { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

input[type="text"], input[type="tel"], input[type="url"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font-family: var(--font); font-size: 14px; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, .12);
}
textarea { resize: vertical; min-height: 90px; font-family: var(--font); }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }
.inline-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; font-size: 14px; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 40px; height: 22px; border-radius: 999px; background: var(--border); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* ── Dropzone (upload) ──────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface-2); padding: 40px 24px; text-align: center;
  transition: border-color .15s, background .15s; cursor: pointer;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .dz-icon { font-size: 34px; }
.dropzone .dz-title { font-weight: 600; margin-top: 8px; }
.dropzone .dz-hint { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.dropzone input[type="file"] { display: none; }
.file-list { list-style: none; margin: 14px 0 0; padding: 0; text-align: left; }
.file-list li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 6px; font-size: 13px; }

/* ── Badges / status ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.4;
}
.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-err { background: var(--danger-soft); color: var(--danger); }
.badge-warn { background: var(--warning-soft); color: var(--warning); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); }
.badge-info { background: var(--primary-soft); color: var(--primary); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--success); }
.dot-err { background: var(--danger); }
.dot-warn { background: var(--warning); }

/* ── Alerts ─────────────────────────────────────────────────────────── */
.alert { border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 14px; font-size: 14px; border: 1px solid transparent; }
.alert-title { font-weight: 700; margin-bottom: 2px; }
.alert-ok { background: var(--success-soft); border-color: #bbf7d0; color: #14532d; }
.alert-err { background: var(--danger-soft); border-color: #fecaca; color: #7f1d1d; }
.alert-warn { background: var(--warning-soft); border-color: #fde68a; color: #78350f; }
.alert-info { background: var(--primary-soft); border-color: #bfdbfe; color: #1e3a8a; }

/* ── Tables ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { background: var(--surface-2); text-align: left; font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 11px 16px; border-bottom: 1px solid var(--border); }
tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ── Progress + log ─────────────────────────────────────────────────── */
.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.progress .bar { height: 100%; background: var(--primary); width: 0; transition: width .3s ease; }
.progress.done .bar { background: var(--success); }
.log {
  background: #0f172a; color: #e2e8f0; border-radius: var(--radius-sm);
  padding: 14px 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  max-height: 320px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.log:empty::after { content: "Esperando…"; color: var(--text-soft); }

/* ── JSON / result rendering ────────────────────────────────────────── */
.result-item { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.result-head .fname { font-weight: 600; font-size: 14px; }
.result-head .ftype { color: var(--text-muted); font-size: 13px; }
.kv { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 1px; background: var(--border); }
.kv > div { background: var(--surface); padding: 8px 16px; font-size: 13px; }
.kv .k { color: var(--text-muted); font-weight: 500; }
.kv .v { font-weight: 500; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; margin: 0; }

/* ── Details / expander ─────────────────────────────────────────────── */
details.expander { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px; background: var(--surface); }
details.expander > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 14px; list-style: none; }
details.expander > summary::-webkit-details-marker { display: none; }
details.expander > summary::before { content: "▸ "; color: var(--text-muted); }
details.expander[open] > summary::before { content: "▾ "; }
details.expander > .expander-body { padding: 0 14px 14px; }

/* ── Utilities ──────────────────────────────────────────────────────── */
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 16px; }
.divider { height: 1px; background: var(--border); border: none; margin: 24px 0; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.qr-img { max-width: 280px; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* htmx loading indicators */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
.spinner-dark { border-color: rgba(15,23,42,.2); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Dashboard tiles ────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px 20px; }
.tile .tile-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; }
.tile .tile-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; line-height: 1.1; }
.tile .tile-value.ok { color: var(--success); }
.tile .tile-value.warn { color: var(--warning); }
.tile .tile-value.primary { color: var(--primary); }
.tile .tile-foot { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

/* ── Banner de estado de conexión ──────────────────────────────────── */
.status-banner { display: flex; align-items: center; gap: 18px; padding: 20px 22px; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); background: var(--surface); }
.status-banner .status-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 25px; flex: none; }
.status-banner .status-body { flex: 1; min-width: 0; }
.status-banner .status-title { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.status-banner .status-desc { color: var(--text-muted); font-size: 13.5px; margin-top: 3px; }
.status-banner .status-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.status-banner.tone-ok { border-color: #bbf7d0; background: linear-gradient(180deg, #f4fdf7, var(--surface)); }
.status-banner.tone-ok .status-icon { background: var(--success-soft); color: var(--success); }
.status-banner.tone-err { border-color: #fecaca; background: linear-gradient(180deg, #fef5f5, var(--surface)); }
.status-banner.tone-err .status-icon { background: var(--danger-soft); color: var(--danger); }
.status-banner.tone-warn { border-color: #fde68a; background: linear-gradient(180deg, #fffdf3, var(--surface)); }
.status-banner.tone-warn .status-icon { background: var(--warning-soft); color: var(--warning); }
.status-banner.tone-muted .status-icon { background: var(--surface-2); color: var(--text-muted); }

/* Botón sólo-ícono con tooltip */
.icon-btn { width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--text-muted); transition: background .12s, color .12s, border-color .12s; }
.icon-btn:hover { background: var(--surface-2); color: var(--primary); border-color: var(--primary); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.spinning svg { animation: spin .7s linear infinite; }

[data-tooltip] { position: relative; }
[data-tooltip]:hover::after { content: attr(data-tooltip); position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; font-size: 12px; font-weight: 500; padding: 5px 9px; border-radius: 6px; white-space: nowrap; z-index: 40; pointer-events: none; box-shadow: var(--shadow-md); }
[data-tooltip]:hover::before { content: ""; position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: #0f172a; z-index: 40; }

/* ── Chips (selector de plantilla) ─────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; transition: .12s; font-family: var(--font); }
.chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.chip.chip-plain { border-style: dashed; color: var(--text-muted); }

/* ── Modal (native <dialog>) ───────────────────────────────────────── */
dialog.modal { border: none; border-radius: var(--radius); padding: 0; max-width: 480px; width: calc(100% - 32px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(15, 23, 42, .3); }
dialog.modal::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-x { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; padding: 0; }
.modal-x:hover { color: var(--text); }
.modal-body { padding: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* Grupo indicativo + número */
.phone-group { display: flex; gap: 8px; }
.phone-group select { flex: 0 0 auto; width: auto; min-width: 130px; }
.phone-group input { flex: 1; }

/* ── Toasts ─────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--surface); color: var(--text); box-shadow: 0 8px 24px rgba(15, 23, 42, .18); border-left: 4px solid var(--text-soft); font-size: 14px; font-weight: 500; cursor: pointer; opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast .toast-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; color: #fff; flex: none; }
.toast-ok { border-left-color: var(--success); }
.toast-ok .toast-icon { background: var(--success); }
.toast-err { border-left-color: var(--danger); }
.toast-err .toast-icon { background: var(--danger); }
.toast-warn { border-left-color: var(--warning); }
.toast-warn .toast-icon { background: var(--warning); }
.toast-info { border-left-color: var(--primary); }
.toast-info .toast-icon { background: var(--primary); }

/* Acciones por fila en tablas */
.row-actions { display: flex; gap: 6px; align-items: center; }

/* Ícono dentro de un botón con texto */
.btn-icon { width: 16px; height: 16px; flex: none; }

/* Lista de selección de destinatarios (envío masivo) */
.sel-list { max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.sel-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 14px; }
.sel-item:last-child { border-bottom: none; }
.sel-item:hover { background: var(--surface-2); }
.sel-item.disabled { opacity: .55; cursor: not-allowed; }
.sel-item .sel-name { font-weight: 500; }
.sel-item .badge { margin-left: auto; }
.sel-cb { width: 17px; height: 17px; flex: none; accent-color: var(--primary); cursor: pointer; }
.sel-item.disabled .sel-cb { cursor: not-allowed; }

/* ── Login ──────────────────────────────────────────────────────────── */
.login-wrap { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-theme { position: absolute; top: 20px; right: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 32px 28px; text-align: center; }
.login-logo { width: 64px; height: 64px; object-fit: contain; border-radius: 14px; margin-bottom: 12px; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }
.login-card > p { margin: 0 0 20px; }
.login-card form { text-align: left; }
.login-card .field { margin-bottom: 16px; }

/* ── Tema oscuro ────────────────────────────────────────────────────── */
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #141c2b;
  --surface-2: #1c2740;
  --border: #2a3852;
  --text: #e6edf6;
  --text-muted: #9fb0c3;
  --text-soft: #6b7d93;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft: #17233b;

  --success: #34d399;
  --success-soft: #0f2a20;
  --danger: #f87171;
  --danger-soft: #2c1616;
  --warning: #fbbf24;
  --warning-soft: #2a2006;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .5);
}
/* Componentes con colores fijos que hay que ajustar en oscuro */
:root[data-theme="dark"] .alert-ok { border-color: #14532d; color: #86efac; }
:root[data-theme="dark"] .alert-err { border-color: #7f1d1d; color: #fca5a5; }
:root[data-theme="dark"] .alert-warn { border-color: #78350f; color: #fcd34d; }
:root[data-theme="dark"] .alert-info { border-color: #1e3a8a; color: #93c5fd; }
:root[data-theme="dark"] .status-banner.tone-ok { background: var(--surface); border-color: #14532d; }
:root[data-theme="dark"] .status-banner.tone-err { background: var(--surface); border-color: #7f1d1d; }
:root[data-theme="dark"] .status-banner.tone-warn { background: var(--surface); border-color: #78350f; }
:root[data-theme="dark"] .modal-target { color: #93c5fd; }
:root[data-theme="dark"] .sel-cb { accent-color: var(--primary); }

/* ── Switch de tema, logout y menú responsive del header ────────────── */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.logout-btn { color: var(--danger); }
.logout-btn:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); text-decoration: none; }

.nav-hamburger { display: none; }

@media (max-width: 760px) {
  .header-menu {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 16px; box-shadow: var(--shadow-md);
  }
  .header-menu.open { display: flex; }
  .header-menu a { padding: 11px 12px; }
  .nav-hamburger { display: grid; }
}

/* Filas de contacto clickables */
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }

/* Input con prefijo fijo (+57) */
.input-prefix { display: flex; }
.input-prefix .prefix { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--surface-2); color: var(--text-muted); font-weight: 600; font-size: 14px; white-space: nowrap; }
.input-prefix input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* Tooltip que abre hacia la izquierda (evita desbordar el borde derecho del modal) */
.tip-left[data-tooltip]:hover::after { top: 50%; bottom: auto; left: auto; right: calc(100% + 8px); transform: translateY(-50%); }
.tip-left[data-tooltip]:hover::before { top: 50%; bottom: auto; left: auto; right: calc(100% + 3px); transform: translateY(-50%); border: 5px solid transparent; border-left-color: #0f172a; }

/* Encabezado del modal de contacto */
.contact-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.contact-avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 19px; font-weight: 700; flex: none; }
.contact-head .contact-name { font-weight: 700; font-size: 16px; }
.contact-head .contact-meta { font-size: 13px; color: var(--text-muted); }

.modal-target { background: var(--primary-soft); color: #1e3a8a; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14px; margin-bottom: 14px; }
.modal-target strong { font-weight: 700; }

/* ── Tarjetas de plantillas ────────────────────────────────────────── */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tpl-card { display: flex; flex-direction: column; min-height: 160px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px; transition: box-shadow .15s, transform .15s; }
.tpl-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.tpl-card .tpl-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tpl-card .tpl-name::before { content: "📝"; }
.tpl-card .tpl-text { color: var(--text-muted); font-size: 13px; white-space: pre-wrap; word-break: break-word; flex: 1; overflow: hidden; }
.tpl-card .tpl-actions { margin-top: 14px; display: flex; justify-content: flex-end; }
.tpl-add { display: grid; place-items: center; text-align: center; gap: 6px; min-height: 160px; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text-muted); font-weight: 600; cursor: pointer; transition: .15s; }
.tpl-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.tpl-add .tpl-add-plus { font-size: 30px; font-weight: 400; line-height: 1; }
.empty-hint { color: var(--text-muted); font-size: 14px; }

@media (max-width: 640px) {
  .status-banner { flex-wrap: wrap; }
  .topbar-inner { padding: 0 16px; gap: 14px; }
  .brand .brand-sub { display: none; }
  .main { padding: 20px 16px 48px; }
  .kv { grid-template-columns: 1fr; }
}
