/* ============================================================
   GILGAMEZ — ADMIN PANEL HEADER / TOPBAR (SECTION A)
   Standardized Header Shell Component (Rule #18)
   ============================================================ */

/* --- 1. Header Container ------------------------------------- */
#admin-header, .admin-header {
    position: sticky;
    top: 0;
    height: 60px;
    z-index: 1200;
    background: var(--bg-surface, var(--cc-bg-surface, #11151c));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle, var(--cc-border, #1f2d42));
    box-sizing: border-box;
}

#navbar-container {
    position: relative;
    z-index: 1200;
    flex-shrink: 0;
    height: 100%;
    overflow: visible;
}

.topbar,
.cc-topbar {
    position: relative;
    z-index: 1200;
    height: 60px;
    flex-shrink: 0;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap !important;
    gap: 14px;
    box-sizing: border-box;
    width: 100%;
    overflow: visible;
}

/* --- 2. Header Left: Brand, Toggle & Breadcrumb Title --------- */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 0 0 auto;
}

.topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    flex-shrink: 0;
}

.topbar-brand-mobile-only {
    display: none;
}
@media (max-width: 991px) {
    .topbar-brand-mobile-only {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        user-select: none;
        flex-shrink: 0;
    }
}

.topbar-brand-title {
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-primary, var(--cc-text, #f1f5f9));
}

.topbar-brand-badge {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: var(--cc-radius-sm, 4px);
    background: var(--cc-status-info-bg, rgba(59, 130, 246, 0.12));
    color: var(--cc-status-info-text, #60a5fa);
    border: 1px solid var(--border-subtle, var(--cc-status-info-border, rgba(59, 130, 246, 0.35)));
    line-height: 1.2;
}

.topbar .admin-breadcrumbs,
#topbar-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted, var(--cc-text-muted, #94a3b8));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar .admin-breadcrumbs .breadcrumb-item,
#topbar-breadcrumbs .breadcrumb-item {
    color: var(--text-muted, var(--cc-text-muted, #94a3b8));
    text-decoration: none;
    transition: color 150ms ease;
    display: inline-flex;
    align-items: center;
}

.topbar .admin-breadcrumbs .breadcrumb-item:hover,
#topbar-breadcrumbs .breadcrumb-item:hover {
    color: var(--color-accent, var(--cc-solid-accent, #c5a059));
}

.topbar .admin-breadcrumbs .breadcrumb-separator,
#topbar-breadcrumbs .breadcrumb-separator {
    color: var(--border-subtle, var(--cc-border, #1f2d42));
    font-size: 12px;
    user-select: none;
    opacity: 0.7;
}

.topbar .admin-breadcrumbs .breadcrumb-current,
#topbar-breadcrumbs .breadcrumb-current {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary, var(--cc-text, #f1f5f9));
    letter-spacing: -0.01em;
}

.topbar-divider {
    width: 1px;
    height: 16px;
    background: var(--border-subtle, var(--cc-border, #1f2d42));
    margin: 0 4px;
    flex-shrink: 0;
}

.topbar-breadcrumb-sep {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--border-subtle, var(--cc-border-strong, #2c3e5a));
    font-size: 13px;
    font-weight: 500;
    margin: 0 6px;
    user-select: none;
    opacity: 0.8;
}

.topbar-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary, var(--cc-text, #f1f5f9));
    margin: 0;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Sidebar toggle controls MUST NOT exist inside the header.
   All sidebar controls strictly reside inside the sidebar container itself (#admin-sidebar).
   Executive Standard: Zero sidebar controls in header or content. */
.sidebar-toggle,
#admin-header .sidebar-toggle,
.topbar-left .sidebar-toggle {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* --- 3. Header Center: Command Palette Trigger (Ctrl+K) ------- */
.topbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    max-width: 480px;
    min-width: 0;
}

.topbar-search-trigger {
    display: flex;
    align-items: center;
    width: 100%;
    height: 34px;
    padding: 0 12px;
    gap: 10px;
    border-radius: var(--cc-radius-md, 6px);
    border: 1px solid var(--cc-border, #1f2d42);
    background: var(--cc-bg-component, #161f30);
    color: var(--cc-text-muted, #94a3b8);
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
    transition: var(--cc-transition, all 150ms ease);
    box-sizing: border-box;
    outline: none;
}

.topbar-search-trigger:hover {
    background: var(--cc-bg-component-hover, #1d2a40);
    border-color: var(--cc-border-hover, #2c3e5a);
    color: var(--cc-text, #f1f5f9);
}

.topbar-search-trigger:focus-visible {
    outline: none;
    border-color: var(--cc-solid-accent, #3b82f6);
    box-shadow: var(--cc-focus-ring);
}

.topbar-search-trigger .search-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--cc-text-subtle, #64748b);
    flex-shrink: 0;
}

.topbar-search-trigger:hover .search-icon {
    color: var(--cc-solid-accent, #3b82f6);
}

.topbar-search-trigger .search-placeholder {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--cc-text-muted, #94a3b8);
}

.topbar-search-trigger .search-kbd {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 600;
    border-radius: var(--cc-radius-sm, 4px);
    background: var(--cc-bg-subtle, #111827);
    border: 1px solid var(--cc-border, #1f2d42);
    color: var(--cc-text-muted, #94a3b8);
    flex-shrink: 0;
}

/* --- 4. Header Right: Heartbeat, Env, Docs, Portal & Profile -- */
.topbar-right {
    display: flex;
    align-items: center;
    flex-wrap: nowrap !important;
    gap: 8px;
    flex: 0 0 auto;
    margin-left: auto;
    overflow: visible;
}

.topbar-heartbeat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border-radius: 9999px;
    border: 1px solid var(--cc-border, #1f2d42);
    background: var(--cc-bg-component, #161f30);
    color: var(--cc-text-muted, #94a3b8);
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--cc-transition, all 150ms ease);
    white-space: nowrap;
    font-family: inherit;
    outline: none;
}

.topbar-heartbeat-pill:hover {
    background: var(--cc-bg-component-hover, #1d2a40);
    border-color: var(--cc-border-hover, #2c3e5a);
    color: var(--cc-text, #f1f5f9);
}

.topbar-heartbeat-pill:focus-visible {
    outline: none;
    border-color: var(--cc-solid-accent, #3b82f6);
    box-shadow: var(--cc-focus-ring);
}

.topbar-heartbeat-pill .heartbeat-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    flex-shrink: 0;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.topbar-heartbeat-pill.is-healthy .heartbeat-dot {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.topbar-heartbeat-pill.is-degraded .heartbeat-dot {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

.topbar-heartbeat-pill.is-offline .heartbeat-dot {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

.topbar-heartbeat-pill.is-pending .heartbeat-dot {
    background: #6366f1;
    animation: cc-pulse 1.2s infinite ease-in-out;
}

@keyframes cc-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.topbar-env-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: var(--cc-transition, all 150ms ease);
    white-space: nowrap;
    font-family: inherit;
}

.topbar-env-pill.pill-prod {
    background: var(--cc-status-danger-bg, rgba(239, 68, 68, 0.12));
    color: var(--cc-status-danger-text, #f87171);
    border: 1px solid var(--cc-status-danger-border, rgba(239, 68, 68, 0.35));
}

.topbar-env-pill.pill-prod:hover {
    background: rgba(239, 68, 68, 0.2);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
}

.topbar-env-pill.pill-dev {
    background: var(--cc-status-success-bg, rgba(16, 185, 129, 0.12));
    color: var(--cc-status-success-text, #34d399);
    border: 1px solid var(--cc-status-success-border, rgba(16, 185, 129, 0.35));
}

.topbar-env-pill.pill-dev:hover {
    background: rgba(16, 185, 129, 0.2);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.25);
}

.topbar-env-pill .topbar-env-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.topbar-language-slot {
    display: inline-flex;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}

.topbar-language-slot .lang-switcher-dropdown {
    position: relative;
    display: inline-flex;
}

.topbar-language-slot .btn-lang-switcher,
#admin-language-switcher-slot .btn-lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 8px;
    border-radius: var(--cc-radius-md, 6px);
    border: 1px solid var(--cc-border, #1f2d42);
    background: var(--cc-bg-component, #161f30);
    color: var(--cc-text-muted, #94a3b8);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--cc-transition, all 150ms ease);
    outline: none;
}

.topbar-language-slot .btn-lang-switcher:hover,
#admin-language-switcher-slot .btn-lang-switcher:hover {
    background: var(--cc-bg-component-hover, #1d2a40);
    border-color: var(--cc-border-hover, #2c3e5a);
    color: var(--cc-text, #f1f5f9);
}

.topbar-language-slot .btn-lang-switcher:focus-visible,
#admin-language-switcher-slot .btn-lang-switcher:focus-visible {
    outline: none;
    border-color: var(--cc-solid-accent, #3b82f6);
    box-shadow: var(--cc-focus-ring);
}

.topbar-language-slot .lang-dropdown-menu,
#admin-language-switcher-slot .lang-dropdown-menu {
    top: calc(100% + 6px);
    right: 0;
    z-index: 2000;
}

.topbar-doc-trigger-btn,
.topbar-portal-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border-radius: var(--cc-radius-md, 6px);
    border: 1px solid var(--cc-border, #1f2d42);
    background: var(--cc-bg-component, #161f30);
    color: var(--cc-text-muted, #94a3b8);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--cc-transition, all 150ms ease);
    white-space: nowrap;
    font-family: inherit;
    outline: none;
}

.topbar-doc-trigger-btn:hover,
.topbar-portal-link:hover {
    background: var(--cc-bg-component-hover, #1d2a40);
    color: var(--cc-text, #f1f5f9);
    border-color: var(--cc-border-hover, #2c3e5a);
}

.topbar-doc-trigger-btn:focus-visible,
.topbar-portal-link:focus-visible {
    outline: none;
    border-color: var(--cc-solid-accent, #3b82f6);
    box-shadow: var(--cc-focus-ring);
}

.topbar-doc-trigger-btn .topbar-btn-icon,
.topbar-portal-link .topbar-btn-icon {
    display: inline-flex;
    align-items: center;
}

/* --- 4. Notification Bell & Panel ---------------------------- */
#notif-bell-container {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.notif-bell-btn {
    position: relative;
    width: 32px;
    height: 30px;
    border-radius: var(--cc-radius-md, 6px);
    background: var(--cc-bg-component, #161f30);
    border: 1px solid var(--cc-border, #1f2d42);
    color: var(--cc-text-muted, #94a3b8);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--cc-transition, all 150ms ease);
    flex-shrink: 0;
    outline: none;
}

.notif-bell-btn:hover {
    background: var(--cc-bg-component-hover, #1d2a40);
    color: var(--cc-text, #f1f5f9);
    border-color: var(--cc-border-hover, #2c3e5a);
}

.notif-bell-btn:focus-visible {
    outline: none;
    border-color: var(--cc-solid-accent, #3b82f6);
    box-shadow: var(--cc-focus-ring);
}

.notif-bell-btn.has-unread {
    color: var(--cc-solid-accent, #3b82f6);
    border-color: var(--cc-border-strong, #2c3e5a);
    background: var(--cc-bg-component, #161f30);
    animation: bell-ring 0.4s ease 0s 1;
}

@keyframes bell-ring {
    0%   { transform: rotate(0); }
    20%  { transform: rotate(-15deg); }
    40%  { transform: rotate(15deg); }
    60%  { transform: rotate(-8deg); }
    80%  { transform: rotate(8deg); }
    100% { transform: rotate(0); }
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 17px;
    height: 17px;
    border-radius: 9px;
    background: var(--cc-status-danger-text, #ef4444);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 1.5px solid var(--cc-bg-app, #0b0f17);
    font-family: inherit;
    line-height: 1;
}

.notif-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-height: 480px;
    background: var(--bg-surface-elevated, var(--cc-bg-dropdown, #161f30));
    border: 1px solid var(--border-subtle, var(--cc-border, #1f2d42));
    border-radius: var(--radius-lg, var(--cc-radius-lg, 12px));
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--border-subtle, rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    z-index: 2500;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.notif-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--border-subtle, #1f2d42);
    flex-shrink: 0;
}

.notif-panel-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--cc-text, #f8fafc);
}

.notif-mark-all-btn {
    background: none;
    border: none;
    color: var(--cc-solid-accent, #3b82f6);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    padding: 4px 8px;
    border-radius: var(--cc-radius-sm, 4px);
    transition: background 0.2s;
}

.notif-mark-all-btn:hover {
    background: var(--cc-accent-glow, rgba(59, 130, 246, 0.12));
}

.notif-list {
    overflow-y: auto;
    flex: 1;
    max-height: 400px;
}

.notif-list::-webkit-scrollbar { width: 4px; }
.notif-list::-webkit-scrollbar-track { background: transparent; }
.notif-list::-webkit-scrollbar-thumb { background: var(--cc-border, #1f2d42); border-radius: 2px; }

.notif-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--cc-text-muted, #94a3b8);
    font-size: 14px;
}

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--cc-border-subtle, rgba(255, 255, 255, 0.04));
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--cc-bg-hover, #1d2a40); }

.notif-item--unread {
    background: var(--cc-bg-subtle, rgba(59, 130, 246, 0.04));
}
.notif-item--unread:hover {
    background: var(--cc-bg-hover, rgba(59, 130, 246, 0.08));
}

.notif-item-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
    line-height: 1;
}

.notif-item-body {
    flex: 1;
    min-width: 0;
}

.notif-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--cc-text, #f8fafc);
    margin-bottom: 3px;
    line-height: 1.3;
}

.notif-item-msg {
    font-size: 12px;
    color: var(--cc-text-muted, #94a3b8);
    line-height: 1.5;
    word-break: break-word;
}

.notif-item-time {
    font-size: 11px;
    color: var(--cc-text-subtle, #64748b);
    margin-top: 5px;
}

.notif-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cc-solid-accent, #3b82f6);
    flex-shrink: 0;
    margin-top: 5px;
    box-shadow: 0 0 6px var(--cc-accent-glow, rgba(59, 130, 246, 0.6));
}

/* --- 5. Responsive Header Breakdown (Rule #6 — 5 Viewport Tiers) --- */

/* 5.1 Large Desktop (Tier 1: >= 1441px) */
@media (min-width: 1441px) {
    .topbar {
        padding: 0 24px;
        gap: 16px;
    }
    .topbar-center {
        max-width: 480px;
    }
    .topbar-title {
        font-size: 15px;
    }
}

/* 5.2 Standard Laptop / Desktop (Tier 2: 1201px - 1440px) */
@media (max-width: 1440px) {
    .topbar {
        padding: 0 16px;
        gap: 10px;
    }
    .topbar-center {
        max-width: 360px;
    }
    /* Collapse text labels on utility buttons to clean 32px icon buttons */
    .topbar-doc-trigger-btn .topbar-btn-text,
    .topbar-portal-link .topbar-btn-text {
        display: none !important;
    }
    .topbar-doc-trigger-btn,
    .topbar-portal-link {
        padding: 0 !important;
        width: 32px !important;
        height: 30px !important;
        min-width: 32px !important;
        justify-content: center !important;
        gap: 0 !important;
    }
    /* Operator Avatar is a dedicated circular interactive trigger */
    .topbar-operator-name {
        display: none !important;
    }
    .topbar-title {
        max-width: 160px;
    }
}

/* 5.3 Small Laptop / Tablet Landscape (Tier 3: 992px - 1200px) */
@media (max-width: 1200px) {
    .topbar {
        padding: 0 14px;
        gap: 8px;
    }
    /* Hide title and breadcrumb divider to prevent collision */
    .topbar-divider,
    .topbar-title {
        display: none !important;
    }
    /* Shorten env pill and heartbeat pill */
    .topbar-env-pill .topbar-env-label {
        display: none !important;
    }
    .topbar-env-pill {
        padding: 0 !important;
        width: 30px !important;
        height: 30px !important;
        justify-content: center !important;
        gap: 0 !important;
    }
    .topbar-heartbeat-pill .heartbeat-label {
        display: none !important;
    }
    .topbar-heartbeat-pill {
        padding: 0 !important;
        width: 28px !important;
        height: 28px !important;
        justify-content: center !important;
        gap: 0 !important;
    }
    /* Compress search trigger */
    .topbar-center {
        max-width: 240px;
    }
    .topbar-search-trigger .search-kbd {
        display: none !important;
    }
    .topbar-search-trigger .search-placeholder {
        font-size: 11.5px;
    }
}

/* 5.4 Tablet Portrait / Drawer Trigger Breakpoint (Tier 4: 768px - 991px) */
@media (max-width: 991px) {
    .topbar {
        padding: 0 12px;
        gap: 8px;
    }
    .sidebar-toggle { display: none !important;
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        min-height: 34px !important;
    }
    .topbar-brand-badge {
        display: none !important;
    }
    /* Collapse search input into 34px icon button */
    .topbar-center {
        flex: 0 0 auto !important;
        max-width: 34px !important;
        width: 34px !important;
    }
    .topbar-search-trigger {
        width: 34px !important;
        height: 34px !important;
        padding: 0 !important;
        justify-content: center !important;
        border-radius: var(--cc-radius-md, 6px);
    }
    .topbar-search-trigger .search-placeholder,
    .topbar-search-trigger .search-kbd {
        display: none !important;
    }
    .topbar-search-trigger .search-icon {
        margin: 0 !important;
    }
    .topbar-doc-trigger-btn,
    .topbar-portal-link {
        width: 32px !important;
        height: 32px !important;
    }
    .notif-bell-btn {
        width: 32px !important;
        height: 32px !important;
    }
}

/* 5.5 Mobile Portrait Tier (Tier 5: 361px - 767px) */
@media (max-width: 767px) {
    #admin-header,
    .admin-header,
    .topbar,
    .cc-topbar {
        height: 54px !important;
        min-height: 54px !important;
    }
    .topbar {
        padding: 0 8px !important;
        gap: 6px !important;
    }
    .topbar-left {
        gap: 6px !important;
    }
    .sidebar-toggle {
        width: 32px !important;
        height: 32px !important;
    }
    .topbar-brand-title {
        font-size: 13.5px !important;
    }
    /* Hide non-critical utility buttons on small mobile */
    .topbar-heartbeat-pill,
    .topbar-env-pill,
    .topbar-doc-trigger-btn,
    .topbar-portal-link {
        display: none !important;
    }
    .topbar-right {
        gap: 6px !important;
    }
    .notif-bell-btn {
        width: 32px !important;
        height: 32px !important;
    }
    .topbar-operator-btn {
        height: 32px !important;
        padding: 0 !important;
    }
    .topbar-operator-chevron {
        display: none !important;
    }
    .notif-panel {
        position: fixed !important;
        top: 54px !important;
        right: 8px !important;
        left: 8px !important;
        width: auto !important;
        max-width: none !important;
    }
}

/* 5.6 Ultra-Narrow Mobile Viewport (<= 360px, e.g. iPhone SE 320px) */
@media (max-width: 360px) {
    .topbar {
        padding: 0 4px !important;
        gap: 4px !important;
    }
    .topbar-left {
        gap: 4px !important;
    }
    .sidebar-toggle {
        width: 30px !important;
        height: 30px !important;
    }
    .topbar-brand-title {
        font-size: 12px !important;
    }
    .topbar-center {
        display: none !important;
    }
    .notif-bell-btn,
    .topbar-operator-btn {
        width: 30px !important;
        height: 30px !important;
    }
}

/* 5.7 WCAG 2.5.5 / 2.5.8 Touch Target Hit Area Guarantee (Rule #6 min 44px) */
@media (max-width: 768px) {
    .sidebar-toggle,
    .topbar-env-pill,
    .topbar-language-slot .btn-lang-switcher,
    #admin-language-switcher-slot .btn-lang-switcher,
    .topbar-doc-trigger-btn,
    .notif-bell-btn,
    .topbar-portal-link {
        position: relative;
    }

    .sidebar-toggle::after,
    .topbar-env-pill::after,
    .topbar-language-slot .btn-lang-switcher::after,
    #admin-language-switcher-slot .btn-lang-switcher::after,
    .topbar-doc-trigger-btn::after,
    .notif-bell-btn::after,
    .topbar-portal-link::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        min-width: 44px;
        min-height: 44px;
        width: 100%;
        height: 100%;
        pointer-events: auto;
    }
}

/* --- 6. Operator Profile Menu & Avatar Constraints (Rule #18) --- */
.topbar-operator-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.topbar-operator-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    background: var(--cc-bg-component, #161f30);
    border: 1.5px solid var(--cc-border, #1f2d42);
    cursor: pointer;
    outline: none !important;
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
                border-color 0.25s ease,
                background-color 0.25s ease;
    isolation: isolate;
}

/* Precision rotating conic cyber trace ring on hover */
.topbar-operator-btn::before {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    padding: 1.5px;
    background: conic-gradient(from 0deg, var(--cc-solid-accent, #3b82f6), var(--cc-accent-glow, rgba(59, 130, 246, 0.4)), var(--cc-solid-accent-hover, #2563eb), var(--cc-solid-accent, #3b82f6));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transform: rotate(0deg) scale(0.9);
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    z-index: 1;
}

.topbar-operator-btn:hover {
    transform: translateY(-1px) scale(1.06);
    border-color: transparent;
}

.topbar-operator-btn:hover::before {
    opacity: 1;
    transform: rotate(180deg) scale(1);
}

.topbar-operator-btn:hover .topbar-avatar-img,
.topbar-operator-btn:hover .topbar-avatar-initial {
    transform: scale(1.08);
}

.topbar-operator-btn:focus-visible {
    outline: none !important;
    border-color: var(--cc-solid-accent, #3b82f6) !important;
    box-shadow: var(--cc-focus-ring) !important;
}

.topbar-operator-btn[aria-expanded="true"] {
    border-color: transparent;
    transform: scale(1.04);
}

.topbar-operator-btn[aria-expanded="true"]::before {
    opacity: 1;
    transform: rotate(360deg) scale(1);
}

.topbar-avatar-img {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    max-width: 28px !important;
    max-height: 28px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    display: block !important;
    border: none !important;
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.topbar-avatar-initial {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    max-width: 28px;
    max-height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--cc-solid-accent, #3b82f6), var(--cc-solid-accent-hover, #2563eb));
    color: #ffffff;
    text-transform: uppercase;
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.topbar-operator-name {
    display: none;
}

.topbar-operator-chevron {
    display: none;
}

.topbar-operator-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: var(--bg-surface-elevated, var(--cc-bg-dropdown, #161f30));
    border: 1px solid var(--border-subtle, var(--cc-border, #1f2d42));
    border-radius: var(--radius-lg, var(--cc-radius-lg, 12px));
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--border-subtle, rgba(255, 255, 255, 0.05));
    padding: 8px;
    z-index: 2500;
    display: none;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.topbar-operator-dropdown.is-open {
    display: block !important;
}

.topbar-user-card {
    padding: 10px 12px;
    border-radius: var(--radius-md, var(--cc-radius-md, 6px));
    background: var(--bg-surface-inset, var(--cc-bg-subtle, #111827));
    margin-bottom: 6px;
    border: 1px solid var(--border-subtle, var(--cc-border-subtle, #1f2d42));
}

.topbar-user-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary, var(--cc-text, #f1f5f9));
    line-height: 1.3;
}

.topbar-user-email {
    font-size: 12px;
    color: var(--text-muted, var(--cc-text-muted, #94a3b8));
    margin-top: 2px;
    word-break: break-all;
}

.topbar-user-role {
    display: inline-block;
    margin-top: 6px;
    font-size: 10.5px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
    letter-spacing: 0.05em;
    border: 1px solid var(--border-subtle, var(--cc-border, #1f2d42));
    background: var(--bg-surface, var(--cc-bg-component, #161f30));
    color: var(--color-accent, var(--cc-solid-accent, #c5a059));
}

.topbar-menu-divider {
    height: 1px;
    background: var(--border-subtle, var(--cc-border, #1f2d42));
    margin: 6px 0;
}

.topbar-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-muted, var(--cc-text-muted, #94a3b8));
    border-radius: var(--radius-md, var(--cc-radius-md, 6px));
    text-decoration: none;
    transition: var(--cc-transition, all 120ms ease);
    cursor: pointer;
    box-sizing: border-box;
    outline: none;
    background: transparent;
    border: none;
    font-family: inherit;
    text-align: left;
}

.topbar-menu-item:hover {
    background: var(--bg-surface-hover, var(--cc-bg-hover, #1d2a40));
    color: var(--text-primary, var(--cc-text, #ffffff));
}

.topbar-menu-item:focus-visible {
    outline: none;
    background: var(--bg-surface-hover, var(--cc-bg-hover, #1d2a40));
    color: var(--text-primary, var(--cc-text, #ffffff));
}

.topbar-menu-item.text-danger {
    color: var(--cc-status-danger-text, #f87171);
}

.topbar-menu-item.text-danger:hover {
    background: var(--cc-status-danger-bg, rgba(239, 68, 68, 0.12));
    color: #ef4444;
}
