/* ═══════════════════════════════════════════════════════════════
   NEXUS · DESIGN SYSTEM (Facedoor brand)
   Sophisticated dark-tech · strictly monochrome (black & white)
   Space Grotesk (display) · IBM Plex Sans (body) · IBM Plex Mono (UI)
   White is the only accent. Dot-mesh + scanline "facial scan" motif.
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
    /* ---------- SURFACES (deep cool neutral) ---------- */
    --bg:         oklch(0.145 0.012 255);
    --bg-2:       oklch(0.175 0.014 255);
    --surface:    oklch(0.205 0.016 255);
    --surface-2:  oklch(0.245 0.018 255);
    --line:       oklch(0.30 0.018 255);
    --line-soft:  oklch(0.26 0.016 255 / 0.6);

    /* ---------- TEXT ---------- */
    --fg:    oklch(0.975 0.004 255);
    --muted: oklch(0.74 0.012 255);
    --faint: oklch(0.56 0.012 255);

    /* ---------- ACCENT (monochrome · white is the accent) ---------- */
    --acc:      oklch(0.985 0 0);
    --acc-deep: oklch(0.82 0 0);
    --acc-soft: oklch(1 0 0 / 0.10);
    --acc-glow: oklch(1 0 0 / 0.22);
    --on-acc:   oklch(0.16 0.006 255);

    /* ---------- FUNCTIONAL (destructive only · not a brand color) -- */
    --danger:      oklch(0.68 0.18 22);
    --danger-soft: oklch(0.68 0.18 22 / 0.12);

    /* ---------- TYPE ---------- */
    --font-display: 'Space Grotesk', system-ui, sans-serif;
    --font-body:    'IBM Plex Sans', system-ui, sans-serif;
    --font-mono:    'IBM Plex Mono', ui-monospace, monospace;
    --font: var(--font-body);

    /* ---------- RADII ---------- */
    --radius-sm: 12px;
    --radius:    16px;
    --radius-lg: 24px;
    --r-pill:    999px;

    /* ---------- ELEVATION ---------- */
    --shadow-cta:   0 14px 40px -12px var(--acc-glow);
    --shadow-panel: 0 40px 90px -50px oklch(0 0 0 / 0.9);
    --shadow:       0 24px 60px -32px oklch(0 0 0 / 0.85);

    /* ---------- MOTION ---------- */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --transition: 240ms var(--ease);

    --sidebar-width: 288px;
}

/* ── Reset ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font-body);
    font-size: 16px;
    background: var(--bg);
    color: var(--fg);
    overflow: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--fg); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Brand type helpers ───────────────────────────── */
.t-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--acc-deep);
}

.t-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--faint);
}

::selection { background: var(--acc-glow); color: var(--fg); }

/* ── Decorative motifs: dot-mesh + scanline ───────── */
.mesh {
    position: absolute; inset: 0; z-index: 1; pointer-events: none;
    background-image: radial-gradient(oklch(1 0 0 / 0.10) 1px, transparent 1.4px);
    background-size: 26px 26px;
    mask-image: radial-gradient(80% 70% at 70% 40%, black, transparent 75%);
    -webkit-mask-image: radial-gradient(80% 70% at 70% 40%, black, transparent 75%);
    opacity: 0.7;
}

.scanline {
    position: absolute; left: 0; right: 0; z-index: 2; height: 2px; pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--acc-glow) 30%, var(--acc) 50%, var(--acc-glow) 70%, transparent);
    filter: blur(0.4px);
    animation: scanDown 6.5s var(--ease) infinite;
    opacity: 0.5;
}

@keyframes scanDown {
    0%   { top: 10%; opacity: 0; }
    12%  { opacity: 0.55; }
    88%  { opacity: 0.55; }
    100% { top: 90%; opacity: 0; }
}

/* ── Screens ──────────────────────────────────────── */
.screen { display: none; height: 100vh; height: 100dvh; width: 100%; }
.screen.active { display: flex; }

/* ═══════════════════════════════════════════════════
   LOGIN
   ═══════════════════════════════════════════════════ */
.login-bg {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background:
        radial-gradient(120% 90% at 80% 8%, transparent, oklch(0.13 0.012 255 / 0.6) 70%),
        linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 60%);
    padding: 24px;
}

