/* ─── Self-hosted Inter (variable) ───
   Replaces the Google Fonts <link>. Same-origin + <link rel="preload"> in each page head
   means the font is available at first paint, killing the FOUT swap that showed the title
   in a system fallback before Inter arrived from gstatic. One variable file covers 100-900. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/inter-latin-wght-normal.woff2') format('woff2');
}

/* ─── Cross-document View Transitions ─── */
@view-transition { navigation: auto; }

::view-transition-group(sidebar) {
    animation-duration: 0s;
}
::view-transition-old(page-content) {
    animation: vt-fade-out 120ms ease both;
}
::view-transition-new(page-content) {
    animation: vt-fade-in 200ms ease 60ms both;
}
@keyframes vt-fade-out { to { opacity: 0; } }
@keyframes vt-fade-in  { from { opacity: 0; } }

/* Design tokens now live in shared/css/tokens.css and arrive via nl-shared.css
   (vendored by shared/sync.mjs). This file keeps only what is specific to this app. */


html.sidebar-collapsed { --sidebar-w: 68px; }

/* RGPD consent banner sits in the content column (right of the sidebar), aligned
   with the notice stack — never over the sidebar. Follows the collapse via --sidebar-w. */
#rgpd-banner { left: calc(var(--sidebar-w) + 16px); transition: left .3s cubic-bezier(.16,1,.3,1); }
@media (max-width: 768px) { #rgpd-banner { left: 16px; } }

@keyframes nl-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes nl-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-in {
    opacity: 0;
    animation: nl-slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes kpi-enter {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.kpi-animate > * {
    animation: kpi-enter 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.kpi-animate > *:nth-child(2) { animation-delay: 0.06s; }
.kpi-animate > *:nth-child(3) { animation-delay: 0.12s; }
.kpi-animate > *:nth-child(4) { animation-delay: 0.18s; }
.kpi-animate > *:nth-child(5) { animation-delay: 0.24s; }

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    margin: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Skip to content link */
.skip-link {
    position: fixed; top: -100%; left: 1rem; z-index: 9999;
    padding: 0.75rem 1.5rem; border-radius: 0 0 0.75rem 0.75rem;
    background: var(--accent-blue); color: #fff;
    font-size: 11px; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.15em; text-decoration: none;
    transition: top 0.15s ease;
}
.skip-link:focus { top: 0; }

.main-content {
    padding: 4rem 6rem;
    min-height: 100vh;
    view-transition-name: page-content;
    transition: margin-left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@media (min-width: 769px) {
    .main-content { margin-left: var(--sidebar-w); }
}

/* ── Page entrance animations (staggered) ─── */
.main-content > .ladder-breadcrumb { animation: nl-fade-in .3s ease both; }
.main-content > header              { animation: nl-slide-up .35s ease both; }
.main-content > *:nth-child(n+3)    { animation: nl-fade-in .35s ease both; }
.main-content > *:nth-child(3)      { animation-delay: .08s; }
.main-content > *:nth-child(4)      { animation-delay: .14s; }
.main-content > *:nth-child(5)      { animation-delay: .18s; }
.main-content > *:nth-child(6)      { animation-delay: .22s; }

.liquid-glass {
    background: var(--w02);
    /* backdrop-filter removed (USR-05): bg is translucent over solid black — the blur was invisible but still cost GPU on every card/scroll */
    border: none;
    border-radius: 2rem;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.liquid-glass-bordered {
    background: var(--glass-bg);
    /* backdrop-filter removed (USR-05): see .liquid-glass */
    border: 1px solid var(--glass-border);
    border-radius: 2rem;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.liquid-glass-bordered:hover {
    border-color: rgba(59, 130, 246, 0.3);
    background: var(--w05);
}

.text-glow { text-shadow: 0 0 40px rgba(59, 130, 246, 0.4); }

/* Pre-render sidebar shell (before JS adds .sidebar class) */
#portal-sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--bg-dark);
    border-right: 1px solid var(--w05);
    z-index: var(--z-sidebar);
    view-transition-name: sidebar;
}

/* Clean Modern Sidebar */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    padding: 0;
    background: var(--bg-dark);
    border-right: 1px solid var(--w05);
    z-index: var(--z-sidebar);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
    padding: 2.5rem 1.5rem 1rem;
    flex-shrink: 0;
    transition: padding 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.sidebar-header-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--w05);
}
.sidebar-header-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 0.625rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--dim-3);
    transition: all 0.2s;
}
.sidebar-header-btn:hover {
    color: var(--text-primary);
    background: var(--w05);
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 1.5rem;
    scrollbar-gutter: stable;
    transition: padding 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-footer {
    padding: 0.75rem 1.5rem 1.5rem;
    flex-shrink: 0;
    transition: padding 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0.85rem 1.25rem;
    margin-bottom: 0.25rem;
    border-radius: 0.75rem;
    color: var(--dim-4);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    transition: all 0.2s ease;
    text-decoration: none;
}

.sidebar-link i, .sidebar-link svg {
    width: 18px;
    height: 18px;
    opacity: 0.5;
    flex-shrink: 0;
}

.sidebar-link:hover {
    color: var(--text-primary);
    background: var(--w03);
}

.sidebar-link:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: -2px;
}

/* Foco de teclado global — anel visível em navegação por teclado. Só :focus-visible. */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
[role="switch"]:focus-visible,
[role="tab"]:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
    border-radius: 6px;
}

.sidebar-link.active {
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
}
/* Active indicator: flush-left bar, curved on the left, straight on the right. */
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 55%;
    background: var(--accent-blue);
    border-radius: 3px 0 0 3px;
}

.sidebar-link.active i,
.sidebar-link.active svg {
    color: var(--accent-blue);
    opacity: 1;
}

/* Message badge in sidebar links */
.sidebar-badge {
    margin-left: auto;
    background: var(--accent-blue);
    color: #fff;
    font-size: 8px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 9999px;
    min-width: 16px;
    text-align: center;
}

/* ── Sidebar Toggle (collapsed / expanded) ────────────────────────── */
.sidebar-logo { font-size: 1.5rem; line-height: 1; white-space: nowrap; text-decoration: none; color: inherit; }
.sidebar-logo .logo-slide {
    display: inline-block;
    overflow: hidden;
    max-width: 80px;
    opacity: 1;
    transition: max-width 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease 0.05s;
    vertical-align: top;
    line-height: inherit;
}
.sidebar-toggle { display: none; }

