/* ==========================================================================
   Tokens — cores do Brik CRM (lemeai-platform/src/index.css), aplicadas aos
   componentes no estilo shadcn/ui. Escuro é o padrão; claro com a classe .light.
   ========================================================================== */

:root {
    /* Escuro (padrão) — mesmos valores do [data-theme='dark'] do CRM */
    --background: #101114;
    --foreground: #e3e5ea;
    --card: #16171a;
    --popover: #1d1f24;
    --primary: #406eb3;
    --primary-hover: #5580c0;
    --primary-soft: rgba(64, 110, 179, 0.16);
    --primary-foreground: #ffffff;
    --tab-active-bg: #235294;
    --tab-active-ink: #ffffff;
    --secondary: #1e2126;
    --secondary-foreground: #e3e5ea;
    --muted: #1e2126;
    --muted-foreground: #9aa0a8;
    --subtle-foreground: #6b7078;
    --accent: #1e2126;
    --accent-foreground: #e3e5ea;
    --destructive: #e5645f;
    --border: #282b31;
    --input: #282b31;
    --field: #1d1f24;
    --ring: #406eb3;
    --sidebar: #121316;
    --sidebar-accent: #1a1c20;

    --log-bg: #0d0e10;
    --log-fg: #d5d8de;
    --log-dim: #6b7078;
    --log-hover: #15161a;
    --lvl-error: #e5645f;
    --lvl-error-bg: rgba(229, 100, 95, 0.07);
    --lvl-warn: #e0a04a;
    --lvl-info: #6293db;
    --lvl-debug: #6b7078;
    --mark: rgba(224, 160, 74, 0.35);

    --radius: 0.625rem;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.625rem;
    --radius-xl: 0.875rem;

    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);

    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "SF Mono", "JetBrains Mono", Consolas, monospace;

    color-scheme: dark;
}

.light {
    /* Claro — mesmos valores do :root do CRM */
    --background: #f8fafc;
    --foreground: #0f172a;
    --card: #ffffff;
    --popover: #ffffff;
    --primary: #00275e;
    --primary-hover: #001a40;
    --primary-soft: rgba(0, 39, 94, 0.08);
    --primary-foreground: #ffffff;
    --secondary: #f1f5f9;
    --secondary-foreground: #0f172a;
    --muted: #f1f5f9;
    --muted-foreground: #475569;
    --subtle-foreground: #94a3b8;
    --accent: #f1f5f9;
    --accent-foreground: #0f172a;
    --destructive: #ef4444;
    --border: #e2e8f0;
    --input: #e2e8f0;
    --field: #ffffff;
    --ring: #235294;
    --sidebar: #fbfbfa;
    --sidebar-accent: #f5f5f3;

    --log-bg: #ffffff;
    --log-fg: #1e293b;
    --log-dim: #94a3b8;
    --log-hover: #f8fafc;
    --lvl-error: #dc2626;
    --lvl-error-bg: rgba(239, 68, 68, 0.06);
    --lvl-warn: #d97706;
    --lvl-info: #2563eb;
    --lvl-debug: #94a3b8;
    --mark: #fde68a;

    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);

    color-scheme: light;
}

/* ==========================================================================
   Base
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
    border-color: var(--border);
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.5;
    background: var(--background);
    color: var(--foreground);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "rlig" 1, "calt" 1;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

a {
    color: inherit;
}

code, pre, kbd {
    font-family: var(--font-mono);
}

h1:focus {
    outline: none;
}

:focus-visible {
    outline: none;
}

.icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.icon-sm {
    width: 0.875rem;
    height: 0.875rem;
}

.spin {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.muted {
    color: var(--muted-foreground);
}

.tabular {
    font-variant-numeric: tabular-nums;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border: 2px solid transparent;
    background-clip: content-box;
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--ring);
}

/* ==========================================================================
   Componentes (equivalentes aos do shadcn/ui)
   ========================================================================== */

/* Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 2.25rem;
    padding: 0 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    background: transparent;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
    user-select: none;
}

.btn:focus-visible {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 35%, transparent);
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
    box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-outline {
    background: var(--background);
    border-color: var(--border);
    box-shadow: var(--shadow-xs);
}

.btn-outline {
    background: var(--field);
}

.btn-outline:hover,
.btn-ghost:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

.btn.is-active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--foreground);
}



.btn-secondary {
    background: var(--secondary);
    color: var(--secondary-foreground);
}

.btn-secondary:hover {
    background: color-mix(in srgb, var(--secondary) 80%, var(--foreground) 6%);
}

.btn-sm {
    height: 2rem;
    padding: 0 0.75rem;
    gap: 0.375rem;
    font-size: 0.8125rem;
}

.btn-xs {
    height: 1.5rem;
    padding: 0 0.5rem;
    gap: 0.25rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    width: 2.25rem;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 2rem;
}

.btn-block {
    width: 100%;
}

/* Input / Select */
.input {
    display: flex;
    width: 100%;
    height: 2.25rem;
    padding: 0 0.75rem;
    border: 1px solid var(--input);
    border-radius: var(--radius-md);
    background: transparent;
    font-size: 0.875rem;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.15s, box-shadow 0.15s;
    min-width: 0;
}

.input {
    background: var(--field);
}

.input::placeholder {
    color: var(--muted-foreground);
}

.input:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 35%, transparent);
}

.input[aria-invalid="true"] {
    border-color: var(--destructive);
}

.input-sm {
    height: 2rem;
    font-size: 0.8125rem;
}

select.input {
    appearance: none;
    padding-right: 2rem;
    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='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    cursor: pointer;
}

select.input option {
    background: var(--popover);
    color: var(--foreground);
}

/* Input com ícone à esquerda */
.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group > .icon {
    position: absolute;
    left: 0.625rem;
    color: var(--muted-foreground);
    pointer-events: none;
}

.input-group > .input {
    padding-left: 2rem;
}

.input[type="search"]::-webkit-search-cancel-button {
    appearance: none;
}

/* Label */
.label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    user-select: none;
}

/* Checkbox */
.checkbox {
    appearance: none;
    width: 1rem;
    height: 1rem;
    margin: 0;
    flex-shrink: 0;
    border: 1px solid var(--input);
    border-radius: 4px;
    background: transparent;
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    display: grid;
    place-content: center;
}

.checkbox {
    background: var(--field);
}

.checkbox:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox:checked::after {
    content: "";
    width: 0.65rem;
    height: 0.65rem;
    background: var(--primary-foreground);
    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='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}

.checkbox:focus-visible {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 35%, transparent);
}

/* Switch */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-track {
    position: relative;
    width: 2rem;
    height: 1.15rem;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--input);
    box-shadow: var(--shadow-xs);
    transition: background-color 0.15s;
}



.switch-thumb {
    position: absolute;
    top: 50%;
    left: 1px;
    width: 1rem;
    height: 1rem;
    border-radius: 999px;
    background: var(--muted-foreground);
    transform: translateY(-50%);
    transition: transform 0.15s;
}



.switch input:checked + .switch-track {
    background: var(--primary);
}

.switch input:checked + .switch-track .switch-thumb {
    transform: translate(calc(2rem - 1rem - 3px), -50%);
}

.switch input:checked + .switch-track .switch-thumb {
    background: var(--primary-foreground);
}

.switch input:focus-visible + .switch-track {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 35%, transparent);
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.1rem;
    white-space: nowrap;
}

.badge-outline {
    border-color: var(--border);
}

.badge-secondary {
    background: var(--secondary);
    color: var(--secondary-foreground);
}

.badge-count {
    min-width: 1.25rem;
    justify-content: center;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--secondary);
    color: var(--muted-foreground);
    font-variant-numeric: tabular-nums;
    font-size: 0.7rem;
    line-height: 1.1rem;
}

.badge .badge-close {
    display: inline-flex;
    padding: 0;
    margin-right: -0.2rem;
    border: none;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
}

.badge .badge-close:hover {
    color: var(--foreground);
}

/* Tabs */
.tabs-list {
    display: flex;
    width: 100%;
    height: 2.25rem;
    padding: 3px;
    border-radius: var(--radius-lg);
    background: var(--muted);
    color: var(--muted-foreground);
}

