.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-language-label {
    margin-left: 4px;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}

.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;
}

.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-detail {
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted, #64748b);
    font-size: 11px;
    font-weight: 600;
}

.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);
    font-size: 16px;
    line-height: 1;
}

.theme-menu-icon i {
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    line-height: 18px;
    text-align: center;
}

.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);
}

.account-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1400;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(6px);
}

.account-modal {
    width: min(760px, 100%);
    max-height: min(88dvh, 720px);
    overflow: hidden;
    border: 1px solid var(--border-color, #dbe3ee);
    border-radius: 18px;
    background: var(--card-bg, #ffffff);
    color: var(--text-color, #0f172a);
    box-shadow: var(--shadow-soft, 0 22px 65px rgba(15, 23, 42, .28));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.account-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--border-color, #dbe3ee);
}

.account-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0;
}

.account-modal-header p {
    margin: 4px 0 0;
    color: var(--text-muted, #64748b);
    font-size: 13px;
}

.account-modal-close {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border-color, #dbe3ee);
    border-radius: 11px;
    background: var(--surface-muted, #f8fafc);
    color: var(--text-color, #0f172a);
    display: grid;
    place-items: center;
    cursor: pointer;
}

.account-modal-body {
    min-height: 0;
    overflow-y: auto;
    padding: 20px 22px 22px;
}

.account-modal-loading {
    min-height: 180px;
    display: grid;
    place-items: center;
    color: var(--text-muted, #64748b);
}

.account-form {
    display: grid;
    gap: 16px;
}

.account-profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.account-profile-grid.single {
    grid-template-columns: minmax(0, 1fr);
}

.account-field {
    display: grid;
    gap: 6px;
    margin: 0;
    color: var(--text-color, #0f172a);
}

.account-field span {
    color: var(--text-color, #0f172a);
    font-size: 12px;
    font-weight: 700;
}

.account-field input,
.account-password-field input,
.account-readonly-box {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--input-border, var(--border-color, #dbe3ee));
    border-radius: 12px;
    background: var(--input-bg, var(--surface-muted, #f8fafc));
    color: var(--input-text, var(--text-color, #0f172a));
    padding: 0 12px;
    font: inherit;
}

.account-field input:focus,
.account-password-field input:focus {
    outline: 0;
    border-color: var(--accent-color, #2563eb);
    box-shadow: var(--focus-ring, 0 0 0 3px rgba(37, 99, 235, .2));
}

.account-field input[readonly],
.account-readonly-box {
    background: var(--readonly-bg, color-mix(in oklab, var(--surface-muted, #f8fafc) 86%, var(--card-bg, #ffffff)));
    color: var(--text-muted, #64748b);
}

.account-readonly-box {
    display: flex;
    align-items: center;
}

.account-password-field {
    position: relative;
}

.account-password-field input {
    padding-right: 44px;
}

.account-password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted, #64748b);
    display: grid;
    place-items: center;
    cursor: pointer;
}

.account-password-toggle:hover {
    background: var(--surface-muted, #f8fafc);
    color: var(--accent-color, #2563eb);
}

.account-modal-hint {
    margin: -4px 0 0;
    color: var(--text-muted, #64748b);
    font-size: 12px;
}

.account-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 2px;
}

.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);
    }

    .account-modal {
        max-height: 92dvh;
    }

    .account-modal-header,
    .account-modal-body {
        padding-left: 16px;
        padding-right: 16px;
    }

    .account-profile-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}
