/* Panel EITB 2027 */
:root {
  --accent: #6d28d9;
  --sidebar-w: 264px;
  --radius: 16px;
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e7e9f2;
  --text: #0f172a;
  --muted: #64748b;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --chart-2: #0ea5e9;
  --chart-warn: #f59e0b;
  --grid: rgba(15, 23, 42, .06);
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-border-radius: 10px;
}
[data-bs-theme="dark"] {
  --bg: #0b0f1a;
  --surface: #121829;
  --surface-2: #171e33;
  --border: #232b45;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
  --grid: rgba(148, 163, 184, .12);
  --bs-body-bg: #0b0f1a;
  --bs-body-color: #e2e8f0;
  --bs-tertiary-bg: #171e33;
  --bs-border-color: #232b45;
}

body { font-family: var(--bs-body-font-family); background: var(--bg); color: var(--text); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
.min-w-0 { min-width: 0; }
a { color: var(--accent); }

/* ------------------------------------------------ Layout */
.app { min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: radial-gradient(120% 60% at 0% 0%, color-mix(in srgb, var(--accent) 35%, transparent) 0%, transparent 60%), linear-gradient(180deg, #0b1022 0%, #111733 100%);
  color: #cbd5e1;
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, .04);
}
@media (min-width: 992px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1030; }
  .main { margin-left: var(--sidebar-w); }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { --bs-offcanvas-width: var(--sidebar-w); --bs-offcanvas-bg: #0b1022; }
}
.sidebar-brand { display: flex; align-items: center; padding: 22px 20px 18px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
.brand-mark img { width: 28px; height: 28px; object-fit: contain; }
.brand-name { display: block; color: #fff; font-weight: 800; letter-spacing: .04em; font-size: 1.05rem; }
.brand-sub { display: block; color: #8b95b3; font-size: .74rem; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; }
.nav-head { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #6b7699; font-weight: 700; padding: 18px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0; border-radius: 10px; color: #c3cbe0; text-decoration: none; font-weight: 500; font-size: .92rem; transition: background .15s, color .15s; }
.nav-item i { font-size: 1.08rem; width: 20px; text-align: center; opacity: .85; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 85%, #fff 0%) 0%, color-mix(in srgb, var(--accent) 65%, #000 10%) 100%); color: #fff; box-shadow: 0 8px 20px -10px var(--accent); }
.nav-item.active i { opacity: 1; }
.sidebar-user { display: flex; align-items: center; gap: 6px; margin: 12px; padding: 10px; border-radius: 14px; background: rgba(255, 255, 255, .05); }
.sidebar-user .btn-icon { color: #a5b0cc; }
.sidebar-user .btn-icon:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.user-name { color: #fff; font-weight: 600; font-size: .86rem; }
.user-role { color: #8b95b3; font-size: .74rem; }
.avatar { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #0ea5e9)); }
.avatar-sm { width: 32px; height: 32px; border-radius: 10px; font-size: .85rem; }

.main { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 10px; padding: 16px 32px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border); }
.page-title { font-size: 1.32rem; font-weight: 750; margin: 0; letter-spacing: -.01em; }
.page-sub { color: var(--muted); font-size: .85rem; }
.content { padding: 28px 32px 40px; flex: 1; max-width: 1560px; width: 100%; }
.footer { padding: 18px 32px; color: var(--muted); font-size: .78rem; }
@media (max-width: 767.98px) { .topbar { padding: 12px 16px; } .content { padding: 18px 16px 32px; } .footer { padding: 16px; } .page-title { font-size: 1.1rem; } }

.btn-icon { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 10px; border: 0; color: var(--muted); background: transparent; }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.lang-badge { font-size: .72rem; font-weight: 800; letter-spacing: .04em; border: 1.5px solid currentColor; border-radius: 6px; padding: 1px 5px; }
.tenant-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: .88rem; color: var(--text); box-shadow: var(--shadow); }
.tenant-btn:hover, .tenant-btn.show { background: var(--surface); border-color: var(--accent); color: var(--text); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); }
.dropdown-menu { border-color: var(--border); border-radius: 12px; padding: 6px; background: var(--surface); }
.dropdown-item { border-radius: 8px; font-size: .9rem; }
.dropdown-item.active, .dropdown-item:active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); }

/* ------------------------------------------------ Componentes */
.card-soft { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--border); font-weight: 650; font-size: .92rem; }
.card-title-sm { font-size: .95rem; font-weight: 700; margin-bottom: 14px; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; margin: 6px 0 12px; }

.btn-accent { --bs-btn-color: #fff; --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: color-mix(in srgb, var(--accent) 88%, #000); --bs-btn-hover-border-color: color-mix(in srgb, var(--accent) 88%, #000); --bs-btn-active-bg: color-mix(in srgb, var(--accent) 80%, #000); --bs-btn-active-color: #fff; --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent); font-weight: 600; box-shadow: 0 6px 16px -8px var(--accent); }
.btn-light-accent { --bs-btn-color: var(--accent); --bs-btn-bg: color-mix(in srgb, var(--accent) 10%, transparent); --bs-btn-border-color: transparent; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--accent); --bs-btn-active-bg: var(--accent); --bs-btn-active-color: #fff; font-weight: 600; }
.bg-accent { background-color: var(--accent) !important; }
.text-bg-accent { background: var(--accent) !important; color: #fff !important; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 .22rem color-mix(in srgb, var(--accent) 18%, transparent); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-control, .form-select { background-color: var(--surface); border-color: var(--border); }
.form-label { font-weight: 600; font-size: .84rem; color: var(--muted); }

.badge-soft { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-secondary { background: #eef0f6; color: #475569; }
.badge-accent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
[data-bs-theme="dark"] .badge-success { background: rgba(34, 197, 94, .16); color: #86efac; }
[data-bs-theme="dark"] .badge-warning { background: rgba(245, 158, 11, .16); color: #fcd34d; }
[data-bs-theme="dark"] .badge-danger { background: rgba(239, 68, 68, .16); color: #fca5a5; }
[data-bs-theme="dark"] .badge-info { background: rgba(14, 165, 233, .16); color: #7dd3fc; }
[data-bs-theme="dark"] .badge-secondary { background: rgba(148, 163, 184, .14); color: #cbd5e1; }
[data-bs-theme="dark"] .badge-accent { color: color-mix(in srgb, var(--accent) 55%, #fff); }
.code-pill { display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
[data-bs-theme="dark"] .code-pill { color: color-mix(in srgb, var(--accent) 50%, #fff); }

/* KPI */
.kpi-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.kpi { display: block; position: relative; overflow: hidden; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
a.kpi:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -16px color-mix(in srgb, var(--accent) 55%, transparent); color: inherit; }
.kpi-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.15rem; color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, transparent); margin-bottom: 14px; }
.kpi-label { color: var(--muted); font-size: .82rem; font-weight: 600; }
.kpi-value { font-size: 1.7rem; font-weight: 780; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.kpi-accent { background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 60%, #0ea5e9) 100%); border-color: transparent; color: #fff; }
.kpi-accent .kpi-label, .kpi-accent .kpi-sub { color: rgba(255, 255, 255, .8); }
.kpi-accent .kpi-icon { background: rgba(255, 255, 255, .18); color: #fff; }
.kpi-ok .kpi-icon { color: #16a34a; background: rgba(22, 163, 74, .12); }
.kpi-warn .kpi-icon { color: #d97706; background: rgba(217, 119, 6, .12); }
.kpi-bad .kpi-icon { color: #dc2626; background: rgba(220, 38, 38, .12); }
.kpi::after { content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 6%, transparent); }

.feature { display: flex; gap: 16px; align-items: center; text-decoration: none; color: inherit; transition: transform .15s, border-color .15s; }
.feature:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: inherit; }
.feature-icon { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; font-size: 1.4rem; color: #fff; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #0ea5e9)); box-shadow: 0 10px 20px -12px var(--accent); }
.feature-body { flex: 1; min-width: 0; }
.feature-title { display: block; font-weight: 700; font-size: 1rem; }
.feature-desc { display: block; color: var(--muted); font-size: .85rem; margin-top: 2px; }
.feature-arrow { color: var(--muted); transition: transform .15s; }
.feature:hover .feature-arrow { transform: translateX(3px); color: var(--accent); }

.stat-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 22px; box-shadow: var(--shadow); }
.stat-num { display: block; font-size: 1.45rem; font-weight: 780; line-height: 1.1; }
.stat-lbl { color: var(--muted); font-size: .78rem; font-weight: 600; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.search-box { position: relative; min-width: 240px; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box .form-control { padding-left: 36px; border-radius: 999px; }

/* Tablas */
.table-modern { --bs-table-bg: transparent; margin: 0; }
.table-modern > thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 12px 16px; white-space: nowrap; }
.table-modern > tbody td, .table-modern > tbody th, .table-modern > tfoot th { padding: 12px 16px; border-color: var(--border); }
.table-modern > tbody tr:last-child td { border-bottom: 0; }
.table-modern > tfoot th { background: var(--surface-2); border-top: 1px solid var(--border); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: color-mix(in srgb, var(--accent) 5%, transparent); }
.table-scroll { max-height: 460px; overflow-y: auto; }
.table-scroll thead th { position: sticky; top: 0; z-index: 1; }
.group-row td { background: color-mix(in srgb, var(--accent) 6%, var(--surface)) !important; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text); }
.table-invoice .input-group { flex-wrap: nowrap; }
.table-invoice .qty-input { flex: 0 0 110px; width: 110px; font-variant-numeric: tabular-nums; }
.table-invoice .qty-input.is-auto::placeholder { color: var(--text); opacity: .75; }
.row-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); flex: 0 0 auto; }
.total-card { background: linear-gradient(140deg, #0f172a 0%, color-mix(in srgb, var(--accent) 70%, #0f172a) 100%); color: #fff; border: 0; }
td, .kpi-value, .stat-num { font-variant-numeric: tabular-nums; }

/* Filtro de periodo */
.period-filter { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; }
.month-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 13px; border-radius: 999px; font-size: .83rem; font-weight: 600; color: var(--muted); text-decoration: none; background: var(--surface-2); border: 1px solid var(--border); }
.chip:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.range-form .input-group { flex-wrap: nowrap; }
.range-form .input-group-text { background: var(--surface-2); border-color: var(--border); color: var(--muted); }

.nav-pills-soft { gap: 6px; }
.nav-pills-soft .nav-link { color: var(--muted); font-weight: 600; border-radius: 999px; padding: 8px 16px; background: var(--surface); border: 1px solid var(--border); }
.nav-pills-soft .nav-link.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.chart-box { position: relative; height: 320px; }
.list-bars { list-style: none; margin: 0; padding: 8px 20px 16px; max-height: 420px; overflow-y: auto; }
.list-bars li { padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: .88rem; }
.list-bars li:last-child { border-bottom: 0; }
.list-bars .bar { height: 6px; background: var(--surface-2); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.list-bars .bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #0ea5e9)); border-radius: 99px; }

.progress { background: var(--surface-2); }
.progress-dual { height: 10px; border-radius: 99px; }
.time-marker { position: relative; height: 0; }
.time-marker::before { content: ""; position: absolute; top: -14px; width: 2px; height: 18px; background: var(--text); opacity: .55; border-radius: 2px; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state i { font-size: 2.4rem; display: block; margin-bottom: 8px; opacity: .8; }
.empty-state h2 { font-size: 1.2rem; color: var(--text); }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .88rem; }
.back-link:hover { color: var(--accent); }
.perm-matrix th, .perm-matrix td { border-color: var(--border); }
.perm-matrix thead th { font-weight: 600; vertical-align: bottom; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0 6px 14px; border-left: 2px solid var(--border); position: relative; font-size: .86rem; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.ban-chip { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 6px 6px 6px 12px; }
.alert { border-radius: 12px; }
.modal-content { border-radius: 18px; border-color: var(--border); background: var(--surface); }

/* ------------------------------------------------ Login */
.auth { min-height: 100vh; background: var(--bg); }
.auth-wrap { display: flex; min-height: 100vh; }
.auth-hero { flex: 1.1; position: relative; overflow: hidden; align-items: center; justify-content: center; padding: 64px; color: #fff;
  background: radial-gradient(80% 60% at 20% 10%, rgba(139, 92, 246, .55), transparent 60%), radial-gradient(70% 60% at 90% 90%, rgba(14, 165, 233, .45), transparent 60%), linear-gradient(160deg, #0b1022, #141a3a); }
.auth-hero-inner { position: relative; z-index: 2; max-width: 460px; }
.auth-logo { width: 240px; max-width: 70%; filter: brightness(0) invert(1); margin-bottom: 36px; }
.auth-hero h2 { font-size: 2.1rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.auth-hero p { color: rgba(255, 255, 255, .72); font-size: 1.05rem; margin: 14px 0 28px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-points li { background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px; padding: 10px 14px; font-weight: 600; font-size: .9rem; backdrop-filter: blur(6px); }
.auth-points i { margin-right: 6px; color: #c4b5fd; }
.auth-glow { position: absolute; width: 520px; height: 520px; border-radius: 50%; right: -160px; top: -160px; background: radial-gradient(circle, rgba(167, 139, 250, .35), transparent 65%); }
.auth-panel { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 16px; }
.auth-card { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 34px; box-shadow: 0 30px 60px -30px rgba(15, 23, 42, .35); --accent: #6d28d9; }
.auth-mini-logo { height: 34px; }
[data-bs-theme="dark"] .auth-mini-logo { filter: brightness(0) invert(1); }
.auth-title { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 6px; }
.auth-foot { color: var(--muted); font-size: .78rem; margin-top: 22px; }
.auth-icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 1.6rem; color: #fff; background: linear-gradient(135deg, #6d28d9, #0ea5e9); margin-bottom: 18px; box-shadow: 0 12px 24px -12px #6d28d9; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); z-index: 5; }
.input-icon > .form-control { padding-left: 42px; }
.otp-input { text-align: center; font-size: 1.8rem; letter-spacing: .5em; font-weight: 700; font-variant-numeric: tabular-nums; }
.qr-box { display: flex; justify-content: center; }
.qr-box #qr { width: 210px; padding: 10px; background: #fff; border-radius: 16px; border: 1px solid var(--border); }
.qr-box svg { display: block; width: 100%; height: auto; }
.secret-code { font-size: .95rem; letter-spacing: .08em; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; }

@media print {
  .sidebar, .topbar .btn-icon, .tenant-btn, .nav-pills-soft, .toolbar, .footer, form button, .btn { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0; }
  .card-soft { box-shadow: none; }
  .qty-input { border: 0; }
}

/* Lista de canales (kontratua) */
.channel-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2px 20px; margin: 0; padding: 0; list-style: none; counter-reset: ch; font-size: .88rem; }
.channel-list li { counter-increment: ch; display: flex; gap: 8px; padding: 3px 0; min-width: 0; }
.channel-list li::before { content: counter(ch) "."; flex: 0 0 1.6em; text-align: right; color: var(--muted); font-size: .8rem; line-height: 1.6; }