.tabs-trigger {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0 0.5rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s;
}

.tabs-trigger:hover {
    color: var(--foreground);
}

.tabs-trigger[aria-selected="true"] {
    background: var(--tab-active-bg);
    color: var(--tab-active-ink);
    box-shadow: var(--shadow-sm);
}

/* Separator */
.separator-v {
    width: 1px;
    height: 1rem;
    flex-shrink: 0;
    background: var(--border);
}

/* Card */
.card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--card);
    box-shadow: var(--shadow-sm);
}

.card-header,
.card-content {
    padding: 0 1.5rem;
}

.card-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.card-description {
    margin: 0.375rem 0 0;
    color: var(--muted-foreground);
}

/* Alert */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card);
    font-size: 0.875rem;
}

.alert > .icon {
    margin-top: 0.125rem;
}

.alert-destructive {
    color: var(--destructive);
    border-color: color-mix(in srgb, var(--destructive) 40%, transparent);
}

/* Dialog */
.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgb(0 0 0 / 0.5);
    animation: fade-in 0.15s ease-out;
}

.dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: min(40rem, 100%);
    max-height: 80vh;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--background);
    box-shadow: var(--shadow-lg);
    animation: zoom-in 0.15s ease-out;
}

.dialog-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1;
}

.dialog-description {
    margin: 0.5rem 0 0;
    color: var(--muted-foreground);
}

.dialog-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: inline-flex;
    padding: 0.125rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted-foreground);
    opacity: 0.7;
    cursor: pointer;
}

.dialog-close:hover {
    opacity: 1;
    color: var(--foreground);
}

.dialog-body {
    overflow-y: auto;
    margin: 0 -1.5rem;
    padding: 0 1.5rem;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
}

@keyframes zoom-in {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
}

@keyframes slide-in-right {
    from {
        transform: translateX(100%);
    }
}

/* ==========================================================================
   Login
   ========================================================================== */

.login-page {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--background);
}

.light .login-page {
    background: var(--muted);
}

.login-wrapper {
    display: flex;
    width: 100%;
    max-width: 24rem;
    flex-direction: column;
    gap: 1.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.login-wrapper > .brand {
    align-self: center;
}

.brand-logo {
    display: block;
    height: 1.5rem;
    width: auto;
}

.brand-logo-light {
    display: none;
}

.light .brand-logo-light {
    display: block;
}

.light .brand-logo-dark {
    display: none;
}

.brand-mark {
    display: flex;
    width: 1.5rem;
    height: 1.5rem;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: var(--primary-foreground);
}

.brand-mark .icon {
    width: 0.875rem;
    height: 0.875rem;
}

.login-form {
    display: grid;
    gap: 1.25rem;
}

.field {
    display: grid;
    gap: 0.5rem;
}

.login-footnote {
    margin: 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

/* ==========================================================================
   App: sidebar + área principal
   ========================================================================== */

.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    display: flex;
    width: 16rem;
    flex-shrink: 0;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--sidebar);
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.25rem;
}

.sidebar-brand .brand-mark {
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-lg);
}

.sidebar-brand .brand-mark .icon {
    width: 1rem;
    height: 1rem;
}

.sidebar-brand-text {
    display: grid;
    line-height: 1.25;
}

.sidebar-brand-text strong {
    font-weight: 600;
}

.sidebar-brand-text span {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.env-dot {
    width: 0.5rem;
    height: 0.5rem;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--env-color, var(--muted-foreground));
}

.sidebar-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 0.5rem 0.5rem;
}

.sidebar-group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground);
}

.file-menu {
    display: grid;
    gap: 1px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.file-item {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.1s;
}

.file-item:hover {
    background: var(--sidebar-accent);
}

.file-item[aria-current="true"] {
    background: var(--tab-active-bg);
    color: var(--tab-active-ink);
    font-weight: 500;
}

.file-item[aria-current="true"] .icon,
.file-item[aria-current="true"] .file-item-meta {
    color: rgba(255, 255, 255, 0.75);
}

.file-item .icon {
    color: var(--muted-foreground);
}

.file-item-text {
    display: grid;
    min-width: 0;
    flex: 1;
    line-height: 1.3;
}

.file-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8125rem;
}

