:root {
    --sidebar-width: 250px;
    --sidebar-bg: #141e30;
    --sidebar-fg: #b8c4d9;
    --sidebar-active: #2563eb;
    --topbar-bg: #ffffff;
    --body-bg: #f2f4f8;
    --border-color: #e2e6ee;
}

body {
    background: var(--body-bg);
    font-size: .9rem;
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #141e30 0%, #1e2b47 100%);
    color: var(--sidebar-fg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-brand a {
    color: #fff;
}

.sidebar-logo {
    height: 34px;
    width: auto;
    border-radius: 6px;
}

.brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.sidebar-body {
    flex: 1;
    padding: .75rem 0;
}

.nav-group {
    padding: .6rem 1.25rem .3rem;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #7d8db0;
}

.sidebar .nav-link {
    color: var(--sidebar-fg);
    padding: .55rem 1.25rem;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, .06);
}

.sidebar .nav-link.active {
    color: #fff;
    background: rgba(37, 99, 235, .22);
    border-left-color: var(--sidebar-active);
}

.sidebar .nav-link i {
    font-size: 1rem;
    width: 1.1rem;
    text-align: center;
}

.sidebar-footer {
    padding: .75rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    color: #7d8db0;
}

.main-area {
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: .6rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.content {
    padding: 1.25rem;
    flex: 1;
}

.app-footer {
    padding: .8rem 1.25rem;
    border-top: 1px solid var(--border-color);
    color: #8a93a6;
    font-size: .8rem;
    background: #fff;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .85rem;
    text-transform: uppercase;
}

.user-avatar-sm {
    width: 26px;
    height: 26px;
    font-size: .75rem;
}

.btn-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.notification-menu {
    width: 320px;
    max-height: 420px;
    overflow-y: auto;
}

.stat-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
}

.stat-label {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6b7280;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: #111827;
}

.stat-sub {
    font-size: .78rem;
    color: #6b7280;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0 !important;
    padding: .8rem 1rem;
}

.table thead th {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #6b7280;
    background: #f8fafc;
    border-bottom-width: 1px;
    white-space: nowrap;
}

.perm-group .card-body {
    max-height: 260px;
    overflow-y: auto;
}

.settings-tabs .nav-link {
    color: #556;
}

.settings-tabs .nav-link.active {
    font-weight: 600;
}

.auth-body {
    background: linear-gradient(135deg, #0f172a 0%, #16223c 55%, #1e2b47 100%);
}

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-brand-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 10px 30px rgba(37, 99, 235, .45);
}

.auth-brand h1,
.auth-brand div:not(.auth-brand-icon) {
    color: #fff;
}

.auth-brand .text-muted {
    color: #b8c4d9 !important;
}

.auth-card {
    border: none;
    border-radius: 16px;
}

.error-code {
    font-size: 5rem;
    font-weight: 800;
    color: #94a3b8;
    line-height: 1;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .sidebar-backdrop.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .45);
        z-index: 1035;
    }
    .main-area {
        margin-left: 0;
    }
}

@media print {
    .sidebar, .topbar, .app-footer {
        display: none !important;
    }
    .main-area {
        margin-left: 0;
    }
    .content {
        padding: 0;
    }
}

/* Shared workspace refresh */
:root {
    --sidebar-width: 264px;
    --sidebar-bg: #11192d;
    --sidebar-fg: #c0c9dc;
    --sidebar-active: #7a8bff;
    --topbar-bg: rgba(255, 255, 255, .96);
    --body-bg: #f5f7fb;
    --border-color: #e6eaf2;
    --brand-primary: #5368e8;
    --brand-primary-dark: #4055d4;
    --ink-strong: #19233a;
    --ink-muted: #748097;
    --surface-shadow: 0 8px 28px rgba(26, 39, 71, .055);
}

body {
    color: #35415a;
    font-family: Inter, "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: .925rem;
    line-height: 1.5;
    background-color: var(--body-bg);
    background-image: radial-gradient(ellipse at 68% -12%, rgba(114, 132, 255, .09), transparent 42%);
}

::selection { background: rgba(83, 104, 232, .2); }

:focus-visible {
    outline: 3px solid rgba(83, 104, 232, .45);
    outline-offset: 2px;
}

