.custom-control {
  position: relative;
  display: block;
  min-width: 0;
  flex: 1;
}

.control-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.control-trigger {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--separator);
  border-radius: 9px;
  color: var(--primary);
  background: var(--surface);
  text-align: left;
  font-size: 14px;
  line-height: 20px;
  box-shadow: 0 1px 2px #1823320a;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.control-trigger:hover { background: #f8f9fb; border-color: #c4c7d0; }
.custom-control.is-open .control-trigger,
.control-trigger:focus-visible { border-color: var(--separator); box-shadow: inset 0 0 0 1px #cfd3dc; background:#e9edf4; outline: 0; }
.control-trigger[aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 3px #c52e2617; }
.control-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.control-icon { width: 18px; height: 18px; flex: 0 0 18px; color: var(--secondary); }
.control-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.custom-control.is-open .control-icon-select { transform: rotate(180deg); }
.control-icon-select { transition: transform .15s ease; }

.form-row .custom-control .control-trigger {
  min-height: 44px;
  padding: 10px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 16px;
  line-height: 24px;
}
.form-row .custom-control .control-trigger:hover { background: transparent; }
.form-row .custom-control .control-trigger:focus-visible { outline:0; box-shadow:none; background:#e9edf4; border-radius:4px; }
.form-row .control-icon { margin-right: 1px; }

.control-popup {
  position: fixed;
  z-index: 10050;
  display: block;
  color: var(--primary);
  background: color-mix(in srgb, var(--surface) 96%, #e9eef7);
  border: 1px solid #d5d8e0;
  border-radius: 13px;
  box-shadow: 0 18px 50px #18233224, 0 3px 12px #18233212;
  overflow: auto;
  overscroll-behavior: contain;
  animation: control-popup-in .12s ease-out;
}
.control-popup[hidden] { display: none !important; }
@keyframes control-popup-in { from { opacity: 0; transform: translateY(-3px) scale(.99); } }

.select-popup { max-height: min(320px, calc(100dvh - 16px)); padding: 5px; }
.select-option {
  width: 100%;
  min-height: 38px;
  padding: 8px 34px 8px 11px;
  position: relative;
  display: block;
  border-radius: 8px;
  text-align: left;
  font-size: 14px;
  line-height: 20px;
}
.select-option:hover,
.select-option:focus-visible { background: #e8f1ff; outline: 0; }
.select-option[aria-selected="true"] { color: var(--accent); font-weight: 600; background: #edf4ff; }
.select-option[aria-selected="true"]::after { content: '✓'; position: absolute; right: 11px; top: 8px; }
.select-option:disabled { color: var(--tertiary); background: transparent; text-decoration: none; opacity: .58; }

.date-popup { padding: 10px; max-height:calc(100dvh - 16px); overflow-y:auto; }
.date-header { height: 36px; display: grid; grid-template-columns: 36px 1fr 36px; align-items: center; margin-bottom: 5px; }
.date-title { text-align: center; font-size: 14px; font-weight: 650; }
.date-nav { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--accent); }
.date-nav:hover,.date-nav:focus-visible { background: #e8f1ff; outline: 0; }
.date-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.date-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.date-weekday { height: 28px; display: grid; place-items: center; color: var(--secondary); font-size: 11px; font-weight: 650; }
.date-weekday:nth-of-type(6),.date-weekday:nth-of-type(7) { color: var(--red); }
.date-blank { height: 34px; }
.date-day { height: 34px; min-width: 0; display: grid; place-items: center; border-radius: 50%; font-size: 13px; font-variant-numeric: tabular-nums; }
.date-day:hover,.date-day:focus-visible { background: #e8f1ff; color: var(--accent); outline: 0; }
.date-day.is-today { color: var(--red); font-weight: 700; box-shadow: inset 0 0 0 1px #c52e2640; }
.date-day.is-selected,.date-day.is-selected:hover,.date-day.is-selected:focus-visible { color: white; background: var(--accent); font-weight: 700; box-shadow: none; }
.date-day:disabled { color: #afb1b8; background: transparent; opacity: .55; }

.control-validation {
  position: absolute;
  z-index: 10060;
  left: 0;
  top: calc(100% + 5px);
  max-width: min(280px, calc(100vw - 32px));
  padding: 7px 9px;
  border-radius: 7px;
  color: white;
  background: var(--red);
  box-shadow: 0 5px 16px #c52e2638;
  font-size: 12px;
  line-height: 1.3;
}

@media (max-width: 480px) {
  .control-popup { max-width: calc(100vw - 16px); }
  .date-popup { padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .control-popup { animation: none; }
  .control-icon-select { transition: none; }
}