.file-item-meta {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--muted-foreground);
    font-variant-numeric: tabular-nums;
}

.sidebar-empty {
    padding: 1rem 0.5rem;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border);
}

.avatar {
    display: flex;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.sidebar-user {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.sidebar-footer form {
    display: contents;
}

.theme-icon-light {
    display: none;
}

.light .theme-icon-light {
    display: block;
}

.light .theme-icon-dark {
    display: none;
}

/* Área principal */
.main {
    position: relative;
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    background: var(--background);
}

.page-header {
    display: flex;
    height: 3.5rem;
    flex-shrink: 0;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border);
}

.breadcrumb {
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: center;
    gap: 0.375rem;
    color: var(--muted-foreground);
}

.breadcrumb .icon {
    width: 0.875rem;
    height: 0.875rem;
}

.breadcrumb-env {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.breadcrumb-page {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--foreground);
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar {
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border);
}

.toolbar .input-group {
    width: 18rem;
}

.toolbar-spacer {
    flex: 1;
}

.toggle-group {
    display: inline-flex;
    gap: 0.25rem;
}

.toggle-group .btn .dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 999px;
    background: currentColor;
}

.toggle-error .dot {
    color: var(--lvl-error);
}

.toggle-warn .dot {
    color: var(--lvl-warn);
}

.toggle-timeout .dot {
    color: var(--lvl-info);
}

.subbar {
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--muted) 50%, transparent);
    font-size: 0.8125rem;
}

.subbar .warning {
    color: var(--lvl-warn);
}

.notice-bar {
    padding: 0.75rem 1rem 0;
}

.notice-bar .alert {
    align-items: center;
}

.notice-bar .alert span {
    flex: 1;
}

.empty-state {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    text-align: center;
    color: var(--muted-foreground);
}

.empty-state .icon {
    width: 1.5rem;
    height: 1.5rem;
    margin-bottom: 0.25rem;
}

.empty-state strong {
    color: var(--foreground);
    font-weight: 500;
}

/* ==========================================================================
   Conteúdo do log
   ========================================================================== */

.log-content-wrap {
    position: relative;
    display: flex;
    min-height: 0;
    flex: 1;
}

.log-content {
    flex: 1;
    overflow: auto;
    padding: 0.375rem 0;
    background: var(--log-bg);
    color: var(--log-fg);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.log-empty {
    padding: 2rem 1rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--muted-foreground);
    text-align: center;
}

.log-entry {
    border-left: 2px solid transparent;
}

.log-entry:hover {
    background: var(--log-hover);
}

.entry-line {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    height: 22px;
    padding: 0 1rem 0 0.375rem;
    line-height: 22px;
    white-space: pre;
    overflow: hidden;
}

.log-content.wrap .entry-line,
.log-entry.expanded .entry-line {
    height: auto;
    overflow: visible;
    white-space: pre-wrap;
    word-break: break-all;
}

.expand-toggle {
    display: inline-flex;
    align-self: center;
    flex-shrink: 0;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--log-dim);
    cursor: pointer;
    opacity: 0;
}

.log-entry:hover .expand-toggle,
.log-entry.expanded .expand-toggle,
.expand-toggle:focus-visible {
    opacity: 1;
}

.expand-toggle:hover {
    color: var(--foreground);
}

.ts {
    flex-shrink: 0;
    color: var(--log-dim);
    font-variant-numeric: tabular-nums;
}

.lvl {
    width: 2.75rem;
    flex-shrink: 0;
    font-weight: 500;
    color: var(--log-dim);
}

.logger {
    max-width: 14rem;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--muted-foreground);
}

.req-id {
    flex-shrink: 0;
    padding: 0 0.25rem;
    margin: 0 -0.25rem;
    border-radius: var(--radius-sm);
    color: var(--muted-foreground);
    cursor: pointer;
}

.req-id:hover {
    color: var(--foreground);
    background: var(--accent);
}

