* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    display: flex;
    overflow-x: hidden;
}

button,
input {
    font: inherit;
}

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: 30px;
    display: flex;
    flex-direction: column;
    flex: 0 0 var(--sidebar-width);
    position: sticky;
    top: 0;
    z-index: 30;
}

.brand {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border);
}

.sidebar-close {
    width: 38px;
    height: 38px;
    margin-left: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
    transition: var(--transition);
}

.sidebar-close:hover,
.sidebar-close:focus-visible {
    background: #2a2a2a;
    outline: none;
}

.brand-logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--primary);
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex: 0 0 auto;
}

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-title {
    font-size: 20px;
    font-weight: 700;
    white-space: nowrap;
}

.brand-subtitle {
    color: var(--primary);
    font-size: 12px;
    letter-spacing: 2px;
}

.menu-title {
    margin-top: 35px;
    margin-bottom: 15px;
    color: var(--text-soft);
    font-size: 11px;
    letter-spacing: 2px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar a {
    color: #ddd;
    text-decoration: none;
}

.sidebar-nav a,
.sidebar-footer a {
    min-height: 46px;
    padding: 14px 16px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.sidebar-nav a:hover,
.sidebar-footer a:hover {
    background: #2a2a2a;
    color: var(--text);
}

.sidebar-nav .active,
.sidebar-nav .active:hover {
    background: var(--primary);
    color: #111;
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 30px;
    border-top: 1px solid var(--border);
}

.sidebar-footer .user-name {
    margin-bottom: 15px;
    font-weight: 600;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(0, 0, 0, .58);
    backdrop-filter: blur(2px);
}

.sidebar-overlay[hidden] {
    display: none;
}

.app {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 35px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: max-content;
}

.topbar-left h1 {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
}

.menu-toggle {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    transition: var(--transition);
}

.menu-toggle span {
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
}

.menu-toggle:hover,
.menu-toggle:focus-visible,
.icon-btn:hover,
.icon-btn:focus-visible {
    background: #2a2a2a;
    outline: none;
}

.topbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 180px;
}

.search-box {
    width: min(420px, 100%);
    background: var(--card);
    border: 1px solid #303030;
    color: var(--text);
    border-radius: var(--radius);
    padding: 12px 18px;
    outline: none;
    transition: var(--transition);
}

.search-box::placeholder {
    color: var(--text-muted);
}

.search-box:focus {
    border-color: var(--primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: max-content;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    cursor: pointer;
    font-size: 18px;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.user-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary);
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex: 0 0 auto;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.topbar .user-name {
    font-weight: 600;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.content {
    width: 100%;
    padding: 40px;
    flex: 1;
}

.page {
    max-width: 1120px;
}

.page h2 {
    font-size: clamp(26px, 4vw, 38px);
    line-height: 1.15;
    margin-bottom: 12px;
}

.page p {
    color: var(--text-muted);
    line-height: 1.6;
}

body.sidebar-open {
    overflow: hidden;
}

@media (max-width: 1100px) {
    .topbar {
        gap: 18px;
        padding-inline: 28px;
    }

    .search-box {
        width: 100%;
    }
}

@media (max-width: 900px) {
    body {
        display: block;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 280px;
        max-width: 100vw;
        min-height: 100dvh;
        transform: translateX(-100%);
        transition: transform var(--transition);
        box-shadow: var(--shadow);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .app {
        min-height: 100vh;
        min-height: 100dvh;
        width: 100%;
        margin-left: 0;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .sidebar-close {
        display: inline-flex;
        position: absolute;
        top: 12px;
        right: 16px;
        margin-left: 0;
    }

    .brand {
        gap: 10px;
        padding-top: 50px;
        padding-right: 0;
    }

    .topbar {
        min-height: 68px;
        padding: 14px 22px;
        flex-wrap: wrap;
        align-items: center;
        gap: 14px;
        z-index: 25;
    }

    .topbar-left {
        flex: 1 1 auto;
        min-width: 0;
    }

    .topbar-left h1 {
        font-size: 22px;
    }

    .topbar-center {
        order: 3;
        flex: 1 0 100%;
        min-width: 0;
    }

    .topbar-right {
        gap: 12px;
    }

    .content {
        padding: 28px 22px;
    }
}

@media (max-width: 560px) {
    .topbar {
        padding: 12px 16px;
        gap: 12px;
    }

    .topbar-left h1 {
        font-size: 20px;
    }

    .user-info {
        display: none;
    }

    .search-box {
        padding: 11px 14px;
    }

    .content {
        padding: 24px 16px;
    }
}

@media (max-width: 380px) {
    .topbar-left h1 {
        font-size: 18px;
    }

    .menu-toggle,
    .icon-btn,
    .user-avatar {
        width: 38px;
        height: 38px;
    }

    .topbar-right {
        gap: 8px;
    }
}