@media (min-width: 769px) {
    /* Toggle button (inherits .sidebar-header-btn styles) */
    .sidebar-toggle { display: flex; }
    .sidebar-toggle .toggle-expand { display: none; }
    html.sidebar-collapsed .sidebar-toggle .toggle-expand { display: block; }
    html.sidebar-collapsed .sidebar-toggle .toggle-collapse { display: none; }

    /* ── Collapsed state ───────────────────────────────────────────── */
    html.sidebar-collapsed .sidebar { overflow: visible; }

    html.sidebar-collapsed .sidebar-header { padding: 1.25rem 0.625rem 0.5rem; text-align: center; }
    html.sidebar-collapsed .sidebar-logo .logo-slide {
        max-width: 0;
        opacity: 0;
        transition: max-width 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.15s ease;
    }
    html.sidebar-collapsed .sidebar-header-row {
        flex-direction: column;
        align-items: center;
        margin-top: 0.5rem;
        gap: 0.25rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--w05);
    }
    html.sidebar-collapsed .sidebar .role-badge { display: none; }

    html.sidebar-collapsed .sidebar-nav {
        padding: 0 0.625rem;
        scrollbar-gutter: auto;
        scrollbar-width: none;
    }
    html.sidebar-collapsed .sidebar-nav::-webkit-scrollbar {
        display: none;
    }

    html.sidebar-collapsed .sidebar-link {
        justify-content: center;
        padding: 0.7rem;
        gap: 0;
        border-radius: 0.625rem;
        position: relative;
    }
    html.sidebar-collapsed .sidebar-link-label { display: none; }

    /* Tooltips on collapsed icons */
    html.sidebar-collapsed .sidebar-link:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + 8px);
        top: 50%;
        transform: translateY(-50%);
        background: var(--bg-panel);
        border: 1px solid var(--w08);
        color: var(--text-primary);
        padding: 6px 12px;
        border-radius: 8px;
        font-size: 11px;
        font-weight: 700;
        white-space: nowrap;
        z-index: calc(var(--z-sidebar) + 10);
        pointer-events: none;
        letter-spacing: 0.05em;
    }

    html.sidebar-collapsed .sidebar-badge {
        position: absolute;
        top: 4px; right: 4px;
        margin-left: 0;
        min-width: 8px; height: 8px;
        padding: 0; font-size: 0;
    }

    html.sidebar-collapsed .sidebar-footer { padding: 0.5rem 0.625rem 1rem; }
    html.sidebar-collapsed .sidebar-footer-card {
        padding: 0 !important;
        justify-content: center;
        background: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        border: none !important;
        box-shadow: none !important;
    }
    html.sidebar-collapsed .sidebar-footer-link { justify-content: center; }
    html.sidebar-collapsed .sidebar-footer-info { display: none; }
    html.sidebar-collapsed .sidebar-footer-logout { display: none; }
}

/* Footer card — layout vem das classes Tailwind (markup 1:1 com o backoffice);
   aqui só o que a build purged não tem */
.sidebar-footer-card { border-radius: 1rem; }
.sidebar-footer-link { text-decoration: none; color: inherit; }
.sidebar-footer-logout { border: none; background: none; cursor: pointer; }

/* Utilities em falta na build purged do Tailwind (usadas pelo markup copiado) */
.space-x-3 > :not([hidden]) ~ :not([hidden]) { margin-left: 0.75rem; }
.flex-1 { flex: 1 1 0%; }
.border-none { border-style: none; }
.w-3\.5 { width: 0.875rem; }
.h-3\.5 { height: 0.875rem; }
.transition-opacity { transition-property: opacity; transition-timing-function: cubic-bezier(.4,0,.2,1); transition-duration: .15s; }
.transition-colors { transition-property: color, background-color, border-color; transition-timing-function: cubic-bezier(.4,0,.2,1); transition-duration: .15s; }
.hover\:opacity-80:hover { opacity: 0.8; }
.hover\:bg-white\/\[0\.06\]:hover { background-color: hsla(0,0%,100%,.06); }
.hover\:text-red-400:hover { color: rgb(248 113 113); }

/* Breadcrumbs (Ladder path) */
.ladder-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--dim-2);
    margin-bottom: 3rem;
}

.ladder-breadcrumb span.active {
    color: var(--accent-blue);
}

.role-badge {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 99px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
}

.btn-pill {
    border-radius: 9999px;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.2em;
    font-size: 9px;
    gap: 8px;
    cursor: pointer;
    border: none;
}
.btn-pill:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-pill:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }

.btn-primary {
    padding: 0.75rem 2rem;
    background: var(--accent-blue);
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-blue-hover); transform: translateY(-1px); }

.btn-primary-full {
    width: 100%;
    padding: 1rem;
    background: var(--accent-blue);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
}
.btn-primary-full:hover:not(:disabled) { background: var(--accent-blue-hover); transform: translateY(-1px); }

.btn-secondary {
    padding: 0.75rem 2rem;
    background: var(--w03);
    border: 1px solid var(--w08) !important;
    color: var(--text-secondary);
}
.btn-secondary:hover:not(:disabled) { background: var(--w06); color: var(--text-primary); }

.btn-success {
    padding: 0.75rem 2rem;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3) !important;
    color: var(--color-success);
}
.btn-success:hover:not(:disabled) { background: rgba(34, 197, 94, 0.18); border-color: rgba(34, 197, 94, 0.5) !important; }

.btn-danger {
    padding: 0.75rem 2rem;
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
    color: rgba(239, 68, 68, 0.7);
}
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.06); color: var(--color-error); border-color: rgba(239, 68, 68, 0.5) !important; }

.btn-ghost {
    padding: 0.75rem 2rem;
    background: var(--w03);
    border: 1px solid var(--w06) !important;
    color: var(--text-muted);
}
.btn-ghost:hover { background: var(--w05); color: var(--text-primary); }

/* ── Tabs: standard (bordered, white active) ───────────────── */
.nl-tab {
    padding: 0.625rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
}
.nl-tab:hover { color: var(--text-primary); }
.nl-tab.active { color: var(--text-primary); background: var(--w04); border-color: var(--w08); }

/* ── Tabs: pill (contained, blue active) ───────────────────── */
.nl-tab-pill {
    padding: 0.4rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    background: transparent;
}
.nl-tab-pill:hover { color: var(--text-tertiary); }
.nl-tab-pill.active { background: rgba(59,130,246,0.15); color: var(--accent-blue); }

/* ── Tab panel visibility ──────────────────────────────────── */
.nl-panel { display: none; }
.nl-panel.active { display: block; }

