/* Cabinet / Date picker. Figma 1538:410 and 1540:1680. */
.cab-date-popup {
    --date-border: #dfe5ee;
    --date-muted: #526078;
    --date-range: #eef7fb;
    --date-compare: #f6efe6;
    --date-error: #925300;
    position: fixed;
    width: min(800px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100dvh - 32px);
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--date-border);
    border-radius: 12px;
    background: var(--cab-card);
    color: var(--cab-text);
    font: 400 13px/20px var(--cab-font);
}
.cab-date-popup[open] { display: flex; flex-direction: column; }
/* Global reduced-motion rules set a nonzero duration on every element.
   Geometry must update immediately, including when comparison changes height. */
.cab-date-popup, .cab-date-popup * { transition-property: none; }
.cab-date-popup::backdrop { background: transparent; }
@media (prefers-reduced-motion: no-preference) {
    .cab-date-popup[open] { animation: cabDateOpen 180ms ease-out both; }
    .cab-date-popup[open].is-closing { animation: cabDateClose 140ms ease-in both; pointer-events: none; }
    .cab-date-popup[open]::backdrop { animation: cabDateBackdropOpen 180ms ease-out both; }
    .cab-date-popup[open].is-closing::backdrop { animation: cabDateBackdropClose 140ms ease-in both; }
    .cab-date-popup button, .cab-date-popup__input { transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease; }
    .cab-date-popup__period--compare:not([hidden]) { animation: cabDatePeriodOpen 160ms ease-out both; }
}
@keyframes cabDateOpen { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cabDateClose { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(6px); } }
@keyframes cabDateSheetOpen { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cabDateSheetClose { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(24px); } }
@keyframes cabDateBackdropOpen { from { opacity: 0; } to { opacity: 1; } }
@keyframes cabDateBackdropClose { from { opacity: 1; } to { opacity: 0; } }
@keyframes cabDatePeriodOpen { from { opacity: 0; } to { opacity: 1; } }
.cab-date-popup [hidden] { display: none !important; }
.cab-date-popup button { font: 500 13px/20px var(--cab-font); cursor: pointer; }
.cab-date-popup button:disabled { cursor: default; }
.cab-date-popup button:focus-visible, .cab-date-popup input:focus-visible { outline: 2px solid var(--cab-focus); outline-offset: 2px; }
.cab-date-popup p, .cab-date-popup h2 { margin: 0; }
.cab-date-popup strong { font-weight: 500; }
.cab-date-popup img { display: block; flex: 0 0 16px; }
.cab-date-popup__heading {
    display: flex; align-items: center; gap: 12px; flex: none;
    padding: 24px; border-bottom: 1px solid var(--date-border);
}
.cab-date-popup__heading > div { flex: 1; min-width: 0; }
.cab-date-popup__heading h2 { font: 500 20px/28px var(--cab-font); }
.cab-date-popup__heading p { margin-top: 4px; color: var(--date-muted); font-size: 12px; line-height: 18px; }
.cab-date-popup__scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.cab-date-popup__body { display: flex; align-items: flex-start; gap: 24px; padding: 24px; }
.cab-date-popup__presets { width: 144px; flex: 0 0 144px; }
.cab-date-popup__presets > span { display: block; margin-bottom: 4px; color: var(--date-muted); font-size: 12px; line-height: 18px; }
.cab-date-popup__preset-list { display: grid; gap: 4px; }
.cab-date-popup__preset-list button { min-height: 40px; padding: 8px 12px; border: 0; border-radius: 6px; background: transparent; color: inherit; text-align: left; }
.cab-date-popup__preset-list button:hover, .cab-date-popup__preset-list button.is-active { background: var(--date-range); }
.cab-date-popup__calendars { flex: 1; min-width: 0; }
.cab-date-popup__header { display: grid; grid-template-columns: 40px minmax(0,1fr) 24px minmax(0,1fr) 40px; align-items: center; margin-bottom: 8px; }
.cab-date-popup__header strong { text-align: center; }
.cab-date-popup__header strong:nth-of-type(2) { grid-column: 4; }
.cab-date-popup__nav { display: grid; width: 40px; height: 40px; padding: 0; place-items: center; flex: none; border: 0; border-radius: 6px; background: transparent; color: inherit; }
.cab-date-popup__nav:hover { background: var(--date-range); }
.cab-date-popup .cab-date-popup__editing { margin-bottom: 16px; color: var(--date-muted); font-size: 12px; line-height: 18px; }
.cab-date-popup__grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 24px; }
.cab-date-popup__weekdays { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); margin-bottom: 8px; text-align: center; color: var(--date-muted); font-size: 12px; line-height: 18px; }
.cab-calendar-month { display: grid; gap: 4px; }
.cab-calendar-week { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); }
.cab-calendar-day, .cab-calendar-empty { height: 40px; min-width: 0; }
.cab-calendar-day { padding: 0; border: 1px solid transparent; border-radius: 0; background: transparent; color: inherit; }
.cab-calendar-day:hover, .cab-calendar-day.is-preview { background: var(--date-range); }
.cab-calendar-day.is-today { border-color: var(--cab-text); border-radius: 6px; }
.cab-calendar-day.is-in-compare-range { background: var(--date-compare); }
.cab-calendar-day.is-compare-start, .cab-calendar-day.is-compare-end { background: var(--date-compare); border-color: var(--cab-text); border-radius: 6px; }
.cab-calendar-day.is-in-range { background: var(--date-range); }
.cab-calendar-day.is-start, .cab-calendar-day.is-end { border-radius: 6px; background: var(--cab-blue); color: white; }
.cab-calendar-day:focus-visible { position: relative; z-index: 1; outline-offset: -2px; border-radius: 6px; }
.cab-date-popup__periods { display: grid; gap: 16px; padding: 0 24px 24px; }
.cab-date-popup__period { display: grid; gap: 8px; min-width: 0; }
.cab-date-popup__period-title { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.cab-date-popup__period-title > span { color: var(--date-muted); font-size: 12px; line-height: 18px; }
.cab-date-popup__inputs { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.cab-date-popup__inputs label { display: grid; min-width: 0; gap: 4px; color: var(--date-muted); font-size: 12px; line-height: 18px; }
.cab-date-popup__input { display: flex; min-width: 0; height: 44px; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--date-border); border-radius: 6px; background: white; }
.cab-date-popup__input:focus-within { border-color: var(--cab-focus); box-shadow: inset 0 0 0 1px var(--cab-focus); }
.cab-date-popup__input:has([aria-invalid="true"]) { border-color: var(--date-error); }
.cab-date-popup__input input { min-width: 0; width: 100%; padding: 0; border: 0; outline: 0 !important; background: transparent; color: var(--cab-text); font: 400 13px/20px var(--cab-font); }
.cab-date-popup__input input::placeholder { color: var(--date-muted); }
.cab-date-popup__compare { display: flex; min-height: 32px; align-items: center; gap: 12px; padding-left: 7px; cursor: pointer; font-weight: 500; }
.cab-date-popup__compare input { appearance: none; width: 18px; height: 18px; margin: 0; flex: 0 0 18px; border: 1px solid #a0aec0; border-radius: 4px; background: white; }
.cab-date-popup__compare input:checked { border-color: var(--cab-blue); background: var(--cab-blue) url('../images/cabinet/date-picker/check.svg') center / 16px 16px no-repeat; }
.cab-date-popup__period--compare { padding: 12px; border-radius: 6px; background: var(--date-compare); }
.cab-date-popup .cab-date-popup__hint { color: var(--date-muted); font-size: 12px; line-height: 18px; }
.cab-date-popup .cab-date-popup__error { min-height: 18px; color: var(--date-error); font-size: 12px; line-height: 18px; }
/* Validation changes Apply's availability, never the dialog's geometry. */
.cab-date-popup .cab-date-popup__error[hidden] { display: block !important; visibility: hidden; }
.cab-date-popup__footer { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 24px; padding: 24px; border-top: 1px solid var(--date-border); }
.cab-date-popup__summary { display: grid; gap: 4px; min-width: 0; }
.cab-date-popup__summary span { color: var(--date-muted); font-size: 12px; line-height: 18px; }
.cab-date-popup__buttons { display: flex; flex: none; gap: 8px; }
.cab-date-popup__cancel, .cab-date-popup__apply { width: 144px; min-height: 44px; padding: 10px 16px; border: 1px solid var(--date-border); border-radius: 6px; background: white; color: inherit; }
.cab-date-popup__apply { border-color: var(--cab-blue); background: var(--cab-blue); color: white; }
.cab-date-popup__cancel:hover { background: var(--date-range); }
.cab-date-popup__apply:hover:not(:disabled) { background: var(--cab-blue-soft); }
.cab-date-popup__apply:disabled { border-color: transparent; background: #f5f6f9; color: #a0aec0; }
.cab-date-compare-badge { margin-left: 8px; color: var(--cab-muted); font-size: 11px; white-space: nowrap; }
.cab-date-compare-badge[hidden] { display: none; }
.cab-body.is-date-picker-open { overflow: hidden; }
@media (max-width: 767px) {
    .cab-date-popup { top: auto !important; right: 0; bottom: 0; left: 0 !important; width: 100%; max-height: calc(100dvh - 16px); border-radius: 12px 12px 0 0; }
    .cab-date-popup::backdrop { background: rgb(20 39 78 / .24); }
    .cab-date-popup__heading { padding: 16px; }
    .cab-date-popup__heading p { min-height: 36px; }
    .cab-date-popup .cab-date-popup__error { min-height: 36px; }
    .cab-date-popup__body { flex-direction: column; gap: 20px; padding: 16px; }
    .cab-date-popup__presets { flex: none; width: 100%; }
    .cab-date-popup__presets > span { display: none; }
    .cab-date-popup__preset-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .cab-date-popup__calendars { flex: none; width: 100%; }
    .cab-date-popup__header { grid-template-columns: 40px minmax(0,1fr) 40px; }
    .cab-date-popup__header strong:nth-of-type(2), .cab-date-popup__month:nth-child(2) { display: none; }
    .cab-date-popup__grid { grid-template-columns: minmax(0,1fr); }
    .cab-calendar-day, .cab-calendar-empty { height: 44px; }
    .cab-date-popup__periods { padding: 0 16px 16px; }
    .cab-date-popup__footer { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
    .cab-date-popup__summary { display: none; }
    .cab-date-popup__buttons { display: grid; width: 100%; grid-template-columns: repeat(2,minmax(0,1fr)); }
    .cab-date-popup__buttons button { width: 100%; }
    /* Prevent iOS zoom from displacing the fixed actions during manual entry. */
    .cab-date-popup__input input { font-size: 16px; }
}
@media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
    .cab-date-popup[open] { animation-name: cabDateSheetOpen; animation-duration: 220ms; }
    .cab-date-popup[open].is-closing { animation-name: cabDateSheetClose; animation-duration: 180ms; }
    .cab-date-popup[open]::backdrop { animation-duration: 220ms; }
    .cab-date-popup[open].is-closing::backdrop { animation-duration: 180ms; }
}
@media (prefers-reduced-motion: reduce) {
    .cab-date-popup, .cab-date-popup *, .cab-date-popup::backdrop { animation: none !important; transition: none !important; }
}
