/* Theme compatibility V15. Loaded after the existing design layers. */
:root{--bg:#f3f6fc;--surface:#fff;--surface-2:#f6f8fd;--text:#172b4f;--muted:#7384a1;--border:#e5ebf5;--accent:#286cff;--accent-soft:#eaf1ff;--shadow:0 8px 26px rgba(20,53,102,.065)}
html{overflow-x:hidden}body{background:var(--bg)!important;color:var(--text)!important} .app-main{background:var(--bg)!important;min-width:0} .panel,.stat-card,.topbar,.modal-dialog{background:var(--surface);border-color:var(--border)!important;color:var(--text)}
.topbar{background:var(--surface)!important}.directory-table th{background:var(--surface-2)}.directory-table tbody tr:nth-child(even){background:var(--surface-2)}.directory-table tbody tr:hover{background:var(--accent-soft)}.company-cell-text strong,.director-cell strong,.panel-heading h2,.rail-head h2{color:var(--text)}.company-cell-text small,.director-cell small{color:var(--muted)}.category-meter{background:var(--border)}
body.theme-dark{color-scheme:dark;--bg:#0b1425;--surface:#14233a;--surface-2:#1b2c46;--text:#e8effc;--muted:#a3b4d0;--border:#304460;--accent:#80a6ff;--accent-hover:#6492f9;--accent-soft:#243b60;--shadow:0 12px 34px rgba(0,0,0,.18);--premium-ink:#e8effc;--premium-navy:#e8effc}
body.theme-dark,body.theme-dark .app-main{background:var(--bg)!important;color:var(--text)!important}
body.theme-dark .topbar,body.theme-dark .panel,body.theme-dark .stat-card,body.theme-dark .modal-dialog,body.theme-dark .directory-panel,body.theme-dark .right-rail .panel{background:var(--surface)!important;border-color:var(--border)!important;color:var(--text)!important}
body.theme-dark .directory-table th,body.theme-dark .directory-table thead th,body.theme-dark .table-tools,body.theme-dark .filter-bar,body.theme-dark .table-footer,body.theme-dark .category-meter,body.theme-dark .changes-disclosure>summary{background:var(--surface-2)!important;color:var(--muted)!important;border-color:var(--border)!important}
body.theme-dark .directory-table tbody tr,body.theme-dark .directory-table tbody tr:nth-child(odd),body.theme-dark .directory-table tbody tr:nth-child(even),body.theme-dark .director-watch-panel #mebWarningRows tr:nth-child(odd) td,body.theme-dark .director-watch-panel #mebWarningRows tr:nth-child(even) td{background:var(--surface)!important;color:var(--text)!important}
body.theme-dark .directory-table tbody tr:hover,body.theme-dark .director-watch-panel #mebWarningRows tr:hover td{background:var(--surface-2)!important}
body.theme-dark .company-cell-text strong,body.theme-dark .director-cell strong,body.theme-dark .panel-heading h2,body.theme-dark .rail-head h2,body.theme-dark .stat-value,body.theme-dark .stat-title,body.theme-dark .premium-activity-item strong,body.theme-dark .premium-activity-item b,body.theme-dark .premium-donut strong,body.theme-dark .meb-insights-head h3,body.theme-dark .tool-list strong,body.theme-dark .modal-top h2{color:var(--text)!important}
body.theme-dark .company-cell-text small,body.theme-dark .director-cell small,body.theme-dark .rail-description,body.theme-dark .premium-activity-item small,body.theme-dark .stat-foot,body.theme-dark .topbar-date{color:var(--muted)!important}
body.theme-dark input:not([type=checkbox]):not([type=radio]),body.theme-dark select,body.theme-dark textarea,body.theme-dark .global-search,body.theme-dark .search-wrap{background:var(--surface-2)!important;color:var(--text)!important;border-color:var(--border)!important}
body.theme-dark input::placeholder,body.theme-dark textarea::placeholder{color:#94a6c3!important}
body.theme-dark .icon-button,body.theme-dark .button:not(.button-primary):not(.button-danger),body.theme-dark .round-plus,body.theme-dark .tool-list>button{border-color:var(--border)!important;color:var(--text)}
body.theme-dark .director-command,body.theme-dark .director-metrics-disclosure,body.theme-dark .director-command-foot,body.theme-dark .director-warning-table,body.theme-dark .director-watch-panel,body.theme-dark .director-watch-panel .meb-insights{background:#281f35!important;border-color:#68445c!important;color:var(--text)!important}
body.theme-dark .director-watch-panel .directory-table thead th{background:#3b2943!important;color:#ffc6d3!important}body.theme-dark .director-command-title h2,body.theme-dark .director-metrics-disclosure summary{color:#ffbacc!important}
body.theme-dark .director-command-foot{border-color:#68445c!important}body.theme-dark .director-watch-panel #mebWarningRows td{border-color:var(--border)!important}
body.theme-dark .premium-donut:after{background:var(--surface)!important}body.theme-dark .sidebar{background:linear-gradient(165deg,#0b1830,#122644)!important}body.theme-dark .hero{background:radial-gradient(ellipse at 82% 5%,#5936b9 0%,transparent 38%),linear-gradient(114deg,#0c234b,#16448b 63%,#402282)!important}
/* Keep native controls and horizontal tables usable on small devices */
.main-grid,.primary-column,.right-rail,.directory-panel,.content-wrap{min-width:0}.directory-panel .table-scroll,.director-warning-table .table-scroll{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}.table-tools,.panel-heading{flex-wrap:wrap}.modal-dialog{max-width:calc(100vw - 24px)}
@media(max-width:1199px){.main-grid{grid-template-columns:minmax(0,1fr)!important}.right-rail{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important}}
@media(max-width:790px){.sidebar{position:fixed!important;left:0;top:0;bottom:0;width:min(280px,85vw)!important;height:100dvh!important;transform:translateX(-110%);z-index:60}.sidebar.open{transform:translateX(0)}.app-shell{display:block!important}.app-main{width:100%!important}.topbar{padding-inline:15px!important}.mobile-menu{display:grid!important}.content-wrap{padding:13px!important}.right-rail{grid-template-columns:minmax(0,1fr)!important}.hero-copy{width:100%!important}.hero-school-scene{opacity:.24!important}.hero-script{display:none}.table-tools{gap:9px}}
@media(max-width:520px){.stats-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}.stat-card{min-height:116px!important;padding:12px!important}.stat-card .stat-value{font-size:27px!important}.hero h2{font-size:25px!important}.hero-copy{padding:22px 18px!important}.panel-heading{padding-inline:15px!important}.director-command-head{flex-direction:column!important}.topbar-right{gap:5px!important}.global-search{display:none!important}}
@media print{body,body.theme-dark,.app-main,body.theme-dark .app-main{background:#fff!important;color:#111!important}.directory-table tbody tr,.directory-table tbody tr:nth-child(even){background:#fff!important}}

html.pre-theme-dark,html.pre-theme-dark body{background:#0b1425!important}html.pre-theme-dark body:not(.theme-dark){visibility:hidden}
