/* =============================================
   DashboardVIP — Design System
   Personalize alterando as variáveis abaixo
   ============================================= */

:root {
    /* Brand */
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;
    --brand-grad: linear-gradient(135deg, #6366f1, #8b5cf6);

    /* Neutrals (dark theme) */
    --bg-base:      #0a0e1a;
    --bg-surface:   #0f1629;
    --bg-elevated:  #141d35;
    --bg-hover:     #1a2540;
    --border:       rgba(255,255,255,.07);
    --border-focus: rgba(99,102,241,.6);

    /* Text */
    --text-primary:   #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted:     #475569;

    /* Accents */
    --indigo:  #6366f1;
    --violet:  #8b5cf6;
    --emerald: #10b981;
    --amber:   #f59e0b;
    --rose:    #f43f5e;

    /* Spacing & radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Sidebar */
    --sidebar-w: 240px;
    --sidebar-collapsed-w: 68px;

    /* Transition */
    --transition: 200ms ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input { font-family: inherit; }
svg { display: block; flex-shrink: 0; }

/* ══════════════════════════════════════
   AUTH — Login Page
   ══════════════════════════════════════ */

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-base);
    position: relative;
    overflow: hidden;
}

/* Background orbs */
.auth-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.auth-bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: .25;
}
.orb-1 {
    width: 500px; height: 500px;
    background: var(--indigo);
    top: -150px; left: -150px;
}
.orb-2 {
    width: 400px; height: 400px;
    background: var(--violet);
    bottom: -120px; right: -100px;
}
.orb-3 {
    width: 300px; height: 300px;
    background: #0ea5e9;
    top: 50%; right: 20%;
    transform: translateY(-50%);
    opacity: .10;
}

.auth-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
}

.auth-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2.25rem;
    backdrop-filter: blur(20px);
    box-shadow: 0 24px 64px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.03);
}

.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-logo {
    display: inline-flex;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 16px rgba(99,102,241,.4));
}
.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin-bottom: .375rem;
}
.auth-subtitle {
    font-size: .875rem;
    color: var(--text-secondary);
}

/* Alert */
.alert {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    margin-bottom: 1.25rem;
}
.alert-error {
    background: rgba(244,63,94,.1);
    border: 1px solid rgba(244,63,94,.25);
    color: #fda4af;
}

/* Form */
.auth-form { display: flex; flex-direction: column; gap: 1.125rem; }
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-label {
    font-size: .8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: .01em;
}
.input-wrapper { position: relative; display: flex; align-items: center; }
.input-icon {
    position: absolute;
    left: .875rem;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition);
}
.form-input {
    width: 100%;
    height: 44px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: .9rem;
    padding: 0 2.75rem 0 2.75rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-input:focus + .input-icon,
.input-wrapper:focus-within .input-icon { color: var(--brand-500); }
.toggle-password {
    position: absolute;
    right: .875rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: color var(--transition);
}
.toggle-password:hover { color: var(--text-secondary); }

/* Buttons */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    height: 44px;
    background: var(--brand-grad);
    color: #fff;
    font-size: .9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    margin-top: .5rem;
    transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
    box-shadow: 0 4px 16px rgba(99,102,241,.35);
    letter-spacing: .01em;
}
.btn-primary:hover {
    opacity: .9;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99,102,241,.45);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary.btn-sm { height: 38px; font-size: .8375rem; padding: 0 1.25rem; }

.auth-footer {
    text-align: center;
    margin-top: 1.75rem;
    font-size: .8rem;
    color: var(--text-muted);
}

/* ══════════════════════════════════════
   APP LAYOUT
   ══════════════════════════════════════ */

.app-body {
    display: flex;
    min-height: 100vh;
    background: var(--bg-base);
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: width var(--transition);
    overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-w); }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    min-height: 64px;
    gap: .5rem;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: .625rem;
    overflow: hidden;
    white-space: nowrap;
}
.sidebar-brand {
    font-weight: 700;
    font-size: .9375rem;
    letter-spacing: -.015em;
    color: var(--text-primary);
}
.sidebar-toggle {
    color: var(--text-secondary);
    padding: .375rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}
