:root {
    --bo-sidebar: #102946;
    --bo-sidebar-text: #e4edf7;
    --bo-sidebar-muted: #a9bdd3;
    --bo-brand-green: #177842;
    --bo-control-bg: #f5f8fc;
    --bo-panel: #123357;
    --bo-overlay: rgb(7 24 45 / .55);
    --bo-header-height: 64px;
}

:root[data-bo-theme="dark"] {
    color-scheme: dark;
    --ml-bg: #0d1726;
    --ml-surface: #142237;
    --ml-surface-alt: #1b2d45;
    --ml-text: #e8eff9;
    --ml-text-muted: #b1c2d8;
    --ml-border: #2c4059;
    --ml-border-strong: #4a6583;
    --ml-navy: #e1edff;
    --ml-navy-deep: #bcd4f7;
    --ml-blue: #8ac5ff;
    --ml-blue-soft: #183554;
    --ml-green: #63d894;
    --ml-success: #8ce8ab;
    --ml-warning: #ffd184;
    --ml-error: #ffa7a4;
    --ml-shadow-sm: 0 6px 24px rgb(0 0 0 / .18);
    --ml-shadow-md: 0 16px 44px rgb(0 0 0 / .27);
    --bo-sidebar: #0a1525;
    --bo-brand-green: #83dca5;
    --bo-control-bg: #1b2d45;
    --bo-overlay: rgb(1 9 20 / .72);
}

