/* ============================================================================

LAYOUT — App Shell, Sidebar, Header, Main Content

============================================================================ */

/* === APP SHELL === */
.app-container {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-page);
}

/* === SIDEBAR === */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    transition: width var(--duration-base) var(--easing-in-out),
        transform var(--duration-base) var(--easing-in-out);
    z-index: 1000;
    overflow: hidden;
    flex-shrink: 0;
    pointer-events: auto;
    isolation: isolate;
}

.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}

/* Sidebar Header (Logo) */
.sidebar-header {
    height: var(--header-height);
    padding: 0 var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    min-width: 0;
    overflow: hidden;
}

.logo-icon-wrap {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.logo-icon-wrap svg {
    color: #fff;
}

.logo-text-wrap {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity var(--duration-base), width var(--duration-slow) var(--easing-in-out);
    min-width: 0;
}

.logo-name {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.logo-tag {
    font-size: 10px;
    font-weight: var(--font-weight-semibold);
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1;
    margin-top: 1px;
}

.sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: var(--space-1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast), background-color var(--duration-fast);
    flex-shrink: 0;
    width: 28px;
    height: 28px;
}

.sidebar-collapse-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.sidebar-collapse-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-sunken);
}

.sidebar-chevron-expand {
    display: none;
}

.sidebar.collapsed .sidebar-chevron-collapse {
    display: none;
}

.sidebar.collapsed .sidebar-chevron-expand {
    display: block;
}

.sidebar.collapsed .sidebar-header {
    flex-direction: column;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-2);
    height: auto;
    min-height: var(--header-height);
}

.sidebar.collapsed .logo {
    justify-content: center;
    width: 100%;
}

.sidebar.collapsed .logo-text-wrap {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-3) var(--space-2);
    pointer-events: auto;
}

.nav-section {
    margin-bottom: var(--space-4);
}

.nav-section-label {
    display: block;
    font-size: 10.5px;
    font-weight: var(--font-weight-semibold);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: var(--space-2) var(--space-3);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--duration-base);
}

.sidebar.collapsed .nav-section-label {
    opacity: 0;
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.sidebar.collapsed .nav-section-header {
    display: none;
}

.sidebar.collapsed .nav-group .submenu {
    display: flex !important;
    flex-direction: column;
    padding-left: 0;
    margin: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-2);
    height: 36px;
    margin: 1px 0;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    transition: background-color var(--duration-fast), color var(--duration-fast);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    user-select: none;
}

.nav-item:hover {
    background-color: var(--bg-sunken);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: var(--font-weight-semibold);
}

:root.dark-mode .nav-item.active {
    background-color: rgba(99, 102, 241, 0.12);
    color: var(--brand-400);
}

.nav-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    color: inherit;
}

.nav-label {
    flex: 1;
    transition: opacity var(--duration-base);
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-badge {
    font-size: 10px;
    font-weight: var(--font-weight-bold);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background-color: var(--color-danger);
    color: white;
    flex-shrink: 0;
    transition: opacity var(--duration-base);
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge {
    opacity: 0;
    pointer-events: none;
    width: 0;
    min-width: 0;
    flex: 0 0 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0;
}

.sidebar.collapsed .nav-item-icon {
    width: 36px;
    height: 36px;
}

/* Tooltip for collapsed sidebar */
.sidebar.collapsed .nav-item {
    position: relative;
}

.sidebar.collapsed .nav-item::after {
    content: attr(data-nav-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-md);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--duration-fast), visibility var(--duration-fast);
    z-index: 1100;
}

.sidebar.collapsed .nav-item:hover::after,
.sidebar.collapsed .nav-item:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Footer (Admin Profile) */
.sidebar-footer {
    padding: var(--space-3) var(--space-2);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
    position: relative;
}

.admin-profile-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-2);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color var(--duration-fast);
    position: relative;
    overflow: hidden;
}

.admin-profile-card:hover {
    background-color: var(--bg-sunken);
}

.admin-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--brand-500), var(--color-purple));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-sm);
    flex-shrink: 0;
    user-select: none;
}

.admin-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    transition: opacity var(--duration-base);
}

