:root{color-scheme:light}
.header-actions{display:flex;align-items:center;gap:20px}
.theme-toggle{display:grid;flex:0 0 auto;width:38px;height:38px;border:1px solid rgba(255,255,255,.18);border-radius:50%;background:rgba(255,255,255,.05);place-items:center;color:#f4f2eb;cursor:pointer;transition:border-color .18s,background .18s,color .18s,transform .18s}
.theme-toggle:hover{border-color:#929995;background:rgba(201,168,93,.12);color:#e5c878;transform:translateY(-1px)}
.theme-toggle-icon:before{display:block;font-size:17px;line-height:1;content:"☾"}
html[data-theme="dark"] .theme-toggle-icon:before{content:"☀"}
.system-theme-login{position:fixed;z-index:30;right:24px;top:24px}

/* Portal público */
html[data-theme="dark"] body:not(.system-page){background:#0c0d0b;color:#efeee9}
html[data-theme="dark"] body:not(.system-page) .top-alert{border-color:#30312d;background:#171815;color:#c8c9c3}
html[data-theme="dark"] body:not(.system-page) .btn-primary{border-color:#d0ac55;background:#d0ac55;color:#151611}
html[data-theme="dark"] body:not(.system-page) .btn-primary:hover{border-color:#e0bf6a;background:#e0bf6a;color:#11120f}
html[data-theme="dark"] :is(.public-results,.institutional,.public-hierarchy){background:#111210;color:#efeee9}
html[data-theme="dark"] :is(.public-results,.institutional,.public-hierarchy) .section-heading>p,
html[data-theme="dark"] .institutional .text-column p,
html[data-theme="dark"] .public-hierarchy .section-heading>p{color:#a2a39e}
html[data-theme="dark"] .institutional .text-column .lead{color:#ecebe6}
html[data-theme="dark"] :is(.public-result-grid,.public-result-grid article){border-color:#33342f}
html[data-theme="dark"] .public-result-grid span{color:#a8a49a}
html[data-theme="dark"] .public-result-grid small{color:#777972}
html[data-theme="dark"] .history-facts{border-color:#34352f;background:#34352f}
html[data-theme="dark"] .history-facts article{background:#191a17}
html[data-theme="dark"] .history-facts span{color:#92938d}
html[data-theme="dark"] :is(.public-hierarchy-summary,.hierarchy-group){border-color:#34352f;background:#191a17}
html[data-theme="dark"] .public-hierarchy-summary article{border-color:#34352f}
html[data-theme="dark"] .public-hierarchy-summary span{color:#999a94}
html[data-theme="dark"] .hierarchy-group>header{border-color:#353630;background:#20211e}
html[data-theme="dark"] .hierarchy-group>header b{background:#30312d;color:#dab960}
html[data-theme="dark"] .hierarchy-group article{border-color:#30312d}
html[data-theme="dark"] .hierarchy-group article p{color:#8e8f88}
html[data-theme="dark"] footer{border-color:#292a27;background:#0d0e0c}

/* Sistema operacional */
html[data-theme="dark"] .system-page{
  --ui-bg:#0f100e;
  --ui-surface:#191a17;
  --ui-surface-soft:#20211e;
  --ui-ink:#f0efe9;
  --ui-muted:#9b9c96;
  --ui-line:#343530;
  --ui-accent:#d0ac55;
  --ui-accent-soft:#332b19;
  --ui-sidebar:#090a09;
  background:var(--ui-bg);color:var(--ui-ink)
}
html[data-theme="dark"] .system-page :is(.login-panel,.dashboard-main,.dashboard-view){background:var(--ui-bg)}
html[data-theme="dark"] .system-page .login-form{background:var(--ui-surface);box-shadow:0 18px 55px #0005}
html[data-theme="dark"] .system-page :is(.login-form label,.remember-access strong){color:#d7d8d2}
html[data-theme="dark"] .system-page :is(.login-title p,.remember-access small){color:var(--ui-muted)}
html[data-theme="dark"] .system-page .login-recovery-button{color:#d5b65e}
html[data-theme="dark"] .system-page input:-webkit-autofill,
html[data-theme="dark"] .system-page input:-webkit-autofill:hover,
html[data-theme="dark"] .system-page input:-webkit-autofill:focus{
  -webkit-text-fill-color:#efeee9!important;
  caret-color:#efeee9;
  box-shadow:0 0 0 1000px #20211e inset!important;
  transition:background-color 9999s ease-out 0s
}
html[data-theme="dark"] .system-page .dashboard-header{border-color:var(--ui-line);background:rgba(20,21,18,.94)}
html[data-theme="dark"] .system-page .user-box button{color:#c9cac4}
html[data-theme="dark"] .system-page .user-box button:hover{background:#292a26;color:#fff}
html[data-theme="dark"] .system-page :is(.panel,.metric-grid article,.overview-actions button,.staff-summary article,.course-summary article,.staff-controls,.course-controls,.staff-group,.staff-card,.course-card,.service-report-form fieldset,.service-report-sidebar .panel,.profile-metrics article,.pending-summary article,.profile-grid article,.pending-grid article){border-color:var(--ui-line);background:var(--ui-surface);color:var(--ui-ink)}
html[data-theme="dark"] .system-page #overviewView>.metric-grid{border-color:var(--ui-line);background:var(--ui-surface);box-shadow:0 14px 32px #0004}
html[data-theme="dark"] .system-page #overviewView>.metric-grid article{border-color:var(--ui-line)}
html[data-theme="dark"] .system-page #overviewView>.metric-grid article strong{color:var(--ui-ink)}
html[data-theme="dark"] .system-page :is(.staff-group>header,.course-card>footer,.permission-presets,.staff-editor-identity,.notification-head,table th){border-color:var(--ui-line);background:var(--ui-surface-soft)}
html[data-theme="dark"] .system-page :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea){border-color:#41423d!important;background:#20211e!important;color:#efeee9!important}
html[data-theme="dark"] .system-page :is(input,textarea)::placeholder{color:#777972}
html[data-theme="dark"] .system-page :is(h1,h2,h3,h4,legend,.staff-row b,.staff-row strong,.course-card strong,.profile-head h2){color:var(--ui-ink)}
html[data-theme="dark"] .system-page :is(table td,.overview-composition>div,.overview-pending>div,.report-history-list article,.career-timeline>div,.backup-list>div){border-color:#30312d}
html[data-theme="dark"] .system-page :is(.overview-indicators div,.indicator-grid div,.profile-metrics div,.quantity-summary label,.equipment-grid label,.activity-toggle span,.history-access-note,.role-badge,.personnel-tag,.staff-account-status,.permission-security-note,.report-preview-card pre){background:#20211e;color:#d1d2cc;border-color:#393a35}
html[data-theme="dark"] .system-page :is(.rso-tabs button,.rso-filters input,.rso-filters select,.period-filter select,.staff-edit-button,.course-edit-button,.backup-list button,.permission-manage-button,.permission-presets button,.function-tag-picker button){border-color:#41423d;background:#20211e;color:#d7d8d2}
html[data-theme="dark"] .system-page :is(.staff-row:hover,.participant-ranking tr:first-child td){background:#20211e}
html[data-theme="dark"] .system-page :is(.staff-card-record>div>span,.staff-card-qualifications .qualification-popover summary){border-color:#3a3b36;background:#20211e;color:#d4d5cf}
html[data-theme="dark"] .system-page .staff-function-tags span{border-color:#56482a;background:#2b261a;color:#dfc47f}
html[data-theme="dark"] .system-page :is(.staff-status,.account-badge.active){border-color:#315d40;background:#192c20;color:#83d39d}
html[data-theme="dark"] .system-page .account-badge.disabled{border-color:#69562e;background:#302817;color:#dfbd6d}
html[data-theme="dark"] .system-page :is(.staff-editor-modal,.course-editor-modal,.report-details-modal,.action-modal){background:#151613;color:var(--ui-ink)}
html[data-theme="dark"] .system-page :is(.staff-editor-head,.staff-editor-body fieldset,.staff-editor-modal .modal-actions,.course-editor-modal .modal-actions,.permission-option,.report-details-modal section){border-color:var(--ui-line);background:var(--ui-surface);color:var(--ui-ink)}
html[data-theme="dark"] .system-page .notification-panel{border-color:var(--ui-line);background:var(--ui-surface)}
html[data-theme="dark"] .system-page .notification-item{background:var(--ui-surface);color:var(--ui-ink)}
html[data-theme="dark"] .system-page .notification-item.unread{background:#282315}
html[data-theme="dark"] .system-page .notification-item+.notification-item{border-color:var(--ui-line)!important}
html[data-theme="dark"] .system-page .report-view-switch{border-color:var(--ui-line);background:var(--ui-surface)}
html[data-theme="dark"] .system-page .map-shell{border-color:var(--ui-line);background:#151613}
html[data-theme="dark"] .system-page .map-zoom-controls{border-color:var(--ui-line)!important;background:rgba(25,26,23,.96)!important;box-shadow:0 8px 24px #0005!important}
html[data-theme="dark"] .system-page .map-zoom-controls button{border-color:#3b3c37!important;background:#232420!important;color:#ecebe5!important}

/* Revisao completa de contraste das telas internas */
html[data-theme="dark"] .system-page .btn-primary{
  border-color:#d0ac55!important;
  background:#d0ac55!important;
  color:#151611!important;
  box-shadow:none
}
html[data-theme="dark"] .system-page .btn-primary:hover{
  border-color:#e0bf6a!important;
  background:#e0bf6a!important;
  color:#11120f!important
}
html[data-theme="dark"] .system-page :is(#clearStaffFilters,.statistics-filters button,#printStatisticsButton,#exportStatisticsButton,.report-admin-actions button,.pending-item button){
  border-color:#44453f!important;
  background:#242521!important;
  color:#e6e5df!important
}
html[data-theme="dark"] .system-page :is(#overviewView .overview-indicators div,.access-summary article,.staff-empty,.empty-statistics,.gallery-file-picker,.gallery-admin-grid article,.profile-tag){
  border-color:var(--ui-line)!important;
  background:var(--ui-surface)!important;
  color:var(--ui-ink)!important;
  box-shadow:none
}
html[data-theme="dark"] .system-page :is(#overviewView .overview-indicators div strong,.access-summary article strong,.staff-empty strong,.empty-statistics strong,.gallery-file-picker span,.gallery-admin-grid article strong,.profile-tag strong){color:var(--ui-ink)!important}
html[data-theme="dark"] .system-page :is(#overviewView .overview-indicators div span,.access-summary article span,.staff-empty p,.empty-statistics p,.gallery-admin-grid article p){color:var(--ui-muted)!important}

/* Central de RSO */
html[data-theme="dark"] .system-page #serviceReportsView{
  --rso-gold:#d0ac55;
  --rso-ink:#efeee9;
  --rso-muted:#a2a39d;
  --rso-line:#393a35
}
html[data-theme="dark"] .system-page #serviceReportsView :is(.report-view-switch,.rso-command-summary,.rso-tabs,.rso-filters){
  border-color:var(--rso-line)!important;
  background:var(--ui-surface)!important;
  color:var(--ui-ink)!important
}
html[data-theme="dark"] .system-page #serviceReportsView :is(.report-view-switch button,.rso-tabs button){
  border-color:#42433e!important;
  background:#232420!important;
  color:#d4d5cf!important
}
html[data-theme="dark"] .system-page #serviceReportsView :is(.report-view-switch button.active,.rso-tabs button.active){
  border-color:#d0ac55!important;
  background:#d0ac55!important;
  color:#171815!important
}
html[data-theme="dark"] .system-page #serviceReportsView #historyAccessNote{
  border-color:#574b2d!important;
  background:#2a2518!important;
  color:#d4c28e!important
}
html[data-theme="dark"] .system-page #serviceReportsView .report-history-list .rso-list-card{
  border-color:var(--rso-line)!important;
  background:var(--ui-surface)!important;
  color:var(--ui-ink)!important;
  box-shadow:0 10px 28px #0003!important
}
html[data-theme="dark"] .system-page #serviceReportsView :is(.rso-card-results i,.rso-card-footer){
  border-color:#363732!important;
  background:var(--ui-surface-soft)!important;
  color:#d0d1cb!important
}
html[data-theme="dark"] .system-page #serviceReportsView :is(.rso-open-details,.rso-card-title,.rso-card-results strong){color:var(--ui-ink)!important}

/* Formulario e detalhes do RSO */
html[data-theme="dark"] .system-page #serviceReportsView :is(.rso-wizard-steps,.rso-review-panel,.rso-review-grid article,.rso-wizard-navigation){border-color:var(--ui-line)!important;background:var(--ui-surface)!important;color:var(--ui-ink)!important}
html[data-theme="dark"] .system-page #serviceReportsView .rso-wizard-steps button{border-color:var(--ui-line)!important;background:var(--ui-surface)!important;color:var(--ui-muted)!important}
html[data-theme="dark"] .system-page #serviceReportsView .rso-wizard-steps button.active{background:#11120f!important;color:#fff!important}
html[data-theme="dark"] .system-page #serviceReportsView .rso-wizard-steps button b{color:var(--ui-ink)!important}
html[data-theme="dark"] .system-page #serviceReportsView .rso-wizard-steps button.active b{color:#fff!important}
html[data-theme="dark"] .system-page #serviceReportsView .rso-review-grid span{color:var(--ui-muted)!important}
html[data-theme="dark"] .system-page #serviceReportsView .rso-review-alerts{border-color:#806b37!important;background:#302919!important}
html[data-theme="dark"] .system-page #serviceReportsView .rso-review-alerts :is(strong,p){color:#dfc47f!important}
html[data-theme="dark"] .system-page #serviceReportsView .rso-wizard-navigation button{border-color:#41423d!important;background:#232420!important;color:#e5e4de!important}
html[data-theme="dark"] .system-page #serviceReportsView .rso-wizard-navigation button:last-child{border-color:#d0ac55!important;background:#d0ac55!important;color:#171815!important}
html[data-theme="dark"] .system-page :is(.approach-builder-wrap,.detainee-builder-wrap,.deceased-builder-wrap,.approach-editor,.approach-empty,.detainee-illicit-builder,.detainee-illicit-empty,.detainee-illicit-grid,.occurrence-panel-help,.occurrence-critical-box,.rso-point-field,.rso-point-modal-status,.report-approaches-view,.report-detail-grid>div,.report-detail-text,.report-approach-meta>div,.report-change-list){
  border-color:var(--ui-line)!important;
  background:var(--ui-surface-soft)!important;
  color:var(--ui-ink)!important
}
html[data-theme="dark"] .system-page :is(.approach-tabs,.report-approach-tabs){border-color:var(--ui-line)!important}
html[data-theme="dark"] .system-page :is(.approach-tabs button,.report-approach-tabs button){
  border-color:#41423d!important;
  background:#232420!important;
  color:#d5d6d0!important
}
html[data-theme="dark"] .system-page :is(.approach-tabs button.active,.report-approach-tabs button.active){
  border-color:#d0ac55!important;
  background:#d0ac55!important;
  color:#171815!important
}
html[data-theme="dark"] .system-page .report-details-modal{background:var(--ui-bg)!important}
html[data-theme="dark"] .system-page .report-details-modal :is(.report-detail-section,.report-detail-head){
  border-color:var(--ui-line)!important;
  background:var(--ui-surface)!important;
  color:var(--ui-ink)!important
}
html[data-theme="dark"] .system-page :is(.report-detail-text p,.report-detail-grid strong,.report-approach-meta strong,.report-change-list strong){color:#e4e3dd!important}
html[data-theme="dark"] .system-page :is(.report-detail-grid span,.report-approach-meta span,.report-change-list span){color:var(--ui-muted)!important}
html[data-theme="dark"] .system-page .report-section-heading>span{background:#332b19!important;color:#dfc374!important}

/* Dialogos, seletores e estados auxiliares */
html[data-theme="dark"] .system-page :is(.annotation-category-preview,.annotation-format-picker label>span,.annotation-draw-status,.function-editor-modal,.permission-editor-modal,.backup-modal,.password-modal){
  border-color:var(--ui-line)!important;
  background:var(--ui-surface)!important;
  color:var(--ui-ink)!important
}
html[data-theme="dark"] .system-page :is(.annotation-format-picker label>span:hover,.function-tag-picker button:hover){background:#2a2b27!important}
html[data-theme="dark"] .system-page dialog::backdrop{background:#000b}
html[data-theme="dark"] .system-page :is(.profile-tags span,.function-tag-editor,.rso-attachment,.report-detail-attachments a){
  border-color:#42433e!important;
  background:#242521!important;
  color:#d8d9d3!important
}
html[data-theme="dark"] .system-page :is(.function-tag-picker button.selected,.permission-option:has(input:checked)){
  border-color:#806b37!important;
  background:#302919!important;
  color:#dfc47f!important
}
html[data-theme="dark"] .system-page :is(.report-revision-notice,.rso-revision-note,.rso-list-card>.rso-revision-note){
  border-color:#70403a!important;
  background:#2f1d1a!important;
  color:#e3aaa2!important
}
html[data-theme="dark"] .system-page .report-history-list .rso-actions button.secondary{
  border-color:#44453f!important;
  background:#242521!important;
  color:#dedfd9!important
}
html[data-theme="dark"] .system-page :is(.rso-point-field button,.detainee-illicit-head button){
  border-color:#806b37!important;
  background:#302919!important;
  color:#dfc47f!important
}
html[data-theme="dark"] .system-page .detainee-illicit-row>button{
  border-color:#70403a!important;
  background:#2f1d1a!important;
  color:#e3aaa2!important
}
html[data-theme="dark"] .system-page :is(.occurrence-critical-box .activity-toggle span,.report-section-narrative .report-attachments){
  border-color:var(--ui-line)!important;
  background:var(--ui-surface-soft)!important;
  color:#d5d6d0!important
}
html[data-theme="dark"] .system-page .deceased-builder-wrap :is(.approach-tabs button.active,.detainee-illicit-builder){
  border-color:#70403a!important;
  background:#2f1d1a!important;
  color:#e3aaa2!important
}
html[data-theme="dark"] .system-page .rso-submission-blockers{border-color:#70403a!important;background:#211816!important;box-shadow:0 12px 28px #0004!important}
html[data-theme="dark"] .system-page .rso-submission-blockers-head{border-color:#70403a!important;background:#2f1d1a!important}
html[data-theme="dark"] .system-page .rso-submission-blockers-head strong{color:#f1b7b0!important}
html[data-theme="dark"] .system-page .rso-submission-blockers-head p{color:#c58f88!important}
html[data-theme="dark"] .system-page .rso-submission-blockers li button{border-color:#583531!important;background:#25201d!important;color:#eee7e3!important}
html[data-theme="dark"] .system-page .rso-submission-blockers li button:hover{border-color:#b95a52!important;background:#2b211f!important}
html[data-theme="dark"] .system-page .rso-submission-blockers li button>span{background:#3d2421!important;color:#e4a39c!important}
html[data-theme="dark"] .system-page .rso-submission-blockers li button>small{color:#e2a29b!important}
html[data-theme="dark"] .system-page :is(.staff-editor-head .close-modal,.staff-editor-body .checkbox,.course-active-field){
  border-color:#42433e!important;
  background:#242521!important;
  color:#d8d9d3!important
}
html[data-theme="dark"] .system-page .annotation-category-preview>i{border-color:#44453f!important;box-shadow:0 4px 12px #0005!important}
html[data-theme="dark"] .system-page .annotation-format-picker label>span>i{background:#30312d!important;color:#c8c9c3!important}
html[data-theme="dark"] .system-page :is(.status-badge,.overview-status,.access-state.online){border-color:#315d40!important;background:#192c20!important;color:#83d39d!important}
html[data-theme="dark"] .system-page :is(.overview-status.pending,.rso-status.is-pending){border-color:#69562e!important;background:#302817!important;color:#dfbd6d!important}
html[data-theme="dark"] .system-page :is(.overview-status.revision,.rso-status.is-revision,.access-state.disabled){border-color:#70403a!important;background:#2f1d1a!important;color:#e3aaa2!important}

@media(max-width:1000px){.header-actions{gap:9px}.header-actions .main-nav{order:3}}
@media(max-width:620px){.theme-toggle{width:36px;height:36px}.system-theme-login{right:14px;top:36px}}
@media print{
  .theme-toggle{display:none!important}
  html[data-theme="dark"] .system-page{--ui-bg:#fff;--ui-surface:#fff;--ui-surface-soft:#f7f7f3;--ui-ink:#171816;--ui-muted:#666;--ui-line:#ddd;background:#fff!important;color:#171816!important}
  html[data-theme="dark"] .system-page :is(.panel,.metric-grid article,.service-report-form fieldset,.report-preview-card pre,.report-details-modal section){border-color:#ddd!important;background:#fff!important;color:#171816!important}
}
