/* ═══════════════════════════════════════════════════════════════
   VisioHub — Design System
   ═══════════════════════════════════════════════════════════════ */

:root {
    --brand-primary: #2563eb;
    --brand-secondary: #0f172a;
    --brand-accent: #8b5cf6;
    --brand-success: #10b981;
    --primary: var(--brand-primary);
    --sidebar-w: 248px;
    --topbar-h: 52px;
    --radius: 10px;
    --radius-sm: 6px;
    --app-bg: #eef1f6;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --sidebar-bg: #111318;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(255, 255, 255, 0.1);
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    overflow-x: clip;
    max-width: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--app-bg);
    overflow-x: clip;
    max-width: 100%;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

img, svg, video { max-width: 100%; height: auto; }

a { color: var(--primary); }

/* ─── Bootstrap overrides ─── */
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: color-mix(in srgb, var(--primary) 85%, #000);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--primary) 85%, #000);
    --bs-btn-active-bg: color-mix(in srgb, var(--primary) 75%, #000);
    --bs-btn-active-border-color: color-mix(in srgb, var(--primary) 75%, #000);
}

.bg-primary { background-color: var(--primary) !important; }
.text-primary { color: var(--primary) !important; }
.border-primary { border-color: var(--primary) !important; }

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--primary) 20%, transparent);
}

/* ═══════════════════════════════════════════════════════════════
   APP SHELL
   ═══════════════════════════════════════════════════════════════ */

