:root {
    color-scheme: light;
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 76px;
    --navy: #073c71;
    --navy-deep: #03294f;
    --blue: #2f6fde;
    --red: #bd2532;
    --text: #14233b;
    --muted: #718096;
    --border: #dde6f0;
    --surface: #fff;
    --background: #f4f7fb;
    --radius: 14px;
    --shadow: 0 8px 24px rgb(20 45 80 / 6%);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: clip; }
body { margin: 0; color: var(--text); background: var(--background); }
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }

.app-sidebar {
    position: fixed;
    z-index: 50;
    inset: 0 auto 0 0;
    display: flex;
    width: var(--sidebar-width);
    padding: 18px 16px 14px;
    color: #fff;
    background: radial-gradient(circle at 20% 0, rgb(54 126 230 / 30%), transparent 26%), linear-gradient(180deg, var(--navy), var(--navy-deep));
    flex-direction: column;
    transition: width 220ms ease, transform 220ms ease;
}

.sidebar-collapse-button {
    position: absolute;
    top: 76px;
    right: -14px;
    display: grid;
    width: 28px;
    height: 28px;
    color: var(--navy);
    border: 1px solid #d6e0ec;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: var(--shadow);
    place-items: center;
}

.sidebar-brand { display: flex; min-height: 64px; padding: 0 9px 12px; align-items: center; gap: 12px; }
.sidebar-brand-icon { display: grid; width: 45px; height: 45px; flex: 0 0 45px; border-radius: 13px; background: linear-gradient(145deg, #5b9bff, #2e70e5); font-size: 25px; place-items: center; }
.sidebar-brand strong, .sidebar-brand small { display: block; }
.sidebar-brand strong { font-size: 21px; }
.sidebar-brand small { margin-top: 3px; color: rgb(255 255 255 / 68%); font-size: 11px; }
.sidebar-nav { display: grid; overflow-y: auto; gap: 2px; }

.sidebar-link {
    display: flex;
    min-height: 38px;
    padding: 0 13px;
    align-items: center;
    gap: 13px;
    color: rgb(255 255 255 / 82%);
    border-radius: 10px;
    font-size: 13px;
    transition: color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.sidebar-link > span:last-child { transition: transform 180ms ease; }
.nav-icon { width: 20px; flex: 0 0 20px; text-align: center; font-size: 18px; }
.sidebar-link.active { color: #fff; background: linear-gradient(135deg, #347cef, #2865d3); box-shadow: 0 7px 18px rgb(0 24 67 / 25%); }
.sidebar-link:hover, .sidebar-link:focus-visible { color: #fff; outline: none; background: linear-gradient(135deg, #e5484d, var(--red)); box-shadow: 0 7px 18px rgb(80 5 16 / 28%); }
.sidebar-link:hover > span:last-child, .sidebar-link:focus-visible > span:last-child { transform: translateX(4px); }

.app-shell { min-height: 100vh; margin-left: var(--sidebar-width); transition: margin-left 220ms ease; }
.app-topbar { position: sticky; z-index: 30; top: 0; display: flex; min-height: 72px; padding: 10px 30px; align-items: center; gap: 18px; border-bottom: 1px solid var(--border); background: rgb(255 255 255 / 94%); backdrop-filter: blur(12px); }
.mobile-menu-button { display: none; }
.icon-button { display: grid; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: #5f6c80; cursor: pointer; place-items: center; }
.icon-button:hover { color: var(--blue); background: #edf4ff; }
.global-search { display: flex; width: min(500px, 45vw); height: 42px; padding: 0 14px; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 10px; background: #fbfcfe; }
.global-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; }
.topbar-actions { display: flex; margin-left: auto; align-items: center; gap: 8px; }
.context-selector { display: grid; gap: 2px; }
.context-selector > span { color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.context-selector select { width: clamp(180px, 20vw, 280px); min-height: 40px; padding: 6px 30px 6px 10px; color: #24425b; border: 1px solid #cfdee8; border-radius: 10px; background: #f6fafc; }
.user-menu { position: relative; }
.user-menu summary { display: flex; list-style: none; cursor: pointer; align-items: center; gap: 9px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-avatar, .activity-avatar { display: grid; color: #fff; background: linear-gradient(145deg, #3079ec, #064473); font-weight: 800; place-items: center; }
.user-avatar { width: 40px; height: 40px; border-radius: 50%; }
.user-copy strong, .user-copy small { display: block; white-space: nowrap; }
.user-copy small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.user-dropdown { position: absolute; top: calc(100% + 12px); right: 0; display: grid; width: 190px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: 0 18px 45px rgb(18 42 76 / 16%); }
.user-dropdown a { padding: 10px; border-radius: 8px; font-size: 13px; }
.user-dropdown a:hover { background: #f2f6fc; }

.app-content { width: min(1450px, 100%); min-height: calc(100vh - 120px); margin: 0 auto; padding: 30px; }
.page-heading { display: flex; margin-bottom: 22px; align-items: center; justify-content: space-between; gap: 24px; }
.eyebrow { color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.page-heading h1 { margin: 5px 0; font-size: clamp(24px, 3vw, 30px); letter-spacing: -.035em; }
.page-heading p, .panel-header p { margin: 0; color: var(--muted); font-size: 12px; }
.primary-button { min-height: 42px; padding: 0 16px; color: #fff; border: 0; border-radius: 9px; background: linear-gradient(135deg, #347bef, #2261d2); box-shadow: 0 8px 20px rgb(37 99 235 / 18%); cursor: pointer; font-weight: 700; }

.stats-grid { display: grid; margin-bottom: 18px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card, .panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stat-card { display: flex; min-height: 112px; padding: 18px; align-items: flex-start; gap: 13px; }
.stat-icon { display: grid; width: 44px; height: 44px; flex: 0 0 44px; color: #fff; border-radius: 12px; place-items: center; }
.stat-icon.blue { background: linear-gradient(145deg, #669dff, #3e73e7); }
.stat-icon.green { background: linear-gradient(145deg, #32c58a, #159a64); }
.stat-icon.orange { background: linear-gradient(145deg, #ffb534, #f39010); }
.stat-icon.purple { background: linear-gradient(145deg, #a578ec, #8059d2); }
.stat-card small, .stat-card span { display: block; color: var(--muted); font-size: 11px; }
.stat-card strong { display: block; margin: 5px 0; font-size: 24px; line-height: 1; }

.dashboard-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.panel { min-width: 0; padding: 20px; }
.panel-header { display: flex; margin-bottom: 18px; align-items: center; justify-content: space-between; gap: 14px; }
.panel-header h2 { margin: 0 0 4px; font-size: 16px; }
.text-button { color: var(--blue); border: 0; background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; }
.progress-list { display: grid; gap: 18px; }
.progress-list > div { display: grid; grid-template-columns: 120px minmax(0, 1fr) 42px; align-items: center; gap: 12px; font-size: 12px; }
.progress { height: 8px; overflow: hidden; border-radius: 999px; background: #e9eef5; }
.progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #347bef, #31a6d8); }
.activity-list { display: grid; }
.activity-list a { display: grid; padding: 12px 0; grid-template-columns: 38px 1fr; align-items: center; gap: 10px; border-bottom: 1px solid #edf1f5; }
.activity-avatar { width: 36px; height: 36px; border-radius: 10px; font-size: 11px; }
.activity-list strong, .activity-list small { display: block; }
.activity-list strong { font-size: 12px; }
.activity-list small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.app-footer { padding: 0 30px 22px; color: #8b96a6; font-size: 10px; }
.mobile-overlay { display: none; }

.sidebar-collapsed .app-sidebar { width: var(--sidebar-collapsed-width); padding-inline: 10px; }
.sidebar-collapsed .app-shell { margin-left: var(--sidebar-collapsed-width); }
.sidebar-collapsed .sidebar-brand { padding-inline: 5px; justify-content: center; }
.sidebar-collapsed .sidebar-brand-copy, .sidebar-collapsed .sidebar-link > span:last-child { display: none; }
.sidebar-collapsed .sidebar-link { padding: 0; justify-content: center; }
.sidebar-collapsed .sidebar-collapse-button > span { transform: rotate(180deg); }

@media (max-width: 900px) {
    .app-sidebar { transform: translateX(-100%); }
    .sidebar-open .app-sidebar { transform: translateX(0); }
    .sidebar-open .mobile-overlay { position: fixed; z-index: 40; display: block; inset: 0; background: rgb(1 19 40 / 48%); backdrop-filter: blur(2px); }
    .sidebar-collapse-button { display: none; }
    .app-shell, .sidebar-collapsed .app-shell { margin-left: 0; }
    .mobile-menu-button { display: grid; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .user-copy { display: none; }
}

@media (max-width: 680px) {
    .app-topbar { padding: 9px 15px; flex-wrap: wrap; }
    .global-search { width: auto; min-width: 0; flex: 1; }
    .topbar-actions { display: grid; width: 100%; margin-left: 0; grid-template-columns: minmax(0, 1fr) auto auto; }
    .context-selector, .context-selector select { width: 100%; min-width: 0; }
    .app-content { padding: 22px 15px; }
    .page-heading { align-items: stretch; flex-direction: column; }
    .primary-button { align-self: flex-end; }
    .stat-card { min-width: 0; min-height: 88px; padding: 12px; gap: 9px; }
    .stat-icon { width: 36px; height: 36px; flex-basis: 36px; }
    .stat-card strong { font-size: 20px; }
    .stat-card small, .stat-card span { overflow-wrap: anywhere; font-size: 10px; }
    .progress-list > div { grid-template-columns: 90px minmax(0, 1fr) 38px; }
    .app-footer { padding-inline: 15px; }
}