.login-card {
    position: relative;
    z-index: 3;
    width: 100%;
    max-width: 440px;
    background: linear-gradient(180deg, var(--surface), var(--bg-2));
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    padding: 52px 44px;
    box-shadow: var(--shadow-panel);
    animation: rise 0.6s var(--ease) both;
}

.login-header {
    text-align: center;
    margin-bottom: 38px;
}

.logo {
    display: inline-flex;
    margin-bottom: 18px;
}

.nexus-logo-img {
    width: 188px;
    height: auto;
}

.nexus-icon-img {
    height: 26px;
    width: auto;
}

.nexus-empty-icon {
    width: 76px;
    height: auto;
    opacity: 0.85;
}

.subtitle {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--acc-deep);
    margin-top: 14px;
}

/* ── Inputs ───────────────────────────────────────── */
.input-group {
    margin-bottom: 22px;
}

.input-group label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--faint);
    margin-bottom: 9px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    width: 18px;
    height: 18px;
    color: var(--faint);
    pointer-events: none;
    transition: color var(--transition);
}

.input-wrapper:focus-within .input-icon { color: var(--fg); }

.input-wrapper input {
    width: 100%;
    height: 52px;
    padding: 0 16px 0 46px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-size: 0.95rem;
    font-family: var(--font-body);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.input-wrapper input::placeholder { color: var(--faint); }

.input-wrapper input:focus {
    border-color: var(--acc);
    box-shadow: 0 0 0 3px var(--acc-glow);
}

/* ── Buttons ──────────────────────────────────────── */
.btn-primary {
    width: 100%;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--acc);
    border: 1px solid var(--acc);
    border-radius: var(--r-pill);
    color: var(--on-acc);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
    margin-top: 10px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-cta);
}

.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ── Error ────────────────────────────────────────── */
.error-msg {
    background: var(--danger-soft);
    border: 1px solid oklch(0.68 0.18 22 / 0.35);
    color: var(--danger);
    font-size: 0.84rem;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
}

.hidden { display: none !important; }

/* ── Spinner ──────────────────────────────────────── */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid oklch(0 0 0 / 0.25);
    border-top-color: var(--on-acc);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-secondary .spinner,
.btn-danger .spinner,
.users-loading .spinner {
    border-color: oklch(1 0 0 / 0.2);
    border-top-color: var(--fg);
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════════════════════════════════════════════════
   PORTAL
   ═══════════════════════════════════════════════════ */
.portal-bg {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background:
        radial-gradient(110% 80% at 50% -10%, oklch(0.2 0.016 255 / 0.7), transparent 60%),
        var(--bg);
}

.portal-header {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    border-bottom: 1px solid var(--line-soft);
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--fg);
}

.portal-content {
    position: relative;
    z-index: 3;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    overflow-y: auto;
}

.portal-welcome {
    text-align: center;
    margin-bottom: 54px;
    animation: rise 0.6s var(--ease) both;
}

.portal-logo {
    width: 150px;
    margin-bottom: 18px;
}

.portal-subtitle {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--acc-deep);
}

.portal-modules {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 16px;
    width: 100%;
    max-width: 680px;
    animation: rise 0.7s var(--ease) 0.1s both;
}

.module-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 24px 26px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform var(--transition), border-color var(--transition), background var(--transition), box-shadow var(--transition);
    text-align: left;
    font-family: var(--font-body);
    color: var(--fg);
    overflow: hidden;
}

/* white corner-glow */
.module-card::after {
    content: "";
    position: absolute;
    top: 0; right: 0;
    width: 90px; height: 90px;
    background: radial-gradient(circle at top right, var(--acc-soft), transparent 70%);
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
}

.module-card:hover:not(:disabled) {
    border-color: var(--acc);
    background: var(--surface-2);
    transform: translateY(-6px);
    box-shadow: var(--shadow);
}

.module-card:hover:not(:disabled)::after { opacity: 1; }

.module-card:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.module-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--acc-soft);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    color: var(--fg);
    transition: background var(--transition), border-color var(--transition);
}

.module-card:hover:not(:disabled) .module-icon {
    background: var(--acc);
    border-color: var(--acc);
    color: var(--on-acc);
}

.module-icon svg { width: 22px; height: 22px; }

.module-info {
    flex: 1;
    min-width: 0;
}

.module-info h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 5px;
}

.module-info p {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.5;
}

.module-arrow {
    color: var(--faint);
    transition: transform var(--transition), color var(--transition);
}

