.thai-date-field {
    position: relative;
    min-width: 0;
}

.thai-date-enhanced {
    position: relative;
    display: none;
    align-items: stretch;
    width: 100%;
}

.thai-date-field.is-enhanced > .thai-date-native { display: none; }
.thai-date-field.is-enhanced > .thai-date-enhanced { display: flex; }

.thai-date-display {
    width: 100%;
    min-height: 46px;
    padding: 5px 52px 5px 13px !important;
    color: var(--ink) !important;
    background: rgba(255, 255, 255, .98) !important;
    border: 1px solid #cbd7e5;
    border-radius: 10px;
    cursor: pointer;
}

.thai-date-display::placeholder { color: #94a3b8; opacity: 1; }
.thai-date-display:focus { border-color: var(--blue); outline: 3px solid rgba(37, 99, 235, .12); }

.thai-date-trigger {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 44px;
    min-width: 44px;
    height: calc(100% - 2px);
    min-height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--brand);
    background: transparent;
    border: 0;
    border-left: 1px solid rgba(100, 116, 139, .22);
    border-radius: 0 9px 9px 0;
    cursor: pointer;
}

.thai-date-trigger:hover,
.thai-date-trigger:focus-visible { background: var(--brand-soft); }
.thai-date-trigger svg { width: 20px; height: 20px; }

.thai-calendar {
    position: fixed;
    z-index: 1000;
    width: min(360px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    padding: 7px 14px;
    overflow-y: auto;
    color: var(--ink);
    background: rgba(255, 255, 255, .99);
    border: 1px solid rgba(100, 116, 139, .28);
    border-radius: 16px;
    box-shadow: 0 20px 48px rgba(15, 23, 42, .18);
    overscroll-behavior: contain;
}

.thai-calendar[hidden] { display: none !important; }
.thai-calendar-header {
    display: grid;
    grid-template-columns: 44px minmax(88px, 1fr) minmax(98px, 112px) 44px;
    gap: 7px;
    align-items: center;
    margin-bottom: 5px;
}

.thai-calendar-nav,
.thai-calendar-action,
.thai-calendar-day {
    min-height: 44px;
    font: inherit;
    cursor: pointer;
    touch-action: manipulation;
}

.thai-calendar button:disabled { opacity: .38; cursor: not-allowed; }

.thai-calendar-nav {
    min-width: 44px;
    padding: 0;
    color: var(--brand);
    background: var(--brand-soft);
    border: 1px solid #cfe1f7;
    border-radius: 10px;
    font-size: 23px;
    line-height: 1;
}

.thai-calendar-month,
.thai-calendar-year {
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 3.5px 9px;
    color: var(--ink);
    background: #fff;
    border: 1px solid #cbd7e5;
    border-radius: 10px;
    font: inherit;
    font-weight: 700;
}

.thai-calendar-year { text-align: center; }
.thai-calendar-weekdays,
.thai-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 3px;
}

.thai-calendar-weekdays {
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.thai-calendar-weekdays span { padding: 2.5px 1px; }
.thai-calendar-day {
    min-width: 0;
    padding: 2.5px 2px;
    color: var(--ink);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 600;
}

.thai-calendar-day:hover,
.thai-calendar-day:focus-visible {
    color: var(--brand);
    background: rgba(219, 234, 254, .72);
    border-color: rgba(37, 99, 235, .2);
}

.thai-calendar-day.is-today { border-color: rgba(37, 99, 235, .48); }
.thai-calendar-day.is-selected,
.thai-calendar-day.is-selected:hover,
.thai-calendar-day.is-selected:focus-visible {
    color: #fff;
    background: var(--brand);
    border-color: var(--brand);
}

.thai-calendar-day.is-empty { min-height: 44px; }
.thai-calendar-footer {
    display: flex;
    justify-content: flex-end;
    gap: 7px;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid rgba(226, 232, 240, .9);
}

.thai-calendar-action {
    padding: 3.5px 11px;
    color: var(--brand);
    background: var(--brand-soft);
    border: 1px solid #cfe1f7;
    border-radius: 9px;
    font-weight: 700;
}

.thai-calendar-nav:hover,
.thai-calendar-action:hover { filter: brightness(.97); }

.audit-date-filter {
    display: grid;
    grid-template-columns: repeat(2, minmax(190px, 260px)) auto;
    align-items: end;
    gap: 12px;
    padding: 7px 20px;
    background: #fbfdff;
    border-bottom: 1px solid var(--line);
}

.audit-date-filter .field { gap: 6px; }
.audit-date-filter-actions { display: flex; gap: 8px; }
.audit-date-filter-error { grid-column: 1 / -1; margin: 0; }

@media (max-width: 760px) {
    .audit-date-filter { grid-template-columns: 1fr 1fr; }
    .audit-date-filter-actions { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
    .thai-calendar { padding: 6px 12px; }
    .thai-calendar-header { grid-template-columns: 44px minmax(76px, 1fr) minmax(88px, 98px) 44px; gap: 4px; }
    .audit-date-filter { grid-template-columns: 1fr; padding: 7px 16px; }
    .audit-date-filter-actions { grid-column: auto; flex-wrap: wrap; }
}