.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 1rem .75rem;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: .125rem;
}
.nav-section-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    padding: .75rem .5rem .25rem;
    white-space: nowrap;
    overflow: hidden;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem .75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: .875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    transition: background var(--transition), color var(--transition);
    position: relative;
}
.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.nav-item.active {
    background: rgba(99,102,241,.15);
    color: #a5b4fc;
}
.nav-item.active svg { color: var(--brand-500); }
.nav-badge {
    margin-left: auto;
    font-size: .675rem;
    font-weight: 600;
    padding: .15rem .45rem;
    border-radius: 999px;
    background: rgba(99,102,241,.2);
    color: #a5b4fc;
    flex-shrink: 0;
}

/* Sidebar footer */
.sidebar-footer {
    padding: .875rem .875rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .75rem;
    overflow: hidden;
}
.user-info {
    display: flex;
    align-items: center;
    gap: .625rem;
    flex: 1;
    overflow: hidden;
}
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--brand-grad);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.user-name {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    font-size: .7rem;
    color: var(--text-muted);
}
.btn-logout {
    color: var(--text-muted);
    padding: .375rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: background var(--transition), color var(--transition);
}
.btn-logout:hover {
    background: rgba(244,63,94,.12);
    color: #fda4af;
}

/* ── Main wrapper ── */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-w);
    transition: margin-left var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.sidebar.collapsed ~ .main-wrapper {
    margin-left: var(--sidebar-collapsed-w);
}

/* Topbar */
.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 1rem;
}
.topbar-left { display: flex; flex-direction: column; gap: .1rem; }
.page-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -.01em;
}
.page-subtitle {
    font-size: .75rem;
    color: var(--text-muted);
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: .875rem;
}
.topbar-date {
    display: flex;
    align-items: center;
    gap: .375rem;
    font-size: .8rem;
    color: var(--text-secondary);
}
.status-badge {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .78rem;
    font-weight: 500;
    color: #6ee7b7;
    background: rgba(16,185,129,.1);
    border: 1px solid rgba(16,185,129,.2);
    padding: .3rem .75rem;
    border-radius: 999px;
}
.status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--emerald);
    box-shadow: 0 0 6px var(--emerald);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .4; }
}