.app-shell {
    display: flex;
    min-height: 100vh;
    max-width: 100%;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

@media (min-width: 992px) {
    .app-main {
        margin-left: var(--sidebar-w);
    }
}

/* ─── Sidebar ─── */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    flex-direction: column;
    z-index: 1040;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1rem 1rem 0.85rem;
    text-decoration: none;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.app-brand:hover { color: #fff; }

/* Upload da ótica — ícone quadrado; lockup da plataforma usa .app-brand-logo--lockup em brand.css */
.app-brand-logo:not(.app-brand-logo--lockup) {
    width: 40px;
    height: 40px;
    object-fit: contain;
    object-position: center;
    flex-shrink: 0;
}

.app-brand-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
}

.app-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.app-brand-text strong {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-brand-text small {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.65rem 0.6rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.app-nav-group {
    margin-bottom: 0.35rem;
}

.app-nav-label {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.35);
    padding: 0.5rem 0.65rem 0.25rem;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.65rem;
    margin-bottom: 1px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.app-nav-link i {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    opacity: 0.85;
}

.app-nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.app-nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}

.app-nav-link.active i { color: var(--primary); opacity: 1; }

.app-sidebar-store {
    padding: 0.65rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.app-sidebar-store .form-select {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 0.78rem;
}

.app-sidebar-store .app-nav-label { padding-left: 0; }

.app-store-name {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.app-sidebar-footer {
    padding: 0.65rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.app-user-btn {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.45rem 0.55rem;
    border: none;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.app-user-btn:hover { background: rgba(255, 255, 255, 0.1); }

.app-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    overflow: hidden;
}

.app-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.app-user-info strong {
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-user-info small {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.45);
}

.app-user-btn > .bi-chevron-expand {
    font-size: 0.7rem;
    opacity: 0.5;
}

/* ─── Offcanvas mobile ─── */
.app-offcanvas {
    --bs-offcanvas-width: min(280px, 85vw);
    background: var(--sidebar-bg);
    color: #fff;
}

.app-offcanvas .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.85rem 1rem;
}

.app-offcanvas .btn-close {
    filter: invert(1);
    opacity: 0.6;
}

.app-offcanvas .offcanvas-body {
    padding: 0;
    display: flex;
    flex-direction: column;
}

.app-offcanvas .app-nav { flex: 1; }

.app-offcanvas .app-sidebar-store .form-select {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    color: #fff;
}

/* ─── Topbar ─── */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.app-topbar-start {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.app-page-title {
    min-width: 0;
}

.app-page-title h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-page-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
}

@media (min-width: 992px) {
    .app-page-title h1 { font-size: 0.92rem; }
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
}

.btn-icon:hover { background: var(--surface-2); }

/* ─── Impersonation banner ─── */
.app-impersonation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 0.75rem;
    padding: 0.45rem 1rem;
    background: #fef3c7;
    border-bottom: 1px solid #fde68a;
    font-size: 0.78rem;
    color: #92400e;
    flex-shrink: 0;
}

.app-impersonation a {
    color: #b45309;
    font-weight: 600;
    text-decoration: none;
}

.app-impersonation a:hover { text-decoration: underline; }

/* ─── Support session banner (client view) ─── */
.app-support-session {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 0.75rem;
    padding: 0.45rem 1rem;
    background: #dbeafe;
    border-bottom: 1px solid #93c5fd;
    font-size: 0.78rem;
    color: #1e40af;
    flex-shrink: 0;
}

.app-support-session--pending {
    background: #fef3c7;
    border-bottom-color: #fde68a;
    color: #92400e;
}

.app-support-session a,
.app-support-session-end {
    color: #1d4ed8;
    font-weight: 600;
    text-decoration: none;
}

.app-support-session--pending a { color: #b45309; }

.app-support-session a:hover,
.app-support-session-end:hover { text-decoration: underline; }

.support-activity-feed {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.support-activity-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.5rem;
    padding: 0.4rem 0.55rem;
    background: var(--surface-2, #f8fafc);
    border-radius: 0.35rem;
    font-size: 0.82rem;
}

.support-activity-time {
    color: var(--text-muted, #64748b);
    font-size: 0.75rem;
    white-space: nowrap;
}

.support-activity-label { font-weight: 500; }

/* ─── Guided session (co-browse + chat) ─── */
.guided-cobrowse-wrap {
    position: relative;
    min-height: 360px;
    background: #0f172a;
    overflow: auto;
}

.guided-cobrowse-wrap--staff {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: min(72vh, 640px);
    max-height: min(78vh, 860px);
    overflow: hidden;
    padding: 0.75rem;
}

.guided-cobrowse-viewport {
    position: relative;
    margin: 0 auto;
    max-width: 100%;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 32px rgba(0, 0, 0, 0.35);
    border-radius: 4px;
    overflow: hidden;
}

.guided-annotate-surface {
    position: absolute;
    inset: 0;
    z-index: 12;
}

.guided-cobrowse-root {
    position: relative;
    overflow: hidden;
    background: #fff;
}

.guided-cobrowse-root .replayer-wrapper {
    pointer-events: none;
    transform-origin: top left;
}

.guided-cobrowse-root .replayer-wrapper iframe {
    border: none;
}

.guided-cobrowse-root .replayer-mouse,
.guided-cobrowse-root .replayer-mouse-tail {
    display: none !important;
}

.guided-annotate-surface {
    position: absolute;
    z-index: 12;
}

.guided-cobrowse-waiting {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.92);
    color: #94a3b8;
}

.guided-chat-messages {
    max-height: 420px;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.guided-chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 92%;
    padding: 0.45rem 0.65rem;
    border-radius: 0.5rem;
    font-size: 0.82rem;
}

.guided-chat-msg--mine {
    align-self: flex-end;
    background: var(--brand-primary, #0d6efd);
    color: #fff;
}

.guided-chat-msg--staff {
    align-self: flex-start;
    background: var(--surface-2, #f1f5f9);
}

.guided-chat-author {
    font-size: 0.68rem;
    opacity: 0.85;
    margin-bottom: 0.15rem;
}

.guided-staff-chat {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1080;
}

.guided-staff-chat-toggle {
    border: none;
    border-radius: 2rem;
    padding: 0.55rem 1rem;
    background: var(--brand-primary, #0d6efd);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.guided-staff-chat-panel {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    right: 0;
    width: min(320px, calc(100vw - 2rem));
    background: var(--surface-1, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.guided-staff-chat-header {
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.guided-staff-chat-panel .guided-chat-messages {
    max-height: 240px;
}

.guided-cobrowse-wrap--staff[data-annotate-tool="point"] .guided-annotate-surface {
    cursor: crosshair;
}

.guided-cobrowse-wrap--staff[data-annotate-tool="rect"] .guided-annotate-surface,
.guided-cobrowse-wrap--staff[data-annotate-tool="highlight"] .guided-annotate-surface,
.guided-cobrowse-wrap--staff[data-annotate-tool="arrow"] .guided-annotate-surface {
    cursor: cell;
}

.guided-annotation-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1060;
}

.guided-annotation {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.guided-annotate-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.guided-annotate-label-input {
    max-width: 220px;
    margin-left: auto;
}

.guided-draw-preview {
    position: absolute;
    inset: 0;
    z-index: 11;
    pointer-events: none;
}

.guided-draw-preview-shape {
    position: absolute;
    border: 3px dashed #ef4444;
    background: rgba(239, 68, 68, 0.12);
    border-radius: 4px;
}

.guided-draw-preview--highlight .guided-draw-preview-shape {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.25);
}

.guided-annotation-wrap {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1060;
}

.guided-annotation-wrap--point .guided-annotation,
.guided-annotation-wrap--rect .guided-annotation,
.guided-annotation-wrap--highlight .guided-annotation {
    position: absolute;
    transform: none;
}

.guided-annotation--point::before {
    content: '';
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.35);
    border: 3px solid #ef4444;
    animation: guided-pulse 1.2s ease-out infinite;
    transform: translate(-50%, -50%);
}

.guided-annotation-wrap--point .guided-annotation {
    transform: translate(-50%, -50%);
}

.guided-annotation--rect {
    border: 3px solid #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 6px;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.guided-annotation--highlight {
    border: 2px dashed #f59e0b;
    background: rgba(245, 158, 11, 0.28);
    border-radius: 6px;
    animation: guided-highlight-pulse 1.5s ease-in-out infinite;
}

.guided-annotation-arrow-svg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.guided-annotation-arrow-label {
    position: absolute;
    transform: translate(-50%, -120%);
    background: #ef4444;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    white-space: nowrap;
}

.guided-annotation-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 4px;
    background: #ef4444;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    white-space: nowrap;
    z-index: 1;
}

.guided-annotation--highlight .guided-annotation-label {
    background: #d97706;
}

@keyframes guided-highlight-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

@keyframes guided-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    70% { box-shadow: 0 0 0 14px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.guided-floating-chat {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1080;
}

.guided-floating-chat-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--brand-primary, #0d6efd);
    color: #fff;
    font-size: 1.2rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
}

.guided-floating-chat-panel {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    right: 0;
    width: min(300px, calc(100vw - 2rem));
    background: var(--surface-1, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.guided-floating-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.guided-floating-chat-messages {
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.guided-floating-chat-form {
    padding: 0.45rem;
    border-top: 1px solid var(--border-color, #e2e8f0);
}

/* ─── Content area ─── */
.app-content {
    flex: 1;
    padding: 1rem;
    max-width: 100%;
    overflow-x: clip;
}

@media (min-width: 768px) {
    .app-content { padding: 1.25rem 1.5rem; }
}

.app-alert {
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* ─── Guest (login) ─── */
.app-guest {
    background: linear-gradient(145deg, #eef1f6 0%, #e2e8f0 100%);
}

.app-guest-main {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.5rem 1rem;
}

.app-guest .card {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.login-logo {
    max-height: 52px;
    max-width: 160px;
    object-fit: contain;
}

.login-brand-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    font-size: 1.5rem;
}

/* ═══════════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════════ */

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    max-width: 100%;
}

.card-header {
    background: var(--surface);
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}

.card-body { padding: 1rem; }

.stat-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s;
}

.stat-card:hover { box-shadow: var(--shadow); }

.stat-card .stat-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    font-weight: 600;
}

.stat-card .stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
}

.metric-value {
    color: var(--text);
}

.vh-flow-guide {
    background: var(--surface-2);
}

.vh-flow-step {
    background: var(--surface);
    border-color: var(--border) !important;
    color: var(--text);
}

.vh-flow-step .text-muted {
    color: var(--text-muted) !important;
}

.vh-kanban-hint {
    background: var(--surface) !important;
    color: var(--text-muted) !important;
    border-color: var(--border) !important;
}

.module-card {
    border-radius: var(--radius);
    transition: transform 0.15s, box-shadow 0.15s;
}

.module-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.module-card .card-body { padding: 1rem 0.75rem; }

.nav-tabs {
    flex-wrap: wrap;
    gap: 0.2rem;
    border-bottom-color: var(--border);
}

.nav-tabs .nav-link {
    color: var(--text-muted);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: 0.82rem;
    padding: 0.45rem 0.75rem;
}

.nav-tabs .nav-link.active {
    font-weight: 600;
    color: var(--primary);
    border-color: var(--border) var(--border) var(--surface);
}

/* Page headers inside content */
.app-content > .d-flex.mb-4,
.app-content > .d-flex.mb-3 {
    margin-bottom: 1rem !important;
}

.app-content h2.h4 {
    font-size: 1rem;
    font-weight: 600;
}

@media (max-width: 991.98px) {
    /* Topbar já mostra o título — esconde duplicata no conteúdo */
    .app-content > .d-flex.mb-3 > div > h2.h4,
    .app-content > .d-flex.mb-4 > div > h2.h4,
    .app-content > .d-flex.mb-3 > h2.h4,
    .app-content > .d-flex.mb-4 > h2.h4 {
        display: none;
    }
    .app-content > .d-flex.mb-3 > div > small.text-muted,
    .app-content > .d-flex.mb-4 > div > small.text-muted {
        display: none;
    }
}

.empty-state-icon {
    font-size: 2rem;
    color: #cbd5e1;
}

.page-kpi {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
}

/* Status badges */
.badge-status-orcamento { background-color: #94a3b8; }
.badge-status-confirmada { background-color: var(--primary); }
.badge-status-enviada_lab { background-color: #38bdf8; color: #000; }
.badge-status-em_producao { background-color: #fbbf24; color: #000; }
.badge-status-pronta { background-color: #22c55e; }
.badge-status-entregue { background-color: #334155; }
.badge-status-cancelada { background-color: #ef4444; }

/* Forms */
.form-control, .form-select, .input-group { max-width: 100%; }

.form-label { font-size: 0.8rem; font-weight: 500; color: var(--text); }

/* Autocomplete */
.client-search-results,
.product-picker .list-group {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: 1050;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    max-height: 240px;
    overflow-y: auto;
}

/* ═══════════════════════════════════════════════════════════════
   TABLES — sem scroll horizontal, compactas no mobile
   ═══════════════════════════════════════════════════════════════ */

.table-responsive {
    overflow-x: visible !important;
    overflow-y: visible !important;
}

.table {
    font-size: 0.82rem;
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: 0.55rem 0.75rem;
}

.table thead th {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.table-adaptive {
    width: 100%;
}

.table-adaptive th,
.table-adaptive td {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Lentes */
.lens-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 1fr;
}

@media (min-width: 992px) {
    .lens-grid { grid-template-columns: 1fr 1fr; }
}

.lens-grid-block {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}

.lens-grid-block-title {
    background: var(--surface-2);
    font-weight: 600;
    font-size: 0.78rem;
    text-align: center;
    padding: 0.45rem;
    border-bottom: 1px solid var(--border);
}

.lens-grid-eye {
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid var(--border);
}

.lens-grid-eye:last-child { border-bottom: none; }

.lens-grid-eye-title {
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.lens-grid-fields {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.35rem;
}

@media (min-width: 768px) {
    .lens-grid-fields { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
    .lens-grid-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 399.98px) {
    .lens-grid-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.lens-grid-field { min-width: 0; }

.lens-grid-label {
    display: block;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.1rem;
}

.lens-grid-value {
    display: block;
    font-size: 0.8rem;
}

.lens-grid-field .form-control {
    min-width: 0;
    padding: 0.2rem 0.3rem;
    font-size: 0.78rem;
    text-align: center;
}

/* ─── Itens da OS (formulário) ─── */
.os-items-form {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}

.os-items-header {
    grid-template-columns: 72px 1fr 2fr 110px 44px;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.os-item-row {
    display: grid;
    grid-template-columns: 72px 1fr 2fr 110px 44px;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    align-items: end;
    border-bottom: 1px solid var(--border);
}

.os-item-row:last-child { border-bottom: none; }

.os-item-label {
    display: none;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.os-item-field .form-control { min-width: 0; }

.os-item-field--actions {
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.os-items-footer {
    padding: 0.65rem 0.75rem;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
}

@media (max-width: 767.98px) {
    .os-item-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        padding: 0.75rem;
        margin: 0.5rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface);
    }

    .os-item-row:last-child { margin-bottom: 0.5rem; }

    .os-item-label { display: block; }

    .os-item-field--desc { grid-column: 1 / -1; }

    .os-item-field--actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
        padding-top: 0.15rem;
    }

    #osItemsList { padding-top: 0.25rem; }
}

@media (min-width: 768px) {
    .os-item-field--actions .os-item-remove {
        width: 36px;
        height: 31px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* Mobile: cards compactos em grid 2 colunas */
@media (max-width: 991.98px) {
    .table-adaptive thead { display: none; }

    .table-adaptive tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.35rem 0.65rem;
        padding: 0.65rem 0.75rem;
        margin-bottom: 0.45rem;
        border: 1px solid var(--border) !important;
        border-radius: var(--radius-sm);
        background: var(--surface);
    }

    .table-adaptive tbody tr:last-child { margin-bottom: 0; }

    .table-adaptive tbody td {
        display: block;
        padding: 0 !important;
        border: none !important;
        text-align: left !important;
    }

    .table-adaptive tbody td::before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        font-size: 0.6rem;
        color: var(--text-muted);
        text-transform: uppercase;
        margin-bottom: 0.1rem;
        letter-spacing: 0.03em;
    }

    .table-adaptive tbody td:not([data-label])::before,
    .table-adaptive tbody td[data-label=""]::before {
        display: none;
    }

    .table-adaptive tbody td.actions-cell {
        grid-column: 1 / -1;
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem;
        padding-top: 0.35rem !important;
        margin-top: 0.15rem;
        border-top: 1px solid var(--border) !important;
    }

    .table-adaptive tbody td.actions-cell::before { display: none; }

    .table-row-card tbody td:first-child {
        grid-column: 1 / -1;
    }

    .table-row-card tbody td.actions-cell {
        grid-column: 1 / -1;
        border-top: 1px solid var(--border) !important;
        padding-top: 0.45rem !important;
    }

    .table-adaptive tbody tr.table-empty-row {
        display: block;
        padding: 0;
        border: none !important;
        background: transparent;
    }

    .table-adaptive tbody tr.table-empty-row td {
        display: block;
        grid-column: 1 / -1;
    }

    .table-adaptive tbody tr.table-empty-row td::before { display: none; }

    .stat-card .stat-value { font-size: 1rem; }
    .page-kpi { font-size: 1.1rem; }

    .module-card .card-body { padding: 0.75rem 0.5rem; }
    .module-card .display-6 { font-size: 1.35rem; }
    .module-card .fs-2 { font-size: 1.35rem !important; }
}

@media (max-width: 575.98px) {
    .app-content { padding: 0.75rem; }

    .row { --bs-gutter-x: 0.65rem; }

    .text-nowrap { white-space: normal !important; }

    .d-flex.justify-content-between { flex-wrap: wrap; gap: 0.35rem; }

    .btn-sm { padding: 0.3rem 0.5rem; font-size: 0.78rem; }

    .card-body { padding: 0.85rem; }
}

.w-100 { width: 100% !important; }

/* Passos do fluxo da OS */
.os-status-steps {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    padding: 0.75rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

.os-status-step {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    min-width: 0;
}

.os-status-step-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border);
    flex-shrink: 0;
    font-size: 0.85rem;
}

.os-status-step.current .os-status-step-icon {
    background: var(--primary);
    color: #fff;
}

.os-status-step.current {
    color: var(--text);
    font-weight: 600;
}

.os-status-step.done .os-status-step-icon {
    background: #22c55e;
    color: #fff;
}

.os-status-step-line {
    flex: 1;
    min-width: 12px;
    height: 2px;
    background: var(--border);
    margin: 0 0.15rem;
}

.os-status-step-line.done {
    background: #22c55e;
}

@media (max-width: 575.98px) {
    .os-status-steps { flex-direction: column; align-items: stretch; }
    .os-status-step-line { display: none; }
}

.ticket-chat-messages { background: var(--surface-2, #f8f9fa); }
.ticket-msg-body {
    display: inline-block;
    max-width: 85%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    background: #fff;
    border: 1px solid var(--border, #dee2e6);
    white-space: pre-wrap;
    word-break: break-word;
}
.ticket-msg-staff { text-align: left; }
.ticket-msg-staff .ticket-msg-body { background: #e7f1ff; border-color: #b6d4fe; }
.ticket-msg-client { text-align: right; }
.ticket-msg-client .ticket-msg-body { background: #fff; }
.ticket-msg-client .small { text-align: right; }

/* Painel SaaS */
.saas-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.saas-kpi {
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e9ecef);
    border-radius: var(--radius, 0.5rem);
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.saas-kpi-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #6c757d);
    font-weight: 600;
}

.saas-kpi-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
}

.saas-kpi--accent { border-color: #a3cfbb; background: #f0fdf4; }
.saas-kpi--warn { border-color: #ffda6a; background: #fffbeb; }

.saas-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.saas-bar-label {
    width: 48px;
    font-size: 0.75rem;
    color: var(--text-muted, #6c757d);
}

.saas-bar-val {
    width: 28px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: right;
}

/* ═══════════════════════════════════════════════════════════════
   DARK THEME
   ═══════════════════════════════════════════════════════════════ */

[data-theme="dark"] {
    --app-bg: #020617;
    --surface: #0f172a;
    --surface-2: #1e293b;
    --sidebar-bg: #020617;
    --sidebar-hover: rgba(255, 255, 255, 0.05);
    --sidebar-active: rgba(37, 99, 235, 0.18);
    --border: #1e293b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
}

[data-theme="dark"] body {
    background: var(--app-bg);
    color: var(--text);
}

[data-theme="dark"] .app-topbar {
    background: var(--surface);
    border-bottom-color: var(--border);
}

[data-theme="dark"] .app-page-title h1 { color: var(--text); }
[data-theme="dark"] .app-page-sub { color: var(--text-muted); }

[data-theme="dark"] .card {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .card-header {
    background: var(--surface-2);
    border-bottom-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background: var(--surface-2);
    color: var(--text);
}

[data-theme="dark"] .input-group-text {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-muted);
}

[data-theme="dark"] .dropdown-menu {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .dropdown-item {
    color: var(--text);
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background: var(--surface-2);
    color: var(--text);
}

[data-theme="dark"] .dropdown-item-text { color: var(--text-muted) !important; }

[data-theme="dark"] .modal-content {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: var(--border);
}

[data-theme="dark"] .list-group-item {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }

[data-theme="dark"] .bg-light { background: var(--surface-2) !important; }

[data-theme="dark"] .app-offcanvas {
    background: var(--sidebar-bg);
}

[data-theme="dark"] .saas-kpi {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .saas-kpi--accent {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .saas-kpi--warn {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .btn-icon {
    color: var(--text-muted);
}

[data-theme="dark"] .btn-icon:hover {
    background: var(--surface-2);
    color: var(--text);
}

.btn-theme-toggle {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
    line-height: 1;
}

.btn-theme-toggle:hover {
    background: var(--surface-2);
    color: var(--text);
}

/* Dark theme — legibilidade (Bootstrap utilities + KPIs) */
[data-theme="dark"] .text-dark,
[data-theme="dark"] .card .fs-4,
[data-theme="dark"] .card .fs-5,
[data-theme="dark"] .card .display-6,
[data-theme="dark"] .module-card .fw-bold,
[data-theme="dark"] .module-card .display-6,
[data-theme="dark"] .stat-card .stat-value,
[data-theme="dark"] .stat-card .fs-4,
[data-theme="dark"] .stat-card .fw-bold,
[data-theme="dark"] .saas-kpi-value,
[data-theme="dark"] .card-body .fw-bold:not(.text-success):not(.text-danger):not(.text-warning):not(.text-primary):not(.text-info),
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6,
[data-theme="dark"] .h4, [data-theme="dark"] .h5, [data-theme="dark"] .h6 {
    color: var(--text) !important;
}

[data-theme="dark"] .bg-white {
    background-color: var(--surface-2) !important;
    color: var(--text);
}

[data-theme="dark"] .bg-light,
[data-theme="dark"] .card.bg-light {
    background-color: var(--surface-2) !important;
    color: var(--text);
    border-color: var(--border) !important;
}

[data-theme="dark"] .bg-light .text-muted,
[data-theme="dark"] .bg-white .text-muted,
[data-theme="dark"] .card.bg-light .text-muted {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .bg-light strong,
[data-theme="dark"] .border.bg-white strong,
[data-theme="dark"] .bg-white strong {
    color: var(--text);
}

[data-theme="dark"] .card-header.bg-white,
[data-theme="dark"] .card-header.bg-light {
    background: var(--surface-2) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

[data-theme="dark"] .card-header.bg-primary,
[data-theme="dark"] .card-header.bg-success,
[data-theme="dark"] .card-header.bg-danger,
[data-theme="dark"] .card-header.bg-warning,
[data-theme="dark"] .card-header.bg-secondary {
    color: #fff !important;
}

[data-theme="dark"] .card-header .badge.bg-light {
    background: rgba(255, 255, 255, 0.92) !important;
    color: #0f172a !important;
}

[data-theme="dark"] .table thead th,
[data-theme="dark"] .table-light th {
    background: var(--surface-2) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

[data-theme="dark"] .list-group-item a,
[data-theme="dark"] .list-group-item a strong {
    color: #93c5fd;
}

[data-theme="dark"] .list-group-item a:hover strong {
    color: #bfdbfe;
}

[data-theme="dark"] .list-group-item .text-muted {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .module-card,
[data-theme="dark"] .stat-card {
    background: var(--surface);
    color: var(--text);
}

[data-theme="dark"] .module-card small,
[data-theme="dark"] .stat-card small {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .saas-kpi-label {
    color: var(--text-muted);
}

[data-theme="dark"] .nav-pills .nav-link {
    color: var(--text-muted);
}

[data-theme="dark"] .nav-pills .nav-link.active {
    background: var(--primary);
    color: #fff;
}

[data-theme="dark"] .alert {
    border-color: var(--border);
}

[data-theme="dark"] .btn-outline-secondary {
    --bs-btn-color: var(--text-muted);
    --bs-btn-border-color: var(--border);
    --bs-btn-hover-bg: var(--surface-2);
    --bs-btn-hover-color: var(--text);
}

[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

[data-theme="dark"] .metric-value {
    color: var(--text) !important;
}

[data-theme="dark"] .badge.bg-light,
[data-theme="dark"] .badge.text-bg-light,
[data-theme="dark"] .text-bg-light {
    background: var(--surface-2) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

[data-theme="dark"] .badge.bg-warning.text-dark {
    color: #0f172a !important;
}
