/* ================================================================
   JURISAI DASHBOARD — Professional Design System v3
   Dark theme · Inter · Indigo accent
================================================================ */

/* ── TOKENS ─────────────────────────────────────────────────── */

:root {
    /* Backgrounds */
    --bg-base:       #09090b;
    --bg-raised:     #111116;
    --bg-overlay:    #18181f;
    --bg-subtle:     #1f1f2a;

    /* Borders */
    --border:        rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.11);
    --border-focus:  rgba(99, 102, 241, 0.5);

    /* Text */
    --text-primary:   #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted:     #52525b;

    /* Accent — Indigo */
    --accent:        #6366f1;
    --accent-hover:  #818cf8;
    --accent-muted:  rgba(99, 102, 241, 0.12);
    --accent-border: rgba(99, 102, 241, 0.25);

    /* Semantic colors */
    --green:         #22c55e;
    --green-muted:   rgba(34, 197, 94, 0.12);
    --orange:        #f97316;
    --orange-muted:  rgba(249, 115, 22, 0.12);
    --blue:          #3b82f6;
    --blue-muted:    rgba(59, 130, 246, 0.12);
    --purple:        #a855f7;
    --purple-muted:  rgba(168, 85, 247, 0.12);
    --red:           #ef4444;
    --red-muted:     rgba(239, 68, 68, 0.12);

    /* Radius */
    --r-sm:  6px;
    --r-md:  10px;
    --r-lg:  14px;
    --r-xl:  20px;

    /* Sidebar */
    --sidebar-w:  252px;
    --sidebar-collapsed-w: 64px;

    /* Transitions */
    --t:      200ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── RESET ───────────────────────────────────────────────────── */

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

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
    font-size: 14px;
}

/* ── APP LAYOUT ──────────────────────────────────────────────── */

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-raised);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--t-slow);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-w);
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    height: 60px;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
    /* Anima largura + opacidade para colapso sem cortar o SVG */
    max-width: 200px;
    transition: max-width var(--t-slow), opacity var(--t);
}

.brand-logo svg {
    flex-shrink: 0;
}

.brand-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--t);
}

/* Colapso: esconde brand-logo via max-width (não deixa SVG ser clipado) */
.sidebar.collapsed .brand-logo {
    max-width: 0;
    opacity: 0;
    pointer-events: none;
}

/* Centraliza o botão toggle quando sidebar recolhida */
.sidebar.collapsed .sidebar-brand {
    justify-content: center;
}

.sidebar.collapsed .brand-name {
    opacity: 0;
    pointer-events: none;
}

/* Toggle button */
.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--t);
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.sidebar.collapsed .sidebar-toggle-btn svg {
    transform: rotate(180deg);
}

.sidebar-toggle-btn svg {
    transition: transform var(--t-slow);
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 10px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 0;
}

.nav-group {
    padding: 0 8px;
    margin-bottom: 4px;
}

.nav-group-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 8px 4px;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--t);
}

.sidebar.collapsed .nav-group-label {
    opacity: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px;
    border-radius: var(--r-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all var(--t);
    position: relative;
    white-space: nowrap;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-overlay);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-muted);
    color: var(--accent-hover);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 56%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.nav-text {
    flex: 1;
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--t);
}

.sidebar.collapsed .nav-text {
    opacity: 0;
}

.nav-badge {
    background: var(--accent-muted);
    color: var(--accent-hover);
    border: 1px solid var(--accent-border);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 20px;
    flex-shrink: 0;
    opacity: 1;
    transition: opacity var(--t);
}

.sidebar.collapsed .nav-badge {
    opacity: 0;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 10px 8px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background var(--t);
    overflow: hidden;
}

.user-card:hover {
    background: var(--bg-overlay);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.user-meta {
    min-width: 0;
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--t);
}

.sidebar.collapsed .user-meta {
    opacity: 0;
}

.user-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-plan {
    display: block;
    font-size: 11px;
    color: var(--accent);
    font-weight: 500;
    margin-top: 1px;
}

/* ── MAIN WRAPPER ────────────────────────────────────────────── */

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── TOPBAR ──────────────────────────────────────────────────── */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    height: 60px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-raised);
    overflow: hidden;
}

/* BUG 1 FIX: topbar-left sem flex base causava corte ao recolher sidebar */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.page-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-desc {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 1px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--green-muted);
    border: 1px solid rgba(34, 197, 94, 0.2);
    padding: 5px 10px;
    border-radius: 20px;
}

.status-dot-live {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
    animation: livePulse 2.4s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
    50%       { opacity: 0.7; box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

.status-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--green);
}

.topbar-date {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

/* ── MAIN CONTENT ────────────────────────────────────────────── */

.main-content {
    flex: 1;
    padding: 22px 28px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.main-content::-webkit-scrollbar { width: 5px; }
.main-content::-webkit-scrollbar-thumb { background: var(--bg-overlay); border-radius: 10px; }
.main-content::-webkit-scrollbar-track { background: transparent; }

/* ── METRICS GRID ────────────────────────────────────────────── */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    flex-shrink: 0;
}

.metric-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
    transition: border-color var(--t), transform var(--t), box-shadow var(--t);
    cursor: default;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.07), transparent);
}