/* Content area */
.content {
    flex: 1;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ── KPI Cards ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 640px)  { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: border-color var(--transition), transform var(--transition);
}
.kpi-card:hover {
    border-color: rgba(99,102,241,.3);
    transform: translateY(-2px);
}
.kpi-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.kpi-icon--indigo  { background: rgba(99,102,241,.15); color: #a5b4fc; }
.kpi-icon--violet  { background: rgba(139,92,246,.15); color: #c4b5fd; }
.kpi-icon--emerald { background: rgba(16,185,129,.15);  color: #6ee7b7; }
.kpi-icon--amber   { background: rgba(245,158,11,.15);  color: #fcd34d; }

.kpi-data { display: flex; flex-direction: column; gap: .2rem; }
.kpi-label { font-size: .78rem; color: var(--text-secondary); font-weight: 500; }
.kpi-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.kpi-change { font-size: .75rem; font-weight: 500; }
.kpi-change.up      { color: var(--emerald); }
.kpi-change.down    { color: var(--rose); }
.kpi-change.neutral { color: var(--text-muted); }

/* ── Empty state ── */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-xl);
    gap: 1rem;
}
.empty-icon { margin-bottom: .5rem; }
.empty-title {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -.01em;
}
.empty-desc {
    max-width: 400px;
    font-size: .875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: .5rem;
}

/* ── Alert variants ── */
.alert-success {
    background: rgba(16,185,129,.1);
    border: 1px solid rgba(16,185,129,.25);
    color: #6ee7b7;
}

/* ── Status badge warn ── */
.status-badge--warn {
    background: rgba(245,158,11,.1);
    border-color: rgba(245,158,11,.25);
    color: #fcd34d;
    cursor: pointer;
    transition: background var(--transition);
}
.status-badge--warn:hover { background: rgba(245,158,11,.18); }

/* ── Kommo Connection Card ── */
.kommo-card {
    background: var(--bg-surface);
    border: 1px solid rgba(16,185,129,.25);
    border-radius: var(--radius-lg);
    padding: 1.375rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.kommo-card-header {
    display: flex;
    align-items: center;
    gap: .875rem;
}
.kommo-status-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(16,185,129,.15);
    color: var(--emerald);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.kommo-card-title {
    font-size: .9375rem;
    font-weight: 700;
    color: var(--text-primary);
}
.kommo-card-subtitle {
    font-size: .775rem;
    color: var(--text-secondary);
    margin-top: .1rem;
}
.kommo-card-subtitle code {
    font-size: .72rem;
    background: var(--bg-elevated);
    padding: .1rem .35rem;
    border-radius: 4px;
    color: #a5b4fc;
    font-family: monospace;
}
.kommo-edit-btn {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .375rem;
    font-size: .78rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: .35rem .75rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}
.kommo-edit-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.kommo-fields {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .875rem 1.5rem;
}
@media (max-width: 900px) { .kommo-fields { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 560px) { .kommo-fields { grid-template-columns: 1fr; } }

.kommo-field { display: flex; flex-direction: column; gap: .2rem; }
.kommo-field-label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
}
.kommo-field-value {
    font-size: .9rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ── Settings Page ── */
.settings-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 900px) { .settings-layout { grid-template-columns: 1fr; } }

.settings-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.375rem;
}
.settings-card-header {
    display: flex;
    align-items: flex-start;
    gap: .875rem;
}
.settings-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    background: rgba(99,102,241,.12);
    color: #a5b4fc;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.settings-card-title {
    font-size: .9375rem;
    font-weight: 700;
}
.settings-card-desc {
    font-size: .78rem;
    color: var(--text-secondary);
    margin-top: .15rem;
}
.badge-connected {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .75rem;
    font-weight: 600;
    color: #6ee7b7;
    background: rgba(16,185,129,.1);
    border: 1px solid rgba(16,185,129,.2);
    padding: .3rem .75rem;
    border-radius: 999px;
    white-space: nowrap;
}

.settings-form { display: flex; flex-direction: column; gap: 1.125rem; }

/* Input group (prefixo/sufixo) */
.input-group {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.input-group:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.input-addon, .input-addon-right {
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: .8rem;
    padding: 0 .75rem;
    display: flex;
    align-items: center;
    white-space: nowrap;
    border: none;
    flex-shrink: 0;
}
.input-addon { border-right: 1px solid var(--border); }
.input-addon-right { border-left: 1px solid var(--border); }
.input-grouped {
    flex: 1;
    height: 44px;
    background: var(--bg-elevated);
    border: none;
    color: var(--text-primary);
    font-size: .9rem;
    padding: 0 .875rem;
    outline: none;
}
.input-grouped::placeholder { color: var(--text-muted); }

.form-hint {
    font-size: .77rem;
    color: var(--text-muted);
    margin-top: .1rem;
}
.form-hint code {
    background: var(--bg-elevated);
    padding: .1rem .3rem;
    border-radius: 4px;
    color: #a5b4fc;
    font-size: .72rem;
}

.settings-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .75rem;
    padding-top: .375rem;
}
.btn-ghost {
    height: 40px;
    padding: 0 1.125rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    display: flex; align-items: center;
    transition: background var(--transition), color var(--transition);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-ghost-danger {
    color: #fda4af;
    border-color: rgba(244,63,94,.28);
    background: rgba(244,63,94,.08);
}
.btn-ghost-danger:hover {
    color: #fecdd3;
    border-color: rgba(244,63,94,.42);
    background: rgba(244,63,94,.16);
}

/* Guide sidebar */
.settings-guide {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.guide-title {
    font-size: .9rem;
    font-weight: 700;
    color: var(--text-primary);
}
.guide-steps {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: .875rem;
}
.guide-steps li {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
}
.step-num {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(99,102,241,.15);
    color: #a5b4fc;
    font-size: .75rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    margin-top: .1rem;
}
.guide-steps strong {
    display: block;
    font-size: .8375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: .15rem;
}
.guide-steps p {
    font-size: .78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.guide-steps em {
    font-style: normal;
    color: #a5b4fc;
}
.guide-warning {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    font-size: .77rem;
    color: #fcd34d;
    background: rgba(245,158,11,.08);
    border: 1px solid rgba(245,158,11,.2);
    border-radius: var(--radius-sm);
    padding: .625rem .75rem;
    line-height: 1.5;
    flex-shrink: 0;
}

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}
.tab {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .625rem 1rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--text-primary); }
.tab.active {
    color: var(--brand-500);
    border-bottom-color: var(--brand-500);
}

/* ── Goals form ── */
.goals-period-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}
.form-select {
    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='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2.25rem !important;
    cursor: pointer;
}
.form-select option { background: var(--bg-elevated); }

/* ── Goals history ── */
.goals-history { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1.25rem; }
.goals-history-title {
    font-size: .875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .875rem;
}
.goals-table-wrap { overflow-x: auto; }
.goals-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.goals-table th {
    text-align: left;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    padding: .375rem .75rem;
    border-bottom: 1px solid var(--border);
}
.goals-table td {
    padding: .625rem .75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}
.goals-table tr:last-child td { border-bottom: none; }
.goals-value { font-weight: 600; color: var(--text-primary); }
.goals-edit-link {
    font-size: .78rem;
    color: var(--brand-500);
    font-weight: 500;
}
.goals-edit-link:hover { text-decoration: underline; }

/* ── Period filter bar ── */
.period-filter-bar {
    display: flex;
    gap: .375rem;
    flex-wrap: wrap;
}

/* ── KPI 3-col variant ── */
.kpi-grid--3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .kpi-grid--3 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 560px) { .kpi-grid--3 { grid-template-columns: 1fr; } }