.admin-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.admin-role-badge {
    font-size: 10px;
    color: var(--color-primary);
    font-weight: var(--font-weight-medium);
    line-height: 1.3;
}

.admin-more-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: var(--space-1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast), background-color var(--duration-fast);
    flex-shrink: 0;
}

.admin-more-btn:hover {
    color: var(--text-primary);
    background-color: var(--border-default);
}

.sidebar.collapsed .admin-info,
.sidebar.collapsed .admin-more-btn {
    opacity: 0;
    pointer-events: none;
    width: 0;
}

.sidebar.collapsed .admin-profile-card {
    justify-content: center;
    padding: 0;
}

/* Admin popup menu */
.admin-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: var(--space-2);
    right: var(--space-2);
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
    animation: slideUp var(--duration-base) var(--easing-out);
}

.admin-menu.open {
    display: flex;
}

.admin-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--duration-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.admin-menu-item:hover {
    background-color: var(--bg-sunken);
}

.admin-menu-item.danger {
    color: var(--color-danger);
}

.admin-menu-divider {
    height: 1px;
    background-color: var(--border-subtle);
    margin: var(--space-1) 0;
}

/* === MAIN WRAPPER === */
.main-wrapper {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--duration-base) var(--easing-in-out),
        width var(--duration-base) var(--easing-in-out);
    min-width: 0;
    position: relative;
    z-index: 1;
}

.sidebar.collapsed~.sidebar-overlay~.main-wrapper {
    margin-left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
}

.app-container.sidebar-is-collapsed .main-wrapper {
    margin-left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
}

/* Prevent sidebar width flash before JS applies collapse state */
html.sidebar-is-collapsed-init .sidebar {
    width: var(--sidebar-width-collapsed);
    transition: none;
}

html.sidebar-is-collapsed-init .main-wrapper {
    margin-left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
    transition: none;
}

/* === HEADER === */
.header {
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: 900;
    gap: var(--space-4);
    flex-shrink: 0;
    transition: background-color var(--duration-base);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
    flex-shrink: 0;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    display: none;
    align-items: center;
    justify-content: center;
    transition: color var(--duration-fast), background-color var(--duration-fast);
    width: 36px;
    height: 36px;
}

.sidebar-toggle:hover {
    color: var(--text-primary);
    background-color: var(--bg-sunken);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    white-space: nowrap;
}

.breadcrumb-home {
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
}

.breadcrumb-sep {
    color: var(--border-strong);
    font-size: 16px;
    line-height: 1;
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
}

/* Global Search */
.header-center {
    flex: 1;
    max-width: 480px;
    margin: 0 var(--space-4);
}

.global-search {
    position: relative;
    display: flex;
    align-items: center;
}

.global-search-icon {
    position: absolute;
    left: var(--space-3);
    color: var(--text-tertiary);
    pointer-events: none;
    flex-shrink: 0;
}

.global-search-input {
    width: 100%;
    height: 36px;
    padding: 0 var(--space-3) 0 calc(var(--space-3) + 20px + var(--space-2));
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background-color: var(--bg-sunken);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-family: var(--font-sans);
    transition: border-color var(--duration-fast), background-color var(--duration-fast), box-shadow var(--duration-fast);
    outline: none;
}

.global-search-input::placeholder {
    color: var(--text-tertiary);
}

.global-search-input:focus {
    border-color: var(--color-primary);
    background-color: var(--bg-surface);
    box-shadow: var(--shadow-brand);
}

.global-search-kbd {
    position: absolute;
    right: var(--space-3);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xs);
    padding: 1px 5px;
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-tertiary);
    pointer-events: none;
}

/* Header Right Controls */
.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.header-icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--duration-fast), background-color var(--duration-fast);
    position: relative;
}

.header-icon-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-sunken);
}

/* Notification badge */
.notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--radius-full);
    background-color: var(--color-danger);
    color: white;
    font-size: 10px;
    font-weight: var(--font-weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-surface);
    box-sizing: content-box;
    transition: transform var(--duration-fast) cubic-bezier(0.34, 1.56, 0.64, 1), opacity var(--duration-fast) ease;
    transform: scale(1);
    opacity: 1;
}

.notif-badge.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

.notif-badge.animate-pulse {
    animation: badgePulse 0.4s ease-out 2;
}