.module-card:hover:not(:disabled) .module-arrow {
    color: var(--fg);
    transform: translateX(4px);
}

.module-arrow svg { width: 18px; height: 18px; }

.module-badge {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    padding: 5px 11px;
    border-radius: var(--r-pill);
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--faint);
    white-space: nowrap;
}

@media (max-width: 768px) {
    .portal-header { padding: 16px 18px; }
    .portal-content { padding: 28px 18px; }
    .portal-modules { grid-template-columns: 1fr; }
    .portal-logo { width: 128px; }
}

/* ═══════════════════════════════════════════════════
   CHAT LAYOUT
   ═══════════════════════════════════════════════════ */
#chat-screen { flex-direction: row; }

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh; height: 100dvh;
    background: var(--bg-2);
    border-right: 1px solid var(--line-soft);
    display: flex;
    flex-direction: column;
    transition: transform 0.35s var(--ease);
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--line-soft);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.btn-icon {
    width: 38px; height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    color: var(--muted);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--surface);
    color: var(--fg);
    border-color: var(--line);
}

.btn-icon svg { width: 18px; height: 18px; }

.sidebar-sessions {
    flex: 1;
    overflow-y: auto;
    padding: 14px 10px;
}

.sidebar-sessions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px 10px;
}

.sidebar-sessions h3 {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--faint);
}

.btn-clear-sessions {
    background: none;
    border: none;
    color: var(--faint);
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    transition: all var(--transition);
    display: flex;
    align-items: center;
}

.btn-clear-sessions svg { width: 14px; height: 14px; }

.btn-clear-sessions:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

#sessions-list { list-style: none; }

#sessions-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.84rem;
    color: var(--muted);
    transition: all var(--transition);
}

#sessions-list li span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#sessions-list li .btn-delete-session {
    display: none;
    background: none;
    border: none;
    color: var(--faint);
    cursor: pointer;
    padding: 3px;
    border-radius: 5px;
    flex-shrink: 0;
    transition: all var(--transition);
}

#sessions-list li .btn-delete-session svg { width: 14px; height: 14px; }
#sessions-list li:hover .btn-delete-session { display: flex; }

#sessions-list li .btn-delete-session:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

#sessions-list li:hover {
    background: var(--surface);
    color: var(--fg);
}

#sessions-list li.active {
    background: var(--surface);
    border-color: var(--line);
    color: var(--fg);
}

#sessions-list li svg {
    width: 16px; height: 16px;
    min-width: 16px;
    opacity: 0.55;
}

.sidebar-footer {
    padding: 14px 10px;
    border-top: 1px solid var(--line-soft);
}

.btn-logout,
.btn-portal-back {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-portal-back { margin-bottom: 4px; }

.btn-portal-back:hover {
    background: var(--surface);
    color: var(--fg);
}

.btn-logout:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.btn-logout svg,
.btn-portal-back svg { width: 18px; height: 18px; }

/* ── Chat Main ────────────────────────────────────── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh; height: 100dvh;
    min-width: 0;
    background: var(--bg);
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 28px;
    border-bottom: 1px solid var(--line-soft);
    background: oklch(0.145 0.012 255 / 0.72);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
}

.header-info h2 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.db-badges {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.db-badge {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: var(--r-pill);
    background: var(--acc-soft);
    border: 1px solid var(--line-soft);
    color: var(--acc-deep);
}

/* ── Seletor de bancos ────────────────────────────── */
.db-selector {
    position: relative;
    margin-left: auto;
}

.db-selector-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    height: 38px;
    padding: 0 14px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-pill);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: all var(--transition);
    max-width: 240px;
}

.db-selector-btn:hover { border-color: var(--line); color: var(--fg); }
.db-selector-btn.open { border-color: var(--acc); color: var(--fg); }
.db-selector.filtered .db-selector-btn { border-color: var(--acc); color: var(--fg); }

.db-selector-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.db-selector-btn #db-selector-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.db-selector-btn .db-chevron { width: 13px; height: 13px; opacity: 0.7; transition: transform var(--transition); }
.db-selector-btn.open .db-chevron { transform: rotate(180deg); }

.db-selector-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 300px;
    max-width: 78vw;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-panel);
    z-index: 120;
    padding: 12px;
    animation: fadeIn 0.14s var(--ease);
}

