/* ============ PayNow — Design System Premium ============ */
:root {
  color-scheme: dark;
  --bg: #070912;
  --bg2: #0a0d1a;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-2: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);
  --text: #eef1f8;
  --muted: #8b93a7;
  --muted-2: #5c6478;
  --accent: #6366f1;
  --accent-2: #22d3ee;
  --accent-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #22d3ee 100%);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

/* ============ Tema claro ============ */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5fb;
  --bg2: #e9edf7;
  --surface: rgba(15, 23, 42, 0.04);
  --surface-2: rgba(15, 23, 42, 0.07);
  --border: rgba(15, 23, 42, 0.10);
  --border-2: rgba(15, 23, 42, 0.18);
  --text: #101828;
  --muted: #5b6478;
  --muted-2: #8b93a7;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  --sidebar-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(243, 246, 252, 0.95));
  --topbar-bg: rgba(255, 255, 255, 0.72);
  --card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.65));
  --grid-line: rgba(15, 23, 42, 0.05);
  --row-hover: rgba(15, 23, 42, 0.04);
  --bar-track: rgba(15, 23, 42, 0.08);
  --modal-bg: linear-gradient(180deg, #ffffff, #f5f7fd);
}
:root {
  --sidebar-bg: linear-gradient(180deg, rgba(15, 18, 32, 0.9), rgba(8, 10, 20, 0.95));
  --topbar-bg: rgba(10, 13, 26, 0.6);
  --card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  --grid-line: rgba(255, 255, 255, 0.025);
  --row-hover: rgba(255, 255, 255, 0.02);
  --bar-track: rgba(255, 255, 255, 0.06);
  --modal-bg: linear-gradient(180deg, #12162a, #0b0e1c);
}
body, .sidebar, .topbar, .card, .chip, .icon-btn, .nav-item, .table th, .table td {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
.muted { color: var(--muted); }
.ok { color: var(--ok) !important; }
.mono { font-family: var(--mono); }

/* ============ Shell ============ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100dvh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  backdrop-filter: blur(20px);
  z-index: 50;
  overflow: hidden;
}
.brand {
  display: flex; align-items: center; gap: 12px; padding: 6px 8px 22px;
  flex-shrink: 0;
}
.brand-mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--accent-grad);
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}
.brand-mark.lg { width: 56px; height: 56px; border-radius: 16px; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--muted); }

.nav {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 999px;
}
.nav-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted-2); padding: 8px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 500;
  transition: all 0.18s ease;
  border: 1px solid transparent;
}
.nav-item:hover { color: var(--text); background: var(--surface); }
.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.22), rgba(34, 211, 238, 0.1));
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.08);
}
.sidebar-foot {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 14px; border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.status-pill { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 8px 10px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.ver { font-size: 11px; color: var(--muted-2); padding: 0 10px; }

/* ============ Main / Topbar ============ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 40;
}
.topbar-title { flex: 1; display: flex; flex-direction: column; }
.topbar-title h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.crumb { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.company-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  max-width: min(240px, 36vw);
}
.pay-mode-switch {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer; user-select: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.pay-mode-switch:hover { border-color: var(--border-2); }
.pay-mode-switch input {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.pay-mode-track {
  width: 36px; height: 20px; border-radius: 999px;
  background: #16a34a;
  position: relative; flex-shrink: 0;
  transition: background .2s ease;
}
.pay-mode-track i {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .2s ease;
}
.pay-mode-switch input:checked + .pay-mode-track {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
}
.pay-mode-switch input:checked + .pay-mode-track i {
  transform: translateX(16px);
}
.pay-mode-label {
  font-size: 10px; font-weight: 800; letter-spacing: .06em;
  color: var(--muted-2);
}
.pay-mode-switch:not(:has(input:checked)) .pay-mode-label.is-live,
.pay-mode-switch:has(input:checked) .pay-mode-label.is-test {
  color: var(--text);
}
.app-shell.is-pay-test .pay-mode-switch {
  border-color: rgba(234, 88, 12, .45);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, .12);
}
.portal-mode-switch {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer; user-select: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.portal-mode-switch:hover { border-color: var(--border-2); }
.portal-mode-switch input {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.portal-mode-track {
  width: 36px; height: 20px; border-radius: 999px;
  background: #94a3b8;
  position: relative; flex-shrink: 0;
  transition: background .2s ease;
}
.portal-mode-track i {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .2s ease;
}
.portal-mode-switch input:checked + .portal-mode-track {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
}
.portal-mode-switch input:checked + .portal-mode-track i {
  transform: translateX(16px);
}
.portal-mode-switch:not(:has(input:checked)) .pay-mode-label.is-off,
.portal-mode-switch:has(input:checked) .pay-mode-label.is-on {
  color: var(--text);
}
.app-shell.is-portal-off .portal-mode-switch {
  border-color: rgba(148, 163, 184, .55);
  box-shadow: 0 0 0 3px rgba(148, 163, 184, .12);
}
.app-shell.is-portal-off .company-chip {
  opacity: .85;
}
.portal-mode-switch--table {
  padding: 4px 8px;
  gap: 6px;
}
.portal-mode-switch--table .pay-mode-label {
  font-size: 9px;
}
#companiesTable tr.is-portal-off-row .slug-tag {
  opacity: .55;
}
#companiesTable tr.is-portal-off-row .portal-mode-switch--table {
  border-color: rgba(148, 163, 184, .55);
}
.co-channels {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  max-width: 220px;
}
.co-channel-switch {
  position: relative; display: inline-flex; cursor: pointer; user-select: none;
}
.co-channel-switch input {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.co-channel-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; height: 26px; padding: 0 8px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  transition: background .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease;
}
.co-channel-pill i { font-style: normal; }
.co-channel-switch input:checked + .co-channel-pill {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .25);
}
.co-channel-switch input:not(:checked) + .co-channel-pill {
  opacity: .72;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}
.co-channel-switch:hover .co-channel-pill {
  border-color: var(--border-2);
}
.btn.is-channel-off {
  opacity: .55;
  cursor: not-allowed;
  filter: grayscale(.25);
}
.company-chip-mark {
  width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0;
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px; color: #fff;
  background: var(--co, #5b5ef6);
}
.company-chip.is-admin .company-chip-mark {
  background: linear-gradient(135deg, #64748b, #334155);
}
.company-chip-meta {
  display: flex; flex-direction: column; line-height: 1.15; min-width: 0;
}
.company-chip-label {
  font-size: 10px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.company-chip-name {
  font-size: 13px; font-weight: 650; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-menu { position: relative; }
.user-chip-btn {
  appearance: none;
  cursor: pointer;
  padding: 4px 8px 4px 4px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.user-chip-btn:hover,
.user-menu.is-open .user-chip-btn {
  border-color: var(--border-2);
  background: var(--surface-2);
}
.user-caret { color: var(--muted); flex-shrink: 0; transition: transform 0.15s ease; }
.user-menu.is-open .user-caret { transform: rotate(180deg); }
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 16px 40px rgba(0,0,0,.28);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.user-dropdown[hidden] { display: none !important; }
.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.user-dropdown-item:hover { background: var(--surface-2); }
.user-dropdown-item.is-danger { color: var(--err); }
.user-dropdown-item.is-danger:hover { background: rgba(248, 113, 113, 0.12); }
.avatar {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--accent-grad);
  display: grid; place-items: center;
  font-weight: 700; color: #fff;
  font-size: 15px;
  flex-shrink: 0;
}
.avatar.sm { width: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--muted); }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); background: var(--surface-2); }
.icon-btn.danger:hover { color: var(--err); border-color: rgba(248, 113, 113, 0.4); }
.logout-form { display: block; margin: 0; }
.menu-toggle { display: none; }

/* ============ Content ============ */
.content { padding: 26px 28px 24px; flex: 1; }

/* Footer Powered by ELP */
.app-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 28px 22px;
}
.app-powered {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  text-decoration: none;
  color: var(--muted);
  opacity: 0.85;
  transition: opacity 0.18s ease, color 0.18s ease;
}
.app-powered-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--muted);
}
.app-powered-brand {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--accent, #5b5ef6);
}
.app-powered:hover {
  opacity: 1;
}
.app-powered:hover .app-powered-brand {
  color: var(--accent-dark, #4338ca);
}

.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px;
  border-radius: 12px;
  margin-bottom: 20px;
  font-weight: 500;
  font-size: 13px;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.flash.ok { background: rgba(52, 211, 153, 0.1); border: 1px solid rgba(52, 211, 153, 0.3); color: var(--ok); }
.flash.error { background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.3); color: var(--err); }