.metric-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.metric-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.metric-icon-wrap {
    width: 34px;
    height: 34px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.icon-blue   { background: var(--blue-muted);   color: var(--blue); }
.icon-orange { background: var(--orange-muted); color: var(--orange); }
.icon-green  { background: var(--green-muted);  color: var(--green); }
.icon-purple { background: var(--purple-muted); color: var(--purple); }

.metric-change {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 20px;
    letter-spacing: 0.01em;
}

.trend-up   { background: var(--green-muted); color: var(--green); }
.trend-down { background: var(--red-muted);   color: var(--red); }

.metric-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.04em;
    line-height: 1;
    margin-bottom: 5px;
    font-variant-numeric: tabular-nums;
    transition: color var(--t);
}

.metric-label {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-muted);
}

/* Skeleton for metric value */
.metric-card.loading .metric-value {
    color: transparent;
    background: var(--bg-overlay);
    border-radius: 4px;
    width: 72px;
    user-select: none;
}

/* Shimmer bar at card bottom */
.skeleton-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    display: none;
    background: linear-gradient(
        90deg,
        var(--bg-overlay) 0%,
        rgba(99,102,241,0.3) 50%,
        var(--bg-overlay) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.6s ease-in-out infinite;
}

.metric-card.loading .skeleton-bar {
    display: block;
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}

/* ── PANELS GRID ─────────────────────────────────────────────── */

.panels-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 14px;
    /* Sem flex: 1 — altura natural, main-content rola para acomodar charts + painéis */
    min-height: 380px;
}

/* Garante que os painéis do dashboard sempre tenham altura suficiente */
.panels-grid .panel {
    min-height: 380px;
}

.panel {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.panel-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.panel-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.panel-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--r-sm);
    transition: all var(--t);
    font-family: inherit;
    white-space: nowrap;
    line-height: 1;
}

.btn-ghost:hover {
    color: var(--text-secondary);
    background: var(--bg-subtle);
}

.btn-sm { font-size: 11.5px; }

/* ── LEADS LIST ──────────────────────────────────────────────── */

.leads-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-height: 200px;
}

.leads-list::-webkit-scrollbar { width: 3px; }
.leads-list::-webkit-scrollbar-thumb { background: var(--bg-overlay); border-radius: 4px; }
.leads-list::-webkit-scrollbar-track { background: transparent; }

.lead-item {
    display: flex;
    align-items: center;
    gap: 11px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 11px 12px;
    cursor: pointer;
    transition: all var(--t);
    animation: fadeUp 0.25s ease both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.lead-item:hover {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
}

.lead-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-muted), rgba(168,85,247,0.15));
    border: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--accent-hover);
    flex-shrink: 0;
    letter-spacing: 0.01em;
}

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

.lead-name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.lead-phone {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.lead-status {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    flex-shrink: 0;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.status-hot  { background: var(--orange-muted); color: var(--orange); }
.status-warm { background: var(--blue-muted);   color: var(--blue); }
.status-cold { background: var(--bg-subtle);    color: var(--text-muted); }
.status-novo { background: var(--green-muted);  color: var(--green); }

/* Skeleton leads */
.skeleton-lead {
    height: 54px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.skeleton-lead::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,255,255,0.04) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.6s ease-in-out infinite;
}

/* ── FOLLOW-UP BUTTON ────────────────────────────────────────── */

.followup-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    margin-top: 12px;
    padding: 11px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--t);
    flex-shrink: 0;
    box-shadow: 0 2px 20px rgba(99, 102, 241, 0.28);
    letter-spacing: -0.01em;
}

.followup-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 28px rgba(99, 102, 241, 0.44);
    transform: translateY(-1px);
}

.followup-btn:active {
    transform: translateY(0);
}

.followup-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ── CHAT PANEL ──────────────────────────────────────────────── */

.panel-chat {
    min-height: 0;
}

.ai-status-wrap {
    display: flex;
    align-items: center;
    gap: 9px;
}

.ai-pulse {
    position: relative;
    width: 9px;
    height: 9px;
    flex-shrink: 0;
}

.ai-pulse-ring {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1.5px solid var(--accent);
    opacity: 0.4;
    animation: aiRing 2.2s ease-in-out infinite;
}

.ai-pulse-dot {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--accent);
}

@keyframes aiRing {
    0%, 100% { transform: scale(1);   opacity: 0.4; }
    50%       { transform: scale(1.7); opacity: 0; }
}

.ai-badge {
    background: var(--accent-muted);
    border: 1px solid var(--accent-border);
    color: var(--accent-hover);
    font-size: 9.5px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--r-sm);
    letter-spacing: 0.06em;
}

