:root {
    --app-bg: #f5f7fb;
    --app-sidebar-bg: #ffffff;
    --app-sidebar-border: #e6ebf3;
    --app-text: #21304d;
    --app-muted: #7f8ba3;
    --app-primary: #5b5ce9;
    --app-primary-soft: #eef0ff;
    --app-card-shadow: 0 12px 32px rgba(30, 41, 59, .07);
    --app-sidebar-width: 286px;
    --app-radius: 1.1rem;
}

html, body { min-height: 100%; }
body { background: var(--app-bg); color: var(--app-text); }
body.app-authenticated { padding-left: calc(var(--app-sidebar-width) + 1.5rem); }
a { color: var(--app-primary); }

main.container, main.container-fluid { transition: margin-left .25s ease, width .25s ease; }
body.app-authenticated main.container, body.app-authenticated main.container-fluid {
    max-width: none; width: calc(100% - 1.5rem); margin-left: 0; padding-left: 1.25rem; padding-right: 1.25rem;
}

.card, .app-surface {
    border: 1px solid rgba(230, 235, 243, .95);
    border-radius: 1.25rem;
    box-shadow: var(--app-card-shadow);
    background: #fff;
}
.card-header { background: transparent !important; border-bottom: 1px solid #eef2f8; padding: 1.1rem 1.3rem 0.9rem; }
.card-body { padding: 1.25rem 1.3rem; }
.table-responsive { border-radius: 1rem; }
.table > :not(caption) > * > * { padding-top: .9rem; padding-bottom: .9rem; border-bottom-color: #eef2f8; }
.table thead th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: #7b879d; font-weight: 700; }
.list-group-item { border-color: #eef2f8; }
.list-group-item:first-child { border-top: 0; }
.form-control, .form-select {
    min-height: 44px; border-radius: .9rem; border-color: #e4eaf3; background: #fbfcfe; box-shadow: none;
}
.form-control:focus, .form-select:focus {
    border-color: #d8dffd; box-shadow: 0 0 0 .2rem rgba(91, 92, 233, .08); background: #fff;
}
.btn { border-radius: .95rem; font-weight: 600; }
.btn-primary { background: linear-gradient(135deg, #6c70ff 0%, #5b5ce9 100%); border-color: transparent; box-shadow: 0 10px 20px rgba(91, 92, 233, .18); }
.btn-primary:hover { background: linear-gradient(135deg, #6367ff 0%, #5052e0 100%); border-color: transparent; }
.btn-light { background: #fff; }
.badge { border-radius: 999px; padding: .45rem .7rem; }

.app-page-header {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem;
}
.app-page-title h1 { margin-bottom: .3rem; font-size: 1.7rem; }
.app-page-title p { margin: 0; color: var(--app-muted); }
.app-toolbar { display: flex; gap: .6rem; flex-wrap: wrap; }
.app-filter-bar { margin-bottom: 1.25rem; }
.app-filter-bar .card-body { padding-bottom: 1rem; }
.app-context-chip {
    background: #f7f9fc; border: 1px solid #edf1f7; border-radius: 1rem; padding: .85rem 1rem;
}
.app-kpi { font-size: 2rem; font-weight: 700; line-height: 1.1; margin-top: .35rem; }
.label-muted { font-size: .875rem; color: var(--app-muted); }
.copy-btn { min-width: 40px; }
.kpi { font-size: 1.8rem; font-weight: 700; margin-top: .3rem; }

.stat-card .icon {
    width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center; border-radius: 16px;
    font-size: 1.25rem; background: rgba(91, 92, 233, .10); color: var(--app-primary);
}
.stat-card .card-body { display: flex; justify-content: space-between; align-items: center; }

.app-mini-card {
    border: 1px solid #edf1f7; border-radius: 1rem; background: #fbfcfe; padding: 1rem;
}
.app-mini-card h3 { font-size: 1rem; margin-bottom: .3rem; }
.app-empty { color: var(--app-muted); background: #fbfcfe; border: 1px dashed #dfe6f2; border-radius: 1rem; padding: 1rem; }
.app-grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }

.app-sidebar {
    position: fixed; top: 1rem; left: 1rem; bottom: 1rem; width: var(--app-sidebar-width); background: var(--app-sidebar-bg);
    border: 1px solid var(--app-sidebar-border); border-radius: 1.75rem; box-shadow: var(--app-card-shadow); z-index: 1030; overflow: hidden;
}
.app-sidebar-inner { height: 100%; display: flex; flex-direction: column; padding: 1.35rem; }
.app-brand-wrap { margin-bottom: 1.25rem; }
.app-brand { display: flex; align-items: center; gap: .9rem; }
.app-brand-logo, .app-mobile-brand-badge {
    width: 48px; height: 48px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #6c70ff 0%, #5b5ce9 100%); color: #fff; font-weight: 700; box-shadow: 0 10px 20px rgba(91, 92, 233, .25);
}
.app-brand-text, .app-mobile-brand span:last-child { display: flex; flex-direction: column; line-height: 1.15; }
.app-brand-text strong, .app-mobile-brand strong { font-size: 1.15rem; color: var(--app-text); }
.app-brand-text small, .app-mobile-brand small { color: var(--app-muted); margin-top: .2rem; }
.app-sidebar-search { position: relative; margin-bottom: 1rem; }
.app-sidebar-search i { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: #9aa6bd; }
.app-sidebar-search .form-control { padding-left: 2.55rem; }
.app-nav { display: flex; flex-direction: column; gap: .28rem; overflow: auto; padding-right: .15rem; }
.app-nav-link {
    display: flex; align-items: center; gap: .8rem; min-height: 46px; padding: .75rem .9rem; border-radius: .95rem;
    color: #6f7b94; text-decoration: none; font-weight: 500; transition: background-color .18s ease, color .18s ease, transform .18s ease;
}
.app-nav-link:hover { background: #f4f6fb; color: var(--app-text); transform: translateX(2px); }
.app-nav-link.active { background: var(--app-primary-soft); color: var(--app-primary); }
.app-sidebar-footer { margin-top: auto; padding-top: 1rem; }
.app-user-card {
    display: flex; align-items: center; gap: .8rem; padding: .95rem 1rem; background: #f7f9fc; border: 1px solid #edf1f7; border-radius: 1rem;
}
.app-user-avatar {
    width: 42px; height: 42px; border-radius: 14px; background: var(--app-primary-soft); color: var(--app-primary); display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.app-mobile-topbar, .app-sidebar-backdrop { display: none; }
.login-wrap { min-height: 100vh; }

.timeline { position: relative; margin: 0; padding: 0; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 0; bottom: 0; width: 2px; background: #dfe5ef; }
.timeline li { position: relative; padding-left: 2.25rem; margin-bottom: 1rem; }
.timeline-dot {
    position: absolute; left: 0; top: .2rem; width: 24px; height: 24px; border-radius: 999px; background: #fff; border: 2px solid #ced8ea;
}

@media (max-width: 991.98px) {
    body.app-authenticated { padding-left: 0; }
    .app-sidebar {
        top: 0; left: 0; bottom: 0; border-radius: 0 1.5rem 1.5rem 0; transform: translateX(-100%); transition: transform .25s ease;
    }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-mobile-topbar {
        display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1rem .5rem;
    }
    .app-sidebar-backdrop {
        position: fixed; inset: 0; background: rgba(15, 23, 42, .32); z-index: 1020;
    }
    body.sidebar-open .app-sidebar-backdrop { display: block; }
    body.app-authenticated main.container, body.app-authenticated main.container-fluid {
        width: 100%; padding-left: 1rem; padding-right: 1rem;
    }
    .app-page-header { flex-direction: column; align-items: stretch; }
}


.app-breadcrumb-bar {
    position: sticky;
    top: 0;
    z-index: 1010;
    margin-left: calc(var(--app-sidebar-width) + 1rem);
    margin-right: 1rem;
    margin-top: 1rem;
    padding: .8rem 1.1rem;
    background: rgba(255,255,255,.92);
    border: 1px solid #e8edf6;
    border-radius: 1rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(15,23,42,.05);
}
.app-breadcrumb-bar .breadcrumb-item,
.app-breadcrumb-bar .breadcrumb-item a { color: #73809a; text-decoration: none; font-weight: 500; }
.app-breadcrumb-bar .breadcrumb-item.active { color: var(--app-text); }
.app-breadcrumb-bar .breadcrumb-item + .breadcrumb-item::before { color: #b4bfd4; }

.app-nav-group-title {
    font-size: .74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #9aa6bd;
    padding: .75rem .95rem .35rem;
}
.app-nav-link { justify-content: space-between; }
.app-nav-icon { width: 20px; display: inline-flex; justify-content: center; }
.app-nav-text { flex: 1; margin-left: .15rem; }
.app-nav-badge {
    min-width: 22px; height: 22px; border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .72rem; font-weight: 700; color: #fff; background: #ef4444;
    box-shadow: 0 6px 14px rgba(239,68,68,.22);
}
.app-mobile-work-tabs {
    display: none;
}
.mobile-site-primary {
    display: none;
}
@media (max-width: 991.98px) {
    .app-breadcrumb-bar {
        margin: .25rem 1rem 0;
        top: 0;
    }
    .app-mobile-work-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0,1fr));
        gap: .65rem;
        margin-bottom: 1rem;
    }
    .mobile-site-primary {
        display: block;
    }
}