/* ── Panels grid (2 col) ── */
.panels-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 900px) { .panels-grid { grid-template-columns: 1fr; } }

/* ── Dashboard pages (pages/) shared layout ── */
.page-header-meta {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}
.date-filter {
    display: flex;
    align-items: center;
    gap: .375rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .3rem .75rem;
    font-size: .8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color var(--transition);
}
.date-filter:hover { border-color: rgba(99,102,241,.4); color: var(--text-primary); }
.date-filter.active { border-color: var(--brand-500); color: var(--brand-500); }

/* ── Data table ── */
.data-table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.data-table th {
    text-align: left;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table th.right, .data-table td.right { text-align: right; }
.data-table td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table .td-strong { font-weight: 600; color: var(--text-primary); }
.data-table .td-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
}
.badge-won  { background: rgba(16,185,129,.12);  color: #6ee7b7; }
.badge-lost { background: rgba(244,63,94,.12);   color: #fda4af; }
.badge-open { background: rgba(99,102,241,.12);  color: #a5b4fc; }
.badge-warn { background: rgba(245,158,11,.12);  color: #fcd34d; }

/* ── Panel card ── */
.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    gap: .75rem;
}
.panel-title {
    font-size: .9rem;
    font-weight: 700;
    color: var(--text-primary);
}
.panel-subtitle {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: .1rem;
}
.panel-body { padding: 1.25rem; flex: 1; }

/* ── Stat row (for detail panels) ── */
.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .625rem 0;
    border-bottom: 1px solid var(--border);
}
.stat-row:last-child { border-bottom: none; }
.stat-label { font-size: .875rem; color: var(--text-secondary); }
.stat-val   { font-size: .875rem; font-weight: 600; color: var(--text-primary); }

/* ── Progress bar ── */
.progress-bar {
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 999px;
    overflow: hidden;
    margin-top: .375rem;
}
.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--brand-grad);
    transition: width .4s ease;
}
.progress-fill--emerald { background: linear-gradient(90deg,#059669,#10b981); }
.progress-fill--amber   { background: linear-gradient(90deg,#d97706,#f59e0b); }
.progress-fill--rose    { background: linear-gradient(90deg,#e11d48,#f43f5e); }

/* ── Loading state ── */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    padding: 3rem 2rem;
    color: var(--text-muted);
    font-size: .875rem;
}
.spinner {
    width: 28px; height: 28px;
    border: 2px solid var(--border);
    border-top-color: var(--brand-500);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── UX loading/progressive render ── */
[data-defer-block] {
    opacity: 0;
    transform: translateY(8px);
    filter: blur(2px);
    transition: opacity 260ms ease, transform 260ms ease, filter 260ms ease;
}
[data-defer-block].is-ready {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
}

.sync-meta {
    font-size: .74rem;
    color: var(--text-secondary);
    background: rgba(99,102,241,.08);
    border: 1px solid rgba(99,102,241,.24);
    border-radius: 999px;
    padding: .25rem .6rem;
    white-space: nowrap;
}
.sync-meta--stale {
    color: #fcd34d;
    background: rgba(245,158,11,.12);
    border-color: rgba(245,158,11,.3);
}
.sync-meta--network {
    color: #6ee7b7;
    background: rgba(16,185,129,.1);
    border-color: rgba(16,185,129,.22);
}

.app-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background:
        radial-gradient(1200px 500px at 15% 5%, rgba(99,102,241,.10), rgba(10,14,26,0) 60%),
        radial-gradient(900px 450px at 80% 0%, rgba(14,165,233,.08), rgba(10,14,26,0) 60%),
        rgba(10, 14, 26, .78);
    backdrop-filter: blur(4px) saturate(1.05);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
}
.app-loading-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}
.app-loading-shell {
    max-width: 1020px;
    margin: 70px auto 0;
    padding: 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .95rem;
}
.app-loading-status {
    background: rgba(15,22,41,.92);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: .85rem 1rem;
    display: flex;
    align-items: center;
    gap: .8rem;
    box-shadow: 0 10px 32px rgba(0,0,0,.22);
}
.app-loading-badge {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(99,102,241,.2);
    border: 1px solid rgba(99,102,241,.35);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.app-loading-badge::after {
    content: '';
    position: absolute;
    inset: 7px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.15);
    border-top-color: #a5b4fc;
    animation: spin .8s linear infinite;
}
.app-loading-copy {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;
}
.app-loading-title {
    font-size: .86rem;
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-loading-title strong {
    color: #c7d2fe;
    font-weight: 700;
}
.app-loading-subtitle {
    font-size: .74rem;
    color: var(--text-secondary);
}
.app-loading-progress {
    width: 100%;
    height: 3px;
    border-radius: 999px;
    background: rgba(255,255,255,.06);
    overflow: hidden;
}
.app-loading-progress > span {
    display: block;
    width: 45%;
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #22d3ee);
    border-radius: 999px;
    animation: loadingBar 1.15s ease-in-out infinite;
}
.app-loading-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .875rem;
}
@media (max-width: 1100px) {
    .app-loading-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
    .app-loading-row { grid-template-columns: 1fr; }
}
.app-loading-card {
    height: 94px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    overflow: hidden;
    position: relative;
}
.app-loading-card::before {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-120%);
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,.08) 45%,
        rgba(255,255,255,0) 100%
    );
    animation: skeletonShimmer 1.2s infinite;
}
.app-loading-row--panels .app-loading-card {
    height: 230px;
}
@keyframes loadingBar {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(240%); }
}
@keyframes skeletonShimmer {
    100% { transform: translateX(120%); }
}

