/* Shared sizing for native controls in Chromium, Firefox and Safari.
   Keep intrinsic date/select widths from expanding grid and flex tracks. */
main :where(form,fieldset,label,.grid,.filters,.card),
dialog :where(form,fieldset,label,section,article,div){min-inline-size:0;box-sizing:border-box}
:where(main,dialog) :where(input,select,textarea){box-sizing:border-box;min-inline-size:0;max-inline-size:100%}
:where(main,dialog) :where(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),select,textarea){min-width:0;max-width:100%}
:where(main,dialog) input:is([type="date"],[type="datetime-local"],[type="month"],[type="time"]){
  display:block;width:100%;inline-size:100%;min-width:0;min-inline-size:0;
  max-width:100%;max-inline-size:100%;box-sizing:border-box;
}
:where(main,dialog) input::-webkit-date-and-time-value{min-width:0;text-align:left}
:where(main,dialog) input::-webkit-datetime-edit{min-width:0;padding:0}
:where(main,dialog) :where(select,input[type="file"]){width:100%;text-overflow:ellipsis}
:where(.grid,.filters,.edit-basic,.hotel-fields,.transport-fields,.vehicle-details,.board-edit-date-row,.selected-guide-dates)>*{min-width:0;max-width:100%;box-sizing:border-box}
dialog{box-sizing:border-box;max-width:calc(100vw - 24px);max-height:90vh;max-height:90dvh;overflow:auto}
:where(.dialog-head,.board-edit-head,.hotel-dialog-head,.reservation-dialog-head)>div{min-width:0;overflow-wrap:anywhere}
:where(.title-actions,.dialog-actions,.board-edit-actions,.hotel-form-actions){flex-wrap:wrap;gap:8px}
@media(min-width:601px) and (max-width:1366px){
  #hotel-dialog .hotel-fields{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
  #hotel-dialog .hotel-fields>*{grid-column:auto;min-width:0}
  #hotel-dialog .hotel-fields>.wide-field,
  #hotel-dialog .hotel-fields>.hotel-room-allocations{grid-column:1/-1}
  .board-edit-date-row,.selected-guide-dates{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:600px){
  #hotel-dialog .hotel-fields,.board-edit-date-row{grid-template-columns:minmax(0,1fr)!important}
  #hotel-dialog .hotel-fields>*{grid-column:1/-1!important;min-width:0}
  :where(.title-actions,.dialog-actions,.board-edit-actions,.hotel-form-actions)>*{min-width:0;max-width:100%}
}
@media(pointer:coarse){
  :where(main,dialog) :where(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),select,textarea){font-size:16px;min-height:44px}
}

/* V487: fit columns to the panel, not to the device or pointer type.
   Reset legacy explicit spans so they cannot create implicit grid tracks. */
body #hotel-dialog .hotel-fields,
body #transport-dialog .transport-item .transport-fields,
body #transport-dialog .vehicle-details{
  display:grid!important;
  grid-template-columns:repeat(auto-fit,minmax(min(100%,210px),1fr))!important;
  grid-template-rows:none!important;gap:10px 12px!important;
  min-width:0;max-width:100%;
}
body #hotel-dialog .hotel-fields>*,
body #transport-dialog .transport-item .transport-fields>*,
body #transport-dialog .vehicle-details>*{
  grid-column:auto!important;grid-row:auto!important;
  min-width:0!important;max-width:100%;box-sizing:border-box;padding-right:0;
}
body #hotel-dialog .hotel-fields>.wide-field,
body #hotel-dialog .hotel-fields>.hotel-room-allocations,
body #transport-dialog .transport-fields>.wide-field,
body #transport-dialog .transport-fields>.vehicle-details,
body #transport-dialog .transport-fields>.transport-period-summary,
body #transport-dialog .transport-fields>.airline-manual-toggle{grid-column:1/-1!important}
body #transport-dialog .vehicle-details[hidden],
body #transport-dialog .transport-item.is-collapsed .transport-fields{display:none!important}
body .basic-departure-date,body .basic-korea-departure{grid-template-rows:auto auto auto}
body .arrival-date-heading{height:auto;min-height:0;flex-wrap:wrap;white-space:normal}
body .same-day-arrival-check{white-space:normal}
/* Native WebKit date controls may otherwise retain their intrinsic width. */
body :is(main,dialog) input:is([type="date"],[type="month"],[type="time"],[type="datetime-local"]){
  -webkit-appearance:none;appearance:none;
  min-width:0!important;min-inline-size:0!important;max-width:100%;
  box-sizing:border-box;
}

/* Search and route selectors contain multiple controls; give them a whole row. */
body #transport-dialog .transport-fields>.ktx-train-field,
body #transport-dialog .transport-fields>.airline-flight-field,
body #hotel-dialog .hotel-fields>label:has(.hotel-name-select){grid-column:1/-1!important}
body #transport-dialog .airline-flight-picker,
body #transport-dialog .rail-train-picker{
  grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr));min-width:0;
}
body #transport-dialog .airline-flight-picker>*,
body #transport-dialog .rail-train-picker>*{min-width:0!important;width:100%;box-sizing:border-box}


/* V489: a dedicated date row; compact details wrap independently below it. */
body #hotel-dialog .hotel-fields{
  display:flex!important;flex-wrap:wrap;align-items:flex-start;gap:10px 12px!important;
}
body #hotel-dialog .hotel-fields>*{
  grid-column:auto!important;grid-row:auto!important;flex:0 1 160px;align-self:flex-start!important;
  min-width:0!important;max-width:100%;
}
body #hotel-dialog .hotel-fields>.hotel-dates-row{
  flex:0 0 100%;display:grid;grid-template-columns:repeat(3,minmax(0,240px));
  gap:12px;min-width:0;max-width:100%;align-items:start;
}
body #hotel-dialog .hotel-dates-row>label{
  min-width:0;max-width:100%;grid-column:auto!important;grid-row:auto!important;
}
body #hotel-dialog .hotel-fields>label:has(.hotel-region-select){flex-basis:100px}
body #hotel-dialog .hotel-fields>label:has(.hotel-name-select){flex:0 1 210px}
body #hotel-dialog .hotel-fields>.hotel-room-allocations{
  flex:0 1 340px;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px 8px;
}
body #hotel-dialog .hotel-room-allocations>strong{grid-column:1/-1;margin:0}
body #hotel-dialog .hotel-room-rows{min-width:0}
body #hotel-dialog .hotel-room-allocations .hotel-room-row{grid-template-columns:minmax(0,1fr) 65px}
body #hotel-dialog .hotel-room-actions{display:flex;align-items:start;gap:6px;flex-wrap:wrap;margin:0}
body #hotel-dialog .hotel-room-actions button{width:auto;margin:0;min-width:0;white-space:normal;min-height:44px;padding:8px}
body #hotel-dialog .hotel-fields>.hotel-breakfast-field{flex-basis:115px}
body #hotel-dialog .hotel-fields>.wide-field{flex-basis:100%}
@media(max-width:600px){
  body #hotel-dialog .hotel-fields>.hotel-dates-row{grid-template-columns:repeat(auto-fit,minmax(min(100%,200px),240px))}
  body #hotel-dialog .hotel-fields>.hotel-room-allocations{flex-basis:100%;grid-template-columns:minmax(0,1fr)}
  body #hotel-dialog .hotel-room-allocations>strong{grid-column:1}
}

body #hotel-dialog .hotel-item>.transport-item-head{margin-left:0;margin-right:0;min-width:0;max-width:100%;box-sizing:border-box}
