:root {
    --primary: #4f46e5;
    --primary-600: #4338ca;
    --primary-50: #eef2ff;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --bg: #f4f6fb;
    --card: #ffffff;
    --border: #e7eaf3;
    --text: #1e293b;
    --muted: #64748b;
    --sidebar-bg: #0f172a;
    --sidebar-w: 260px;
    --radius: 14px;
    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
    --bs-body-font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body { background: var(--bg); color: var(--text); font-size: .9rem; }
a { color: var(--primary); text-decoration: none; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-600); --bs-btn-hover-border-color: var(--primary-600); --bs-btn-active-bg: var(--primary-600); }
.btn-outline-primary { --bs-btn-color: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary); --bs-btn-hover-border-color: var(--primary); }
.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }
.btn { border-radius: 10px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; }
.btn-sm { border-radius: 8px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon.btn-sm { width: 30px; height: 30px; }
.form-control, .form-select { border-radius: 10px; border-color: var(--border); font-size: .9rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(79,70,229,.12); }
.form-label { font-weight: 500; font-size: .82rem; color: #334155; margin-bottom: .3rem; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); background: var(--sidebar-bg); color: #cbd5e1;
    position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 1040;
    transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.15rem 1.25rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand img { width: 40px; height: 40px; object-fit: contain; border-radius: 10px; background: #fff; }
.brand-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(135deg, #6366f1, #22d3ee); font-size: 1.25rem; color: #fff; }
.brand-text { font-weight: 700; line-height: 1.15; font-size: .98rem; }
.brand-text small { display: block; font-weight: 400; color: #94a3b8; font-size: .72rem; }
.side-nav { flex: 1; overflow-y: auto; padding: .5rem .75rem 1rem; }
.side-nav::-webkit-scrollbar { width: 4px; } .side-nav::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
.nav-label { text-transform: uppercase; font-size: .66rem; letter-spacing: .08em; color: #64748b; padding: 1rem .75rem .4rem; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 10px; color: #cbd5e1; font-weight: 500; margin-bottom: 2px; font-size: .87rem; }
.nav-item i { font-size: 1.05rem; width: 20px; text-align: center; color: #94a3b8; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -6px rgba(79,70,229,.7); }
.nav-item.active i { color: #fff; }
.sidebar-foot { padding: .75rem; border-top: 1px solid rgba(255,255,255,.06); }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1020; background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 1rem; padding: .7rem 1.5rem; min-height: 66px;
}
.topbar-title h1 { font-size: 1.15rem; font-weight: 700; margin: 0; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.user-btn { display: flex; align-items: center; gap: .6rem; border: 0; padding: .25rem .5rem; }
.user-btn strong { font-size: .84rem; }
.avatar { width: 36px; height: 36px; border-radius: 10px; background: var(--primary-50); color: var(--primary); display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.5rem; border-radius: 18px; }
.content { padding: 1.5rem; flex: 1; }
.app-footer { display: flex; justify-content: space-between; padding: 1rem 1.5rem; font-size: .78rem; color: var(--muted); border-top: 1px solid var(--border); }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .main { margin-left: 0; }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1030; }
    .content { padding: 1rem; }
    .topbar { padding: .6rem 1rem; }
}

/* ---------- Cards ---------- */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,24,40,.04); background: var(--card); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); padding: 1rem 1.25rem; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.card-header h5, .card-title { font-size: .98rem; font-weight: 600; margin: 0; }
.card-body { padding: 1.25rem; }

.stat-card { padding: 1.15rem 1.25rem; display: flex; gap: 1rem; align-items: flex-start; height: 100%; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-label { color: var(--muted); font-size: .78rem; font-weight: 500; }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.25; margin: .15rem 0; letter-spacing: -.01em; }
.stat-sub { font-size: .75rem; color: var(--muted); }
.bg-soft-primary { background: #eef2ff; color: #4f46e5; }
.bg-soft-success { background: #ecfdf5; color: #059669; }
.bg-soft-danger { background: #fef2f2; color: #dc2626; }
.bg-soft-warning { background: #fffbeb; color: #d97706; }
.bg-soft-info { background: #f0f9ff; color: #0284c7; }
.bg-soft-purple { background: #faf5ff; color: #9333ea; }
.bg-soft-secondary { background: #f1f5f9; color: #475569; }

.badge-soft { display: inline-flex; align-items: center; padding: .28em .65em; border-radius: 6px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.badge-soft-success { background: #dcfce7; color: #15803d; }
.badge-soft-danger { background: #fee2e2; color: #b91c1c; }
.badge-soft-warning { background: #fef3c7; color: #b45309; }
.badge-soft-info { background: #e0f2fe; color: #0369a1; }
.badge-soft-primary { background: #e0e7ff; color: #4338ca; }
.badge-soft-secondary { background: #f1f5f9; color: #475569; }

.progress { height: 8px; border-radius: 99px; background: #eef1f6; }
.progress-bar { border-radius: 99px; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .7rem .75rem; border-bottom-color: var(--border); vertical-align: middle; }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #f8fafc; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-hover tbody tr:hover > * { background: #f8faff; }
.person { display: flex; align-items: center; gap: .65rem; }
.person .avatar { width: 34px; height: 34px; font-size: .75rem; }
.person-name { font-weight: 600; color: var(--text); }
.person-sub { font-size: .75rem; color: var(--muted); }
.actions { white-space: nowrap; text-align: right; }
.actions .btn { margin-left: 2px; }

div.dt-container .dt-search input { border-radius: 10px; border-color: var(--border); min-width: 220px; }
div.dt-container .dt-length select { border-radius: 8px; }
div.dt-container div.dt-layout-row { margin: .75rem 0; }
div.dt-container div.dt-layout-row.dt-layout-table { margin: 0; }
.dt-buttons .btn { font-size: .78rem; padding: .3rem .7rem; }
div.dt-container .dt-paging .dt-paging-button { border-radius: 8px !important; }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }
.card .dt-container { padding: 0 1.25rem 1rem; }
.card .dt-container .dt-layout-table { margin: 0 -1.25rem !important; }

.filter-bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
.filter-bar .form-select, .filter-bar .form-control { min-width: 150px; width: auto; }

.nav-tabs-custom { border-bottom: 1px solid var(--border); gap: .25rem; }
.nav-tabs-custom .nav-link { border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; padding: .75rem 1rem; }
.nav-tabs-custom .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); background: transparent; }

.modal-content { border: 0; border-radius: 16px; }
.modal-header, .modal-footer { border-color: var(--border); }
.modal-title { font-weight: 600; font-size: 1.05rem; }

.list-clean { list-style: none; padding: 0; margin: 0; }
.list-clean li { display: flex; align-items: center; gap: .75rem; padding: .65rem 0; border-bottom: 1px dashed var(--border); }
.list-clean li:last-child { border-bottom: 0; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .6; }

.borc-item { border: 1px solid var(--border); border-radius: 10px; padding: .55rem .8rem; display: flex; align-items: center; gap: .75rem; margin-bottom: .4rem; cursor: pointer; }
.borc-item:hover { border-color: var(--primary); }
.borc-item input { margin: 0; }

.att-btn-group .btn { min-width: 44px; }
.att-row.var .btn-var, .btn-check:checked + .btn-outline-success { background: var(--success); color: #fff; }

.sube-btn { border: 1px solid var(--border); }
.ts-wrapper .ts-control { border-radius: 10px; border-color: var(--border); }
.color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.info-row { display: flex; justify-content: space-between; padding: .5rem 0; border-bottom: 1px dashed var(--border); gap: 1rem; }
.info-row:last-child { border-bottom: 0; }
.info-row span:first-child { color: var(--muted); }
.info-row span:last-child { font-weight: 500; text-align: right; }

.wa-preview { background: #e7ffdb; border-radius: 10px 10px 10px 2px; padding: .75rem 1rem; white-space: pre-wrap; font-size: .87rem; position: relative; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.wa-bg { background: #efeae2 url("data:image/svg+xml,%3Csvg width='40' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='2' cy='2' r='1' fill='%23d6cfc4'/%3E%3C/svg%3E"); border-radius: 12px; padding: 1rem; }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: linear-gradient(135deg, #312e81 0%, #4f46e5 50%, #0ea5e9 100%); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side::after { content: ''; position: absolute; width: 480px; height: 480px; border-radius: 50%; background: rgba(255,255,255,.07); right: -140px; bottom: -140px; }
.auth-side h2 { font-weight: 700; font-size: 2rem; }
.auth-feature { display: flex; gap: .75rem; align-items: center; margin-bottom: 1rem; opacity: .95; }
.auth-feature i { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.15); display: grid; place-items: center; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }
.auth-form .inner { width: 100%; max-width: 380px; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

@media print {
    .sidebar, .topbar, .app-footer, .no-print, .dt-buttons, .dt-search, .dt-length, .dt-paging { display: none !important; }
    .main { margin: 0; }
    .card { border: 0; box-shadow: none; }
}