.section-error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .75rem .9rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(244,63,94,.3);
    background: rgba(244,63,94,.1);
    color: #fda4af;
    font-size: .8rem;
}

.btn-retry-inline {
    padding: .25rem .65rem;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.18);
    color: var(--text-primary);
    font-size: .72rem;
    font-weight: 600;
    transition: background var(--transition), border-color var(--transition);
}
.btn-retry-inline:hover {
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.3);
}

.async-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 220px;
}
.async-placeholder {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.async-placeholder-head {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.async-placeholder-title {
    font-size: .875rem;
    font-weight: 600;
    color: var(--text-primary);
}
.async-placeholder-subtitle {
    font-size: .78rem;
    color: var(--text-secondary);
    margin-top: .15rem;
}
.async-placeholder-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .875rem;
}
.async-placeholder-grid--three {
    grid-template-columns: repeat(3, 1fr);
}
.async-placeholder-panels {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .875rem;
}
.async-placeholder-card {
    min-height: 90px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    overflow: hidden;
    position: relative;
}
.async-placeholder-card--tall {
    min-height: 210px;
}
.async-placeholder-card::before {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-120%);
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,.08) 45%,
        rgba(255,255,255,0) 100%
    );
    animation: skeletonShimmer 1.2s infinite;
}
.section-error-block {
    border: 1px solid rgba(244,63,94,.3);
    background: rgba(244,63,94,.1);
    border-radius: var(--radius-md);
    color: #fda4af;
    padding: .9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .55rem;
}
.section-error-block-title {
    font-size: .85rem;
    font-weight: 600;
}
.section-error-block-detail {
    font-size: .78rem;
    color: #fecdd3;
}
.async-cache-meta {
    display: none !important;
}

