* {
    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: grid;
    align-items: center;
    grid-template-columns: 46px minmax(0, 470px) max-content;
    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;
    flex: 0 0 auto;
    gap: 14px;
    min-width: 46px;
    width: 46px;
}

.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 {
    display: flex;
    justify-content: center;
    justify-self: center;
    max-width: 470px;
    min-width: 0;
    width: 100%;
}

.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: background .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease;
}

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

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

.topbar-right {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 18px;
    min-width: max-content;
    justify-self: end;
    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;
}

.topbar-user-menu { position: relative; }
.topbar-user-menu > summary { border-radius: 13px; cursor: pointer; list-style: none; padding: 4px 7px; transition: background .2s ease, box-shadow .2s ease; }
.topbar-user-menu > summary::-webkit-details-marker { display: none; }
.topbar-user-menu > summary:hover,
.topbar-user-menu > summary:focus-visible,
.topbar-user-menu[open] > summary { background: color-mix(in srgb, var(--workspace-accent, var(--primary)) 10%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--workspace-accent, var(--primary)) 16%, transparent); outline: 0; }
.topbar-user-chevron { color: var(--text-muted); fill: none; height: 18px; stroke: currentColor; stroke-width: 1.8; transition: transform .2s ease; width: 18px; }
.topbar-user-menu[open] .topbar-user-chevron { transform: rotate(180deg); }
.topbar-user-dropdown { background: color-mix(in srgb, var(--card) 94%, #05070d); border: 1px solid color-mix(in srgb, var(--workspace-accent, var(--primary)) 30%, var(--border)); border-radius: 17px; box-shadow: 0 22px 54px rgba(0,0,0,.48), inset 0 1px rgba(255,255,255,.05); display: grid; padding: 10px; position: absolute; right: 0; top: calc(100% + 11px); width: 230px; z-index: 1200; }
.topbar-user-dropdown::before { bottom: 100%; content: ""; height: 12px; position: absolute; right: 0; width: 100%; }
.topbar-user-dropdown a { align-items: center; border-radius: 11px; color: var(--text); display: flex; font-size: 14px; font-weight: 700; gap: 12px; min-height: 44px; padding: 10px 12px; text-decoration: none; transition: background .18s ease, color .18s ease; }
.topbar-user-dropdown a:hover,
.topbar-user-dropdown a:focus-visible { background: color-mix(in srgb, var(--workspace-accent, var(--primary)) 11%, transparent); color: color-mix(in srgb, var(--workspace-accent, var(--primary)) 78%, white); outline: 0; }
.topbar-user-dropdown a.is-license-status { color: color-mix(in srgb, var(--workspace-accent, var(--primary)) 80%, white); }
.topbar-user-dropdown a.is-logout:hover,
.topbar-user-dropdown a.is-logout:focus-visible { background: rgba(202,71,71,.10); color: #f0a3a3; }
.topbar-user-dropdown svg { fill: none; height: 19px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; width: 19px; }
.topbar-user-dropdown-divider { background: rgba(255,255,255,.09); height: 1px; margin: 7px 6px; }

.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-avatar svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.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 {
        display: flex;
        gap: 18px;
        padding-inline: 28px;
    }

    .topbar-left {
        min-width: max-content;
        width: auto;
    }

    .topbar-center {
        flex: 1 1 420px;
        max-width: 470px;
    }

    .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%;
        max-width: none;
        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;
    }

    .topbar-user-menu > summary { gap: 4px; padding-inline: 2px; }
    .topbar-user-dropdown { position: fixed; right: 14px; top: 70px; width: min(260px, calc(100vw - 28px)); }

    .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;
    }
}
