:root {
    --sidebar-width: 254px;
    --topbar-height: 64px;
    --sidebar-bg: #0d6efd;
    --primary-color: #6366f1;

    --accent: #7B6CD6;
    --accent-hover: #6B5BCB;
    --ink: #2F2A38;
    --muted: #857E91;
    --border-warm: #EBE5DC;
    --gold-start: #E7BE63;
    --gold-end: #CF9836;
}

body {
    font-family: 'Manrope', system-ui, -apple-system, sans-serif;
    background: #F5F2EC;
}

h1, h2, h3, h4, h5, h6 { font-family: 'Spectral', serif; }

/* ===== Page background wash (sidebar sits opaque on top) ===== */
#wrapper {
    min-height: 100vh;
    background:
        radial-gradient(1100px 520px at 2% -8%, #EFE6F8 0%, rgba(245,242,236,0) 55%),
        radial-gradient(1000px 520px at 100% -8%, #FBEBDD 0%, rgba(245,242,236,0) 52%),
        #F5F2EC;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: linear-gradient(180deg, #3E3057 0%, #2C2340 100%) !important;
    border-right: 1px solid rgba(0,0,0,.18);
    box-shadow: inset -1px 0 0 rgba(255,255,255,.04);
    transition: width 0.25s ease;
    overflow: hidden;
}

.sidebar-brand { height: auto; padding: 14px 12px 18px; white-space: nowrap; }

.brand-badge {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, #D6219C 0%, #8E1166 100%);
    display: flex; align-items: center; justify-content: center;
    color: #FBF7EF;
    font-size: 1.05rem;
    box-shadow: 0 4px 14px rgba(142,17,102,.45);
    flex: 0 0 auto;
}

.brand-title {
    font-family: 'Spectral', serif;
    font-weight: 600;
    font-size: 16px;
    color: #FBF7EF;
    letter-spacing: .2px;
}

.sidebar .nav-link {
    font-size: .84rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background .15s, color .15s;
    border-radius: 11px;
    color: #CDC4DC;
}
.sidebar .nav-link:hover  { color: #fff !important; background: rgba(255,255,255,.08); }

.nav-chip {
    width: 28px; height: 28px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
    font-size: .82rem;
    transition: background .15s;
}

.sidebar-section-title {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: rgba(255,255,255,.42);
    white-space: nowrap;
}

/* ===== Sidebar collapsed ===== */
.sidebar-collapsed { width: 64px !important; }
.sidebar-collapsed .nav-text,
.sidebar-collapsed .sidebar-brand .nav-text { display: none !important; }
.sidebar-collapsed .nav-link { padding-left: 1rem !important; }
.sidebar-collapsed .user-avatar + div { display: none !important; }
.sidebar-collapsed .nav-link i { margin-right: 0 !important; }

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-height);
    background: rgba(255,255,255,.72) !important;
    backdrop-filter: blur(8px);
    border-color: var(--border-warm) !important;
}

/* ===== Content ===== */
#content-wrapper { background: transparent; }

.page-content { min-height: calc(100vh - var(--topbar-height)); }

/* ===== User avatar ===== */
.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-start), var(--gold-end));
    color: #3B2E52;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem;
}