/* Chat messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 2px;
    min-height: 0;
}

.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--bg-overlay); border-radius: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }

.message {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 11px 13px;
    animation: msgIn 0.2s ease;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 5px;
}

.message-sender {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.message-time {
    font-size: 10px;
    color: var(--text-muted);
}

.message p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.65;
}

.ai-message   { border-left: 2px solid var(--accent); }
.user-message { border-left: 2px solid var(--green); }
.system-message { border-left: 2px solid var(--red); }

.ai-message   .message-sender { color: var(--accent-hover); }
.user-message .message-sender { color: var(--green); }
.system-message .message-sender { color: var(--red); }

/* Chat input */
.chat-input-wrap {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-shrink: 0;
}

.chat-input-field {
    flex: 1;
    background: var(--bg-overlay);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 11px 14px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--t), box-shadow var(--t);
}

.chat-input-field::placeholder {
    color: var(--text-muted);
}

.chat-input-field:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border: none;
    border-radius: var(--r-md);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--t);
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

.chat-send-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 20px rgba(99, 102, 241, 0.44);
}

/* ── TOAST NOTIFICATIONS ─────────────────────────────────────── */

.toast-container {
    position: fixed;
    bottom: 22px;
    right: 22px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--bg-overlay);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    padding: 12px 14px;
    min-width: 280px;
    max-width: 340px;
    pointer-events: all;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px var(--border);
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.toast.removing {
    animation: toastOut 0.22s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(16px) scale(0.94); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(10px) scale(0.94); }
}

.toast-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    margin-top: 1px;
}

.toast--success .toast-icon { background: var(--green-muted);  color: var(--green); }
.toast--error   .toast-icon { background: var(--red-muted);    color: var(--red); }
.toast--info    .toast-icon { background: var(--accent-muted); color: var(--accent-hover); }

.toast--success { border-color: rgba(34,197,94,0.15); }
.toast--error   { border-color: rgba(239,68,68,0.15); }

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.toast-desc {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    transition: color var(--t);
    margin-top: -1px;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--text-secondary);
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */

@media (max-width: 1400px) {
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1280px) {
    .metrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .panels-grid {
        grid-template-columns: 1fr;
        overflow-y: auto;
        flex: none;
    }

    .panel {
        min-height: 280px;
    }

    .panel-chat {
        height: 500px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        height: 100%;
        z-index: 50;
    }

    .main-content {
        padding: 14px 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-right {
        display: none;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* ================================================================
   PAGES — navigation views
================================================================ */

.page {
    display: none;
    flex-direction: column;
    gap: 18px;
    flex: 1;
    min-height: 0;
}

.page.active {
    display: flex;
}

/* ── PAGE TOOLBAR ────────────────────────────────────────────── */

.page-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-raised);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 0 12px;
    flex: 1;
    max-width: 380px;
    transition: border-color var(--t), box-shadow var(--t);
}

.search-wrap:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.search-wrap svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-wrap input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    padding: 10px 0;
    flex: 1;
    min-width: 0;
}

.search-wrap input::placeholder {
    color: var(--text-muted);
}

.filter-select {
    background: var(--bg-raised);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    padding: 9px 12px;
    cursor: pointer;
    outline: none;
    transition: border-color var(--t);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2352525b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.filter-select:focus {
    border-color: var(--border-focus);
}

.filter-select option {
    background: var(--bg-overlay);
    color: var(--text-primary);
}

/* ── LEADS FULL PAGE ─────────────────────────────────────────── */

.leads-full-panel {
    flex: 1;
    min-height: 0;
    padding: 0;
}

.leads-table-header {
    display: grid;
    grid-template-columns: 44px 1fr 160px 140px 110px;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-strong);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    flex-shrink: 0;
}

.leads-full-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.leads-full-list::-webkit-scrollbar { width: 4px; }
.leads-full-list::-webkit-scrollbar-thumb { background: var(--bg-overlay); border-radius: 4px; }

.lead-row {
    display: grid;
    grid-template-columns: 44px 1fr 160px 140px 110px;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--t);
    animation: fadeUp 0.2s ease both;
}

.lead-row:hover {
    background: var(--bg-overlay);
}

.lead-row-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lead-row-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

.lead-row-phone {
    font-size: 12.5px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.lead-row-date {
    font-size: 12px;
    color: var(--text-muted);
}

.leads-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ── PLACEHOLDER PAGES ───────────────────────────────────────── */

.placeholder-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
    padding: 40px;
}

.placeholder-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--r-xl);
    background: var(--bg-raised);
    border: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.placeholder-page h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.placeholder-page p {
    font-size: 13.5px;
    color: var(--text-muted);
    max-width: 380px;
    line-height: 1.65;
}

.placeholder-page .followup-btn {
    width: auto;
    padding: 11px 24px;
    margin-top: 4px;
}

/* ── AI FULL CHAT PAGE ────────────────────────────────────────── */

.ai-full-panel {
    flex: 1;
    min-height: 0;
}

