/* These helpers leave the desktop table and filter layouts intact. */
.mobile-cell-content { display: contents; }
.mobile-checkbox-touch { display: contents; }
.mobile-account-toggle, .mobile-filter-toggle, .mobile-filter-summary, .mobile-table-hint { display: none; }

@media (max-width: 720px) {
  html { scroll-padding-top: 76px; }
  body { background: #f5f7fb; line-height: 1.5; }
  button, a, summary { touch-action: manipulation; }
  .topbar {
    position: sticky; top: 0; z-index: 30;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px; min-height: 64px; height: auto;
    padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
    background: #fff; backdrop-filter: none;
  }
  .topbar .brand { width: auto; gap: 7px; }
  .topbar .brand-logo { height: 28px; max-width: 54px; }
  .topbar .brand strong { font-size: 14px; }
  .topbar .top-meta { width: auto; gap: 6px; }
  .mobile-nav-toggle { padding: 8px; gap: 5px; font-size: 13px; }
  .mobile-account-toggle { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 8px; font-size: 13px; }
  .topbar .language > span { display: none; }
  .topbar .language select { width: 74px; min-height: 44px; padding-left: 8px; padding-right: 26px; font-size: 16px; }
  .topbar .admin-session {
    display: none; position: absolute; top: calc(100% + 8px); left: 12px; right: 12px;
    padding: 14px; gap: 10px; flex-wrap: wrap;
    background: #fff; border: 1px solid var(--line); box-shadow: 0 10px 32px #1f2a4426;
  }
  .topbar .admin-session.mobile-account-open { display: flex; }
  .topbar #adminSessionName { display: block; flex: 1; min-width: 0; overflow-wrap: anywhere; }
  .topbar .admin-session .badge { display: inline-flex; }
  .topbar .admin-session .small-btn { min-height: 44px; font-size: 14px; padding: 0 12px; }
  .content { min-width: 0; padding: 16px max(12px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .page-head { gap: 12px; margin-bottom: 16px; }
  .page-head > div:first-child { grid-row: 1; }
  .page-head .attraction-picker { grid-row: 2; min-width: 0; padding: 10px 12px; border-radius: 12px; }
  .breadcrumb { margin-bottom: 4px; font-size: 12px; }
  .page-head h1 { font-size: 23px; line-height: 1.3; }
  .panel, .filter-band, .calendar-toolbar { min-width: 0; padding: 14px; border-radius: 12px; }
  .panel-title { gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
  .panel-title h2 { font-size: 17px; }
  .panel-title > span:not(.panel-count) { width: 100%; line-height: 1.6; }
  .order-list-title { flex-wrap: nowrap; }
  .order-list-title .panel-count { flex: 0 0 auto; }
  .form-grid, .filter-band, .slot-config-form, .brand-settings-form { gap: 14px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea {
    min-width: 0; max-width: 100%; min-height: 44px; font-size: 16px; border-radius: 8px;
  }
  input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
  .primary-btn, .outline-btn, .ghost-btn, .danger-btn, .icon-btn { min-height: 44px; white-space: normal; line-height: 1.4; padding-block: 8px; }
  .toolbar, .filter-actions, .dialog-actions { gap: 8px; align-items: stretch; }
  .toolbar > button { flex: 1 1 auto; padding-inline: 10px; }
  .filter-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .filter-actions > button { min-width: 0; width: auto; padding-inline: 8px; }
  .order-management-filter .filter-actions > button { grid-column: auto; }
  .order-management-filter .filter-actions > button:last-child { grid-column: 1 / -1; }
  .filter-actions > button:only-child { grid-column: 1 / -1; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 96px; padding: 14px; }
  .metric strong { font-size: 24px; }
  .slot-effective-action-row { grid-template-columns: 1fr; }
  .slot-effective-action-row > .slot-config-actions { grid-column: 1; }
  .slot-config-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .slot-config-actions > button { flex: 1; }

  .mobile-filter-panel, .order-management-filter { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .mobile-filter-panel > *, .order-management-filter > label { grid-column: 1 / -1; }
  .order-management-filter > .panel-title { display: none; }
  .mobile-filter-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--text); text-align: left; }
  .mobile-filter-toggle span { color: var(--primary-dark); font-size: 13px; }
  .mobile-filter-toggle span::after { content: '⌄'; display: inline-block; margin-left: 6px; }
  .mobile-filter-toggle[aria-expanded="true"] span::after { transform: rotate(180deg); }
  .mobile-filter-summary { display: block; margin: -4px 0 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
  .mobile-filter-panel:not(.mobile-filter-collapsed) > .mobile-filter-summary { display: none; }
  .product-filter-band.mobile-filter-collapsed > label:not(:first-of-type),
  .order-management-filter.mobile-filter-collapsed > label:not(.wide-field),
  .unified-report-filter.mobile-filter-collapsed > .report-base-grid,
  .unified-report-filter.mobile-filter-collapsed > .report-multi-filter { display: none; }
  .report-base-grid, .report-multi-grid { grid-template-columns: minmax(0, 1fr); }

  .mobile-card-wrap { overflow: visible; background: transparent; box-shadow: none; border-radius: 0; }
  table.mobile-card-table { display: block; min-width: 0; width: 100%; border-collapse: separate; }
  .mobile-card-table thead { display: block; }
  .mobile-card-table thead tr { display: block; }
  .mobile-card-table th {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap;
  }
  .mobile-card-table th.mobile-card-selection-heading {
    position: static; display: flex; align-items: center; gap: 10px; width: auto; height: auto; min-height: 44px;
    padding: 4px 12px; margin: 0 0 8px; clip: auto; clip-path: none; background: transparent; border: 0; white-space: normal;
  }
  .mobile-card-selection-heading::after { content: attr(data-label); font-weight: 500; }
  .mobile-card-table tbody { display: grid; gap: 12px; }
  .mobile-card-table tbody > tr { position: relative; display: block; min-width: 0; border: 1px solid #e0e7f1; border-radius: 14px; background: #fff; overflow: hidden; }
  .mobile-card-table td {
    display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.6fr); gap: 12px; align-items: start;
    width: auto; min-width: 0; padding: 10px 14px; border: 0; text-align: left; font-size: 14px;
  }
  .mobile-card-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
  .mobile-card-table .mobile-cell-content { display: block; min-width: 0; overflow-wrap: anywhere; }
  .mobile-card-table td.mobile-card-title { display: block; padding: 14px; border-bottom: 1px solid #edf1f6; color: #14294b; font-size: 16px; font-weight: 600; }
  .mobile-card-table td.mobile-card-title::before, .mobile-card-table td.mobile-card-selection::before,
  .mobile-card-table td.mobile-card-actions::before { content: none; }
  .mobile-card-selectable td.mobile-card-title { padding-right: 60px; }
  .mobile-card-table td.mobile-card-selection { display: flex; position: absolute; right: 6px; top: 6px; width: 44px; min-width: 44px; height: 44px; padding: 0; align-items: center; justify-content: center; z-index: 1; box-shadow: none; background: transparent; }
  .mobile-card-table input[type="checkbox"] { width: 24px; height: 24px; min-height: 24px; margin: 0; padding: 0; }
  .mobile-card-table .mobile-checkbox-touch { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; cursor: pointer; }
  .mobile-card-table input[type="checkbox"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
  .mobile-card-table .table-field-link { margin: 0; padding: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .mobile-card-table .table-subtext { font-weight: 400; line-height: 1.6; white-space: normal; }
  .mobile-card-table td.mobile-card-actions { display: block; padding: 12px; margin-top: 4px; border-top: 1px solid #edf1f6; }
  .mobile-card-actions .action-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); justify-content: stretch; gap: 8px; }
  .mobile-card-actions button { min-height: 44px; width: 100%; padding: 8px; border: 1px solid #dae5f8; border-radius: 8px; background: #f5f8ff; line-height: 1.4; white-space: normal; }
  .mobile-card-actions .danger-link { border-color: #f5dedb; background: #fff8f7; }
  .mobile-card-table .order-status-stack { min-width: 0; }
  .mobile-card-table .mobile-card-empty td { display: block; padding: 20px 14px; }
  .mobile-card-table .mobile-card-empty td::before { content: none; }
  .mobile-card-table .overflow-display-cell { max-width: none; max-height: none; -webkit-line-clamp: unset; white-space: normal; overflow: visible; }
  .mobile-table-hint { display: block; margin: 8px 0; color: var(--muted); font-size: 12px; }
  .table-wrap:not(.mobile-card-wrap) { max-width: 100%; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .table-wrap:not(.mobile-card-wrap) table { min-width: 640px; }

  dialog { max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); margin: auto; border-radius: 14px; }
  .dialog-card { width: 100%; max-width: 100%; min-width: 0; padding: 16px; max-height: calc(100dvh - 20px); overflow-y: auto; overscroll-behavior: contain; }
  .dialog-head { gap: 10px; align-items: flex-start; }
  .dialog-head h2 { font-size: 19px; }
  .dialog-head > .icon-btn { flex: 0 0 44px; }
  dialog .dialog-actions { position: sticky; bottom: -16px; z-index: 2; margin-inline: -16px; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
  .dialog-actions > button { flex: 1 1 auto; }
  .order-management-dialog-card, .order-activity-dialog-card { padding: 0; overflow: hidden; }
  .toast { max-width: calc(100vw - 24px); bottom: max(16px, env(safe-area-inset-bottom)); overflow-wrap: anywhere; }
}

@media (max-width: 360px) {
  .mobile-nav-toggle > span[data-i18n] { display: none; }
  .topbar .brand-logo { display: none; }
  .topbar .brand strong { font-size: 13px; }
  .mobile-card-table td { gap: 10px; padding-inline: 12px; }
}
