:root {
    --bg: #0f1115;
    --panel: #171b24;
    --card: #1b2029;
    --card-2: #1e2330;
    --sidebar: #141821;
    --border: #262c39;
    --text: #e5e7eb;
    --muted: #8b93a3;
    --muted-2: #5b6472;
    --accent: #3b82f6;
    --accent-hover: #2f6fe0;
    --green: #22c55e;
    --red: #ef4444;
    --purple: #6366f1;
    --sidebar-w: 74px;
}

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

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ---------------- Layout ---------------- */
.app-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#sidebar-container {
    display: flex;
}

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

.workspace {
    position: relative;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
}

.ws-content {
    height: 100%;
}

/* ---------------- Sidebar ---------------- */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    height: 100dvh;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 16px 6px 14px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: block;
}

.sidebar-name {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    color: var(--text);
}

.sidebar-mark {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.25rem;
    color: #fff;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
}

.sidebar-menu {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.sidebar-foot {
    padding: 8px;
    border-top: 1px solid var(--border);
}

.menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 4px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: color 0.15s;
    user-select: none;
}

.menu-item i {
    font-size: 1.05rem;
    width: 44px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    transition: background 0.15s, color 0.15s;
}

.menu-item span {
    line-height: 1.1;
    transition: color 0.15s;
}

.menu-item:hover {
    color: var(--text);
}

.menu-item:hover i {
    background: #1c2230;
}

.menu-item.active {
    color: var(--accent);
}

.menu-item.active i {
    background: var(--accent);
    color: #fff;
}

.menu-item.logout {
    color: #f0787a;
}

.menu-item.logout:hover {
    color: var(--red);
}

.menu-item.logout:hover i {
    background: rgba(239, 68, 68, 0.14);
}

/* ---------------- Header ---------------- */
.app-header {
    height: 60px;
    flex-shrink: 0;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.1rem;
    cursor: pointer;
}

.page-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
}

.user-menu {
    position: relative;
}

.user-badge {
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    display: flex;
}

.user-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 230px;
    background: #141922;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.55);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
    z-index: 60;
}

.user-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ud-head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 10px 12px;
}

.ud-avatar {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    flex-shrink: 0;
}

.ud-info { min-width: 0; display: flex; flex-direction: column; }
.ud-name { font-weight: 600; font-size: 0.9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ud-email { font-size: 0.76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ud-sep { height: 1px; background: var(--border); margin: 2px 4px 6px; }

.ud-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.86rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}
.ud-item i { width: 16px; text-align: center; color: var(--muted); }
.ud-item:hover { background: #1c2230; }

.ud-logout { color: #f0787a; }
.ud-logout i { color: #f0787a; }
.ud-logout:hover { background: rgba(239, 68, 68, 0.12); color: var(--red); }
.ud-logout:hover i { color: var(--red); }

/* ---------------- Mobile sidebar ---------------- */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
}

.sidebar-backdrop.show {
    display: block;
}

/* ---------------- Shared UI atoms ---------------- */
.module-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 100%;
    color: var(--muted);
}

.module-error i {
    font-size: 1.8rem;
    color: var(--red);
}

/* thin scrollbars */
.workspace::-webkit-scrollbar,
.data-table-wrap::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.workspace::-webkit-scrollbar-thumb,
.data-table-wrap::-webkit-scrollbar-thumb {
    background: #2c3444;
    border-radius: 8px;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 50;
    }

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

    .hamburger {
        display: block;
    }
}

@media (max-width: 480px) {
    .workspace {
        padding: 14px;
    }
}