.db-selector-search {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.db-selector-search svg {
    position: absolute;
    left: 12px;
    width: 15px; height: 15px;
    color: var(--faint);
    pointer-events: none;
}

.db-selector-search input {
    width: 100%;
    height: 40px;
    padding: 0 12px 0 36px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-family: var(--font-body);
    font-size: 0.86rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.db-selector-search input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-glow); }
.db-selector-search input::placeholder { color: var(--faint); }

.db-selector-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 2px 4px 10px;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 8px;
}

.db-action-link {
    background: none;
    border: none;
    color: var(--acc-deep);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 0;
    transition: color var(--transition);
}
.db-action-link:hover { color: var(--fg); text-decoration: underline; }

.db-count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    color: var(--faint);
}

.db-list {
    list-style: none;
    max-height: 280px;
    overflow-y: auto;
    margin: 0 -4px;
}

.db-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.db-item:hover { background: var(--surface); }

.db-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px; height: 16px;
    min-width: 16px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--bg);
    cursor: pointer;
    position: relative;
    transition: all var(--transition);
}
.db-item input[type="checkbox"]:checked {
    background: var(--acc);
    border-color: var(--acc);
}
.db-item input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px; top: 2px;
    width: 4px; height: 8px;
    border: solid var(--on-acc);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.db-item label {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--fg);
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.db-empty {
    padding: 16px 10px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--faint);
}

@media (max-width: 768px) {
    .db-selector-btn { max-width: 150px; }
    .db-selector-btn #db-selector-label { display: none; }
}

/* ── Messages Container ───────────────────────────── */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;        /* nada de scroll horizontal na conversa */
    padding: 28px 0;
    scroll-behavior: smooth;
}

/* ── Empty State ──────────────────────────────────── */
.empty-state {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px 20px;
    overflow: hidden;
    animation: fadeIn 0.6s var(--ease);
}

.empty-state > :not(.mesh) { position: relative; z-index: 3; }

.empty-icon {
    margin-bottom: 22px;
}

.empty-state h3 {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 0.95rem;
    color: var(--muted);
    margin-bottom: 32px;
    max-width: 44ch;
}

.suggestions {
    position: relative;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    max-width: 640px;
}

.suggestion-chip {
    padding: 11px 20px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-pill);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all var(--transition);
}

.suggestion-chip:hover {
    border-color: var(--acc);
    color: var(--fg);
    background: var(--surface-2);
    transform: translateY(-2px);
}

/* ── Messages ─────────────────────────────────────── */
.message {
    padding: 12px 28px;
    animation: fadeIn 0.3s var(--ease);
}

.message-row {
    display: flex;
    gap: 16px;
    max-width: 820px;
    margin: 0 auto;
}

.message-avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    margin-top: 2px;
    overflow: hidden;
    position: relative;
}

.message.user .message-avatar {
    background: var(--acc);
    color: var(--on-acc);
}

.message.assistant .message-avatar {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--fg);
}

/* brand "scan" sweep behind the assistant mark */
.message.assistant .message-avatar::after {
    content: "";
    position: absolute;
    left: 5px; right: 5px;
    height: 1.5px;
    background: var(--acc);
    box-shadow: 0 0 8px var(--acc);
    opacity: 0.5;
    animation: scanAvatar 2.8s var(--ease) infinite;
}

