:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e6eaf2;
  --brand: #6d4cff;
  --brand-2: #8b73ff;
  --green: #16a34a; --green-bg: #dcfce7;
  --amber: #d97706; --amber-bg: #fef3c7;
  --red: #dc2626;   --red-bg: #fee2e2;
  --blue: #0ea5e9;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}
[data-theme="dark"] {
  --bg: #0b0e1a;
  --surface: #141829;
  --surface-2: #1b2034;
  --ink: #e9ecf5;
  --muted: #97a0bd;
  --muted-2: #6b7596;
  --line: #232a42;
  --green-bg: #0e2e1d; --amber-bg: #34280c; --red-bg: #36161a;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased;
}
h1 { font-size: 22px; margin: 0; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: 0; font-weight: 800; }
h3 { font-size: 14px; margin: 0 0 14px; font-weight: 700; }
p { margin: 4px 0 0; }
a { color: inherit; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 11px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; }

/* Botones */
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 9px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.block { width: 100%; padding: 12px; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.danger { color: var(--red); border-color: var(--red-bg); }
.btn.green { color: var(--green); border-color: var(--green-bg); }

/* Login */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(1200px 600px at 70% -10%, rgba(109,76,255,0.25), transparent), var(--bg); z-index: 100; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 30px 28px; width: 360px; max-width: 92vw; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.login-card h2 { margin-top: 14px; }
.login-card label { font-size: 12px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.login-card input { padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); font-size: 14px; outline: none; }
.login-card input:focus { border-color: var(--brand); }
.login-card .btn { margin-top: 18px; }
.login-error { color: var(--red); font-size: 12.5px; min-height: 16px; margin-top: 8px; }
.demo { text-align: center; margin-top: 12px; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 234px; flex-shrink: 0; background: #0f1222; color: #e8eaf3; display: flex; flex-direction: column; padding: 22px 16px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.brand-mark.big { width: 56px; height: 56px; font-size: 28px; border-radius: 16px; align-self: center; }
.brand-name { font-weight: 800; font-size: 17px; }
.brand-sub { font-size: 11px; color: #9aa0c0; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { color: #c7cbe4; text-decoration: none; padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.nav-item .ic { width: 18px; text-align: center; opacity: .8; }
.nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active { background: rgba(109,76,255,0.28); color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.theme-toggle, .logout { background: rgba(255,255,255,0.06); color: #c7cbe4; border: none; padding: 9px; border-radius: 10px; cursor: pointer; font-size: 13px; font-family: inherit; }
.theme-toggle:hover, .logout:hover { background: rgba(255,255,255,0.12); }

.content { flex: 1; padding: 24px 30px 48px; max-width: 1320px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.search input { width: 280px; max-width: 38vw; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; outline: none; }
.search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109,76,255,0.15); }
.user { background: var(--surface); border: 1px solid var(--line); padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 25px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.kpi .hint { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }
.kpi.brand .value { color: var(--brand); }
.kpi.green .value { color: var(--green); }
.kpi.amber .value { color: var(--amber); }
.kpi.red .value { color: var(--red); }

/* Cards / grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 18px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.grid-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }

/* Charts CSS */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 170px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar { width: 68%; max-width: 46px; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, var(--brand-2), var(--brand)); transition: height .5s ease; min-height: 3px; }
.bar.alt { background: linear-gradient(180deg, #38bdf8, var(--blue)); }
.bar-col .bval { font-size: 11px; font-weight: 700; }
.bar-col .blabel { font-size: 11px; color: var(--muted); }
.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut { width: 110px; height: 110px; border-radius: 50%; flex-shrink: 0; position: relative; }
.donut::after { content: ''; position: absolute; inset: 22px; background: var(--surface); border-radius: 50%; }
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
/* Barras horizontales (distribuciones) */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 10px; font-size: 12.5px; }
.hbar .track { background: var(--surface-2); border-radius: 999px; height: 10px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

/* Tabla */
.table-card { padding: 0; overflow: hidden; }
.table-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; flex-wrap: wrap; gap: 12px; }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); padding: 7px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit; }
.chip:hover { color: var(--ink); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-2); font-weight: 700; padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
thead th.num { text-align: right; }
thead th .arrow { opacity: .5; font-size: 10px; }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
.biz { display: flex; align-items: center; gap: 11px; }
.avatar { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px; }
.biz .bn { font-weight: 700; }
.biz .bo { font-size: 11.5px; color: var(--muted); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge.activo, .badge.pagado, .badge.resuelto { background: var(--green-bg); color: var(--green); }
.badge.prueba, .badge.pendiente, .badge.en_proceso, .badge.media { background: var(--amber-bg); color: var(--amber); }
.badge.suspendido, .badge.vencido, .badge.abierto, .badge.alta { background: var(--red-bg); color: var(--red); }
.badge.baja { background: var(--surface-2); color: var(--muted); }
.riesgo { color: var(--red); font-size: 11px; font-weight: 700; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; font-size: 13px; color: var(--muted); }
.pagination .pages { display: flex; gap: 6px; }

/* Lista de atención / actividad */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; align-items: center; }
.feed-item:last-child { border-bottom: none; }
.feed-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 14px; flex-shrink: 0; }
.feed-ic.riesgo { background: var(--red-bg); color: var(--red); }
.feed-ic.prueba { background: var(--amber-bg); color: var(--amber); }
.feed-ic.vencido { background: var(--red-bg); color: var(--red); }
.feed-ic.sesion { background: var(--surface-2); color: var(--muted); }
.feed-ic.pedido, .feed-ic.alta { background: var(--green-bg); color: var(--green); }
.feed-item .ev { font-weight: 600; }
.feed-item .dt { color: var(--muted); font-size: 12px; margin-left: auto; }

/* Detalle drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.45); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 40; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 440px; max-width: 94vw; background: var(--surface); box-shadow: -16px 0 40px rgba(0,0,0,0.25); transform: translateX(100%); transition: transform .3s cubic-bezier(.22,.61,.36,1); z-index: 50; padding: 24px; overflow-y: auto; }
.drawer.open { transform: translateX(0); }
.drawer .x { position: absolute; top: 16px; right: 16px; border: none; background: var(--surface-2); color: var(--ink); width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 15px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.detail-grid .box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.detail-grid .box .l { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.detail-grid .box .v { font-size: 16px; font-weight: 800; margin-top: 3px; }
.tabs { display: flex; gap: 6px; margin: 8px 0 14px; }
.tab { padding: 7px 12px; border-radius: 9px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--surface-2); color: var(--ink); }
.actions { display: flex; gap: 8px; margin-top: 14px; }

/* Config */
.cfg-list { display: flex; flex-direction: column; gap: 10px; }
.cfg-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cfg-row input { padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); width: 140px; text-align: right; font-family: inherit; }

/* Toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); animation: slidein .25s ease; }
.toast.ok { background: var(--green); color: #fff; }
.toast.err { background: var(--red); color: #fff; }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } }

.section-title { font-size: 15px; font-weight: 800; margin: 4px 0 12px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-row { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ===== Añadidos del panel real: login Google, modal y asistente de activación ===== */
[hidden] { display: none !important; }
.btn-google { display: inline-flex; align-items: center; justify-content: center; gap: 10px; margin-top: 18px;
  text-decoration: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 18px; font-weight: 700; font-size: 14px; }
.btn-google:hover { background: var(--surface-2); }
.btn-google.disabled { opacity: .5; pointer-events: none; }
.btn-google .g { color: #4285f4; font-weight: 800; }
.btn-dev { display: inline-block; margin-top: 12px; color: var(--brand); font-weight: 700; font-size: 13px; text-decoration: none; }

.modal { position: fixed; inset: 0; background: rgba(2,6,23,.5); display: grid; place-items: center; z-index: 200; }
.modal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; width: 460px; max-width: 94vw; max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; } .modal .x { border: none; background: none; font-size: 24px; cursor: pointer; color: var(--muted); }
#modal-body { padding: 20px; }
.form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.form input, .form select { width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--ink); font-size: 14px; }
.form .frow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.steps { list-style: none; margin: 0; padding: 0; }
.step { display: grid; grid-template-columns: 28px 1fr; align-items: start; gap: 4px 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.step .ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--surface-2); color: var(--muted); grid-row: span 2; }
.step.ok .ic { background: var(--green-bg); color: var(--green); } .step.error .ic { background: var(--red-bg); color: var(--red); }
.step.run .ic { background: rgba(109,76,255,.18); color: var(--brand); }
.step .lbl { font-weight: 600; padding-top: 3px; } .step.ok .lbl { color: var(--green); }
.step .st-msg { font-size: 12px; color: var(--muted); grid-column: 2; }
.spin { width: 14px; height: 14px; border: 2px solid var(--brand); border-top-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.wz-error { background: var(--red-bg); color: var(--red); border-radius: 10px; padding: 12px 14px; margin: 14px 0; font-size: 13px; }
.qr-wrap { text-align: center; } .qr-wrap .qr { width: 230px; height: 230px; margin: 8px auto; }
.token { word-break: break-all; background: var(--surface-2); padding: 8px; border-radius: 8px; font-size: 11px; }
.table-head .btn.primary { margin-left: auto; }
