/* 表单控件独立配色，避免品牌主色在暗色主题变浅后淹没勾选标记。 */
:root {
  --acg-control-bg: #ffffff;
  --acg-control-border: #64748b;
  --acg-control-selected: #1d4ed8;
  --acg-control-mark: #ffffff;
  --acg-control-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round' d='M4 10l4 4 8-8'/%3E%3C/svg%3E");
  --acg-control-dot: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='4.5' fill='%23ffffff'/%3E%3C/svg%3E");
  --acg-control-dash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath stroke='%23ffffff' stroke-width='3' stroke-linecap='round' d='M5 10h10'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] {
  --acg-control-bg: #182230;
  --acg-control-border: #94a3b8;
  --acg-control-selected: #93c5fd;
  --acg-control-mark: #0f172a;
  --acg-control-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%230f172a' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round' d='M4 10l4 4 8-8'/%3E%3C/svg%3E");
  --acg-control-dot: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='4.5' fill='%230f172a'/%3E%3C/svg%3E");
  --acg-control-dash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath stroke='%230f172a' stroke-width='3' stroke-linecap='round' d='M5 10h10'/%3E%3C/svg%3E");
}

/* 保留原生 checked/disabled/键盘语义；不接管业务开关，也不强行显示 Layui 隐藏的原输入。 */
html:root body :is(input[type="checkbox"], input[type="radio"]):not([lay-skin="switch"]):not([role="switch"]):not(.form-switch input):not(.md-remote-product-picker__checkbox) {
  -webkit-appearance: none !important;
  appearance: none !important;
  box-sizing: border-box;
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
  padding: 0 !important;
  flex: 0 0 20px;
  vertical-align: middle;
  border: 2px solid var(--acg-control-border) !important;
  border-radius: 4px !important;
  background: var(--acg-control-bg) !important;
  background-position: center !important;
  background-size: 100% 100% !important;
  background-repeat: no-repeat !important;
  box-shadow: none !important;
  cursor: pointer;
}
html:root body :is(input[type="checkbox"], input[type="radio"]):not([lay-skin="switch"]):not([role="switch"]):not(.form-switch input):not(.md-remote-product-picker__checkbox):checked {
  border-color: var(--acg-control-selected) !important;
  background-color: var(--acg-control-selected) !important;
  background-image: var(--acg-control-check) !important;
}
html:root body input[type="radio"]:not([lay-skin="switch"]):not([role="switch"]):not(.form-switch input):not(.md-remote-product-picker__checkbox) {
  border-radius: 50% !important;
}
html:root body input[type="radio"]:not([lay-skin="switch"]):not([role="switch"]):not(.form-switch input):not(.md-remote-product-picker__checkbox):checked {
  background-image: var(--acg-control-dot) !important;
}
html:root body input[type="checkbox"]:not([lay-skin="switch"]):not([role="switch"]):not(.form-switch input):not(.md-remote-product-picker__checkbox):indeterminate {
  border-color: var(--acg-control-selected) !important;
  background-color: var(--acg-control-selected) !important;
  background-image: var(--acg-control-dash) !important;
}
html:root body :is(input[type="checkbox"], input[type="radio"]):not([lay-skin="switch"]):not([role="switch"]):not(.form-switch input):not(.md-remote-product-picker__checkbox)::after {
  content: none !important;
}
html:root body :is(input[type="checkbox"], input[type="radio"]):not([lay-skin="switch"]):not([role="switch"]):not(.form-switch input):not(.md-remote-product-picker__checkbox):focus-visible {
  outline: 3px solid var(--acg-control-selected) !important;
  outline-offset: 3px;
}
html:root body :is(input[type="checkbox"], input[type="radio"]):not([lay-skin="switch"]):not([role="switch"]):not(.form-switch input):not(.md-remote-product-picker__checkbox):disabled {
  cursor: not-allowed;
  opacity: .55;
}