/* Legacy portal tab (kept for invoices filter) */
.tab-btn {
    padding: 8px 20px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--dim-1);
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    background: transparent;
}
.tab-btn.active { background: var(--w06); color: var(--text-primary); }
.tab-btn:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }

/* ── Static modal overlay ──────────────────────────────────── */
.nl-modal-overlay {
    display: flex;
    position: fixed; inset: 0;
    z-index: var(--z-modal);
    align-items: center; justify-content: center;
    background: rgba(0,0,0,0.75);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
}
.nl-modal-overlay > * {
    transform: scale(0.97) translateY(6px); transition: transform .2s ease;
}
.nl-modal-overlay.open {
    opacity: 1; visibility: visible; pointer-events: auto;
}
.nl-modal-overlay.open > * { transform: scale(1) translateY(0); }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--bg-tooltip); border-radius: 20px; }

/* ── Utility classes missing from pre-compiled Tailwind ──────────────────── */
.text-4xl { font-size: 2.25rem; line-height: 2.5rem; }
.leading-tight { line-height: 1.25; }
.mb-16 { margin-bottom: 4rem; }

.btn-ver-mais {
    width: 100%;
    padding: 1rem;
    margin-top: 0.75rem;
    border: 1px solid var(--w07);
    border-radius: 1rem;
    background: transparent;
    color: var(--dim-1);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-ver-mais:hover {
    background: var(--w03);
    color: var(--text-primary);
    border-color: var(--w08);
}

/* ── Checkbox / radio — consistent sizing ──────────────────────────────────── */
input[type="checkbox"],
input[type="radio"] {
    min-width: 18px; min-height: 18px; cursor: pointer;
}

/* ── Form fields — force theme across all pages ──────────────────────────── */

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
select,
textarea {
    background-color: var(--w03) !important;
    color: var(--text-primary) !important;
    border-color: var(--w08);
    -webkit-text-fill-color: var(--text-primary);
    color-scheme: dark;
}

.empty-state {
    font-size: 9px;
    color: var(--text-disabled);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    padding: 2rem 0;
}

.empty-state-rich {
    text-align: center;
    padding: 3rem 1rem;
}
.empty-state-rich .empty-icon {
    width: 48px; height: 48px;
    border-radius: 16px;
    background: rgba(var(--chrome-rgb),0.02);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem;
}
.empty-state-rich .empty-icon i,
.empty-state-rich .empty-icon svg { color: var(--text-disabled); width: 22px; height: 22px; }
.empty-state-rich .empty-title {
    font-size: 13px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px;
}
.empty-state-rich .empty-sub {
    font-size: 10px; color: var(--text-disabled); margin-bottom: 16px;
}
.empty-state-rich .empty-cta {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 20px; border-radius: 999px;
    background: rgba(var(--chrome-rgb),0.04); border: 1px solid rgba(var(--chrome-rgb),0.06);
    color: var(--text-tertiary); font-size: 9px; font-weight: 900;
    text-transform: uppercase; letter-spacing: 0.15em;
    cursor: pointer; transition: all 0.15s;
}
.empty-state-rich .empty-cta:hover {
    background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.3); color: var(--accent-blue);
}

/* ── Forms: unified input / select / label ──────────────────── */
/* Base metrics equal the md token so a plain input matches a default dropdown.
   Mirrors the backoffice control-standardization (conventions §13). */
.nl-input,
.form-input {
    width: 100%;
    background: rgba(var(--chrome-rgb),0.03);
    border: 1px solid rgba(var(--chrome-rgb),0.06);
    border-radius: 0.75rem;
    min-height: 40px;
    padding: 0.625rem 0.875rem;
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s;
}
.nl-input:focus,
.form-input:focus { border-color: rgba(59, 130, 246, 0.4); box-shadow: none; }
.nl-input::placeholder,
.form-input::placeholder { color: var(--text-primary); opacity: 0.4; }
/* Placeholders = typed-text colour at low opacity (always dimmer than typed text,
   theme/background independent). body-prefixed to outrank Tailwind preflight. */
body input::placeholder, body textarea::placeholder { color: var(--text-primary); opacity: 0.4; }

.nl-select {
    width: 100%;
    background: rgba(var(--chrome-rgb),0.03);
    border: 1px solid rgba(var(--chrome-rgb),0.06);
    border-radius: 0.75rem;
    min-height: 40px;
    padding: 0.625rem 0.875rem;
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    outline: none;
    appearance: none;
    transition: border-color 0.2s;
}
.nl-select:focus { border-color: rgba(59, 130, 246, 0.4); }

/* ── Control size tokens + searchSelect/enhanceSelect (mirror of backoffice) ── */
.ctl-sm { min-height: 32px; padding: 0.375rem 0.625rem; font-size: 0.75rem; border-radius: 0.625rem; }
.ctl-md { min-height: 40px; padding: 0.625rem 0.875rem; font-size: 0.8125rem; border-radius: 0.75rem; }
.ctl-lg { min-height: 46px; padding: 0.8125rem 1rem; font-size: 0.875rem; border-radius: 0.875rem; }

.nl-ss { position: relative; }
.nl-ss-trigger {
    background: rgba(var(--chrome-rgb),0.03);
    border: 1px solid rgba(var(--chrome-rgb),0.06);
    border-radius: 0.75rem;
    min-height: 40px;
    padding: 0.625rem 0.875rem;
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s;
    cursor: pointer;
}
.nl-ss-trigger:hover,
.nl-ss-trigger:focus,
.nl-ss.is-open .nl-ss-trigger { border-color: rgba(59, 130, 246, 0.4); }
.nl-ss-trigger:disabled { opacity: 0.5; cursor: not-allowed; }
.nl-ss-pop {
    position: fixed;
    z-index: var(--z-popover);
    background: var(--bg-panel);
    border: 1px solid rgba(var(--chrome-rgb),0.08);
    border-radius: 0.875rem;
    padding: 0.5rem;
    box-shadow: 0 12px 32px rgba(0,0,0,0.35);
    transform-origin: top left;
    /* Smooth open AND close (matches the More Filters popover): transition on
       opacity/transform/visibility instead of a display toggle. */
    opacity: 0; transform: translateY(-6px) scale(0.98);
    visibility: hidden; pointer-events: none;
    transition: opacity .16s ease, transform .16s ease, visibility .16s;
}
.nl-ss-pop.hidden { display: block; }   /* neutralize Tailwind's display:none so it can transition both ways */
.nl-ss-pop:not(.hidden) { opacity: 1; transform: none; visibility: visible; pointer-events: auto; }
/* Trigger chevron flips while the dropdown is open. Explicit rotate(0deg) baseline so the
   transition interpolates on open too (transform:none → rotate can snap in some engines). */