@keyframes badgePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* --- Premium Notification Dropdown Additions --- */
.notif-item {
    position: relative;
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--space-4) var(--space-5);
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    text-decoration: none;
    outline: none;
    transition: background-color var(--duration-fast), border-color var(--duration-fast);
}

.notif-item.unread {
    background-color: rgba(99, 102, 241, 0.03); /* Subtle primary brand tint for unread */
}

:root.dark-mode .notif-item.unread {
    background-color: rgba(99, 102, 241, 0.06); /* Slightly more visible tint in dark mode */
}

.notif-item.unread .notif-content-title {
    font-weight: var(--font-weight-bold);
}

.notif-item.unread .notif-dot-indicator {
    display: inline-block;
    width: 7px;
    height: 7px;
    background-color: var(--color-primary);
    border-radius: var(--radius-full);
    margin-left: var(--space-1);
    flex-shrink: 0;
}

.notif-item.read .notif-dot-indicator {
    display: none;
}

.notif-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

/* Priority backgrounds */
.notif-icon-wrapper.high, .notif-icon-wrapper.critical {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
}
.notif-icon-wrapper.medium {
    background-color: var(--color-warning-bg);
    color: var(--color-warning-text);
}
.notif-icon-wrapper.low {
    background-color: var(--color-success-bg);
    color: var(--color-success);
}
.notif-icon-wrapper.info {
    background-color: var(--color-info-bg);
    color: var(--color-info-text);
}

.notif-content {
    flex: 1;
    min-width: 0;
}

.notif-content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: 2px;
}

.notif-content-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-content-desc {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: var(--space-2);
    word-break: break-word;
}

.notif-content-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.notif-content-time {
    font-size: var(--font-size-xxs);
    color: var(--text-tertiary);
}

.notif-delete-btn {
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast), background-color var(--duration-fast);
}

.notif-delete-btn:hover {
    color: var(--color-danger);
    background-color: var(--color-danger-bg);
}

/* Empty, Loading, and Error States in Dropdown */
.notif-state-container {
    padding: var(--space-8) var(--space-6);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    color: var(--text-secondary);
}

.notif-state-icon {
    font-size: var(--font-size-2xl);
    line-height: 1;
}

.notif-state-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.notif-state-desc {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.notif-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-default);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Notifications dropdown */
.notifications-wrapper {
    position: relative;
}

.notifications-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 360px;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: none;
    flex-direction: column;
    z-index: 1100;
    overflow: hidden;
    animation: slideDown var(--duration-base) var(--easing-out);
}

.notifications-dropdown.open {
    display: flex;
}

.notif-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notif-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.notif-mark-read {
    font-size: var(--font-size-xs);
    color: var(--color-primary);
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
}

.notif-body {
    overflow-y: auto;
    max-height: 320px;
}

.notif-item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    transition: background-color var(--duration-fast);
    cursor: pointer;
}

.notif-item:hover {
    background-color: var(--bg-sunken);
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background-color: var(--color-primary);
    flex-shrink: 0;
    margin-top: 6px;
}

.notif-content-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 2px;
}

.notif-content-time {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.notif-footer {
    padding: var(--space-3) var(--space-5);
    text-align: center;
    border-top: 1px solid var(--border-subtle);
}

.notif-footer a {
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    font-weight: var(--font-weight-medium);
}

/* Theme toggle */
.theme-toggle-btn {
    width: 36px;
    height: 36px;
}

.theme-icon-dark {
    display: none;
}

:root.dark-mode .theme-icon-light {
    display: none;
}

:root.dark-mode .theme-icon-dark {
    display: block;
}

/* Profile Dropdown */
.profile-wrapper {
    position: relative;
}

.profile-trigger {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    cursor: pointer;
    background: none;
    transition: border-color var(--duration-fast), background-color var(--duration-fast);
    height: 36px;
}

.profile-trigger:hover {
    background-color: var(--bg-sunken);
    border-color: var(--border-strong);
}

.profile-avatar-sm {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--brand-500), var(--color-purple));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: var(--font-weight-bold);
    flex-shrink: 0;
}

.profile-caret {
    color: var(--text-tertiary);
    transition: transform var(--duration-base);
}

