:root {
    --bg: #0f172a;
    --panel: #111827;
    --panel-soft: #1f2937;
    --panel-alt: #0b1220;
    --card: #171f2f;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #ef4444;
    --accent-soft: rgba(239, 68, 68, 0.18);
    --line: rgba(148, 163, 184, 0.15);
    --success: #22c55e;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button, input {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 12px 20px;
    background: rgba(15, 23, 42, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.brand-mark {
    width: 16px;
    height: 16px;
    border-radius: 5px;
    background: linear-gradient(135deg, #ef4444, #f97316);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
    display: inline-block;
}

.menu-button,
.icon-button,
.search-button {
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(148, 163, 184, 0.06);
    color: var(--text);
    border-radius: 12px;
    cursor: pointer;
}

.menu-button,
.icon-button {
    width: 38px;
    height: 38px;
}

.menu-button {
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
}

.menu-button:hover {
    background: rgba(148, 163, 184, 0.14);
}

.menu-button-icon,
.menu-button-icon::before,
.menu-button-icon::after {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}

.menu-button-icon {
    position: relative;
}

.menu-button-icon::before,
.menu-button-icon::after {
    position: absolute;
    left: 0;
    content: "";
}

.menu-button-icon::before {
    top: -6px;
}

.menu-button-icon::after {
    top: 6px;
}

.search-form {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    max-width: 760px;
}

.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 999px;
    padding: 8px 14px;
    min-width: 220px;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 1rem;
}

.search-box input::placeholder {
    color: var(--muted);
}

.search-icon {
    color: var(--muted);
    font-size: 1.1rem;
}

.search-button {
    padding: 10px 18px;
    font-weight: 700;
    background: rgba(148, 163, 184, 0.08);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 999px;
    padding: 7px 12px;
}

.login-button,
.logout-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(148, 163, 184, 0.08);
    color: var(--text);
    font-weight: 700;
}

.logout-link {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.35);
}

.user-chip img,
.avatar-fallback {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.15);
    object-fit: cover;
}

.layout {
    display: flex;
    min-height: calc(100vh - 76px);
}

.sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: rgba(15, 23, 42, 0.54);
    border-right: 1px solid var(--line);
    padding: 18px 12px;
    transition: width 0.2s ease, flex-basis 0.2s ease, padding 0.2s ease, transform 0.2s ease;
}

.sidebar-backdrop {
    display: none;
}

.sidebar-collapsed .sidebar {
    width: 76px;
    flex-basis: 76px;
    padding-right: 8px;
    padding-left: 8px;
}

.sidebar-collapsed .nav-section-title,
.sidebar-collapsed .nav-item span:last-child {
    display: none;
}

.sidebar-collapsed .nav-item {
    justify-content: center;
    padding-right: 8px;
    padding-left: 8px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.nav-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-section-title {
    color: var(--muted);
    font-size: 0.7rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    padding: 0 12px;
}

.nav-section ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text);
    transition: background 0.2s ease, color 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(239, 68, 68, 0.08);
}

.nav-icon {
    width: 22px;
    text-align: center;
    font-size: 1.05rem;
    opacity: 0.9;
}

.content {
    flex: 1;
    padding: 24px;
}

.page-shell {
    max-width: 1200px;
    margin: 0 auto;
}

.content-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.hero {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(59, 130, 246, 0.10));
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.hero.compact {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.11), rgba(59, 130, 246, 0.08));
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 22px;
    padding: 24px 28px;
}

.page-shell h1,
.page-shell h2,
.page-shell h3 {
    color: #f8fafc;
}

.hero h1 {
    margin: 0 0 10px;
    font-size: clamp(2rem, 3vw, 3rem);
}

.hero p {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.grid {
    margin-top: 28px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 18px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
    min-height: 150px;
}

.card-label {
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
}

@media (max-width: 900px) {
    .search-form {
        max-width: none;
    }

    .sidebar {
        width: 76px;
        flex-basis: 76px;
        padding-right: 8px;
        padding-left: 8px;
    }

    .nav-section-title,
    .nav-item span:last-child {
        display: none;
    }

    .nav-item {
        justify-content: center;
    }

    body:not(.sidebar-collapsed) .sidebar {
        width: 240px;
        flex-basis: 240px;
        padding: 18px 12px;
    }

    body:not(.sidebar-collapsed) .nav-section-title,
    body:not(.sidebar-collapsed) .nav-item span:last-child {
        display: initial;
    }

    body:not(.sidebar-collapsed) .nav-item {
        justify-content: flex-start;
        padding: 10px 12px;
    }
}

@media (max-width: 640px) {
    .layout {
        flex-direction: row;
    }

    .sidebar {
        position: fixed;
        z-index: 42;
        top: 76px;
        bottom: 0;
        left: 0;
        width: min(280px, 85vw);
        height: calc(100vh - 76px);
        padding: 18px 12px;
        overflow-y: auto;
        border-right: 1px solid var(--line);
        background: #111827;
        box-shadow: 16px 0 40px rgba(0, 0, 0, 0.28);
        transform: translateX(-105%);
        visibility: hidden;
    }

    body.sidebar-open .sidebar {
        width: min(280px, 85vw);
        transform: translateX(0);
        visibility: visible;
    }

    .sidebar .nav-section-title,
    .sidebar .nav-item span:last-child,
    body:not(.sidebar-collapsed) .sidebar .nav-section-title,
    body:not(.sidebar-collapsed) .sidebar .nav-item span:last-child {
        display: initial;
    }

    .sidebar .nav-item,
    body:not(.sidebar-collapsed) .sidebar .nav-item {
        justify-content: flex-start;
        padding: 10px 12px;
    }

    .sidebar-backdrop {
        position: fixed;
        z-index: 41;
        inset: 76px 0 0;
        display: block;
        border: 0;
        background: rgba(0, 0, 0, 0.58);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .content {
        padding: 16px;
    }
}

@media (max-width: 780px) {
    .topbar {
        flex-wrap: wrap;
    }

    .search-form {
        width: 100%;
        max-width: none;
        order: 3;
    }
}