@keyframes scanAvatar {
    0%, 100% { top: 7px; opacity: 0.25; }
    50%      { top: 25px; opacity: 0.7; }
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-content .role-label {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    margin-bottom: 6px;
    color: var(--faint);
}

.message-content .msg-body {
    font-size: 0.95rem;
    line-height: 1.72;
    color: var(--fg);
    overflow-wrap: break-word;     /* quebra só palavras/URLs longas quando preciso */
    min-width: 0;
}

.message.user .msg-body { color: var(--muted); }

/* Markdown styling inside messages */
.msg-body p { margin-bottom: 11px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body strong { color: var(--fg); font-weight: 600; }
.msg-body ul, .msg-body ol { padding-left: 22px; margin-bottom: 11px; }
.msg-body li { margin-bottom: 5px; }
.msg-body a { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
.msg-body code {
    background: var(--acc-soft);
    border: 1px solid var(--line-soft);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.84em;
    font-family: var(--font-mono);
    color: var(--fg);
}
.msg-body pre {
    background: var(--bg-2);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}
.msg-body pre code {
    background: none;
    border: none;
    padding: 0;
    color: var(--fg);
}
.msg-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    font-size: 0.84rem;
    font-variant-numeric: tabular-nums;
    display: block;            /* tabela larga rola dentro de si, sem empurrar a conversa */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
.msg-body table th,
.msg-body table td {
    border: 1px solid var(--line-soft);
    padding: 9px 13px;
    text-align: left;
}
.msg-body table th {
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
.msg-body table tr:hover { background: var(--surface); }

/* ── Typing indicator ─────────────────────────────── */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--faint);
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30%           { opacity: 1; transform: translateY(-4px); }
}

/* ── Bloco "pensando" com frase rotativa ──────────── */
.thinking-block {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.thinking-phrase {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    color: var(--faint);
    opacity: 1;
    transition: opacity 0.18s ease;
    animation: thinking-pulse 2.4s ease-in-out infinite;
}

.thinking-phrase.fading { opacity: 0; animation: none; }

@keyframes thinking-pulse {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 1; }
}

/* ── Chat Input ───────────────────────────────────── */
.chat-input-area {
    padding: 18px 28px 22px;
    border-top: 1px solid var(--line-soft);
    background: var(--bg);
}

.chat-form {
    max-width: 820px;
    margin: 0 auto;
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 10px 10px 20px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-container:focus-within {
    border-color: var(--acc);
    box-shadow: 0 0 0 3px var(--acc-glow);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--fg);
    font-size: 0.95rem;
    font-family: var(--font-body);
    line-height: 22px;
    resize: none;
    min-height: 40px;
    max-height: 200px;
    padding: 9px 0;
    outline: none;
    box-sizing: border-box;
    display: block;
}

#chat-input::placeholder { color: var(--faint); }

.btn-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--acc);
    border: none;
    border-radius: var(--r-pill);
    color: var(--on-acc);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-send:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-cta);
}
.btn-send:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-send svg { width: 18px; height: 18px; }

.input-hint {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.06em;
    color: var(--faint);
    margin-top: 10px;
    text-align: center;
}

.input-hint strong { color: var(--muted); font-weight: 600; }

/* ═══════════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--surface-2); background-clip: padding-box; }

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */
.mobile-only { display: none; }

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 40px oklch(0 0 0 / 0.6);
    }

    .mobile-only { display: flex; }

    .login-card { padding: 40px 26px; }

    .message { padding: 10px 16px; }
    .chat-header { padding: 14px 16px; }
    .chat-input-area { padding: 14px 16px 18px; }
}

/* ═══════════════════════════════════════════════════
   OVERLAY (mobile sidebar)
   ═══════════════════════════════════════════════════ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: oklch(0 0 0 / 0.55);
    backdrop-filter: blur(2px);
    z-index: 99;
}

.sidebar-overlay.active { display: block; }

/* ═══════════════════════════════════════════════════
   MÓDULO USUÁRIOS
   ═══════════════════════════════════════════════════ */
.users-layout {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.users-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    border-bottom: 1px solid var(--line-soft);
}

.users-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.users-header h1 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.btn-sm {
    width: auto;
    height: 42px;
    padding: 0 22px;
    font-size: 0.72rem;
    gap: 8px;
    margin-top: 0;
}

.btn-sm svg { width: 16px; height: 16px; }

.users-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
}

.users-table-wrapper {
    max-width: 960px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    overflow-x: auto;          /* tabela larga rola na horizontal (não corta) */
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.users-table thead th {
    text-align: left;
    padding: 14px 18px;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--faint);
    background: var(--bg-2);
    border-bottom: 1px solid var(--line-soft);
}

.th-actions { text-align: right; }

.users-table tbody tr {
    border-bottom: 1px solid var(--line-soft);
    transition: background var(--transition);
}

.users-table tbody tr:last-child { border-bottom: none; }
.users-table tbody tr:hover { background: var(--surface-2); }

.users-table tbody td {
    padding: 15px 18px;
    color: var(--fg);
}

.users-table tbody td:last-child { text-align: right; }

.role-tag {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 4px 11px;
    border-radius: var(--r-pill);
    border: 1px solid var(--line-soft);
}

.role-tag.superAdmin {
    background: var(--acc);
    border-color: var(--acc);
    color: var(--on-acc);
}

.role-tag.admin {
    background: var(--acc-soft);
    color: var(--fg);
}

