.topbar {
    min-height: 68px;
    background: color-mix(in oklab, var(--topbar-bg, #fff) 95%, transparent);
    border-bottom: 1px solid var(--topbar-border, #dbe3ee);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-left {
    flex: 1 1 auto;
}

.topbar-right {
    flex: 0 1 auto;
}

.topbar-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 19px;
    font-weight: 700;
    color: var(--topbar-text, #0f172a);
}

.menu-toggle,
.topbar-icon-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--topbar-chip-border, var(--border-color, #dbe3ee));
    border-radius: 11px;
    background: var(--topbar-chip-bg, var(--surface-muted, #f8fafc));
    color: var(--topbar-chip-text, var(--text-color, #0f172a));
    cursor: pointer;
    transition: var(--transition, .2s);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.topbar-icon-btn:hover,
.menu-toggle:hover {
    transform: translateY(-1px);
    background: var(--topbar-chip-hover, var(--surface-muted, #f8fafc));
    box-shadow: var(--shadow-hover, 0 16px 38px rgba(37, 99, 235, .16));
}

.topbar-icon-btn:active,
.menu-toggle:active {
    transform: translateY(0);
}

.topbar-icon-btn:focus-visible,
.menu-toggle:focus-visible {
    box-shadow: var(--focus-ring, 0 0 0 3px rgba(37, 99, 235, .2));
}

.topbar-icon-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.topbar-icon-btn.message-btn {
    position: relative;
    overflow: visible;
}

.topbar-icon-btn.message-btn::after {
    content: none;
}

.topbar-icon-btn.message-btn .topbar-message-icon {
    width: 22px;
    height: 22px;
    stroke-width: 2.15;
}

.topbar-icon-btn.message-btn.is-active {
    border-color: color-mix(in oklab, var(--accent-color, #2563eb) 45%, var(--topbar-chip-border, #dbe3ee));
    background: color-mix(in oklab, var(--accent-color, #2563eb) 14%, var(--topbar-chip-bg, #f8fafc));
    color: var(--accent-color, #2563eb);
    box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent-color, #2563eb) 14%, transparent);
}

.topbar-time-chip,
.topbar-subscription-chip,
.topbar-user {
    min-height: 40px;
    border-radius: 12px;
    border: 1px solid var(--topbar-chip-border, var(--border-color, #dbe3ee));
    background: var(--topbar-chip-bg, var(--surface-muted, #f8fafc));
    color: var(--topbar-chip-text, var(--text-color, #0f172a));
}

.topbar-time-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 11px;
}

.topbar-time-chip i,
.topbar-subscription-chip i {
    color: var(--accent-color, #2563eb);
    flex: 0 0 auto;
    opacity: .94;
}

.topbar-time-chip strong {
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
}

.topbar-time-chip small {
    color: var(--text-subtle, #94a3b8);
    font-size: 11px;
    font-weight: 500;
}

.topbar-subscription-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 11px;
    max-width: 230px;
    text-align: left;
    color: var(--topbar-chip-text, var(--text-color, #0f172a));
    cursor: pointer;
    font-weight: 500;
}

.topbar-subscription-chip span {
    min-width: 0;
    display: grid;
    gap: 1px;
}

.topbar-subscription-chip strong,
.topbar-subscription-chip small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-subscription-chip strong {
    font-size: 12px;
    font-weight: 600;
}

.topbar-subscription-chip small {
    font-size: 10px;
    color: var(--text-muted, #64748b);
}

.topbar-subscription-chip.is-warning {
    border-color: color-mix(in oklab, var(--warning, #f59e0b) 55%, transparent);
    background: color-mix(in oklab, var(--warning, #f59e0b) 18%, transparent);
}

.topbar-subscription-chip.is-urgent,
.topbar-subscription-chip.is-expired {
    border-color: color-mix(in oklab, var(--danger, #ef4444) 55%, transparent);
    background: color-mix(in oklab, var(--danger, #ef4444) 18%, transparent);
}

.topbar-subscription-chip [data-id="subscription-badge-count"] {
    color: inherit;
}

.topbar-dropdown {
    position: relative;
}

.topbar-icon-btn.notification-btn {
    position: relative;
}

.notification-btn {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 17px;
    height: 17px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--state-danger, #ef4444);
    color: var(--text-color-inverse, #fff);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.message-badge {
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    box-shadow: 0 0 0 2px var(--topbar-bg, #fff);
    z-index: 1;
}

.notification-badge.show {
    display: inline-flex;
}

.topbar-dropdown-menu {
    position: absolute;
    top: 52px;
    right: 0;
    width: 228px;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #dbe3ee);
    border-radius: 12px;
    padding: 8px;
    display: none;
    box-shadow: var(--topbar-dropdown-shadow, var(--shadow-soft, 0 12px 42px rgba(15, 23, 42, .28)));
    z-index: 1000;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.topbar-dropdown-menu.show {
    display: block;
}

.notification-menu {
    width: min(380px, calc(100vw - 24px));
    padding: 0;
}

.topbar-user {
    max-width: 340px;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border-color, #dbe3ee);
    background: transparent;
    cursor: pointer;
    text-align: left;
    padding: 0 10px;
}

.topbar-avatar,
.topbar-avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    flex: 0 0 auto;
}

.topbar-avatar {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent-color, #2563eb), color-mix(in oklab, var(--accent-color, #2563eb) 72%, var(--primary-color, #2563eb)));
    color: var(--text-color-inverse, #fff);
    font-weight: 700;
}

.topbar-avatar-img {
    object-fit: cover;
    background: var(--surface-muted, #f8fafc);
}

.topbar-user-info {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.topbar-user-name {
    display: block;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color, #0f172a);
}

.topbar-user-role {
    display: block;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    color: var(--text-muted, #64748b);
}

.account-chevron {
    color: var(--text-muted, #64748b);
    font-size: 11px;
}

.notification-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid var(--border-color, #dbe3ee);
}

.notification-menu-title {
    color: var(--text-color, #0f172a);
    font-weight: 600;
}

.notification-menu-subtitle {
    color: var(--text-subtle, #94a3b8);
    font-size: 12px;
}

.notification-menu-header button {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--surface-muted, #f8fafc);
    color: var(--text-color, #0f172a);
    cursor: pointer;
}

.notification-menu-list {
    max-height: 340px;
    overflow-y: auto;
}

.notification-dropdown-item {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border: 0;
    border-bottom: 1px solid var(--border-color, #dbe3ee);
    background: transparent;
    color: var(--text-color, #0f172a);
    text-align: left;
    cursor: pointer;
}

.notification-dropdown-item:hover {
    background: color-mix(in oklab, var(--surface-hover) 78%, transparent);
}

.notification-dropdown-item.unread .notification-dropdown-title::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 7px;
    border-radius: 999px;
    background: var(--accent-color, #2563eb);
}

.notification-dropdown-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--accent-weak, #dbeafe);
    color: var(--accent-color, #2563eb);
}

.notification-dropdown-content {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.notification-dropdown-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-color, #0f172a);
    font-size: 13px;
    font-weight: 600;
}

.notification-dropdown-message {
    display: -webkit-box;
    overflow: hidden;
    color: var(--text-muted, #64748b);
    font-size: 12px;
    line-height: 1.3;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.notification-dropdown-time {
    color: var(--text-subtle, #94a3b8);
    font-size: 11px;
}

.notification-dropdown-empty {
    min-height: 130px;
    display: grid;
    place-items: center;
    gap: 8px;
    padding: 18px;
    color: var(--text-muted, #64748b);
    text-align: center;
    font-size: 12px;
}

.notification-view-all {
    width: 100%;
    min-height: 42px;
    border: 0;
    background: var(--surface-muted, #f8fafc);
    color: var(--accent-color, #2563eb);
    cursor: pointer;
    font-weight: 600;
}

.account-menu,
.theme-menu {
    width: 260px;
    padding: 8px;
}

.account-menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-bottom: 1px solid var(--border-color, #dbe3ee);
    margin-bottom: 6px;
}

.account-menu-header > div {
    min-width: 0;
}

.account-menu-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-color, #0f172a);
    font-weight: 600;
}

.account-menu-role {
    color: var(--text-muted, #64748b);
    font-size: 12px;
    font-weight: 500;
}

.account-menu-item,
.lang-item,
.theme-item {
    width: 100%;
    min-height: 40px;
    border: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    background: transparent;
    color: var(--text-color, #0f172a);
    cursor: pointer;
    font-weight: 500;
    text-align: left;
}

.account-menu-item:hover {
    background: var(--surface-muted, #f8fafc);
}

.account-menu-item.danger {
    color: var(--danger, #ef4444);
}

.lang-item,
.theme-item {
    min-height: 46px;
    padding: 8px 10px;
    transition: .2s;
}

.theme-menu-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--accent-weak, #dbeafe);
    color: var(--accent-color, #2563eb);
}

.theme-menu-icon svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-item span {
    min-width: 0;
    display: grid;
    gap: 1px;
}

.theme-item small {
    color: var(--text-subtle, #94a3b8);
    font-size: 11px;
}

.lang-item:hover,
.theme-item:hover {
    background: color-mix(in oklab, var(--accent-weak, #dbeafe) 78%, var(--card-bg, #ffffff));
    color: var(--accent-color, #2563eb);
    transform: translateX(1px);
}

.lang-item.active,
.theme-item.active {
    background: color-mix(in oklab, var(--accent-weak, #dbeafe) 86%, var(--card-bg, #ffffff));
    color: var(--accent-color, #2563eb);
    font-weight: 800;
}

.theme-item.active .theme-menu-icon,
.lang-item.active .theme-menu-icon {
    background: var(--accent-color, #2563eb);
    color: var(--text-color-inverse, #ffffff);
}

.lang-item.active small,
.theme-item.active small {
    color: var(--text-muted, #64748b);
    font-weight: 700;
}

body[data-theme="dark"] .theme-item.active,
body[data-theme="dark"] .lang-item.active {
    background: color-mix(in oklab, var(--accent-color, #60a5fa) 20%, var(--card-bg, #172033));
    color: var(--text-color, #f8fafc);
}

body[data-theme="dark"] .theme-item.active small,
body[data-theme="dark"] .lang-item.active small {
    color: var(--text-subtle, #9fb0c7);
}

.topbar-time-chip[hidden],
.topbar-subscription-chip[hidden] {
    display: none;
}

@media (max-width: 768px) {
    .topbar {
        padding: 0 12px;
        gap: 10px;
    }

    .topbar-left {
        flex: 0 0 auto;
    }

    .topbar-right {
        flex: 1 1 auto;
        justify-content: flex-end;
        gap: 9px;
    }

    .topbar-time-chip,
    .topbar-user-info,
    .topbar-title {
        display: none;
    }

    .topbar-user {
        gap: 8px;
        padding: 0;
    }

    .topbar-dropdown-menu {
        width: min(340px, calc(100vw - 24px));
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }

    .account-menu,
    .notification-menu {
        top: calc(100% + 6px);
        max-height: calc(100dvh - 92px);
    }
}