@media (max-width: 1100px) {
    .async-placeholder-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .async-placeholder-grid--three {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 720px) {
    .async-placeholder-grid,
    .async-placeholder-grid--three,
    .async-placeholder-panels {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-loading-overlay,
    [data-defer-block],
    .app-loading-progress > span,
    .app-loading-card::before,
    .app-loading-badge::after,
    .async-placeholder-card::before {
        animation: none !important;
        transition: none !important;
    }
    [data-defer-block] {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
    }
}

/* ── Funnel stages ── */
.funnel-stages { display: flex; flex-direction: column; gap: .875rem; }
.funnel-stage { display: flex; align-items: center; gap: 1rem; }
.funnel-stage-info { min-width: 220px; }
.funnel-stage-name { font-size: .875rem; font-weight: 600; color: var(--text-primary); display: block; margin-bottom: .2rem; }
.funnel-stage-meta { display: flex; gap: .75rem; flex-wrap: wrap; }
.funnel-count, .funnel-value { font-size: .78rem; color: var(--text-secondary); }
.funnel-conv { font-size: .75rem; color: var(--text-muted); font-style: italic; }
.funnel-bar-wrap { flex: 1; display: flex; align-items: center; gap: .625rem; }
.funnel-bar-bg { flex: 1; height: 20px; background: var(--bg-elevated); border-radius: 4px; overflow: hidden; }
.funnel-bar-fill { height: 100%; border-radius: 4px; opacity: .85; transition: width .4s ease; }
.funnel-pct { font-size: .75rem; font-weight: 600; color: var(--text-secondary); min-width: 32px; text-align: right; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 9999px; }

/* ══════════════════════════════════════
   REGISTRO DE VENDAS — Sales Form
   ══════════════════════════════════════ */

/* --- Sections --- */
.sale-form-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: .875rem;
    overflow: hidden;
}
.sale-form-section-header {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}
.sale-section-num {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--brand-grad);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sale-section-title {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.sale-form-body { padding: 1.125rem 1.25rem; }

/* --- Grids --- */
.sale-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .875rem; }
.sale-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .875rem; }
.sale-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .875rem; }
@media (max-width: 900px) {
    .sale-grid-3, .sale-grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .sale-grid-2, .sale-grid-3, .sale-grid-4 { grid-template-columns: 1fr; }
}

