:root {
    --app-ink: #172033;
    --app-muted: #667085;
    --app-line: #e5e9f0;
    --app-canvas: #f4f6f9;
    --app-paper: #fff;
    --app-brand: #4f46e5;
    --app-brand-soft: #eeedff;
    --app-green: #18876a;
    --app-shadow: 0 12px 36px rgba(22, 34, 58, .07);
    font-family: 'Inter', 'Cairo', sans-serif;
}

.app-shell {
    min-height: 100dvh;
    background: var(--app-canvas);
    color: var(--app-ink);
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    width: 232px;
    padding: 20px 14px 16px;
    background: var(--app-paper);
    border-right: 1px solid var(--app-line);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 10px;
    color: var(--app-ink);
    font: 800 1.28rem 'Inter', sans-serif;
    text-decoration: none;
}

.app-brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 10px;
    background: var(--app-brand);
    color: #fff;
    font-size: .78rem;
}

.app-nav-label {
    padding: 24px 12px 8px;
    color: #98a1b2;
    font-size: .64rem;
    font-weight: 800;
}

.app-nav {
    display: grid;
    gap: 4px;
}

.app-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 8px;
    color: #667085;
    font-size: .83rem;
    font-weight: 650;
    text-decoration: none;
    transition: background .16s ease, color .16s ease;
}

.app-nav a i { width: 18px; text-align: center; font-size: .9rem; }
.app-nav a:hover { background: #f4f5fa; color: var(--app-ink); }
.app-nav a.active { background: var(--app-brand-soft); color: var(--app-brand); }

.app-sidebar-bottom { margin-top: auto; }

.app-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 4px 0;
    padding: 14px 8px 0;
    border-top: 1px solid var(--app-line);
}

.app-user-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    border-radius: 50%;
    background: #e8efff;
    color: #3157a4;
    font-size: .72rem;
    font-weight: 800;
}

.app-user-meta { min-width: 0; }
.app-user-meta strong, .app-user-meta span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-user-meta strong { font-size: .72rem; }
.app-user-meta span { margin-top: 2px; color: var(--app-muted); font-size: .65rem; }

.app-main {
    min-height: 100dvh;
    margin-left: 232px;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 66px;
    padding: 0 34px;
    border-bottom: 1px solid var(--app-line);
    background: rgba(255,255,255,.93);
    backdrop-filter: blur(16px);
}

.app-topbar-actions { display: flex; align-items: center; gap: 10px; }
.app-status { display: flex; align-items: center; gap: 7px; color: var(--app-muted); font-size: .72rem; }
.app-status i { color: var(--app-green); font-size: .55rem; }
.app-icon-button { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--app-line); border-radius: 8px; background: #fff; color: #667085; cursor: pointer; }
.app-primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 15px; border: 0; border-radius: 8px; background: var(--app-brand); color: #fff; font: 700 .77rem 'Inter','Cairo',sans-serif; text-decoration: none; cursor: pointer; box-shadow: 0 5px 13px rgba(79,70,229,.17); }
.app-primary-button:hover { background: #4338ca; }
.app-outline-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--app-line); border-radius: 8px; background: #fff; color: var(--app-ink); font: 700 .75rem 'Inter','Cairo',sans-serif; text-decoration: none; cursor: pointer; }