/* Layui 的实际点击对象：图标用固定 SVG 绘制，避免字体未加载或浅色填充配白勾。 */
html:root body .layui-form-checkbox:not([lay-skin="tag"]):not([lay-skin="none"]) > i {
  box-sizing: border-box;
  width: 20px !important;
  height: 20px !important;
  border: 2px solid var(--acg-control-border) !important;
  border-radius: 4px !important;
  background: var(--acg-control-bg) center / 100% 100% no-repeat !important;
  color: transparent !important;
  font-size: 0 !important;
}
html:root body .layui-form-checkbox.layui-form-checked:not([lay-skin="tag"]):not([lay-skin="none"]) > i {
  border-color: var(--acg-control-selected) !important;
  background-color: var(--acg-control-selected) !important;
  background-image: var(--acg-control-check) !important;
}
html:root body .layui-form-checkbox:not([lay-skin="tag"]):not([lay-skin="none"]) > i.layui-icon-indeterminate {
  border-color: var(--acg-control-selected) !important;
  background-color: var(--acg-control-selected) !important;
  background-image: var(--acg-control-dash) !important;
}
html:root body .layui-form-checkbox:not([lay-skin="tag"]):not([lay-skin="none"]) > i.layui-icon-indeterminate::before {
  content: none !important;
}
html:root body .layui-form-checkbox.layui-form-checked:not([lay-skin="primary"]):not([lay-skin="tag"]):not([lay-skin="none"]) > :is(div, span) {
  background: var(--acg-control-selected) !important;
  color: var(--acg-control-mark) !important;
}
html:root body .layui-form-checkbox[lay-skin="tag"].layui-form-checked > :is(div, span) {
  border-color: var(--acg-control-selected) !important;
  background: var(--acg-control-selected) !important;
  color: var(--acg-control-mark) !important;
}
html:root body .layui-form-radio:not([lay-skin="none"]) > i {
  position: relative;
  display: inline-block;
  box-sizing: border-box;
  flex: 0 0 20px;
  width: 20px !important;
  height: 20px !important;
  border: 2px solid var(--acg-control-border) !important;
  border-radius: 50% !important;
  background: var(--acg-control-bg) !important;
  font-size: 0 !important;
}
html:root body .layui-form-radio:not([lay-skin="none"]) > i::after {
  content: "" !important;
  position: absolute;
  width: 10px;
  height: 10px;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  background: var(--acg-control-selected) !important;
  transform: translate(-50%, -50%) scale(0);
}
html:root body .layui-form-radio.layui-form-radioed:not([lay-skin="none"]) > i {
  border-color: var(--acg-control-selected) !important;
}
html:root body .layui-form-radio.layui-form-radioed:not([lay-skin="none"]) > i::after {
  transform: translate(-50%, -50%) scale(1);
}
html:root body .layui-form-radio[lay-skin="none"] > i {
  display: none !important;
}
html:root body :is(.layui-form-checkbox.layui-checkbox-disabled, .layui-form-radio.layui-radio-disabled, .layui-form-radio.layui-disabled) {
  opacity: .55;
  cursor: not-allowed;
}

/* 下拉单选、多选只接管默认图标，保留自定义图标及隐藏图标。 */
html:root body xm-select .xm-body .xm-option > .xm-option-icon:not(.xm-custom-icon):not(.xm-option-icon-hidden) {
  display: inline-block;
  box-sizing: border-box;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  vertical-align: middle;
  border-radius: 4px;
  border: 2px solid var(--acg-control-border) !important;
  background: var(--acg-control-bg) center / 100% 100% no-repeat !important;
  color: transparent !important;
  font-size: 0 !important;
}
html:root body xm-select .xm-body .xm-option > .xm-option-icon.xm-icon-danx:not(.xm-custom-icon):not(.xm-option-icon-hidden) {
  border-radius: 50%;
}
html:root body xm-select .xm-body .xm-option.selected > .xm-option-icon:not(.xm-custom-icon):not(.xm-option-icon-hidden) {
  border-color: var(--acg-control-selected) !important;
  background-color: var(--acg-control-selected) !important;
  background-image: var(--acg-control-check) !important;
}
html:root body xm-select .xm-body .xm-option.selected > .xm-option-icon.xm-icon-danx:not(.xm-custom-icon):not(.xm-option-icon-hidden) {
  background-image: var(--acg-control-dot) !important;
}
html:root body xm-select .xm-body .xm-option.disabled > .xm-option-icon {
  opacity: .55;
}

/* 验证码原图使用透明底和深色字；图像容器固定浅底，主题切换不改变原图颜色。 */
html:root body :is(img.image-code, img.prompt-image-code, img.captcha-img, img.order-query-captcha-image, img[src*="/user/captcha/image"]) {
  box-sizing: border-box;
  background: #ffffff !important;
  border: 2px solid #64748b !important;
  border-radius: 8px;
  padding: 4px;
  object-fit: contain;
  filter: none !important;
  mix-blend-mode: normal !important;
  opacity: 1 !important;
}

/* 后台登录验证码已有独立按钮边框，保留原图高度，避免重复边框和内边距缩小数字。 */
html:root body.lk #lk-captcha-img {
  padding: 0 !important;
  border: 0 !important;
}

@media (forced-colors: active) {
  html:root body :is(input[type="checkbox"], input[type="radio"]):not([lay-skin="switch"]):not([role="switch"]):not(.form-switch input):not(.md-remote-product-picker__checkbox) {
    -webkit-appearance: auto !important;
    appearance: auto !important;
  }
}