.role-tag.basicUser {
    background: transparent;
    color: var(--faint);
}

.action-btns {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.btn-action {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    color: var(--muted);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-action svg { width: 15px; height: 15px; }

.btn-action:hover {
    background: var(--surface-2);
    color: var(--fg);
    border-color: var(--line);
}

.btn-action.danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: oklch(0.68 0.18 22 / 0.35);
}

.users-empty, .users-loading {
    text-align: center;
    padding: 56px 20px;
    color: var(--faint);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ═══════════════════════════════════════════════════
   MODAIS
   ═══════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: oklch(0 0 0 / 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    animation: fadeIn 0.18s var(--ease);
}

.modal-card {
    width: 100%;
    max-width: 500px;
    background: linear-gradient(180deg, var(--surface), var(--bg-2));
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 30px 34px;
    box-shadow: var(--shadow-panel);
}

.modal-card-sm { max-width: 420px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 26px;
}

.modal-header h2 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.modal-body-text {
    font-size: 0.92rem;
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 22px;
}

.modal-body-text strong { color: var(--fg); }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 26px;
}

.btn-secondary {
    height: 42px;
    padding: 0 22px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-secondary:hover {
    background: var(--surface-2);
    color: var(--fg);
    border-color: var(--line);
}

.btn-danger {
    height: 42px;
    padding: 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--danger);
    border: 1px solid var(--danger);
    border-radius: var(--r-pill);
    color: oklch(0.16 0.02 22);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 12px 30px -14px var(--danger); }

.select-field {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-size: 0.95rem;
    font-family: var(--font-body);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8a9a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}

.select-field:focus {
    border-color: var(--acc);
    box-shadow: 0 0 0 3px var(--acc-glow);
}

@media (max-width: 768px) {
    .users-header { padding: 14px 16px; }
    .users-content { padding: 16px; }
    .users-table { font-size: 0.84rem; }
    .users-table thead th, .users-table tbody td { padding: 11px 10px; }
    .modal-card { padding: 26px 22px; }
}

/* ═══════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .scanline,
    .message.assistant .message-avatar::after,
    .thinking-phrase { animation: none; }
    * { scroll-behavior: auto; }
}

/* ═══════════════════════════════════════════════════
   GRÁFICOS IN-CHAT + LINKS DE ARTEFATO
   ═══════════════════════════════════════════════════ */
.nexus-chart {
    margin: 14px 0;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    height: 320px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
}
.nexus-chart canvas { max-width: 100%; }
.nexus-chart-title {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--faint);
    margin-bottom: 12px;
}
.nexus-chart canvas { flex: 1; min-height: 0; }

.artifact-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    margin: 2px 0;
    max-width: 100%;
    background: var(--acc);
    color: var(--on-acc) !important;
    border-radius: var(--r-pill);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-decoration: none !important;
    transition: transform var(--transition), box-shadow var(--transition);
}
/* nome do arquivo: trunca com reticências, ícone permanece fixo */
.artifact-link .al-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.artifact-link::before {
    content: "";
    flex-shrink: 0;
    width: 14px; height: 14px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E") center/contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E") center/contain no-repeat;
}
.artifact-link:hover { transform: translateY(-1px); box-shadow: var(--shadow-cta); }

/* ═══════════════════════════════════════════════════
   MÓDULO DASHBOARDS
   ═══════════════════════════════════════════════════ */
.dash-layout { width: 100%; height: 100%; display: flex; flex-direction: column; background: var(--bg); }
.dash-view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.dash-view.hidden { display: none; }

.dash-detail-actions { display: flex; align-items: center; gap: 8px; }

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.dash-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    color: var(--fg);
    font-family: var(--font-body);
    transition: transform var(--transition), border-color var(--transition), background var(--transition);
}
.dash-card:hover { transform: translateY(-4px); border-color: var(--acc); background: var(--surface-2); }
.dash-card-icon {
    width: 46px; height: 46px; min-width: 46px;
    display: flex; align-items: center; justify-content: center;
    background: var(--acc-soft); border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm); color: var(--fg);
}
.dash-card-icon svg { width: 22px; height: 22px; }
.dash-card-info h3 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 5px; }

.widgets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    max-width: 1240px;
    margin: 0 auto;
    width: 100%;
}

.widget-card {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}
.widget-kpi-card { min-height: 150px; }