.nl-ss-chev { transition: transform .18s ease; transform: rotate(0deg); }
.nl-ss.is-open .nl-ss-chev { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .nl-ss-pop { transition: none; } .nl-ss-chev { transition: none; } }
.nl-ss-list { max-height: 13rem; overflow-y: auto; }
.nl-ss-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s;
}
.nl-ss-item:hover,
.nl-ss-item.is-active { background: rgba(var(--chrome-rgb),0.05); }
.nl-ss-item.is-selected { background: rgba(59, 130, 246, 0.08); }
.nl-ss-empty { padding: 0.75rem 0.5rem; text-align: center; font-size: 0.625rem; color: var(--text-secondary); font-style: italic; }
.nl-ss-mount { width: auto; min-width: 11rem; }

.nl-search {
    background: rgba(var(--chrome-rgb),0.03);
    border: 1px solid rgba(var(--chrome-rgb),0.06);
    border-radius: 0.625rem;
    min-height: 32px;
    padding: 0.375rem 0.625rem 0.375rem 2rem;
    color: var(--text-primary);
    font-size: 0.75rem;
    font-family: inherit;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s;
}
.nl-search:focus { border-color: rgba(59, 130, 246, 0.4); box-shadow: none; }
.nl-search::placeholder { color: var(--text-primary); opacity: 0.4; text-transform: none; }

.nl-label {
    display: block;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.nl-filter {
    background: rgba(var(--chrome-rgb),0.03);
    border: 1px solid rgba(var(--chrome-rgb),0.06);
    border-radius: 0.75rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    outline: none;
    appearance: none;
    transition: border-color 0.2s;
}
.nl-filter:focus { border-color: rgba(59, 130, 246, 0.4); }

.form-otp {
    width: 100%;
    background: var(--w03);
    border: 1px solid var(--w07);
    border-radius: 0.875rem;
    padding: 1rem;
    color: var(--text-primary);
    font-size: 24px;
    font-family: monospace;
    font-weight: 900;
    letter-spacing: 0.4em;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}
.form-otp:focus { border-color: rgba(59, 130, 246, 0.5); }
.form-otp:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.form-otp::placeholder { color: var(--dim-1); }

/* Browser autocomplete override */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-panel) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    caret-color: var(--text-primary);
}

select option {
    background-color: var(--bg-panel) !important;
    color: var(--text-primary) !important;
}
select optgroup {
    background-color: var(--bg-panel);
    color: var(--text-primary);
}

/* Panel form fields — ensures dark inputs inside modals, drawers, popups */
[id$="-modal"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
[id$="-modal"] select, [id$="-modal"] textarea {
    background-color: var(--w03) !important;
    color: var(--text-primary) !important;
    border-color: var(--w08) !important;
    -webkit-text-fill-color: var(--text-primary) !important;
}

/* Page Titles */
.page-title {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

/* ── Mobile responsive ────────────────────────────────────────────────────────── */
#nl-mobile-toggle {
    display: none;
    position: fixed; top: .9rem; left: .9rem; z-index: var(--z-mobile-toggle);
    width: 40px; height: 40px; border-radius: 11px;
    background: rgba(5,5,5,.92); border: 1px solid rgba(var(--chrome-rgb),.09);
    align-items: center; justify-content: center;
    color: #fff; cursor: pointer; backdrop-filter: blur(12px);
}

#nl-mobile-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.6); z-index: var(--z-mobile-overlay);
}
#nl-mobile-overlay.visible { display: block; }

@media (max-width: 768px) {
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
        transition: transform .25s cubic-bezier(0.16,1,0.3,1);
        z-index: var(--z-mobile-sidebar);
    }
    .sidebar.mobile-open  { transform: translateX(0); }
    .sidebar.mobile-open .sidebar-header { padding: 2.5rem 1.5rem 1rem; text-align: left; }
    .sidebar.mobile-open .sidebar-logo .logo-slide { max-width: 80px; opacity: 1; }
    .sidebar.mobile-open .sidebar-header-row { flex-direction: row; margin-top: 0.75rem; }
    .sidebar.mobile-open .sidebar-nav { padding: 0 1.5rem; }
    .sidebar.mobile-open .sidebar-link { justify-content: flex-start; padding: 0.85rem 1.25rem; gap: 16px; border-radius: 0.75rem; }
    .sidebar.mobile-open .sidebar-link-label { display: inline; }
    .sidebar.mobile-open .sidebar-badge { position: static; min-width: 16px; height: auto; padding: 2px 6px; font-size: 8px; margin-left: auto; }
    .sidebar.mobile-open .sidebar-footer { padding: 0.75rem 1.5rem 1.5rem; }
    .sidebar.mobile-open .sidebar-footer-card { padding: 1rem !important; justify-content: flex-start; }
    .sidebar.mobile-open .sidebar-footer-info { display: block; }
    .sidebar.mobile-open .sidebar-footer-logout { display: inline-flex; }
    .main-content         { margin-left: 0 !important; width: 100% !important; padding: 2rem 1.5rem !important; }
    #nl-mobile-toggle     { display: flex; }
    .ladder-breadcrumb    { margin-bottom: 2rem; }
}