/* ===== Dashboard greeting ===== */
.dash-greeting h1 {
    font-family: 'Spectral', serif;
    font-weight: 600;
    font-size: 1.65rem;
    color: var(--ink);
    letter-spacing: -.2px;
    margin: 0;
}
.dash-greeting p { margin: 6px 0 0; font-size: .85rem; color: var(--muted); }
.dash-greeting b.hl-purple { color: var(--accent); }
.dash-greeting b.hl-peach  { color: #DD8A56; }
.dash-greeting b.hl-mint   { color: #2C8C5A; }

/* ===== Stat / KPI cards ===== */
.stat-card {
    border: none;
    border-radius: 18px;
    box-shadow: 0 1px 3px rgba(45,40,55,.05);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(45,40,55,.09); }

.stat-card.kpi-lav    { background: #EEE9FB; }
.stat-card.kpi-sky    { background: #E2EEFB; }
.stat-card.kpi-mint   { background: #DCF1E6; }
.stat-card.kpi-peach  { background: #FBE6D8; }
.stat-card.kpi-pink   { background: #FBE1EC; }
.stat-card.kpi-butter { background: #FAF0CF; }

.kpi-icon {
    width: 42px; height: 42px;
    border-radius: 11px;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
}
.kpi-value { font-family: 'Spectral', serif; font-weight: 600; font-size: 1.85rem; color: var(--ink); line-height: 1.1; }
.kpi-label { font-size: .8rem; font-weight: 600; margin-top: .15rem; }
.kpi-sub   { font-size: .72rem; margin-top: .1rem; }

.kpi-lav   .kpi-label, .kpi-lav   .kpi-sub { color: #6A6378; }
.kpi-sky   .kpi-label, .kpi-sky   .kpi-sub { color: #3F5D7E; }
.kpi-mint  .kpi-label, .kpi-mint  .kpi-sub { color: #3C6B52; }
.kpi-peach .kpi-label, .kpi-peach .kpi-sub { color: #8A5634; }
.kpi-pink  .kpi-label, .kpi-pink  .kpi-sub { color: #823A5C; }
.kpi-butter .kpi-label, .kpi-butter .kpi-sub { color: #806715; }

.company-logo-thumb { transition: opacity .15s; }
.company-logo-thumb:hover { opacity: .75; }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}

/* ===== Data card / table ===== */
.data-card {
    border: 1px solid var(--border-warm);
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(45,40,55,.05);
    overflow: hidden;
}

.table thead th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
    color: #A39CB0;
    border-bottom: 1px solid #EFEAE2;
    background: transparent;
    padding: 12px 16px;
}
.table tbody td {
    padding: 11px 16px;
    vertical-align: middle;
    color: var(--ink);
    font-size: .85rem;
    border-color: #F3EFE8;
}
.table tbody tr:hover { background: #FAF8F4; }

/* ===== Buttons in tables ===== */
.btn-xs { padding: 2px 9px; font-size: .78rem; border-radius: 6px; }

/* ===== Login page ===== */
.login-card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,.1);
}

/* ===== Badge pills ===== */
.status-badge { font-size: .75rem; padding: 4px 10px; border-radius: 20px; }

/* ===== Pipeline funnel widget ===== */
.funnel-row { display: flex; align-items: center; gap: 14px; }
.funnel-label { width: 150px; font-size: .8rem; font-weight: 600; color: #514B5C; flex-shrink: 0; }
.funnel-track { flex: 1; height: 26px; background: #F4F1EA; border-radius: 8px; overflow: hidden; }
.funnel-fill  { height: 100%; border-radius: 8px; transition: width .3s; }
.funnel-count { width: 34px; text-align: right; font-family: 'Spectral', serif; font-weight: 600; font-size: .95rem; color: var(--ink); }

/* ===== Trend chart widget ===== */
.trend-badge { background: #DCF1E6; color: #2C6B50; padding: 5px 11px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.trend-chart { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; height: 150px; padding-top: 18px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative; }
.trend-bar { width: 100%; max-width: 38px; background: #DDD3F4; border-radius: 7px 7px 3px 3px; }
.trend-bar-active { background: linear-gradient(180deg, #7B6CD6, #9C8FE0); }
.trend-month { font-size: .72rem; color: #A39CB0; font-weight: 600; }
.trend-month-active { color: #6B5BCB; font-weight: 700; }
.trend-amount { position: absolute; top: -22px; font-family: 'Spectral', serif; font-weight: 600; font-size: .8rem; color: #6B5BCB; }

/* ===== Outcome donut widget ===== */
.donut-ring { position: relative; width: 120px; height: 120px; border-radius: 50%; flex: 0 0 auto; }
.donut-hole { position: absolute; inset: 24px; background: #fff; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-total { font-family: 'Spectral', serif; font-weight: 600; font-size: 1.5rem; color: var(--ink); line-height: 1; }
.donut-total-label { font-size: .65rem; color: #938C9F; margin-top: 2px; text-align: center; }
.donut-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.donut-seg-label { font-size: .8rem; font-weight: 600; color: var(--ink); }
.donut-seg-count { font-family: 'Spectral', serif; font-weight: 600; font-size: 1.05rem; color: var(--ink); }
.donut-seg-pct { font-size: .72rem; color: #938C9F; font-weight: 600; }

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        z-index: 1050;
        height: 100%;
        margin-left: calc(-1 * var(--sidebar-width));
    }
    .sidebar.mobile-open { margin-left: 0; }
}

/* ===== Page header area ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-title { font-size: 1.25rem; font-weight: 700; color: #111827; margin: 0; }

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #9ca3af;
}
.empty-state i { font-size: 3rem; margin-bottom: .75rem; display: block; }

/* ===== Dark mode overrides ===== */
[data-bs-theme="dark"] body {
    background-color: #0d1117 !important;
}
[data-bs-theme="dark"] #wrapper {
    background: #0d1117 !important;
}
[data-bs-theme="dark"] #content-wrapper {
    background: #0d1117 !important;
}
[data-bs-theme="dark"] .topbar {
    background: #161b22 !important;
    border-color: #30363d !important;
}
[data-bs-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #3E3057 0%, #2C2340 100%) !important;
    border-color: rgba(0,0,0,.35) !important;
}
[data-bs-theme="dark"] .sidebar .nav-link {
    color: rgba(255,255,255,.5);
}
[data-bs-theme="dark"] .sidebar .nav-link:hover {
    color: #fff !important;
    background: rgba(255,255,255,.07);
}
[data-bs-theme="dark"] .dash-greeting h1 { color: #e6edf3 !important; }
[data-bs-theme="dark"] .dash-greeting p  { color: #8b949e !important; }
[data-bs-theme="dark"] .stat-card {
    box-shadow: 0 1px 4px rgba(0,0,0,.4) !important;
    background: #161b22 !important;
    color: #e6edf3 !important;
}
[data-bs-theme="dark"] .kpi-icon { background: #21262d !important; }
[data-bs-theme="dark"] .kpi-value { color: #e6edf3 !important; }
[data-bs-theme="dark"] .kpi-label,
[data-bs-theme="dark"] .kpi-sub { color: #8b949e !important; }
[data-bs-theme="dark"] .data-card {
    box-shadow: 0 1px 4px rgba(0,0,0,.4) !important;
    background: #161b22 !important;
    border-color: #30363d !important;
}
[data-bs-theme="dark"] .card {
    background-color: #161b22 !important;
    border-color: #30363d !important;
    color: #e6edf3 !important;
}
[data-bs-theme="dark"] .card-header {
    background-color: #161b22 !important;
    border-color: #30363d !important;
    color: #e6edf3 !important;
}
[data-bs-theme="dark"] .alert-light {
    background-color: #21262d !important;
    border-color: #30363d !important;
    color: #c9d1d9 !important;
}
[data-bs-theme="dark"] .table thead th {
    color: #8b949e !important;
    border-color: #30363d !important;
    background: #0d1117 !important;
}
[data-bs-theme="dark"] .table tbody td {
    color: #c9d1d9 !important;
    border-color: #21262d !important;
}
[data-bs-theme="dark"] .table tbody tr:hover {
    background: rgba(255,255,255,.05) !important;
}
[data-bs-theme="dark"] .page-title {
    color: #e6edf3 !important;
}
[data-bs-theme="dark"] .login-card {
    background: #161b22 !important;
    box-shadow: 0 12px 40px rgba(0,0,0,.4) !important;
    color: #e6edf3 !important;
}
[data-bs-theme="dark"] .empty-state {
    color: #8b949e !important;
}
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .input-group-text {
    background-color: #21262d !important;
    border-color: #30363d !important;
    color: #e6edf3 !important;
}
[data-bs-theme="dark"] .modal-content {
    background-color: #161b22 !important;
    border-color: #30363d !important;
    color: #e6edf3 !important;
}
[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    border-color: #30363d !important;
}
[data-bs-theme="dark"] .funnel-track { background: #21262d !important; }
[data-bs-theme="dark"] .funnel-label { color: #c9d1d9 !important; }
[data-bs-theme="dark"] .funnel-count { color: #e6edf3 !important; }
[data-bs-theme="dark"] .trend-bar { background: #30363d !important; }
[data-bs-theme="dark"] .trend-month { color: #8b949e !important; }
[data-bs-theme="dark"] .donut-hole { background: #161b22 !important; }
[data-bs-theme="dark"] .donut-total,
[data-bs-theme="dark"] .donut-seg-label,
[data-bs-theme="dark"] .donut-seg-count { color: #e6edf3 !important; }

/* ===== Welcome / splash screen ===== */
.welcome-page {
    margin: 0;
    overflow: hidden;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #4338ca 100%);
}

.bubble-field {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.bubble {
    position: absolute;
    bottom: -100px;
    width: var(--size, 40px);
    height: var(--size, 40px);
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 50%;
    animation: bubble-rise linear infinite;
}

@keyframes bubble-rise {
    0%   { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
    10%  { opacity: .8; }
    50%  { transform: translateY(-55vh) translateX(15px) scale(1.05); }
    90%  { opacity: .5; }
    100% { transform: translateY(-115vh) translateX(-10px) scale(.9); opacity: 0; }
}

.bubble-burst {
    bottom: auto;
    background: rgba(255, 255, 255, .4);
    border-color: rgba(255, 255, 255, .6);
    animation-name: bubble-burst;
    animation-timing-function: ease-out;
    animation-iteration-count: 1;
}

@keyframes bubble-burst {
    0%   { transform: translateY(0) scale(.4); opacity: .9; }
    100% { transform: translateY(-45vh) scale(1.1); opacity: 0; }
}

.welcome-screen { position: relative; z-index: 2; color: #fff; }

.welcome-logo {
    width: 96px; height: 96px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    backdrop-filter: blur(4px);
}
.welcome-logo img { width: 100%; height: 100%; object-fit: contain; padding: 14px; }
.welcome-logo-fallback i { font-size: 2.6rem; color: #fff; }

.welcome-title { font-size: 2rem; font-weight: 700; margin-bottom: .5rem; }
.welcome-title span { color: #fde68a; }
.welcome-slogan { font-size: 1.05rem; color: rgba(255,255,255,.85); letter-spacing: .02em; }
.welcome-user { color: rgba(255,255,255,.75); font-size: .95rem; }

.welcome-page.welcome-leaving .welcome-screen {
    transition: opacity .3s ease;
    opacity: 0;
}

/* ===== Theme toggle icon transition ===== */
#themeIcon,
#loginThemeIcon { transition: transform .3s ease; }
#themeToggle:hover #themeIcon,
#loginThemeToggle:hover #loginThemeIcon { transform: rotate(20deg); }