.ai-area-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.ai-model-select {
    background: var(--bg-overlay);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--text-secondary);
    font-size: 11.5px;
    font-family: inherit;
    font-weight: 500;
    padding: 5px 10px;
    cursor: pointer;
    outline: none;
    transition: border-color var(--t);
    appearance: none;
    -webkit-appearance: none;
}

.ai-model-select:focus {
    border-color: var(--border-focus);
}

.ai-model-select option {
    background: var(--bg-overlay);
    color: var(--text-primary);
}

.ai-clear-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-muted);
    font-size: 11.5px;
    font-family: inherit;
    padding: 5px 10px;
    cursor: pointer;
    transition: all var(--t);
}

.ai-clear-btn:hover {
    border-color: var(--border-strong);
    color: var(--text-secondary);
    background: var(--bg-overlay);
}

/* ── RAG PAGE ─────────────────────────────────────────────────── */

.rag-panel {
    flex: 1;
    min-height: 0;
}

.rag-search-bar {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    margin-bottom: 16px;
}

.rag-search-bar .search-wrap {
    max-width: none;
}

.rag-search-btn {
    background: var(--accent);
    border: none;
    color: white;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: all var(--t);
    white-space: nowrap;
    box-shadow: 0 2px 12px rgba(99,102,241,0.25);
}

.rag-search-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 20px rgba(99,102,241,0.4);
}

.rag-results {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.rag-results::-webkit-scrollbar { width: 4px; }
.rag-results::-webkit-scrollbar-thumb { background: var(--bg-overlay); border-radius: 4px; }

.rag-result-item {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 16px;
    cursor: pointer;
    transition: all var(--t);
    animation: fadeUp 0.2s ease both;
}

.rag-result-item:hover {
    border-color: var(--border-strong);
    background: var(--bg-subtle);
}

.rag-result-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.rag-result-snippet {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.55;
}

.rag-result-tags {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.rag-tag {
    background: var(--accent-muted);
    color: var(--accent-hover);
    border: 1px solid var(--accent-border);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.02em;
}

.rag-hint {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}

/* ================================================================
   SETTINGS DRAWER
================================================================ */

.settings-drawer {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    justify-content: flex-end;
    pointer-events: none;
}

.settings-drawer.open {
    pointer-events: all;
}

.settings-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity var(--t-slow);
    cursor: pointer;
}

.settings-drawer.open .settings-overlay {
    opacity: 1;
}

.settings-panel {
    position: relative;
    width: 400px;
    max-width: 92vw;
    height: 100%;
    background: var(--bg-raised);
    border-left: 1px solid var(--border-strong);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--t-slow);
    box-shadow: -12px 0 48px rgba(0,0,0,0.5);
}

.settings-drawer.open .settings-panel {
    transform: translateX(0);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.settings-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.settings-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: all var(--t);
}

.settings-close:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.settings-body::-webkit-scrollbar { width: 4px; }
.settings-body::-webkit-scrollbar-thumb { background: var(--bg-overlay); border-radius: 4px; }

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-section-title {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.settings-field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.settings-field input,
.settings-field select {
    background: var(--bg-overlay);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--t), box-shadow var(--t);
    width: 100%;
}

.settings-field input:focus,
.settings-field select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.settings-field select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2352525b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

.settings-field select option {
    background: var(--bg-overlay);
    color: var(--text-primary);
}

.settings-hint {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 1px;
}

.settings-hint a {
    color: var(--accent-hover);
    text-decoration: none;
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 0;
}

.settings-toggle-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.toggle {
    width: 36px;
    height: 20px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: background var(--t), border-color var(--t);
    flex-shrink: 0;
}

.toggle.on {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    top: 2px;
    left: 2px;
    transition: transform var(--t);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle.on::after {
    transform: translateX(16px);
}

.settings-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-version {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

.settings-save-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    padding: 11px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--t);
    box-shadow: 0 2px 16px rgba(99,102,241,0.28);
}

.settings-save-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 24px rgba(99,102,241,0.4);
}

/* ================================================================
   LOGIN SCREEN
================================================================ */

.login-screen {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    background-image:
        radial-gradient(ellipse at 20% 10%, rgba(99,102,241,0.1) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 90%, rgba(139,92,246,0.08) 0%, transparent 50%);
    padding: 24px;
    animation: loginFadeIn 0.35s ease;
}

.login-screen.hiding {
    animation: loginFadeOut 0.28s ease forwards;
    pointer-events: none;
}

@keyframes loginFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes loginFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-raised);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-xl);
    padding: 36px 32px 28px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    box-shadow: 0 0 0 1px var(--border), 0 24px 80px rgba(0,0,0,0.55);
    position: relative;
    overflow: hidden;
    animation: loginCardUp 0.4s cubic-bezier(0.34, 1.15, 0.64, 1);
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(99,102,241,0.5), transparent);
}