/* ─── Density: Small ────────────────────────────────────────────── */
body.density-small .liquid-glass,
body.density-small .liquid-glass-bordered { padding: 1rem 1.25rem !important; border-radius: 1rem; }
body.density-small .main-content { padding: 2rem 3rem !important; }
body.density-small .text-3xl { font-size: 1.25rem !important; }
body.density-small .text-xl { font-size: 1rem !important; }
body.density-small .mb-12 { margin-bottom: 1.5rem !important; }
body.density-small .mb-10 { margin-bottom: 1.25rem !important; }
body.density-small .mb-16 { margin-bottom: 2rem !important; }
body.density-small .gap-8 { gap: 1rem !important; }
body.density-small .gap-6 { gap: 0.75rem !important; }
body.density-small .p-10 { padding: 1.25rem !important; }
body.density-small .p-8 { padding: 1rem !important; }
body.density-small .p-6 { padding: 0.75rem !important; }
body.density-small .py-16 { padding-top: 2rem !important; padding-bottom: 2rem !important; }
body.density-small .py-12 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
body.density-small .py-8 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
body.density-small .py-4 { padding-top: 0.625rem !important; padding-bottom: 0.625rem !important; }
body.density-small .py-3 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
body.density-small .px-8 { padding-left: 1.25rem !important; padding-right: 1.25rem !important; }
body.density-small .px-6 { padding-left: 1rem !important; padding-right: 1rem !important; }
body.density-small .px-5 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
body.density-small .px-4 { padding-left: 0.625rem !important; padding-right: 0.625rem !important; }
body.density-small .p-5 { padding: 0.875rem !important; }
body.density-small .p-4 { padding: 0.625rem !important; }
body.density-small .gap-4 { gap: 0.625rem !important; }
body.density-small .gap-3 { gap: 0.5rem !important; }
body.density-small .mb-8 { margin-bottom: 1.25rem !important; }
body.density-small .mb-6 { margin-bottom: 0.875rem !important; }
body.density-small .mb-4 { margin-bottom: 0.625rem !important; }
body.density-small .text-5xl { font-size: 2rem !important; }
body.density-small .text-4xl { font-size: 1.75rem !important; }
body.density-small .text-2xl { font-size: 1.125rem !important; }
body.density-small .ladder-breadcrumb { margin-bottom: 1.5rem; }
body.density-small .nl-tab { padding: 0.4rem 0.875rem; }
body.density-small .nl-tab-pill { padding: 0.3rem 0.625rem; }
body.density-small .btn-primary,
body.density-small .btn-ghost,
body.density-small .btn-secondary,
body.density-small .btn-success,
body.density-small .btn-danger { padding: 0.5rem 1.25rem; }
body.density-small .btn-primary-full { padding: 0.75rem; }
body.density-small .nl-input,
body.density-small .form-input,
body.density-small .nl-select { padding: 0.5rem 0.75rem; font-size: 0.8rem; border-radius: 0.625rem; }
body.density-small .page-error { padding: 2rem 1rem; }
body.density-small .empty-state-rich { padding: 2rem 1rem; }

/* ─── Density: Large ────────────────────────────────────────────── */
body.density-large .liquid-glass,
body.density-large .liquid-glass-bordered { padding: 2.5rem 2.75rem !important; border-radius: 1.75rem; }
body.density-large .main-content { padding: 4rem 5rem !important; }
body.density-large .text-5xl { font-size: 3.5rem !important; }
body.density-large .text-4xl { font-size: 2.75rem !important; }
body.density-large .text-3xl { font-size: 2.25rem !important; }
body.density-large .text-2xl { font-size: 1.75rem !important; }
body.density-large .text-xl { font-size: 1.5rem !important; }
body.density-large .mb-16 { margin-bottom: 5rem !important; }
body.density-large .mb-12 { margin-bottom: 4rem !important; }
body.density-large .mb-10 { margin-bottom: 3.5rem !important; }
body.density-large .mb-8 { margin-bottom: 2.75rem !important; }
body.density-large .mb-6 { margin-bottom: 2rem !important; }
body.density-large .mb-4 { margin-bottom: 1.25rem !important; }
body.density-large .gap-8 { gap: 2.5rem !important; }
body.density-large .gap-6 { gap: 2rem !important; }
body.density-large .gap-4 { gap: 1.25rem !important; }
body.density-large .gap-3 { gap: 1rem !important; }
body.density-large .p-10 { padding: 3.5rem !important; }
body.density-large .p-8 { padding: 2.75rem !important; }
body.density-large .p-6 { padding: 2rem !important; }
body.density-large .p-5 { padding: 1.75rem !important; }
body.density-large .p-4 { padding: 1.25rem !important; }
body.density-large .py-16 { padding-top: 5rem !important; padding-bottom: 5rem !important; }
body.density-large .py-12 { padding-top: 4rem !important; padding-bottom: 4rem !important; }
body.density-large .py-8 { padding-top: 2.75rem !important; padding-bottom: 2.75rem !important; }
body.density-large .py-4 { padding-top: 1.25rem !important; padding-bottom: 1.25rem !important; }
body.density-large .py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
body.density-large .px-8 { padding-left: 2.75rem !important; padding-right: 2.75rem !important; }
body.density-large .px-6 { padding-left: 2rem !important; padding-right: 2rem !important; }
body.density-large .px-5 { padding-left: 1.75rem !important; padding-right: 1.75rem !important; }
body.density-large .px-4 { padding-left: 1.25rem !important; padding-right: 1.25rem !important; }
body.density-large .ladder-breadcrumb { margin-bottom: 3rem; }
body.density-large .nl-tab { padding: 0.75rem 1.5rem; font-size: 12px; }
body.density-large .nl-tab-pill { padding: 0.5rem 1rem; }
body.density-large .btn-primary,
body.density-large .btn-ghost,
body.density-large .btn-secondary,
body.density-large .btn-success,
body.density-large .btn-danger { padding: 0.875rem 2rem; font-size: 13px; }
body.density-large .btn-primary-full { padding: 1.125rem; font-size: 13px; }
body.density-large .nl-input,
body.density-large .form-input,
body.density-large .nl-select { padding: 0.875rem 1.125rem; font-size: 0.95rem; border-radius: 0.875rem; }
body.density-large .page-error { padding: 4rem 2.5rem; }
body.density-large .empty-state-rich { padding: 4rem 2.5rem; }

/* ═══ Light Mode ═══════════════════════════════════════════════════ */
body.light-mode {
    --bg-dark: #f5f5f7;
    --bg-panel: #ffffff;
    --bg-surface: #f0f0f2;
    --bg-elevated: #ffffff;
    --bg-tooltip: #1e293b;
    --accent-blue: #2563eb;
    --accent-blue-hover: #1d4ed8;
    --text-muted: #6b7280;
    --color-success: #16a34a;
    --color-warning: #ca8a04;
    --color-error: #dc2626;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #6b7280;
    --text-disabled: #d1d5db;
    --dim-1: #9ca3af;
    --dim-2: #6b7280;
    --dim-3: #4b5563;
    --dim-4: #374151;
    --dim-5: #1f2937;
    --dim-6: #111827;
    --dim-7: #030712;
    --chrome-rgb: 0, 0, 0;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(0, 0, 0, 0.08);
    color-scheme: light;
}

body.light-mode { background-color: var(--bg-dark); color: var(--text-primary); }

