/* Optional screen theme. No rule applies in day mode. */
html[data-bs-theme="dark"] {
  color-scheme: dark;
  --bg: #111827;
  --bg2: #182233;
  --text: #e2e8f0;
  --muted: #a8b6ca;
  --line: #3b4b61;
  --glass: #202d40;
  --glass-strong: #2a3a50;
}
html[data-bs-theme="dark"] body {
  --ui-bg: #111827;
  --ui-ink: #e2e8f0;
  --ui-muted: #a8b6ca;
  --ui-line: #3b4b61;
  --ui-primary: #83b4ff;
  background: #111827 !important;
  color: #e2e8f0;
}
html[data-bs-theme="dark"] :is(.card, .card-header, .card-footer, .section-card,
  .page-card, .panel, .metric, .canvas-card, .side-card, .ui-filter-bar,
  .modal-content, .accordion-item, .accordion-button, .product-box,
  .bg-white, .bg-light, .bg-soft, .topbar, .user-panel) {
  background: #1c293b !important;
  color: #e2e8f0 !important;
  border-color: #3b4b61 !important;
}
html[data-bs-theme="dark"] .accordion-button:not(.collapsed) {
  background: #293c57 !important;
}
html[data-bs-theme="dark"] :is(.text-muted, .text-secondary, .form-text) {
  color: #a8b6ca !important;
}
html[data-bs-theme="dark"] :is(.text-dark, .text-body, .form-label) {
  color: #e2e8f0 !important;
}
html[data-bs-theme="dark"] body form :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea),
html[data-bs-theme="dark"] :is(.ts-control, .ts-dropdown, .input-group-text) {
  background-color: #111d2e !important;
  color: #e2e8f0 !important;
  border-color: #52647c !important;
}
html[data-bs-theme="dark"] input::placeholder,
html[data-bs-theme="dark"] textarea::placeholder { color: #94a3b8; opacity: 1; }
html[data-bs-theme="dark"] .table {
  --bs-table-color: #e2e8f0;
  --bs-table-bg: #1c293b;
  --bs-table-border-color: #3b4b61;
  --bs-table-striped-bg: #243349;
  --bs-table-striped-color: #e2e8f0;
  --bs-table-hover-bg: #30435e;
  --bs-table-hover-color: #fff;
}
html[data-bs-theme="dark"] :is(.kv th, .table-light, .table-light th) {
  background: #243349 !important;
  color: #e2e8f0 !important;
}
/* Bootstrap paints each table cell from the variables on its row. Styling only
   the table-light row leaves purchase-order and delivery-note totals white. */
html[data-bs-theme="dark"] body.ascolink-ui .table :is(tfoot, .table-light) {
  --bs-table-bg: #243349;
  --bs-table-color: #e2e8f0;
  --bs-table-border-color: #3b4b61;
}
html[data-bs-theme="dark"] body.ascolink-ui .table > tfoot > tr > :is(th, td),
html[data-bs-theme="dark"] body.ascolink-ui .table > :is(thead, tbody, tfoot) > .table-light > :is(th, td),
html[data-bs-theme="dark"] body.ascolink-ui .table > .table-light > tr > :is(th, td) {
  background: #243349 !important;
  color: #e2e8f0 !important;
  border-color: #3b4b61 !important;
}
html[data-bs-theme="dark"] .btn-outline-secondary {
  color: #d2deef;
  border-color: #71849f;
  --bs-btn-hover-bg: #354861;
  --bs-btn-hover-color: #fff;
}
html[data-bs-theme="dark"] .btn-outline-dark {
  --bs-btn-color: #e2e8f0;
  --bs-btn-border-color: #94a3b8;
  --bs-btn-hover-color: #0f172a;
  --bs-btn-hover-bg: #e2e8f0;
  --bs-btn-hover-border-color: #e2e8f0;
  --bs-btn-active-color: #0f172a;
  --bs-btn-active-bg: #cbd5e1;
  --bs-btn-active-border-color: #cbd5e1;
  --bs-btn-disabled-color: #94a3b8;
  --bs-btn-disabled-border-color: #64748b;
}
html[data-bs-theme="dark"] .btn-primary {
  --bs-btn-bg: #2864bd;
  --bs-btn-border-color: #3979d5;
  --bs-btn-color: #fff;
  --bs-btn-hover-bg: #3477d4;
}
html[data-bs-theme="dark"] .btn-outline-primary { color: #91bdff; }
html[data-bs-theme="dark"] :is(.action-icon, .group-icon) { background: #25354b; }
html[data-bs-theme="dark"] .action::before { opacity: .12; }

/* Shared controls and surfaces used outside a form or a Bootstrap card. */
html[data-bs-theme="dark"] body.ascolink-ui :is(.form-control, .form-select, .readonly-box,
  .page-link, .list-group-item, .dropdown-menu, .dropdown-item, .popover,
  .nav-tabs .nav-link, .modal-header, .modal-footer) {
  background: #1c293b !important;
  color: #e2e8f0 !important;
  border-color: #3b4b61 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui :is(.page-link, .dropdown-item, .list-group-item,
  .nav-tabs .nav-link):is(:hover, :focus) {
  background: #30435e !important;
  color: #fff !important;
}
html[data-bs-theme="dark"] body.ascolink-ui :is(.page-item.active .page-link, .nav-tabs .nav-link.active) {
  background: #2864bd !important;
  color: #fff !important;
}
html[data-bs-theme="dark"] body.ascolink-ui :is(.form-label, form > p > label, .small-label, .small-card-label,
  .hint, .section-title-note) { color: #b9c8dc !important; }
html[data-bs-theme="dark"] body.ascolink-ui :is(input, select, textarea):disabled,
html[data-bs-theme="dark"] body.ascolink-ui fieldset:disabled :is(input, select, textarea),
html[data-bs-theme="dark"] body.ascolink-ui :is(input, textarea)[readonly] {
  background-color: #253449 !important;
  color: #b9c8dc !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .ts-dropdown .option:is(.active, :hover),
html[data-bs-theme="dark"] body.ascolink-ui .ts-dropdown .active {
  background: #30435e !important;
  color: #fff !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .ts-control input { color: #e2e8f0 !important; }
html[data-bs-theme="dark"] body.ascolink-ui .btn-outline-secondary {
  --bs-btn-color: #d2deef;
  --bs-btn-border-color: #71849f;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #354861;
}

/* Purchase forms and their product pickers have explicit light backgrounds. */
html[data-bs-theme="dark"] body.ascolink-ui .po-table td :is(input:not([type="checkbox"]):not([type="hidden"]), select, textarea) {
  background-color: #111d2e !important;
  color: #e2e8f0 !important;
  border-color: #52647c !important;
}
html[data-bs-theme="dark"] body.ascolink-ui :is(.suggestions .panel, .produit-dialog,
  .produit-dialog-result) {
  background: #1c293b !important;
  color: #e2e8f0 !important;
  border-color: #3b4b61 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui :is(.suggestions .item, .produit-dialog-result) {
  border-color: #3b4b61 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui :is(.suggestions .item:hover,
  .produit-dialog-result:hover, .produit-dialog-result:focus) {
  background: #30435e !important;
  color: #fff !important;
}

/* Inventory and production status colors keep their meaning in the dark palette. */
html[data-bs-theme="dark"] body.ascolink-ui .row-stock-seuil > td {
  background: #473a20 !important;
  color: #fff0c2 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .row-stock-critique > td {
  background: #542b35 !important;
  color: #ffe0e4 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .ligne-conso-ok > td {
  background: #204335 !important;
  color: #d4f5e2 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .btn-ok-conso-pending {
  background: #1c293b !important;
  color: #ff9ba5 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .table-sticky thead th {
  background: #293d55 !important;
  color: #fff !important;
}

/* Maps, planning board, trace graph and small page-specific panels. */
html[data-bs-theme="dark"] body.ascolink-ui :is(.palette-box, .readonly-box,
  .gantt-name, .gantt-hours, .week-entry, .assignment, .toolbar,
  #svg-stage-wrap, #svg-stage, #picker-wrap, #picker-svg, .whiteboard-shell) {
  background: #202d40 !important;
  color: #e2e8f0 !important;
  border-color: #3b4b61 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui :is(.section-box, .address-card) {
  background: #1c293b !important;
  color: #e2e8f0 !important;
  border-color: #3b4b61 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .address-card .meta {
  color: #b9c8dc !important;
}
html[data-bs-theme="dark"] body.ascolink-ui :is(#traceGraph, .whiteboard) {
  background-color: #182537 !important;
  border-color: #3b4b61 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui :is(.legend-badge, .root-box) {
  background: #243349 !important;
  color: #e2e8f0 !important;
  border-color: #52647c !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .root-box .value { color: #e2e8f0 !important; }
html[data-bs-theme="dark"] body.ascolink-ui .root-box .label { color: #91bdff !important; }
html[data-bs-theme="dark"] body.ascolink-ui .ligne-conso-pending > td {
  background: #542b35 !important;
  color: #ffe0e4 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui :is(.status-line, .login-subtitle, .footer-note) {
  color: #b9c8dc !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .login-card { background: #1c293b !important; }
html[data-bs-theme="dark"] body.ascolink-ui .alert-danger {
  background: #542b35 !important;
  color: #ffe0e4 !important;
  border-color: #864756 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .alert-warning {
  background: #473a20 !important;
  color: #fff0c2 !important;
  border-color: #76602e !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .alert-success {
  background: #204335 !important;
  color: #d4f5e2 !important;
  border-color: #356c54 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .alert-info {
  background: #1d4150 !important;
  color: #d3f3ff !important;
  border-color: #346578 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui #dropZoneCommandeClient.dragover {
  background: #30435e !important;
}
html[data-bs-theme="dark"] body.ascolink-ui :is(.gantt-track, .fc .fc-scrollgrid,
  .fc .fc-daygrid-day, .fc .fc-timegrid-slot) {
  background: #182537 !important;
  color: #e2e8f0 !important;
  border-color: #3b4b61 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .shape-text {
  background: #243349 !important;
  color: #e2e8f0 !important;
}
html[data-bs-theme="dark"] body.ascolink-ui .legend-yellow { background: #856521 !important; }
html[data-bs-theme="dark"] body.ascolink-ui .legend-red { background: #9a404f !important; }
html[data-bs-theme="dark"] dialog[open] {
  background: #1c293b;
  color: #e2e8f0;
  border-color: #3b4b61;
}