html, body { background: var(--ml-bg); color: var(--ml-text); }
.bo-shell, .bo-shell[dir="rtl"] {
    direction: inherit;
    grid-template-columns: clamp(215px, 19vw, 250px) minmax(0, 1fr);
    height: 100dvh;
}
.bo-shell[dir="rtl"] { direction: rtl; }
.bo-shell[dir="ltr"] { direction: ltr; }
.bo-shell > .bo-sidebar, .bo-shell > .bo-main { grid-column: auto; grid-row: 1; }
.bo-sidebar {
    display: flex;
    min-width: 0;
    overflow-y: auto;
    padding: 1rem .75rem;
    gap: 1rem;
    background: var(--bo-sidebar);
    border-inline-end: 1px solid rgb(255 255 255 / .1);
    box-shadow: none;
}
.bo-brand {
    flex: none;
    min-height: 48px;
    padding: .25rem .65rem;
}
.bo-brand .ml-brand-image { width: auto; max-width: 100%; height: 37px; }
.bo-nav { display: grid; gap: .8rem; }
.bo-nav-group { display: grid; gap: .15rem; }
.bo-nav-label {
    padding: 0 .65rem .2rem;
    color: var(--bo-sidebar-muted);
    font-size: .76rem;
    font-weight: 700;
}
.bo-nav a {
    padding: .42rem .65rem;
    color: var(--bo-sidebar-text);
    border-inline-start: 3px solid transparent;
    border-radius: 8px;
    font-size: .88rem;
    overflow-wrap: anywhere;
}
.bo-nav a:hover, .bo-nav a:focus-visible, .bo-nav a.active {
    background: rgb(255 255 255 / .1);
    color: #fff;
}
.bo-nav a.active { border-inline-start-color: #69dfa0; font-weight: 700; }
.bo-sidebar-footer { display: grid; font-size: .78rem; }
.bo-sidebar-footer small { color: var(--bo-sidebar-muted); }
.bo-menu-overlay { display: none; }
[data-bo-menu="closed"] .bo-shell { grid-template-columns: minmax(0, 1fr); }
[data-bo-menu="closed"] .bo-sidebar { display: none; }

.bo-main { overflow: auto; scrollbar-gutter: stable; }
.bo-topbar {
    min-height: var(--bo-header-height);
    padding: .55rem clamp(.75rem, 3vw, 2rem);
    gap: .55rem;
    background: var(--ml-surface);
    border-block-end: 1px solid var(--ml-border);
    box-shadow: none;
    backdrop-filter: none;
}
.bo-topbar > .bo-top-context {
    display: flex;
    align-items: center;
    gap: .7rem;
    min-width: 0;
}
.bo-top-context > div { display: grid; line-height: 1.25; }
.bo-top-context strong { color: var(--ml-text); font-size: .95rem; }
.bo-top-context small { color: var(--ml-text-muted); font-size: .75rem; }
.bo-top-actions { gap: .4rem; }
.bo-icon-button, .bo-top-actions .ml-language-trigger, .bo-login-actions .ml-language-trigger {
    display: inline-grid;
    place-items: center;
    min-width: 42px;
    min-height: 42px;
    flex: none;
    padding: .45rem;
    border: 1px solid var(--ml-border-strong);
    border-radius: 12px;
    background: var(--bo-control-bg);
    color: var(--ml-text);
    cursor: pointer;
}
.bo-icon-button:hover, .bo-icon-button[aria-pressed="true"] { background: var(--ml-surface-alt); }
.bo-icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.bo-theme-toggle .bo-theme-moon, [data-bo-theme="dark"] .bo-theme-toggle .bo-theme-sun { display: none; }
[data-bo-theme="dark"] .bo-theme-toggle .bo-theme-moon { display: block; }
.bo-shell :focus-visible, .bo-login :focus-visible { outline: 2px solid var(--ml-focus); outline-offset: 3px; }

.bo-content { max-width: 1550px; padding: clamp(.9rem, 3vw, 2rem); padding-block-end: 3rem; }
.bo-heading { scroll-margin-block-start: calc(var(--bo-header-height) + 1rem); }
.bo-heading h1 { font-size: clamp(1.65rem, 2.75vw, 2.35rem); }
.bo-heading-inline { margin-bottom: .8rem; }
.bo-heading-inline h2 { margin-bottom: .25rem; }
.bo-eyebrow { letter-spacing: .08em; }
.bo-kpis { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.bo-panel { background: var(--bo-panel); }
.bo-panel .bo-eyebrow { color: #93c9ff; }
.bo-section, .bo-kpi { box-shadow: none; }
.bo-table-wrap { box-shadow: none; }
.bo-table { min-width: 34rem; }
.bo-table th { background: var(--ml-surface-alt); }
.bo-table tbody tr:hover, .bo-docs article { background: var(--bo-control-bg); }
.bo-table td:first-child { display: table-cell; }
.bo-table tbody th { background: transparent; text-transform: none; letter-spacing: normal; font-size: inherit; border-top: 1px solid var(--ml-border); }
.bo-detail-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.bo-detail-columns .bo-section { margin-block: 0; }
.bo-definition { display: grid; grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr); gap: .65rem; }
.bo-definition dt { color: var(--ml-text-muted); }
.bo-definition dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.bo-sensitive, .bo-decision { border-top: 1px solid var(--ml-border); margin-block-start: .85rem; padding-block-start: .75rem; }
.bo-sensitive { display: flex; flex-wrap: wrap; gap: .45rem; }
.bo-decision h3 { margin-block-start: 0; }
.bo-fieldset > .validation-message { color: var(--ml-error); }
@media (max-width: 820px) { .bo-detail-columns { grid-template-columns: minmax(0, 1fr); } }
.bo-table bdi, .resource-row bdi, .bo-note { overflow-wrap: anywhere; }
.bo-muted { color: var(--ml-text-muted); }
.bo-table a, .bo-content a.link-button { color: var(--ml-blue); font-weight: 650; }
.bo-actions { align-items: center; margin-block-start: .8rem; }
.bo-pagination { flex-wrap: wrap; }
.bo-filters { align-items: end; }
.bo-filters .ml-label { flex: 1 1 12rem; }
.bo-filters .ml-button { margin-block-end: .2rem; }
.bo-picker > strong { display: block; margin-block-end: .6rem; }
.bo-picker > .ml-label { margin-block-start: .6rem; max-width: 38rem; }
.bo-editor { max-width: 54rem; }
.bo-editor .ml-label { margin-block-start: .65rem; }
.bo-editor .ml-label:first-child { margin-block-start: 0; }
.bo-fieldset, .bo-section fieldset { min-inline-size: 0; border: 0; margin: 0; padding: 0; }
.bo-section fieldset legend { margin-block: .85rem .5rem; font-size: 1.06rem; font-weight: 750; }
.bo-section .bo-checkboxes { display: flex; gap: .5rem 1rem; flex-wrap: wrap; margin-block: .6rem; }
.bo-secondary-actions { border-block-start: 1px solid var(--ml-border); margin-block-start: 1rem; padding-block-start: .8rem; }
.bo-secondary-actions summary { margin-block-end: .65rem; cursor: pointer; font-weight: 700; }
.bo-content .link-button {
    border: 0;
    border-radius: 8px;
    padding: .35rem .5rem;
    background: transparent;
    color: var(--ml-blue);
    font-weight: 650;
    cursor: pointer;
}
.bo-content .link-button:hover:not(:disabled) { background: var(--ml-surface-alt); }
.bo-content .link-button:disabled { opacity: .55; cursor: default; }
.bo-content .ml-alert-success { background: #e7f6ed; border-color: #bce2cb; color: #165b35; }
.bo-content .ml-button, .bo-login .ml-button { color: white; background: #1769b2; }
.bo-content .ml-button-secondary, .bo-login .ml-button-secondary { color: var(--ml-text); background: var(--ml-surface-alt); }
[data-bo-theme="dark"] .bo-content .ml-alert, [data-bo-theme="dark"] .bo-login .ml-alert { background: var(--ml-blue-soft); color: var(--ml-text); }
[data-bo-theme="dark"] .bo-content .ml-alert-error, [data-bo-theme="dark"] .bo-login .ml-alert-error { background: #40252d; color: #ffd0ce; }
[data-bo-theme="dark"] .bo-content .ml-alert-success { background: #183a32; border-color: #295443; color: #a1efc0; }
[data-bo-theme="dark"] .bo-content .ml-alert-warning { background: #403320; color: #ffdc9e; }
[data-bo-theme="dark"] .ml-badge-success { background: #163a32; color: var(--ml-success); }
[data-bo-theme="dark"] .ml-badge-warning { background: #403320; color: var(--ml-warning); }
[data-bo-theme="dark"] .ml-badge-error { background: #40252d; color: var(--ml-error); }
[data-bo-theme="dark"] .ml-badge-info { background: var(--ml-blue-soft); color: var(--ml-blue); }
[data-bo-theme="dark"] .confirm-overlay { background: var(--bo-overlay); }
[data-bo-theme="dark"] .ml-input { color: var(--ml-text); border-color: var(--ml-border-strong); }

.bo-login {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: grid;
    align-content: start;
    justify-items: center;
    padding: clamp(.75rem, 3vw, 2rem);
    background: radial-gradient(ellipse at 70% 0%, var(--ml-blue-soft), var(--ml-bg) 65%);
}
.bo-login-actions { justify-self: end; display: flex; gap: .4rem; }
.bo-login-card {
    width: min(100%, 29rem);
    margin-block: clamp(.9rem, 5vh, 3rem) 1rem;
    padding: clamp(1rem, 4vw, 2rem);
    border: 1px solid var(--ml-border);
    border-radius: 20px;
    background: var(--ml-surface);
    box-shadow: var(--ml-shadow-md);
}
.bo-login-brand { display: block; width: min(185px, 100%); aspect-ratio: 4 / 1; margin-block-end: 1.25rem; background: var(--bo-logo-light) center / contain no-repeat; }
[data-bo-theme="dark"] .bo-login-brand { background-image: var(--bo-logo-dark); }
.bo-login-card h1 { margin: 0 0 .3rem; font-size: clamp(1.5rem, 4vw, 2rem); letter-spacing: -.035em; color: var(--ml-text); }
.bo-login-card > p { margin-block: 0 1.1rem; color: var(--ml-text-muted); }
.bo-login-card form { display: grid; gap: .55rem; }
.bo-password-field { display: flex; align-items: stretch; gap: .35rem; }
.bo-password-field .ml-input { min-width: 0; flex: 1; }
.bo-login-submit { margin-block-start: .35rem; }

@media (max-width: 980px) {
    .bo-shell, .bo-shell[dir="rtl"] { grid-template-columns: minmax(0, 1fr); }
    .bo-shell > .bo-sidebar {
        display: none;
        position: fixed;
        inset-block: var(--bo-header-height) 0;
        inset-inline-start: 0;
        width: min(82vw, 280px);
        z-index: 5;
        box-shadow: var(--ml-shadow-md);
    }
    .bo-shell > .bo-main { grid-column: 1; }
    .bo-topbar { z-index: 6; }
    [data-bo-overlay="open"] .bo-sidebar { display: flex; }
    [data-bo-overlay="open"] .bo-menu-overlay {
        display: block;
        position: fixed;
        inset: var(--bo-header-height) 0 0;
        z-index: 4;
        border: 0;
        background: var(--bo-overlay);
    }
}
@media (max-width: 430px) {
    .bo-login-card { padding-inline: 1rem; }
    .bo-top-context strong { font-size: .82rem; }
    .bo-topbar .bo-icon-button, .bo-top-actions .ml-language-trigger { min-width: 40px; }
}
@media screen {
    .bo-print-contract { display: none; }
}
@media print {
    html:has(body > .bo-print-contract), body:has(> .bo-print-contract) { background: white !important; color-scheme: light; }
    body:has(> .bo-print-contract) > :not(.bo-print-contract) { display: none !important; }
    .bo-print-contract { display: block; color: black; background: white; padding: 1rem; }
}
