:root {
    /* ── Layout ── */
    --sidebar-width: 235px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --topbar-h: 60px;
    --main-bg: #f1f5f9;

    /* ── NEXUS Design Tokens ── */

    /* Spacing scale */
    --nx-space-xs: 4px;
    --nx-space-sm: 8px;
    --nx-space-md: 16px;
    --nx-space-lg: 24px;
    --nx-space-xl: 32px;
    --nx-space-2xl: 48px;

    /* Typography scale */
    --nx-text-xs: 0.7rem;
    --nx-text-sm: 0.8rem;
    --nx-text-base: 0.875rem;
    --nx-text-lg: 1rem;
    --nx-text-xl: 1.25rem;
    --nx-text-2xl: 1.75rem;
    --nx-text-3xl: 2.25rem;

    /* Shadows — elevation system */
    --nx-shadow-xs: 0 1px 2px rgba(0,0,0,.04);
    --nx-shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --nx-shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --nx-shadow-lg: 0 8px 24px rgba(0,0,0,.1);
    --nx-shadow-hover: 0 8px 20px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.04);

    /* Radius */
    --nx-radius-sm: 6px;
    --nx-radius-md: 10px;
    --nx-radius-lg: 14px;
    --nx-radius-xl: 20px;
    --nx-radius-full: 9999px;

    /* Module accent colors */
    --nx-mod-ti: #cc3300;
    --nx-mod-vendas: #16a34a;
    --nx-mod-sac: #7c3aed;
    --nx-mod-mercado: #1565c0;
    --nx-mod-admin: #d97706;
    --nx-mod-formulacao: #16a34a;

    /* Semantic colors */
    --nx-primary: #3b82f6;
    --nx-success: #22c55e;
    --nx-warning: #f59e0b;
    --nx-danger: #ef4444;
    --nx-info: #06b6d4;
    --nx-muted: #64748b;

    /* Transition tokens */
    --nx-ease-out: cubic-bezier(.2, .8, .2, 1);
    --nx-ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
    --nx-dur-fast: 150ms;
    --nx-dur-normal: 250ms;
    --nx-dur-slow: 400ms;
}

* { box-sizing: border-box; }