.app-page { width: min(1440px, 100%); margin: 0 auto; padding: 34px 36px 56px; }
.app-footer { padding: 18px 36px 26px; border-top: 1px solid var(--app-line); color: #8a93a3; font-size: .67rem; text-align: center; }
.app-footer a { color: inherit; text-decoration: none; }
.app-mobile-nav { display: none; }
.app-menu-button { display: none; }

.app-global-nav {
    position: fixed;
    inset: 0 0 auto;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 28px;
    height: 64px;
    padding: 0 max(24px, calc((100vw - 1440px) / 2));
    border-bottom: 1px solid var(--app-line);
    background: rgba(255,255,255,.96);
    color: var(--app-ink);
    backdrop-filter: blur(16px);
}

.app-global-brand {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
    color: var(--app-ink);
    font: 800 1.25rem 'Inter', 'Cairo', sans-serif;
    text-decoration: none;
}

.app-global-brand span {
    display: grid;
    width: 30px;
    height: 30px;
    margin-inline-end: 4px;
    place-items: center;
    border-radius: 8px;
    background: var(--app-brand);
    color: #fff;
    font-size: .72rem;
}

.app-global-links { display: flex; align-items: center; gap: 3px; min-width: 0; }
.app-global-links a { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 10px; border-radius: 7px; color: var(--app-muted); font-size: .7rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
.app-global-links a:hover { background: #f4f5fa; color: var(--app-ink); }
.app-global-links a.active { background: var(--app-brand-soft); color: var(--app-brand); }
.app-global-links i { font-size: .76rem; }
.app-global-actions { display: flex; align-items: center; gap: 9px; margin-inline-start: auto; }
.app-global-theme, .app-global-menu { display: grid; width: 35px; height: 35px; place-items: center; border: 1px solid var(--app-line); border-radius: 8px; background: transparent; color: var(--app-muted); cursor: pointer; }
.app-global-account { display: inline-flex; align-items: center; min-height: 35px; padding: 0 12px; border-radius: 7px; background: var(--app-brand); color: #fff; font-size: .7rem; font-weight: 700; text-decoration: none; }
.app-global-menu { display: none; }
.app-global-mobile-nav { display: none; }
.app-global-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 28px 24px; border-top: 1px solid var(--app-line); color: #8791a1; font-size: .67rem; }
.app-global-footer div { display: flex; align-items: center; gap: 18px; }
.app-global-footer a { color: inherit; text-decoration: none; }
.app-global-footer a:hover { color: var(--app-brand); }
.app-global-offset { width: 100%; flex: 0 0 auto; }
.app-chrome-page[data-app-page="tracker"] > .topbar { display: none !important; }
.app-chrome-page[data-app-page="tracker"] > .container { margin-top: 64px; }

body.dark-mode .app-global-nav { background: rgba(23,29,43,.97); }
body.dark-mode .app-global-links a:hover { background: #222a3b; }
body.dark-mode .app-global-theme, body.dark-mode .app-global-menu { background: #171d2b; color: var(--app-ink); }

@media (max-width: 1100px) and (min-width: 821px) {
    .app-global-nav { gap: 16px; padding: 0 20px; }
    .app-global-links { display: none; position: absolute; top: 64px; right: 16px; width: 250px; padding: 8px; border: 1px solid var(--app-line); border-radius: 10px; background: var(--app-paper); box-shadow: var(--app-shadow); }
    .app-global-nav.menu-open .app-global-links { display: grid; }
    .app-global-links a { min-height: 40px; }
    .app-global-menu { display: grid; }
}

body.dark-mode .app-shell { --app-ink:#e7eaf1; --app-muted:#9ba4b5; --app-line:#273044; --app-canvas:#101522; --app-paper:#171d2b; --app-brand-soft:#28254b; --app-shadow:0 12px 36px rgba(0,0,0,.2); }
body.dark-mode .app-topbar, body.dark-mode .app-icon-button, body.dark-mode .app-outline-button { background: #171d2b; color: var(--app-ink); }
body.dark-mode .app-nav a:hover { background: #222a3b; }

@media (max-width: 820px) {
    .app-sidebar { display: none; }
    .app-main { margin-left: 0; padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
    .app-topbar { min-height: 58px; padding: 0 16px; }
    .app-menu-button { display: grid; }
    .app-mobile-nav {
        position: fixed;
        inset: auto 0 0;
        z-index: 30;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--app-line);
        background: rgba(255,255,255,.96);
        backdrop-filter: blur(18px);
    }
    .app-mobile-nav a { display: grid; justify-items: center; gap: 4px; min-height: 46px; color: #80899a; font-size: .58rem; text-decoration: none; }
    .app-mobile-nav a i { font-size: .95rem; }
    .app-mobile-nav a.active { color: var(--app-brand); }
    body.dark-mode .app-mobile-nav { background: rgba(23,29,43,.96); }
    .app-page { padding: 22px 16px 30px; }
    .app-footer { padding: 14px 16px 20px; }
    .app-chrome-page { padding-bottom: calc(66px + env(safe-area-inset-bottom)) !important; }
    .app-global-nav { height: 58px; gap: 10px; padding: 0 14px; }
    .app-global-brand { font-size: 1.12rem; }
    .app-global-brand span { width: 29px; height: 29px; }
    .app-global-links { display: none; position: absolute; inset: 58px 8px auto; padding: 8px; border: 1px solid var(--app-line); border-radius: 10px; background: var(--app-paper); box-shadow: var(--app-shadow); }
    .app-global-nav.menu-open .app-global-links { display: grid; }
    .app-global-links a { min-height: 42px; padding: 0 12px; }
    .app-global-menu { display: grid; }
    .app-global-account { min-height: 34px; padding: 0 10px; font-size: .66rem; }
    .app-global-mobile-nav { position: fixed; inset: auto 0 0; z-index: 1010; display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); padding: 7px 6px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--app-line); background: rgba(255,255,255,.97); backdrop-filter: blur(16px); }
    .app-global-mobile-nav a { display: grid; justify-items: center; align-content: center; gap: 4px; min-height: 47px; color: #80899a; font-size: .56rem; text-decoration: none; }
    .app-global-mobile-nav a i { font-size: .92rem; }
    .app-global-mobile-nav a.active { color: var(--app-brand); }
    .app-global-footer { flex-direction: column; padding: 14px 12px 16px; font-size: .62rem; }
    .app-global-footer div { gap: 16px; }
    body.dark-mode .app-global-mobile-nav { background: rgba(23,29,43,.97); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}