/* Shared control rhythm. Keep labels, controls and help text independently sized. */
:root { --control-height: 44px; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: var(--control-height);
    line-height: 1.4;
    text-align: center;
    vertical-align: middle;
}
.btn-sm { min-height: 36px; }
.btn-lg { min-height: 52px; }
.btn > :is(i, svg) { flex-shrink: 0; }
.form-control, .form-select { min-width: 0; min-height: var(--control-height); line-height: 1.5; }
.form-control-sm, .form-select-sm { min-height: 36px; }
textarea.form-control { min-height: 100px; resize: vertical; }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input:is([type="date"], [type="time"], [type="datetime-local"]) { max-width: 100%; }
label:has(> :is(.form-control, .form-select)) { min-width: 0; }
label > :is(.form-control, .form-select) { margin-top: .4rem; }
.input-group { flex-wrap: nowrap; min-width: 0; }
.input-group > .form-control { min-width: 0; }
.input-group-text { white-space: nowrap; }
.modal-footer { gap: .5rem; }
.modal-footer > .btn { margin: 0; }
.modal-body, .modal-content, .row > * { min-width: 0; }

/* File inputs retain native keyboard, drag/drop and validation behavior. */
.ui-file-picker { position: relative; display: flex; align-items: center; gap: .75rem; min-height: 48px; width: 100%; margin-top: .4rem; padding: .45rem .65rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card-2); font-size: .875rem; font-weight: 400; }
.ui-file-picker > input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.ui-file-picker__button { flex: 0 0 auto; padding: .4rem .7rem; border-radius: 7px; background: var(--bg-card); color: var(--primary); border: 1px solid var(--border); font-weight: 600; }
.ui-file-picker__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.ui-file-picker:focus-within { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 2px; }
.ui-file-picker:has(input:disabled) { opacity: .5; }

/* Radio choices complement the existing application switches. */
body label > input[type="radio"]:not([class]) {
    appearance: none; display: inline-grid; place-content: center; flex: 0 0 auto;
    width: 20px; height: 20px; margin: 0 .4rem 0 0; vertical-align: middle;
    background: var(--bg-card); border: 1.5px solid var(--text-muted); border-radius: 50%; cursor: pointer;
}
body label > input[type="radio"]:not([class]):checked { background: var(--primary); border-color: var(--primary); }
body label > input[type="radio"]:not([class]):checked::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
body label > input[type="radio"]:not([class]):focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 3px; }

.admin-control { align-content: start; }
.admin-control > :is(input:not([type="checkbox"]):not([type="radio"]), select) { height: var(--control-height); min-width: 0; align-self: start; }
.admin-control > small { line-height: 1.6; }
.admin-control select { appearance: none; padding-right: 2.5rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23748196' stroke-width='1.7' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .8rem center; }
.admin-settings-form .admin-form-grid { row-gap: 7px; }
.admin-settings-form .admin-form-grid > .admin-control { grid-row: span 3; grid-template-rows: subgrid; }
.admin-settings-form .admin-switch-list:has(> label:only-child) { grid-template-columns: minmax(0, 1fr); }
.admin-switch-list > label > span { min-width: 0; }
.admin-switch-list small { line-height: 1.6; }
.admin-control .ui-file-picker { margin: 0; }

.vehicle-form, .vehicle-fuel-fields, .vehicle-maintenance-fields { align-items: start; }
.vehicle-form .vehicle-field-heading { min-height: 28px; }
.vehicle-form-preview .vehicle-preview-scene { height: 172px; }
.vehicle-detail-header > .page-title { min-width: 0; max-width: 100%; flex: 1 1 16rem; overflow-wrap: anywhere; }
.vehicle-fuel-fields > label { align-self: start; }
.vehicle-spend-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; max-width: 58rem; margin-inline: auto; }
.vehicle-spend-form > label { min-width: 0; }
.vehicle-spend-form__wide { grid-column: 1 / -1; }
.vehicle-driver-payment, .ui-switch-label { display: flex; align-items: center; gap: .75rem; line-height: 1.5; cursor: pointer; }
:is(.vehicle-driver-payment, .ui-switch-label) > input { flex-shrink: 0; }
:is(.vehicle-driver-payment, .ui-switch-label) > span { min-width: 0; }
.vehicle-spend-form > .btn { justify-self: start; margin-top: 0 !important; }
.profile-page > form.profile-card { flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.profile-notifications-title { flex: 0 0 100%; width: 100%; margin: 0; font-size: 1.25rem; }
.mileage-reminder .mileage-snooze { display: inline-flex; align-items: center; gap: .5rem; min-height: var(--control-height); margin: 0; white-space: nowrap; }
.mileage-reminder .mileage-snooze input { flex: 0 0 4.5rem; width: 4.5rem; max-width: 100%; margin: 0; text-align: center; }
/* The Mini App uses a collapsible Modules panel instead of the browser dropdown. */
.telegram-more-menu__modules > .telegram-more-menu__modules-chevron { transition: transform .18s ease; }
.telegram-more-menu__modules-panel.collapsing { transition: height .26s cubic-bezier(.2,.75,.25,1); }
.telegram-more-menu__grid a, .telegram-more-menu__modules { transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
.telegram-more-menu__grid a:focus-visible, .telegram-more-menu__modules:focus-visible { outline: 2px solid var(--tg-theme-button-color, var(--primary)); outline-offset: 2px; }
@media (hover:hover) {
    .telegram-more-menu__grid a:hover, .telegram-more-menu__modules:hover { border-color: var(--tg-theme-button-color, var(--primary)); background: color-mix(in srgb, var(--tg-theme-button-color, var(--primary)) 12%, var(--tg-theme-bg-color, var(--bg-card-2))); }
}
@media (prefers-reduced-motion:reduce) {
    .telegram-more-menu__modules-panel.collapsing, .telegram-more-menu__modules > .telegram-more-menu__modules-chevron, .telegram-more-menu__grid a, .telegram-more-menu__modules { transition: none; }
}
@media (max-width: 575.98px) {
    .vehicle-spend-form { grid-template-columns: minmax(0, 1fr); padding: 1rem !important; }
    .vehicle-spend-form > .btn { width: 100%; }
    .ui-file-picker { gap: .5rem; }
    .ui-file-picker__button { padding-inline: .5rem; }
    .modal-footer > .btn { flex: 1 1 auto; }
}
