/* High-contrast dark theme. Loaded last so it always wins over page styles. */
html[data-theme="dark"]{--ui-bg:#05090d;--ui-card:#0d141b;--ui-border:#2b3b48;--ui-text:#f4f7fa;--ui-muted:#bdc8d2;--ui-shadow:0 10px 30px rgba(0,0,0,.42);color-scheme:dark}
html[data-theme="dark"],html[data-theme="dark"] body,html[data-theme="dark"] body.app-page,html[data-theme="dark"] .app-shell,html[data-theme="dark"] .workspace,html[data-theme="dark"] .single-page,html[data-theme="dark"] .settings-shell{background:#05090d!important;color:#f4f7fa!important}
html[data-theme="dark"] .topbar{background:linear-gradient(135deg,#111a22,#060b10)!important;border-bottom-color:#f5a719!important}
html[data-theme="dark"] .sidebar{background:#080e13!important;border-color:#2b3b48!important;box-shadow:-5px 0 24px rgba(0,0,0,.5)!important}
html[data-theme="dark"] .panel,html[data-theme="dark"] details.panel,html[data-theme="dark"] .kpi,html[data-theme="dark"] .login-card,html[data-theme="dark"] .settings-card,html[data-theme="dark"] .asset-card,html[data-theme="dark"] .modal-card,html[data-theme="dark"] dialog,html[data-theme="dark"] .empty-state,html[data-theme="dark"] .workspace-head,html[data-theme="dark"] .dashboard-heading,html[data-theme="dark"] .chart-card,html[data-theme="dark"] .report-card{background:#0d141b!important;color:#f4f7fa!important;border-color:#2b3b48!important;box-shadow:var(--ui-shadow)!important}
html[data-theme="dark"] #projectWorkspace .workspace-head>div:first-child{background:linear-gradient(135deg,#121b23,#0b1117)!important;border-color:#3a4650!important}
html[data-theme="dark"] #projectWorkspace .toolbar,html[data-theme="dark"] .toolbar{background:#091017!important;border-color:#2b3b48!important}
html[data-theme="dark"] #projectWorkspace .kpi-grid .kpi,html[data-theme="dark"] #projectWorkspace .panel{background:#0d141b!important;border-color:#2b3b48!important}
html[data-theme="dark"] #projectWorkspace .kpi-grid .kpi span{color:#c7d1da!important}
html[data-theme="dark"] #projectWorkspace .kpi-grid .kpi strong,html[data-theme="dark"] #projectWorkspace #workspaceTitle{color:#fff!important}
html[data-theme="dark"] #projectWorkspace #deadlineBadge{background:#121b23!important;color:#ffd58b!important;border-color:#bd7811!important}
html[data-theme="dark"] #projectWorkspace .toolbar .save-status{color:#c1ccd5!important}
html[data-theme="dark"] .project-card,html[data-theme="dark"] .quick-add,html[data-theme="dark"] .asset-preview,html[data-theme="dark"] .tabs,html[data-theme="dark"] .filter-bar,html[data-theme="dark"] .summary-card{background:#111c24!important;color:#f3f7fa!important;border-color:#314452!important}
html[data-theme="dark"] .project-card:hover,html[data-theme="dark"] .project-card.active{background:#182733!important;border-color:#f5a719!important}
html[data-theme="dark"] input,html[data-theme="dark"] select,html[data-theme="dark"] textarea,html[data-theme="dark"] .search-input{background:#060c11!important;color:#fff!important;border-color:#3a4d5c!important;caret-color:#f5a719!important}
html[data-theme="dark"] input:focus,html[data-theme="dark"] select:focus,html[data-theme="dark"] textarea:focus{border-color:#f5a719!important;box-shadow:0 0 0 3px rgba(245,167,25,.18)!important}
html[data-theme="dark"] input::placeholder,html[data-theme="dark"] textarea::placeholder{color:#93a2ae!important;opacity:1!important}
html[data-theme="dark"] option{background:#091017;color:#fff}
html[data-theme="dark"] h1,html[data-theme="dark"] h2,html[data-theme="dark"] h3,html[data-theme="dark"] h4,html[data-theme="dark"] strong,html[data-theme="dark"] label,html[data-theme="dark"] summary,html[data-theme="dark"] td{color:#f4f7fa!important}
html[data-theme="dark"] .muted,html[data-theme="dark"] .hint,html[data-theme="dark"] small{color:#b9c5cf!important}
html[data-theme="dark"] .eyebrow{color:#ffb52e!important}
html[data-theme="dark"] .data-table,html[data-theme="dark"] .table{--bs-table-bg:#0d141b;--bs-table-color:#f4f7fa;--bs-table-border-color:#2b3b48;--bs-table-striped-bg:#111c24;--bs-table-hover-bg:#172632;--bs-table-hover-color:#fff;background:#0d141b!important;color:#f4f7fa!important}
html[data-theme="dark"] .data-table thead th,html[data-theme="dark"] .data-table tfoot th,html[data-theme="dark"] .table thead th{background:#17232d!important;color:#fff!important;border-color:#344957!important}
html[data-theme="dark"] .data-table td,html[data-theme="dark"] .data-table th,html[data-theme="dark"] .table td,html[data-theme="dark"] .table th{border-color:#2b3b48!important}
html[data-theme="dark"] .btn-light{background:#17232d!important;border-color:#405361!important;color:#fff!important}
html[data-theme="dark"] .btn-light:hover{background:#223440!important;border-color:#607482!important;color:#fff!important}
html[data-theme="dark"] #projectWorkspace #deleteProjectBtn{background:#211012!important;border-color:#a84747!important;color:#ff8e8e!important}
html[data-theme="dark"] #projectWorkspace #deleteProjectBtn{background:#b42318!important;border-color:#f97066!important;color:#fff!important}
html[data-theme="dark"] .system-footer{color:#b8c5d1;border-color:#304656}
html[data-theme="dark"] #projectWorkspace .project-actions-menu .toolbar{background:#101a22!important;border-color:#385064!important}
html[data-theme="dark"] #projectWorkspace .project-actions-menu>summary{background:#315f7e!important;color:#fff!important}
html[data-theme="dark"] #projectWorkspace #tripCostsBtn{background:#092221!important;border-color:#277b76!important;color:#75e1d9!important}
html[data-theme="dark"] .badge,html[data-theme="dark"] .user-chip{color:#f4f7fa!important;border-color:#425563!important}
html[data-theme="dark"] hr{border-color:#2b3b48!important;opacity:1}
html[data-theme="dark"] ::-webkit-scrollbar{width:11px;height:11px}
html[data-theme="dark"] ::-webkit-scrollbar-track{background:#05090d}
html[data-theme="dark"] ::-webkit-scrollbar-thumb{background:#41515d;border:2px solid #05090d;border-radius:10px}
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover{background:#5b6e7b}

/* Critical contrast fixes: section headers and item counters */
html[data-theme="dark"] #projectWorkspace details.project-details>summary,
html[data-theme="dark"] #projectWorkspace .panel>summary{
  background:#111d26!important;
  color:#fff!important;
  border-bottom:1px solid #3b4f5e!important;
  text-shadow:0 1px 1px rgba(0,0,0,.45)!important;
}
html[data-theme="dark"] #projectWorkspace details.project-details>summary::marker,
html[data-theme="dark"] #projectWorkspace .panel>summary::marker{color:#f5a719!important}

html[data-theme="dark"] .project-card small{
  color:#c8d2db!important;
  opacity:1!important;
}
html[data-theme="dark"] .project-card small>span:last-child{
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
  min-width:52px!important;
  padding:3px 8px!important;
  border:1px solid #bd7811!important;
  border-radius:999px!important;
  background:#18232c!important;
  color:#fff!important;
  font-weight:800!important;
  opacity:1!important;
}
html[data-theme="dark"] #itemsCount,
html[data-theme="dark"] .items-panel .panel-head .badge{
  background:#18232c!important;
  color:#fff!important;
  border:1px solid #f5a719!important;
  font-weight:800!important;
  opacity:1!important;
  box-shadow:0 0 0 1px rgba(245,167,25,.12)!important;
}

/* Keep project names and the sidebar header readable. */
html[data-theme="dark"] .sidebar-head{
  background:#080e13!important;
  border-bottom-color:#344957!important;
}
html[data-theme="dark"] .sidebar-head h2{
  color:#fff!important;
  opacity:1!important;
  text-shadow:0 1px 1px rgba(0,0,0,.5)!important;
}
html[data-theme="dark"] .project-card strong,
html[data-theme="dark"] .project-card:hover strong,
html[data-theme="dark"] .project-card.active strong{
  color:#fff!important;
  opacity:1!important;
}
html[data-theme="dark"] #projectWorkspace #workspaceTitle{
  color:#fff!important;
  opacity:1!important;
  text-shadow:0 1px 1px rgba(0,0,0,.45)!important;
}

/* Bootstrap table-hover writes its color on every cell, so override the cells too. */
html[data-theme="dark"] .data-table.table-hover>tbody>tr:hover,
html[data-theme="dark"] .data-table.table-hover>tbody>tr:hover>*,
html[data-theme="dark"] .data-table tbody tr:hover,
html[data-theme="dark"] .data-table tbody tr:hover>td{
  --bs-table-bg-state:#172630!important;
  --bs-table-color-state:#fff!important;
  background:#172630!important;
  color:#fff!important;
}
html[data-theme="dark"] .data-table tbody tr:hover strong,
html[data-theme="dark"] .data-table tbody tr:hover span,
html[data-theme="dark"] .data-table tbody tr:hover small,
html[data-theme="dark"] .data-table tbody tr:hover .num{
  color:#fff!important;
  opacity:1!important;
}
html[data-theme="dark"] .data-table tbody tr.dirty,
html[data-theme="dark"] .data-table tbody tr.dirty>td{
  background:#241b0c!important;
  color:#fff!important;
}

/* Dashboard metric cards */
html[data-theme="dark"] .dashboard-kpis .metric-card{
  background:#0d161e!important;
  border:1px solid #344957!important;
  color:#fff!important;
  box-shadow:0 8px 22px rgba(0,0,0,.32)!important;
}
html[data-theme="dark"] .dashboard-kpis .metric-card.warning-card{
  background:#241b0c!important;
  border-color:#b87917!important;
}
html[data-theme="dark"] .dashboard-kpis .metric-card span,
html[data-theme="dark"] .dashboard-kpis .metric-card small{
  color:#bdc9d3!important;
  opacity:1!important;
}
html[data-theme="dark"] .dashboard-kpis .metric-card strong{
  color:#fff!important;
  opacity:1!important;
  text-shadow:0 1px 1px rgba(0,0,0,.45)!important;
}
html[data-theme="dark"] .dashboard-kpis .metric-card.warning-card strong{color:#ffc85a!important}

/* PDF stamper: dark panels with clear labels and values. */
html[data-theme="dark"] .pdf-stamper-panel .panel-head{
  background:linear-gradient(135deg,#111d26,#0a1117)!important;
  border-bottom-color:#344957!important;
}
html[data-theme="dark"] .pdf-stamper-panel .panel-head h2{color:#fff!important}
html[data-theme="dark"] .pdf-stamper-panel .panel-head p{color:#bdc9d3!important}
html[data-theme="dark"] .pdf-drop-field{
  background:#0a131a!important;
  border-color:#47827f!important;
  color:#fff!important;
}
html[data-theme="dark"] .pdf-drop-field>label,
html[data-theme="dark"] .pdf-stamp-options>label{color:#fff!important;opacity:1!important}
html[data-theme="dark"] .pdf-drop-field small{color:#b9c7d1!important}
html[data-theme="dark"] .pdf-drop-field input[type="file"]{
  background:#050b10!important;
  color:#fff!important;
  border-color:#3a5060!important;
}
html[data-theme="dark"] .pdf-drop-field input[type="file"]::file-selector-button{
  background:#253746!important;
  color:#fff!important;
  border:0!important;
  border-inline-end:1px solid #506575!important;
}
html[data-theme="dark"] .selected-stamp-preview{
  background:#101a22!important;
  border-color:#3a5060!important;
  color:#fff!important;
}
html[data-theme="dark"] .selected-stamp-preview strong{color:#fff!important}
html[data-theme="dark"] .selected-stamp-preview small{color:#bdc9d3!important}
html[data-theme="dark"] .selected-stamp-preview img{
  background-color:#d8dde1!important;
  border-color:#657783!important;
}
html[data-theme="dark"] .pdf-stamp-status{color:#c5d0d8!important}
html[data-theme="dark"] .pdf-stamp-status.success{color:#35d58b!important}
html[data-theme="dark"] .pdf-stamp-status.error{color:#ff8585!important}
html[data-theme="dark"] .privacy-badge{
  background:#08251a!important;
  color:#69e8a8!important;
  border-color:#258e60!important;
}
html[data-theme="dark"] .stamp-card{background:#0f1921!important;border-color:#344957!important;color:#fff!important}
html[data-theme="dark"] .stamp-card-body strong{color:#fff!important}
html[data-theme="dark"] .stamp-card-body small{color:#bdc9d3!important}
html[data-theme="dark"] .pdf-file-row{background:#101b23!important;border-color:#344b59!important;color:#fff!important}
html[data-theme="dark"] .pdf-file-row strong{color:#fff!important}
html[data-theme="dark"] .pdf-file-row span{color:#bdc9d3!important}
html[data-theme="dark"] .pdf-file-row.done{background:#09261b!important;border-color:#278b61!important}
html[data-theme="dark"] .pdf-file-row.error{background:#291315!important;border-color:#a64b50!important}

/* Compact command palette: keep every action visibly distinct in dark mode. */
html[data-theme="dark"] #projectWorkspace #quotationLink,
html[data-theme="dark"] #projectWorkspace #projectCostImportChoose{background:#356f98!important;border-color:#4d8bb5!important;color:#fff!important}
html[data-theme="dark"] #projectWorkspace #financialOfferLink{background:#f7a91b!important;border-color:#f7a91b!important;color:#18232b!important}
html[data-theme="dark"] #projectWorkspace #pdfLink,
html[data-theme="dark"] #projectWorkspace #pricingSheetPdfLink{background:#332817!important;border-color:#b78027!important;color:#ffd98e!important}
html[data-theme="dark"] #projectWorkspace #exportLink,
html[data-theme="dark"] #projectWorkspace #pricingSheetXlsxLink{background:#122b20!important;border-color:#3d8b61!important;color:#8be0af!important}
html[data-theme="dark"] #projectWorkspace #pricingSheetWordLink{background:#17283a!important;border-color:#4d79a5!important;color:#9dcaef!important}
html[data-theme="dark"] #projectWorkspace #tripCostsBtn{background:#102d2c!important;border-color:#358b85!important;color:#7ce0d9!important}
html[data-theme="dark"] #projectWorkspace #deleteProjectBtn,
html[data-theme="dark"] #projectWorkspace #clearAllItemCostsBtn{background:#35191a!important;border-color:#a84e52!important;color:#ff9a9d!important}

html[data-theme="dark"] #costDialog #costTabs button{background:#1a2731!important;border-color:#455b6b!important;color:#dce5eb!important}
html[data-theme="dark"] #costDialog #costTabs button[data-category="purchase"].active{background:#f7a91b!important;border-color:#f7a91b!important;color:#17232c!important}
html[data-theme="dark"] #costDialog #costTabs button[data-category="execution"].active{background:#3478a5!important;border-color:#3478a5!important;color:#fff!important}
html[data-theme="dark"] #costDialog #costTabs button[data-category="post_execution"].active{background:#17845f!important;border-color:#17845f!important;color:#fff!important}
html[data-theme="dark"] #costDialog .save-cost{background:#123326!important;border-color:#39845f!important;color:#81e0ad!important}
html[data-theme="dark"] #costDialog .delete-cost{background:#35191a!important;border-color:#a84e52!important;color:#ff9a9d!important}

/* B57: readable interactive values in the pricing table and administrative reports. */
html[data-theme="dark"] #itemsTable .approved-price-label input{background:#142530!important;border-color:#648da7!important;color:#fff!important}
html[data-theme="dark"] #itemsTable .approved-price-label input:hover{background:#1b3140!important;border-color:#f5b335!important;color:#fff!important}
html[data-theme="dark"] #projectWorkspace .items-help{background:#152734!important;border-color:#5d829a!important;color:#fff!important}
html[data-theme="dark"] #projectWorkspace .project-details>summary small{color:#c4d0d8!important}
html[data-theme="dark"] .dashboard-kpis .metric-card:hover{background:#172631!important;border-color:#6f93aa!important;color:#fff!important}
html[data-theme="dark"] .dashboard-kpis .metric-card:hover span,
html[data-theme="dark"] .dashboard-kpis .metric-card:hover small,
html[data-theme="dark"] .dashboard-kpis .metric-card:hover strong{color:#fff!important;opacity:1!important}
html[data-theme="dark"] .dashboard-kpis .metric-card.warning-card:hover{background:#342713!important;border-color:#e4a438!important}
html[data-theme="dark"] .dashboard-page .panel-head>.badge{background:#214d6a!important;color:#fff!important;border-color:#6da3c5!important;text-shadow:0 1px 1px #000!important}
html[data-theme="dark"] .table-pagination{border-color:#344957!important;background:#0d161e!important}
html[data-theme="dark"] .table-pagination button{background:#172631!important;color:#fff!important;border-color:#506b7d!important}
html[data-theme="dark"] .table-pagination button:hover:not(:disabled),html[data-theme="dark"] .table-pagination button.active{background:#356f98!important;border-color:#79a9c7!important;color:#fff!important}
html[data-theme="dark"] .table-pagination .page-summary{color:#c6d1d9!important}
html[data-theme="dark"] .status-pill:hover{filter:brightness(1.18);color:#fff!important;box-shadow:0 0 0 1px #ffffff55}
html[data-theme="dark"] .status-pill.status-draft{background:#6e3f06!important;color:#fff2cf!important}
html[data-theme="dark"] .status-pill.status-submitted{background:#164b7b!important;color:#e8f5ff!important}
html[data-theme="dark"] .status-pill.status-awarded{background:#14633f!important;color:#e5fff1!important}
html[data-theme="dark"] .status-pill.status-closed{background:#43505b!important;color:#fff!important}
html[data-theme="dark"] .entity-list>div:hover strong{background:#284e73!important;color:#fff!important}
