:root{
  --primary:#1d4ed8;
  --primary-dark:#123a9a;
  --text:#152033;
  --muted:#667085;
  --border:#e6eaf2;
  --bg:#f4f7fb;
  --card:#ffffff;
  --success:#16a34a;
  --danger:#dc2626;
  --warning:#d97706;
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;background:var(--bg);color:var(--text)}
a{color:inherit}
img{max-width:100%;display:block}
body{line-height:1.4}
button,.btn{border:0;border-radius:14px;padding:12px 18px;font-weight:700;font-size:14px;cursor:pointer;text-decoration:none;display:inline-flex;align-items:center;justify-content:center;background:var(--primary);color:#fff;box-shadow:0 10px 24px rgba(29,78,216,.18)}
.btn.soft{background:#eff4ff;color:var(--primary);box-shadow:none}
.mini-btn{padding:8px 12px;border-radius:10px;font-size:12px;background:var(--primary);color:#fff;border:0;cursor:pointer}
input,select,textarea{width:100%;border:1px solid #cfd7e6;border-radius:14px;padding:13px 14px;font-size:15px;outline:none;background:#fff;color:var(--text)}
input:focus,select:focus,textarea:focus{border-color:var(--primary);box-shadow:0 0 0 4px rgba(29,78,216,.12)}
label{font-size:13px;font-weight:700;color:#334155}
.field{display:flex;flex-direction:column;gap:8px}
.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
.form-grid .full{grid-column:1/-1}
.actions{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-top:18px}
.notice{padding:13px 15px;border-radius:14px;background:#f8fbff;border:1px solid var(--border);font-size:14px;margin-bottom:14px}
.notice.ok{background:#effcf3;border-color:#c6efd0;color:#11662d}
.notice.error{background:#fff2f2;border-color:#ffd0d0;color:#9b1c1c}
.muted{color:var(--muted)} .small{font-size:12px}
.badge{display:inline-flex;padding:6px 10px;border-radius:999px;font-size:12px;font-weight:800;text-transform:capitalize;background:#eef2ff;color:#334155}
.badge.active{background:#e9f9ef;color:#11662d}
.badge.expired{background:#f3f4f6;color:#475467}
.badge.pending{background:#fff7e6;color:#9a6700}
.badge.error{background:#ffecec;color:#a21b1b}
.chip{display:inline-flex;align-items:center;padding:6px 10px;border-radius:999px;background:#eef4ff;color:var(--primary);font-size:12px;font-weight:700}

/* auth / portal */
.auth-page{position:relative;overflow-x:hidden;background:#091326}
.auth-bg{position:fixed;inset:0;background:linear-gradient(135deg,#0f172a,#1d4ed8 55%,#60a5fa);background-size:cover;background-position:center;filter:saturate(1.05)}
.auth-bg::after{content:"";position:absolute;inset:0;background:rgba(6,19,39,.56)}
.auth-shell{position:relative;min-height:100vh;display:flex;align-items:center;justify-content:center;padding:22px}
.auth-card{position:relative;width:min(100%,560px);background:rgba(255,255,255,.96);backdrop-filter:blur(9px);border:1px solid rgba(255,255,255,.55);border-radius:24px;box-shadow:0 20px 60px rgba(9,19,38,.35);padding:24px}
.auth-card.wide{width:min(100%,720px)}
.brand-row{display:flex;align-items:center;gap:14px;margin-bottom:18px}
.brand-image{width:70px;height:70px;object-fit:contain;border-radius:18px;background:#fff;padding:10px;border:1px solid var(--border)}
.brand-placeholder{width:70px;height:70px;border-radius:18px;display:grid;place-items:center;background:var(--primary);color:#fff;font-size:26px;font-weight:900}
.hero-banner{margin:-24px -24px 18px;border-radius:24px 24px 16px 16px;overflow:hidden;min-height:150px;background:linear-gradient(135deg,var(--primary),#60a5fa)}
.hero-banner img{width:100%;height:180px;object-fit:cover}
.hero-banner-fallback{height:180px;display:grid;place-items:center;text-align:center;color:#fff;padding:20px}
.hero-banner-fallback h2{margin:0 0 8px;font-size:30px}
.hero-banner-fallback p{margin:0;opacity:.95}
.portal-page{position:relative;min-height:100vh;background:#091326}
.portal-shell{position:relative;min-height:100vh;display:flex;align-items:center;justify-content:center;padding:20px}
.portal-card{width:min(100%,980px);background:rgba(255,255,255,.96);backdrop-filter:blur(10px);border-radius:28px;overflow:hidden;box-shadow:0 24px 70px rgba(0,0,0,.28);border:1px solid rgba(255,255,255,.55)}
.portal-top-banner{position:relative;min-height:150px;background:linear-gradient(135deg,var(--primary),#60a5fa)}
.portal-top-banner img{width:100%;height:220px;object-fit:cover}
.portal-banner-fallback{height:220px;display:flex;align-items:center;justify-content:center;color:#fff;text-align:center;padding:24px}
.portal-banner-fallback h2{font-size:32px;margin:0 0 8px}
.portal-content{display:grid;grid-template-columns:1.1fr .9fr;gap:0}
.portal-side{padding:28px 28px 30px;background:linear-gradient(180deg,rgba(29,78,216,.05),transparent)}
.portal-form{padding:28px 28px 30px}
.portal-brand{display:flex;gap:14px;align-items:center;margin-bottom:18px}
.portal-brand-logo{width:68px;height:68px;border-radius:18px;object-fit:contain;background:#fff;border:1px solid var(--border);padding:10px}
.portal-brand h1{margin:0 0 4px;font-size:28px}
.portal-brand p{margin:0;color:var(--muted)}
.feature-list{display:grid;gap:12px;margin-top:20px}
.feature-item{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;border-radius:16px;background:#fff;border:1px solid var(--border)}
.feature-item b{display:block;margin-bottom:3px}
.feature-icon{width:34px;height:34px;border-radius:12px;background:#e8efff;color:var(--primary);display:grid;place-items:center;font-weight:800;flex:0 0 auto}
.consent{display:flex;gap:10px;align-items:flex-start;font-size:14px}
.consent input{width:auto;margin-top:4px}
.spinner{width:48px;height:48px;border:4px solid #e5e7eb;border-top-color:var(--primary);border-radius:50%;animation:spin .8s linear infinite;margin:25px auto}@keyframes spin{to{transform:rotate(360deg)}}
.center{text-align:center}

/* admin */
.admin-body{background:#edf2f8}
.admin-shell{display:grid;grid-template-columns:280px 1fr;min-height:100vh}
.sidebar{background:linear-gradient(180deg,#0f172a,#111c34);color:#fff;padding:24px 18px;display:flex;flex-direction:column;gap:18px}
.sidebar-brand{display:flex;gap:12px;align-items:center;padding:6px 8px 18px;border-bottom:1px solid rgba(255,255,255,.1)}
.brand-mark{width:54px;height:54px;border-radius:16px;background:rgba(255,255,255,.12);display:grid;place-items:center;overflow:hidden}
.brand-mark img{width:100%;height:100%;object-fit:contain;background:#fff;padding:8px}
.sidebar-title{font-size:18px;font-weight:800}
.sidebar-subtitle{font-size:12px;color:rgba(255,255,255,.65)}
.sidebar-nav{display:grid;gap:6px}
.sidebar-nav a{padding:12px 14px;border-radius:14px;text-decoration:none;color:rgba(255,255,255,.82);font-weight:700}
.sidebar-nav a.active,.sidebar-nav a:hover{background:rgba(255,255,255,.1);color:#fff}
.sidebar-foot{margin-top:auto;padding:14px;border-radius:16px;background:rgba(255,255,255,.08);display:grid;gap:4px;font-size:13px}
.admin-main{padding:28px}
.page-header{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:22px}
.page-header h1{margin:0;font-size:30px}
.page-header p{margin:4px 0 0;color:var(--muted)}
.content-grid{display:grid;gap:20px}.content-grid.two-col{grid-template-columns:1fr 1fr}
.panel-card{background:var(--card);border:1px solid var(--border);border-radius:22px;padding:22px;box-shadow:0 10px 25px rgba(15,23,42,.05)}
.card-head{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:18px}
.card-head h2,.panel-card h2{margin:0;font-size:20px}
.stats-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:18px;margin-bottom:22px}
.stat-card{background:#fff;border:1px solid var(--border);border-radius:20px;padding:20px;box-shadow:0 10px 25px rgba(15,23,42,.05)}
.stat-card span{display:block;color:var(--muted);font-size:13px;margin-bottom:8px}
.stat-card strong{display:block;font-size:32px;line-height:1.05;margin-bottom:8px}
.stat-card small{color:#64748b}
.chart-bars{height:230px;display:flex;align-items:flex-end;gap:14px;padding:12px 4px 0}
.bar-item{flex:1;display:flex;flex-direction:column;align-items:center;gap:10px}
.bar{width:100%;max-width:68px;border-radius:16px 16px 8px 8px;background:linear-gradient(180deg,#60a5fa,var(--primary));display:flex;align-items:flex-start;justify-content:center;padding-top:8px;color:#fff;font-weight:800;box-shadow:0 12px 24px rgba(29,78,216,.25)}
.bar-item label{font-size:12px;color:var(--muted)}
.progress-list{display:grid;gap:14px;margin-top:4px}
.progress-label{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:6px}
.progress-track{height:12px;border-radius:999px;background:#edf2f7;overflow:hidden}
.progress-fill{height:100%;border-radius:999px;background:linear-gradient(90deg,var(--primary),#60a5fa)}
.toolbar{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;margin-bottom:18px}
.toolbar h2{margin:0 0 4px}.toolbar p{margin:0;color:var(--muted)}
.search-form{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.search-form input{min-width:280px}
.table-wrap{overflow:auto;border:1px solid var(--border);border-radius:18px}
table{border-collapse:collapse;width:100%;min-width:980px;background:#fff}th,td{padding:14px;border-bottom:1px solid #eef2f7;text-align:left;font-size:13px;vertical-align:top}th{background:#f8fafc;color:#64748b;font-size:12px;text-transform:uppercase;letter-spacing:.05em}
.preview-box{position:relative;overflow:hidden;border-radius:22px;min-height:540px;background:linear-gradient(135deg,#0f172a,var(--primary));background-size:cover;background-position:center;border:1px solid var(--border)}
.preview-overlay{position:absolute;inset:0;background:rgba(15,23,42,.45)}
.preview-content{position:relative;padding:18px;display:grid;gap:16px}
.preview-banner img,.preview-banner-fallback{width:100%;height:150px;border-radius:18px;object-fit:cover;background:linear-gradient(135deg,var(--primary),#60a5fa)}
.preview-banner-fallback{display:grid;place-items:center;color:#fff;font-weight:800}
.preview-brand{display:flex;gap:12px;align-items:center;color:#fff}.preview-brand img{width:64px;height:64px;border-radius:16px;background:#fff;padding:8px}.preview-brand span{display:block;font-size:13px;opacity:.9}
.preview-card{background:rgba(255,255,255,.95);border-radius:20px;padding:18px;max-width:460px}
.preview-card h3{margin:0 0 8px}.preview-card p{margin:0 0 16px;color:#475467}

@media (max-width:1100px){.stats-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.content-grid.two-col,.portal-content{grid-template-columns:1fr}.admin-shell{grid-template-columns:1fr}.sidebar{position:sticky;top:0;z-index:10;padding:16px}.sidebar-nav{grid-template-columns:repeat(4,minmax(0,1fr))}.sidebar-foot{display:none}.admin-main{padding:18px}}
@media (max-width:760px){.auth-shell,.portal-shell{padding:12px}.auth-card,.portal-card{border-radius:22px}.hero-banner{margin:-24px -24px 16px}.hero-banner img,.hero-banner-fallback,.portal-top-banner img,.portal-banner-fallback{height:120px}.portal-side,.portal-form,.panel-card,.auth-card{padding:18px}.form-grid,.content-grid.two-col,.stats-grid{grid-template-columns:1fr}.search-form input{min-width:0;width:100%}.toolbar,.page-header,.sidebar-nav{display:grid}.sidebar-nav{grid-template-columns:1fr 1fr}.page-header h1{font-size:24px}.portal-brand h1{font-size:24px}.brand-image,.brand-placeholder,.portal-brand-logo{width:56px;height:56px}.table-wrap table{min-width:760px}}

/* v1.7 router online + birthday reports */
.header-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.router-pill{display:inline-flex;align-items:center;gap:8px;border-radius:999px;padding:9px 12px;font-size:12px;font-weight:800;border:1px solid var(--border);background:#fff}
.router-pill i{width:9px;height:9px;border-radius:50%;display:block}
.router-pill.online{color:#11662d;background:#effcf3;border-color:#c6efd0}.router-pill.online i{background:#22c55e;box-shadow:0 0 0 4px rgba(34,197,94,.13)}
.router-pill.offline{color:#9b1c1c;background:#fff2f2;border-color:#ffd0d0}.router-pill.offline i{background:#ef4444;box-shadow:0 0 0 4px rgba(239,68,68,.12)}
.router-status-card{display:flex;justify-content:space-between;gap:20px;align-items:center;padding:18px 20px;border-radius:20px;margin-bottom:20px;border:1px solid var(--border);background:#fff;box-shadow:0 10px 25px rgba(15,23,42,.05)}
.router-status-card.online{border-color:#bbebc8;background:linear-gradient(90deg,#f0fff4,#fff)}
.router-status-card.offline{border-color:#ffd0d0;background:linear-gradient(90deg,#fff3f3,#fff)}
.router-status-main{display:flex;align-items:center;gap:13px}.router-status-main strong{display:block;font-size:18px}.router-status-main span{display:block;color:var(--muted);font-size:13px;margin-top:3px}
.router-status-dot{width:16px;height:16px;border-radius:50%;flex:0 0 auto}.router-status-card.online .router-status-dot{background:#22c55e;box-shadow:0 0 0 6px rgba(34,197,94,.14)}.router-status-card.offline .router-status-dot{background:#ef4444;box-shadow:0 0 0 6px rgba(239,68,68,.12)}
.router-status-meta{display:grid;grid-template-columns:repeat(3,minmax(120px,1fr));gap:12px}.router-status-meta div{padding:10px 12px;border-radius:14px;background:rgba(255,255,255,.72);border:1px solid rgba(148,163,184,.2)}.router-status-meta span{display:block;font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}.router-status-meta strong{display:block;font-size:13px;margin-top:3px}
.report-filter{display:flex;align-items:center;gap:10px}.report-filter label{white-space:nowrap}.report-filter select{min-width:140px}
.birthday-today-row{background:#fffbeb}.birthday-today{display:inline-flex;padding:6px 10px;border-radius:999px;background:#fef3c7;color:#92400e;font-weight:800}.birthday-soon{display:inline-flex;padding:6px 10px;border-radius:999px;background:#eef4ff;color:var(--primary);font-weight:800}
.whatsapp-btn{display:inline-flex;align-items:center;justify-content:center;text-decoration:none;background:#16a34a;color:#fff;padding:9px 12px;border-radius:11px;font-size:12px;font-weight:800;white-space:nowrap;box-shadow:0 8px 18px rgba(22,163,74,.18)}
textarea{resize:vertical;min-height:96px}
@media(max-width:1100px){.router-status-card{align-items:flex-start;flex-direction:column}.router-status-meta{width:100%}}
@media(max-width:760px){.router-status-meta{grid-template-columns:1fr}.report-filter{width:100%;align-items:stretch;flex-direction:column}.report-filter select{width:100%}.report-stats{grid-template-columns:1fr 1fr}.header-actions{width:100%}}
@media(max-width:480px){.report-stats{grid-template-columns:1fr}}

/* v1.8 users + cumpleaños día/mes */
.birthday-selects{display:grid;grid-template-columns:1fr 1.4fr;gap:10px}
.row-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.row-actions form{margin:0}.mini-btn.edit{background:var(--primary);text-decoration:none}.mini-btn.danger{background:#dc2626;box-shadow:none}
.detail-list{display:grid;gap:10px;margin:16px 0}.detail-list div{display:flex;justify-content:space-between;gap:18px;padding:12px 0;border-bottom:1px solid var(--border)}.detail-list span{color:var(--muted);font-size:13px}.detail-list strong{text-align:right}
.report-filter-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;min-width:380px}.report-filter-grid>div{display:grid;gap:6px}.report-filter-grid select{min-width:0}
.badge.ready{background:#eef4ff;color:#1d4ed8}.badge.dispatching{background:#fff7e6;color:#9a6700}
@media(max-width:760px){.birthday-selects,.report-filter-grid{grid-template-columns:1fr}.report-filter-grid{min-width:0;width:100%}.row-actions{flex-direction:column;align-items:stretch}.row-actions .mini-btn{width:100%}}

/* v1.9 reportes y submenu */
.nav-group{display:grid;gap:5px;margin:2px 0}
.nav-group-title{padding:11px 14px 6px;color:rgba(255,255,255,.5);font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.08em}
.nav-submenu{display:grid;gap:4px;padding-left:9px;border-left:1px solid rgba(255,255,255,.12);margin-left:14px}
.nav-submenu a{font-size:13px;padding:10px 12px!important}
.nav-submenu a.active{background:rgba(255,255,255,.13)!important;color:#fff!important}
.report-print-header{display:flex;justify-content:space-between;align-items:center;gap:18px;margin-bottom:16px}
.report-brand-print{display:flex;align-items:center;gap:14px}.report-brand-print img{width:58px;height:58px;object-fit:contain;border-radius:12px;border:1px solid var(--border);padding:6px;background:#fff}
.report-brand-print h2{margin:0 0 3px}.report-brand-print p{margin:0;color:var(--muted)}
.report-meta-print{display:flex;gap:24px;flex-wrap:wrap;padding:12px 14px;background:#f8fafc;border:1px solid var(--border);border-radius:14px;margin-bottom:16px;font-size:13px}
.report-user-table{min-width:760px}.report-user-table th:first-child,.report-user-table td:first-child{width:58px;text-align:center}
@media(max-width:1100px){.nav-group{grid-column:1/-1}.nav-submenu{grid-template-columns:1fr 1fr;margin-left:0;padding-left:0;border-left:0}}
@media(max-width:760px){.nav-submenu{grid-template-columns:1fr}.report-print-header{align-items:flex-start;display:grid}.report-meta-print{display:grid;gap:6px}}
@media print{
  @page{size:A4 portrait;margin:12mm}
  body.admin-body{background:#fff!important}
  .sidebar,.page-header,.no-print,.router-pill{display:none!important}
  .admin-shell{display:block!important}.admin-main{padding:0!important}
  .panel-card.printable-report{box-shadow:none!important;border:0!important;padding:0!important}
  .report-print-header{display:flex!important;margin-bottom:10px}.report-brand-print img{width:48px;height:48px}
  .report-meta-print{border:0!important;background:#fff!important;padding:0 0 10px!important;margin-bottom:8px!important}
  .table-wrap{overflow:visible!important;border:0!important}.report-user-table{min-width:0!important;width:100%!important}
  .report-user-table th,.report-user-table td{font-size:10.5px!important;padding:7px 6px!important;border:1px solid #d9dee8!important;color:#111!important}
  .report-user-table th{background:#f1f3f6!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
}
