/* === Paytech MDM · tema Sipay ===
   Minimalista, fondo claro, texto negro, gris secundario, Inter, primario #F45227. */

:root {
  --sipay-primary: #F45227;
  --sipay-primary-dark: #d43e17;
  --ink: #111111;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #fafafa;
  --surface: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(17, 17, 17, .05), 0 8px 24px rgba(17, 17, 17, .04);
  --space: 24px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

:root { --surface-2: #fbfbfb; --hover: #faf7f5; }

/* Modo oscuro (se activa con data-theme="dark" en <html>). */
:root[data-theme="dark"] {
  --ink: #e6e8ec;
  --muted: #9aa3b2;
  --line: #2a2f39;
  --bg: #0f1116;
  --surface: #171b22;
  --surface-2: #1e232c;
  --hover: #20252f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
.muted { color: var(--muted); }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f3f4f6; padding: 2px 6px; border-radius: 6px; font-size: .9em;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: var(--space);
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { font-weight: 600; font-size: 1.15rem; color: var(--ink); }
.brand-sub {
  font-weight: 600; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase;
  color: #fff; background: var(--sipay-primary); padding: 2px 7px; border-radius: 6px;
}
.topnav { display: flex; gap: 6px; margin-left: 8px; }
.navlink {
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: .92rem;
  padding: 6px 10px; border-radius: 8px;
}
.navlink:hover { background: #f3f4f6; color: var(--ink); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 500; font-size: .92rem; }
.logout-form { margin: 0; }

/* Badges */
.badge {
  display: inline-block; font-size: .72rem; font-weight: 500;
  padding: 2px 9px; border-radius: 999px;
}
.badge-role { background: #f3f4f6; color: var(--muted); border: 1px solid var(--line); }

/* Content */
.content { max-width: 1120px; margin: 0 auto; padding: 40px 28px; }
.page-head { margin-bottom: 28px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card p { margin: .4em 0; }
.card-accent { border-top: 3px solid var(--sipay-primary); }

/* Accordion por aplicación (pestaña Configuración) */
.app-accordion { padding: 0; }
.app-accordion > .app-accordion-summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: baseline; gap: 12px;
  padding: 18px 22px; border-radius: var(--radius);
}
.app-accordion > .app-accordion-summary::-webkit-details-marker { display: none; }
.app-accordion > .app-accordion-summary::before {
  content: "▸"; color: var(--muted); font-size: .9rem; transition: transform .15s;
}
.app-accordion[open] > .app-accordion-summary::before { transform: rotate(90deg); }
.app-accordion[open] > .app-accordion-summary { border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.app-accordion-summary:hover { background: var(--hover); }
.app-accordion-title { font-weight: 600; font-size: 1.1rem; letter-spacing: -0.01em; }
.app-accordion-body { padding: 18px 22px; }

/* Buttons */
.btn {
  font-family: var(--font); font-weight: 500; font-size: .92rem; cursor: pointer;
  border: 1px solid transparent; border-radius: 8px; padding: 9px 16px;
}
.btn-primary { background: var(--sipay-primary); color: #fff; }
.btn-primary:hover { background: var(--sipay-primary-dark); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); background: #f3f4f6; }

/* Messages */
.messages { margin-bottom: 20px; display: grid; gap: 8px; }
.message { padding: 10px 14px; border-radius: 8px; font-size: .92rem; }
.message.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.message.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* Toasts superiores (avisos no bloqueantes) */
.toasts {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 10px; align-items: center;
  width: max-content; max-width: 92vw; pointer-events: none;
}
.toast {
  pointer-events: auto; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  background: #eff6ff; color: #1e3a8a;
  border: 1px solid #bfdbfe; border-left: 6px solid #2563eb;
  border-radius: 10px; box-shadow: 0 6px 24px rgba(17,17,17,.14);
  padding: 16px 22px; font-size: 1rem; font-weight: 500; line-height: 1.35;
  min-width: 420px; max-width: 680px;
  opacity: 0; transform: translateY(-10px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-icon { font-size: 1.3rem; flex: 0 0 auto; }
.toast-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; border-left-color: #dc2626; }
.toast-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; border-left-color: #16a34a; }
:root[data-theme="dark"] .toast { background: var(--surface-2); color: var(--ink); border-color: var(--line); }

/* Login */
.login-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 36px;
}
.brand-login { justify-content: center; margin-bottom: 6px; }
.login-lead { text-align: center; margin: 0 0 24px; }
.login-form { display: grid; gap: 6px; }
.login-form label { font-size: .85rem; font-weight: 500; margin-top: 10px; }
.login-form input {
  font-family: var(--font); font-size: .95rem; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.login-form input:focus { outline: 2px solid var(--sipay-primary); border-color: transparent; }
.login-form .btn-primary { margin-top: 18px; }

/* Estado UNKNOWN — muy identificable */
.badge-unknown {
  background: var(--sipay-primary); color: #fff; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
.badge-online { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-offline { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-original { background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; font-weight: 600; }

/* Leyenda de estados (parte superior de los listados) */
.status-legend {
  display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 14px;
  font-size: .82rem; color: var(--muted);
}
.status-legend .legend-item { display: inline-flex; align-items: center; gap: 6px; }

[x-cloak] { display: none !important; }

/* Topbar: enlaces de marca y buscador global */
.brand-link { display: flex; align-items: baseline; gap: 8px; text-decoration: none; }
.searchbar { margin-left: auto; flex: 0 1 420px; }
.searchbar input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--font); font-size: .9rem; background: #fff;
}
.searchbar input:focus { outline: 2px solid var(--sipay-primary); border-color: transparent; }
.userbox { margin-left: 16px; }

/* Layout helpers */
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.mono-title { display: flex; align-items: center; gap: 10px; }
.small { font-size: .8rem; }
.center { text-align: center; }
.stack { display: grid; gap: 6px; }
.stack label { font-size: .82rem; font-weight: 500; margin-top: 6px; }
.stack input, .stack textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--font); font-size: .9rem;
}

/* Tarjetas de estadística */
.card.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-size: 2rem; font-weight: 600; }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-link { margin-top: 10px; color: var(--sipay-primary); text-decoration: none; font-size: .85rem; font-weight: 500; }

/* Tablas */
.table-meta { padding: 6px 2px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.refresh-controls { display: inline-flex; align-items: center; gap: 10px; }
.paygate-headers { margin: 4px 0 8px; padding-left: 18px; }
.paygate-headers li { font-size: .82rem; }
.btn.btn-icon { padding: 4px 10px; font-size: .82rem; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.table-wrap {
  overflow-x: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
.grid th {
  text-align: left; font-weight: 500; color: var(--muted); padding: 11px 14px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfbfb;
}
.grid td { padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid tbody tr:hover { background: #faf7f5; cursor: pointer; }
.grid.compact th, .grid.compact td { padding: 7px 10px; }
.grid th a { color: var(--muted); text-decoration: none; }
.grid th a:hover { color: var(--ink); }
.arrow { color: var(--sipay-primary); }
.cell-link { color: var(--ink); text-decoration: none; font-weight: 500; }
.cell-link:hover { color: var(--sipay-primary); }
.row-unknown { background: #fff4f0 !important; box-shadow: inset 3px 0 0 var(--sipay-primary); }
.row-unknown:hover { background: #ffe9e1 !important; }

/* Filtros y selector de columnas */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters input, .filters select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--font); font-size: .9rem;
}
.cols-dd { position: relative; }
.cols-menu {
  position: absolute; top: 112%; right: 0; z-index: 20; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  padding: 10px; min-width: 210px; display: grid; gap: 4px; max-height: 340px; overflow: auto;
}
.pager { display: flex; align-items: center; gap: 16px; margin-top: 16px; justify-content: center; }

/* Ficha de dispositivo: tabs y tablas clave-valor */
.tabnav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabnav button {
  background: none; border: none; padding: 10px 16px; font-family: var(--font);
  font-size: .92rem; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabnav button.active { color: var(--ink); border-bottom-color: var(--sipay-primary); font-weight: 500; }
table.kv { width: 100%; border-collapse: collapse; font-size: .9rem; }
.kv th { width: 42%; text-align: left; color: var(--muted); font-weight: 500; padding: 6px 10px 6px 0; vertical-align: top; }
.kv td { padding: 6px 0; }

/* Diff de configuraciones */
.diff-form { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.diff-form select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.diff-container { margin-top: 12px; }
.diff-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.diff { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: .8rem; border-collapse: collapse; }
.diff td { padding: 1px 6px; white-space: pre; }
td.diff_header { text-align: right; color: #bbb; }
.diff_next { display: none; }
.diff_add { background: #e6ffed; }
.diff_sub { background: #ffeef0; }
.diff_chg { background: #fff5b1; }

/* Acciones de cabecera y formularios en línea */
.header-actions { display: flex; align-items: center; gap: 10px; }
.inline-form { margin: 0; display: inline; }

/* Push / revert de configuración */
.push-block { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.push-block details { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.push-block summary { cursor: pointer; font-weight: 500; color: var(--sipay-primary); }
.mono-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem;
  padding: 10px; border: 1px solid var(--line); border-radius: 8px; width: 100%; resize: vertical;
}

/* Descargas de logs */
.retrieval-list { display: grid; gap: 8px; }
.retrieval-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; }

/* NQT: análisis de calidad de red */
.nqt-analysis-list { display: grid; gap: 8px; }
.nqt-analysis-row { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.nqt-analysis-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nqt-report-slot { display: none; margin-top: 12px; }
.nqt-report-slot.open { display: block; }
.nqt-verdict { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.nqt-text { margin: 4px 0 16px; }
.nqt-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.nqt-chart { margin: 0; }
.nqt-chart figcaption { font-size: 0.85rem; margin-bottom: 4px; }
.nqt-svg { width: 100%; height: 90px; display: block; background: var(--surface, #fff); border: 1px solid var(--line); border-radius: 6px; }
.nqt-metrics { margin-top: 16px; }

/* Buscador */
.search-group { margin-bottom: 28px; }
.result-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.result-list a { color: var(--sipay-primary); text-decoration: none; font-weight: 500; }

/* Constructor de configuraciones */
.builder-apps, .template-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  text-decoration: none; color: var(--muted); font-size: .88rem; background: var(--surface);
}
.chip:hover { color: var(--ink); }
.chip-active { background: var(--sipay-primary); color: #fff; border-color: var(--sipay-primary); }
.schema-badge {
  display: inline-block; font-size: .74rem; font-family: ui-monospace, Menlo, monospace;
  padding: 4px 10px; border-radius: 999px; background: #eef2ff; color: #3730a3;
  border: 1px solid #c7d2fe; align-self: center;
}
.modal-head-meta { display: flex; align-items: center; gap: 8px; }
.section-hint { margin: -4px 0 14px; font-size: .85rem; }
.mode-toggle { display: flex; gap: 6px; margin-bottom: 12px; }
.mode-toggle .btn.active { border-color: var(--sipay-primary); color: var(--sipay-primary); }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .84rem; font-weight: 500; }
.field input, .field select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: var(--font); font-size: .9rem;
}
.field-help { font-size: .76rem; color: var(--muted); }
.row-actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.row-actions input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: var(--font); }
.preview-box { margin-top: 14px; }
.json-preview {
  background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 8px; overflow-x: auto;
  font-family: ui-monospace, Menlo, monospace; font-size: .8rem;
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(17, 17, 17, .5);
  display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto;
}
.modal-card {
  position: relative; background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3); width: 100%; max-width: 760px; padding: 24px;
}
.modal-close {
  position: absolute; top: 12px; right: 12px; border: none; background: transparent;
  font-size: 1.1rem; cursor: pointer; color: var(--muted);
}
.modal-close:hover { color: var(--ink); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.snapshot-body .mode-toggle { margin-bottom: 12px; }
.human-table th { text-align: left; color: var(--muted); font-weight: 500; }
.human-table .human-group th { color: var(--ink); font-weight: 600; }

/* Resaltado JSON */
.json-hl { white-space: pre; }
.tok-key { color: #7dd3fc; }
.tok-str { color: #86efac; }
.tok-num { color: #fca5a5; }
.tok-bool { color: #fcd34d; }
.tok-null { color: #cbd5e1; font-style: italic; }
.snap-row { cursor: pointer; }

/* Enlaces de ayuda contextual */
.help-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; font-size: .7rem; font-weight: 600;
  background: #f3f4f6; color: var(--muted); text-decoration: none; margin-left: 4px;
  border: none; padding: 0; line-height: 1; cursor: pointer; vertical-align: middle;
}
.help-link:hover { background: var(--sipay-primary); color: #fff; }

/* Centro de ayuda */
.help-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.help-nav { position: sticky; top: 20px; display: grid; gap: 2px; }
.help-navlink { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .9rem; }
.help-navlink:hover, .help-navlink.active { background: #f3f4f6; color: var(--ink); }
.help-topic { margin-bottom: 16px; scroll-margin-top: 20px; }
.help-topic h2 { color: var(--ink); }
.help-topic ul { margin: .4em 0; padding-left: 1.2em; }
.help-topic li { margin: .25em 0; }
.help-active { border-left: 3px solid var(--sipay-primary); }
@media (max-width: 720px) { .help-layout { grid-template-columns: 1fr; } .help-nav { position: static; } }

/* Auditoría */
.audit-diff { font-size: .82rem; max-width: 460px; }
.audit-diff .old { color: #991b1b; }
.audit-diff .new { color: #166534; }
.audit-diff .arrow { color: var(--muted); margin: 0 4px; }

/* === Layout con menú lateral (rediseño) === */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand-side {
  display: flex; align-items: baseline; gap: 8px; padding: 18px 20px;
  text-decoration: none; border-bottom: 1px solid var(--line);
}
.sidenav { display: flex; flex-direction: column; gap: 2px; padding: 12px; flex: 1; overflow-y: auto; }
.sidelink {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: .94rem;
}
.sidelink:hover { background: var(--hover); color: var(--ink); }
.sidelink.active { background: rgba(244, 82, 39, .12); color: var(--sipay-primary); }
.sidelink .ico { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }
.theme-toggle {
  width: 100%; text-align: left; background: transparent; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; cursor: pointer; font-family: var(--font);
  color: var(--muted); font-size: .9rem;
}
.theme-toggle:hover { background: var(--hover); color: var(--ink); }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Topbar del rediseño */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 24px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.searchbar { position: relative; flex: 0 1 460px; margin: 0; }
.search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: .9rem; pointer-events: none; opacity: .75; }
.searchbar input {
  width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-family: var(--font); font-size: .9rem;
}
.searchbar input:focus { outline: 2px solid var(--sipay-primary); border-color: transparent; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.userbox { display: flex; align-items: center; gap: 10px; margin: 0; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); font-size: 1rem;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-name { font-weight: 500; font-size: .9rem; }
.user-roles { display: flex; gap: 4px; flex-wrap: wrap; }

.content { max-width: 1200px; width: 100%; margin: 0 auto; padding: 28px 24px; }

/* Página de inicio */
.hero h1 { font-size: 1.7rem; }
.stat-icon { font-size: 1.6rem; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.quick-actions .btn { text-decoration: none; }

/* Overrides de modo oscuro para superficies con color fijo */
:root[data-theme="dark"] .grid th { background: var(--surface-2); }
:root[data-theme="dark"] .grid tbody tr:hover { background: var(--hover); }
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .badge-role { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
:root[data-theme="dark"] .help-link { background: var(--surface-2); }
:root[data-theme="dark"] .btn-ghost:hover,
:root[data-theme="dark"] .navlink:hover { background: var(--hover); }
:root[data-theme="dark"] .chip { background: var(--surface-2); }
:root[data-theme="dark"] .cols-menu label:hover { background: var(--hover); }
:root[data-theme="dark"] .message.error { background: #3b1f22; color: #fca5a5; border-color: #7f1d1d; }
:root[data-theme="dark"] .message.success { background: #12301f; color: #86efac; border-color: #166534; }
:root[data-theme="dark"] .schema-badge { background: #20263a; color: #c7d2fe; border-color: #3730a3; }
:root[data-theme="dark"] .row-unknown { background: #2a1a14 !important; }
:root[data-theme="dark"] .row-unknown:hover { background: #34201a !important; }

/* Responsive: sidebar arriba en pantallas estrechas */
@media (max-width: 820px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; }
  .sidenav { flex-direction: row; flex-wrap: wrap; }
  .user-meta { display: none; }
  .searchbar { flex: 1; }
}
:root[data-theme="dark"] code { background: var(--surface-2); }

/* Botones de icono (tema, ayuda) y ajustes del topbar-right */
.btn { text-decoration: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 1.1rem; line-height: 1;
  cursor: pointer; text-decoration: none; flex-shrink: 0;
}
.icon-btn:hover { background: var(--hover); border-color: var(--muted); }
.user-meta { align-items: center; text-align: center; }
.user-roles { justify-content: center; }

/* Footer fijo */
.app-footer {
  position: fixed; left: 0; right: 0; bottom: 0; height: 36px; z-index: 40;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); border-top: 1px solid var(--line);
  color: var(--muted); font-size: .8rem;
}
.app-footer a { color: var(--sipay-primary); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }
/* Espacio para que el footer fijo no tape el contenido */
.content { padding-bottom: 60px; }
.sidenav { padding-bottom: 48px; }

/* Logo de marca (Sipay) con conmutación por tema */
.brand-side, .brand-login { align-items: center; }
.brand-logo { height: 26px; width: auto; display: inline-block; vertical-align: middle; }
.brand-login .brand-logo { height: 32px; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: inline-block; }

/* Wordmark de Sipay en la caja de login (solo login) */
.login-logo { text-align: center; margin-bottom: 18px; }
.login-logo img { height: 44px; width: auto; max-width: 80%; }

/* Buscador de destinos (modal del constructor) */
.btn-sm { padding: 6px 10px; font-size: .82rem; }
.input-with-btn { display: flex; gap: 8px; align-items: center; }
.input-with-btn input { flex: 1; }
.picker-search { position: relative; flex: none; margin: 12px 0; max-width: 100%; }
.picker-results { max-height: 46vh; overflow-y: auto; display: grid; gap: 4px; }
.picker-group { margin-bottom: 12px; }
.picker-group h3 { font-size: .85rem; color: var(--muted); font-weight: 600; margin: 8px 0 4px; }
.picker-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
}
.picker-row:hover { background: var(--hover); }
.picker-info { display: flex; flex-direction: column; min-width: 0; }
.picker-info .muted { font-size: .8rem; }

/* Picker: pestañas, meta/paginación y toast */
.picker-tabs { display: flex; gap: 8px; margin: 4px 0 12px; flex-wrap: wrap; }
.picker-tabs .chip { cursor: pointer; }
.picker-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 2px 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px; flex-wrap: wrap;
}
.pager-mini { display: flex; gap: 6px; }
.recover-card { border-top: 3px solid var(--sipay-primary); }

.toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 60;
  padding: 12px 18px; border-radius: 10px; font-size: .92rem; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); border: 1px solid var(--line);
}
.toast-ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.toast-warn { background: #fff4f0; color: #9a3412; border-color: #fed7aa; }
:root[data-theme="dark"] .toast-ok { background: #12301f; color: #86efac; border-color: #166534; }
:root[data-theme="dark"] .toast-warn { background: #2a1a14; color: #fdba74; border-color: #7c2d12; }

/* Controles del picker (búsqueda + tamaño de página) */
.picker-controls { display: flex; align-items: center; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.picker-controls .picker-search { flex: 1; margin: 0; }
.picker-size { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.picker-size select { padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }

/* Spinner de recuperación en vivo */
.spinner-card { text-align: center; max-width: 360px; }
.spinner {
  width: 40px; height: 40px; margin: 4px auto 14px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--sipay-primary);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Contador online/total en la landing */
.stat-of { font-size: 1rem; font-weight: 500; color: var(--muted); }

/* Cliente API de paygate (pantalla Comandos) */
.mono-label { font-size: .82rem; font-weight: 500; display: block; margin: 12px 0 4px; }
.paygate-resp { margin-top: 14px; }
.paygate-resp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