/* ============ Cards / Dashboard ============ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card:hover { border-color: var(--border-2); }
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}
.stat-card { display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden; }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.5), transparent);
}
.stat-head { display: flex; align-items: center; gap: 12px; }
.stat-ico {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.i-cpu { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.i-mem { background: rgba(34, 211, 238, 0.15); color: #22d3ee; }
.i-disk { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.i-time { background: rgba(52, 211, 153, 0.15); color: #34d399; }
.i-net { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.i-host { background: rgba(244, 114, 182, 0.15); color: #f472b6; }
.stat-title { display: flex; flex-direction: column; }
.stat-title h3 { font-size: 14px; font-weight: 600; }
.stat-title span { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.stat-value small { font-size: 16px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.stat-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.stat-foot b { color: var(--text); font-weight: 600; }

#cpuSpark { width: 100%; height: 44px; display: block; }

.bar { height: 8px; border-radius: 99px; background: var(--bar-track); overflow: hidden; }
.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent-grad);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.bar-fill.warn { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.bar-fill.danger { background: linear-gradient(90deg, #f87171, #ef4444); }

.net-row { display: flex; gap: 10px; }
.net-item {
  flex: 1;
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.net-item b { font-size: 16px; font-weight: 700; font-family: var(--mono); }
.net-tag { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; padding: 3px 8px; border-radius: 6px; width: fit-content; }
.net-tag.rx { background: rgba(52, 211, 153, 0.15); color: var(--ok); }
.net-tag.tx { background: rgba(34, 211, 238, 0.15); color: var(--accent-2); }

.kv { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.kv li { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 8px 12px; border-radius: 10px; background: var(--surface); }
.kv li span { color: var(--muted); }
.kv li b { font-weight: 600; font-family: var(--mono); font-size: 12px; }

/* ============ Tables ============ */
.table-card { padding: 0; overflow: hidden; }
.table-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.table-head h2 { font-size: 16px; font-weight: 700; }
.table-head .sub { font-size: 12px; color: var(--muted); }
.live-badge {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600;
  color: var(--ok);
  padding: 6px 12px;
  border-radius: 99px;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.25);
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 1.5s infinite; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  font-weight: 600;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th.num, .table td.num { text-align: right; }
.table td {
  padding: 14px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
  vertical-align: middle;
}
.table tbody tr { transition: background 0.12s ease; }
.table tbody tr:hover { background: var(--row-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table .loading { text-align: center; color: var(--muted); padding: 30px; }
.u-cell { display: flex; align-items: center; gap: 12px; }
.u-cell div { display: flex; flex-direction: column; line-height: 1.3; }
.role-tag { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 99px; }
.role-tag.admin { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.role-tag.company { background: rgba(251, 191, 36, 0.14); color: #fbbf24; }
.field-sep { display: flex; align-items: center; gap: 10px; margin: 18px 0 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.field-sep::before, .field-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.field-hint { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 4px 0 12px; }
.role-tag.user { background: rgba(34, 211, 238, 0.12); color: var(--accent-2); }
.status-tag { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 99px; }
.status-tag.active { background: rgba(52, 211, 153, 0.12); color: var(--ok); }
.status-tag.disabled { background: rgba(248, 113, 113, 0.12); color: var(--err); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions .icon-btn { width: 32px; height: 32px; border-radius: 8px; }

/* ============ Users top ============ */
.users-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 16px; flex-wrap: wrap; }
.mini-stats { display: flex; gap: 12px; }
.mini-stat {
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 22px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  min-width: 90px;
}
.mini-stat b { font-size: 22px; font-weight: 800; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.mini-stat span { font-size: 11px; color: var(--muted); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(99, 102, 241, 0.5); }
.btn-ghost { background: var(--surface); color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-2); }
.btn-block { width: 100%; }

/* ============ Fields / Forms ============ */
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field-control {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field-control:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); }
.field-control svg { color: var(--muted-2); flex-shrink: 0; }
.field-control input, .field-control select, .field-control textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  padding: 13px 0;
}
/* Select nativo oculto: el menú lo pinta .pn-dd (custom) */
select.pn-dd-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.pn-dd {
  position: relative;
  flex: 1;
  min-width: 0;
  width: 100%;
}
.pn-dd-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  padding: 13px 28px 13px 0;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 2px center;
}
.pn-dd-btn:hover { color: #fff; }
:root[data-theme="light"] .pn-dd-btn:hover { color: #0f172a; }
.pn-dd-menu {
  position: fixed;
  z-index: 2147483646;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #12162a;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  max-height: min(280px, 50vh);
  overflow: auto;
}
dialog.modal .pn-dd-menu {
  /* dentro del top-layer del dialog */
  z-index: 2147483646;
}
:root[data-theme="light"] .pn-dd-menu {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
}
.pn-dd-option {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #eef1f8;
  cursor: pointer;
}
:root[data-theme="light"] .pn-dd-option { color: #101828; }
.pn-dd-option:hover,
.pn-dd-option.is-selected {
  background: rgba(99, 102, 241, 0.22);
  color: #fff;
}
:root[data-theme="light"] .pn-dd-option:hover,
:root[data-theme="light"] .pn-dd-option.is-selected {
  background: rgba(99, 102, 241, 0.12);
  color: #312e81;
}
.pn-dd-option.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
/* Fallback select (status y no mejorados) */
.field-control select:not(.pn-dd-native),
.field select:not(.pn-dd-native),
.form-grid select:not(.pn-dd-native),
select.status-select {
  color: var(--text);
  background-color: var(--bg2);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
/* Textarea de comentarios en el modal de obligaciones */
#ofComments {
  width: 100%;
  box-sizing: border-box;
  min-height: 130px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  border-radius: 12px;
  background: #1a1f35;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#ofComments:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}
#ofComments::placeholder { color: var(--muted); }
:root[data-theme="light"] #ofComments {
  background: #eef1f8;
  border-color: #b0b8c8;
  color: #1e293b;
}
:root[data-theme="light"] #ofComments:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.peek { color: var(--muted-2); display: grid; place-items: center; padding: 4px; }
.peek:hover { color: var(--text); }

/* ============ Modal ============ */
.modal {
  position: fixed !important;
  inset: 0 !important;
  margin: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  border: none;
  padding: 0;
  background: transparent;
  z-index: 200;
}
.modal:not([open]) { display: none !important; }
.modal::backdrop { background: rgba(4, 6, 14, 0.7); backdrop-filter: blur(6px); }
:root[data-theme="light"] .modal::backdrop { background: rgba(15, 23, 42, 0.35); }
.modal[open] { display: block !important; }
.modal[open]:not(.modal-overlay) .modal-form,
.modal[open].modal-wide:not(.modal-overlay) .modal-form {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  transform: none !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw;
  max-height: 100vh !important;
  overflow-y: auto !important;
  background: var(--modal-bg);
  border: none;
  border-radius: 0 !important;
  padding: 32px 48px;
  box-shadow: none;
  display: block;
  animation: modalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 210;
}
.modal[open]:not(.modal-overlay) .modal-form > *,
.modal[open].modal-wide:not(.modal-overlay) .modal-form > * {
  margin-bottom: 16px;
}
.modal-form {
  width: min(80vw, calc(100vw - 32px));
  max-width: 100%;
  background: var(--modal-bg);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column; gap: 16px;
}
@keyframes modalIn { from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ============ Toasts ============ */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 13px; font-weight: 500;
  background: #12162a;
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.ok { border-color: rgba(52, 211, 153, 0.4); }
.toast.error { border-color: rgba(248, 113, 113, 0.4); }
.toast.info { border-color: rgba(99, 102, 241, 0.4); }
.toast.out { animation: toastOut 0.3s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* ============ Auth (login) ============ */
.auth-body { min-height: 100vh; display: grid; place-items: center; position: relative; overflow: hidden; }
.auth-bg { position: fixed; inset: 0; z-index: -1; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.35; }
.orb-1 { width: 500px; height: 500px; background: #6366f1; top: -150px; left: -100px; }
.orb-2 { width: 400px; height: 400px; background: #22d3ee; bottom: -120px; right: -80px; opacity: 0.2; }
.orb-3 { width: 300px; height: 300px; background: #8b5cf6; top: 50%; left: 60%; opacity: 0.25; }
.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}
.auth-wrap { width: min(420px, calc(100vw - 32px)); padding: 20px; }
.auth-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border-2);
  border-radius: 24px;
  padding: 36px 32px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(24px);
  animation: cardIn 0.5s cubic-bezier(0.34, 1.4, 0.64, 1);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 28px; }
.auth-brand h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.auth-brand p { font-size: 13px; color: var(--muted); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-foot { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 24px; font-size: 12px; color: var(--muted-2); }
.auth-foot .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 18px;
}
.alert-error { background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.3); color: var(--err); }

/* ============ Ajustes tema claro ============ */
:root[data-theme="light"] .nav-item.active { color: #4338ca; }
:root[data-theme="light"] .sidebar { box-shadow: 8px 0 30px rgba(15, 23, 42, 0.06); }
:root[data-theme="light"] .auth-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.8));
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.18);
}
:root[data-theme="light"] .orb { opacity: 0.18; }
:root[data-theme="light"] .brand-mark { box-shadow: 0 6px 18px rgba(99, 102, 241, 0.3); }

/* ============ Botón de tema (luna/sol) ============ */
.theme-toggle {
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}
.theme-toggle-icons {
  position: relative;
  width: 18px;
  height: 18px;
  display: block;
}
.theme-toggle .ic-sun,
.theme-toggle .ic-moon {
  position: absolute;
  inset: 0;
  margin: auto;
  display: block;
  transition: opacity 0.2s ease, transform 0.28s ease;
  pointer-events: none;
}
.theme-toggle .ic-sun {
  opacity: 0;
  transform: rotate(-70deg) scale(0.55);
  color: #f59e0b;
}
.theme-toggle .ic-moon {
  opacity: 1;
  transform: none;
}
html[data-theme="light"] .theme-toggle .ic-sun {
  opacity: 1;
  transform: none;
}
html[data-theme="light"] .theme-toggle .ic-moon {
  opacity: 0;
  transform: rotate(70deg) scale(0.55);
}
html[data-theme="light"] .theme-toggle {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.35);
}
.auth-theme-toggle {
  position: fixed; top: 18px; right: 18px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border);
}
.auth-theme-toggle .theme-toggle-icons { width: 18px; height: 18px; display: block; position: relative; }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.5);
  }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid; }
  .content { padding: 18px 16px 16px; }
  .app-footer { padding: 8px 16px 18px; }
  .topbar { padding: 14px 16px; }
  .user-meta { display: none; }
  .company-chip-meta { display: none; }
  .company-chip { padding: 4px; }
  .chip { display: none; }
  .dash-grid { grid-template-columns: 1fr; }
  .mini-stats { width: 100%; }
  .mini-stat { flex: 1; }
}

