/* Every rule requires a positively identified mobile device; desktop rules stay intact. */
html.haima-touch body { padding: 0; }
.haima-touch .app-shell { padding: 10px 8px 20px; }
.haima-touch .app-shell > *,
.haima-touch .haima-dialog-card { scale: none !important; }
.haima-touch .cal-card { padding: 12px 8px; }
.haima-touch .calendar-frame-header { flex-wrap: wrap; gap: 12px; }
.haima-touch .calendar-month-nav { width: 100%; min-width: 0; justify-content: space-between; gap: 6px; }
.haima-touch .calendar-frame-header #monthLabel { font-size: 17px; white-space: nowrap; padding: 4px; }
.haima-touch .calendar-frame-actions { width: 100%; justify-content: space-between; flex-wrap: wrap; }
.haima-touch .calendar-status-summary { flex-wrap: wrap; gap: 6px; font-size: 12px; }
.haima-touch .month-btn { min-height: 44px; min-width: 44px; font-size: 13px; }
.haima-touch .cal-wrap { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; }
.haima-touch .cal-table { width: max-content; min-width: 100%; table-layout: auto; overflow: visible; font-size: 13px; }
.haima-touch .cal-table th:not(.cal-col-vehicle),
.haima-touch .cal-table td:not(.cal-col-vehicle) { min-width: 96px; width: 96px; padding: 6px 4px; height: 48px; }
.haima-touch .cal-table .cal-col-vehicle { width: 132px; min-width: 132px; max-width: 132px; position: sticky; left: 0; z-index: 4; background: #edf3fb; box-shadow: 2px 0 4px #d5deeb; }
.haima-touch .cal-table tbody tr .cal-col-vehicle { background: #edf3fb; }
.haima-touch .cal-vehicle-name { white-space: normal; overflow-wrap: anywhere; font-size: 13px; }
.haima-touch .cal-vehicle-category { font-size: 11px; }
.haima-touch .cal-card .cal-day-num { font-size: 15px; line-height: 1.3; white-space: nowrap; }
.haima-touch .cal-head-day { font-size: 12px; }
.haima-touch .cal-card .cal-mini-booking { font-size: 13px; letter-spacing: normal; line-height: 1.35; padding: 3px 0; }
.haima-touch .cal-card .cal-driver-name { font-size: 12px; white-space: normal; overflow-wrap: anywhere; text-align: center; }
.haima-touch .cal-card .cal-cell-multi .cal-mini-booking { flex-direction: column; gap: 2px; }
.haima-touch .cal-card .cal-cell-multi .cal-driver-name { margin-left: 0; }
.haima-touch .cal-multi-list { max-height: none; min-height: 0; height: auto; overflow: visible; }
.haima-touch .haima-hover-card { display: none !important; }
.haima-touch .after-calendar-workspace { grid-template-columns: minmax(0, 1fr); overflow: visible; }
.haima-touch .haima-assistant-menu { width: 100%; }
.haima-touch .haima-assistant-menu.floating-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.haima-touch .haima-assistant-menu .toolbar-divider { display: none; }
.haima-touch .haima-assistant-menu .floating-btn { min-height: 44px; padding-left: 35px; }
.haima-touch .reservation-compact-list { grid-template-columns: minmax(0, 1fr); }
.haima-touch .reservation-compact-item { min-width: 0; }
.haima-touch .reservation-compact-head { flex-wrap: wrap; }
.haima-touch .reservation-compact-name,
.haima-touch .reservation-compact-period,
.haima-touch .reservation-compact-meta { white-space: normal; overflow-wrap: anywhere; }
.haima-touch .reservation-compact-action { min-height: 44px; min-width: 60px; }

.haima-touch .haima-dialog-overlay { inset: var(--haima-touch-top, 0px) 0 auto; height: var(--haima-touch-height, 100dvh); padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
.haima-touch .haima-dialog-overlay .haima-dialog-card { min-width: 0; max-width: 100%; max-height: 100%; overflow: auto; overscroll-behavior: contain; }
.haima-touch .haima-dialog-overlay .haima-reservation-action-card { position: relative !important; left: auto !important; top: auto !important; transform: none !important; width: 100% !important; max-width: 520px; padding: 18px; }
.haima-touch .haima-dialog-body { max-height: none; overflow-wrap: anywhere; }
.haima-touch .haima-dialog-list { max-height: none; }
.haima-touch .haima-dialog-actions { flex-wrap: wrap; }
.haima-touch .haima-dialog-actions button,
.haima-touch .haima-dialog-list button { box-sizing: border-box; min-height: 44px; font-size: 15px; }
.haima-touch .haima-reservation-actions .haima-action-group { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* The same editor DOM becomes an independent scrolling panel; dialogs remain above it. */
.haima-touch body.reservation-editor-open { overflow: hidden; }
.haima-touch body.reservation-editor-open .reservation-editor-workspace {
  position: fixed; z-index: 6000; top: var(--haima-touch-top, 0px); left: 0; width: 100%; max-width: none;
  height: var(--haima-touch-height, 100dvh); margin: 0; padding: max(8px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  background: #eef5ff; scroll-padding-block: 150px 90px; overflow-anchor: none; -webkit-overflow-scrolling: touch;
}
.haima-touch .reservation-editor-workspace > * { flex-shrink: 0; }
.haima-touch .reservation-editor-workspace .reservation-editor-header { position: sticky; top: 0; z-index: 5; margin: 0; padding: 10px; flex-wrap: wrap; background: #f7faff; border-radius: 12px; }
.haima-touch .reservation-editor-status { width: 100%; flex-wrap: wrap; gap: 4px; }
.haima-touch .reservation-editor-context { white-space: normal; line-height: 1.5; overflow-wrap: anywhere; }
.haima-touch .reservation-editor-actions { width: 100%; flex-wrap: wrap; justify-content: space-between; }
.haima-touch .reservation-editor-actions button { min-height: 44px; padding: 10px 14px; font-size: 15px; }
.haima-touch .reservation-editor-workspace .sheet-input,
.haima-touch .reservation-editor-workspace .sheet-select,
.haima-touch .itinerary-editor-drawer input,
.haima-touch .itinerary-editor-drawer select { min-height: 44px; font-size: 16px; max-width: 100%; }
.haima-touch .reservation-editor-workspace .sheet-card { margin: 0; padding: 14px; border-radius: 14px; }
.haima-touch .reservation-editor-workspace .basic-tools-row,
.haima-touch .reservation-editor-workspace .billing-memo-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 0; }
.haima-touch .reservation-editor-workspace .billing-memo-row { grid-template-columns: minmax(0, 1fr) !important; }
.haima-touch .reservation-editor-workspace .core-grid,
.haima-touch .reservation-editor-workspace .info-status-crew-row { grid-template-columns: minmax(0, 1fr); gap: 14px; }
.haima-touch .reservation-editor-workspace .info-field.span-2 { grid-column: auto; }
.haima-touch .reservation-editor-workspace .sheet-range-wide { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.haima-touch .reservation-editor-workspace .sheet-range-wide input { width: 100%; }
.haima-touch .reservation-editor-workspace .sheet-range-sep { text-align: center; }
.haima-touch .reservation-editor-workspace .info-dual { grid-template-columns: minmax(0, 1fr); }
.haima-touch .reservation-editor-workspace .day-card { padding: 12px; }
.haima-touch .reservation-editor-workspace .day-meta { align-items: flex-start; }
.haima-touch .reservation-editor-workspace .day-summary { min-width: 0; flex-basis: 100%; }
.haima-touch .reservation-editor-workspace .day-field { max-width: 100%; }
.haima-touch .reservation-editor-workspace .day-actions { margin-left: 0; }
.haima-touch .reservation-editor-workspace .itinerary-add-actions { display: flex; flex-wrap: wrap; }
.haima-touch .reservation-editor-workspace .itinerary-add-action { min-height: 44px; flex: 1 1 120px; }
.haima-touch .reservation-editor-workspace .itinerary-add-action.is-empty { display: none; }
.haima-touch .reservation-editor-workspace .day-card.is-list-mode .itinerary-add-actions { display: flex; width: 100%; max-width: none; height: auto; max-height: none; overflow: visible; }
.haima-touch .reservation-editor-workspace .itinerary-head { flex-wrap: wrap; }
.haima-touch .reservation-editor-workspace .itinerary-head .sheet-section-title { flex: 1 0 100%; }
.haima-phone .reservation-editor-workspace #moneyCard .money-grid { grid-template-columns: minmax(0, 1fr) !important; }
.haima-touch .reservation-editor-workspace #moneyCard,
.haima-touch .reservation-editor-workspace #dailyMemoCard { height: auto !important; min-height: 0 !important; max-height: none !important; overflow: visible !important; }
.haima-touch .reservation-editor-workspace #moneyCard .money-input,
.haima-touch .reservation-editor-workspace #moneyCard #sheetProfit,
.haima-touch .reservation-editor-workspace #moneyCard #sheetProfitRate { height: 44px !important; min-height: 44px !important; max-height: none !important; font-size: 16px !important; }
.haima-touch .reservation-editor-workspace #dailyMemo { min-height: 140px; font-size: 16px; }
.haima-touch .reservation-editor-workspace .day-card.is-list-mode .spot-card { width: 100%; max-width: 100%; min-height: 60px; }
.haima-touch .reservation-editor-workspace .spot-overview { min-height: 44px; }
.haima-touch .driver-combobox-list { max-width: calc(100vw - 32px); }
.haima-touch .driver-combobox-option { min-height: 44px; font-size: 16px; }
.haima-touch .itinerary-editor-drawer,
.haima-touch .itinerary-editor-drawer.spot-editor-floating { top: var(--haima-touch-top, 0px) !important; left: 0 !important; right: 0; bottom: auto; width: 100%; height: var(--haima-touch-height, 100dvh); max-height: var(--haima-touch-height, 100dvh); border-radius: 0; padding-bottom: env(safe-area-inset-bottom); }
.haima-touch .itinerary-editor-body { min-height: 0; overflow-y: auto; scroll-padding-block: 16px; }
.haima-touch .itinerary-editor-drawer button { min-height: 44px; font-size: 15px; }
.haima-touch .itinerary-editor-move-actions,
.haima-touch .itinerary-editor-actions { flex-wrap: wrap; }

.haima-phone .haima-touch-steps { font-size: 16px; font-weight: 700; color: #204c7a; padding: 4px; }
.haima-phone .haima-touch-step-actions { position: sticky; bottom: 0; display: flex; justify-content: space-between; gap: 12px; margin-top: auto; padding: 12px 0 max(8px, env(safe-area-inset-bottom)); background: #eef5ff; z-index: 4; }
.haima-phone .haima-touch-step-actions button { min-height: 48px; padding: 10px 18px; border: 1px solid #c5d2e6; border-radius: 10px; background: white; color: #204c7a; font-size: 16px; }
.haima-phone .haima-touch-step-actions .btn-primary { margin-left: auto; background: #2563eb; color: white; }
.haima-phone .haima-touch-review dl { margin: 0; }
.haima-phone .haima-touch-review dt { font-weight: 700; color: #52657c; margin-top: 16px; }
.haima-phone .haima-touch-review dd { margin: 6px 0 0; white-space: pre-line; overflow-wrap: anywhere; line-height: 1.6; }
.haima-touch body:not(.reservation-editor-open) .haima-touch-steps,
.haima-touch body:not(.reservation-editor-open) .haima-touch-review,
.haima-touch body:not(.reservation-editor-open) .haima-touch-step-actions { display: none; }
.haima-phone .reservation-editor-workspace:not([data-touch-step="1"]) > .basic-tools-row,
.haima-phone .reservation-editor-workspace:not([data-touch-step="2"]) > #itinerarySheet,
.haima-phone .reservation-editor-workspace:not([data-touch-step="2"]) > .billing-memo-row,
.haima-phone .reservation-editor-workspace:not([data-touch-step="3"]) > .haima-touch-review,
.haima-phone .reservation-editor-workspace:not([data-touch-step="3"]) #btnSave { display: none !important; }
.haima-touch .haima-touch-step-actions button[hidden] { display: none; }

.haima-tablet .reservation-compact-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.haima-tablet .reservation-editor-workspace .core-grid,
.haima-tablet .reservation-editor-workspace .info-status-crew-row,
.haima-tablet .reservation-editor-workspace .billing-memo-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.haima-tablet .reservation-editor-workspace .billing-memo-row { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
.haima-tablet .reservation-editor-workspace .info-field.span-2 { grid-column: span 2; }
.haima-tablet .reservation-editor-workspace .info-dual { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.haima-tablet .reservation-editor-workspace .sheet-range-wide { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; }
.haima-tablet .itinerary-editor-drawer,
.haima-tablet .itinerary-editor-drawer.spot-editor-floating { left: auto !important; width: min(520px, 100%); }
@media (min-width: 1100px) {
  .haima-tablet body.reservation-editor-open .reservation-editor-workspace { left: auto; right: 0; width: min(880px, 72vw); box-shadow: -12px 0 32px #b2c4dd; }
}
@media (max-width: 700px) {
  .haima-tablet .reservation-editor-workspace .core-grid,
  .haima-tablet .reservation-editor-workspace .info-status-crew-row,
  .haima-tablet .reservation-editor-workspace .billing-memo-row { grid-template-columns: minmax(0, 1fr); }
  .haima-tablet .reservation-editor-workspace .billing-memo-row { grid-template-columns: minmax(0, 1fr) !important; }
  .haima-tablet .reservation-editor-workspace .info-field.span-2 { grid-column: auto; }
  .haima-tablet .reservation-compact-list { grid-template-columns: minmax(0, 1fr); }
}
