:root{
  --bg:#f3f6fb; --surface:#fff; --ink:#1e293b; --muted:#64748b; --line:#e6ebf3;
  --primary:#2563eb; --primary-2:#06b6d4; --primary-soft:#e8f0ff;
  --sidebar-w:268px; --radius:16px;
  --shadow:0 1px 2px rgba(15,23,42,.04),0 8px 24px rgba(15,23,42,.05);
  --bs-body-font-family:'Plus Jakarta Sans',system-ui,-apple-system,Segoe UI,sans-serif;
  --bs-primary:#2563eb; --bs-primary-rgb:37,99,235;
}
body{background:var(--bg);color:var(--ink);font-family:var(--bs-body-font-family);font-size:.925rem}
a{color:var(--primary)}
.btn-primary{--bs-btn-bg:#2563eb;--bs-btn-border-color:#2563eb;--bs-btn-hover-bg:#1d4ed8;--bs-btn-hover-border-color:#1d4ed8;--bs-btn-active-bg:#1e40af;border-radius:10px;font-weight:600}
.btn{border-radius:10px;font-weight:500}
.form-control,.form-select{border-radius:10px;border-color:#dbe3ef;padding:.55rem .8rem}
.form-control:focus,.form-select:focus{border-color:#93b4f5;box-shadow:0 0 0 .22rem rgba(37,99,235,.12)}
.form-label{font-weight:600;font-size:.8rem;color:#475569;margin-bottom:.3rem}

/* Layout */
.app-shell{display:flex;min-height:100vh}
.sidebar{width:var(--sidebar-w);background:linear-gradient(185deg,#0b2545 0%,#10345f 55%,#0e4a63 100%);border-right:0;box-shadow:4px 0 24px rgba(11,37,69,.18);position:fixed;inset:0 auto 0 0;display:flex;flex-direction:column;z-index:1040;transition:transform .25s}
.main{margin-left:var(--sidebar-w);flex:1;min-width:0;display:flex;flex-direction:column}
.brand{display:flex;align-items:center;gap:12px;padding:20px 20px 16px;text-decoration:none;color:#fff;border-bottom:1px solid rgba(255,255,255,.08);margin-bottom:4px}
.brand-mark{width:42px;height:42px;border-radius:13px;background:linear-gradient(135deg,#2563eb,#06b6d4);color:#fff;display:grid;place-items:center;font-size:1.3rem;box-shadow:0 6px 16px rgba(37,99,235,.3)}
.brand-logo{width:42px;height:42px;object-fit:contain;border-radius:10px}
.brand-text{display:flex;flex-direction:column;line-height:1.15;min-width:0}
.brand-text strong{font-size:1rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:170px}
.brand-text small{color:#8fb4e3;font-size:.72rem}
.menu{flex:1;overflow-y:auto;padding:4px 14px 12px}
.menu::-webkit-scrollbar{width:5px}.menu::-webkit-scrollbar-thumb{background:#2c5282;border-radius:5px}
.menu-group{font-size:.67rem;text-transform:uppercase;letter-spacing:.09em;color:#7fa6d6;font-weight:700;padding:16px 10px 6px}
.menu-link{display:flex;align-items:center;gap:12px;padding:10px 12px;margin-bottom:2px;border-radius:12px;color:#d3e2f5;text-decoration:none;font-weight:500;transition:.15s}
.menu-link i{font-size:1.1rem;width:22px;text-align:center;color:#7cc4ee;transition:.15s}
.menu-link:hover{background:rgba(255,255,255,.09);color:#fff}
.menu-link:hover i{color:#67e8f9}
.menu-link.active{background:linear-gradient(135deg,#2563eb,#0891b2);color:#fff;font-weight:700;box-shadow:0 8px 18px -6px rgba(8,145,178,.6)}
.menu-link.active i{color:#fff}
.sidebar-foot{padding:14px}
.foot-card{display:flex;gap:10px;align-items:center;background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.1);border-radius:14px;padding:12px 14px;color:#67e8f9}
.foot-card i{font-size:1.4rem}.foot-card div{display:flex;flex-direction:column;line-height:1.2}
.foot-card strong{font-size:.8rem;color:#fff}.foot-card small{color:#8fb4e3;font-size:.7rem}
.sidebar-backdrop{display:none}

.topbar{display:flex;align-items:center;gap:14px;padding:14px 28px;background:rgba(243,246,251,.85);backdrop-filter:blur(8px);position:sticky;top:0;z-index:1030}
.topbar-title h1{font-size:1.3rem;font-weight:800;margin:0;letter-spacing:-.01em}
.topbar-title small{color:var(--muted)}
.btn-icon{border:1px solid var(--line);background:#fff;border-radius:11px;width:42px;height:42px;font-size:1.4rem;display:grid;place-items:center}
.user-chip{display:flex;align-items:center;gap:10px;background:#fff;border:1px solid var(--line);border-radius:14px;padding:6px 12px 6px 6px}
.user-chip::after{margin-left:4px}
.avatar{width:36px;height:36px;border-radius:11px;background:linear-gradient(135deg,#2563eb,#06b6d4);color:#fff;font-weight:700;display:grid;place-items:center}
.user-chip strong{display:block;font-size:.82rem;line-height:1.1}.user-chip small{color:var(--muted);font-size:.72rem}
.content{padding:6px 28px 28px;flex:1}
.app-footer{padding:16px 28px;color:#94a3b8;font-size:.78rem;text-align:center}

/* Cards */
.cardx{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:20px}
.cardx-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:14px}
.cardx-head h5{margin:0;font-size:1rem;font-weight:700}
.cardx-head small{color:var(--muted)}
.kpi{position:relative;overflow:hidden;color:#fff;border:0;padding:18px 20px;min-height:122px;box-shadow:0 10px 24px -8px rgba(15,23,42,.28)}
.kpi::before,.kpi::after{content:"";position:absolute;border-radius:50%;background:#fff;pointer-events:none}
.kpi::before{width:140px;height:140px;right:-36px;top:-44px;opacity:.16}
.kpi::after{width:120px;height:120px;right:38px;bottom:-62px;opacity:.12}
.kpi>div:last-child{position:relative;z-index:1;padding-right:56px}
.kpi .ico{position:absolute;z-index:1;right:16px;top:16px;width:46px;height:46px;border-radius:13px;display:grid;place-items:center;font-size:1.35rem;color:#fff;background:rgba(255,255,255,.18);border:1.5px solid rgba(255,255,255,.65)}
.kpi .lbl{color:rgba(255,255,255,.92);font-size:.74rem;font-weight:700;text-transform:uppercase;letter-spacing:.05em}
.kpi .val{color:#fff;font-size:1.7rem;font-weight:800;line-height:1.2;letter-spacing:-.02em;white-space:nowrap;margin:4px 0 10px}
.kpi .sub{display:inline-block;background:rgba(255,255,255,.24);color:#fff;font-size:.75rem;font-weight:600;padding:.25em .75em;border-radius:20px}
.t-blue{background:linear-gradient(135deg,#60a5fa,#3b82f6)}
.t-cyan{background:linear-gradient(135deg,#22d3ee,#06a3c4)}
.t-green{background:linear-gradient(135deg,#34d399,#16a34a)}
.t-amber{background:linear-gradient(135deg,#fbbf24,#f59e0b)}
.t-violet{background:linear-gradient(135deg,#a78bfa,#7c3aed)}
.t-rose{background:linear-gradient(135deg,#fb7185,#e11d48)}
.chart-box{position:relative;height:290px}

/* Tables */
.table-modern{margin:0}
.table-modern thead th{background:#f7f9fd;color:#64748b;font-size:.72rem;text-transform:uppercase;letter-spacing:.05em;font-weight:700;border-bottom:1px solid var(--line);padding:12px 14px;white-space:nowrap}
.table-modern td{padding:13px 14px;vertical-align:middle;border-color:#eef2f8}
.table-modern tbody tr:hover{background:#fafcff}
.table-wrap{border:1px solid var(--line);border-radius:14px;overflow:hidden;background:#fff}
.badge-soft{display:inline-block;padding:.32em .75em;border-radius:20px;font-size:.73rem;font-weight:700}
.bg-success-soft{background:#e4f8ec;color:#15803d}.bg-primary-soft{background:#e8f0ff;color:#1d4ed8}
.bg-info-soft{background:#e0f7fb;color:#0e7490}.bg-warning-soft{background:#fff3df;color:#b45309}
.bg-danger-soft{background:#ffe8ee;color:#be123c}.bg-secondary-soft{background:#eef1f6;color:#475569}
.soft-alert{border:0;border-radius:12px;box-shadow:var(--shadow)}
.btn-action{width:34px;height:34px;display:inline-grid;place-items:center;border-radius:10px;border:1px solid var(--line);background:#fff;color:#475569}
.btn-action:hover{background:var(--primary-soft);color:var(--primary);border-color:#c7d7fb}
.btn-action.danger:hover{background:#ffe8ee;color:#e11d48;border-color:#fbc4d1}
.search-box{position:relative}.search-box i{position:absolute;left:13px;top:50%;transform:translateY(-50%);color:#94a3b8}
.search-box input{padding-left:38px}
.empty-state{text-align:center;padding:60px 20px;color:var(--muted)}
.empty-state i{font-size:3rem;color:#cbd5e1}
.modal-content{border:0;border-radius:18px;box-shadow:0 20px 60px rgba(15,23,42,.18)}
.modal-header{border-bottom:1px solid var(--line)}.modal-footer{border-top:1px solid var(--line)}
.pagination .page-link{border-radius:9px;margin:0 2px;border:1px solid var(--line);color:#475569}
.pagination .active .page-link{background:var(--primary);border-color:var(--primary);color:#fff}
.alert-chip{display:flex;align-items:center;gap:12px;padding:11px 0;border-bottom:1px dashed var(--line)}
.alert-chip:last-child{border-bottom:0}
.alert-chip .dot{width:38px;height:38px;border-radius:12px;display:grid;place-items:center;flex:none}

/* Empresa / backup */
.section-title{display:flex;align-items:center;gap:10px;font-weight:700;margin-bottom:16px}
.section-title i{width:34px;height:34px;border-radius:10px;background:var(--primary-soft);color:var(--primary);display:grid;place-items:center}
.logo-preview{width:130px;height:130px;border:2px dashed #cbd5e1;border-radius:18px;display:grid;place-items:center;background:#f8fafc;overflow:hidden}
.logo-preview img{max-width:100%;max-height:100%;object-fit:contain}
.preview-money{background:linear-gradient(135deg,#eff6ff,#ecfeff);border-radius:14px;padding:16px;text-align:center}
.preview-money strong{font-size:1.6rem;display:block}
.action-card{border:1px solid var(--line);border-radius:18px;padding:22px;background:#fff;height:100%;box-shadow:var(--shadow)}
.action-card .big{width:56px;height:56px;border-radius:17px;display:grid;place-items:center;font-size:1.7rem;margin-bottom:14px}
.danger-zone{border:1px solid #fbc4d1;background:linear-gradient(135deg,#fff5f7,#fff);border-radius:18px;padding:24px}

@media (max-width:991.98px){
  .sidebar{transform:translateX(-100%)}.sidebar.open{transform:none;box-shadow:0 0 40px rgba(15,23,42,.2)}
  .main{margin-left:0}
  .sidebar-backdrop.show{display:block;position:fixed;inset:0;background:rgba(15,23,42,.35);z-index:1035}
  .topbar,.content{padding-left:16px;padding-right:16px}
}

/* ---------- Login ---------- */
.login-page{min-height:100vh;display:grid;grid-template-columns:1.1fr 1fr;background:#fff}
.login-hero{position:relative;overflow:hidden;background:linear-gradient(145deg,#dbeafe 0%,#e0f2fe 45%,#ccfbf1 100%);padding:48px 56px;display:flex;flex-direction:column;justify-content:space-between}
.login-hero::before,.login-hero::after{content:"";position:absolute;border-radius:50%;background:#fff;opacity:.45}
.login-hero::before{width:420px;height:420px;right:-140px;top:-120px}
.login-hero::after{width:300px;height:300px;left:-100px;bottom:-110px}
.hero-brand{display:flex;align-items:center;gap:12px;position:relative;z-index:1}
.hero-brand .brand-mark{width:46px;height:46px}
.hero-brand strong{font-size:1.15rem;color:#0f172a}
.hero-copy{position:relative;z-index:1;max-width:520px}
.hero-copy h2{font-size:2.35rem;font-weight:800;letter-spacing:-.03em;color:#0f172a;line-height:1.15}
.hero-copy h2 span{background:linear-gradient(90deg,#2563eb,#0891b2);-webkit-background-clip:text;background-clip:text;color:transparent}
.hero-copy p{color:#475569;font-size:1.02rem;margin:14px 0 22px}
.hero-feats{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.hero-feat{background:rgba(255,255,255,.75);backdrop-filter:blur(6px);border-radius:14px;padding:12px 14px;display:flex;gap:10px;align-items:center;font-weight:600;font-size:.86rem;color:#1e293b;box-shadow:0 4px 14px rgba(37,99,235,.08)}
.hero-feat i{color:#2563eb;font-size:1.2rem}
.hero-art{position:relative;z-index:1;margin-top:14px}
.hero-art svg{width:100%;height:auto;display:block}
.login-side{display:grid;place-items:center;padding:32px}
.login-card{width:100%;max-width:410px}
.login-card h3{font-weight:800;letter-spacing:-.02em;margin-bottom:4px}
.input-ico{position:relative}
.input-ico>i{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:#94a3b8;font-size:1.05rem}
.input-ico .form-control{padding:.78rem 2.6rem .78rem 2.65rem;background:#f8fafc}
.input-ico .toggle-pass{position:absolute;right:6px;top:50%;transform:translateY(-50%);border:0;background:transparent;color:#94a3b8;width:38px;height:38px}
.btn-login{padding:.85rem;font-size:1rem;background:linear-gradient(135deg,#2563eb,#0891b2);border:0;box-shadow:0 10px 24px rgba(37,99,235,.28)}
.btn-login:hover{filter:brightness(1.05);transform:translateY(-1px)}
@media (max-width:991.98px){.login-page{grid-template-columns:1fr}.login-hero{display:none}}

/* ================= v2: refinamiento visual ================= */
body{background:radial-gradient(1200px 500px at 85% -10%,#e3efff 0%,transparent 60%),radial-gradient(900px 400px at -10% 100%,#dcf6f1 0%,transparent 55%),#f3f6fb;background-attachment:fixed}
@keyframes rise{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
.content>*{animation:rise .35s ease both}.content>*:nth-child(2){animation-delay:.04s}.content>*:nth-child(3){animation-delay:.08s}.content>*:nth-child(4){animation-delay:.12s}
.cardx{border-color:#e3eaf5;box-shadow:0 1px 2px rgba(15,23,42,.04),0 10px 30px -12px rgba(30,64,120,.14)}
.kpi{transition:transform .2s,box-shadow .2s}.kpi:hover{transform:translateY(-3px);box-shadow:0 18px 32px -10px rgba(15,23,42,.35)}
.topbar{border-bottom:1px solid rgba(214,226,243,.7)}
.topbar-title h1{font-size:1.35rem;background:linear-gradient(90deg,#0b2545,#1d4ed8);-webkit-background-clip:text;background-clip:text;color:transparent}
.btn-sell{background:linear-gradient(135deg,#16a34a,#0d9488);border:0;color:#fff;box-shadow:0 8px 18px -6px rgba(13,148,136,.6)}.btn-sell:hover{color:#fff;filter:brightness(1.07)}

/* Iconos de cabecera de panel */
.chip{width:38px;height:38px;border-radius:12px;display:grid;place-items:center;font-size:1.1rem;flex:none}
.chip-blue{background:#e6efff;color:#2563eb}.chip-cyan{background:#dff6fb;color:#0891b2}.chip-green{background:#e2f7ea;color:#16a34a}
.chip-amber{background:#fff1da;color:#d97706}.chip-violet{background:#efe8ff;color:#7c3aed}.chip-rose{background:#ffe6ec;color:#e11d48}
.cardx-head .ttl{display:flex;align-items:center;gap:12px}
.cardx-head h5{font-size:1rem;letter-spacing:-.01em}

/* Hero del dashboard */
.hero{position:relative;overflow:hidden;border-radius:22px;padding:28px 32px;color:#fff;margin-bottom:20px;
  background:linear-gradient(120deg,#0b2545 0%,#16408a 55%,#0e7490 100%);box-shadow:0 22px 40px -18px rgba(11,37,69,.6);display:grid;grid-template-columns:1.2fr 1fr;gap:20px;align-items:center}
.hero::before,.hero::after{content:"";position:absolute;border-radius:50%;background:#fff;opacity:.07;pointer-events:none}
.hero::before{width:380px;height:380px;right:-90px;top:-170px}.hero::after{width:260px;height:260px;right:240px;bottom:-170px}
.hero>*{position:relative;z-index:1}
.hero-tag{display:inline-flex;align-items:center;gap:6px;background:rgba(255,255,255,.14);border:1px solid rgba(255,255,255,.25);border-radius:20px;padding:.25em .9em;font-size:.75rem;font-weight:600;margin-bottom:10px}
.hero h2{font-weight:800;letter-spacing:-.02em;margin:0 0 6px;font-size:1.7rem}
.hero p{color:#cfe0f7;margin:0 0 18px}
.hero .btn{font-weight:600}.hero .btn-light{background:rgba(255,255,255,.14);border:1px solid rgba(255,255,255,.28);color:#fff}.hero .btn-light:hover{background:rgba(255,255,255,.24);color:#fff}
.hero .btn-white{background:#fff;color:#1d4ed8;border:0}
.hero-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}
.hero-stat{background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.2);backdrop-filter:blur(6px);border-radius:16px;padding:14px 14px 12px}
.hero-stat small{display:block;color:#bcd3f1;font-size:.7rem;text-transform:uppercase;letter-spacing:.06em;font-weight:700}
.hero-stat b{font-size:1.45rem;font-weight:800;letter-spacing:-.02em;display:block;line-height:1.25;margin-top:2px}
.hero-stat span{font-size:.72rem;color:#9fe4f1}

/* Feed de actividad */
.feed{position:relative;padding-left:4px}.feed-item{display:flex;gap:12px;padding:9px 0;position:relative}
.feed-item:not(:last-child)::before{content:"";position:absolute;left:17px;top:42px;bottom:-6px;width:2px;background:#e8eef7}
.feed-item .chip{width:34px;height:34px;font-size:.95rem;border-radius:50%}
.feed-item .t{font-size:.84rem;font-weight:600;line-height:1.25}.feed-item small{color:var(--muted)}

/* Tabs de estado en módulos */
.state-tabs{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:16px}
.state-tab{display:inline-flex;align-items:center;gap:8px;padding:7px 14px;border-radius:12px;background:#fff;border:1px solid var(--line);color:#475569;font-weight:600;font-size:.82rem;text-decoration:none;transition:.15s}
.state-tab b{background:#eef2f8;border-radius:10px;padding:1px 8px;font-size:.74rem;color:#475569}
.state-tab:hover{border-color:#bcd0f5;color:#1d4ed8}
.state-tab.on{background:linear-gradient(135deg,#2563eb,#0891b2);color:#fff;border-color:transparent;box-shadow:0 8px 16px -8px rgba(37,99,235,.7)}
.state-tab.on b{background:rgba(255,255,255,.25);color:#fff}
.mod-head{display:flex;align-items:center;gap:14px;margin-bottom:16px;flex-wrap:wrap}
.mod-ico{width:52px;height:52px;border-radius:16px;display:grid;place-items:center;font-size:1.5rem;color:#fff;background:linear-gradient(135deg,#2563eb,#06b6d4);box-shadow:0 12px 22px -10px rgba(37,99,235,.7)}
.mod-head h2{font-size:1.15rem;font-weight:800;margin:0}.mod-head small{color:var(--muted)}

/* Tablas más pulidas */
.table-wrap{border-color:#e3eaf5;box-shadow:0 1px 2px rgba(15,23,42,.03)}
.table-modern thead th{background:linear-gradient(180deg,#f8faff,#f1f5fc);color:#53688a;border-bottom:1px solid #e3eaf5}
.table-modern tbody tr{transition:background .12s}.table-modern tbody tr:hover{background:#f5f9ff}
.table-modern tbody tr:last-child td{border-bottom:0}
.who{display:flex;align-items:center;gap:11px}
.who .av{width:36px;height:36px;border-radius:12px;display:grid;place-items:center;font-weight:700;font-size:.82rem;color:#fff;flex:none}
.who b{display:block;line-height:1.15;font-weight:600}.who small{color:var(--muted)}
.plate{display:inline-flex;align-items:center;gap:7px;background:#fff;border:2px solid #1e3a8a;border-radius:8px;padding:2px 10px;font-weight:800;letter-spacing:.06em;color:#1e3a8a;font-size:.82rem;box-shadow:inset 0 -3px 0 #fbbf24}
.badge-soft::before{content:"";display:inline-block;width:6px;height:6px;border-radius:50%;background:currentColor;margin-right:6px;vertical-align:1px}
.btn-primary{background-image:linear-gradient(135deg,#2563eb,#0891b2);border:0;box-shadow:0 8px 18px -8px rgba(37,99,235,.7)}
.btn-primary:hover,.btn-primary:focus{background-image:linear-gradient(135deg,#1d4ed8,#0e7490)}
.btn-login{background-image:linear-gradient(135deg,#2563eb,#0891b2)}
.search-box input{background:#f8fafd}

/* Modal */
.modal-header{background:linear-gradient(120deg,#eef4ff,#e7f8fb);border-radius:18px 18px 0 0;border-bottom:1px solid #dbe8fb}
.modal-title .mi{width:34px;height:34px;border-radius:11px;display:inline-grid;place-items:center;background:linear-gradient(135deg,#2563eb,#06b6d4);color:#fff;margin-right:10px;font-size:1rem}
.modal-footer{background:#fafcff;border-radius:0 0 18px 18px}

@media (max-width:991.98px){.hero{grid-template-columns:1fr}.hero-stats{grid-template-columns:repeat(3,1fr)}}
@media (max-width:575.98px){.hero{padding:22px 20px}.hero-stats{grid-template-columns:1fr 1fr}}

.hero-stat b{white-space:nowrap;font-size:1.3rem}.plate{white-space:nowrap}
.table-modern td{white-space:nowrap}.table-modern td.wrap{white-space:normal;min-width:200px;max-width:340px}
.badge-soft{white-space:nowrap}
.table-modern th:last-child,.table-modern td:last-child{position:sticky;right:0;background:#fff;box-shadow:-10px 0 14px -12px rgba(15,23,42,.18)}
.table-modern th:last-child{background:#f4f7fd}.table-modern tbody tr:hover td:last-child{background:#f5f9ff}
.table-modern td{padding:13px 12px}
.mant-card{border:1px solid var(--line);border-radius:16px;padding:14px 16px;background:#fff;border-left:5px solid #cbd5e1;transition:.15s}
.mant-card:hover{transform:translateY(-2px);box-shadow:0 12px 22px -14px rgba(15,23,42,.3)}
.mant-rose{border-left-color:#e11d48;background:linear-gradient(135deg,#fff,#fff5f7)}.mant-amber{border-left-color:#f59e0b;background:linear-gradient(135deg,#fff,#fffaf0)}
.mant-green{border-left-color:#22c55e}.mant-violet{border-left-color:#94a3b8}
