.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 12px;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: var(--z-header);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Navigation hamburger menu */
.nav-menu-toggle {
    font-size: 14px;
}

.nav-menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: var(--z-drawer);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.nav-menu-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

:root {
    --list-pane-width: 370px;
    --davinci-logo-height: 28px;
}

.nav-menu-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--list-pane-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border-secondary);
    box-shadow: none;
    z-index: var(--z-drawer);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 12px;
    transform: translateX(-100%);
    transition: transform 0.1s ease;
}

.nav-menu-drawer.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
}

.nav-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px;
    flex-shrink: 0;
}

.nav-menu-header-logo {
    display: flex;
    align-items: center;
}

.nav-menu-logo-img {
    height: var(--davinci-logo-height);
    width: auto;
}

:root[data-theme='light'] .nav-menu-logo-img {
    filter: invert(1);
}

.nav-menu-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.nav-menu-close:hover {
    background: var(--bg-row-hover);
    color: var(--text-primary);
}

.nav-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.1s;
}

.nav-menu-item:hover {
    background: var(--bg-row-hover);
}

.nav-menu-item i {
    width: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.nav-menu-divider {
    height: 1px;
    background: var(--border-primary);
    margin: 4px 0;
}

.nav-menu-section-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 16px 4px;
}

.nav-menu-spacer {
    flex: 1;
}

.nav-menu-bottom-link {
    margin-bottom: 15px;
}

.nav-menu-projects-section {
    display: flex;
    flex-direction: column;
    max-height: 30vh;
    flex-shrink: 0;
    margin-bottom: 24px;
}

.nav-menu-projects {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.nav-menu-projects .list-item {
    border-radius: 6px;
}

.nav-menu-empty {
    padding: 20px 16px;
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
}

.topbar-logo {
    display: flex;
    align-items: center;
    user-select: none;
    cursor: pointer;
}

.topbar-logo-img {
    height: var(--davinci-logo-height);
    width: auto;
}

:root[data-theme='light'] .topbar-logo-img {
    filter: invert(1);
}

/* Topbar search */
.topbar-search {
    position: relative;
    flex: 1;
    max-width: 480px;
    margin: 0 20px;
}

.topbar-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.topbar-search-input {
    width: 100%;
    height: 32px;
    padding: 0 36px 0 32px;
    border-radius: 6px;
    border: 1px solid var(--border-primary);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

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

.topbar-search-input:focus {
    border-color: var(--accent-purple);
}

.topbar-search.focused .topbar-search-input {
    border-color: var(--accent-purple);
}

.topbar-search-kbd {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
    color: var(--text-tertiary);
    background: var(--bg-badge);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 0 5px;
    line-height: 18px;
    pointer-events: none;
}

.topbar-search-results {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 380px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: var(--z-search-results);
    padding: 4px 0;
}

.topbar-search-results.open {
    display: block;
}

.search-group {
    padding: 4px 0;
}

.search-group+.search-group {
    border-top: 1px solid var(--border-primary);
}

.search-group-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-group-label i {
    font-size: 10px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.08s;
}

.search-result-item:hover,
.search-result-item.active {
    background: var(--bg-row-hover);
}

.search-item-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

.search-item-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.search-item-tag {
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
    flex-shrink: 0;
}

.search-item-tag.owned {
    background: var(--tag-owned-bg);
    color: var(--tag-owned-text);
}

.search-item-tag.shared {
    background: var(--tag-shared-bg);
    color: var(--tag-shared-text);
}

.search-item-tag.org {
    background: var(--accent-purple-subtle);
    color: var(--accent-purple);
}

.search-item-org-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 700;
    color: white;
}

.search-item-meta {
    font-size: 10px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    white-space: nowrap;
}

.search-highlight {
    background: transparent;
    color: var(--accent-purple);
    font-weight: 600;
}

.search-empty {
    padding: 16px 12px;
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
}

/* Close button: hidden at all widths by default */
.topbar-search-close {
    display: none;
}

@media (max-width: 700px) {

    /* Collapsed: icon-only button, left-aligned in its flex slot */
    .topbar-search {
        margin: 0 10px;
        display: flex;
        align-items: center;
    }

    .topbar-search-input,
    .topbar-search-kbd,
    .topbar-search-close {
        display: none;
    }

    .topbar-search-icon {
        position: static;
        transform: none;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 15px;
        color: var(--text-secondary);
        border-radius: 6px;
        pointer-events: auto;
        cursor: pointer;
        transition: background 0.15s, color 0.15s;
    }

    .topbar-search:hover .topbar-search-icon {
        color: var(--text-primary);
    }

    /* Expanded: full-width overlay inside topbar */
    .topbar.search-expanded .topbar-search {
        position: absolute;
        inset: 0;
        width: auto;
        height: auto;
        max-width: none;
        min-width: 0;
        margin: 0;
        border-radius: 0;
        display: flex;
        align-items: center;
        padding: 0 8px;
        background: var(--bg-topbar);
        z-index: var(--z-content);
        cursor: default;
    }

    .topbar.search-expanded .topbar-search:hover {
        background: var(--bg-topbar);
    }

    .topbar.search-expanded .topbar-search-icon {
        position: static;
        transform: none;
        width: auto;
        height: auto;
        font-size: 12px;
        color: var(--text-tertiary);
        border-radius: 0;
        margin-right: 8px;
        flex-shrink: 0;
    }

    .topbar.search-expanded .topbar-search-input {
        display: block;
        flex: 1;
        padding: 0 8px;
        height: 32px;
    }

    .topbar.search-expanded .topbar-search-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        border: none;
        border-radius: 6px;
        background: transparent;
        color: var(--text-secondary);
        font-size: 14px;
        cursor: pointer;
        flex-shrink: 0;
        transition: background 0.15s, color 0.15s;
    }

    .topbar.search-expanded .topbar-search-close:hover {
        background: var(--bg-row-hover);
        color: var(--text-primary);
    }

    .topbar.search-expanded .topbar-search-results {
        top: 100%;
        left: 0;
        right: 0;
    }
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-login-btn {
    height: 28px;
    padding: 0 14px;
    border-radius: 6px;
    border: none;
    background: var(--accent-purple);
    color: white;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s;
}

.topbar-login-btn:hover {
    opacity: 0.85;
}

.topbar-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.topbar-btn:hover {
    background: var(--bg-row-hover);
    color: var(--text-primary);
}

.topbar-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: var(--accent-purple);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.user-menu {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    padding: 4px 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: var(--z-dropdown);
}

.user-dropdown.open {
    display: block;
}

.user-dropdown-header {
    padding: 10px 14px;
}

.user-dropdown-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.user-dropdown-username:empty {
    display: none;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border-primary);
    margin: 4px 0;
}

