/* Native checkboxes keep their labels, keyboard behavior and form values. */
body input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-content: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  margin: 0;
  padding: 0;
  vertical-align: middle;
  border: 1px solid #a2c1bb80;
  border-radius: 7px;
  background: linear-gradient(145deg, #284047c7, #071b22e6);
  box-shadow: inset 0 1px 0 #e2fff414, 0 2px 4px #0002;
  color: #052e2a;
  cursor: pointer;
  outline: none;
  transition: transform 140ms ease-out;
}

body input[type="checkbox"]::before {
  content: "";
  width: 13px;
  height: 13px;
  background: currentColor;
  clip-path: polygon(12% 42%, 39% 68%, 87% 14%, 100% 27%, 40% 94%, 0 55%);
  opacity: 0;
  transform: scale(.85);
  transition: opacity 120ms ease-out, transform 140ms ease-out;
}

body input[type="checkbox"]:checked,
body input[type="checkbox"]:indeterminate {
  border-color: #70e5d5;
  background: linear-gradient(145deg, #65dfcf, #22bcaf);
  box-shadow: inset 0 1px 0 #e2fff44d, 0 2px 7px #031a1740;
}

body input[type="checkbox"]:checked::before,
body input[type="checkbox"]:indeterminate::before {
  opacity: 1;
  transform: scale(1);
}

body input[type="checkbox"]:indeterminate::before {
  clip-path: inset(39% 4% round 1px);
}

body input[type="checkbox"]:focus { outline: none; }
body input[type="checkbox"]:focus-visible {
  outline: 2px solid #72e5d5;
  outline-offset: 3px;
  transition: none;
}
body input[type="checkbox"]:focus-visible::before { transition: none; }
body input[type="checkbox"]:active:not(:disabled):not(:focus-visible) { transform: scale(.94); }
body input[type="checkbox"]:disabled { opacity: .42; cursor: not-allowed; }
body input[type="checkbox"][aria-invalid="true"],
body .has-error input[type="checkbox"] { border-color: #f59578; }

body .check-filter,
body label:has(> input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
}
body label:has(> input[type="checkbox"]:disabled) { cursor: not-allowed; }

/* Django BooleanField renders its label before the control. */
body .field:has(> input[type="checkbox"]) {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
}
body .field:has(> input[type="checkbox"]) > label {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  min-height: 44px;
  margin: 0;
  cursor: pointer;
}
body .field > input[type="checkbox"] { grid-column: 1; grid-row: 1; }
body .field:has(> input[type="checkbox"]) > :is(.help-text, .field-error, small) { grid-column: 1 / -1; }

/* The design preview uses the same native control as the live app. */
body .task-check { flex: 0 0 44px; width: 44px; height: 44px; justify-content: center; }

@media (hover: hover) and (pointer: fine) {
  body input[type="checkbox"]:hover:not(:disabled),
  body label:hover > input[type="checkbox"]:not(:disabled) { border-color: #71dece; }
}

@media (forced-colors: active) {
  body input[type="checkbox"] {
    appearance: auto;
    -webkit-appearance: auto;
    background: none;
    box-shadow: none;
  }
  body input[type="checkbox"]::before { display: none; }
}
