/* ========================================================================== 
   ALPHA DESIGN ERP Cloud v4.8.0 — GLOBAL DARK MODE PARITY HARDENING (Phase 6)
   Loaded last. Presentation-only compatibility layer.
   Purpose:
   - eliminate legacy light fallbacks in dark mode;
   - consume canonical aliases from alpha-ui-foundation.css;
   - normalize controls, data surfaces, status surfaces and generated panels;
   - preserve all backend/API/RBAC/accounting/workflow behavior.
   ========================================================================== */

/* ---------- Canonical surfaces ---------- */
html[data-theme="dark"] .template-current,
html[data-theme="dark"] .settings-link-note,
html[data-theme="dark"] .role-access-card,
html[data-theme="dark"] .statutory-report-card,
html[data-theme="dark"] .statutory-screen-summary,
html[data-theme="dark"] .adaptive-ux-pins,
html[data-theme="dark"] .adaptive-ux-pin,
html[data-theme="dark"] .table-scroll-top,
html[data-theme="dark"] .annual-benefit-toolbar select,
html[data-theme="dark"] .annual-benefit-table tfoot td,
html[data-theme="dark"] .active-filter-note,
html[data-theme="dark"] .chart-unit-badge{
  background:var(--surface-2)!important;
  border-color:var(--line)!important;
  color:var(--text)!important;
}

html[data-theme="dark"] .template-current strong,
html[data-theme="dark"] .role-access-card strong,
html[data-theme="dark"] .statutory-report-card strong,
html[data-theme="dark"] .statutory-screen-summary strong,
html[data-theme="dark"] .adaptive-ux-pin strong{
  color:var(--text)!important;
}
html[data-theme="dark"] .template-current span,
html[data-theme="dark"] .template-current small,
html[data-theme="dark"] .settings-link-note,
html[data-theme="dark"] .statutory-screen-summary small,
html[data-theme="dark"] .chart-unit-badge{
  color:var(--muted)!important;
}

html[data-theme="dark"] .annual-benefit-hero{
  background:linear-gradient(135deg,var(--surface),var(--surface-2))!important;
  border-color:var(--line)!important;
  color:var(--text)!important;
}

