/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:          #06091a;
  --bg-nav:      #080c1e;
  --bg-card:     #0d1428;
  --bg-card2:    #111a35;
  --border:      #1e2a4a;
  --blue:        #3b82f6;
  --purple:      #8b5cf6;
  --green:       #22c55e;
  --amber:       #f59e0b;
  --red:         #ef4444;
  --cyan:        #06b6d4;
  --text:        #e2e8f0;
  --text-muted:  #64748b;
  --text-dim:    #94a3b8;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 4px 24px rgba(0,0,0,.5);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 30%, #0d1f4a 0%, var(--bg) 70%);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo {
  display: block;
  max-width: 160px;
  margin: 0 auto 1.5rem;
}
.login-title {
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: 1.75rem;
}
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  margin-bottom: .4rem;
  color: var(--text-dim);
  font-size: .85rem;
}
.form-control {
  width: 100%;
  padding: .6rem .85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .95rem;
  transition: border-color .2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--blue);
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .88; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-danger  { background: var(--red);   color: #fff; }
.btn-ghost   { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-sm { padding: .35rem .75rem; font-size: .82rem; }
.btn-full { width: 100%; justify-content: center; }
.error-msg {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: var(--red);
  padding: .6rem .85rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .88rem;
}

/* ── App shell (manager / admin) ───────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-nav);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
}
.sidebar-logo {
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo img {
  max-width: 140px;
  display: block;
}
.sidebar-nav {
  flex: 1;
  padding: .75rem 0;
  list-style: none;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .65rem 1.25rem;
  color: var(--text-dim);
  font-size: .9rem;
  border-left: 3px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
}
.nav-link:hover, .nav-link.active {
  color: var(--text);
  background: rgba(59,130,246,.08);
  border-left-color: var(--blue);
  text-decoration: none;
}
.sidebar-bottom {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}
.user-badge {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: .6rem;
}
.user-badge strong { color: var(--text-dim); display: block; }
.view-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem 2rem;
}

/* ── Section header ────────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.section-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg-card2); }
th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  font-weight: 600;
}
td {
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: .9rem;
  vertical-align: middle;
}
tr:hover td { background: rgba(255,255,255,.02); }
.td-actions { display: flex; gap: .4rem; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-monitor { background: rgba(6,182,212,.15); color: var(--cyan); }
.badge-manager { background: rgba(245,158,11,.15); color: var(--amber); }
.badge-admin   { background: rgba(139,92,246,.15); color: var(--purple); }
.badge-active  { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-inactive{ background: rgba(100,116,139,.15);color: var(--text-muted); }
.badge-file    { background: rgba(59,130,246,.15);  color: var(--blue); }
.badge-paste   { background: rgba(245,158,11,.15);  color: var(--amber); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  padding: .2rem;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
}

/* ── Tabs ──────────────────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: .6rem 1rem;
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: -1px;
}
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Paste zone ────────────────────────────────────────────────────────────── */
.paste-zone {
  width: 100%;
  min-height: 120px;
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--text-muted);
  font-size: .9rem;
  resize: vertical;
  transition: border-color .2s;
}
.paste-zone:focus {
  outline: none;
  border-color: var(--blue);
  color: var(--text);
}
.paste-zone.has-data {
  border-color: var(--green);
  color: var(--green);
}
.paste-hint {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: .4rem;
}

/* ── File drop area ────────────────────────────────────────────────────────── */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.file-drop:hover, .file-drop.drag-over {
  border-color: var(--blue);
  background: rgba(59,130,246,.05);
}
.file-drop input[type=file] { display: none; }
.file-drop-icon { font-size: 2rem; margin-bottom: .5rem; color: var(--text-muted); }
.file-drop-text { color: var(--text-dim); font-size: .9rem; }
.file-drop-text strong { color: var(--blue); }

/* ── Variables modal ───────────────────────────────────────────────────────── */
.var-list { list-style: none; }
.var-list li {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem .6rem;
  border-radius: var(--radius);
  font-size: .9rem;
}
.var-list li:hover { background: rgba(255,255,255,.03); }
.var-list input[type=checkbox] { accent-color: var(--blue); width: 16px; height: 16px; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  padding: .7rem 1.1rem;
  border-radius: var(--radius);
  font-size: .88rem;
  min-width: 220px;
  animation: toast-in .2s ease;
  box-shadow: var(--shadow);
}
.toast-success { background: rgba(34,197,94,.9);  color: #fff; }
.toast-error   { background: rgba(239,68,68,.9);  color: #fff; }
.toast-info    { background: rgba(59,130,246,.9);  color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateX(1rem); } to { opacity: 1; transform: none; } }

/* ── Monitor view ──────────────────────────────────────────────────────────── */
.monitor-shell {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.monitor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 1.5rem;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 56px;
}
.monitor-logo { height: 36px; object-fit: contain; }
.monitor-center { font-size: .95rem; font-weight: 600; color: var(--text-dim); }
.monitor-right { display: flex; align-items: center; gap: 1rem; }
.live-badge {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--green);
}
.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.7); }
}
.monitor-clock { font-size: .88rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.monitor-counter { font-size: .8rem; color: var(--text-muted); }
.monitor-pause-icon { font-size: 1.1rem; color: var(--amber); display: none; }
.monitor-pause-icon.visible { display: block; }

.slide-stage {
  flex: 1;
  overflow: hidden;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
}
.slide-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 1rem;
}
.components-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  overflow: hidden;
}
.component-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 180px;
}
.component-card-title {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: .75rem;
}
.component-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.component-value.blue   { color: var(--blue); }
.component-value.green  { color: var(--green); }
.component-value.amber  { color: var(--amber); }
.component-value.purple { color: var(--purple); }
.chart-wrap { flex: 1; position: relative; min-height: 0; }