/* Tailwind color class overrides */
body.light-mode .text-white { color: var(--text-primary) !important; }
body.light-mode .text-gray-400 { color: #6b7280 !important; }
body.light-mode .text-gray-500 { color: #4b5563 !important; }
body.light-mode .text-gray-600 { color: #6b7280 !important; }
body.light-mode .text-gray-700 { color: #9ca3af !important; }

/* Keep white text on colored backgrounds */
body.light-mode .btn-primary,
body.light-mode .btn-primary-full,
body.light-mode .btn-primary:hover,
body.light-mode .btn-primary-full:hover { color: #fff !important; }
body.light-mode .sidebar-badge { color: #fff !important; }
body.light-mode .chat-tab .tab-badge { color: #fff !important; }
body.light-mode .nl-bell-badge { color: #fff !important; }
body.light-mode .sidebar:hover { box-shadow: 8px 0 32px rgba(0, 0, 0, 0.12); }

/* Notification panel + search palette shadows */
body.light-mode #nl-notif-panel { box-shadow: 0 24px 60px rgba(0,0,0,.16); }
body.light-mode .search-palette { box-shadow: 0 25px 60px rgba(0,0,0,.15), 0 0 0 1px rgba(0,0,0,.05); }

/* White-opacity backgrounds → black-opacity via attribute selectors */
body.light-mode [class*="bg-white\\/[0.0"],
body.light-mode [class*="bg-white/[0.0"] { background-color: rgba(0,0,0,0.04) !important; }
body.light-mode [class*="border-white\\/[0.0"],
body.light-mode [class*="border-white/[0.0"] { border-color: rgba(0,0,0,0.08) !important; }
body.light-mode [class*="divide-white\\/[0.0"] > * + *,
body.light-mode [class*="divide-white/[0.0"] > * + * { border-color: rgba(0,0,0,0.06) !important; }

/* Hover states with white-opacity */
body.light-mode [class*="hover\\:bg-white"]:hover { background-color: rgba(0,0,0,0.04) !important; }

/* Form fields */
body.light-mode input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
body.light-mode select,
body.light-mode textarea {
    color-scheme: light !important;
    -webkit-text-fill-color: var(--text-primary) !important;
}
body.light-mode input:-webkit-autofill,
body.light-mode input:-webkit-autofill:hover,
body.light-mode input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-panel) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
}
body.light-mode select option {
    background-color: var(--bg-panel);
    color: var(--text-primary);
}

/* Scrollbar */
body.light-mode ::-webkit-scrollbar-track { background: var(--bg-dark); }
body.light-mode ::-webkit-scrollbar-thumb { background: #d1d5db; }

/* Sidebar */
body.light-mode .sidebar { border-right-color: rgba(0,0,0,0.08); }

/* Mobile toggle */
body.light-mode #nl-mobile-toggle { background: rgba(255,255,255,.92); border-color: rgba(0,0,0,.09); color: var(--text-primary) !important; }

/* Modal overlay stays dark */
body.light-mode .nl-modal-overlay { background: rgba(0,0,0,0.5); }

/* Liquid glass light variant */
body.light-mode .liquid-glass { backdrop-filter: blur(20px); }
body.light-mode .liquid-glass-bordered { backdrop-filter: blur(20px); }
body.light-mode .liquid-glass-bordered:hover { border-color: rgba(37, 99, 235, 0.3); }

/* ── Pilar dots (multi-pilar badges) ──────────────────────────────────────────── */
.pillar-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}
.pillar-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.pillar-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 8px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 2px 8px;
    border-radius: 99px;
    border: 1px solid;
}

/* ═══ Chat Engine (ce-) — shared message rendering ═══════════════ */

/* Layout de chat (canais à esquerda — copiado do chat.html do backoffice) */
.chat-layout {
    display: flex;
    height: calc(100vh - 16rem);
    min-height: 420px;
    gap: 2rem;
}
.chat-channels {
    width: 250px;
    flex-shrink: 0;
    background: var(--w02);
    border: 1px solid var(--w06);
    border-radius: 1.25rem;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}
.channel-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.6rem 0.85rem;
    border-radius: 0.75rem;
    color: var(--dim-5, var(--dim-3));
    font-size: 11px;
    font-weight: 600;
    transition: all 0.15s;
    cursor: pointer;
    border: 1px solid transparent;
    background: none;
    width: 100%;
    text-align: left;
    margin-bottom: 2px;
}
.channel-link:hover {
    color: var(--text-primary);
    background: var(--w03);
}
.channel-link.active {
    color: var(--text-primary);
    background: rgba(59,130,246,0.08);
    border: 1px solid rgba(59,130,246,0.12);
}
@media (max-width: 768px) {
    .chat-layout { flex-direction: column; height: auto; gap: 1rem; }
    .chat-channels {
        width: 100%; border-right: none; padding-right: 0;
        display: flex; gap: 0.25rem; overflow-x: auto;
        border-bottom: 1px solid var(--w03); padding-bottom: 0.5rem;
    }
    .channel-link { width: auto; white-space: nowrap; }
    .chat-layout .chat-panel { height: calc(100vh - 360px); min-height: 360px; }
}

.chat-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--w02);
    border: 1px solid var(--w06);
    border-radius: 1.25rem;
}
.chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid var(--w04);
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
    flex-shrink: 0;
}

.messages-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Message row */
.msg-row {
    position: relative;
    padding: 3px 0.5rem;
    margin: 0 -0.5rem;
    border-radius: 0.5rem;
}
.msg-row:hover { background: rgba(var(--chrome-rgb),0.015); }

.ce-msg-group {
    display: flex;
    gap: 1rem;
}
.ce-avatar-col {
    width: 36px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
}
.msg-continuation .ce-avatar-col {
    visibility: hidden;
}
.ce-time-inline {
    visibility: visible;
    display: none;
    font-size: 8px;
    color: var(--dim-2);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    line-height: 20px;
}
.msg-continuation:hover .ce-avatar-col .ce-time-inline { display: block; }

.ce-msg-body { flex: 1; min-width: 0; }
.ce-msg-header { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 3px; }
.ce-msg-name { font-size: 13px; font-weight: 700; }
.ce-msg-time { font-size: 9px; color: var(--dim-2); font-weight: 800; text-transform: uppercase; letter-spacing: 0.2em; }
.ce-msg-text { font-size: 13px; color: var(--dim-7); line-height: 1.55; word-break: break-word; white-space: pre-line; }
.ce-msg-text.mine { color: var(--text-primary); }

/* Date separator */
.ce-date-sep {
    display: flex; align-items: center; gap: 1rem;
    margin: 1.5rem 0 0.5rem;
}
.ce-date-sep::before, .ce-date-sep::after {
    content: ''; flex: 1; height: 1px; background: rgba(var(--chrome-rgb),0.05);
}
.ce-date-sep span {
    font-size: 9px; font-weight: 900; text-transform: uppercase;
    letter-spacing: 0.2em; color: var(--dim-1);
}

.ce-msg-edited {
    font-size: 8px; color: var(--dim-3); font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.15em;
    margin-left: 6px;
}

/* Hover actions toolbar */
.ce-actions {
    position: absolute; top: -12px; right: 12px;
    display: none; align-items: center; gap: 1px;
    background: var(--bg-elevated); border: 1px solid rgba(var(--chrome-rgb),0.06);
    border-radius: 6px; padding: 2px; z-index: 5;
}
.msg-row:hover .ce-actions { display: flex; }
.ce-action-btn {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px; cursor: pointer; color: var(--dim-4);
    transition: all 0.1s; background: none; border: none;
}
.ce-action-btn:hover { background: rgba(var(--chrome-rgb),0.06); color: var(--dim-7); }
.ce-action-btn.ce-danger:hover { color: var(--color-error); background: rgba(239,68,68,0.08); }

/* Reply reference (inline above message) */
.ce-reply-ref {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 4px; padding-left: 52px;
    font-size: 11px; color: var(--dim-3); cursor: pointer;
}
.ce-reply-ref:hover { color: var(--dim-5); }
.ce-reply-bar { width: 2px; height: 12px; border-radius: 1px; background: var(--dim-2); flex-shrink: 0; }
.ce-reply-author { font-weight: 700; color: var(--dim-4); }
.ce-reply-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 400px; }