.user-dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 14px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s;
}

.user-dropdown-item:hover {
    background: var(--bg-row-hover);
}

.user-dropdown-logout {
    color: var(--commit-del);
}

.user-dropdown-logout:hover {
    background: rgba(218, 54, 51, 0.08);
}

/* Site banner */
.site-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 8px 40px 8px 16px;
    font-size: 13px;
    line-height: 1.4;
    transition: opacity 0.3s, max-height 0.3s, padding 0.3s;
    max-height: 200px;
}

.site-banner.banner-hiding {
    opacity: 0;
    max-height: 0;
    padding: 0 40px 0 16px;
}

.site-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.site-banner-icon {
    flex-shrink: 0;
    font-size: 14px;
}

.site-banner-text {}

.site-banner-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.site-banner-link:hover {
    opacity: 0.8;
}

.site-banner-text strong,
.site-banner-text em,
.site-banner-text u {
    color: inherit;
}

.site-banner-dismiss {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.site-banner-dismiss:hover {
    opacity: 1;
}

.site-banner-timer {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-left: 2px;
}

.site-banner-timer circle {
    fill: none;
    stroke-width: 2.5;
}

.site-banner-timer .timer-track {
    stroke: currentColor;
    opacity: 0.2;
}

.site-banner-timer .timer-ring {
    stroke: currentColor;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: center;
    transition: none;
}

.site-banner.banner-info {
    background: var(--accent-purple-subtle);
    color: var(--text-primary);
}

.site-banner.banner-info .site-banner-dismiss {
    color: var(--text-primary);
}

.site-banner.banner-warning {
    background: #fff3cd;
    color: #856404;
}

.site-banner.banner-warning .site-banner-dismiss {
    color: #856404;
}

.site-banner.banner-critical {
    background: #f8d7da;
    color: #721c24;
}

.site-banner.banner-critical .site-banner-dismiss {
    color: #721c24;
}

[data-theme="dark"] .site-banner.banner-warning {
    background: rgba(249, 168, 37, 0.15);
    color: #f9a825;
}

[data-theme="dark"] .site-banner.banner-warning .site-banner-dismiss {
    color: #f9a825;
}

[data-theme="dark"] .site-banner.banner-critical {
    background: rgba(211, 47, 47, 0.15);
    color: #ef5350;
}

[data-theme="dark"] .site-banner.banner-critical .site-banner-dismiss {
    color: #ef5350;
}

/* Notifications dropdown */
.notif-menu {
    position: relative;
}

.notif-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: var(--accent-purple);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    pointer-events: none;
}

.notif-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    max-height: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: var(--z-dropdown);
    overflow: hidden;
    flex-direction: column;
}

.notif-dropdown.open {
    display: flex;
    flex-direction: column;
}

.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}

.notif-refresh-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 11px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.notif-refresh-btn:hover {
    color: var(--text-primary);
    background: var(--bg-row-hover);
}

.notif-refresh-btn.spinning i {
    animation: notif-spin 0.6s linear;
}

