/* K-Forms dark theme
 * Applies to authenticated administrative pages that opt in through
 * kforms_theme_root_attributes(). Respondent and projector canvases stay light.
 */
:is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] {
  color-scheme: dark;
  --kf-bg: #191b20;
  --kf-page-bg: #191b20;
  --kf-surface: #24272e;
  --kf-raised: #2c3037;
  --kf-border: #424854;
  --kf-control-border: #AAB2BE;
  --kf-text: #f1f3f6;
  --kf-muted: #b7c0cb;
  --kf-gold: #e5c66f;
  --kf-gold-hover: #f1d98d;
  --kf-gold-text: #211e14;
  --kf-accent: #e5c66f;
  --kf-accent-text: #211e14;
  --kf-cobalt: #e5c66f;
  --kf-kiraly-cobalt: #e5c66f;
  --kf-kiraly-carbon: #f1f3f6;
  --kf-kiraly-gold: #e5c66f;
  --kf-editor-accent: #e5c66f;
  --kf-editor-text: #f1f3f6;
  --kf-link: #e5c66f;
  --kf-danger: #ffadb5;
  --kf-danger-hover: #ffc1c7;
  --kf-danger-soft: #432a31;
  --kf-danger-border: #74414a;
  --kf-focus: rgba(229, 198, 111, .42);
  --kf-shadow: 0 10px 28px rgba(0, 0, 0, .2);
  --kf-1on1-gold: #e5c66f;
  --kf-red: #ffadb5;
  min-height: 100%;
  color: var(--kf-text) !important;
  background-color: var(--kf-bg) !important;
  background-image: none !important;
}

/* General text, links and help copy */
:is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  h1, h2, h3, h4, h5, h6, strong, b, legend, dt, th
):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  color: #f3f4f7 !important;
}
:is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  p, small, label, .kf-muted, .kf-help, .kf-field-help, .kf-eyebrow,
  .kf-section-heading p, .opacitymedium, [class*="kf-"][class*="description"],
  [class*="kf-"][class*="subtitle"], [class*="kf-"][class*="meta"]
):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  color: var(--kf-muted) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] a:not(.button):not(.kf-btn):not(.kf-icon-btn) {
  color: var(--kf-link) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(.kf-alert, .kf-anon-note) {
  color: var(--kf-text) !important;
  background: var(--kf-raised) !important;
  border-color: var(--kf-border) !important;
}

/* Panels, cards, question/result summaries and dialog surfaces */
:is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  [class*="kf-"][class*="card"],
  [class*="kf-"][class*="panel"],
  [class*="kf-"][class*="question"],
  [class*="kf-"][class*="response"],
  [class*="kf-"][class*="result"],
  [class*="kf-"][class*="summary"],
  [class*="kf-"][class*="template"],
  [class*="kf-"][class*="notice"],
  [class*="kf-"][class*="tile"],
  [class*="kf-"][class*="section"],
  [role="dialog"],
  .kf-empty,
  .kf-fieldset,
  .kf-metric,
  .kf-private-result,
  .kf-participants-note
):not([class*="head"]):not([class*="meta"]):not([class*="icon"]):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  color: var(--kf-text) !important;
  background-color: var(--kf-surface) !important;
  background-image: none !important;
  border-color: var(--kf-border) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}

:is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  [class*="kf-"][class*="head"],
  [class*="kf-"][class*="toolbar"],
  [class*="kf-"][class*="tabs"],
  [class*="kf-"][class*="table-wrap"],
  [class*="kf-"][class*="filter"],
  [class*="kf-"][class*="savebar"],
  .kf-pagination,
  .kf-form-actions
):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  color: var(--kf-text) !important;
  background-color: var(--kf-raised) !important;
  background-image: none !important;
  border-color: var(--kf-border) !important;
}

/* Fields use dark native controls while preserving visible labels. */
:is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  input:not([type="checkbox"]):not([type="radio"]),
  select, textarea, .flat, [contenteditable="true"]
):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  color: var(--kf-text) !important;
  background-color: #191c21 !important;
  background-image: none !important;
  border-color: var(--kf-control-border) !important;
  color-scheme: dark;
}
:is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(input, textarea)::placeholder {
  color: #aeb7c2 !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(input[type="checkbox"], input[type="radio"]) {
  accent-color: #e5c66f;
}