@keyframes loginCardUp {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* Logo */
.login-logo-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.login-logo-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(140deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(99,102,241,0.4), 0 0 0 1px rgba(99,102,241,0.2);
}

.login-product-name {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1;
}

.login-tagline {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: -2px;
}

/* Divider */
.login-divider {
    height: 1px;
    background: var(--border);
    margin: -6px 0;
}

/* Form section header */
.login-form-header {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.login-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

/* Form */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.login-field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.login-field input {
    background: var(--bg-overlay);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 11px 13px;
    color: var(--text-primary);
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--t), box-shadow var(--t);
    width: 100%;
}

.login-field input::placeholder {
    color: var(--text-muted);
}

.login-field input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.login-field input.input-error {
    border-color: rgba(239,68,68,0.5);
    box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}

/* Error message */
.login-error {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--red-muted);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: var(--r-md);
    padding: 10px 12px;
    font-size: 12.5px;
    color: var(--red);
    font-weight: 500;
    animation: errorShake 0.38s ease;
}

.login-error svg {
    flex-shrink: 0;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-7px); }
    40%       { transform: translateX(7px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

/* Login button */
.login-btn {
    width: 100%;
    padding: 12px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--r-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--t);
    box-shadow: 0 2px 20px rgba(99,102,241,0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 2px;
    letter-spacing: -0.01em;
}

.login-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: 0 2px 28px rgba(99,102,241,0.48);
    transform: translateY(-1px);
}

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

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.login-btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: loginSpin 0.65s linear infinite;
    flex-shrink: 0;
}

@keyframes loginSpin {
    to { transform: rotate(360deg); }
}

/* Demo credentials hint */
.login-demo-hint {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.login-demo-title {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.login-demo-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.login-demo-row code {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
    color: var(--text-secondary);
}

.login-demo-badge {
    font-size: 9.5px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.login-demo-badge.admin {
    background: var(--accent-muted);
    color: var(--accent-hover);
    border: 1px solid var(--accent-border);
}

.login-demo-badge.user {
    background: var(--green-muted);
    color: var(--green);
    border: 1px solid rgba(34,197,94,0.2);
}

/* ================================================================
   LOGOUT BUTTON (sidebar footer)
================================================================ */

.logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 8px;
    background: transparent;
    border: none;
    border-radius: var(--r-md);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--t);
    text-align: left;
    margin-top: 4px;
}

.logout-btn:hover {
    background: var(--red-muted);
    color: var(--red);
}

.logout-btn svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.sidebar.collapsed .logout-btn .nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* ================================================================
   MOBILE OVERLAY (sidebar backdrop)
================================================================ */

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 49;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: fadeIn 0.22s ease;
}

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

/* ================================================================
   HAMBURGER BUTTON (mobile only)
================================================================ */

.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--t);
    flex-shrink: 0;
}

.hamburger-btn:hover {
    background: var(--bg-overlay);
    color: var(--text-primary);
}

/* Topbar title group */
.topbar-title-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

/* ================================================================
   LEADS TOOLBAR
================================================================ */

.leads-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.leads-toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.leads-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.leads-count-badge {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 500;
}

/* ── BULK ACTIONS ──────────────────────────────────────────────── */

.bulk-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-muted);
    border: 1px solid var(--accent-border);
    border-radius: var(--r-md);
    padding: 6px 12px;
    animation: fadeUp 0.2s ease;
    white-space: nowrap;
}

.bulk-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-hover);
}

.btn-bulk {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--accent);
    border: none;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
    font-family: inherit;
    transition: all var(--t);
    min-height: 28px;
}

.btn-bulk:hover {
    background: var(--accent-hover);
}

.btn-bulk--danger {
    background: var(--red-muted);
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.2);
}

.btn-bulk--danger:hover {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

/* ================================================================
   LEADS TABLE (SaaS-grade)
================================================================ */

.leads-full-panel {
    flex: 1;
    min-height: 0;
    padding: 0;
    overflow: hidden;
}

.leads-table-wrap {
    overflow-x: auto;
    flex-shrink: 0;
}

.leads-table-wrap::-webkit-scrollbar { height: 4px; }
.leads-table-wrap::-webkit-scrollbar-thumb { background: var(--bg-overlay); border-radius: 4px; }

.leads-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 680px;
}

/* ── THEAD ─────────────────────────────────────────────────────── */

.leads-table thead tr {
    border-bottom: 1px solid var(--border-strong);
}

.leads-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
    user-select: none;
    background: var(--bg-raised);
}

.th-check { width: 44px; padding: 10px 8px 10px 16px !important; }
.th-score { width: 80px; }
.th-actions { width: 110px; text-align: right; padding-right: 16px !important; }

.th-sortable {
    cursor: pointer;
    transition: color var(--t);
}

.th-sortable:hover {
    color: var(--text-secondary);
}

.th-sortable.sort-asc,
.th-sortable.sort-desc {
    color: var(--accent-hover);
}

.sort-arrow {
    display: inline-block;
    width: 12px;
    font-size: 10px;
    margin-left: 3px;
    opacity: 0.35;
    transition: opacity var(--t);
    vertical-align: middle;
}

