*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; color: var(--text); background: var(--background); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { color: inherit; font: inherit; }
button, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; color: var(--primary-deep); font-size: clamp(1.65rem, 3vw, 2.15rem); line-height: 1.15; letter-spacing: -.025em; }
h2 { margin-bottom: 5px; color: var(--primary-deep); font-size: 1.08rem; line-height: 1.3; }
h3 { margin-bottom: 5px; color: var(--primary-deep); font-size: 1rem; }
p { margin-bottom: 0; color: var(--muted); }
ul, ol { margin-top: 0; }
.icon { width: 20px; height: 20px; flex: 0 0 auto; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .88rem; }
.skip-link { position: fixed; z-index: 1000; top: 8px; left: 8px; transform: translateY(-150%); padding: 9px 14px; color: #fff; background: var(--primary); border-radius: var(--radius-sm); }
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: none; box-shadow: var(--focus); }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; display: flex; width: var(--sidebar-width); flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); transition: transform .22s ease, box-shadow .22s ease; }
.brand { display: flex; min-height: var(--topbar-height); align-items: center; gap: 12px; padding: 0 22px; border-bottom: 1px solid var(--border); }
.brand-mark { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; color: #fff; background: var(--accent); border-radius: 10px; box-shadow: 0 6px 14px rgba(245, 107, 42, .22); }
.brand-mark .icon { width: 21px; height: 21px; }
.brand strong, .brand small { display: block; }
.brand strong { color: var(--primary-deep); font-size: .98rem; }
.brand small { color: var(--muted); font-size: .71rem; }
.side-nav { overflow-y: auto; flex: 1; padding: 15px 12px; }
.nav-label { margin: 15px 11px 6px; color: #8a98a3; font-size: .66rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.side-nav a { display: flex; min-height: 43px; align-items: center; gap: 12px; margin: 3px 0; padding: 9px 12px; color: #526472; border-radius: 8px; font-size: .9rem; font-weight: 600; }
.side-nav a:hover { color: var(--primary); background: #f5f7f8; text-decoration: none; }
.side-nav a.active { color: var(--accent-dark); background: #fff1e9; box-shadow: inset 3px 0 var(--accent); }
.side-nav .icon { width: 18px; height: 18px; }
.sidebar-footer { padding: 16px 19px; color: #8a98a3; border-top: 1px solid var(--border); font-size: .7rem; }
.security-note { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--muted); font-size: .74rem; line-height: 1.35; }
.security-note .icon { width: 17px; color: var(--success); }
.app-body { min-height: 100vh; margin-left: var(--sidebar-width); transition: margin-left .22s ease; }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; height: var(--topbar-height); align-items: center; justify-content: flex-start; gap: 16px; padding: 0 clamp(18px, 3vw, 34px); background: rgba(255, 255, 255, .97); border-bottom: 1px solid var(--border); }
.topbar-title strong, .topbar-title span { display: block; }
.topbar-title strong { color: var(--primary-deep); font-size: .95rem; }
.topbar-title span { color: var(--muted); font-size: .72rem; }
.sidebar-toggle { display: inline-grid; flex: 0 0 auto; }
.user-menu { position: relative; margin-left: auto; }
.user-menu summary { display: flex; min-width: 175px; align-items: center; gap: 10px; padding: 5px 8px; list-style: none; border-radius: 9px; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--surface-alt); }
.avatar { display: grid; width: 34px; height: 34px; place-items: center; color: #fff; background: var(--primary); border-radius: 50%; font-size: .82rem; font-weight: 800; }
.user-menu-name strong, .user-menu-name small { display: block; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-name strong { color: var(--primary-deep); font-size: .81rem; }
.user-menu-name small { color: var(--muted); font-size: .69rem; }
.user-dropdown { position: absolute; top: calc(100% + 8px); right: 0; width: 210px; overflow: hidden; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.user-dropdown a, .user-dropdown button { display: flex; width: 100%; align-items: center; gap: 9px; padding: 10px; color: var(--text); background: transparent; border: 0; border-radius: 7px; text-align: left; font-size: .84rem; }
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--surface-alt); text-decoration: none; }
.user-dropdown .icon { width: 17px; height: 17px; color: var(--muted); }
.main-content { width: 100%; max-width: 1580px; min-height: calc(100vh - var(--topbar-height) - 50px); margin: 0 auto; padding: clamp(24px, 3vw, 38px); }
.app-footer { display: flex; justify-content: space-between; padding: 14px clamp(18px, 3vw, 38px); color: #85939f; border-top: 1px solid var(--border); font-size: .72rem; }
.mobile-overlay { display: none; }

@media (min-width: 901px) {
    body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
    body.sidebar-collapsed .app-body { margin-left: 0; }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-md); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .mobile-overlay { position: fixed; z-index: 25; inset: 0; display: block; background: rgba(20, 34, 44, .42); }
    .app-body { margin-left: 0; }
}

@media (max-width: 560px) {
    .topbar { padding: 0 13px; }
    .topbar-title span, .user-menu-name { display: none; }
    .user-menu summary { min-width: auto; padding: 3px; }
    .main-content { padding: 22px 14px 30px; }
    .app-footer { padding: 13px 14px; }
    .app-footer span:last-child { display: none; }
}