.sidebar {
    background: linear-gradient(165deg, #11192d 0%, #192641 58%, #1e2d4b 100%);
    box-shadow: 8px 0 24px rgba(15, 23, 42, .08);
    scrollbar-color: rgba(190, 202, 228, .3) transparent;
}

.sidebar-brand {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 1.15rem 1.3rem;
    border-bottom-color: rgba(255, 255, 255, .09);
    background: linear-gradient(165deg, #11192d 0%, #15213b 100%);
}

.brand-icon {
    background: linear-gradient(135deg, #8190ff, #5065e3);
    box-shadow: 0 8px 20px rgba(69, 90, 220, .35);
}

.brand-text { letter-spacing: -.015em; }

.sidebar-body { padding: 1rem .55rem .75rem; }

.nav-group {
    padding: .9rem .8rem .4rem;
    color: #8492b0;
    font-size: .64rem;
    font-weight: 700;
    letter-spacing: .13em;
}

.sidebar .nav { gap: .15rem; }

.sidebar .nav-link {
    min-height: 40px;
    margin: 0 .25rem;
    padding: .55rem .75rem;
    border: 0;
    border-radius: 9px;
    color: #c0c9dc;
    font-size: .86rem;
    font-weight: 500;
    gap: .75rem;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, .075);
    transform: translateX(2px);
}

.sidebar .nav-link.active {
    color: #fff;
    background: linear-gradient(100deg, rgba(103, 122, 255, .25), rgba(103, 122, 255, .12));
    box-shadow: inset 3px 0 0 var(--sidebar-active);
}

.sidebar .nav-link i { font-size: 1rem; color: #aab8d2; }
.sidebar .nav-link.active i { color: #a9b6ff; }
.sidebar-footer { position: sticky; bottom: 0; border-top-color: rgba(255, 255, 255, .09); padding: .9rem 1.25rem; background: #1c2a46; }

.main-area { min-width: 0; }

.topbar {
    min-height: 76px;
    padding: .8rem 1.75rem;
    border-bottom-color: rgba(224, 229, 239, .9);
    background: var(--topbar-bg);
    box-shadow: 0 4px 18px rgba(26, 39, 71, .025);
    backdrop-filter: blur(14px);
}

.topbar-heading { min-width: 0; }
.topbar-title { color: var(--ink-strong); font-size: 1.12rem; font-weight: 700; letter-spacing: -.025em; }
.topbar-hint { max-width: min(38vw, 470px); margin-top: .12rem; overflow: hidden; color: var(--ink-muted); font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.topbar .btn { border-radius: 9px; }
.topbar .btn-outline-secondary { border-color: #e3e7ef; color: #516078; background: #fff; }
.topbar .btn-outline-secondary:hover { border-color: #cbd3e4; background: #f7f8fc; color: #2b3854; }
.quick-create { min-height: 38px; padding-inline: .9rem; border-color: var(--brand-primary); background: var(--brand-primary); box-shadow: 0 4px 12px rgba(83, 104, 232, .2); font-weight: 600; }
.quick-create:hover, .quick-create:focus { border-color: var(--brand-primary-dark); background: var(--brand-primary-dark); }
.dropdown-menu { border-color: #e8ebf2; border-radius: 11px; padding: .45rem; }
.dropdown-item { border-radius: 7px; padding: .55rem .7rem; }

.content { width: 100%; max-width: 1680px; margin: 0 auto; padding: 1.55rem 1.75rem 2rem; }
.app-footer { padding: .75rem 1.75rem; border-color: #e9edf4; color: #8a94a8; background: rgba(255, 255, 255, .72); }

.card {
    border-color: var(--border-color);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--surface-shadow);
}

.card-header { border-color: var(--border-color); background: #fff; }
.table { --bs-table-color: #39455d; --bs-table-hover-bg: #f8f9fd; }
.table > :not(caption) > * > * { padding: .78rem .9rem; border-bottom-color: #edf0f5; }
.table thead th { color: #7c879c; background: #fafbfe; font-size: .68rem; font-weight: 700; letter-spacing: .075em; }
.table-responsive { border-radius: inherit; }

.form-label { margin-bottom: .4rem; color: #35415a; font-size: .83rem; font-weight: 600; }
.form-control, .form-select { min-height: 42px; border-color: #dfe4ed; border-radius: 9px; color: #27334c; }
.form-control:focus, .form-select:focus { border-color: #91a0ff; box-shadow: 0 0 0 .22rem rgba(83, 104, 232, .13); }
.form-text, .text-muted { color: #7b879a !important; }
.btn { border-radius: 9px; font-weight: 550; transition: box-shadow .16s ease, transform .16s ease, background-color .16s ease; }
.btn-primary { border-color: var(--brand-primary); background: var(--brand-primary); }
.btn-primary:hover { border-color: var(--brand-primary-dark); background: var(--brand-primary-dark); box-shadow: 0 5px 12px rgba(83, 104, 232, .18); transform: translateY(-1px); }
.btn-outline-primary { border-color: #c5ccff; color: var(--brand-primary-dark); }
.alert { border: 0; border-radius: 11px; box-shadow: 0 4px 14px rgba(26, 39, 71, .055); }

/* Dashboard */
.dashboard-welcome {
    position: relative;
    display: flex;
    min-height: 194px;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    padding: 1.8rem 2rem;
    border: 1px solid rgba(111, 128, 236, .17);
    border-radius: 17px;
    background: linear-gradient(112deg, #172442 0%, #24355d 61%, #4559aa 100%);
    box-shadow: 0 12px 32px rgba(30, 48, 93, .14);
    color: #fff;
}

.dashboard-welcome::after {
    position: absolute;
    top: -116px;
    right: 15%;
    width: 310px;
    height: 310px;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 50%;
    box-shadow: 0 0 0 34px rgba(255, 255, 255, .025), 0 0 0 68px rgba(255, 255, 255, .02);
    content: "";
}

.dashboard-welcome-copy { position: relative; z-index: 1; max-width: 740px; }
.welcome-eyebrow { display: inline-flex; align-items: center; margin-bottom: .65rem; color: #c4cbff; font-size: .68rem; font-weight: 700; letter-spacing: .14em; }
.dashboard-welcome h2 { margin: 0 0 .35rem; color: #fff; font-size: clamp(1.5rem, 2.3vw, 2rem); font-weight: 700; letter-spacing: -.04em; }
.dashboard-welcome p { max-width: 650px; margin: 0; color: #d4dbee; font-size: .94rem; }
.welcome-meta { display: flex; align-items: center; gap: .8rem; margin-top: 1.1rem; color: #c5cee3; font-size: .76rem; }
.welcome-meta-divider { width: 4px; height: 4px; border-radius: 50%; background: #8798cf; }
.welcome-mark { position: relative; z-index: 1; display: grid; width: 84px; height: 84px; flex: 0 0 84px; place-items: center; margin-right: 2.2rem; border: 1px solid rgba(255,255,255,.19); border-radius: 25px; background: rgba(255,255,255,.08); color: #dce3ff; font-size: 2.35rem; transform: rotate(-8deg); }

.metric-card { position: relative; display: flex; min-height: 178px; flex-direction: column; padding: 1.1rem 1.15rem .95rem; border: 1px solid var(--border-color); border-radius: 14px; background: #fff; box-shadow: var(--surface-shadow); color: inherit; text-decoration: none; transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.metric-card:hover { transform: translateY(-3px); border-color: #d4daf0; box-shadow: 0 13px 30px rgba(26, 39, 71, .09); color: inherit; }
.metric-icon { display: grid; width: 38px; height: 38px; place-items: center; margin-bottom: .65rem; border-radius: 11px; font-size: 1.05rem; }
.metric-sales .metric-icon { background: #eef0ff; color: #5368e8; }
.metric-received .metric-icon { background: #e9f8f2; color: #199873; }
.metric-outstanding .metric-icon { background: #fff6e5; color: #c48516; }
.metric-overdue .metric-icon { background: #fff0ef; color: #d95d51; }
.metric-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .45rem; color: #69758b; font-size: .76rem; font-weight: 600; }
.metric-label small { color: #99a2b2; font-size: .68rem; font-weight: 400; }
.metric-card > strong { margin: .22rem 0 .48rem; overflow: hidden; color: var(--ink-strong); font-size: clamp(1.2rem, 1.6vw, 1.55rem); font-weight: 750; letter-spacing: -.04em; text-overflow: ellipsis; white-space: nowrap; }
.metric-link { margin-top: auto; color: #77839a; font-size: .71rem; }
.metric-link i { margin-left: .15rem; }
.metric-card:hover .metric-link { color: var(--brand-primary); }

.dashboard-card { overflow: hidden; }
.dashboard-card-header { display: flex; min-height: 72px; align-items: center; justify-content: space-between; gap: 1rem; padding: .95rem 1.15rem; }
.section-title { margin: 0; color: var(--ink-strong); font-size: .98rem; font-weight: 700; letter-spacing: -.015em; }
.section-subtitle { margin-top: .2rem; color: #8994a8; font-size: .73rem; }
.section-header-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; background: #f0f2ff; color: #6375e5; }
.chart-note { color: #99a2b3; font-size: .67rem; }
.chart-body { padding: 1rem 1.15rem .65rem; }
.dashboard-chart-wrap { position: relative; min-height: 285px; }
.quick-actions { display: flex; flex-direction: column; padding: .45rem 1rem; }
.quick-action { display: flex; min-height: 72px; align-items: center; gap: .7rem; padding: .7rem .2rem; border-bottom: 1px solid #f0f2f6; color: inherit; text-decoration: none; }
.quick-action:last-child { border-bottom: 0; }
.quick-action > span:nth-child(2) { display: grid; gap: .12rem; }
.quick-action strong, .snapshot-list strong { color: #34415b; font-size: .79rem; font-weight: 650; }
.quick-action small, .snapshot-list small { color: #929caf; font-size: .68rem; }
.quick-action > i { color: #acb5c5; font-size: .77rem; transition: transform .15s ease, color .15s ease; }
.quick-action:hover > i { color: var(--brand-primary); transform: translateX(3px); }
.quick-action:hover strong { color: var(--brand-primary-dark); }
.quick-action-icon, .snapshot-icon { display: grid; width: 39px; height: 39px; flex: 0 0 39px; place-items: center; border-radius: 11px; font-size: 1rem; }
.quick-icon-blue { background: #eef0ff; color: #596de4; }
.quick-icon-green { background: #eaf8f2; color: #199873; }
.quick-icon-violet { background: #f4edff; color: #8a60d0; }
.quick-icon-amber { background: #fff6e6; color: #c48516; }
.snapshot-list { display: flex; flex-direction: column; padding: .35rem 1rem; }
.snapshot-list > a { display: flex; min-height: 67px; align-items: center; gap: .65rem; border-bottom: 1px solid #f0f2f6; color: inherit; text-decoration: none; }
.snapshot-list > a:last-child { border-bottom: 0; }
.snapshot-list > a > span:nth-child(2) { display: grid; gap: .12rem; }
.snapshot-list > a > i { color: #adb5c5; font-size: .75rem; }
.snapshot-list > a:hover strong, .snapshot-list > a:hover > i { color: var(--brand-primary-dark); }
.snapshot-icon { width: 35px; height: 35px; flex-basis: 35px; font-size: .9rem; }
.activity-table { font-size: .79rem; }
.activity-user { display: flex; align-items: center; gap: .65rem; min-width: 145px; }
.activity-user > span:last-child { display: grid; gap: .1rem; }
.activity-user strong { color: #39455d; font-size: .77rem; font-weight: 650; }
.activity-user small { color: #98a2b3; font-size: .67rem; }
.activity-avatar { display: grid; width: 32px; height: 32px; flex: 0 0 32px; place-items: center; border-radius: 10px; background: linear-gradient(135deg, #e8ebff, #f3eaff); color: #6375d7; font-size: .8rem; font-weight: 700; text-transform: uppercase; }
.activity-description { max-width: 340px; color: #758197; }
.activity-time { color: #8a95a8 !important; font-size: .7rem; }
.empty-state { display: flex; min-height: 180px; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; padding: 1.2rem; color: #8a95a8; text-align: center; }
.empty-state-icon { display: grid; width: 42px; height: 42px; place-items: center; margin-bottom: .25rem; border-radius: 14px; background: #f1f3fb; color: #7786dc; font-size: 1.1rem; }
.empty-state strong { color: #49566e; font-size: .86rem; }
.empty-state > span:last-of-type { max-width: 270px; font-size: .74rem; }
.compact-empty { min-height: 235px; }

@media (max-width: 1199.98px) {
    .content { padding-inline: 1.35rem; }
    .topbar { padding-inline: 1.35rem; }
    .dashboard-chart-wrap { min-height: 270px; }
}

@media (max-width: 767.98px) {
    .topbar { min-height: 64px; padding: .65rem .9rem; gap: .5rem; }
    .topbar-title { font-size: 1rem; }
    .topbar-hint { display: none; }
    .topbar .quick-create { width: 38px; height: 38px; padding: 0; }
    .quick-create-label { display: none; }
    .topbar .quick-create .bi { margin: 0 !important; }
    .topbar .dropdown-toggle::after { display: none; }
    .content { padding: 1rem .85rem 1.5rem; }
    .app-footer { padding: .7rem .9rem; font-size: .7rem; }
    .dashboard-welcome { min-height: 175px; padding: 1.25rem 1.2rem; border-radius: 14px; }
    .dashboard-welcome p { max-width: 90%; font-size: .83rem; }
    .welcome-meta { flex-wrap: wrap; gap: .4rem .65rem; font-size: .68rem; }
    .welcome-mark { width: 58px; height: 58px; flex-basis: 58px; margin: 0 .1rem 0 .4rem; border-radius: 18px; font-size: 1.7rem; }
    .metric-card { min-height: 154px; padding: .9rem; }
    .metric-card > strong { font-size: 1.18rem; }
    .dashboard-card-header { align-items: flex-start; padding: .85rem .9rem; }
    .chart-note { display: none; }
    .dashboard-chart-wrap { min-height: 245px; }
    .chart-body { padding: .65rem .6rem .4rem; }
    .activity-table > :not(caption) > * > * { padding: .65rem .7rem; }
    .sidebar { max-width: min(84vw, 300px); }
}

@media (max-width: 420px) {
    .topbar .notification-menu { width: min(320px, calc(100vw - 1rem)); }
    .welcome-mark { display: none; }
    .dashboard-welcome p { max-width: 100%; }
    .welcome-meta-divider { display: none; }
    .metric-card { min-height: 148px; }
    .metric-label { display: grid; gap: .05rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