.sort-arrow::after { content: "↕"; }

.th-sortable:hover .sort-arrow { opacity: 0.7; }
.th-sortable.sort-asc  .sort-arrow::after { content: "↑"; opacity: 1; color: var(--accent-hover); }
.th-sortable.sort-desc .sort-arrow::after { content: "↓"; opacity: 1; color: var(--accent-hover); }
.th-sortable.sort-asc  .sort-arrow,
.th-sortable.sort-desc .sort-arrow { opacity: 1; }

/* ── TBODY ─────────────────────────────────────────────────────── */

.leads-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--t);
    animation: fadeUp 0.18s ease both;
}

.leads-table tbody tr:hover {
    background: var(--bg-overlay);
}

.leads-table tbody tr:hover .row-actions {
    opacity: 1;
}

.leads-table tbody tr.row-selected {
    background: var(--accent-muted);
}

.leads-table tbody tr.row-selected .row-actions {
    opacity: 1;
}

.leads-table tbody td {
    padding: 12px 14px;
    color: var(--text-secondary);
    vertical-align: middle;
}

.td-check { padding: 12px 8px 12px 16px !important; width: 44px; }

/* ── CHECKBOX ──────────────────────────────────────────────────── */

.leads-checkbox {
    width: 16px;
    height: 16px;
    min-width: 16px;
    border-radius: 4px;
    border: 1.5px solid var(--border-strong);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    position: relative;
    transition: all var(--t);
    display: block;
}

.leads-checkbox:hover {
    border-color: var(--accent);
}

.leads-checkbox:checked,
.leads-checkbox:indeterminate {
    background: var(--accent);
    border-color: var(--accent);
}

.leads-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1.5px;
    width: 5px;
    height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

.leads-checkbox:indeterminate::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 6px;
    width: 8px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
}

/* ── NOME CELL ─────────────────────────────────────────────────── */

.td-lead-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.td-lead-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    border: 1px solid var(--border-strong);
}

.td-lead-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

/* ── SCORE ─────────────────────────────────────────────────────── */

.lead-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 22px;
    border-radius: var(--r-sm);
    font-size: 11.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 0 6px;
}

.score-high { background: var(--green-muted);  color: var(--green); }
.score-mid  { background: var(--orange-muted); color: var(--orange); }
.score-low  { background: var(--red-muted);    color: var(--red); }

/* ── STATUS UNDEF ──────────────────────────────────────────────── */

.status-undef {
    background: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
}

/* ── MESSAGE / DATE ────────────────────────────────────────────── */

.td-message-text {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12.5px;
    color: var(--text-muted);
}

.td-date-text {
    white-space: nowrap;
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ── ROW ACTIONS ───────────────────────────────────────────────── */

.td-actions-cell {
    text-align: right;
    padding-right: 16px !important;
}

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--t);
}

.row-action-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--bg-overlay);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--t);
}

.row-action-btn:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.row-action-btn.btn-danger:hover {
    background: var(--red-muted);
    color: var(--red);
    border-color: rgba(239,68,68,0.3);
}

/* ================================================================
   EMPTY STATE
================================================================ */

.leads-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 20px;
    gap: 14px;
    text-align: center;
}

.empty-icon {
    width: 68px;
    height: 68px;
    border-radius: var(--r-xl);
    background: var(--bg-overlay);
    border: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.leads-empty-state h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.leads-empty-state p {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 300px;
    line-height: 1.6;
}

/* ================================================================
   PAGINATION
================================================================ */

.leads-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-raised);
}

.page-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-overlay);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    padding: 7px 14px;
    cursor: pointer;
    transition: all var(--t);
    min-height: 36px;
}