/* Reply/Edit banners (composing) */
.ce-reply-banner, .ce-edit-banner {
    display: none; align-items: center; gap: 0.75rem;
    padding: 0.6rem 1rem; border-radius: 0 0.5rem 0.5rem 0;
    margin-bottom: 0.5rem; font-size: 12px; color: var(--dim-5);
}
.ce-reply-banner { background: rgba(59,130,246,0.06); border-left: 3px solid var(--accent-blue); }
.ce-edit-banner  { background: rgba(234,179,8,0.06);  border-left: 3px solid var(--color-warning); }
.ce-reply-banner.active, .ce-edit-banner.active { display: flex; }
.ce-banner-close {
    margin-left: auto; cursor: pointer; color: var(--dim-4);
    transition: color 0.1s; background: none; border: none;
    display: flex; align-items: center;
}
.ce-banner-close:hover { color: var(--text-primary); }

/* Pinned bar (Discord-style) */
.ce-pinned-bar {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    background: rgba(234,179,8,0.04);
    border-bottom: 1px solid rgba(var(--chrome-rgb),0.04);
    font-size: 11px; font-weight: 600; color: var(--color-warning);
    cursor: pointer; user-select: none;
    transition: background 0.15s;
}
.ce-pinned-bar:hover { background: rgba(234,179,8,0.08); }
.ce-pinned-chevron { transition: transform 0.15s; }
.has-pins { position: relative; }

/* Pinned popover */
.ce-pinned-popover {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
    max-height: 320px; overflow-y: auto;
    background: var(--bg-panel);
    border: 1px solid rgba(var(--chrome-rgb),0.08);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.ce-pinned-popover.hidden { display: none; }
.ce-pinned-popover-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; font-size: 10px; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.15em; color: var(--color-warning);
    border-bottom: 1px solid rgba(var(--chrome-rgb),0.04);
    position: sticky; top: 0; background: var(--bg-panel);
}
.ce-pinned-close {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 2px; border-radius: 4px; display: flex;
}
.ce-pinned-close:hover { color: var(--text-primary); background: rgba(var(--chrome-rgb),0.06); }
.ce-pinned-popover-list { padding: 4px; }
.ce-pinned-msg {
    display: flex; flex-direction: column; gap: 2px;
    padding: 8px 10px; border-radius: 6px; cursor: pointer;
    font-size: 12px; color: var(--dim-5); margin-bottom: 2px;
    transition: background 0.1s;
}
.ce-pinned-msg:hover { background: rgba(var(--chrome-rgb),0.04); }
.ce-pin-author { font-weight: 700; color: var(--dim-6); font-size: 11px; }
.ce-pin-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim-5); }
.ce-pin-date { font-size: 10px; color: var(--dim-4); }

/* Empty state */
.ce-empty {
    display: flex; align-items: center; justify-content: center;
    height: 100%; min-height: 80px;
    font-size: 9px; color: var(--dim-2); font-weight: 900;
    text-transform: uppercase; letter-spacing: 0.2em;
}

.chat-input-bar {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--w04);
}
.chat-input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--w03);
    border: 1px solid var(--w07);
    border-radius: 1rem;
    padding: 0 1rem;
}
.chat-input-row:focus-within {
    border-color: rgba(59, 130, 246, 0.3);
}
.chat-input-row input {
    flex: 1;
    background: transparent !important;
    border: none !important;
    outline: none;
    color: var(--text-primary) !important;
    font-size: 13px;
    padding: 0.8rem 0;
    font-family: inherit;
}
.chat-input-row input::placeholder {
    color: var(--dim-1);
}
.chat-send-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    flex-shrink: 0;
    transition: all 0.15s;
}
.chat-send-btn:hover {
    background: var(--accent-blue-hover);
    transform: scale(1.08);
}

.chat-tab {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    white-space: nowrap;
    background: var(--w02);
    border: 1px solid var(--w06);
    color: var(--dim-1);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.chat-tab:hover { background: var(--w04); color: var(--dim-5); }
.chat-tab.active {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.2);
    color: var(--accent-blue);
}
.chat-tab .tab-badge {
    background: var(--accent-blue);
    color: #fff;
    font-size: 8px;
    font-weight: 900;
    padding: 1px 5px;
    border-radius: 9999px;
    min-width: 14px;
    text-align: center;
}

.ce-team-badge {
    font-size: 7px;
    font-weight: 800;
    color: rgba(59, 130, 246, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

/* ── Notification popover ───────────────────────────────────────────────── */
/* Anchored to the bell button via inline top/left set in JS (_positionPanel).
   Mobile turns it into a bottom sheet (see mobile media query). */
#nl-notif-panel {
    position: fixed; top: 0; left: 0;
    width: 360px; max-height: min(560px, calc(100vh - 32px));
    background: var(--bg-surface); border: 1px solid var(--w06); border-radius: 16px;
    z-index: var(--z-notif); display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 24px 60px rgba(0,0,0,.7);
    opacity: 0; transform: scale(.96); transform-origin: top left;
    pointer-events: none;
    transition: opacity .16s ease, transform .18s cubic-bezier(0.16,1,0.3,1);
}
#nl-notif-panel.open { opacity: 1; transform: scale(1); pointer-events: auto; }

#nl-notif-overlay {
    display: none; position: fixed; inset: 0;
    background: transparent; z-index: var(--z-notif-overlay);
}
#nl-notif-overlay.visible { display: block; }