.req-id.active {
    color: var(--primary-foreground);
    background: var(--primary);
}

.msg {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-content.wrap .msg,
.log-entry.expanded .msg {
    overflow: visible;
}

.more-count {
    flex-shrink: 0;
    padding: 0 0.375rem;
    border-radius: var(--radius-sm);
    background: var(--muted);
    color: var(--muted-foreground);
    font-size: 0.6875rem;
    line-height: 1.1rem;
}

.level-error {
    background: var(--lvl-error-bg);
    border-left-color: var(--lvl-error);
}

.level-error .lvl {
    color: var(--lvl-error);
}

.level-warn .lvl {
    color: var(--lvl-warn);
}

.level-info .lvl {
    color: var(--lvl-info);
}

.level-debug .lvl,
.level-debug .msg,
.level-orphan .msg {
    color: var(--lvl-debug);
}

.log-entry.expanded {
    background: color-mix(in srgb, var(--muted) 45%, var(--log-bg));
}

.entry-detail {
    padding: 0.25rem 1rem 0.75rem 1.75rem;
}

.entry-actions {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
    font-family: var(--font-sans);
}

.entry-full {
    max-height: 60vh;
    margin: 0;
    padding: 0.75rem;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--log-bg);
    color: var(--log-fg);
    font-size: inherit;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-entry.flash {
    animation: flash 1.6s ease-out;
}

@keyframes flash {
    0%, 30% {
        background: var(--mark);
    }
}

.jump-bottom {
    position: absolute;
    right: 1.25rem;
    bottom: 1.25rem;
    box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   Sheet de busca
   ========================================================================== */

.sheet {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    width: min(28rem, 100%);
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--background);
    box-shadow: var(--shadow-lg);
    animation: slide-in-right 0.2s ease-out;
}

.sheet-header {
    position: relative;
    padding: 1rem 1rem 0.75rem;
}

.sheet-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.sheet-description {
    margin: 0.25rem 2rem 0 0;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

.search-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    padding: 0 1rem 1rem;
    border-bottom: 1px solid var(--border);
}

.search-form .input-group {
    grid-column: 1 / -1;
}

.search-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.5rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

.search-results {
    flex: 1;
    overflow-y: auto;
}

.search-file {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--background);
    font-size: 0.75rem;
    font-weight: 500;
}

.search-hit {
    display: grid;
    width: 100%;
    gap: 0.125rem;
    padding: 0.5rem 1rem;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.search-hit:hover {
    background: var(--accent);
}

.search-hit[aria-current="true"] {
    background: var(--accent);
    box-shadow: inset 2px 0 0 var(--foreground);
}

.hit-line {
    font-size: 0.7rem;
    color: var(--muted-foreground);
    font-variant-numeric: tabular-nums;
}

.hit-preview {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    word-break: break-all;
}

mark {
    border-radius: 2px;
    background: var(--mark);
    color: inherit;
}

/* Erros frequentes */
.top-errors {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
}

.top-errors li {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.top-errors li:last-child {
    border-bottom: none;
}

.top-errors .count {
    min-width: 2.5rem;
    flex-shrink: 0;
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.top-errors .message {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    word-break: break-all;
    color: var(--muted-foreground);
}

/* Páginas simples (404 / erro) */
.simple-page {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem;
    text-align: center;
}

.simple-page h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.simple-page p {
    max-width: 32rem;
    margin: 0;
    color: var(--muted-foreground);
}

/* ==========================================================================
   Blazor
   ========================================================================== */

#blazor-error-ui {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid color-mix(in srgb, var(--destructive) 40%, transparent);
    border-radius: var(--radius-lg);
    background: var(--background);
    color: var(--destructive);
    box-shadow: var(--shadow-lg);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
}

.blazor-error-boundary {
    padding: 1rem;
    border: 1px solid var(--destructive);
    border-radius: var(--radius-lg);
    color: var(--destructive);
}

.blazor-error-boundary::after {
    content: "Ocorreu um erro.";
}

@media (max-width: 900px) {
    .sidebar {
        width: 13rem;
    }

    .toolbar .input-group {
        width: 100%;
    }
}