/* Default actions remain graphite; primary actions keep the Kiraly gold. */
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .button, button, .kf-btn, .kf-icon-btn, .kf-link-button
):not(.kf-btn-primary):not(.button-primary):not(.kf-danger):not(.kf-btn-danger) {
  color: #eef0f4 !important;
  background-color: #30343c !important;
  background-image: none !important;
  border-color: var(--kf-control-border) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .button-primary, .kf-primary, .kf-btn-primary, .kf-button-primary, .kf-ms-results-btn
) {
  color: var(--kf-gold-text) !important;
  background: var(--kf-gold) !important;
  border-color: var(--kf-gold) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .button-primary, .kf-primary, .kf-btn-primary, .kf-button-primary, .kf-ms-results-btn
):hover {
  background: var(--kf-gold-hover) !important;
  border-color: var(--kf-gold-hover) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(.kf-danger, .kf-btn-danger) {
  color: var(--kf-red) !important;
  background-color: #432a31 !important;
  border-color: #74414a !important;
}

:is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] tr:hover:not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  background-color: #2c3037 !important;
}
/* Tables and status labels retain clear hierarchy and semantic colors. */
:is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  table, thead, tbody, tr, th, td, .liste_titre
):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  color: var(--kf-text) !important;
  border-color: var(--kf-border) !important;
}
:is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(th, thead, .liste_titre):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  background-color: var(--kf-raised) !important;
}
:is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] tr:nth-child(even):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  background-color: rgba(255, 255, 255, .025) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(.kf-status, .kf-1on1-status, .kf-settings-badge, .kf-type-badge, .kf-pill) {
  color: #c3cbd4 !important;
  background-color: #343941 !important;
  font-weight: 650;
  border-color: transparent !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-status-success, .kf-status-complete, .kf-settings-badge-success
) {
  color: #9be5c2 !important;
  background: #203c32 !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-status-warning, .kf-status-pending, .kf-settings-badge-neutral
) {
  color: var(--kf-gold) !important;
  background: #3d3522 !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-status-danger, .kf-status-error
) {
  color: var(--kf-red) !important;
  background: #432a31 !important;
}
/* Builder chrome is dark, while its authored form preview stays paper white. */
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-ms-title-card, .kf-ms-question-card, .kf-ms-panel, .kf-ms-panel-dialog,
  .kf-ms-preview-dialog, .kf-ms-more-dialog, .kf-ms-collect-dialog,
  .kf-ms-branch-help-dialog, .kf-ms-draft-preview-card, .kf-ms-more-card
) {
  color: var(--kf-text) !important;
  background-color: var(--kf-surface) !important;
  background-image: none !important;
  border-color: var(--kf-border) !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-ms-panel-head, .kf-ms-section-editor, .kf-ms-section-preview,
  .kf-ms-toolbar, .kf-ms-toolbar-actions
) {
  color: var(--kf-text) !important;
  background-color: var(--kf-raised) !important;
  border-color: var(--kf-border) !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-canvas {
  color-scheme: light !important;
  color: #252b33 !important;
  background: #fff !important;
  border-color: #e2e5eb !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-canvas * {
  color-scheme: light !important;
}

.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-one-to-one {
  --kf-1on1-navy: #f1f3f6;
  --kf-1on1-indigo: #e5c66f;
  --kf-1on1-gold: #e5c66f;
  --kf-1on1-cream: #2c3037;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] {
  --kf-kiraly-cobalt: #e5c66f;
  --kf-kiraly-carbon: #f1f3f6;
  --kf-kiraly-gold: #e5c66f;
  --kf-editor-accent: #e5c66f;
  --kf-editor-text: #f1f3f6;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-ms-theme-preview, .kf-ms-preview-shell, #kf-draft-preview, .kf-ms-canvas
) {
  --kf-page-bg: #fff;
  --kf-surface: #fff;
  --kf-border: #e2e5eb;
  --kf-text: #252b33;
  --kf-muted: #697184;
  --kf-cobalt: #2f2f85;
  --kf-kiraly-cobalt: #2f2f85;
  --kf-kiraly-carbon: #1d1e18;
  --kf-editor-accent: #2f2f85;
  --kf-editor-text: #252a34;
  --kf-kiraly-gold: #d5b365;
  --kf-accent: #d5b365;
  --kf-accent-text: #1d1e18;
}
/* Additional authenticated-workspace surfaces and semantic states. */
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-alert, .kf-anon-note, .kf-group-picker, .kf-group-option,
  .kf-permission-recipe, .kf-danger-zone, .kf-progress, .kf-dist,
  .kf-ms-palette, .kf-ms-palette-section, .kf-ms-color-control,
  .kf-ms-color-field, .kf-ms-media-upload, .kf-ms-media-file,
  .kf-ms-branch-no-value, .kf-ms-branch-help-trigger,
  .kf-ms-branch-help-type, .kf-ms-branch-help-panel,
  .kf-ms-branch-help-empty, .kf-ms-branch-help-steps,
  .kf-ms-collect-card, .kf-ms-collect-actions,
  .kf-one-to-one, .kf-one-to-one-summary, .kf-one-to-one-detail,
  .kf-one-to-one-question, .kf-one-to-one-answer, .kf-one-to-one-review,
  .kf-one-to-one-alert, .kf-one-to-one-form, .kf-one-to-one-notifications,
  .kf-one-to-one-order, .kf-one-to-one-timeline, .kf-one-to-one-script-row,
  .kf-one-to-one-record-question, .kf-one-to-one-questions,
  .kf-one-to-one-table, .kf-schedule-table
) {
  color: var(--kf-text) !important;
  background-color: var(--kf-surface) !important;
  background-image: none !important;
  border-color: var(--kf-border) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-ms-branch-help-chip, .kf-ms-branch-help-intro,
  .kf-ms-branch-help-note, .kf-ms-branch-row, .kf-ms-option-edit-row,
  .kf-ms-ranking-edit-row, .kf-ranking li, .kf-group-option:hover,
  .kf-ms-menu-action:hover, .kf-ms-toolbar-btn:hover, .kf-ms-more-btn:hover,
  .kf-ms-question-tools button:hover, .kf-ms-add-question:hover,
  .kf-ms-add-col:hover, .kf-ms-rank-handle:hover, .kf-rank-drag:hover
) {
  color: var(--kf-text) !important;
  background-color: var(--kf-raised) !important;
  background-image: none !important;
  border-color: var(--kf-border) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-field-error, .kf-field-error input, .kf-form-feedback.is-error,
  .kf-inline-alert.is-error, .kf-one-to-one-alert.is-error
) {
  color: var(--kf-red) !important;
  background-color: #432a31 !important;
  border-color: #74414a !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-success-icon, .kf-status.is-open, .kf-one-to-one-status.is-complete,
  .kf-1on1-status.is-complete, .kf-ms-collect-status
) {
  color: #9be5c2 !important;
  background-color: #203c32 !important;
  border-color: #35614f !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-status.is-scheduled, .kf-status.is-draft, .kf-timer,
  .kf-ms-collect-status.is-pending, .kf-settings-badge-neutral
) {
  color: var(--kf-gold) !important;
  background-color: #3d3522 !important;
  border-color: #65552d !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-status.is-closed, .kf-status.is-archived
) {
  color: #c3cbd4 !important;
  background-color: #343941 !important;
  border-color: var(--kf-control-border) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-status.is-canceled {
  color: #ffb4b4 !important;
  background-color: #432a31 !important;
  border-color: #74414a !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-cancel-summary {
  background-color: var(--kf-raised) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(.kf-btn-ghost, .kf-link-button) {
  color: var(--kf-text) !important;
  background-color: transparent !important;
  border-color: var(--kf-border) !important;
}

.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-danger-zone {
  color: var(--kf-red) !important;
  background-color: #30252a !important;
  border-color: #74414a !important;
}

/* Style and response previews keep the exact authored form theme. */
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-ms-theme-preview, .kf-ms-preview-shell, #kf-draft-preview, .kf-ms-canvas
) {
  color-scheme: light !important;
  color: #252b33 !important;
  background: var(--preview-bg, #fff) !important;
  border-color: #e2e5eb !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-ms-theme-preview *, .kf-ms-preview-shell *, #kf-draft-preview *, .kf-ms-canvas *
) {
  color-scheme: light !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-theme-preview :is(
  .kf-ms-theme-card, .kf-ms-theme-answer, .kf-ms-preview-head
) {
  color: #252b33 !important;
  background: #fff !important;
  border-color: #e2e5eb !important;
}

/* Small surfaces and editor controls that use legacy light-color declarations. */
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-settings-default-note, .kf-settings-number-field, .kf-settings-group-picker,
  .kf-settings-group-option, .kf-readonly-value, .kf-stage-item,
  .kf-stage-arrow, .kf-ms-question-extra, .kf-ms-add-picker,
  .kf-ms-media-upload, .kf-ms-branch-row, .kf-ms-branch-no-value
) {
  color: var(--kf-text) !important;
  background-color: var(--kf-surface) !important;
  border-color: var(--kf-border) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-settings-group-option:hover, .kf-settings-group-option.is-selected,
  .kf-settings-group-option:has(input:checked), .kf-stage-item.is-current,
  .kf-ms-ellipsis:hover, .kf-ms-presentation-btn:hover, .kf-ms-toolbar-back:hover
) {
  color: #f3d98e !important;
  background-color: #3d3522 !important;
  border-color: #65552d !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-form-list-icon, .kf-empty-icon, .kf-template-icon, .kf-feature-icon,
  .kf-ms-collect-status-icon, .kf-pending-notice-icon
) {
  color: var(--kf-gold) !important;
  background-color: #3b3525 !important;
  border-color: #65552d !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-collect-status.is-pending .kf-ms-collect-status-icon {
  color: #e5c66f !important;
  background-color: #26384f !important;
  border-color: #3d5d80 !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-tabs :is(.kf-tab, a.kf-tab) {
  color: var(--kf-muted) !important;
  background-color: transparent !important;
  border-color: var(--kf-border) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-tabs :is(.kf-tab:hover, a.kf-tab:hover, .kf-tab.is-active, a.kf-tab.is-active) {
  color: #f3d98e !important;
  background-color: #2c3037 !important;
  border-color: var(--kf-gold) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-tools-divider {
  background-color: var(--kf-border) !important;
  border-color: var(--kf-border) !important;
}

.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] a:not(.button):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  color: var(--kf-link) !important;
}

/* Builder controls use graphite too; authored response previews remain light. */
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-ms-palette, .kf-ms-palette-section, .kf-ms-color-control,
  .kf-ms-color-field, .kf-ms-add-picker, .kf-ms-question-extra,
  .kf-ms-branch-no-value, .kf-ms-branch-help-trigger,
  .kf-ms-branch-help-type, .kf-ms-branch-help-empty,
  .kf-ms-branch-help-steps, .kf-ms-branch-help-note,
  .kf-ms-branch-help-chip, .kf-ms-branch-row,
  .kf-ms-collect-actions, .kf-ms-config-line,
  .kf-ms-option-list, .kf-ms-ranking-edit-row
):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  color: var(--kf-text) !important;
  background-color: var(--kf-surface) !important;
  background-image: none !important;
  border-color: var(--kf-border) !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-ms-qtitle, .kf-ms-section-title, .kf-ms-section-desc,
  .kf-ms-toolbar-label, .kf-ms-branch-help-kicker,
  .kf-ms-branch-help-note, .kf-ms-question-list,
  .kf-ms-option-edit-row, .kf-ms-ranking-edit-row,
  .kf-ms-nps-labels, .kf-ms-likert-col-head
):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  color: var(--kf-text) !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  button, .kf-ms-toolbar-btn, .kf-ms-more-btn, .kf-ms-menu-action,
  .kf-ms-add-question, .kf-ms-add-col, .kf-ms-ellipsis,
  .kf-ms-rank-handle, .kf-ms-question-tools button,
  .kf-ms-toolbar-back, .kf-ms-presentation-btn
):not(.kf-ms-collect-btn):not(.kf-ms-results-btn):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  color: #eef0f4 !important;
  background-color: #30343c !important;
  background-image: none !important;
  border-color: var(--kf-control-border) !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-ms-collect-btn
):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  color: var(--kf-gold-text) !important;
  background: var(--kf-gold) !important;
  border-color: var(--kf-gold) !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-ms-results-btn
):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  color: #c5d9ff !important;
  background: #26384f !important;
  border-color: #3d5d80 !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-switch span:not(.kf-ms-canvas *) {
  background-color: #424854 !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-switch input:checked + span:not(.kf-ms-canvas *) {
  background-color: var(--kf-gold) !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-collect-status-icon:not(.kf-ms-canvas *) {
  color: #9be5c2 !important;
  background-color: #203c32 !important;
  border-color: #35614f !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-collect-status.is-pending .kf-ms-collect-status-icon:not(.kf-ms-canvas *) {
  color: #e5c66f !important;
  background-color: #26384f !important;
  border-color: #3d5d80 !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-likert-editor :is(th, td):not(.kf-ms-canvas *) {
  color: var(--kf-text) !important;
  background-color: var(--kf-surface) !important;
  border-color: var(--kf-border) !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-likert-editor tbody tr:nth-child(odd) :is(th, td):not(.kf-ms-canvas *) {
  background-color: var(--kf-raised) !important;
}

/* Focus remains visible, and motion respects operating-system preferences. */
:is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :focus-visible {
  outline: 3px solid var(--kf-gold) !important;
  outline-offset: 2px;
}
:is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] {
  scrollbar-color: #69717c var(--kf-bg);
}
@media (prefers-reduced-motion: reduce) {
  :is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] *,
  :is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] *::before,
  :is(.kf-shell, .kf-ms-builder-page)[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}