body {
    background: var(--main-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: sticky;
    top: 0;
    overflow-y: auto;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-mobile {
    background: var(--sidebar-bg) !important;
    width: 250px !important;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    letter-spacing: 0.02em;
}

.sidebar-footer {
    padding: 4px 18px;
    font-size: 0.42rem;
    font-weight: 200;
    color: rgba(255,255,255,0.18);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.04);
}

.sidebar-nav { margin: 0; padding: 6px 8px; overflow-y: auto; flex: 1 1 0; min-height: 0; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 11px;
    color: var(--sidebar-text) !important;
    text-decoration: none !important;
    border-radius: 7px;
    font-size: 0.83rem;
    transition: background 0.15s, color 0.15s;
    margin-bottom: 1px;
}
.sidebar-link:hover { background: rgba(255,255,255,0.07); color: #fff !important; }
.sidebar-link.active { background: #3b82f6; color: #fff !important; }
.sidebar-link i { font-size: 0.95rem; width: 18px; text-align: center; }

/* Submenu colapsável */
.sidebar-group-toggle { cursor: pointer; user-select: none; }
.sidebar-group-toggle .sidebar-chevron {
    margin-left: auto;
    font-size: 0.65rem;
    transition: transform 0.2s;
    opacity: 0.6;
}
.sidebar-group-toggle[aria-expanded="true"] .sidebar-chevron {
    transform: rotate(180deg);
}
.sidebar-submenu {
    padding-left: 8px;
    margin-bottom: 2px;
}
.sidebar .sidebar-sublink,
.sidebar-mobile .sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 11px 5px 28px;
    color: var(--sidebar-text) !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-size: 0.8rem;
    transition: background 0.15s, color 0.15s;
    margin-bottom: 1px;
}
.sidebar .sidebar-sublink:hover,
.sidebar-mobile .sidebar-sublink:hover { background: rgba(255,255,255,0.06); color: #fff !important; }
.sidebar .sidebar-sublink.active,
.sidebar-mobile .sidebar-sublink.active { background: rgba(59,130,246,0.25); color: #93c5fd !important; }
.sidebar .sidebar-sublink i,
.sidebar-mobile .sidebar-sublink i { font-size: 0.85rem; width: 16px; text-align: center; }

.sidebar-user {
    padding: 10px 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: auto;
}

.user-avatar {
    width: 34px; height: 34px;
    background: #3b82f6;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.75rem; color: #fff;
    flex-shrink: 0;
}

.user-avatar-sm {
    width: 32px; height: 32px;
    background: #64748b;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.7rem; color: #fff;
    flex-shrink: 0;
}

/* ===================== TOPBAR (glassmorphism) ===================== */
.topbar {
    height: var(--topbar-h);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Auto-refresh controls */
.auto-refresh-controls {
    margin-left: auto;
    margin-right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

/* ===================== MAIN ===================== */
.main-area {
    min-height: 100vh;
    overflow-x: hidden;
    transition: margin-left 0.2s ease;
    background: var(--main-bg);
}

/* Sidebar collapsed */
#app-wrapper.sidebar-collapsed .sidebar {
    width: 0 !important;
    min-width: 0 !important;
    flex: 0 0 0 !important;
    padding: 0 !important;
    overflow: hidden;
}

#app-wrapper.sidebar-collapsed .main-area {
    margin-left: 0;
}

/* ===================== ONLINE DOT ===================== */
.online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 0 2px #dcfce7;
    vertical-align: middle;
    animation: pulse-green 2s infinite;
}
@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 2px #dcfce7; }
    50%       { box-shadow: 0 0 0 4px #bbf7d0; }
}

/* ===================== STAT CARDS ===================== */
.stat-card {
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
    border: 1px solid #f0f0f0;
}
.stat-icon {
    width: 46px; height: 46px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}
.stat-number {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.1;
    margin: 6px 0 2px;
}
.stat-label { font-size: 0.78rem; color: #64748b; }

/* ===================== TICKET TABLE ===================== */
.ticket-table th {
    font-size: 0.73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0 !important;
    white-space: nowrap;
    padding-top: 12px;
    padding-bottom: 12px;
}
.ticket-table td { vertical-align: middle; font-size: 0.875rem; }
.ticket-row { cursor: pointer; }
.ticket-row:hover td { background: #f8fafc; }

/* ===================== FILTER BAR ===================== */
.filter-bar {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
}

/* ===================== COMMENT BOX ===================== */
.comment-box {
    background: #f8fafc;
    border-radius: 10px;
    padding: 14px 16px;
    border: 1px solid #e2e8f0;
}
.comment-box.internal {
    background: #fffbeb;
    border-color: #fde68a;
    border-left: 3px solid #f59e0b;
}
.comment-avatar {
    width: 30px; height: 30px;
    background: #3b82f6;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700; color: #fff;
    flex-shrink: 0;
}
.comment-time { font-size: 0.75rem; color: #9ca3af; }

/* ===================== LOGIN PAGE ===================== */
.login-page { background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); }

.login-card {
    width: 400px;
    max-width: 95vw;
    border-radius: 16px !important;
    overflow: hidden;
}

.login-card .card-header {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: 0 !important;
}

.login-icon {
    width: 60px; height: 60px;
    background: rgba(255,255,255,0.15);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto;
}

/* ===================== CARDS ===================== */
.card { border-radius: 12px !important; border: 1px solid #e2e8f0 !important; }
.card-header { border-radius: 12px 12px 0 0 !important; }

/* ===================== TICKET CARD MOBILE ===================== */
.ticket-card-mobile { transition: background 0.15s; }
.ticket-card-mobile:hover { background: #f8fafc; }

/* ===================== RESPONSIVE ===================== */
#app-wrapper { min-height: 100vh; }

@media (max-width: 767.98px) {
    .main-area { min-height: 100vh; }
    .stat-card { padding: 14px 10px; }
    .stat-number { font-size: 1.5rem; }
    .topbar { padding-left: 1rem !important; padding-right: 1rem !important; }

    /* Tables: horizontal scroll wrapper */
    .table-responsive-mobile { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-responsive-mobile table { min-width: 600px; }

    /* Cards layout */
    .card { border-radius: 10px !important; }
    .card-body { padding: 1rem !important; }
    .card-header { padding: 0.75rem 1rem !important; }

    /* Buttons */
    .btn { font-size: 0.85rem; padding: 0.4rem 0.8rem; }
    .btn-sm { font-size: 0.78rem; padding: 0.3rem 0.6rem; }

    /* Page titles */
    .page-title, h1, h2 { font-size: 1.25rem !important; }
    h3 { font-size: 1.1rem !important; }
    h5, h6 { font-size: 0.95rem !important; }

    /* Forms */
    .form-control, .form-select { font-size: 0.9rem; }

    /* Stat cards on dashboard - 2 columns */
    .row .col-sm-6.col-xl-3, .row .col-md-3, .row .col-lg-3 {
        flex: 0 0 50%; max-width: 50%;
    }

    /* Hide columns marked as mobile-hidden */
    .d-mobile-none { display: none !important; }

    /* Touch-friendly spacing */
    .gap-2 { gap: 0.4rem !important; }
    .mb-4 { margin-bottom: 1rem !important; }

    /* Filter forms inline */
    .filter-bar .form-control,
    .filter-bar .form-select { font-size: 0.8rem; min-height: 36px; }

    /* Badge sizes */
    .badge { font-size: 0.7rem; padding: 0.25em 0.5em; }

    /* Pagination */
    .pagination { flex-wrap: wrap; gap: 2px; }
    .page-link { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

    /* Bottom nav spacing for PWA */
    body { padding-bottom: env(safe-area-inset-bottom, 0); }
}

/* Small phones */
@media (max-width: 400px) {
    .row .col-sm-6.col-xl-3, .row .col-md-3, .row .col-lg-3 {
        flex: 0 0 100%; max-width: 100%;
    }
    .stat-number { font-size: 1.3rem; }
    .btn { font-size: 0.8rem; }
}

/* ===================== CHART LOADING OVERLAY ===================== */
.chart-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.88);
    border-radius: 8px;
    z-index: 5;
    transition: opacity 0.4s;
    min-height: 120px;
}
[data-bs-theme="dark"] .chart-spinner { background: rgba(30,41,59,0.88); }

/* ===================== DARK MODE ===================== */
[data-bs-theme="dark"] {
    --main-bg: #0f172a;
    --bs-body-bg: #0f172a;
    --bs-body-color: #e2e8f0;
    --bs-border-color: #334155;
    color-scheme: dark;
}
[data-bs-theme="dark"] body { background: var(--main-bg); color: #e2e8f0; }

/* Layout */
[data-bs-theme="dark"] .topbar {
    background: rgba(30, 41, 59, 0.82) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom-color: rgba(51, 65, 85, 0.6) !important;
}

/* Cards e containers */
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .card-body,
[data-bs-theme="dark"] .stat-card {
    background: #1e293b !important;
    border-color: #334155 !important;
}
[data-bs-theme="dark"] .card-header,
[data-bs-theme="dark"] .card-footer,
[data-bs-theme="dark"] .card-header.bg-white,
[data-bs-theme="dark"] .card-footer.bg-white,
[data-bs-theme="dark"] .bg-white {
    background: #1e293b !important;
    border-color: #334155 !important;
}
[data-bs-theme="dark"] .stat-label { color: #94a3b8; }

/* Tabelas */
[data-bs-theme="dark"] .table { color: #e2e8f0; }
[data-bs-theme="dark"] .table > :not(caption) > * > * {
    background: transparent;
    border-color: #334155;
    color: #e2e8f0;
}
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light th,
[data-bs-theme="dark"] .table-light td {
    background: #0f172a !important;
    color: #94a3b8 !important;
    border-color: #334155 !important;
}
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * { background: #162032 !important; }
[data-bs-theme="dark"] .table-danger > td,
[data-bs-theme="dark"] .table-danger  { background: #3b0f0f !important; color: #fca5a5 !important; }

/* Ticket table específico */
[data-bs-theme="dark"] .ticket-table th {
    background: #0f172a !important;
    border-bottom-color: #334155 !important;
    color: #94a3b8 !important;
}
[data-bs-theme="dark"] .ticket-row:hover td { background: #162032 !important; }
[data-bs-theme="dark"] .ticket-card-mobile:hover { background: #162032 !important; }

/* Comentários */
[data-bs-theme="dark"] .comment-box {
    background: #162032 !important;
    border-color: #334155 !important;
}
[data-bs-theme="dark"] .comment-box.internal {
    background: #1c1400 !important;
    border-color: #92400e !important;
    border-left-color: #f59e0b !important;
}

/* Formulários */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .input-group-text {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}
[data-bs-theme="dark"] .form-control::placeholder { color: #64748b; }
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background: #0f172a !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 0.2rem rgba(59,130,246,0.25) !important;
}

/* Utilitários */
[data-bs-theme="dark"] .filter-bar { background: #1e293b !important; border-color: #334155 !important; }
[data-bs-theme="dark"] .bg-light, [data-bs-theme="dark"] .bg-light-subtle { background: #162032 !important; }
[data-bs-theme="dark"] .text-muted { color: #94a3b8 !important; }
[data-bs-theme="dark"] .text-dark { color: #e2e8f0 !important; }
[data-bs-theme="dark"] .border,
[data-bs-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border-start,
[data-bs-theme="dark"] .border-end { border-color: #334155 !important; }
[data-bs-theme="dark"] .badge.bg-light { background: #334155 !important; color: #e2e8f0 !important; }
[data-bs-theme="dark"] .badge.bg-secondary { background: #475569 !important; }

/* Alertas */
[data-bs-theme="dark"] .alert { border-color: #334155; }
[data-bs-theme="dark"] .alert-warning { background: #1c1400 !important; color: #fcd34d !important; border-color: #92400e !important; }
[data-bs-theme="dark"] .alert-danger  { background: #3b0f0f !important; color: #fca5a5 !important; border-color: #7f1d1d !important; }
[data-bs-theme="dark"] .alert-success { background: #052e16 !important; color: #86efac !important; border-color: #166534 !important; }

/* Modais */
[data-bs-theme="dark"] .modal-content { background: #1e293b !important; border-color: #334155 !important; }
[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer { border-color: #334155 !important; }

/* Nav / Tabs */
[data-bs-theme="dark"] .nav-tabs { border-color: #334155; }
[data-bs-theme="dark"] .nav-tabs .nav-link { color: #94a3b8; }
[data-bs-theme="dark"] .nav-tabs .nav-link.active {
    background: #1e293b !important;
    border-color: #334155 #334155 #1e293b !important;
    color: #e2e8f0 !important;
}

/* Login */
[data-bs-theme="dark"] .login-page { background: linear-gradient(135deg, #020617 0%, #0f172a 100%); }
[data-bs-theme="dark"] .login-card { background: #1e293b !important; }

/* Dark mode toggle button */
#darkModeToggle { width: 36px; height: 36px; padding: 0; display:flex; align-items:center; justify-content:center; }

/* Fundo principal e wrapper */
[data-bs-theme="dark"] .main-area { background: var(--main-bg) !important; }
[data-bs-theme="dark"] #app-wrapper { background: var(--main-bg) !important; }
[data-bs-theme="dark"] main { background: var(--main-bg) !important; }

/* Dropdown / popover */
[data-bs-theme="dark"] .dropdown-menu {
    background: #1e293b !important;
    border-color: #334155 !important;
}
[data-bs-theme="dark"] .dropdown-item { color: #e2e8f0 !important; }
[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus { background: #162032 !important; color: #fff !important; }
[data-bs-theme="dark"] .dropdown-divider { border-color: #334155 !important; }

/* Listas e grupos */
[data-bs-theme="dark"] .list-group-item {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

/* Botões outline */
[data-bs-theme="dark"] .btn-outline-secondary {
    color: #94a3b8 !important;
    border-color: #475569 !important;
}
[data-bs-theme="dark"] .btn-outline-secondary:hover {
    background: #334155 !important;
    color: #e2e8f0 !important;
}

/* Spinner chart */
[data-bs-theme="dark"] .chart-spinner { background: rgba(15,23,42,0.88); }

/* Breadcrumbs */
[data-bs-theme="dark"] .breadcrumb { background: transparent; }
[data-bs-theme="dark"] .breadcrumb-item a { color: #60a5fa !important; }
[data-bs-theme="dark"] .breadcrumb-item.active { color: #94a3b8 !important; }

/* Pagination */
[data-bs-theme="dark"] .page-link {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #60a5fa !important;
}
[data-bs-theme="dark"] .page-item.active .page-link {
    background: #3b82f6 !important;
    border-color: #3b82f6 !important;
    color: #fff !important;
}
[data-bs-theme="dark"] .page-item.disabled .page-link {
    background: #0f172a !important;
    color: #475569 !important;
}

/* Accordions */
[data-bs-theme="dark"] .accordion-item { background: #1e293b !important; border-color: #334155 !important; }
[data-bs-theme="dark"] .accordion-button { background: #1e293b !important; color: #e2e8f0 !important; }
[data-bs-theme="dark"] .accordion-button:not(.collapsed) { background: #162032 !important; color: #60a5fa !important; }
[data-bs-theme="dark"] .accordion-body { background: #1e293b !important; }

/* Progress bars */
[data-bs-theme="dark"] .progress { background: #334155 !important; }

/* Offcanvas (mobile menu) */
[data-bs-theme="dark"] .offcanvas { background: #1e293b !important; }
[data-bs-theme="dark"] .offcanvas-header { border-color: #334155 !important; }

/* Toast / Tooltip */
[data-bs-theme="dark"] .tooltip-inner { background: #334155 !important; }
[data-bs-theme="dark"] .toast { background: #1e293b !important; border-color: #334155 !important; }

/* Select2 / Datalist */
[data-bs-theme="dark"] option { background: #1e293b; color: #e2e8f0; }

/* Links */
[data-bs-theme="dark"] a:not(.btn):not(.nav-link):not(.sidebar-link):not(.dropdown-item) { color: #60a5fa; }
[data-bs-theme="dark"] a:not(.btn):not(.nav-link):not(.sidebar-link):not(.dropdown-item):hover { color: #93c5fd; }

/* Dashboard usuario - welcome */
[data-bs-theme="dark"] .welcome-card { background: linear-gradient(135deg, #1e3a5f 0%, #1e293b 100%) !important; }

/* Kanban */
[data-bs-theme="dark"] .kanban-column { background: #162032 !important; }
[data-bs-theme="dark"] .kanban-card { background: #1e293b !important; border-color: #334155 !important; }

/* Timeline */
[data-bs-theme="dark"] .timeline-item::before { background: #334155; }

/* Checkbox / switch custom */
[data-bs-theme="dark"] .form-check-input { background-color: #334155; border-color: #475569; }
[data-bs-theme="dark"] .form-check-input:checked { background-color: #3b82f6; border-color: #3b82f6; }

/* Hr / dividers */
[data-bs-theme="dark"] hr { border-color: #334155 !important; opacity: 0.5; }

/* Code blocks */
[data-bs-theme="dark"] pre, [data-bs-theme="dark"] code { background: #0f172a; color: #86efac; }

/* SLA config cards com header colorido - manter cores originais */
[data-bs-theme="dark"] .card-header.bg-primary,
[data-bs-theme="dark"] .card-header.bg-success,
[data-bs-theme="dark"] .card-header.bg-warning,
[data-bs-theme="dark"] .card-header.bg-danger,
[data-bs-theme="dark"] .card-header.bg-dark,
[data-bs-theme="dark"] .card-header.bg-info {
    border-color: transparent !important;
}

/* Table striped */
[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * { background: #162032 !important; }

/* ===================== PWA & MOBILE IMPROVEMENTS ===================== */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    padding: 12px 16px;
    background: #1e293b;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
}
.pwa-install-banner .btn-install {
    white-space: nowrap;
    background: #3b82f6;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Touch-friendly links and interactive elements */
@media (pointer: coarse) {
    .sidebar-link { padding: 10px 11px; min-height: 44px; }
    .table td, .table th { padding: 10px 8px; }
    .dropdown-item { padding: 10px 16px; }
    .nav-link { padding: 10px 12px; }
    .list-group-item { padding: 12px 16px; }
}

/* ===================== NX-CARD — Componente Unificado ===================== */
.nx-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: var(--nx-radius-lg);
    box-shadow: var(--nx-shadow-sm);
    transition: transform var(--nx-dur-fast) var(--nx-ease-out),
                box-shadow var(--nx-dur-fast) var(--nx-ease-out);
    overflow: hidden;
}
.nx-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--nx-shadow-hover);
}
.nx-card-header {
    padding: var(--nx-space-md) var(--nx-space-lg);
    border-bottom: 1px solid #f1f5f9;
    font-weight: 600;
    font-size: var(--nx-text-lg);
    display: flex;
    align-items: center;
    gap: var(--nx-space-sm);
}
.nx-card-body { padding: var(--nx-space-lg); }
.nx-card-footer {
    padding: var(--nx-space-md) var(--nx-space-lg);
    border-top: 1px solid #f1f5f9;
    font-size: var(--nx-text-sm);
    color: var(--nx-muted);
}

/* Module top accent */
.nx-card[data-module="ti"]         { border-top: 3px solid var(--nx-mod-ti); }
.nx-card[data-module="vendas"]     { border-top: 3px solid var(--nx-mod-vendas); }
.nx-card[data-module="sac"]        { border-top: 3px solid var(--nx-mod-sac); }
.nx-card[data-module="mercado"]    { border-top: 3px solid var(--nx-mod-mercado); }
.nx-card[data-module="admin"]      { border-top: 3px solid var(--nx-mod-admin); }
.nx-card[data-module="formulacao"] { border-top: 3px solid var(--nx-mod-formulacao); }

/* Dark mode */
[data-bs-theme="dark"] .nx-card {
    background: #1e293b;
    border-color: #334155;
}
[data-bs-theme="dark"] .nx-card-header,
[data-bs-theme="dark"] .nx-card-footer { border-color: #334155; }

/* ── NX-KPI — Stat display ── */
.nx-kpi {
    text-align: center;
    padding: var(--nx-space-lg) var(--nx-space-md);
}
.nx-kpi-icon {
    width: 48px; height: 48px;
    border-radius: var(--nx-radius-md);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto var(--nx-space-sm);
    font-size: 1.3rem;
}
.nx-kpi-value {
    font-size: var(--nx-text-2xl);
    font-weight: 800;
    line-height: 1;
    margin-bottom: var(--nx-space-xs);
}
.nx-kpi-label {
    font-size: var(--nx-text-xs);
    color: var(--nx-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}
.nx-kpi-sub {
    font-size: 0.65rem;
    color: #9ca3af;
    margin-top: 2px;
}

/* ===================== NX-ANIMATE — Entrada escalonada ===================== */
@keyframes nx-fadeup {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.nx-animate {
    animation: nx-fadeup var(--nx-dur-slow) var(--nx-ease-out) both;
}
.nx-animate:nth-child(1)  { animation-delay: 0.04s; }
.nx-animate:nth-child(2)  { animation-delay: 0.08s; }
.nx-animate:nth-child(3)  { animation-delay: 0.12s; }
.nx-animate:nth-child(4)  { animation-delay: 0.16s; }
.nx-animate:nth-child(5)  { animation-delay: 0.20s; }
.nx-animate:nth-child(6)  { animation-delay: 0.24s; }
.nx-animate:nth-child(7)  { animation-delay: 0.28s; }
.nx-animate:nth-child(8)  { animation-delay: 0.32s; }
.nx-animate:nth-child(9)  { animation-delay: 0.36s; }
.nx-animate:nth-child(10) { animation-delay: 0.40s; }
.nx-animate:nth-child(11) { animation-delay: 0.44s; }
.nx-animate:nth-child(12) { animation-delay: 0.48s; }

/* ── Fade-in simples (sem translate) ── */
@keyframes nx-fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.nx-fadein { animation: nx-fadein 0.5s ease both; }

/* ===================== NX-BADGE — Pulso para crítico ===================== */
.badge-critico,
.badge.nx-pulse {
    animation: nx-pulse-red 2s ease-in-out infinite;
}
@keyframes nx-pulse-red {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
    50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.badge-atencao,
.badge.nx-pulse-warn {
    animation: nx-pulse-yellow 2s ease-in-out infinite;
}
@keyframes nx-pulse-yellow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    50%      { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}

/* ===================== NX-SKELETON — Loading shimmer ===================== */
.nx-skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: nx-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--nx-radius-sm);
    color: transparent !important;
    user-select: none;
    pointer-events: none;
}
.nx-skeleton * { visibility: hidden; }
@keyframes nx-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
[data-bs-theme="dark"] .nx-skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
}

/* Skeleton variants */
.nx-skeleton-text { height: 14px; margin-bottom: 8px; width: 80%; }
.nx-skeleton-title { height: 20px; margin-bottom: 12px; width: 60%; }
.nx-skeleton-circle { border-radius: 50%; }
.nx-skeleton-card { height: 120px; border-radius: var(--nx-radius-lg); }

/* ===================== NX-EMPTY — Empty states ===================== */
.nx-empty {
    text-align: center;
    padding: var(--nx-space-2xl) var(--nx-space-lg);
    color: var(--nx-muted);
}
.nx-empty-icon {
    font-size: 3rem;
    opacity: 0.2;
    margin-bottom: var(--nx-space-md);
    display: block;
}
.nx-empty-title {
    font-size: var(--nx-text-lg);
    font-weight: 600;
    color: #475569;
    margin-bottom: var(--nx-space-xs);
}
.nx-empty-text {
    font-size: var(--nx-text-sm);
    color: #94a3b8;
    margin-bottom: var(--nx-space-md);
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}
[data-bs-theme="dark"] .nx-empty-title { color: #94a3b8; }
[data-bs-theme="dark"] .nx-empty-text { color: #64748b; }

/* ===================== NX-TABLE — Unified table ===================== */
.nx-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.nx-table thead th {
    font-size: var(--nx-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--nx-muted);
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    padding: 12px 14px;
}
.nx-table tbody td {
    vertical-align: middle;
    font-size: var(--nx-text-base);
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    transition: background var(--nx-dur-fast);
}
.nx-table tbody tr:hover td { background: #f8fafc; }
.nx-table tbody tr:last-child td { border-bottom: none; }
[data-bs-theme="dark"] .nx-table thead th {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
}
[data-bs-theme="dark"] .nx-table tbody td { border-color: #1e293b; }
[data-bs-theme="dark"] .nx-table tbody tr:hover td { background: #162032; }

/* ===================== NX-SIDEBAR-BADGE — Activity indicators ===================== */
.nx-sidebar-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--nx-radius-full);
    background: var(--nx-danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.nx-sidebar-dot {
    margin-left: auto;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--nx-success);
    flex-shrink: 0;
}
.nx-sidebar-dot.warn { background: var(--nx-warning); }
.nx-sidebar-dot.info { background: var(--nx-info); }

/* ===================== NX-COUNTER — Animated numbers ===================== */
.nx-counter {
    font-variant-numeric: tabular-nums;
    transition: color var(--nx-dur-fast);
}

/* ===================== NX-TREND — Trend indicators ===================== */
.nx-trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--nx-radius-full);
}
.nx-trend-up   { background: #dcfce7; color: #166534; }
.nx-trend-down { background: #fee2e2; color: #991b1b; }
.nx-trend-flat { background: #f1f5f9; color: #64748b; }
[data-bs-theme="dark"] .nx-trend-up   { background: rgba(22,101,52,.25); color: #86efac; }
[data-bs-theme="dark"] .nx-trend-down { background: rgba(153,27,27,.25); color: #fca5a5; }
[data-bs-theme="dark"] .nx-trend-flat { background: #334155; color: #94a3b8; }

/* ===================== MISC — Enhancements ===================== */

/* Smooth hover for stat cards */
.stat-card {
    transition: transform var(--nx-dur-fast) var(--nx-ease-out),
                box-shadow var(--nx-dur-fast) var(--nx-ease-out);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--nx-shadow-hover);
}

/* Row clickable cursor */
tr[onclick], tr.clickable { cursor: pointer; }

/* Focus ring utility */
.nx-focus-ring:focus-visible {
    outline: 2px solid var(--nx-primary);
    outline-offset: 2px;
    border-radius: var(--nx-radius-sm);
}

/* Scrollbar styling for webkit */
.nx-scroll::-webkit-scrollbar { width: 6px; }
.nx-scroll::-webkit-scrollbar-track { background: transparent; }
.nx-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 3px; }
.nx-scroll::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.25); }
[data-bs-theme="dark"] .nx-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); }

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .nx-animate, .badge-critico, .badge-atencao, .nx-skeleton, .online-dot {
        animation: none !important;
    }
    .nx-card, .stat-card, .topbar {
        transition: none !important;
    }
}

/* Print-friendly */
@media print {
    .sidebar, .sidebar-mobile, .topbar, .offcanvas, .pwa-install-banner,
    .no-print, .pagination, .filter-bar,
    #fabi-btn, #fabi-panel, #fabi-minibar, #fabi-greeting-bubble,
    #notif-container, .offcanvas-backdrop,
    .btn:not(.btn-print), .breadcrumb { display: none !important; }
    .main-area { margin: 0 !important; padding: 10px !important; }
    .card { border: 1px solid #ddd !important; box-shadow: none !important; break-inside: avoid; }
    body { background: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    #app-wrapper { display: block !important; }
    table { font-size: 11px !important; }
    a[href]:after { content: none !important; }
}