/* Suite introductions used literal white gradients in a legacy layer. */
html[data-theme="dark"] .suite-hr-screen .suite-screen-intro,
html[data-theme="dark"] .suite-finance-screen .suite-screen-intro,
html[data-theme="dark"] .suite-settings-screen .suite-screen-intro,
html[data-theme="dark"] .suite-system-screen .suite-screen-intro{
  background:linear-gradient(135deg,#11232d,#122733)!important;
  border-color:#2c4553!important;
  color:var(--text)!important;
}

/* ---------- Forms / browser-native controls ---------- */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] button{
  accent-color:var(--primary);
}
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea{
  color-scheme:dark;
}
html[data-theme="dark"] select option,
html[data-theme="dark"] select optgroup{
  background:#0d1d26;
  color:#e4edf1;
}
html[data-theme="dark"] input[type="file"]{
  color:var(--muted)!important;
}
html[data-theme="dark"] input[type="file"]::file-selector-button{
  background:#132630;
  color:#dce7ed;
  border:1px solid #334d5b;
  border-radius:8px;
  padding:7px 10px;
  margin-right:10px;
}
html[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="month"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator{
  filter:invert(.86) saturate(.55);
  opacity:.88;
}
html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus,
html[data-theme="dark"] textarea:-webkit-autofill,
html[data-theme="dark"] select:-webkit-autofill{
  -webkit-text-fill-color:#e4edf1!important;
  caret-color:#e4edf1!important;
  -webkit-box-shadow:0 0 0 1000px #0d1d26 inset!important;
  box-shadow:0 0 0 1000px #0d1d26 inset!important;
  border-color:#2f4754!important;
}
html[data-theme="dark"] input:disabled,
html[data-theme="dark"] select:disabled,
html[data-theme="dark"] textarea:disabled,
html[data-theme="dark"] button:disabled{
  opacity:.72;
}

/* ---------- Status and exception surfaces ---------- */
html[data-theme="dark"] .sync-pill.sync-pending,
html[data-theme="dark"] .tax-calendar-countdown.is-due-soon,
html[data-theme="dark"] .suite-finance-screen .finance-forecast-label,
html[data-theme="dark"] .action-prompt-backdrop[data-tone="warning"] .action-prompt-icon{
  background:#3a321b!important;
  border-color:#67582b!important;
  color:#f4d78c!important;
}
html[data-theme="dark"] .sync-pill.sync-error,
html[data-theme="dark"] .tax-calendar-countdown.is-overdue,
html[data-theme="dark"] .tax-bridge .tax-diff,
html[data-theme="dark"] .journal-total-balance.is-unbalanced,
html[data-theme="dark"] .integrity-row.fail .integrity-icon,
html[data-theme="dark"] .icon-btn.danger,
html[data-theme="dark"] .business-suite-screen .icon-btn.danger,
html[data-theme="dark"] .action-prompt-backdrop[data-tone="danger"] .action-prompt-icon{
  background:#3b2028!important;
  border-color:#6b3946!important;
  color:#ffafb9!important;
}
html[data-theme="dark"] .icon-btn.danger:hover,
html[data-theme="dark"] .business-suite-screen .icon-btn.danger:hover{
  background:#4a2630!important;
  border-color:#80505b!important;
  color:#ffd0d6!important;
}
html[data-theme="dark"] .sync-pill.sync-offline{
  background:#182733!important;
  border-color:#344c5a!important;
  color:#b7c7d0!important;
}

/* ---------- Drawers, dialogs, previews, uploads, empty states ---------- */
html[data-theme="dark"] .export-preview,
html[data-theme="dark"] .import-box,
html[data-theme="dark"] .upload-drop,
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .zero-state,
html[data-theme="dark"] .preview-panel,
html[data-theme="dark"] .preview-card{
  background:var(--surface-2)!important;
  border-color:var(--line)!important;
  color:var(--text)!important;
}
html[data-theme="dark"] .empty-state p,
html[data-theme="dark"] .zero-state p,
html[data-theme="dark"] .preview-panel small,
html[data-theme="dark"] .preview-card small{
  color:var(--muted)!important;
}

/* ---------- Table edge cases ---------- */
html[data-theme="dark"] .table-wrap:not(.staff-cost-table) th:first-child,
html[data-theme="dark"] .annual-benefit-table tfoot td{
  background:var(--table-head)!important;
  color:#a9c1ce!important;
}
html[data-theme="dark"] tr.record-edit-locked td{
  background:color-mix(in srgb,#f3c66b 7%,var(--surface))!important;
}
html[data-theme="dark"] .record-edit-lock-indicator{
  background:color-mix(in srgb,#f3c66b 12%,var(--surface))!important;
  border-color:#67582b!important;
  color:#f4d78c!important;
}

/* ---------- Accessibility / system surfaces ---------- */
html[data-theme="dark"] code,
html[data-theme="dark"] pre,
html[data-theme="dark"] kbd:not(.global-search-wrap kbd){
  background:#0b1b24;
  border-color:#2b424e;
  color:#d9e6ed;
}
html[data-theme="dark"] ::-webkit-scrollbar{width:11px;height:11px}
html[data-theme="dark"] ::-webkit-scrollbar-track{background:#0a1820}
html[data-theme="dark"] ::-webkit-scrollbar-thumb{background:#384f5c;border:3px solid #0a1820;border-radius:999px}
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover{background:#486575}

/* Explicit contrast fixes for the settings cards shown in the reported bug. */
html[data-theme="dark"] .settings-secondary-grid .template-current{
  background:#122630!important;
  border-color:#334d5b!important;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.025);
}
html[data-theme="dark"] .settings-secondary-grid .template-current>span{
  color:#a1b3bc!important;
}
html[data-theme="dark"] .settings-secondary-grid .template-current>strong{
  color:#f1f6f9!important;
}
html[data-theme="dark"] .settings-secondary-grid .template-current>small{
  color:#aebfc8!important;
}

@media (forced-colors:active){
  html[data-theme="dark"] .template-current,
  html[data-theme="dark"] .role-access-card,
  html[data-theme="dark"] .statutory-report-card,
  html[data-theme="dark"] .adaptive-ux-pin{
    forced-color-adjust:auto;
    border:1px solid CanvasText!important;
  }
}
