:root {
  --company-sidebar-bg: #102b44;
  --company-sidebar-text: #ffffff;
  --company-sidebar-hover: #233c53;
  --company-sidebar-hover-text: #ffffff;
  --company-sidebar-active: #364d62;
  --company-sidebar-active-text: #ffffff;
  --company-sidebar-accent: #70808f;
  --company-sidebar-soft: rgba(255,255,255,.14);
  --company-sidebar-logo-filter: brightness(0) invert(1);
}

/* Default and company colors share the same solid navigation states. Load
   after page styles so icons and nested labels inherit the selected palette. */
html .app-sidebar { background: var(--company-sidebar-bg); color: var(--company-sidebar-text); }
html .app-sidebar :is(.logo-full, .logo-icon) { filter: var(--company-sidebar-logo-filter); }
html .app-sidebar :is(.sidebar-link, .sidebar-company, .sidebar-nav-section, .sidebar-notifications, .user-name, .user-role, .sidebar-collapse-btn, .sidebar-footer a, .sidebar-footer button) { color: var(--company-sidebar-text); }
html .app-sidebar :is(.sidebar-link, .sidebar-notifications) svg { color: inherit; }
html .app-sidebar .sidebar-footer { background: var(--company-sidebar-soft); border-color: var(--company-sidebar-soft); }
html .app-sidebar :is(.sidebar-link:hover, .sidebar-link:focus-visible, .sidebar-collapse-btn:hover, .sidebar-collapse-btn:focus-visible, .sidebar-notifications:hover, .sidebar-notifications:focus-visible),
html .app-sidebar .sidebar-footer :is(a, button):is(:hover, :focus-visible) { background: var(--company-sidebar-hover); color: var(--company-sidebar-hover-text); border-color: var(--company-sidebar-hover); outline-color: var(--company-sidebar-accent); }
html .app-sidebar :is(.sidebar-link.active, .sidebar-notifications.active) { background: var(--company-sidebar-active); color: var(--company-sidebar-active-text); border-color: var(--company-sidebar-accent); }
html .app-sidebar .sidebar-link.active { box-shadow: inset 3px 0 0 var(--company-sidebar-accent); }
html .app-sidebar .sidebar-link.active svg { color: inherit; }
.sidebar-branch-switch { padding: 0 14px 8px; flex-shrink: 0; }
.sidebar-branch-switch[hidden], .business-unit-section[hidden] { display: none; }
.sidebar-branch-switch small { display: block; color: inherit; opacity: .7; font-size: 11px; margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-branch-control { position: relative; }
.sidebar-branch-control svg { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); opacity: .7; pointer-events: none; }
.sidebar-branch-switch select { width: 100%; min-width: 0; background: transparent; color: var(--company-sidebar-text); border: 1px solid transparent; border-radius: 7px; padding: 8px 28px 8px 5px; font: inherit; font-size: 12px; cursor: pointer; }
.sidebar-branch-switch select option { background: #fff; color: #111827; }
html .app-sidebar .sidebar-branch-switch select { color: var(--company-sidebar-text); background: transparent; border-color: transparent; box-shadow: none; }
html .app-sidebar .sidebar-branch-switch select:hover { background: var(--company-sidebar-hover); color: var(--company-sidebar-hover-text); }
html .app-sidebar .sidebar-branch-switch select:focus-visible { outline: 2px solid var(--company-sidebar-accent); outline-offset: 2px; }
html .app-sidebar .sidebar-branch-switch { color: var(--company-sidebar-text); }
/* Keep the switcher's space so navigation does not jump during collapse. */
.app-sidebar.collapsed .sidebar-branch-switch { visibility: hidden; pointer-events: none; }
.business-unit-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.business-unit-member { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid #dbe5ec; }
.business-unit-member-info { flex: 1 1 160px; min-width: 0; }
.business-unit-member-info small { display: block; overflow-wrap: anywhere; }
.business-unit-member select { max-width: 170px; padding: 8px; border: 1px solid #dbe5ec; border-radius: 8px; }
/* Company Settings → Company Structure: the two terms, a diagram of the umbrella
   and its business units, and the add form (business_unit_settings.js). */
.structure-terms { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 12px; margin: 0 0 22px; }
.structure-terms > div { padding: 14px 16px; border: 1px solid #dbe5ec; border-radius: 10px; background: #f8fbfc; }
.structure-terms dt { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; color: #183d4a; font-size: 13px; font-weight: 800; }
.structure-terms dd { margin: 0; color: #5b6f7e; font-size: 12px; line-height: 1.55; }
.structure-heading { margin: 0 0 10px; color: #29465b; font-size: 13px; }
.structure-icon { display: inline-grid; place-items: center; flex: 0 0 auto; width: 32px; height: 32px; border-radius: 8px; background: #e7f1f6; color: #27778d; }
.structure-icon.umbrella { background: #dff3ee; color: #11695f; }
.structure-icon svg { width: 18px; height: 18px; }
.structure-node, .structure-unit { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; min-height: 60px; padding: 10px 14px; border: 1px solid #dbe5ec; border-radius: 10px; background: #fff; box-sizing: border-box; }
.structure-text { display: flex; flex: 1 1 160px; flex-direction: column; gap: 1px; min-width: 0; }
.structure-text small { color: #6b7f8e; font-size: 12px; font-weight: 650; }
.structure-text b { color: #183d4a; font-size: 14px; overflow-wrap: anywhere; }
.structure-umbrella { border-color: #bfe0d8; background: #f3fbf9; }
.structure-umbrella .structure-text b { font-size: 15px; }
.structure-units { margin: 0; padding: 12px 0 0 46px; list-style: none; display: grid; gap: 12px; }
/* Connectors: a line down from under the umbrella's icon, with a branch to each unit. */
.structure-units > li { position: relative; }
.structure-units > li::before { content: ""; position: absolute; left: -16px; top: -12px; width: 16px; height: 42px; border-left: 2px solid #c3d5df; border-bottom: 2px solid #c3d5df; border-bottom-left-radius: 9px; box-sizing: border-box; }
.structure-units > li:not(:last-child)::after { content: ""; position: absolute; left: -16px; top: 28px; bottom: -12px; border-left: 2px solid #c3d5df; }
.structure-diagram.standalone .structure-units { padding: 0; }
.structure-diagram.standalone .structure-units > li::before, .structure-diagram.standalone .structure-units > li::after { content: none; }
.structure-unit.current { border-color: #9fd3c9; box-shadow: 0 0 0 3px rgba(18, 140, 124, .1); }
.structure-unit.added { border-color: #0ea5a3; background: #f3fbf9; }
.structure-badge { padding: 4px 10px; border-radius: 999px; background: #e7f5f2; color: #11695f; font-size: 12px; font-weight: 750; white-space: nowrap; }
.structure-muted { color: #7b8d9b; font-size: 12px; }
.structure-unit .settings-btn { min-height: 34px; padding: 6px 12px; white-space: nowrap; }
.structure-add-button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 14px; border: 2px dashed #8fcabd; border-radius: 10px; background: #fbfefd; color: #11695f; font: inherit; text-align: left; cursor: pointer; box-sizing: border-box; }
.structure-add-button:hover { border-color: #4fb09f; background: #f0faf7; }
.structure-add-button:focus-visible { outline: 3px solid #2799b7; outline-offset: 2px; }
.structure-add-button .structure-icon { background: #0ea5a3; color: #fff; }
.structure-add-button b { color: #0f5f56; font-size: 14px; }
.structure-add-button[aria-expanded="true"] { border-style: solid; border-radius: 10px 10px 0 0; }
.structure-add-form { padding: 14px 16px 16px; border: 2px solid #8fcabd; border-top: 0; border-radius: 0 0 10px 10px; background: #fbfefd; }
.structure-add-form .settings-note { margin: 8px 0 0; }
.structure-link { margin-top: 18px; padding-top: 14px; border-top: 1px solid #e1ebef; }
.structure-panel { margin-top: 22px; padding: 16px 18px; border: 1px solid #dbe5ec; border-radius: 10px; background: #f8fbfc; }
.structure-panel h3 { margin: 0 0 6px; color: #183d4a; font-size: 14px; }
.structure-panel > p { margin: 0 0 14px; color: #5b6f7e; font-size: 12px; line-height: 1.55; }
.structure-preview { margin: 0 0 16px; }
.structure-preview :is(.structure-umbrella, .structure-planned) { border-style: dashed; }
.structure-planned .structure-text b { color: #5b6f7e; font-weight: 650; }
.structure-add-button:disabled { border-color: #d3dde3; background: #f8fafb; color: #7b8d9b; cursor: not-allowed; }
.structure-add-button:disabled :is(b, small) { color: #7b8d9b; }
.structure-add-button:disabled .structure-icon { background: #dfe7ec; color: #7b8d9b; }
.structure-owner-note { margin: 8px 0 0; color: #6b5a2a; font-size: 12px; line-height: 1.5; }