.page-btn:hover:not(:disabled) {
    background: var(--bg-subtle);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.page-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.page-info {
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ================================================================
   MOBILE RESPONSIVE — SIDEBAR AS DRAWER
================================================================ */

@media (max-width: 768px) {

    /* Sidebar → fixed drawer */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 50;
        width: var(--sidebar-w) !important;
        transform: translateX(-100%);
        transition: transform var(--t-slow);
        box-shadow: none;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 8px 0 40px rgba(0,0,0,0.55);
    }

    .sidebar.collapsed {
        width: var(--sidebar-w) !important;
        transform: translateX(-100%);
    }

    .sidebar.collapsed.mobile-open {
        transform: translateX(0);
    }

    /* Hide collapse toggle on mobile */
    .sidebar-toggle-btn { display: none; }

    /* Show hamburger */
    .hamburger-btn { display: flex; }

    /* Topbar */
    .topbar {
        padding: 0 14px;
        gap: 10px;
    }

    .topbar-left { gap: 10px; }

    .page-desc { display: none; }

    .system-status,
    .topbar-date { display: none; }

    /* Main content */
    .main-content {
        padding: 14px 14px;
        gap: 14px;
    }

    /* Metrics → 2×2 */
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .metric-value { font-size: 26px; }
    .metric-card  { padding: 14px 16px; }

    /* Panels → stack */
    .panels-grid {
        grid-template-columns: 1fr;
        flex: none;
    }

    .panel-chat { height: 440px; }

    /* Leads toolbar → wrap */
    .leads-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .leads-toolbar-left {
        flex-wrap: wrap;
    }

    .leads-toolbar-right {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    /* Hide less-critical columns at tablet */
    .th-message,
    .td-message { display: none !important; }

    .th-score,
    .td-score { display: none !important; }

    /* Touch targets */
    .nav-item { min-height: 44px; }
    .followup-btn { min-height: 44px; }
    .row-action-btn { width: 36px; height: 36px; }

    /* Row actions always visible on mobile */
    .row-actions { opacity: 1 !important; }
}

/* ================================================================
   MOBILE 640px — TABLE → CARDS
================================================================ */

@media (max-width: 640px) {

    /* Reset table display */
    .leads-table,
    .leads-table thead,
    .leads-table tbody,
    .leads-table tr,
    .leads-table th,
    .leads-table td { display: block; }

    /* Hide header row */
    .leads-table thead { display: none; }

    /* Each tbody row becomes a card */
    .leads-table tbody tr {
        background: var(--bg-overlay);
        border: 1px solid var(--border);
        border-radius: var(--r-md);
        margin: 0 0 8px;
        padding: 12px;
        display: grid;
        grid-template-columns: 44px 1fr auto;
        grid-template-rows: auto auto;
        gap: 0 8px;
        align-items: center;
        width: 100%;
    }

    .leads-table tbody tr:hover {
        background: var(--bg-subtle);
    }

    .leads-table .td-check     { grid-row: 1 / 3; grid-column: 1; align-self: center; padding: 0 !important; }
    .leads-table .td-nome      { grid-row: 1;      grid-column: 2; padding: 0 0 4px !important; }
    .leads-table .td-status    { grid-row: 1;      grid-column: 3; padding: 0 !important; align-self: start; margin-top: 2px; }
    .leads-table .td-phone     { grid-row: 2;      grid-column: 2; padding: 0 !important; font-size: 12px; color: var(--text-muted); }
    .leads-table .td-actions   { grid-row: 2;      grid-column: 3; padding: 0 !important; }

    .leads-table .td-score,
    .leads-table .td-message,
    .leads-table .td-date { display: none !important; }

    .td-lead-name { max-width: none; }

    /* Pagination stacks */
    .leads-pagination {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .page-btn { justify-content: center; }
}

/* ================================================================
   MOBILE 400px — METRICS 1 COLUMN
================================================================ */

@media (max-width: 400px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .metric-value { font-size: 28px; }

    .main-content { padding: 12px; }

    .topbar { padding: 0 12px; }
}

/* ================================================================
   ICON INDIGO (5º card)
================================================================ */

.icon-indigo {
    background: var(--accent-muted);
    color:      var(--accent-hover);
}

.metric-card--link:hover {
    border-color: var(--accent-border);
    box-shadow: 0 8px 32px rgba(99,102,241,0.15);
}

/* ================================================================
   STATUS BADGES — AGENDAMENTOS
================================================================ */

.status-confirmed { background: var(--green-muted);  color: var(--green); }
.status-pending   { background: var(--orange-muted); color: var(--orange); }
.status-cancelled { background: var(--red-muted);    color: var(--red); }
.status-done      {
    background: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
}

/* ================================================================
   PAINEL PRÓXIMOS AGENDAMENTOS (dashboard)
================================================================ */

.panel-upcoming {
    /* BUG 2 FIX: min-height: 0 colapsava o painel; agora cresce naturalmente */
    display: flex;
    flex-direction: column;
}

.upcoming-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 200px;
    padding-bottom: 4px;
}

.upcoming-list::-webkit-scrollbar { width: 3px; }
.upcoming-list::-webkit-scrollbar-thumb { background: var(--bg-overlay); border-radius: 4px; }

.upcoming-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: default;
    transition: background var(--t);
    animation: fadeUp 0.2s ease both;
}

.upcoming-item:hover {
    background: var(--bg-subtle);
}

.upcoming-time-chip {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-secondary);
    background: var(--bg-subtle);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    padding: 3px 7px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.upcoming-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
    border: 1px solid var(--border-strong);
}

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

.upcoming-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.upcoming-type {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Skeleton upcoming */
.upcoming-skeleton {
    height: 52px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.upcoming-skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 1.6s ease-in-out infinite;
}

/* Empty state mini */
.upcoming-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px 16px;
    text-align: center;
    flex: 1;
}

.upcoming-empty-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--r-lg);
    background: var(--bg-overlay);
    border: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.upcoming-empty p {
    font-size: 12.5px;
    color: var(--text-muted);
}

.upcoming-copy-btn {
    margin-top: 12px;
    flex-shrink: 0;
    font-size: 12.5px;
    padding: 10px 14px;
}

/* ================================================================
   ABA AGENDAMENTOS — PAGE HEADER
================================================================ */