.nl-bell-badge {
    display: flex; align-items: center; justify-content: center;
    position: absolute; top: -5px; right: -5px;
    min-width: 16px; height: 16px; border-radius: 99px;
    background: var(--color-error); color: #fff;
    font-size: 7px; font-weight: 900; letter-spacing: 0; line-height: 1;
    padding: 0 3px; border: 2px solid var(--bg-dark); box-sizing: border-box;
}
.nl-bell-badge.hidden { display: none; }

.notif-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 10px 12px; border-radius: 10px;
    transition: background .12s; cursor: pointer;
    text-decoration: none; border: 1px solid transparent;
    color: inherit;
}
.notif-item:hover  { background: var(--w03); }
.notif-item.n-warn { border-color: rgba(249,115,22,.15); }
.notif-item.n-err  { border-color: rgba(239,68,68,.15);  }
.notif-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.notif-row { position: relative; }
.notif-row .notif-item { flex: 1; min-width: 0; }
.notif-dismiss {
    position: absolute; right: 6px; top: 6px;
    width: 20px; height: 20px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; cursor: pointer;
    color: rgba(var(--chrome-rgb),0.2); opacity: 0; transition: all 0.15s;
}
.notif-row:hover .notif-dismiss { opacity: 1; }
.notif-dismiss:hover { background: rgba(var(--chrome-rgb),0.06); color: rgba(var(--chrome-rgb),0.5); }

@media (max-width: 768px) {
    /* Bottom sheet — !important beats the inline top/left from _positionPanel */
    #nl-notif-panel {
        left: 8px !important; right: 8px !important; width: auto !important;
        top: auto !important; bottom: 8px !important;
        max-height: 80vh; border-radius: 20px; transform-origin: bottom center;
    }
}

/* ── Search palette (Ctrl+K) ────────────────────────────────────────────── */
.search-overlay {
    position: fixed; inset: 0; z-index: var(--z-modal);
    background: rgba(0,0,0,.65); backdrop-filter: blur(4px);
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: min(20vh, 160px);
}
.search-palette {
    width: min(580px, 92vw);
    background: var(--bg-surface); border: 1px solid var(--w08);
    border-radius: 1.25rem; overflow: hidden;
    box-shadow: 0 25px 60px rgba(0,0,0,.7), 0 0 0 1px rgba(var(--chrome-rgb),.03);
}
.search-input-row {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--w05);
}
.search-input-row input {
    flex: 1; background: transparent !important; border: none !important; outline: none;
    color: var(--text-primary) !important; font-size: 15px; font-weight: 500;
    font-family: 'Inter', sans-serif;
}
.search-input-row input::placeholder { color: var(--dim-3); }
.search-kbd {
    padding: 2px 7px; border-radius: 6px; font-size: 10px; font-weight: 700;
    color: var(--dim-4); background: var(--w05); border: 1px solid var(--w08);
    font-family: 'Inter', sans-serif; line-height: 1.6;
}
.search-results {
    max-height: 380px; overflow-y: auto; padding: 8px;
}
.search-hint {
    text-align: center; padding: 2rem 1rem;
    color: var(--dim-3); font-size: 12px; font-weight: 600;
}
.search-group { margin-bottom: 4px; }
.search-group-label {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px; font-size: 9px; font-weight: 900;
    text-transform: uppercase; letter-spacing: 0.3em; color: var(--dim-4);
}
.search-result {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-radius: 10px;
    transition: background .1s; text-decoration: none; color: inherit;
}
.search-result:hover { background: var(--w05); }
.search-result-icon {
    width: 30px; height: 30px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* ═══ Button Loading State ═════════════════════════════════════════ */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}
.btn-loading .btn-text { opacity: 0; }
.btn-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 16px; height: 16px;
    border: 2px solid rgba(var(--chrome-rgb), 0.15);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: nl-spin 0.6s linear infinite;
}
@keyframes nl-spin { to { transform: rotate(360deg); } }

/* ═══ Page Error State ════════════════════════════════════════════ */
.page-error {
    text-align: center;
    padding: 4rem 2rem;
}
.page-error .error-icon {
    width: 56px; height: 56px;
    border-radius: 16px;
    background: rgba(239, 68, 68, 0.08);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.25rem;
    color: var(--color-error);
}
.page-error .error-icon i,
.page-error .error-icon svg { width: 24px; height: 24px; }
.page-error .error-title {
    font-size: 13px; font-weight: 700; color: var(--text-secondary); margin-bottom: 4px;
}
.page-error .error-sub {
    font-size: 10px; color: var(--text-muted); margin-bottom: 20px;
}
.page-error .error-retry {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 20px; border-radius: 999px;
    background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--color-error); font-size: 9px; font-weight: 900;
    text-transform: uppercase; letter-spacing: 0.15em;
    cursor: pointer; transition: all 0.15s;
}
.page-error .error-retry:hover {
    background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.4);
}

/* ═══ Inline Field Error ══════════════════════════════════════════ */
.field-error {
    font-size: 10px; color: var(--color-error); margin-top: 4px;
    display: flex; align-items: center; gap: 4px;
}
.nl-input.has-error,
.form-input.has-error,
.nl-select.has-error {
    border-color: rgba(239, 68, 68, 0.4) !important;
}

/* ═══ Reduced Motion ═══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ═══ High Contrast ════════════════════════════════════════════════ */
@media (prefers-contrast: more) {
    :root {
        --dim-1: #888;
        --dim-2: #999;
        --dim-3: #aaa;
        --dim-4: #bbb;
        --dim-5: #ccc;
        --dim-6: #ddd;
        --dim-7: #eee;
        --text-muted: #999;
        --text-tertiary: #bbb;
        --text-disabled: #777;
    }
    body.light-mode {
        --dim-1: #555;
        --dim-2: #444;
        --dim-3: #333;
        --dim-4: #222;
        --dim-5: #111;
        --dim-6: #000;
        --dim-7: #000;
        --text-muted: #444;
        --text-tertiary: #333;
        --text-disabled: #666;
    }
}

/* ── Shared entrance animations ─────────────────────────────── */
@keyframes nl-panel-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes nl-item-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.nl-anim-panel { animation: nl-panel-in 0.4s cubic-bezier(0.16,1,0.3,1) backwards; }
.nl-anim-item  { animation: nl-item-in 0.3s cubic-bezier(0.16,1,0.3,1) backwards; }
.nl-anim-fade  { animation: nl-fade-in 0.3s ease backwards; }
