.cbmg-theme-header {
    position: relative;
    z-index: 50;
    background: var(--cbmg-theme-surface);
    border-bottom: 1px solid var(--cbmg-theme-border);
    color: var(--cbmg-theme-text);
}

.cbmg-theme-header__inner {
    min-height: 82px;
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto minmax(120px, 1fr);
    align-items: center;
    gap: 18px;
}

.cbmg-theme-header__left { display: flex; align-items: center; justify-content: flex-start; }
.cbmg-theme-header__center { display: flex; align-items: center; justify-content: center; min-width: 0; }
.cbmg-theme-header__right { display: flex; align-items: center; justify-content: flex-end; min-width: 0; }

.cbmg-theme-header__brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 160px;
    text-align: center;
}

.cbmg-theme-logo img { max-height: 58px; width: auto; display: block; }
.cbmg-theme-logo-link { color: var(--cbmg-theme-primary); font-weight: 600; text-decoration: none; }
.cbmg-theme-logo-link--image { display: inline-flex; align-items: center; justify-content: center; }
.cbmg-theme-logo-link--image img { max-height: 58px; width: auto; display: block; }

.cbmg-theme-header__identity { min-height: 1px; }
.cbmg-theme-auth-links { display: inline-flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.cbmg-theme-auth-link { font-size: 13px; font-weight: 500; line-height: 1; text-decoration: none; color: var(--cbmg-theme-secondary); transition: color .2s ease, transform .2s ease; }
.cbmg-theme-auth-link:hover { color: var(--cbmg-theme-primary); transform: translateY(-1px); }

.cbmg-theme-header__actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }

