/* Control interiors. Outer rows and columns belong to shell.css. */
.gui-company-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: var(--shell-space-2); min-width: 0; padding: var(--shell-space-1); border: 1px solid var(--shell-border); border-radius: var(--shell-radius-panel); background: var(--shell-topbar-bg); }
.gui-topbar .company-selector { width: 100%; max-width: 100%; min-width: 0; }
.gui-topbar .form-control, .gui-topbar select, .gui-topbar .user-menu-trigger, .gui-theme-form button {
    color: var(--shell-text); background: var(--shell-panel-bg);
    border: 1px solid var(--shell-border); border-radius: var(--shell-radius-control);
    font-family: var(--shell-font); font-size: var(--shell-font-size); font-weight: 400; line-height: var(--shell-line-height);
    min-height: 44px; box-sizing: border-box;
}
.gui-topbar #companySearch { padding-inline-end: 44px; }
.gui-topbar .form-control::placeholder { color: var(--shell-muted); opacity: 1; }
/* Native search action stays inside its input row with a full touch target. */
.gui-topbar .gui-company-search-submit { position: absolute; inset-inline-end: 0; top: 0; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: var(--shell-text); border-radius: var(--shell-radius-control); }
.gui-topbar .selected-company { display: grid; min-width: 0; min-height: 44px; align-content: center; gap: 2px; padding: var(--shell-space-1) var(--shell-space-2); border: 0; color: var(--shell-text); font: 400 var(--shell-font-size)/var(--shell-line-height) var(--shell-font); text-transform: none; letter-spacing: normal; }
.gui-topbar .gui-company-caption { font: 600 var(--shell-caption-size)/var(--shell-line-height) var(--shell-font-strong); letter-spacing: .02em; color: var(--shell-muted); }
.gui-topbar .gui-company-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gui-topbar .company-results { min-width: 0; width: 100%; max-width: 100%; max-height: min(320px, 50dvh); overflow-y: auto; overflow-wrap: anywhere; margin-top: var(--shell-space-1); border: 1px solid var(--shell-border); border-radius: var(--shell-radius-panel); box-shadow: var(--shell-shadow); background: var(--shell-panel-bg); }
.gui-topbar .company-item { padding: var(--shell-space-2); background: var(--shell-panel-bg); color: var(--shell-text); border-color: var(--shell-border); }
.gui-topbar .company-item .d-flex > div { min-width: 0; }
.gui-topbar .company-item h6 { font: 400 var(--shell-font-size)/var(--shell-line-height) var(--shell-font); text-transform: none; overflow-wrap: anywhere; }
.gui-topbar .company-item small { font: 600 var(--shell-caption-size)/var(--shell-line-height) var(--shell-font-strong); letter-spacing: .02em; overflow-wrap: anywhere; }
.gui-topbar .text-muted { color: var(--shell-muted) !important; }

/* Four direct language links share the existing narrow-session control tree. */
.gui-topbar .langs { display: grid; grid-template-columns: repeat(4, 32px); align-items: center; gap: var(--shell-space-1); width: max-content; max-width: 100%; height: auto; }
.gui-topbar .langs a { display: inline-flex; align-items: center; justify-content: center; min-width: 0; min-height: 44px; padding: 0 !important; border: 1px solid transparent; border-radius: var(--shell-radius-control); }
/* Keep the legacy flag treatment outside the shell (for example, the login page). */
.gui-topbar .langs img { width: 20px; height: 14px; object-fit: contain; border: 0 !important; }
.gui-topbar .langs a[aria-current="true"] { border-color: var(--shell-brand); background: var(--shell-active-bg); box-shadow: inset 0 -2px var(--shell-brand); }

.gui-account-group { display: flex; flex-wrap: nowrap; align-items: center; gap: var(--shell-space-2); min-width: 0; }
/* Native theme form retains its submit fallback and PHP-owned destination. */
.gui-theme-form { display: flex; align-items: center; min-width: 0; }
.gui-topbar #color-mode-select { width: 100px; max-width: 100%; min-width: 0; padding-inline: var(--shell-space-1); border-start-end-radius: 0; border-end-end-radius: 0; }
.gui-theme-form option { background: var(--shell-panel-bg); color: var(--shell-text); }
.gui-theme-form button { min-width: 44px; border-start-start-radius: 0; border-end-start-radius: 0; }
.gui-shell-topbar .user-menu-wrapper { position: relative; display: inline-block; min-width: 0; max-width: 100%; }
.gui-shell-topbar .user-menu-trigger { display: flex; align-items: center; gap: var(--shell-space-2); min-width: 44px; max-width: 100%; padding: 6px 8px; cursor: pointer; }
.gui-shell-topbar .user-menu-trigger i { flex: 0 0 20px; font-size: 20px; line-height: 1; }
.gui-shell-topbar .user-menu-name { min-width: 0; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gui-shell-topbar .user-menu-dropdown { position: absolute; top: 100%; right: 0; list-style: none; margin: var(--shell-space-1) 0 0; padding: var(--shell-space-1); width: 220px; min-width: 0; max-width: calc(100vw - 32px); max-height: min(320px, 50dvh); overflow-y: auto; overflow-wrap: anywhere; background: var(--shell-panel-bg); border: 1px solid var(--shell-border); border-radius: var(--shell-radius-panel); box-shadow: var(--shell-shadow); z-index: 1000; }
.gui-shell-topbar .user-menu-dropdown li { margin: 0; padding: 0; }
.gui-shell-topbar .user-menu-dropdown a { display: block; padding: var(--shell-space-2) var(--shell-space-3); border-radius: var(--shell-radius-control); color: var(--shell-text); text-decoration: none; font-size: var(--shell-font-size); }
.gui-shell-topbar .user-menu-divider { height: 1px; margin-block: var(--shell-space-1); background: var(--shell-border); }
.gui-topbar .user-menu-logout a { color: var(--shell-danger); }
.gui-shell-topbar .user-menu-trigger { list-style: none; }
.gui-shell-topbar .user-menu-trigger::-webkit-details-marker { display: none; }
.gui-shell-topbar .user-menu-wrapper:not([open]) > .user-menu-dropdown { display: none; }
.gui-shell-topbar .user-menu-wrapper[open] > .user-menu-trigger { background: var(--shell-active-bg); }
.gui-topbar .company-item:hover, .gui-topbar .user-menu-trigger:hover, .gui-topbar .user-menu-dropdown a:hover, .gui-topbar .langs a:hover, .gui-theme-form button:hover { background: var(--shell-hover-bg); }
.gui-topbar .langs a[aria-current="true"]:hover { background: var(--shell-active-bg); }
.gui-topbar :is(button, summary, select, input, a):focus-visible { outline: 2px solid var(--shell-focus); outline-offset: -2px; }

/* Accepted responsive control interiors; the shell's row architecture is unchanged. */
@media (max-width: 1100px) {
    .gui-topbar .user-menu-name { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media (max-width: 768px) {
    .gui-account-group { gap: 4px; }
    .gui-topbar #color-mode-select { width: 84px; }
}
@media (max-width: 576px) {
    .gui-company-controls { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
    .gui-session-controls .langs { grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
    .gui-account-group { justify-content: space-between; }
    /* Keep the account submenu inside the existing scrollable session panel. */
    .gui-topbar .user-menu-dropdown { position: static; display: none; width: 100%; min-width: 0; max-width: 100%; margin-top: 0; }
    .gui-topbar .user-menu-wrapper[open] > .user-menu-dropdown { display: block; }
    .gui-topbar .user-menu-wrapper { min-width: 0; }
}
@media (max-width: 320px) {
    .gui-session-controls .langs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