.widget-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.widget-titles h4 { font-family: var(--font-display); font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 4px; }
.widget-actions { display: flex; gap: 6px; flex-shrink: 0; }
.widget-actions .btn-action { width: 30px; height: 30px; }
.widget-actions .btn-action svg { width: 13px; height: 13px; }

.widget-body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.widget-card:not(.widget-kpi-card) .widget-body { min-height: 220px; }
.widget-body canvas { flex: 1; min-height: 0; }

.widget-loading { flex: 1; display: flex; align-items: center; justify-content: center; }
.widget-error {
    flex: 1; display: flex; align-items: center; justify-content: center;
    text-align: center; padding: 12px;
    color: var(--danger); font-size: 0.82rem; font-family: var(--font-mono);
}

.widget-kpi { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.widget-kpi-value { font-family: var(--font-display); font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 600; letter-spacing: -0.03em; color: var(--fg); }
.widget-kpi-label { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); }

.widget-table-wrap { overflow: auto; max-height: 260px; }
.widget-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.widget-table th, .widget-table td { border: 1px solid var(--line-soft); padding: 6px 9px; text-align: left; white-space: nowrap; }
.widget-table th { background: var(--bg-2); font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); position: sticky; top: 0; }

/* Modal de widget */
.widget-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.sql-area {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.5;
    padding: 12px 14px;
    outline: none;
    resize: vertical;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.sql-area:focus { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-glow); }
.sql-hint { display: block; margin-top: 7px; font-family: var(--font-mono); font-size: 0.64rem; color: var(--faint); }
.widget-preview {
    margin-top: 14px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    padding: 14px;
    min-height: 120px;
    max-height: 300px;
    overflow: auto;
}
.widget-preview canvas { max-height: 240px; }

@media (max-width: 768px) {
    .widget-form-row { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════
   WIZARD DE BANCOS (nova conversa)
   ═══════════════════════════════════════════════════ */
.db-mode { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }

.db-mode-opt {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    text-align: left;
    padding: 16px 18px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    font-family: var(--font-body);
    color: var(--fg);
}
.db-mode-opt:hover { border-color: var(--line); background: var(--surface); }
.db-mode-opt.active { border-color: var(--acc); background: var(--surface); }

.db-mode-check {
    width: 20px; height: 20px; min-width: 20px;
    margin-top: 2px;
    border: 1px solid var(--line);
    border-radius: 50%;
    position: relative;
    transition: all var(--transition);
}
.db-mode-opt.active .db-mode-check { border-color: var(--acc); }
.db-mode-opt.active .db-mode-check::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: var(--acc);
}

.db-mode-text { display: flex; flex-direction: column; gap: 4px; }
.db-mode-title { font-family: var(--font-display); font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.db-mode-desc { font-size: 0.82rem; color: var(--muted); line-height: 1.45; }

.db-wizard-picker {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line-soft);
}
.db-wizard-picker .db-list {
    max-height: 240px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    padding: 4px;
}

/* ═══════════════════════════════════════════════════
   DASHBOARD DE USO & CUSTOS
   ═══════════════════════════════════════════════════ */
#usage-content { max-width: 1240px; margin: 0 auto; width: 100%; transition: opacity .2s ease; }

.usage-period-select { width: auto; height: 38px; padding: 0 36px 0 14px; font-size: 0.8rem; }

.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}
.kpi-card {
    background: linear-gradient(180deg, var(--surface), var(--bg-2));
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.kpi-value { font-family: var(--font-display); font-size: clamp(1.8rem, 3.5vw, 2.6rem); font-weight: 600; letter-spacing: -0.03em; color: var(--fg); line-height: 1; }
.kpi-label { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); }

.usage-grid { max-width: none; margin-bottom: 18px; }
.usage-grid .widget-card { min-height: 260px; }
.usage-grid .widget-body { min-height: 200px; }

.usage-recent { margin-top: 6px; }
.usage-recent-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}
.usage-recent .users-table-wrapper { max-width: none; }
.usage-recent .users-table td { font-variant-numeric: tabular-nums; }

/* Tabelas (usuários / uso recente): em telas estreitas, rolam na horizontal
   com largura mínima legível em vez de espremer/cortar colunas. */
@media (max-width: 760px) {
    .users-table { min-width: 520px; }
    .users-table thead th, .users-table tbody td { padding: 12px 12px; }
    .usage-recent .users-table { min-width: 660px; }
}