.cbmg-theme-grid-mega-toggle {
    appearance: none;
    border: 0 !important;
    background: transparent !important;
    color: var(--cbmg-theme-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 0;
    text-decoration: none;
    cursor: pointer;
    box-shadow: none !important;
    transition: transform .2s ease, color .2s ease;
}
.cbmg-theme-grid-mega-toggle:hover { transform: translateY(-2px); color: var(--cbmg-theme-secondary); box-shadow: none !important; }
.cbmg-theme-grid-icon { position: relative; display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; }
.cbmg-theme-grid-icon > span {
    width: 6px;
    height: 6px;
    border-radius: 8px;
    background: currentColor;
    box-shadow:
        -10px -10px 0 currentColor, 0 -10px 0 currentColor, 10px -10px 0 currentColor,
        -10px 0 0 currentColor, 10px 0 0 currentColor,
        -10px 10px 0 currentColor, 0 10px 0 currentColor, 10px 10px 0 currentColor;
}

.cbmg-theme-action-link,
.cbmg-theme-language-toggle {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--cbmg-theme-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 54px;
    block-size: 30px;
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
    box-shadow: none;
    transition: transform .2s ease, color .2s ease, background-color .2s ease, box-shadow .2s ease;
}

.cbmg-theme-healthy-toggle { background: var(--cbmg-theme-secondary); color: #FFFFFF; }
.cbmg-theme-healthy-toggle.is-active { background: var(--cbmg-theme-accent); color: #FFFFFF; }
.cbmg-theme-healthy-toggle:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(28,52,64,.12); }
.cbmg-theme-action-icon { font-size: 17px; line-height: 1; }

.cbmg-theme-language-toggle {
    inline-size: 42px;
    background: transparent;
    color: var(--cbmg-theme-secondary);
}
.cbmg-theme-language-toggle:hover { transform: translateY(-2px); color: var(--cbmg-theme-primary); box-shadow: none; }
.cbmg-theme-language-flag { font-size: 17px; line-height: 1; }

.cbmg-theme-mode-toggle {
    appearance:none;
    border:0;
    inline-size:54px;
    block-size:30px;
    border-radius:999px;
    background:var(--cbmg-theme-primary);
    color:var(--cbmg-theme-bg);
    padding:3px;
    display:inline-flex;
    align-items:center;
    justify-content:flex-start;
    position:relative;
    box-shadow:inset 0 0 0 1px rgba(28,52,64,.12);
    cursor:pointer;
    transition:background-color .2s ease,color .2s ease,box-shadow .2s ease;
}
.cbmg-theme-mode-toggle::before {
    content:"☾";
    inline-size:24px;
    block-size:24px;
    border-radius:999px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    background:var(--cbmg-theme-bg);
    color:var(--cbmg-theme-primary);
    font-size:15px;
    line-height:1;
    transition:transform .2s ease,background-color .2s ease,color .2s ease;
}
.cbmg-theme-mode-toggle:hover { box-shadow:0 8px 18px rgba(28,52,64,.12); }
.cbmg-theme-mode-toggle__day,.cbmg-theme-mode-toggle__night{display:none!important;}
html[data-cbmg-mode="night"] .cbmg-theme-mode-toggle,
body.cbmg-night-mode .cbmg-theme-mode-toggle { background:var(--cbmg-theme-bg); color:var(--cbmg-theme-secondary); box-shadow:inset 0 0 0 1px rgba(244,242,238,.22); }
html[data-cbmg-mode="night"] .cbmg-theme-mode-toggle::before,
body.cbmg-night-mode .cbmg-theme-mode-toggle::before { content:"☀"; transform:translateX(24px); background:#F4F2EE; color:var(--cbmg-theme-secondary); }

.cbmg-theme-mobile-toggle { appearance: none; border: 1px solid var(--cbmg-theme-border); background: var(--cbmg-theme-surface); color: var(--cbmg-theme-primary); border-radius: 8px; min-width: 42px; min-height: 42px; display: none; align-items: center; justify-content: center; cursor: pointer; flex-direction: column; gap: 4px; }
.cbmg-theme-mobile-toggle span { width: 20px; height: 2px; background: currentColor; display: block; }

.cbmg-theme-header__nav-row { border-top: 1px solid rgba(226,223,216,.55); }
.cbmg-theme-primary-nav { display: flex; align-items: center; justify-content: center; min-height: 42px; }

.cbmg-theme-mega-wrap { background: var(--cbmg-theme-surface); border-top: 1px solid var(--cbmg-theme-border); border-bottom: 1px solid var(--cbmg-theme-border); box-shadow: 0 10px 24px rgba(0,0,0,.06); }
.cbmg-theme-mega-wrap[hidden] { display: none; }

html[data-cbmg-mode="night"] .cbmg-theme-grid-mega-toggle,
body.cbmg-night-mode .cbmg-theme-grid-mega-toggle { color: #FFFFFF; }
html[data-cbmg-mode="night"] .cbmg-theme-grid-mega-toggle:hover,
body.cbmg-night-mode .cbmg-theme-grid-mega-toggle:hover { color: var(--cbmg-theme-secondary); }

html[data-cbmg-mode="night"] .cbmg-theme-language-toggle,
body.cbmg-night-mode .cbmg-theme-language-toggle { color: var(--cbmg-theme-bg); }
html[data-cbmg-mode="night"] .cbmg-theme-language-toggle:hover,
body.cbmg-night-mode .cbmg-theme-language-toggle:hover { color: #FFFFFF; }

html[data-cbmg-mode="night"] .cbmg-theme-header,
body.cbmg-night-mode .cbmg-theme-header { background: var(--cbmg-theme-night-surface); border-color: rgba(244,242,238,.18); }
html[data-cbmg-mode="night"] .cbmg-theme-header__nav-row,
body.cbmg-night-mode .cbmg-theme-header__nav-row { border-color: rgba(244,242,238,.14); }

@media (max-width: 1024px) {
    .cbmg-theme-primary-nav { display: none; }
    .cbmg-theme-header__nav-row { display: none; }
    .cbmg-theme-mobile-toggle { display: inline-flex; }
    .cbmg-theme-header__inner { grid-template-columns: auto 1fr auto; gap: 12px; }
}

@media (max-width: 767px) {
    .cbmg-theme-header__inner { min-height: 72px; }
    .cbmg-theme-header__brand { min-width: auto; }
    .cbmg-theme-header__actions { gap: 8px; }
    .cbmg-theme-language-toggle { inline-size: 34px; }
    .cbmg-theme-healthy-toggle { inline-size: 44px; }
    .cbmg-theme-logo img,
    .cbmg-theme-logo-link--image img { max-height: 48px; }
}


/* ============================================================
   CBMG Theme v1.0.7 — Header precision refinements
   ============================================================ */
.cbmg-theme-header,
html[data-cbmg-mode="night"] .cbmg-theme-header,
body.cbmg-night-mode .cbmg-theme-header {
    background: var(--cbmg-theme-bg) !important;
}

.cbmg-theme-header__inner {
    grid-template-columns: minmax(90px, 1fr) auto minmax(220px, 1fr);
}

.cbmg-theme-header__actions {
    gap: 18px;
}

.cbmg-theme-grid-mega-toggle {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}
.cbmg-theme-grid-mega-toggle:hover,
.cbmg-theme-grid-mega-toggle:focus {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    transform: translateY(-2px);
}
.cbmg-theme-grid-icon > span {
    width: 6px;
    height: 6px;
    border-radius: 2px;
}
html[data-cbmg-mode="night"] .cbmg-theme-grid-mega-toggle,
body.cbmg-night-mode .cbmg-theme-grid-mega-toggle {
    color: var(--cbmg-theme-secondary) !important;
}
html[data-cbmg-mode="night"] .cbmg-theme-grid-mega-toggle:hover,
body.cbmg-night-mode .cbmg-theme-grid-mega-toggle:hover {
    color: var(--cbmg-theme-bg) !important;
}

.cbmg-theme-profile-card {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 42px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(250,250,248,.74);
    border: 1px solid rgba(226,223,216,.82);
    color: var(--cbmg-theme-primary);
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(0,0,0,.06);
    transition: transform .2s ease, box-shadow .2s ease, color .2s ease, background-color .2s ease;
}
.cbmg-theme-profile-card:hover,
.cbmg-theme-profile-card:focus {
    color: var(--cbmg-theme-secondary);
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0,0,0,.08);
}
.cbmg-theme-profile-card__avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: block;
}
.cbmg-theme-profile-card__content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    line-height: 1.1;
}
.cbmg-theme-profile-card__label {
    font-size: 11px;
    font-weight: 500;
    color: var(--cbmg-theme-secondary);
}
.cbmg-theme-profile-card__name {
    font-size: 12px;
    font-weight: 500;
    color: inherit;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
html[data-cbmg-mode="night"] .cbmg-theme-profile-card,
body.cbmg-night-mode .cbmg-theme-profile-card {
    background: rgba(244,242,238,.08);
    border-color: rgba(244,242,238,.18);
    color: #FFFFFF;
}
html[data-cbmg-mode="night"] .cbmg-theme-profile-card__label,
body.cbmg-night-mode .cbmg-theme-profile-card__label {
    color: var(--cbmg-theme-bg);
}

.cbmg-theme-action-link,
.cbmg-theme-language-toggle,
.cbmg-theme-mode-toggle {
    flex: 0 0 auto;
}
.cbmg-theme-language-toggle {
    inline-size: 34px;
    block-size: 30px;
    font-size: 16px;
}
.cbmg-theme-healthy-toggle {
    inline-size: 54px;
    block-size: 30px;
    border-radius: 999px;
}

html[data-cbmg-mode="night"] .cbmg-theme-header,
body.cbmg-night-mode .cbmg-theme-header,
html[data-cbmg-mode="night"] .cbmg-theme-mega-wrap,
body.cbmg-night-mode .cbmg-theme-mega-wrap {
    background: var(--cbmg-theme-bg) !important;
}

@media (max-width: 767px) {
    .cbmg-theme-header__actions { gap: 10px; }
    .cbmg-theme-profile-card__content { display: none; }
    .cbmg-theme-profile-card { padding: 4px; min-height: 40px; }
}
