/**
 * HRIS theme layer (loaded after every other stylesheet).
 *   1. Skeleton loaders (replace every spinner / "Loading…" text).
 *   2. Dark mode, driven by <html data-theme="dark"> (set by hris-theme.js).
 *   3. Company-theme hooks: data-radius, data-density, data-font.
 *   4. Theme toggle button + responsive polish.
 */

/* ───────────── 1. Skeleton loaders ───────────── */
:root { --sk-a: #e8ebf0; --sk-b: #f4f6f9; }
html[data-theme="dark"] { --sk-a: #232938; --sk-b: #2e3547; }

@keyframes hris-sk-shimmer { 0% { background-position: 120% 0; } 100% { background-position: -120% 0; } }
.hris-sk { display: block; width: 100%; min-width: 120px; max-width: 520px; }
.hris-sk > i, .hris-skb {
  display: block; height: 12px; border-radius: 6px; margin: 8px 0;
  background: linear-gradient(90deg, var(--sk-a) 25%, var(--sk-b) 37%, var(--sk-a) 63%);
  background-size: 300% 100%; animation: hris-sk-shimmer 1.4s ease-in-out infinite;
}
.hris-sk > i:nth-child(1) { width: 92%; }
.hris-sk > i:nth-child(2) { width: 74%; }
.hris-sk > i:nth-child(3) { width: 56%; }
.hris-sk > i:nth-child(4) { width: 82%; }
.hris-sk > i:nth-child(5) { width: 48%; }
td > .hris-sk, th > .hris-sk { margin: 2px 0; }

/* Ant Design spinners → skeleton. Hide the dots, draw skeleton bars instead. */
body .ant-spin-dot, body .ant-spin-text { opacity: 0 !important; }
body .ant-spin-spinning .ant-spin-dot-holder, body .ant-spin-dot-spin { display: none !important; }
body .ant-spin-container.ant-spin-blur, body .ant-spin-blur { opacity: .35 !important; filter: none !important; pointer-events: none !important; }
body .ant-spin-nested-loading:has(> div > .ant-spin-spinning),
body .ant-spin.ant-spin-spinning { position: relative; min-height: 180px; }
body .ant-spin-nested-loading > div > .ant-spin-spinning { background: transparent !important; }
body .ant-spin-nested-loading > div > .ant-spin-spinning::before,
body .ant-spin.ant-spin-spinning::before {
  content: ""; position: absolute; left: 16px; right: 16px; top: 24px; height: 14px; border-radius: 6px; z-index: 6;
  background: linear-gradient(90deg, var(--sk-a) 25%, var(--sk-b) 37%, var(--sk-a) 63%); background-size: 300% 100%;
  animation: hris-sk-shimmer 1.4s ease-in-out infinite;
  box-shadow: 0 30px 0 0 var(--sk-a), 0 60px 0 -22px var(--sk-a), 0 90px 0 -44px var(--sk-a), 0 120px 0 -66px var(--sk-a);
}
/* Loading icons inside buttons / selects / uploads → a small shimmering pill. */
body .anticon-loading svg { display: none !important; }
body .anticon-loading { display: inline-block; width: 14px; height: 10px; border-radius: 5px; vertical-align: middle;
  background: linear-gradient(90deg, currentColor 25%, transparent 37%, currentColor 63%); background-size: 300% 100%;
  opacity: .45; animation: hris-sk-shimmer 1.2s ease-in-out infinite; }
body .ant-btn-loading { position: relative; pointer-events: none; opacity: .8; }

/* Static loader helpers used by pages */
.hris-sk-card { padding: 16px; border: 1px solid var(--line, var(--hris-border, #e2e8f0)); border-radius: var(--hris-radius, 8px); background: var(--surface, var(--hris-surface, #fff)); }
.hris-sk-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.hris-sk-row .hris-skb { margin: 0; }
.hris-sk-avatar { width: 36px; height: 36px; border-radius: 50% !important; flex: none; }

/* Dashboard's refresh icon used a rotating spinner */
.icon-btn.spin svg { animation: hris-sk-pulse 1s ease-in-out infinite !important; }
@keyframes hris-sk-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

@media (prefers-reduced-motion: reduce) {
  .hris-sk > i, .hris-skb, body .ant-spin-nested-loading > div > .ant-spin-spinning::before,
  body .ant-spin.ant-spin-spinning::before, body .anticon-loading { animation: none; background: var(--sk-a); }
}

/* Boot skeleton (index.html) */
.hris-boot-skel { position: fixed; inset: 0; display: flex; background: var(--bg, #f6f7f9); }
.hris-boot-skel .bs-side { width: 240px; background: var(--theme-sidebar, #1c0c34); padding: 20px 16px; flex: none; }
.hris-boot-skel .bs-side .hris-skb { background: linear-gradient(90deg, rgba(255,255,255,.08) 25%, rgba(255,255,255,.16) 37%, rgba(255,255,255,.08) 63%); background-size: 300% 100%; height: 14px; margin: 18px 0; }
.hris-boot-skel .bs-main { flex: 1; min-width: 0; padding: 0; display: flex; flex-direction: column; }
.hris-boot-skel .bs-head { height: 56px; border-bottom: 1px solid var(--line, #e2e7ee); background: var(--surface, #fff); display: flex; align-items: center; padding: 0 20px; }
.hris-boot-skel .bs-body { padding: 20px; display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-content: start; }
.hris-boot-skel .hris-sk-card { height: 110px; }
.hris-boot-skel .bs-wide { grid-column: 1 / -1; height: 260px; }
@media (max-width: 768px) { .hris-boot-skel .bs-side { display: none; } }

/* ───────────── 2. Dark mode ───────────── */
html[data-theme="dark"] {
  color-scheme: dark;
  --dk-bg: #0f121a; --dk-surface: #171b26; --dk-raised: #1e2330; --dk-line: #2b3242; --dk-line-2: #3a4254;
  --dk-text: #e6e9f0; --dk-text-2: #c3cad6; --dk-muted: #9aa4b8;

  /* standalone pages (--bg/--surface/--text …) */
  --bg: var(--dk-bg); --surface: var(--dk-surface); --subtle: var(--dk-raised); --raised: var(--dk-raised);
  --text: var(--dk-text); --text-2: var(--dk-text-2); --muted: var(--dk-muted);
  --line: var(--dk-line); --line-strong: var(--dk-line-2); --soft-line: var(--dk-line);
  --ok: #4ade80; --ok-bg: rgba(74,222,128,.12); --warn: #fbbf24; --warn-bg: rgba(251,191,36,.12);
  --danger: #f87171; --danger-bg: rgba(248,113,113,.13); --info: #60a5fa; --info-bg: rgba(96,165,250,.13);
  --violet: #a78bfa; --violet-bg: rgba(167,139,250,.14);
  --panel: var(--dk-surface); --panel2: var(--dk-raised); --card: var(--dk-surface); --ink: var(--dk-text); --track: var(--dk-line);
  /* pages that name their palette differently */
  --ground: var(--dk-bg); --ink-2: var(--dk-text-2); --line-2: var(--dk-line);
  --shadow: 0 1px 2px rgba(0,0,0,.5); --shadow-pop: 0 12px 32px rgba(0,0,0,.6);

  /* SPA token families */
  --hris-bg: var(--dk-bg); --hris-surface: var(--dk-surface); --hris-surface-2: var(--dk-raised);
  --hris-border: var(--dk-line); --hris-border-strong: var(--dk-line-2);
  --hris-text: var(--dk-text); --hris-text-secondary: var(--dk-text-2); --hris-text-muted: var(--dk-muted);
  --hris-success: #4ade80; --hris-success-bg: rgba(74,222,128,.12);
  --hris-warning: #fbbf24; --hris-warning-bg: rgba(251,191,36,.12);
  --hris-danger: #f87171; --hris-danger-bg: rgba(248,113,113,.13);
  --hris-info: #60a5fa; --hris-info-bg: rgba(96,165,250,.13);
  --hris-shadow: 0 1px 2px rgba(0,0,0,.5);
  --d-bg: var(--dk-bg); --d-surface: var(--dk-surface); --d-subtle: var(--dk-raised);
  --d-text: var(--dk-text); --d-text-2: var(--dk-text-2); --d-muted: var(--dk-muted);
  --d-border: var(--dk-line); --d-border-strong: var(--dk-line-2);

  /* Pera neutral ramp, inverted */
  --p-n0: #171b26; --p-n1: #0f121a; --p-n2: #1e2330; --p-n3: #2b3242; --p-n4: #3a4254; --p-n5: #5d667a;
  --p-n6: #8892a6; --p-n7: #a5aebf; --p-n8: #c3cad6; --p-n9: #dde2ea; --p-n10: #eef1f6;
  --p-ok: #4ade80; --p-warn: #fbbf24; --p-bad: #f87171;
  --n0: #171b26; --n1: #0f121a; --n2: #1e2330; --n3: #2b3242; --n4: #3a4254; --n5: #5d667a;
  --n6: #8892a6; --n7: #a5aebf; --n8: #c3cad6; --n9: #dde2ea; --n10: #eef1f6;
  --bad: #f87171; --bad-bg: rgba(248,113,113,.13);
}

html[data-theme="dark"] body,
html[data-theme="dark"] #root { background: var(--dk-bg) !important; color: var(--dk-text) !important; }
html[data-theme="dark"] body ::selection { background: rgba(255,255,255,.22); color: #fff; }
html[data-theme="dark"] body * { scrollbar-color: var(--dk-line-2) transparent; }
html[data-theme="dark"] body ::-webkit-scrollbar-thumb { background: var(--dk-line-2); }

/* Text */
html[data-theme="dark"] body :is(h1,h2,h3,h4,h5,h6,.ant-typography,.ant-card-head-title,.ant-form-item-label > label,
  .ant-descriptions-item-label,.ant-descriptions-title,.ant-statistic-title,.ant-statistic-content,.ant-modal-title,
  .ant-drawer-title,.ant-breadcrumb,.ant-breadcrumb a,.ant-page-header-heading-title,.ant-list-item-meta-title,
  .ant-collapse-header,.ant-tabs-tab,.ant-steps-item-title,.ant-radio-wrapper,.ant-checkbox-wrapper) { color: var(--dk-text) !important; }
html[data-theme="dark"] body :is(.ant-typography-secondary,.ant-form-item-extra,.ant-empty-description,.ant-list-item-meta-description,
  .ant-steps-item-description,.ant-upload-hint,.ant-breadcrumb-separator,.ant-picker-suffix,.ant-select-arrow,.ant-input-suffix,
  .ant-table-column-sorter,.ant-card-meta-description,.ant-statistic-content-suffix) { color: var(--dk-muted) !important; }
html[data-theme="dark"] body a:not(.ant-btn):not([class*="ant-menu"]) { color: var(--primary, #8b7bd8); }
html[data-theme="dark"] body hr, html[data-theme="dark"] body .ant-divider { border-color: var(--dk-line) !important; }
html[data-theme="dark"] body .ant-divider-inner-text { color: var(--dk-muted) !important; }

/* Layout & surfaces */
html[data-theme="dark"] body :is(.ant-layout,.ant-layout-content) { background: var(--dk-bg) !important; }
html[data-theme="dark"] body :is(.ant-layout-header,.ant-layout-footer,.ant-page-header) { background: var(--dk-surface) !important; border-color: var(--dk-line) !important; color: var(--dk-text) !important; }
html[data-theme="dark"] body :is(.ant-card,.ant-card-head,.ant-card-body,.ant-modal-content,.ant-modal-header,.ant-modal-footer,
  .ant-drawer-content,.ant-drawer-header,.ant-drawer-footer,.ant-popover-inner,.ant-collapse,.ant-collapse-content,.ant-list,
  .ant-descriptions-view,.ant-tabs-card .ant-tabs-tab-active) { background: var(--dk-surface) !important; border-color: var(--dk-line) !important; color: var(--dk-text) !important; }
html[data-theme="dark"] body :is(.ant-collapse > .ant-collapse-item,.ant-list-item,.ant-card-head,.ant-modal-header,.ant-modal-footer,
  .ant-drawer-header,.ant-descriptions-row > th,.ant-descriptions-row > td,.ant-tabs-nav::before) { border-color: var(--dk-line) !important; }
html[data-theme="dark"] body :is(.ant-descriptions-item-label,.ant-descriptions-bordered .ant-descriptions-item-label,.ant-collapse > .ant-collapse-item > .ant-collapse-header) { background: var(--dk-raised) !important; }
html[data-theme="dark"] body .ant-modal-close, html[data-theme="dark"] body .ant-drawer-close { color: var(--dk-muted) !important; }
html[data-theme="dark"] body .ant-modal-mask, html[data-theme="dark"] body .ant-drawer-mask { background: rgba(0,0,0,.65) !important; }

/* Tables */
html[data-theme="dark"] body :is(.ant-table,.ant-table-container,.ant-table-tbody > tr > td,.ant-table-tbody > tr.ant-table-row > td,
  .ant-table-placeholder,.ant-table-placeholder:hover > td,.ant-table-summary td) { background: var(--dk-surface) !important; color: var(--dk-text) !important; border-color: var(--dk-line) !important; }
html[data-theme="dark"] body :is(.ant-table-thead > tr > th,.ant-table-thead > tr > th.ant-table-column-sort,.ant-table-cell-fix-left,.ant-table-cell-fix-right) { background: var(--dk-raised) !important; color: var(--dk-text-2) !important; border-color: var(--dk-line) !important; }
html[data-theme="dark"] body .ant-table-tbody > tr.ant-table-row:hover > td { background: var(--dk-raised) !important; }
html[data-theme="dark"] body :is(.ant-table-tbody > tr.ant-table-row-selected > td) { background: var(--soft, rgba(124,92,214,.18)) !important; }
html[data-theme="dark"] body .ant-table-tbody > tr.ant-table-expanded-row > td { background: var(--dk-raised) !important; }
html[data-theme="dark"] body .ant-table-column-has-sorters:hover { background: var(--dk-line) !important; }

/* Inputs */
html[data-theme="dark"] body :is(.ant-input,.ant-input-affix-wrapper,.ant-input-number,.ant-input-number-input,.ant-input-group-addon,
  .ant-select:not(.ant-select-customize-input) .ant-select-selector,.ant-picker,.ant-picker-input > input,.ant-mentions,.ant-cascader-picker) {
  background: var(--dk-raised) !important; color: var(--dk-text) !important; border-color: var(--dk-line-2) !important; }
html[data-theme="dark"] body :is(.ant-input-affix-wrapper > input.ant-input,.ant-input-number-handler-wrap,.ant-select-selection-item,.ant-select-selection-search-input) { background: transparent !important; color: var(--dk-text) !important; }
html[data-theme="dark"] body :is(.ant-input-disabled,.ant-input[disabled],.ant-select-disabled .ant-select-selector,.ant-picker-disabled,.ant-input-number-disabled) { background: var(--dk-bg) !important; color: var(--dk-muted) !important; }
html[data-theme="dark"] body ::placeholder, html[data-theme="dark"] body .ant-select-selection-placeholder { color: #6f7a90 !important; opacity: 1; }
html[data-theme="dark"] body :is(.ant-radio-inner,.ant-checkbox-inner) { background: var(--dk-raised) !important; border-color: var(--dk-line-2) !important; }
html[data-theme="dark"] body :is(.ant-radio-checked .ant-radio-inner,.ant-checkbox-checked .ant-checkbox-inner) { background: var(--primary) !important; border-color: var(--primary) !important; }
html[data-theme="dark"] body .ant-switch:not(.ant-switch-checked) { background: var(--dk-line-2) !important; }

/* Buttons (default style only: primary/danger keep their own colors) */
html[data-theme="dark"] body :is(.ant-btn-default,.ant-btn-dashed):not(.ant-btn-primary):not(.ant-btn-dangerous) { background: var(--dk-raised) !important; color: var(--dk-text) !important; border-color: var(--dk-line-2) !important; }
html[data-theme="dark"] body :is(.ant-btn-default,.ant-btn-dashed):not(.ant-btn-primary):not(.ant-btn-dangerous):hover { border-color: var(--primary) !important; color: var(--primary) !important; }
html[data-theme="dark"] body .ant-btn-text, html[data-theme="dark"] body .ant-btn-link:not(.ant-btn-dangerous) { color: var(--dk-text-2); }
html[data-theme="dark"] body .ant-btn[disabled], html[data-theme="dark"] body .ant-btn-disabled { background: var(--dk-bg) !important; color: #5d667a !important; border-color: var(--dk-line) !important; }

/* Dropdowns, popups, menus (non-sidebar) */
html[data-theme="dark"] body :is(.ant-select-dropdown,.ant-dropdown-menu,.ant-picker-panel-container,.ant-picker-panel,.ant-cascader-menus,
  .ant-popover-inner,.ant-notification-notice,.ant-message-notice-content) { background: var(--dk-raised) !important; color: var(--dk-text) !important; border-color: var(--dk-line-2) !important; box-shadow: 0 8px 28px rgba(0,0,0,.55) !important; }
html[data-theme="dark"] body :is(.ant-select-item,.ant-dropdown-menu-item,.ant-picker-cell,.ant-picker-header,.ant-picker-header button,.ant-picker-content th) { color: var(--dk-text) !important; }
html[data-theme="dark"] body :is(.ant-picker-cell-in-view.ant-picker-cell-selected .ant-picker-cell-inner,.ant-picker-cell-today .ant-picker-cell-inner::before) { background: var(--primary) !important; color: #fff !important; }
html[data-theme="dark"] body :is(.ant-select-item-option-active:not(.ant-select-item-option-disabled),.ant-dropdown-menu-item:hover) { background: var(--dk-line) !important; }
html[data-theme="dark"] body .ant-select-item-option-selected:not(.ant-select-item-option-disabled) { background: var(--soft, var(--dk-line)) !important; color: var(--dk-text) !important; }
html[data-theme="dark"] body .ant-picker-cell:hover:not(.ant-picker-cell-in-view) .ant-picker-cell-inner { background: var(--dk-line) !important; }
html[data-theme="dark"] body .ant-picker-cell:hover:not(.ant-picker-cell-selected):not(.ant-picker-cell-range-start):not(.ant-picker-cell-range-end) .ant-picker-cell-inner { background: var(--dk-line) !important; }
html[data-theme="dark"] body .ant-picker-cell:not(.ant-picker-cell-in-view) { color: #5d667a !important; }
html[data-theme="dark"] body .ant-menu:not(.ant-menu-dark) { background: var(--dk-surface) !important; color: var(--dk-text) !important; border-color: var(--dk-line) !important; }
html[data-theme="dark"] body .ant-menu-submenu-popup .ant-menu { background: var(--dk-raised) !important; }
html[data-theme="dark"] body :is(.ant-tabs-nav .ant-tabs-tab-btn,.ant-tabs-tab) { color: var(--dk-muted) !important; }
html[data-theme="dark"] body :is(.ant-tabs-tab-active .ant-tabs-tab-btn,.ant-tabs-tab:hover) { color: var(--primary) !important; }
html[data-theme="dark"] body .ant-tabs-card .ant-tabs-tab { background: var(--dk-raised) !important; border-color: var(--dk-line) !important; }

/* Pagination */
html[data-theme="dark"] body :is(.ant-pagination-item,.ant-pagination-prev .ant-pagination-item-link,.ant-pagination-next .ant-pagination-item-link,.ant-pagination-options .ant-select-selector) { background: var(--dk-raised) !important; border-color: var(--dk-line-2) !important; }
html[data-theme="dark"] body :is(.ant-pagination-item a,.ant-pagination-total-text,.ant-pagination-item-link) { color: var(--dk-text) !important; }
html[data-theme="dark"] body .ant-pagination-item-active { border-color: var(--primary) !important; }
html[data-theme="dark"] body .ant-pagination-item-active a { color: var(--primary) !important; }

/* Tags, alerts, empties, badges, tooltips */
html[data-theme="dark"] body .ant-tag:not([class*="ant-tag-"]):not(.ant-tag-has-color) { background: var(--dk-raised) !important; border-color: var(--dk-line-2) !important; color: var(--dk-text-2) !important; }
html[data-theme="dark"] body :is(.ant-tag-red,.ant-tag-error) { background: rgba(248,113,113,.14) !important; border-color: rgba(248,113,113,.4) !important; color: #fca5a5 !important; }
html[data-theme="dark"] body :is(.ant-tag-orange,.ant-tag-gold,.ant-tag-warning,.ant-tag-yellow) { background: rgba(251,191,36,.14) !important; border-color: rgba(251,191,36,.4) !important; color: #fcd34d !important; }
html[data-theme="dark"] body :is(.ant-tag-green,.ant-tag-success,.ant-tag-cyan) { background: rgba(74,222,128,.13) !important; border-color: rgba(74,222,128,.4) !important; color: #86efac !important; }
html[data-theme="dark"] body :is(.ant-tag-blue,.ant-tag-processing,.ant-tag-geekblue) { background: rgba(96,165,250,.14) !important; border-color: rgba(96,165,250,.4) !important; color: #93c5fd !important; }
html[data-theme="dark"] body :is(.ant-tag-purple,.ant-tag-magenta,.ant-tag-volcano) { background: rgba(167,139,250,.15) !important; border-color: rgba(167,139,250,.4) !important; color: #c4b5fd !important; }
html[data-theme="dark"] body .ant-alert { background: var(--dk-raised) !important; border-color: var(--dk-line-2) !important; }
html[data-theme="dark"] body .ant-alert :is(.ant-alert-message,.ant-alert-description) { color: var(--dk-text) !important; }
html[data-theme="dark"] body .ant-empty-img-simple-ellipse, html[data-theme="dark"] body .ant-empty-img-default-ellipse { fill-opacity: .08 !important; }
html[data-theme="dark"] body .ant-skeleton :is(.ant-skeleton-title,.ant-skeleton-paragraph > li,.ant-skeleton-avatar,.ant-skeleton-button,.ant-skeleton-input) { background: linear-gradient(90deg, var(--sk-a) 25%, var(--sk-b) 37%, var(--sk-a) 63%) !important; background-size: 300% 100% !important; }
html[data-theme="dark"] body .ant-tooltip-inner { background: #2b3242 !important; color: #fff !important; }
html[data-theme="dark"] body .ant-tooltip-arrow-content, html[data-theme="dark"] body .ant-tooltip-arrow::before { background: #2b3242 !important; }
html[data-theme="dark"] body .ant-progress-text { color: var(--dk-text) !important; }
html[data-theme="dark"] body .ant-progress-bg { background: var(--primary) !important; }
html[data-theme="dark"] body .ant-progress-inner { background: var(--dk-line) !important; }
html[data-theme="dark"] body .ant-steps-item-wait .ant-steps-item-icon { background: var(--dk-raised) !important; border-color: var(--dk-line-2) !important; }
html[data-theme="dark"] body .ant-upload.ant-upload-drag { background: var(--dk-raised) !important; border-color: var(--dk-line-2) !important; }

/* React inline-styled white boxes / black text */
html[data-theme="dark"] body :is([style*="background: rgb(255, 255, 255)"],[style*="background:#fff"],[style*="background: #fff"],[style*="background-color: rgb(255, 255, 255)"],[style*="background:white"],[style*="background: white"],[style*="background-color:#fff"],[style*="background-color: #fff"]) { background: var(--dk-surface) !important; }
html[data-theme="dark"] body :is([style*="background: rgb(250, 250, 250)"],[style*="background: rgb(245, 245, 245)"],[style*="background: rgb(248, 250, 252)"],[style*="background: #fafafa"],[style*="background:#fafafa"],[style*="background: #f5f5f5"],[style*="background-color: rgb(250, 250, 250)"],[style*="background-color: rgb(245, 245, 245)"]) { background: var(--dk-raised) !important; }
html[data-theme="dark"] body :is([style*="color: rgb(0, 0, 0)"],[style*="color: rgba(0, 0, 0"],[style*="color:#000"],[style*="color: #000"],[style*="color: rgb(31, 41, 55)"],[style*="color: rgb(17, 24, 39)"],[style*="color: rgb(15, 23, 42)"]) { color: var(--dk-text) !important; }
html[data-theme="dark"] body :is([style*="border: 1px solid rgb(240, 240, 240)"],[style*="border: 1px solid rgb(217, 217, 217)"],[style*="border-bottom: 1px solid rgb(240, 240, 240)"],[style*="border: 1px solid #f0f0f0"]) { border-color: var(--dk-line) !important; }

/* Floating helpers added by shell scripts */
html[data-theme="dark"] body :is(#hris-guide-panel,#hris-guide-tip,#hqs .box,#hris-locmap .lm-box,.hris-modal,.hris-modal-box,#hris-notif-panel,#hris-toasts > *:not(.err):not(.error)) { background: var(--dk-surface) !important; color: var(--dk-text) !important; }
html[data-theme="dark"] body :is(#hqs .ft,#hqs kbd,#hqs li.it .ic,.hg-go,.hg-btn.ghost,.hg-period select,.hg-period input,.hg-wf > button:hover,.hg-x:hover) { background: var(--dk-raised) !important; color: var(--dk-text-2) !important; border-color: var(--dk-line-2) !important; }
html[data-theme="dark"] body :is(#hqs input,#hqs li.it,.hris-modal input,.hris-modal select,.hris-modal textarea) { background: transparent; color: var(--dk-text) !important; }
html[data-theme="dark"] body #hqs li.it.on { background: var(--dk-line) !important; }
html[data-theme="dark"] body :is(#hris-guide-panel *,#hqs *,.hris-modal *) { border-color: var(--dk-line); }
html[data-theme="dark"] body #hris-guide-panel :is(h1,h2,h3,p,li,span,div,label) { color: inherit; }

/* App shell pieces that hard-code light colours */
html[data-theme="dark"] body #hris-legal-footer { background: var(--dk-surface) !important; color: var(--dk-muted) !important; border-color: var(--dk-line) !important; }
html[data-theme="dark"] body #hris-legal-footer a { color: var(--primary) !important; }
html[data-theme="dark"] body :is(#hqs-btn,#hqs-btn kbd) { background: var(--dk-raised) !important; border-color: var(--dk-line-2) !important; color: var(--dk-text-2) !important; }
html[data-theme="dark"] body .ant-layout-header :is(button,.anticon,svg,.ant-badge) { color: var(--dk-text-2); }
html[data-theme="dark"] body .ant-layout-header .ant-avatar { background: var(--primary); }
html[data-theme="dark"] body #hris-cookie-banner { background: #0b0e15 !important; }

/* Native elements on standalone pages */
html[data-theme="dark"] :is(input,select,textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]) {
  background-color: var(--dk-raised); color: var(--dk-text); border-color: var(--dk-line-2); }
html[data-theme="dark"] option, html[data-theme="dark"] optgroup { background: var(--dk-raised); color: var(--dk-text); }
html[data-theme="dark"] :is(table,th,td) { border-color: var(--dk-line); }
html[data-theme="dark"] :is(.card,.panel,.box,.modal,.dialog,section.card,.tile,.stat,.kpi,.drawer,.sheet,.popover,.menu) { background-color: var(--surface); color: var(--text); border-color: var(--line); }
html[data-theme="dark"] :is(th) { background-color: var(--dk-raised); color: var(--dk-text-2); }
html[data-theme="dark"] :is(code,pre,kbd) { background-color: var(--dk-raised); color: var(--dk-text); border-color: var(--dk-line-2); }
html[data-theme="dark"] img:not([src*="logo"]):not([src*="avatar"]):not(.keep) { filter: brightness(.92); }
html[data-theme="dark"] .skel, html[data-theme="dark"] [class*="skel"]:not(.hris-sk):not(.hris-skb) { --sk-a: #232938; --sk-b: #2e3547; }

/* ───────────── 3. Company-theme hooks ───────────── */
html[data-radius] body :is(.ant-btn,.ant-input,.ant-input-affix-wrapper,.ant-input-number,.ant-select-selector,.ant-picker,.ant-tag,.ant-alert,.ant-dropdown-menu,.ant-select-dropdown) { border-radius: var(--hris-radius) !important; }
html[data-radius] body :is(.ant-card,.ant-modal-content,.ant-drawer-content,.ant-popover-inner,.ant-table-container,.ant-collapse) { border-radius: var(--hris-radius-lg) !important; }
html[data-radius] :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea,button:not(.ant-btn)) { border-radius: var(--hris-radius); }
html[data-radius] :is(.card,.panel,.box,.modal,.dialog) { border-radius: var(--hris-radius-lg); }
html[data-radius="pill"] body .ant-btn:not(.ant-btn-icon-only) { border-radius: 999px !important; }

html[data-density="comfortable"] body :is(.ant-table-tbody > tr > td,.ant-table-thead > tr > th) { padding-top: 14px !important; padding-bottom: 14px !important; }
html[data-density="comfortable"] body :is(.ant-btn,.ant-input,.ant-input-affix-wrapper,.ant-picker,.ant-select:not(.ant-select-customize-input) .ant-select-selector) { min-height: 38px !important; }
html[data-density="comfortable"] body :is(.ant-card-body,.ant-modal-body) { padding: 22px !important; }
html[data-density="comfortable"] :is(td,th) { padding-top: 12px; padding-bottom: 12px; }

html[data-font="system"] :is(body,button,input,select,textarea,.ant-layout,.ant-btn,.ant-table,.ant-menu,.ant-input,.ant-select,.ant-typography),
html[data-font="serif"] :is(body,button,input,select,textarea,.ant-layout,.ant-btn,.ant-table,.ant-menu,.ant-input,.ant-select,.ant-typography) { font-family: var(--hris-font) !important; }

/* Company primary also drives default Ant primary buttons / links */
html[data-company-theme] body .ant-btn-primary:not(.ant-btn-dangerous) { background: var(--primary) !important; border-color: var(--primary) !important; }
html[data-company-theme] body .ant-btn-primary:not(.ant-btn-dangerous):hover { background: var(--primary-hover) !important; border-color: var(--primary-hover) !important; }
html[data-company-theme] body .ant-layout-sider { background: var(--theme-sidebar) !important; }

/* ───────────── 4. Toggle button & responsive ───────────── */
#hris-theme-toggle {
  position: fixed; right: 20px; bottom: 16px; z-index: 1150; width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
  background: var(--surface, #fff); color: var(--text, #141a24); border: 1px solid var(--line, #cfd6e0);
  box-shadow: 0 2px 8px rgba(15,23,42,.18); transition: transform .15s ease, background .15s ease;
}
#hris-theme-toggle:hover { transform: scale(1.06); }
/* Sit above the cookie banner (about 64px tall) until it is dismissed. */
body:has(#hris-cookie-banner) #hris-theme-toggle { bottom: 80px; }
#hris-theme-toggle:focus-visible { outline: 2px solid var(--primary, #4b2a86); outline-offset: 2px; }
html[data-theme="dark"] #hris-theme-toggle { background: var(--dk-raised); color: var(--dk-text); border-color: var(--dk-line-2); box-shadow: 0 2px 10px rgba(0,0,0,.6); }
@media (max-width: 600px) { #hris-theme-toggle { right: 12px; bottom: 12px; width: 40px; height: 40px; } }
html.embed #hris-theme-toggle, body:has(.ant-modal-wrap .ant-modal) #hris-theme-toggle { display: none !important; }
@media print { #hris-theme-toggle { display: none !important; } }

/* Responsive polish for the shell */
img, video, canvas { max-width: 100%; }
@media (max-width: 768px) {
  body .ant-table-wrapper, body .ant-table-container { overflow-x: auto; }
  body .ant-modal { max-width: calc(100vw - 16px) !important; margin: 8px auto !important; }
  body .ant-drawer-content-wrapper { max-width: 100vw; }
  body .ant-layout-content { padding-left: 12px !important; padding-right: 12px !important; }
  body .ant-form-item-label { text-align: left; }
  body .ant-picker, body .ant-select, body .ant-input-number { max-width: 100%; }
}