.profile-wrapper.open .profile-caret {
    transform: rotate(180deg);
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 220px;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: none;
    flex-direction: column;
    z-index: 1100;
    overflow: hidden;
    animation: slideDown var(--duration-base) var(--easing-out);
}

.profile-dropdown.open {
    display: flex;
}

.profile-dropdown-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.profile-dropdown-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    line-height: 1.3;
}

.profile-dropdown-email {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color var(--duration-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    text-decoration: none;
}

.profile-dropdown-item:hover {
    background-color: var(--bg-sunken);
}

.profile-dropdown-item.danger {
    color: var(--color-danger);
}

.profile-dropdown-divider {
    height: 1px;
    background-color: var(--border-subtle);
    margin: var(--space-1) 0;
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    padding: var(--content-padding);
    background-color: var(--bg-page);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Page structure */
.page-container {
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn var(--duration-base) var(--easing-out);
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    gap: var(--space-4);
    flex-wrap: wrap;
}

.page-header-info h1 {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-header-info p {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
    line-height: 1.5;
}

.page-header h1 {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-header p {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
    line-height: 1.5;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

/* Sidebar mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: var(--bg-overlay);
    z-index: 999;
    animation: fadeIn var(--duration-base);
}

.sidebar-overlay.open {
    display: block;
}

/* === RESPONSIVE === */
/* Mobile: overlay drawer */
@media (max-width: 767px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        width: var(--sidebar-width) !important;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open.collapsed {
        width: var(--sidebar-width) !important;
    }

    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .app-container.sidebar-is-collapsed .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .sidebar-toggle {
        display: flex !important;
    }

    .sidebar-collapse-btn {
        display: none !important;
    }

    .header-center {
        max-width: 300px;
    }
}

/* Tablet: default collapsed icon rail; expand still available */
@media (min-width: 768px) and (max-width: 1023px) {
    .sidebar.collapsed {
        width: var(--sidebar-width-collapsed);
    }

    .sidebar:not(.collapsed) {
        width: var(--sidebar-width);
    }

    .app-container.sidebar-is-collapsed .main-wrapper {
        margin-left: var(--sidebar-width-collapsed) !important;
        width: calc(100% - var(--sidebar-width-collapsed)) !important;
    }

    .app-container:not(.sidebar-is-collapsed) .main-wrapper {
        margin-left: var(--sidebar-width) !important;
        width: calc(100% - var(--sidebar-width)) !important;
    }

    .sidebar-toggle {
        display: none !important;
    }

    .sidebar-collapse-btn {
        display: flex !important;
    }
}

@media (max-width: 640px) {
    .header {
        padding: 0 var(--space-4);
        gap: var(--space-3);
    }

    .header-center {
        display: none;
    }

    .main-content {
        padding: var(--space-4);
    }

    .page-header h1,
    .page-header-info h1 {
        font-size: var(--font-size-xl);
    }
}

@media (max-width: 480px) {
    :root {
        --header-height: 56px;
        --content-padding: var(--space-4);
    }
}

/* Collapsible Submenu Styling */
.submenu {
    display: none;
    flex-direction: column;
    padding-left: calc(var(--space-3) + 24px);
    margin: var(--space-1) 0;
    transition: all var(--duration-base) var(--easing-out);
}

.submenu.open {
    display: flex;
}

.submenu-item {
    display: flex;
    align-items: center;
    height: 32px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: var(--font-weight-medium);
    transition: background-color var(--duration-fast), color var(--duration-fast);
    cursor: pointer;
}

.submenu-item:hover {
    background-color: var(--bg-sunken);
    color: var(--text-primary);
}

.submenu-item.active {
    color: var(--color-primary);
    background-color: var(--color-primary-light);
    font-weight: var(--font-weight-semibold);
}

:root.dark-mode .submenu-item.active {
    background-color: rgba(99, 102, 241, 0.12);
    color: var(--brand-400);
}

.submenu-arrow {
    display: flex;
    align-items: center;
    transition: transform var(--duration-base);
    margin-left: auto;
}

.nav-group.open .submenu-arrow {
    transform: rotate(90deg);
}

/* Legacy rule removed — collapsed submenus are flattened to icons in layout.css */