/* 1:1 workflow and builder controls that still used paper-white component fills. */
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-dialog, dialog.kf-dialog, .kf-one-to-one-agreement,
  .kf-one-to-one-flow li, .kf-one-to-one-progress,
  .kf-one-to-one-history-comment, .kf-one-to-one-review-hint,
  .kf-employee-one-to-one-manager-entry,
  .kf-one-to-one-row-actions .kf-icon-btn, .kf-one-to-one-drag-handle,
  .kf-rank-controls button
) {
  color: var(--kf-text) !important;
  background-color: var(--kf-surface) !important;
  background-image: none !important;
  border-color: var(--kf-border) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-one-to-one-progress {
  background-color: var(--kf-raised) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-one-to-one-history-comment, .kf-one-to-one-review-hint,
  .kf-employee-one-to-one-manager-entry
) {
  background-color: var(--kf-raised) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-one-to-one-validation {
  color: var(--kf-red) !important;
  background-color: var(--kf-danger-soft) !important;
  border-color: var(--kf-danger-border) !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-one-to-one-flow li:is(.is-current, .is-active) {
  color: #f3d98e !important;
  background-color: #3d3522 !important;
  border-color: #65552d !important;
}
.kf-shell[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] dialog.kf-dialog::backdrop {
  background: rgba(7, 10, 15, .72) !important;
}

.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] :is(
  .kf-ms-picker, .kf-ms-picker .kf-ms-type-tile,
  .kf-ms-media-editor-preview, .kf-ms-upload-preview,
  .kf-ms-nps-scale span
):not(.kf-ms-canvas *):not(.kf-ms-theme-preview *):not(.kf-ms-preview-shell *) {
  color: var(--kf-text) !important;
  background-color: var(--kf-surface) !important;
  background-image: none !important;
  border-color: var(--kf-border) !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-nps-scale span:has(input:checked) {
  color: var(--kf-gold-text) !important;
  background-color: var(--kf-gold) !important;
  border-color: var(--kf-gold) !important;
}
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-media-editor-preview img,
.kf-ms-builder-page[data-dolibarr-theme-root][data-theme-module="kforms"][data-theme="dark"] .kf-ms-upload-preview img {
  color-scheme: light;
}

/* Portaled controls live under body, outside the module root. */
html[data-dolibarr-shell-theme="dark"][data-dolibarr-shell-module="kforms"] :is(
  .select2-dropdown, .select2-results, .ui-datepicker, .ui-widget-content,
  .flatpickr-calendar, .datepicker, .dropdown-menu
) {
  color: #f1f3f6 !important;
  background-color: #24272e !important;
  border-color: #424854 !important;
}
html[data-dolibarr-shell-theme="dark"][data-dolibarr-shell-module="kforms"] :is(
  .select2-results__option, .ui-menu-item, .ui-state-default,
  .flatpickr-day
) {
  color: #f1f3f6 !important;
  background-color: transparent !important;
  border-color: #424854 !important;
}
html[data-dolibarr-shell-theme="dark"][data-dolibarr-shell-module="kforms"] :is(
  .select2-results__option--highlighted, .ui-state-active,
  .flatpickr-day.selected, .flatpickr-day:hover
) {
  color: #211e14 !important;
  background-color: #e5c66f !important;
}