@keyframes notif-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.notif-dropdown-body {
    overflow-y: auto;
    max-height: 380px;
    flex: 1;
}

.notif-empty {
    padding: 24px 16px;
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
}

.notif-item {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-primary);
    align-items: flex-start;
    cursor: pointer;
    transition: background 0.15s;
}

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

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

.notif-item-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-primary);
    background: var(--bg-row-hover);
    margin-top: 2px;
}

.notif-item-icon.tenant {
    background: var(--accent-purple);
    color: #fff;
}

.notif-item-icon.org {
    background: var(--accent-blue, #5c6bc0);
    color: #fff;
}

.notif-item-icon.project {
    background: var(--accent-green, #66bb6a);
    color: #fff;
}

.notif-item-icon.alert {
    background: var(--notif-alert-bg);
    color: var(--notif-alert-text);
}

.notif-item-icon.alert-warning {
    background: var(--notif-warning-bg);
    color: var(--notif-warning-text);
}

.notif-item-icon.alert-critical {
    background: var(--notif-critical-bg);
    color: var(--notif-critical-text);
}

.notif-item-icon.account {
    background: var(--notif-account-bg);
    color: var(--notif-account-text);
}

.notif-item-icon.auth {
    background: var(--notif-auth-bg);
    color: var(--notif-auth-text);
}

.notif-item-icon.info {
    background: var(--bg-row-hover);
    color: var(--text-secondary);
}

.notif-item.notif-unread {
    background: var(--accent-purple-subtle);
}

.notif-item.notif-unread:hover {
    background: rgba(149, 117, 205, 0.14);
}

.notif-item.notif-unread .notif-item-text {
    font-weight: 500;
}

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

.notif-item-text {
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 4px;
}

.notif-item-text strong {
    font-weight: 600;
}

.notif-item-time {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}

.notif-item-actions {
    display: flex;
    gap: 6px;
}

.notif-item-actions .compact-button {
    font-size: 10px;
    padding: 3px 8px;
}

.notif-item.removing {
    opacity: 0;
    transition: opacity 0.3s;
}

.notif-item-resolved {
    font-size: 11px;
    color: var(--accent-green, #66bb6a);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.notif-item-resolved i {
    font-size: 10px;
}

.notif-view-all {
    padding: 8px 16px;
    border-top: 1px solid var(--border-primary);
    text-align: center;
    flex-shrink: 0;
}

.notif-view-all a {
    font-size: 12px;
    color: var(--accent-purple);
    text-decoration: none;
}

.notif-view-all a:hover {
    text-decoration: underline;
}

/* Notifications inbox page */
.notif-page-header {
    max-width: 720px;
    margin: 0 auto 16px;
}

.notif-inbox-shell {
    max-width: 720px;
    margin: 0 auto;
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    background: var(--bg-elevated, var(--primary-background));
    overflow: hidden;
}

.notif-inbox {
    max-width: none;
}

.notif-inbox-item {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-primary);
    align-items: flex-start;
    position: relative;
    transition: background 0.15s;
}

.notif-inbox-item.notif-unread {
    cursor: pointer;
}

.notif-inbox-item.notif-unread:hover {
    background: rgba(149, 117, 205, 0.14);
}

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

.notif-inbox-item.notif-unread {
    background: var(--accent-purple-subtle);
}

.notif-inbox-item.notif-unread .notif-item-text {
    font-weight: 500;
}

.notif-inbox-item.removing {
    opacity: 0;
    transition: opacity 0.3s;
}

.notif-archive-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px 6px;
    font-size: 11px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    margin-top: 2px;
}

.notif-inbox-item:hover .notif-archive-btn {
    opacity: 1;
}

.notif-archive-btn:hover {
    color: var(--text-primary);
    background: var(--bg-row-hover);
}

.notif-inbox-footer {
    padding: 12px 16px;
    text-align: center;
    border-top: 1px solid var(--border-primary);
}

.shell {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.list-pane {
    width: var(--list-pane-width);
    min-width: var(--list-pane-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.main-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px 48px;
}

.main-inner {
    max-width: 740px;
    margin: 0 auto;
}

@media (max-width: 900px) {
    .list-pane {
        display: none;
    }
}

/* ================================================
   Detail Layout (shared by project, billing, etc.)
   ================================================ */

:root {
    --detail-content-max-width: 1000px;
    --detail-sidebar-width: 260px;
}

.detail-body {
    flex: 1;
    padding: 16px 24px 32px;
}

.detail-content-wrap {
    max-width: var(--detail-content-max-width);
    margin: 0 auto;
}

.detail-body-inner {
    max-width: var(--detail-content-max-width);
    margin: 0 auto;
}

/* ================================================
   Avatar Bubble (reusable circular avatar)
   ================================================ */

.avatar-bubble {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: white;
    background: var(--accent-purple);
    flex-shrink: 0;
    line-height: 1;
    text-transform: uppercase;
}

.hidden {
    display: none;
}