.progress-bar-wrap {
  height: 3px;
  background: var(--border);
  flex-shrink: 0;
}
.progress-bar {
  height: 3px;
  background: var(--blue);
  width: 0%;
  transition: none;
}

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: .75rem; }

/* ── Monitor grid (positioned components) ──────────────────────────────────── */
.monitor-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
  overflow: hidden;
  min-height: 0;
}
.monitor-grid .component-card { min-height: 0; }
.comp-text { font-size: 1.1rem; color: var(--text); white-space: pre-wrap; }
.comp-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-muted); font-size: .85rem; text-align: center;
}
.comp-table-wrap { overflow: auto; flex: 1; min-height: 0; }
.comp-table { width: 100%; font-size: .8rem; border-collapse: collapse; }
.comp-table th { padding: .35rem .5rem; font-size: .875em; text-align: left; white-space: nowrap; color: var(--text-muted); font-weight: 600; }
.comp-table td { padding: .3rem .5rem; border-top: 1px solid var(--border); white-space: nowrap; }

/* Extra calculated row / column */
.comp-table .tbl-extra       { font-weight: 700; color: #94a3b8; }
.comp-table .tbl-extra-lbl   { font-style: italic; }
.comp-table .tbl-extra-tr td { border-top: 2px solid rgba(148,163,184,.35) !important; background: rgba(255,255,255,.03); }
.comp-table th.tbl-extra     { border-left: 1px solid rgba(148,163,184,.2); }
.comp-table td.tbl-extra:not(.tbl-extra-lbl) { border-left: 1px solid rgba(148,163,184,.12); text-align: right; }

/* ── Table templates — Group 1: Sin bordes ──────────────────────────────── */
.tpl-nb-clean .comp-table td { border-top: none; }
.tpl-nb-clean .comp-table th { border-bottom: 2px solid rgba(255,255,255,.1); background: rgba(255,255,255,.04); }

.tpl-nb-minimal .comp-table td,
.tpl-nb-minimal .comp-table th { border: none; }
.tpl-nb-minimal .comp-table th { font-weight: 800; text-transform: uppercase; letter-spacing: .07em; font-size: .62rem; color: #475569; padding-bottom: .55rem; }

.tpl-nb-dark .comp-table td { border-top: none; }
.tpl-nb-dark .comp-table th { border: none; background: rgba(0,0,0,.35); color: #94a3b8; }

.tpl-nb-soft .comp-table td { border-top: none; }
.tpl-nb-soft .comp-table th { border: none; background: rgba(59,130,246,.08); color: #60a5fa; font-weight: 700; }

.tpl-nb-glass .comp-table td { border-top: none; }
.tpl-nb-glass .comp-table th { border: none; background: rgba(255,255,255,.06); color: #e2e8f0; }
.tpl-nb-glass .comp-table tbody tr:hover { background: rgba(255,255,255,.04); }

.tpl-nb-compact .comp-table td { border-top: none; padding: .15rem .4rem; font-size: .74rem; }
.tpl-nb-compact .comp-table th { border: none; padding: .18rem .4rem; font-size: .63rem; }

/* ── Table templates — Group 2: Solo líneas horizontales ────────────────── */
.tpl-hl-classic .comp-table th { border-bottom: 2px solid #1e3a6e; background: transparent; }
.tpl-hl-classic .comp-table td { border-top: 1px solid #1e2a4a; }

.tpl-hl-thin .comp-table th { border-bottom: 1px solid rgba(148,163,184,.18); background: transparent; }
.tpl-hl-thin .comp-table td { border-top: 1px solid rgba(148,163,184,.09); }

.tpl-hl-bold .comp-table th { border-bottom: 3px solid #3b82f6; color: #60a5fa; font-weight: 700; }
.tpl-hl-bold .comp-table td { border-top: 1px solid rgba(59,130,246,.14); }

.tpl-hl-accent .comp-table th { border-bottom: 2px solid #22c55e; color: #4ade80; }
.tpl-hl-accent .comp-table td { border-top: 1px solid rgba(34,197,94,.12); }

.tpl-hl-deep .comp-table th { background: rgba(30,42,74,.8); border-bottom: 2px solid #3b82f6; color: #93c5fd; }
.tpl-hl-deep .comp-table td { border-top: 1px solid rgba(59,130,246,.1); }

.tpl-hl-double .comp-table th { border-bottom: 4px double rgba(148,163,184,.3); color: #cbd5e1; }
.tpl-hl-double .comp-table td { border-top: 1px solid rgba(148,163,184,.1); }

.tpl-hl-wide .comp-table th { border-bottom: 1px solid rgba(148,163,184,.22); padding: .6rem .75rem; color: #94a3b8; }
.tpl-hl-wide .comp-table td { border-top: 1px solid rgba(148,163,184,.1); padding: .5rem .75rem; }

.tpl-hl-purple .comp-table th { border-bottom: 2px solid #8b5cf6; color: #a78bfa; }
.tpl-hl-purple .comp-table td { border-top: 1px solid rgba(139,92,246,.14); }

/* ── Table templates — Group 3: Filas alternadas ────────────────────────── */
.tpl-zb-blue .comp-table th { background: rgba(59,130,246,.14); color: #93c5fd; border: none; }
.tpl-zb-blue .comp-table td { border: none; }
.tpl-zb-blue .comp-table tbody tr:nth-child(odd)  { background: rgba(59,130,246,.04); }
.tpl-zb-blue .comp-table tbody tr:nth-child(even) { background: rgba(59,130,246,.1); }

.tpl-zb-green .comp-table th { background: rgba(34,197,94,.11); color: #4ade80; border: none; }
.tpl-zb-green .comp-table td { border: none; }
.tpl-zb-green .comp-table tbody tr:nth-child(even) { background: rgba(34,197,94,.08); }

.tpl-zb-gray .comp-table th { background: rgba(255,255,255,.06); border-bottom: 1px solid rgba(255,255,255,.1); color: #94a3b8; }
.tpl-zb-gray .comp-table td { border: none; }
.tpl-zb-gray .comp-table tbody tr:nth-child(even) { background: rgba(255,255,255,.04); }

.tpl-zb-purple .comp-table th { background: rgba(139,92,246,.12); color: #c4b5fd; border: none; }
.tpl-zb-purple .comp-table td { border: none; }
.tpl-zb-purple .comp-table tbody tr:nth-child(even) { background: rgba(139,92,246,.07); }

.tpl-zb-amber .comp-table th { background: rgba(245,158,11,.1); color: #fcd34d; border: none; }
.tpl-zb-amber .comp-table td { border: none; }
.tpl-zb-amber .comp-table tbody tr:nth-child(even) { background: rgba(245,158,11,.06); }

.tpl-zb-teal .comp-table th { background: rgba(20,184,166,.11); color: #2dd4bf; border: none; }
.tpl-zb-teal .comp-table td { border: none; }
.tpl-zb-teal .comp-table tbody tr:nth-child(even) { background: rgba(20,184,166,.07); }

.tpl-zb-rose .comp-table th { background: rgba(244,63,94,.09); color: #fb7185; border: none; }
.tpl-zb-rose .comp-table td { border: none; }
.tpl-zb-rose .comp-table tbody tr:nth-child(even) { background: rgba(244,63,94,.06); }

.tpl-zb-dark .comp-table th { background: rgba(0,0,0,.45); color: #94a3b8; border: none; }
.tpl-zb-dark .comp-table td { border: none; }
.tpl-zb-dark .comp-table tbody tr:nth-child(odd)  { background: rgba(0,0,0,.15); }
.tpl-zb-dark .comp-table tbody tr:nth-child(even) { background: rgba(0,0,0,.32); }

.tpl-zb-indigo .comp-table th { background: rgba(99,102,241,.12); color: #a5b4fc; border: none; }
.tpl-zb-indigo .comp-table td { border: none; }
.tpl-zb-indigo .comp-table tbody tr:nth-child(even) { background: rgba(99,102,241,.07); }

/* ── Table templates — Group 4: Bordes completos ────────────────────────── */
.tpl-grid-light .comp-table th,
.tpl-grid-light .comp-table td { border: 1px solid rgba(148,163,184,.14); }
.tpl-grid-light .comp-table th { background: rgba(255,255,255,.04); }

.tpl-grid-mid .comp-table th,
.tpl-grid-mid .comp-table td { border: 1px solid rgba(148,163,184,.25); }
.tpl-grid-mid .comp-table th { background: rgba(59,130,246,.07); }

.tpl-grid-dark .comp-table th,
.tpl-grid-dark .comp-table td { border: 1px solid rgba(255,255,255,.07); }
.tpl-grid-dark .comp-table th { background: rgba(0,0,0,.35); color: #94a3b8; }

.tpl-grid-outer { border: 1px solid rgba(148,163,184,.2); border-radius: 4px; overflow: hidden; }
.tpl-grid-outer .comp-table th { border-bottom: 1px solid rgba(148,163,184,.2); border-top: none; border-left: none; border-right: none; }
.tpl-grid-outer .comp-table td { border: none; }

/* ── Table templates — Group 5: Encabezado destacado ───────────────────── */
.tpl-hd-blue .comp-table th { background: #1d4ed8; color: #fff; border: none; font-weight: 600; }
.tpl-hd-blue .comp-table td { border-top: 1px solid rgba(29,78,216,.18); }

.tpl-hd-dark .comp-table th { background: #0f172a; color: #60a5fa; border: none; font-weight: 600; }
.tpl-hd-dark .comp-table td { border-top: 1px solid rgba(255,255,255,.06); }

.tpl-hd-green .comp-table th { background: #166534; color: #86efac; border: none; font-weight: 600; }
.tpl-hd-green .comp-table td { border-top: 1px solid rgba(22,101,52,.22); }

.tpl-hd-purple .comp-table th { background: #4c1d95; color: #ddd6fe; border: none; font-weight: 600; }
.tpl-hd-purple .comp-table td { border-top: 1px solid rgba(76,29,149,.22); }

.tpl-hd-gradient .comp-table th { background: linear-gradient(135deg,#1e3a8a,#3730a3); color: #e0f2fe; border: none; font-weight: 600; }
.tpl-hd-gradient .comp-table td { border-top: 1px solid rgba(59,130,246,.12); }

/* Zebra overrides — extra row must override nth-child background */
[class*="tpl-zb-"] .comp-table .tbl-extra-tr td { background: rgba(255,255,255,.08) !important; }

/* ── Builder ───────────────────────────────────────────────────────────────── */
.builder-shell { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.builder-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem 1.25rem;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.builder-title { font-size: 1rem; font-weight: 600; margin-left: .5rem; }
.builder-body {
  flex: 1; overflow-y: auto; padding: 1rem 1.25rem;
  background:
    linear-gradient(var(--bg-nav) 1px, transparent 1px) 0 0 / 100% 86px,
    var(--bg);
}
.grid-stack { min-height: 400px; overflow-x: hidden; }
.grid-stack-item-content.comp-card {
  display: flex; flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  inset: 0;
}
.comp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .4rem .65rem;
  border-bottom: 1px solid var(--border);
  cursor: move;
  background: var(--bg-card2);
  flex-shrink: 0;
}
.comp-header-title { font-size: .82rem; font-weight: 600; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comp-actions { display: flex; gap: .25rem; cursor: default; }
.comp-btn {
  background: none; border: none; color: var(--text-muted);
  font-size: .9rem; padding: .1rem .3rem; border-radius: 4px; line-height: 1;
}
.comp-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }
.comp-body { flex: 1; padding: .65rem; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.comp-body .chart-wrap { flex: 1; position: relative; min-height: 0; }
.comp-body .comp-value { font-size: 1.8rem; font-weight: 700; display: flex; align-items: center; height: 100%; }

/* ── Config panel ──────────────────────────────────────────────────────────── */
.config-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 340px;
  background: var(--bg-nav);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform .2s ease;
  z-index: 500;
  display: flex; flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,.4);
}
.config-panel.open { transform: translateX(0); }
.config-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.config-panel-body { padding: 1.25rem; overflow-y: auto; }

/* ── Util ──────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .82rem; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.align-center { align-items: center; }

/* ── Preview overlay (admin Pantallas → Ver) ───────────────────────────────── */
.preview-overlay {
  position: fixed; inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.preview-bar {
  display: flex; align-items: center; gap: 1rem;
  padding: .5rem 1rem;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 48px;
}
.preview-bar-title { flex: 1; font-size: .9rem; color: var(--text-dim); }
.preview-iframe { flex: 1; border: none; width: 100%; }

/* ── Sortable screens list (Presentaciones → Pantallas modal) ──────────────── */
.sort-list { list-style: none; margin-bottom: 0; }
.sort-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .35rem;
  user-select: none;
  cursor: grab;
}
.sort-item:active { cursor: grabbing; }
.sort-item.drag-over { border-color: var(--blue); background: rgba(59,130,246,.08); }
.sort-item.dragging  { opacity: .35; }
.sort-handle { color: var(--text-muted); font-size: 1.1rem; line-height: 1; }
.sort-item-num  { font-size: .78rem; font-weight: 700; color: var(--text-muted); min-width: 1.5rem; }
.sort-item-name { flex: 1; font-size: .9rem; }
.sort-avail-label {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); padding: .85rem 0 .4rem; font-weight: 600;
  border-top: 1px solid var(--border); margin-top: .5rem;
}
.sort-avail-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .45rem .5rem;
  border-radius: var(--radius);
  margin-bottom: .2rem;
}
.sort-avail-item:hover { background: rgba(255,255,255,.03); }
.sort-avail-name { flex: 1; font-size: .9rem; color: var(--text-dim); }

/* ── Days pill (datasources) ───────────────────────────────────────────────── */
.days-pill, .prd-pill {
  display: inline-block; padding: .1rem .45rem;
  border-radius: 999px; font-size: .68rem; font-weight: 600;
  margin-left: .35rem; vertical-align: middle; white-space: nowrap;
}
/* Periodicidad */
.prd-daily    { background: rgba(59,130,246,.15);  color: #3b82f6; }
.prd-weekly   { background: rgba(139,92,246,.15);  color: #8b5cf6; }
.prd-biweekly { background: rgba(6,182,212,.15);   color: #06b6d4; }
.prd-monthly  { background: rgba(245,158,11,.15);  color: #f59e0b; }
/* Frescura de datos */
.days-green  { background: rgba(34,197,94,.15);   color: #22c55e; }
.days-yellow { background: rgba(245,158,11,.15);  color: #f59e0b; }
.days-orange { background: rgba(249,115,22,.15);  color: #f97316; }
.days-red    { background: rgba(239,68,68,.15);   color: #ef4444; }
.days-neutral{ background: rgba(148,163,184,.1);  color: #64748b; }

/* ── Password toggle (input + eye button) ──────────────────────────────────── */
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 2.4rem; }
.pw-eye {
  position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); font-size: 1rem;
  line-height: 1; padding: .1rem; cursor: pointer;
}
.pw-eye:hover { color: var(--text); }

/* ── Data Config Modal (datasource matrix) ─────────────────────────────────── */
.dcfg-table { border-collapse: collapse; font-size: .82rem; white-space: nowrap; }
.dcfg-table th,
.dcfg-table td { padding: .22rem .45rem; border: 1px solid var(--border); vertical-align: middle; }
.dcfg-table thead th {
  background: var(--bg-nav); color: var(--text-muted); font-weight: 600;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
}
.dcfg-th-rowtype { min-width: 108px; }
.dcfg-th-id      { min-width: 100px; }
.dcfg-td-id      { font-weight: 600; color: var(--text); }
.dcfg-td-rowtype { white-space: nowrap; }
.dcfg-row-header td { background: rgba(59,130,246,.07); }
.dcfg-row-exclude td { opacity: .4; }
.dcfg-col-dim    { opacity: .3; }
.dcfg-id-badge {
  display: inline-block; background: var(--blue); color: #fff;
  font-size: .63rem; padding: 1px 6px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: .04em;
}
.dcfg-col-cb  { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.dcfg-col-num { font-size: .68rem; color: var(--text-muted); }
.rtype-btns   { display: flex; gap: 2px; }
.rtype-btn {
  padding: 2px 7px; font-size: .7rem; border-radius: 4px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); cursor: pointer; transition: background .12s, color .12s;
}
.rtype-btn:hover { border-color: var(--text-muted); }
.rtype-btn.active[data-type="header"]  { background: var(--blue);       border-color: var(--blue);       color: #fff; }
.rtype-btn.active[data-type="data"]    { background: var(--green);      border-color: var(--green);      color: #fff; }
.rtype-btn.active[data-type="exclude"] { background: var(--text-muted); border-color: var(--text-muted); color: #fff; }
.var-preview-pill {
  display: inline-block; background: var(--bg-card); border: 1px solid var(--border);
  padding: 2px 10px; border-radius: 99px; font-size: .8rem; color: var(--text);
}

/* ── Structured value_card (monitor + builder preview) ─────────────────────── */
.comp-value-grid { display: flex; flex-direction: column; gap: .35rem; padding: .5rem; overflow: auto; height: 100%; }
.comp-value-row  { display: flex; align-items: center; gap: .65rem; padding: .25rem .4rem; background: var(--bg); border-radius: var(--radius); }
.comp-value-label { font-size: .76rem; color: var(--text-muted); min-width: 80px; flex-shrink: 0; }
.comp-value-cell  { display: flex; flex-direction: column; align-items: flex-end; flex: 1; min-width: 60px; }
.comp-value-prop  { font-size: .62rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.comp-value-num   { font-size: 1.05rem; font-weight: 700; }

/* ── Builder structured selectors ──────────────────────────────────────────── */
.struct-var-list,
.struct-prop-list {
  list-style: none; padding: 0; margin: 0;
  max-height: 140px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
.struct-var-list li,
.struct-prop-list li {
  display: flex; align-items: center; padding: .28rem .6rem;
  border-bottom: 1px solid var(--border); font-size: .84rem; cursor: pointer;
}
.struct-var-list li:last-child,
.struct-prop-list li:last-child { border-bottom: none; }
.struct-var-list li:hover,
.struct-prop-list li:hover { background: var(--bg-card); }
.struct-var-list label,
.struct-prop-list label { display: flex; align-items: center; gap: .4rem; cursor: pointer; width: 100%; }

/* ── KPI component ─────────────────────────────────────────────────────────── */
.comp-kpi-wrap {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; container-type: size; text-align: center; gap: .3em;
}
.comp-kpi-unit {
  display: flex; flex-direction: column; align-items: center; gap: .15em;
}
.comp-kpi-name {
  font-size: clamp(.65rem, 8cqh, 1.1rem);
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.comp-kpi-value {
  font-size: clamp(1.2rem, 18cqh, 5rem); font-weight: 700; line-height: 1;
}
.comp-kpi-icon { line-height: 1; }
.comp-kpi-row { display: flex; align-items: center; justify-content: center; gap: .3em; }

/* ── Label component ───────────────────────────────────────────────────────── */
.comp-label {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: .6rem; overflow: hidden; word-break: break-word; white-space: pre-wrap;
  box-sizing: border-box;
}

/* Label card: float action buttons over content */
.comp-label-card .comp-header,
.comp-notitle-card .comp-header {
  position: absolute; top: 0; right: 0;
  background: rgba(17, 26, 53, 0.88);
  border: none; border-bottom-left-radius: 6px;
  padding: .1rem .25rem; width: auto; left: auto;
  z-index: 10; opacity: 0; transition: opacity .15s; cursor: default;
}
.comp-label-card:hover .comp-header,
.comp-notitle-card:hover .comp-header { opacity: 1; }
.comp-label-card .comp-header-title,
.comp-notitle-card .comp-header-title { display: none; }
.comp-label-card .comp-body { padding: 0; }
/* notitle-card: body keeps its own padding — only header floats */
.comp-notitle-card { position: relative; }

/* ── Per-variable color pickers ────────────────────────────────────────────── */
.var-color-list { display: flex; flex-direction: column; gap: .3rem; }
.var-color-row { display: flex; align-items: center; gap: .5rem; }
.var-color-name { flex: 1; font-size: .82rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.var-color-cb { width: 32px; height: 28px; padding: 2px; border: 1px solid var(--border); border-radius: 4px; background: none; cursor: pointer; }

/* ── KPI icon selector ─────────────────────────────────────────────────────── */
.kpi-icon-grid {
  display: flex; flex-wrap: wrap; gap: .3rem;
  max-height: 160px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .4rem; background: var(--bg);
}
.kpi-icon-btn {
  font-size: 1.3rem; padding: .2rem .3rem; border-radius: 4px;
  border: 1px solid transparent; background: transparent; cursor: pointer; line-height: 1;
  transition: border-color .12s, background .12s;
}
.kpi-icon-btn:hover { border-color: var(--border); background: var(--bg-card); }
.kpi-icon-btn.active { border-color: var(--blue); background: rgba(59,130,246,.15); }
.kpi-icon-btn[style*="display: none"] { display: none !important; }