/* ---------- Módulo de empresas ---------- */
.company-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.slug-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 8px; white-space: nowrap;
}
.avatars-stack { display: flex; align-items: center; }
.avatars-stack .avatar { margin-left: -8px; border: 2px solid var(--card-bg, var(--bg)); }
.avatars-stack .avatar:first-child { margin-left: 0; }
.avatar.xs {
  width: 28px; height: 28px; border-radius: 8px;
  font-size: 11px; display: grid; place-items: center;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
}
.avatar.more { background: transparent; color: var(--muted); font-weight: 600; }

/* ---------- Portal de pago ---------- */
.portal-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  padding: 4px 10px 4px 8px; border-radius: 999px;
  margin: 2px 4px 2px 0; text-decoration: none;
  transition: border-color .15s, transform .15s;
}
.portal-chip:hover { border-color: var(--pc, var(--accent)); transform: translateY(-1px); }
.pc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pc, var(--accent)); flex: none; }
.method-tag {
  font-size: 12px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 3px 9px; border-radius: 8px; white-space: nowrap;
}
.status-select {
  font-size: 12px; font-weight: 600;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 8px; cursor: pointer;
}
.status-select.pending   { color: #f59e0b; border-color: rgba(245,158,11,.4); }
.status-select.completed { color: #10b981; border-color: rgba(16,185,129,.4); }
.status-select.failed    { color: #ef4444; border-color: rgba(239,68,68,.4); }
.status-select.refunded  { color: var(--muted); border-color: var(--border); }
.portal-users { display: flex; flex-wrap: wrap; gap: 8px; }
.portal-user-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  padding: 5px 12px 5px 6px; border-radius: 999px;
}
.portal-user-chip em { font-style: normal; font-size: 11px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
/* ---------- Gestión de empresas en Usuarios ---------- */
.co-assigned { margin-bottom: 4px; }
.co-assigned .portal-users { gap: 8px; }
.co-assigned .portal-user-chip { padding: 5px 8px 5px 6px; }
.co-assigned .icon-btn.danger { background: transparent; border: none; color: var(--muted); }
.co-assigned .icon-btn.danger:hover { color: var(--err); }

/* ===== Dashboard empresa (contraseña) ===== */
.i-lock { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
:root[data-theme="light"] .i-lock { background: rgba(34, 197, 94, 0.12); color: #16a34a; }

/* ===== Página cambiar contraseña ===== */
.pw-wrap { max-width: 520px; margin: 0 auto; }
.pw-card { padding: 24px; }
.pw-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.pw-head .stat-ico { flex-shrink: 0; }

/* ===== Checklist de contraseña en tiempo real ===== */
.pw-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.pw-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
  transition: background 0.2s ease, color 0.2s ease;
}
.pw-check-item .pw-ico { display: inline-flex; line-height: 0; }
.pw-check-item .ic-x, .pw-check-item .ic-ok { display: none; }
.pw-check-item.fail .ic-x { display: block; color: var(--muted); }
.pw-check-item.pass {
  color: var(--text);
  background: rgba(52, 211, 153, 0.12);
}
.pw-check-item.pass .ic-ok { display: block; color: var(--green, #34d399); }
:root[data-theme="light"] .pw-check-item {
  background: rgba(15, 23, 42, 0.05);
}
:root[data-theme="light"] .pw-check-item.pass {
  background: rgba(16, 185, 129, 0.10);
}

.pw-form { display: flex; flex-direction: column; gap: 14px; }
.pw-form .field { display: flex; flex-direction: column; gap: 6px; }
.pw-form .field span { font-size: 13px; font-weight: 600; color: var(--muted); }
.pw-form .field input { width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); font-size: 14px; outline: none; transition: border-color .15s; }
.pw-form .field input:focus { border-color: #6366f1; }
.pw-form .field-hint { font-size: 11.5px; color: var(--muted); }
.pw-actions { display: flex; justify-content: flex-end; margin-top: 6px; }
.pw-actions .btn.primary { display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 10px; border: none; background: linear-gradient(135deg, #6366f1, #22d3ee); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer; transition: opacity .15s; }
.pw-actions .btn.primary:hover { opacity: .9; }

/* ===== Módulo de Obligaciones ===== */
.table-head-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.table-head-row .field-inline { min-width: 260px; }
/* Buscador de obligaciones */
.search-input { margin-left: auto; min-width: 200px; flex: 0 1 auto; width: 100%; max-width: 280px; margin-right: 20px; }
.search-input .field-control { position: relative; padding-left: 34px; }
.search-input .field-control input { padding: 13px 20px 13px 0; }
.search-input .field-control svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
tr.no-results .loading { text-align: center; padding: 28px 0; }
tr.no-results .loading span { color: var(--accent); font-weight: 600; }
:root[data-theme="light"] tr.no-results .loading span { color: var(--accent); }
.table-head-row b { font-size: 14px; }
/* ===== Modal overlay (div, reemplaza a <dialog>) ===== */
.modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  margin: 0 !important;
  background: rgba(4, 6, 14, 0.7) !important;
  backdrop-filter: blur(6px);
  z-index: 9999 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 24px !important;
  box-sizing: border-box !important;
  width: 100vw !important;
  height: 100vh !important;
}
:root[data-theme="light"] .modal-overlay {
  background: rgba(15, 23, 42, 0.35) !important;
}
.modal-overlay.open {
  display: flex !important;
}
.modal-overlay .modal-form,
.modal-overlay.modal-form {
  width: min(460px, 100%) !important;
  max-width: 100% !important;
  position: static !important;
  top: auto !important;
  left: auto !important;
  transform: none !important;
  background: var(--modal-bg) !important;
  border: 1px solid var(--border-2) !important;
  border-radius: 20px !important;
  padding: 24px !important;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6) !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 16px !important;
  animation: oblModalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  max-height: calc(100vh - 48px) !important;
  overflow-y: auto !important;
  margin: 0 auto !important;
  justify-self: center !important;
  align-self: center !important;
}
.modal-overlay.modal-wide .modal-form,
.modal-overlay.modal-wide.modal-form {
  width: min(1400px, calc(100vw - 48px)) !important;
  max-width: calc(100vw - 48px) !important;
}
@keyframes oblModalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: none; } }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid-5 { grid-template-columns: repeat(5, 1fr); gap: 10px 12px; }
.form-grid .field { margin: 0; }
.form-grid .field-label { font-size: 11.5px; }
.form-grid .field-control input { font-size: 13px; padding: 8px 10px; }
.form-grid .field input, .form-grid .field textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: inherit; resize: vertical; min-height: 60px; line-height: 1.5; }
.form-grid .field input:focus, .form-grid .field textarea:focus { outline: none; border-color: var(--accent, #6366f1); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.form-grid .field textarea::placeholder { color: var(--muted); }
.form-grid .field.full-width { grid-column: 1 / -1; }
.field.full-width { margin-top: 4px; }




.val-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.val-pair .field { margin: 0; }
.obl-due { font-weight: 600; white-space: nowrap; }
.obl-date { display: block; font-size: 11px; margin-top: 2px; }
.obl-comments { display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root[data-theme="light"] .obl-comments { color: #475569; }
@media (max-width: 900px) {
  .form-grid-5 { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}

/* Estado del pago (obligaciones) */
.status-tag.pay-paid { background: rgba(34,197,94,0.14); color: #4ade80; border: 1px solid rgba(34,197,94,0.35); }
.status-tag.pay-pending { background: rgba(245,158,11,0.14); color: #fbbf24; border: 1px solid rgba(245,158,11,0.35); }
.status-tag.pay-with_payment { background: rgba(59,130,246,0.14); color: #60a5fa; border: 1px solid rgba(59,130,246,0.35); }
:root[data-theme="light"] .status-tag.pay-paid { background: rgba(22,163,74,0.10); color: #15803d; border-color: rgba(22,163,74,0.30); }
:root[data-theme="light"] .status-tag.pay-pending { background: rgba(217,119,6,0.10); color: #b45309; border-color: rgba(217,119,6,0.30); }
:root[data-theme="light"] .status-tag.pay-with_payment { background: rgba(37,99,235,0.10); color: #1d4ed8; border-color: rgba(37,99,235,0.30); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== MÓDULO APIS ===== */
.page-title { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 800; margin: 0 0 4px; }
.page-title svg { color: var(--accent-2); }
.page-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; line-height: 1.5; }
.dim { color: var(--muted); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 15px; font-weight: 700; margin: 0; }
.btn-sm { padding: 7px 13px; font-size: 12.5px; border-radius: 8px; }
.btn.is-disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* Paginador */
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; width: 100%; padding: 4px 0;
}
.pager-info { font-size: 12.5px; color: var(--muted); }
.pager-links { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pager-num {
  min-width: 32px; height: 32px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: 13px; font-weight: 600;
  background: var(--surface);
}
.pager-num:hover { border-color: var(--border-2); }
.pager-num.is-active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.pager-ellipsis { color: var(--muted); padding: 0 2px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); font-weight: 600; padding: 12px 18px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 12px 18px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); font-size: 13px; vertical-align: middle; }
.tbl tbody tr { transition: background 0.12s ease; }
.tbl tbody tr:hover { background: var(--row-hover); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl-doc th { width: 150px; }
.empty-row td { text-align: center; color: var(--muted); padding: 36px 18px; font-size: 13px; }
.row-muted td { opacity: 0.55; }
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell .icon-btn { display: inline-flex; align-items: center; justify-content: center; }
.key-label { font-weight: 600; }
.new-key-banner { background: linear-gradient(135deg, rgba(99,102,241,0.16), rgba(34,211,238,0.10)); border: 1px solid rgba(99,102,241,0.40); border-radius: 14px; padding: 18px 22px; margin-bottom: 18px; }
.nk-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.nk-head svg { color: var(--warn); }
.nk-warn { color: var(--warn); font-size: 12.5px; font-weight: 600; }
.nk-token-row { display: flex; gap: 10px; align-items: stretch; margin-top: 12px; }
.nk-token { flex: 1; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border-2); border-radius: 8px; padding: 10px 12px; word-break: break-all; user-select: all; }
.nk-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.doc-card{border-color:var(--border)}
.doc-body { padding: 18px 22px; }
.doc-body h3 { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); margin: 20px 0 8px; }
.doc-body h3:first-child { margin-top: 0; }
.doc-body p { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 6px 0; }
.doc-code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; }
.doc-pre { font-family: var(--mono); font-size: 12px; line-height: 1.65; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; overflow-x: auto; white-space: pre; margin: 8px 0 14px; color: var(--text); }
.doc-list { margin: 6px 0 14px; padding-left: 18px; font-size: 13px; color: var(--muted); line-height: 1.75; }
.doc-list li::marker { color: var(--accent-2); }
.status-tag.st-active { background: rgba(52, 211, 153, 0.12); color: var(--ok); }
.status-tag.st-expired { background: rgba(251, 191, 36, 0.12); color: var(--warn); }
.status-tag.st-revoked { background: rgba(248, 113, 113, 0.12); color: var(--err); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
:root[data-theme="light"] .nk-token { background: #f1f3fb; }
:root[data-theme="light"] .doc-pre { background: #f1f3fb; }
:root[data-theme="light"] .new-key-banner { background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(34,211,238,0.06)); }
/* ====== TABS PAGINA APIS ====== */
.apis-card { padding: 0; overflow: hidden; }
.tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--bg2); overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 13px 14px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: color .15s, border-color .15s; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
.tab svg { opacity: .8; }
.tab-count { background: var(--bg3); color: var(--muted); font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.tab-panel { display: none; padding: 20px; }
/* La cabecera de la tab rompe el padding del panel para quedar edge-to-edge (no flotante) */
.tab-panel > .card-head { margin: -20px -20px 18px; padding: 14px 16px; }
.tab-panel.is-active { display: block; }

/* --- Tab: visión general --- */
.ov-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.ov-title-block { flex: 1 1 380px; }
.ov-title-block h3 { margin: 0 0 6px; font-size: 18px; }
.ov-title-block p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; max-width: 560px; }
.ov-base { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ov-base-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); font-weight: 600; }
.ov-base-url { font-size: 13px; padding: 8px 12px; }
.ov-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-mini { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-size: 22px; font-weight: 700; color: var(--text); }
.stat-lbl { font-size: 11px; color: var(--muted); }
.ov-h { margin: 4px 0 10px; font-size: 14px; }
.ov-next { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

/* --- Tab: documentación --- */
.doc-body { max-width: 860px; }
.doc-body h3 { margin: 26px 0 8px; font-size: 15px; }
.doc-body h3:first-child { margin-top: 0; }
.doc-body p { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 6px 0; }
.doc-body code { font-family: 'JetBrains Mono', monospace; font-size: 12px; background: var(--bg3); padding: 1px 6px; border-radius: 5px; color: var(--text); }
.doc-code { display: inline-block; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-family: 'JetBrains Mono', monospace; font-size: 13px; margin: 4px 0; }
.doc-pre { background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; font-family: 'JetBrains Mono', monospace; font-size: 12px; line-height: 1.6; overflow-x: auto; white-space: pre; color: var(--text); margin: 8px 0; }
.doc-list { margin: 6px 0; padding-left: 20px; }
.doc-list li { color: var(--muted); font-size: 13px; line-height: 1.7; }
.doc-list b { color: var(--text); }
.doc-sub { font-size: 12px; font-weight: 600; color: var(--accent); margin: 18px 0 6px; font-family: 'JetBrains Mono', monospace; }
.tbl-doc { margin: 8px 0 14px; }
.tbl-doc th, .tbl-doc td { font-size: 12.5px; padding: 9px 12px; }
.tbl-doc .mono { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; white-space: nowrap; }
.m { display: inline-block; font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 5px; margin-right: 3px; }
.m-get { color: #22c55e; background: rgba(34,197,94,.12); }
.m-post { color: #3b82f6; background: rgba(59,130,246,.12); }
.m-put { color: #f59e0b; background: rgba(245,158,11,.12); }
.m-del { color: #ef4444; background: rgba(239,68,68,.12); }
.m-patch { color: #a78bfa; background: rgba(167,139,250,.14); }

/* --- Tab: API keys --- */
.keys-table-wrap { overflow-x: auto; }
.key-label { font-weight: 600; }
.actions-cell { white-space: nowrap; text-align: right; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: var(--bg3); border: 1px solid var(--border); color: var(--muted); cursor: pointer; transition: all .15s; }
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn.danger:hover { color: #ef4444; border-color: #ef4444; }
.status-tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.st-active { color: #22c55e; background: rgba(34,197,94,.12); }
.st-revoked { color: var(--muted-2); background: var(--bg3); }
.st-expired { color: #f59e0b; background: rgba(245,158,11,.12); }
.row-muted { opacity: .55; }
.tag { display: inline-block; font-size: 11px; color: var(--muted); background: var(--bg3); padding: 3px 9px; border-radius: 999px; }
.empty-row td { padding: 28px 18px; text-align: center; color: var(--muted); }

/* --- Banner de key recién creada --- */
.new-key-banner { background: linear-gradient(135deg, rgba(99,102,241,.14), rgba(34,211,238,.10)); border: 1px solid rgba(99,102,241,.4); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.nk-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.nk-warn { font-size: 12px; color: #fbbf24; }
.nk-token-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nk-token { font-family: 'JetBrains Mono', monospace; font-size: 13px; background: rgba(0,0,0,.35); padding: 9px 12px; border-radius: 8px; word-break: break-all; flex: 1 1 320px; }
.nk-meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }

/* --- Tab: ejemplos --- */
.ex-body { max-width: 980px; }
.ex-body > p { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.ex-body code { font-family: 'JetBrains Mono', monospace; font-size: 12px; background: var(--bg3); padding: 1px 6px; border-radius: 5px; }
.ex-hero {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
  flex-wrap: wrap; margin-bottom: 16px;
}
.ex-hero h3 { margin: 0 0 6px; font-size: 18px; }
.ex-hero p { margin: 0; color: var(--muted); font-size: 13px; max-width: 62ch; line-height: 1.5; }
.ex-dl { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.ex-kit {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
  margin-bottom: 18px;
}
.ex-kit__item {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px;
}
.ex-kit__item strong { font-size: 12px; }
.ex-kit__item span { font-size: 12px; color: var(--muted); line-height: 1.4; }
@media (max-width: 900px) {
  .ex-kit { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .ex-kit { grid-template-columns: 1fr; }
}
.ex-lang-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.ex-lang { padding: 7px 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg2); color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s; }
.ex-lang:hover { color: var(--text); }
.ex-lang.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ex-pane { display: none; }
.ex-pane.is-active { display: block; }
.ex-block { margin-bottom: 18px; }
.ex-block__head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.ex-block__head h4 { margin: 0; font-size: 14px; }
.ex-block__head .muted { font-size: 12px; }
.ex-pre { position: relative; background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; font-family: 'JetBrains Mono', monospace; font-size: 12px; line-height: 1.65; overflow: auto; white-space: pre; max-height: 520px; }
.ex-copy { position: sticky; float: right; top: 0; margin: -6px 0 0 -6px; z-index: 1; }

/* ===== Webhooks ===== */
.wh-hero {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
  flex-wrap: wrap; margin-bottom: 16px;
}
.wh-hero h3 { margin: 0 0 6px; font-size: 18px; }
.wh-hero p { margin: 0; color: var(--muted); font-size: 13px; max-width: 68ch; line-height: 1.5; }
.wh-hero-actions {
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.wh-ex-pane { display: none; }
.wh-ex-pane.is-active { display: block; }
.wh-kit .ex-block__head h4 { font-size: 13px; }
.wh-company-chip {
  align-self: center; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg2); font-size: 13px; font-weight: 600;
}
.wh-company-form { min-width: 220px; }
.wh-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px;
}
@media (max-width: 960px) {
  .wh-grid { grid-template-columns: 1fr; }
}
.wh-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; margin-bottom: 14px;
}
.wh-card--full { margin-bottom: 14px; }
.wh-card__head {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  margin-bottom: 10px;
}
.wh-card__head h4, .wh-card > h4 { margin: 0 0 8px; font-size: 15px; }
.wh-card__head h4 { margin: 0; }
.wh-key-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 12px 0 14px;
}
.wh-key-prefix {
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  background: var(--bg3); padding: 6px 10px; border-radius: 8px;
}
.wh-verify { margin-top: 14px; }
.wh-verify strong { display: block; font-size: 12px; margin-bottom: 6px; }
.wh-add-form { display: grid; gap: 10px; }
.wh-events {
  display: flex; flex-wrap: wrap; gap: 12px 16px; font-size: 12px; color: var(--muted);
}
.wh-events label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.wh-urls { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.wh-url {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg3);
}
.wh-url.is-off { opacity: .55; }
.wh-url__main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.wh-url__href {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; word-break: break-all;
  color: var(--muted);
}
.wh-url__meta { display: flex; flex-direction: column; gap: 2px; font-size: 11px; }
.wh-url__actions { display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0; }
.wh-inline { margin: 0; }
.btn.danger, .btn-ghost.danger { color: #ef4444; }

/* ===== API Labs ===== */
.doc-callout {
  margin: 16px 0 20px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.doc-callout h4 { margin: 0 0 8px; font-size: 14px; }
.doc-callout > p { margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.doc-callout .doc-pre { margin: 10px 0 0; }
.lab-tip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  margin: 0 0 16px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid rgba(37, 99, 235, .25);
  background: rgba(37, 99, 235, .08);
  font-size: 13px; line-height: 1.45; color: var(--text);
}
.lab-tip strong { font-weight: 750; }
.lab-tip code { font-size: 12px; }
.lab-hero {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.lab-hero h3 { margin: 0 0 6px; font-size: 18px; }
.lab-hero p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 560px; line-height: 1.5; }
.lab-empty {
  text-align: center; padding: 48px 24px;
  border: 1px dashed var(--border); border-radius: 16px;
  background: var(--surface);
}
.lab-empty-ico {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px;
  display: grid; place-items: center;
  background: rgba(37, 99, 235, .12); color: var(--accent, #6366f1);
}
.lab-empty h4 { margin: 0 0 8px; font-size: 17px; }
.lab-empty p { margin: 0 auto 18px; max-width: 420px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.lab-keybar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  margin-bottom: 16px; padding: 14px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface);
}
.lab-key-field { flex: 1 1 320px; margin: 0; }
.lab-key-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 2px; }
.lab-layout {
  display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 14px; align-items: start;
}
.lab-catalog {
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
  max-height: min(70vh, 720px); overflow: auto;
}
.lab-group + .lab-group { border-top: 1px solid var(--border); }
.lab-group__h {
  padding: 10px 12px; font-size: 10px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.lab-ep {
  width: 100%; display: flex; align-items: center; gap: 8px;
  text-align: left; padding: 9px 12px; border: 0; background: transparent;
  color: var(--text); cursor: pointer; font: inherit;
}
.lab-ep:hover { background: var(--bg2, rgba(255,255,255,.03)); }
.lab-ep.is-active { background: rgba(99,102,241,.12); }
.lab-ep__path {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lab-ep__write {
  margin-left: auto; font-size: 9px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: #b45309; background: #fff7ed;
  border: 1px solid #fed7aa; border-radius: 999px; padding: 2px 6px;
}
.lab-runner {
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
  padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.lab-req-row {
  display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px;
}
.lab-method-field, .lab-url-field { margin: 0; }
@media (max-width: 720px) {
  .lab-req-row { grid-template-columns: 1fr; }
}
.lab-runner__head {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap;
}
.lab-runner__head h4 { margin: 0 0 4px; font-size: 15px; font-family: 'JetBrains Mono', ui-monospace, monospace; }
.lab-runner__head p { margin: 0; font-size: 12.5px; }
.lab-warn {
  padding: 10px 12px; border-radius: 10px; font-size: 12.5px;
  color: #9a3412; background: #fff7ed; border: 1px solid #fed7aa;
}
.lab-body {
  width: 100%; min-height: 140px; box-sizing: border-box; resize: vertical;
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg3, var(--bg2)); color: var(--text);
}
.lab-meta-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lab-pill {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; border: 1px solid var(--border); background: var(--bg2);
}
.lab-pill.is-ok { color: #065f46; background: #ecfdf5; border-color: #a7f3d0; }
.lab-pill.is-err { color: #9f1239; background: #fff1f2; border-color: #fecdd3; }
.lab-pill.is-run { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.lab-json {
  margin: 0; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg3, #0b0e1c); color: #e2e8f0;
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; line-height: 1.6;
  max-height: min(52vh, 520px); overflow: auto; white-space: pre;
}
:root[data-theme="light"] .lab-json { background: #0f172a; color: #e2e8f0; }
@media (max-width: 900px) {
  .lab-layout { grid-template-columns: 1fr; }
  .lab-catalog { max-height: 260px; }
}

/* --- Tema claro --- */
:root[data-theme="light"] .new-key-banner { background: linear-gradient(135deg, rgba(99,102,241,.08), rgba(34,211,238,.06)); }
:root[data-theme="light"] .nk-token { background: rgba(255,255,255,.7); }

/* --- Tabla de API keys: no compactar columnas, scroll si no cabe --- */
#keysTable { min-width: 760px; }

/* ===== Dashboard Empresa (premium) ===== */
.co-dash-card {
  position: relative;
  overflow: hidden;
}
.co-dash-card::before {
  content: '';
  position: absolute;
  top: -80px; right: -80px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--mark, #6366f1) 0%, transparent 70%);
  opacity: 0.14;
  pointer-events: none;
}
.co-dash-card { display: flex; flex-direction: column; gap: 14px; }
/* Cabecera premium de la tarjeta */
.co-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 2px 12px;
  border-bottom: 1px solid var(--border);
}
.co-head .company-mark {
  width: 44px; height: 44px;
  border-radius: 13px;
  font-size: 18px;
  background: var(--mark, #6366f1);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}
.co-head h3 { margin-bottom: 2px; }
/* Barras mensuales de obligaciones */
.co-bars-wrap {
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px 18px 10px;
}
.co-sec-title {
  margin: 0 0 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.co-bars {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 96px;
  padding-bottom: 8px;
  overflow-x: auto;
}
.co-bar {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  min-width: 52px;
  height: 100%;
  position: relative;
}
.co-bar-fill {
  width: 26px;
  border-radius: 8px 8px 0 0;
  margin-bottom: 6px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.18);
  transition: height 0.2s ease;
}
.co-bar b {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.co-bar i {
  margin-top: 3px;
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.co-info-list {
  list-style: none;
  margin: 0;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.co-info-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px dashed var(--border-2);
}
.co-info-list li:last-child { border-bottom: none; }
.co-info-list span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  flex-shrink: 0;
}
.co-info-list b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.pw-date { color: var(--muted-2); }

/* Donut de obligaciones */
.donut-center-num {
  font-size: 22px;
  font-weight: 700;
  fill: var(--text);
}
.donut-center-lab {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  fill: var(--muted-2);
}
.co-donut-row {
  display: grid;
  place-items: center;
  padding: 16px 0;
}
.donut-svg { filter: drop-shadow(0 8px 24px rgba(99, 102, 241, 0.25)); }
.donut-seg { transition: stroke-width 0.2s ease; }

/* Leyenda del donut de estados */
.co-donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}
.co-donut-legend li {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.co-donut-legend i {
  width: 8px; height: 8px;
  min-width: 8px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(99,102,241,.25);
}
.co-donut-legend b { font-weight: 700; color: var(--text); }

/* Mini stats de obligaciones */
.co-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.co-stats-row span {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.co-stats-row b { display: block; margin-top: 4px; font-weight: 700; }

/* Acciones de la empresa */
.co-actions-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Estado activo/inactivo de la empresa */
.st-active { color: var(--ok); }
.st-disabled { color: #f87171; }

/* ===== Dashboard premium v2 ===== */
.dash-alert { margin: 0 0 16px; }
.dash-hero {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  padding: 22px 24px;
  margin-bottom: 16px;
}
.dash-hero::before {
  content: '';
  position: absolute; inset: -40% -10% auto auto;
  width: 340px; height: 340px; border-radius: 50%;
  background: radial-gradient(circle, var(--mark, #6366f1) 0%, transparent 70%);
  opacity: .18; pointer-events: none;
}
.dash-hero-main {
  position: relative;
  display: flex; flex-wrap: wrap; gap: 18px;
  align-items: center; justify-content: space-between;
}
.dash-hero-brand { display: flex; gap: 14px; align-items: center; min-width: 0; }
.dash-hero-logo, .dash-hero-mark {
  width: 56px; height: 56px; border-radius: 16px; flex: 0 0 auto;
  object-fit: cover;
  box-shadow: 0 10px 28px rgba(99,102,241,.28);
}
.dash-hero-mark {
  display: grid; place-items: center;
  background: var(--mark, #6366f1); color: #fff;
  font-weight: 800; font-size: 22px;
}
.dash-eyebrow {
  margin: 0 0 4px; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
}
.dash-hero-title { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.dash-hero-sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; max-width: 520px; line-height: 1.45; }
.dash-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.dash-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.dash-kpi {
  text-decoration: none; color: inherit;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card-bg);
  padding: 16px 16px 14px;
  display: flex; flex-direction: column; gap: 6px;
  transition: transform .15s ease, border-color .15s ease;
  min-width: 0;
}
.dash-kpi:hover { transform: translateY(-2px); border-color: var(--border-2); }
.dash-kpi-lab {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600;
}
.dash-kpi-val {
  font-size: 28px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1;
}
.dash-kpi-money { font-size: 22px; }
.dash-kpi-sub { font-size: 12px; color: var(--muted-2); line-height: 1.35; }
.dash-kpi.ok .dash-kpi-val { color: var(--ok); }
.dash-kpi.warn .dash-kpi-val { color: var(--warn); }
.dash-kpi.alert {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--warn) 18%, transparent);
}
.dash-kpi.alert .dash-kpi-val { color: var(--warn); }

.dash-sec-title {
  margin: 0 0 12px; font-size: 13px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.dash-quick { margin-bottom: 18px; }
.dash-quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.dash-quick-card {
  display: flex; gap: 12px; align-items: flex-start;
  text-decoration: none; color: inherit;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--card-bg); padding: 14px;
  transition: border-color .15s ease, transform .15s ease;
}
.dash-quick-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.dash-quick-card b { display: block; font-size: 13.5px; margin-bottom: 2px; }
.dash-quick-card span:last-child { font-size: 12px; color: var(--muted); line-height: 1.35; }
.dash-quick-ico {
  width: 36px; height: 36px; border-radius: 11px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--accent);
}
.dash-quick-ico.i-obl { color: #818cf8; }
.dash-quick-ico.i-pay { color: #34d399; }
.dash-quick-ico.i-fb { color: #fbbf24; }
.dash-quick-ico.i-mail { color: #22d3ee; }
.dash-quick-ico.i-hist { color: #a78bfa; }
.dash-quick-ico.i-cfg { color: #94a3b8; }
.dash-quick-ico.i-portal { color: #60a5fa; }
.dash-quick-ico.i-lock { color: #f472b6; }

.dash-main-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.dash-co-card { display: flex; flex-direction: column; gap: 16px; position: relative; overflow: hidden; }
.dash-co-card::before {
  content: ''; position: absolute; top: -90px; right: -70px;
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, var(--mark,#6366f1) 0%, transparent 70%);
  opacity: .14; pointer-events: none;
}
.dash-co-head {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.dash-co-logo {
  width: 44px; height: 44px; border-radius: 13px; object-fit: cover;
  box-shadow: 0 6px 18px rgba(99,102,241,.3);
}
.dash-co-titles { flex: 1; min-width: 0; }
.dash-co-titles h2 { margin: 0; font-size: 17px; }
.dash-co-split {
  display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center;
}
.dash-co-viz { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.dash-co-metrics {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px;
}
.dash-metric {
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  padding: 10px 12px;
}
.dash-metric span {
  display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: 4px;
}
.dash-metric b { font-size: 15px; font-weight: 750; }
.dash-metric.is-warn b { color: var(--warn); }
.dash-metric.is-alert b { color: var(--warn); }
.dash-mail-strip {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  font-size: 12.5px;
}
.dash-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.dash-pill.is-busy { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.dash-pill.is-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.dash-co-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.dash-lists-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}
.dash-list-card { padding: 16px 18px; }
.dash-list-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  margin-bottom: 12px;
}
.dash-list-head h2 { margin: 0; font-size: 15px; }
.dash-list-head .sub { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.dash-empty { margin: 8px 0; color: var(--muted); font-size: 13px; }
.dash-feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.dash-feed li {
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
  padding: 12px 13px; display: flex; flex-direction: column; gap: 4px;
}
.dash-feed-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.dash-feed-top time { font-size: 11px; color: var(--muted-2); }
.dash-feed b { font-size: 13px; }
.dash-feed p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.dash-feed-amt { font-weight: 750; font-size: 14px; color: var(--ok); }
.admin-quick { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1100px) {
  .dash-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-lists-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .dash-kpis { grid-template-columns: 1fr 1fr; }
  .dash-co-split { grid-template-columns: 1fr; }
  .dash-hero-title { font-size: 22px; }
  .admin-quick { grid-template-columns: 1fr 1fr; }
}

/* ===== MODAL DETALLE DEL PAGO ===== */
.pay-ref-cell {
  max-width: 220px;
  vertical-align: middle;
}
.pay-ref-code {
  display: inline-block;
  max-width: 180px;
  padding: 2px 7px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.pay-ref-more {
  margin-left: 6px;
  font-size: 11px;
  white-space: nowrap;
}

.pd-modal { max-width: 860px; }
.pd-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg2, var(--surface));
}
.pd-meta-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pd-meta-lab { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.pd-meta-val { font-size: 13px; color: var(--text); word-break: break-word; }
.pd-meta-val.mono, .pd-meta .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.pd-meta a { color: var(--accent, #6366f1); word-break: break-all; font-size: 12px; }
.pd-obl-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--card-bg, var(--surface));
}
.pd-obl-card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.pd-obl-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}
.pd-kv { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pd-kv span { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.pd-kv b { font-size: 13px; font-weight: 600; color: var(--text); word-break: break-word; }
.pd-kv small { font-size: 11px; }
.pd-kv-full { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .pd-meta, .pd-obl-grid { grid-template-columns: 1fr; }
}
.pd-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 4px 0 18px;
}
.pd-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
}
.pd-stat-lab {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
}
.pd-stat-val { font-size: 16px; font-weight: 700; color: var(--text); }
.pd-stat-val.sm { font-size: 13px; font-weight: 600; }
.pd-obl-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 10px;
}
.pd-obl-head h4 { margin: 0; font-size: 14px; color: var(--text); }
.pd-obl-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
}
.pd-obl-wrap {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.pd-obl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pd-obl-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg2);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.pd-obl-table thead th.num { text-align: right; }
.pd-obl-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.pd-obl-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pd-obl-table tbody tr:last-child td { border-bottom: none; }
.pd-obl-table tbody tr:hover td { background: var(--bg2); }
.pd-empty { padding: 26px 16px; text-align: center; color: var(--muted); margin: 0; }
@media (max-width: 620px) {
  .pd-summary { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Modal confirmación eliminar ===== */
.modal.modal-confirm[open] {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  place-items: center;
}
.modal-confirm .confirm-card {
  width: min(440px, calc(100vw - 32px));
  background: var(--modal-bg);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  padding: 28px 28px 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: confirmIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-confirm .confirm-ico { margin: 0 auto 16px; }
.modal-confirm .modal-actions { justify-content: center; }
@keyframes confirmIn { from { opacity: 0; transform: scale(0.92) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.confirm-ico {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  margin-bottom: 16px; color: var(--err);
  background: rgba(248, 113, 113, 0.12); border: 1px solid rgba(248, 113, 113, 0.28);
}
.confirm-ico svg { width: 28px; height: 28px; }
.confirm-title { margin: 0 0 6px; font-size: 19px; font-weight: 700; color: var(--text); }
.confirm-sub { margin: 0 0 18px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.occ-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px 14px; margin-bottom: 20px;
}
.occ-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.occ-row:last-child { border-bottom: none; }
.occ-k { font-size: 12.5px; color: var(--muted); }
.occ-v { font-size: 13.5px; font-weight: 600; color: var(--text); text-align: right; word-break: break-word; }
.occ-val { color: var(--err); }
.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; border: 1px solid rgba(220, 38, 38, 0.6);
}
.btn-danger:hover { filter: brightness(1.08); }
.btn-danger:disabled { opacity: 0.6; cursor: not-allowed; filter: none; }

/* ===== Historial (auditoría) ===== */
.table-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.field-actions { display: flex; align-items: flex-end; gap: 8px; }
.log-date { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.logs-table td { vertical-align: middle; }
.ent-tag, .act-tag, .src-tag {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 99px; white-space: nowrap;
}
.ent-obligation { background: rgba(99, 102, 241, 0.14); color: #a5b4fc; }
.ent-payment    { background: rgba(34, 211, 238, 0.14); color: var(--accent-2); }
.ent-api_key    { background: rgba(245, 158, 11, 0.16); color: #fbbf24; }
.ent-webhook    { background: rgba(16, 185, 129, 0.14); color: #34d399; }
.act-rotated    { background: rgba(245, 158, 11, 0.14); color: #fbbf24; }
.act-revoked    { background: rgba(239, 68, 68, 0.14); color: #f87171; }
.act-created { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.act-updated { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.act-toggled { background: rgba(99, 102, 241, 0.14); color: #a5b4fc; }
.act-deleted { background: rgba(248, 113, 113, 0.14); color: var(--err); }
.src-tag { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.empty-cell { text-align: center; color: var(--muted); padding: 34px 16px; }
.table-foot { margin-top: 12px; font-size: 12px; color: var(--muted); }

/* ============ Admin panel polish ============ */
.nav-label + .nav-item { margin-top: 2px; }
.nav-label:not(:first-child) { margin-top: 14px; }
.nav-item.is-energy.active {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.22);
}
.admin-dash { display: flex; flex-direction: column; gap: 8px; }
.admin-dash-intro {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 6px 2px 14px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.admin-eyebrow {
  margin: 0 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent-2);
}
.admin-dash-title { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.admin-dash-sub { margin: 6px 0 0; font-size: 13px; }
.admin-dash-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 18px 2px 10px;
}
.admin-section-head h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.admin-section-head .muted { font-size: 12px; }
.admin-live-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.admin-inv-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1400px) {
  .admin-live-grid, .admin-inv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .admin-dash-intro { flex-direction: column; align-items: flex-start; }
  .admin-live-grid, .admin-inv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .admin-live-grid, .admin-inv-grid { grid-template-columns: 1fr; }
}

.sip-trunks-card { padding: 16px 18px; margin-bottom: 8px; }
.sip-trunks-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.sip-trunks-table-wrap { overflow-x: auto; }
.sip-trunks-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.sip-trunks-table th,
.sip-trunks-table td {
  text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.sip-trunks-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700;
}
.sip-trunks-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sip-trunks-table a { color: inherit; text-decoration: none; }
.sip-trunks-table a:hover { color: var(--accent, #6366f1); }
.dash-pill.is-alert {
  background: rgba(239, 68, 68, .14);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, .35);
}
.dash-pill.is-busy {
  background: rgba(34, 211, 238, .12);
  color: #67e8f9;
  border: 1px solid rgba(34, 211, 238, .35);
}

/* ============ PayNow BotGuard ============ */
.pn-bg-host { margin: 2px 0 4px; }
.pn-bg-widget {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--border-2);
  background: var(--surface);
}
.pn-bg-box {
  display: inline-flex; align-items: center; gap: 12px;
  background: transparent; border: 0; padding: 0; cursor: pointer;
  color: var(--text); font: inherit; font-weight: 600; font-size: 14px;
  text-align: left;
}
.pn-bg-check {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1.5px solid var(--border-2);
  background: var(--card-bg, var(--bg2));
  display: grid; place-items: center; position: relative;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.pn-bg-check svg { position: absolute; inset: 0; margin: auto; }
.pn-bg-ico-spin, .pn-bg-ico-ok { opacity: 0; transform: scale(.7); }
.pn-bg-ico-empty { opacity: 1; color: var(--muted); }
.pn-bg-box:hover .pn-bg-check { border-color: var(--accent); }
.pn-bg-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 110px; }
.pn-bg-brand {
  font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.pn-bg-status { font-size: 11px; color: var(--muted); text-align: right; max-width: 150px; line-height: 1.3; }
.pn-bg-hp {
  position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important;
  opacity: 0 !important; pointer-events: none !important;
}

.pn-bg-host[data-state="loading"] .pn-bg-ico-empty,
.pn-bg-host[data-state="verifying"] .pn-bg-ico-empty { opacity: 0; }
.pn-bg-host[data-state="loading"] .pn-bg-ico-spin,
.pn-bg-host[data-state="verifying"] .pn-bg-ico-spin {
  opacity: 1; transform: none; color: var(--accent);
  animation: pnBgSpin .8s linear infinite;
}
.pn-bg-host[data-state="ok"] .pn-bg-check {
  border-color: rgba(52,211,153,.55);
  background: rgba(52,211,153,.14);
  box-shadow: 0 0 0 3px rgba(52,211,153,.12);
}
.pn-bg-host[data-state="ok"] .pn-bg-ico-empty,
.pn-bg-host[data-state="ok"] .pn-bg-ico-spin { opacity: 0; }
.pn-bg-host[data-state="ok"] .pn-bg-ico-ok { opacity: 1; transform: none; color: var(--ok); }
.pn-bg-host[data-state="ok"] .pn-bg-status { color: var(--ok); font-weight: 600; }
.pn-bg-host[data-state="err"] .pn-bg-check { border-color: rgba(248,113,113,.5); background: rgba(248,113,113,.1); }
.pn-bg-host[data-state="err"] .pn-bg-status { color: var(--err); }
.pn-bg-host[data-state="ready"] .pn-bg-status { color: var(--muted); }
@keyframes pnBgSpin { to { transform: rotate(360deg); } }
.pn-bg-shake { animation: pnBgShake .4s ease; }
@keyframes pnBgShake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
:root[data-theme="light"] .pn-bg-widget {
  background: rgba(255,255,255,.85);
}
.dash-pill.is-warn { color: #fbbf24; border-color: color-mix(in srgb, #fbbf24 40%, var(--border)); }

/* Experiencias telefónicas */
.pe-page { padding: 0; overflow: hidden; }
.pe-page .pe-head {
  display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-start; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border); margin: 0;
}
.pe-page .pe-head h2 { margin: 0; font-size: 16px; }
.pe-page .card-body,
.pe-page .pe-wizard { padding: 18px 22px 22px; }
.pe-head-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pe-company-form select {
  min-width: 180px; height: 38px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.pe-empty { text-align: center; padding: 36px 16px; display: grid; gap: 10px; justify-items: center; }
.pe-table td, .pe-table th { vertical-align: middle; }
.pe-row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.pe-inline-form { display: inline; margin: 0; }
.pe-chip { font-size: 12px; }
.pe-chip-warn { color: #ca8a04; border-color: color-mix(in srgb, #ca8a04 35%, var(--border)); }
.pe-status-draft { opacity: .9; }
.pe-status-ready { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.pe-status-archived { opacity: .65; }
.pe-wizard { display: grid; gap: 20px; }
.pe-steps { display: flex; flex-wrap: wrap; gap: 8px; }
.pe-step {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600;
  background: var(--surface);
}
.pe-step > span:first-child {
  width: 22px; height: 22px; border-radius: 999px; display: inline-grid; place-items: center;
  background: color-mix(in srgb, var(--surface) 60%, #0000); border: 1px solid var(--border); font-size: 12px;
}
.pe-step.is-active { color: var(--text); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.pe-step.is-done { color: var(--text); }
.pe-step.is-done > span:first-child { background: color-mix(in srgb, var(--ok) 22%, transparent); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.pe-section { display: grid; gap: 10px; }
.pe-section-title { margin: 0; font-size: 14px; font-weight: 700; }
.pe-templates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.pe-template {
  text-align: left; cursor: pointer;
  display: grid; gap: 6px;
  padding: 14px 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.pe-template strong { font-size: 14px; }
.pe-template span { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.pe-template:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); transform: translateY(-1px); }
.pe-template.is-selected {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
.pe-form .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.pe-form .field { margin: 0; }
.pe-form .field-control input,
.pe-form .field-control textarea,
.pe-form .field-control select,
.pe-node .field-control textarea,
.pe-reply textarea,
.pe-reply select {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px; font-size: 13.5px; line-height: 1.45;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: inherit; resize: vertical;
}
.pe-form .field-control input:focus,
.pe-form .field-control textarea:focus,
.pe-node .field-control textarea:focus,
.pe-reply textarea:focus,
.pe-reply select:focus {
  outline: none; border-color: var(--accent, #6366f1);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.pe-hint { margin: 0; }
.pe-form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 4px; }
.pe-nodes { display: grid; gap: 12px; }
.pe-node {
  border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px;
  background: var(--surface); display: grid; gap: 10px;
}
.pe-node header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pe-node.is-stub { opacity: .72; border-style: dashed; }
.pe-bank-toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-start; }
.pe-manual-add {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 88%, var(--accent, #2563eb) 6%);
  display: grid;
  gap: 12px;
}
.pe-manual-add-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; }
.pe-manual-grid { grid-template-columns: minmax(180px, 240px) 1fr; }
.pe-manual-text textarea { min-height: 64px; resize: vertical; }
.pe-replies { display: grid; gap: 10px; margin-top: 14px; }
.pe-reply {
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  display: grid; gap: 8px; background: var(--surface);
}
.pe-reply.is-approved {
  border-color: color-mix(in srgb, var(--ok) 40%, var(--border));
  background: color-mix(in srgb, var(--ok) 8%, var(--surface));
}
.pe-reply-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pe-reply-top select { max-width: 240px; }
.pe-check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text); }
.pe-flow { margin: 0; padding-left: 18px; display: grid; gap: 12px; }
.pe-flow-text { margin-top: 4px; color: var(--text); font-size: 14px; }
.pe-intent-summary { margin: 6px 0 0; padding-left: 16px; color: var(--muted); font-size: 13px; }
.pe-publish-meta { margin: 0 0 12px; padding-left: 18px; display: grid; gap: 6px; }
.pe-publish-actions { gap: 12px; }
.btn.is-danger { color: #f87171; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
@media (max-width: 720px) {
  .pe-form .form-grid { grid-template-columns: 1fr; }
  .pe-row-actions { flex-direction: column; align-items: stretch; }
  .pe-templates { grid-template-columns: 1fr; }
}

.pe-live {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}
.pe-live-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.pe-live-out {
  margin: 0; padding: 12px 14px; min-height: 140px; max-height: 320px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12.5px; line-height: 1.45;
  color: var(--text); background: color-mix(in srgb, var(--surface) 70%, #000 8%);
}
.pe-live #peLiveStatus { padding: 0 14px 12px; }

.pe-move { margin-left: auto; display: inline-flex; gap: 4px; align-items: center; }
.pe-move-form { display: inline; margin: 0; }
.pe-move-btn { min-width: 32px; padding: 4px 8px; line-height: 1; }
.pe-node header { justify-content: flex-start; }
.pe-node-save { margin-top: 4px; }
.pe-row-actions { flex-wrap: wrap; }

.pe-audio {
  width: 100%;
  max-width: 520px;
  height: 36px;
  margin-top: 2px;
}
.pe-audio-missing { margin: 0; font-size: 12.5px; }

/* Panel flotante campaña telefónica */
.pn-camp-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  width: min(360px, calc(100vw - 28px));
  max-height: min(70vh, 560px);
  overflow: auto;
  padding: 14px 14px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, #0b1220 8%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  backdrop-filter: blur(10px);
  display: none;
  flex-direction: column;
  gap: 10px;
}
.pn-camp-panel.is-open {
  display: flex;
}
.pn-camp-panel.is-min {
  width: auto;
  max-width: min(340px, calc(100vw - 28px));
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}
.pn-camp-chip {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, #0b1220 6%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  max-width: 100%;
}
.pn-camp-panel.is-min .pn-camp-chip {
  display: inline-flex;
}
.pn-camp-chip-pct {
  font-weight: 700;
  font-size: 12px;
  color: #0f766e;
}
.pn-camp-chip-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 70%, transparent);
  color: var(--muted);
  white-space: nowrap;
}
.pn-camp-chip-status.is-live {
  color: #0f766e;
  background: color-mix(in srgb, #14b8a6 18%, transparent);
}
.pn-camp-chip-status.is-ok {
  color: #15803d;
  background: color-mix(in srgb, #22c55e 18%, transparent);
}
.pn-camp-chip-status.is-warn {
  color: #b45309;
  background: color-mix(in srgb, #f59e0b 20%, transparent);
}
.pn-camp-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pn-camp-panel.is-min .pn-camp-body {
  display: none;
}
.pn-camp-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.pn-camp-head strong { display: block; font-size: 15px; }
.pn-camp-status {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 70%, transparent);
  color: var(--muted);
}
.pn-camp-status.is-live {
  color: #0f766e;
  background: color-mix(in srgb, #14b8a6 18%, transparent);
}
.pn-camp-status.is-ok {
  color: #15803d;
  background: color-mix(in srgb, #22c55e 18%, transparent);
}
.pn-camp-status.is-warn {
  color: #b45309;
  background: color-mix(in srgb, #f59e0b 20%, transparent);
}
.pn-camp-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}
.pn-camp-sub .dot { opacity: .5; }
.pn-camp-progress-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.pn-camp-bar {
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 80%, transparent);
  overflow: hidden;
}
.pn-camp-bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0d9488, #14b8a6);
  transition: width .35s ease;
}
.pn-camp-stats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.pn-camp-stats li {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
}
.pn-camp-stats b { display: block; font-size: 16px; line-height: 1.1; }
.pn-camp-stats span { font-size: 10.5px; color: var(--muted); }
.pn-camp-total { margin: 0; font-size: 12.5px; }
.pn-camp-current {
  margin: 0;
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px dashed color-mix(in srgb, #14b8a6 45%, var(--border));
  background: color-mix(in srgb, #14b8a6 10%, transparent);
}
.pn-camp-recent {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  max-height: 140px;
  overflow: auto;
}
.pn-camp-recent li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--border) 25%, transparent);
}
.pn-camp-recent em { font-style: normal; color: var(--muted); font-size: 11px; }
.pn-camp-recent .is-ok em { color: #15803d; }
.pn-camp-recent .is-err em { color: #b91c1c; }
.pn-camp-meta { margin: 0; font-size: 11.5px; }
.pn-camp-err {
  margin: 0;
  font-size: 12px;
  color: #b91c1c;
  word-break: break-word;
}
@media (max-width: 720px) {
  .pn-camp-panel { right: 10px; bottom: 10px; width: calc(100vw - 20px); }
  .pn-camp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