/* --- Form groups --- */
.sale-form-group { display: flex; flex-direction: column; gap: .3rem; }
.sale-form-group label {
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.sale-form-group label .req { color: var(--rose); }

/* --- Inputs --- */
.sale-input {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: .875rem;
    padding: .55rem .75rem;
    width: 100%;
    font-family: inherit;
    transition: border-color var(--transition);
}
.sale-input:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.sale-input::placeholder { color: var(--text-muted); }
.sale-input option { background: var(--bg-elevated); }
textarea.sale-input { min-height: 72px; resize: vertical; }
.sale-input-note { font-size: .72rem; color: var(--text-muted); margin-top: .2rem; }

/* --- Radio pills --- */
.radio-pills { display: flex; gap: .375rem; flex-wrap: wrap; }
.radio-pill { position: relative; cursor: pointer; }
.radio-pill input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.radio-pill span {
    display: block;
    padding: .4rem .9rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-base);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.radio-pill:hover span { border-color: var(--border-focus); color: var(--text-primary); }
.radio-pill input:checked + span { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }
.radio-pill--success input:checked + span { background: #059669; border-color: #059669; }
.radio-pill--partial input:checked + span { background: #d97706; border-color: #d97706; }
.radio-pill--danger  input:checked + span { background: #e11d48; border-color: #e11d48; }

/* --- Conditional slide --- */
.sale-conditional {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height .35s ease, opacity .25s ease;
}
.sale-conditional.open { max-height: 400px; opacity: 1; }
.sale-conditional-inner {
    padding-top: .875rem;
    margin-top: .5rem;
    border-top: 1px dashed rgba(255,255,255,.08);
}

/* --- Preview bar --- */
.sale-preview-bar {
    display: flex;
    gap: 2rem;
    align-items: center;
    padding: 1rem 1.25rem;
    background: rgba(99,102,241,.07);
    border: 1px solid rgba(99,102,241,.18);
    border-radius: var(--radius-md);
    margin-bottom: .875rem;
    flex-wrap: wrap;
}
.sale-preview-item { display: flex; flex-direction: column; gap: .15rem; }
.sale-preview-label { font-size: .68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.sale-preview-value { font-size: 1.05rem; font-weight: 700; color: #818cf8; }
.sale-preview-value.green { color: #6ee7b7; }

/* --- Form actions --- */
.sale-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: .625rem;
    padding: .875rem 0 0;
}
.btn-cancel-sale {
    padding: .55rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.btn-cancel-sale:hover { border-color: var(--border-focus); color: var(--text-primary); }

/* --- Sales list badges --- */
.badge-entregue  { background: rgba(16,185,129,.12); color: #6ee7b7; }
.badge-pendente  { background: rgba(245,158,11,.12);  color: #fcd34d; }
.badge-pagou-sim { background: rgba(16,185,129,.12); color: #6ee7b7; }
.badge-pagou-parte { background: rgba(245,158,11,.12); color: #fcd34d; }
.badge-pagou-nao { background: rgba(244,63,94,.12); color: #fda4af; }

/* --- Sales filter bar --- */
.sales-filters {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.25rem;
}
.sales-filters select, .sales-filters input[type="text"] {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: .4rem .65rem;
    font-size: .8rem;
    font-family: inherit;
}
.sales-filters select:focus, .sales-filters input:focus {
    outline: none;
    border-color: var(--border-focus);
}
.btn-new-sale {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    background: var(--brand-grad);
    border-radius: var(--radius-sm);
    font-size: .8rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    transition: opacity var(--transition);
    white-space: nowrap;
}
.btn-new-sale:hover { opacity: .88; }

/* --- Row action buttons --- */
.row-action {
    padding: .25rem .5rem;
    border-radius: 5px;
    font-size: .72rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    background: transparent;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}
.row-action:hover { border-color: var(--border-focus); color: var(--text-primary); background: var(--bg-hover); }
.row-action--danger:hover { border-color: rgba(244,63,94,.5); color: #fda4af; background: rgba(244,63,94,.06); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════════════════════════════════
   Ranking de Vendedores
═══════════════════════════════════════ */

/* Progress bar */
.rank-progress-wrap {
    background: rgba(255,255,255,.09);
    border-radius: 99px;
    height: 7px;
    overflow: hidden;
    min-width: 80px;
}
.rank-progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width .5s ease;
    min-width: 3px;
}

/* Position badge */
.rank-pos {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    font-size: .85rem;
    font-weight: 700;
    color: var(--text-muted);
}
.rank-pos.gold   { color: #fbbf24; }
.rank-pos.silver { color: #94a3b8; }
.rank-pos.bronze { color: #cd7c4f; }