.agenda-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.agenda-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.agenda-today-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-muted);
    border: 1px solid var(--accent-border);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-hover);
}

.agenda-copy-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--bg-raised);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    padding: 9px 16px;
    cursor: pointer;
    transition: all var(--t);
    white-space: nowrap;
    min-height: 40px;
}

.agenda-copy-btn:hover {
    background: var(--accent-muted);
    border-color: var(--accent-border);
    color: var(--accent-hover);
}

/* ================================================================
   ABA AGENDAMENTOS — FILTROS
================================================================ */

.agenda-filters {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    overflow-x: auto;
    padding-bottom: 2px;
}

.agenda-filters::-webkit-scrollbar { height: 0; }

.agenda-filter-btn {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 500;
    font-family: inherit;
    padding: 6px 14px;
    cursor: pointer;
    transition: all var(--t);
    white-space: nowrap;
    min-height: 34px;
}

.agenda-filter-btn:hover {
    border-color: var(--border-strong);
    color: var(--text-secondary);
    background: var(--bg-overlay);
}

.agenda-filter-btn.active {
    background: var(--accent-muted);
    border-color: var(--accent-border);
    color: var(--accent-hover);
    font-weight: 600;
}

/* ================================================================
   ABA AGENDAMENTOS — GRID DE CARDS
================================================================ */

.agenda-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    overflow-y: auto;
    min-height: 0;
}

.agenda-grid::-webkit-scrollbar { width: 4px; }
.agenda-grid::-webkit-scrollbar-thumb { background: var(--bg-overlay); border-radius: 4px; }

/* Skeleton card */
.agenda-skeleton {
    height: 200px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    position: relative;
    overflow: hidden;
}

.agenda-skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 1.6s ease-in-out infinite;
}

/* Card */
.agenda-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
    transition: border-color var(--t), box-shadow var(--t);
    animation: fadeUp 0.22s ease both;
    position: relative;
}

.agenda-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.07), transparent);
}

.agenda-card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}

/* Card top */
.agenda-card-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 16px 16px 12px;
}

.agenda-card-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    border: 1px solid transparent;
}

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

.agenda-card-name {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agenda-card-phone {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

/* Card body */
.agenda-card-body {
    padding: 0 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.agenda-card-datetime {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-hover);
}

.agenda-card-type {
    font-size: 12.5px;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.4;
}

.agenda-card-notes {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card footer (actions) */
.agenda-card-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    flex-wrap: wrap;
}

.agenda-action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-secondary);
    font-size: 11.5px;
    font-weight: 500;
    font-family: inherit;
    padding: 5px 10px;
    cursor: pointer;
    transition: all var(--t);
    min-height: 30px;
    white-space: nowrap;
}

.agenda-action-btn:hover {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.agenda-action-danger:hover {
    background: var(--red-muted);
    border-color: rgba(239,68,68,0.3);
    color: var(--red);
}

/* ================================================================
   ABA AGENDAMENTOS — EMPTY STATE
================================================================ */

.agenda-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 72px 20px;
    text-align: center;
}

.agenda-empty-state h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.agenda-empty-state p {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 340px;
    line-height: 1.65;
}

/* ================================================================
   RESPONSIVE — AGENDAMENTOS
================================================================ */

@media (max-width: 1280px) {
    .agenda-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .agenda-page-header { flex-direction: column; align-items: stretch; }
    .agenda-copy-btn    { justify-content: center; }
    .agenda-grid        { grid-template-columns: 1fr; }
    .agenda-card-footer { justify-content: flex-start; }
}

@media (max-width: 640px) {
    .agenda-today-badge { justify-content: center; }
}

/* ================================================================
   GRÁFICOS — Charts Section
================================================================ */

.charts-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex-shrink: 0;
}

.chart-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}

.chart-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
}

.chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

/* Toggle 7 / 30 dias */
.period-toggle {
    display: flex;
    align-items: center;
    background: var(--bg-overlay);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    padding: 2px;
    gap: 2px;
    flex-shrink: 0;
}

.period-btn {
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 500;
    font-family: inherit;
    padding: 4px 11px;
    cursor: pointer;
    transition: background var(--t), color var(--t);
    white-space: nowrap;
    line-height: 1;
}

.period-btn.active {
    background: var(--accent);
    color: #fff;
}

.period-btn:hover:not(.active) {
    background: var(--bg-subtle);
    color: var(--text-secondary);
}

.chart-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chart-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.chart-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.chart-body {
    position: relative;
    width: 100%;
    /* Altura explícita obrigatória para maintainAspectRatio: false funcionar */
    height: 220px;
}

/* Donut: container quadrado-ish centrado para o círculo não ser cortado */
.chart-body--donut {
    height: 220px;
    max-width: 300px;
    margin: 0 auto;
}

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.legend-value {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 1px;
}

@media (max-width: 900px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .chart-body,
    .chart-body--donut {
        height: 200px;
    }
}

