.incident-prefix-picker { display: none; }

@media screen and (max-width: 1040px) {
  .tabs, .incident-tabs { flex-wrap: wrap; gap: 6px; overflow: visible; }
  .tabs > button, .incident-tabs > button { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }

  .table-wrap.record-table { min-width: 0; overflow: visible; }
  .record-table > table { table-layout: fixed; }
  .record-table :is(th, td) { padding: 8px 10px; white-space: normal; overflow-wrap: anywhere; }
  .record-table .action-cell > .row { flex-wrap: wrap; }
  .record-table button:not(.icon-button) { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .record-table-stacked { position: relative; }
  .record-table-stacked :is(table, tbody, tbody > tr) { display: block; }
  .record-table-stacked thead:not(.record-table-sort) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .record-table-sort, .record-table-sort th { display: block; }
  .record-table-sort tr { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-bottom: 1px solid var(--line); }
  .record-table-sort th { padding: 0; }
  .record-table-sort button { padding: 4px 8px; min-height: 44px; }
  .record-table-stacked tbody > tr { padding: 6px 10px; border-bottom: 1px solid var(--line); }
  .record-table-stacked tbody > tr:last-child { border-bottom: 0; }
  .record-table-stacked td:not(.empty) { display: grid; grid-template-columns: minmax(0, 36%) minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 4px 0; border: 0; }
  .record-table-stacked td > .record-cell-label { display: block !important; color: var(--muted); font-size: .75rem; font-weight: 600; }
  .record-table-stacked td:is(.action-cell, [data-label=""]) { display: block; }
  .record-table-stacked td.empty { display: block; }
  .record-table .attachment-name { text-align: left; }
  .resource-panel .record-table td:last-child { min-width: 0; }

  .shell .incident-grid-shell { border: 0; background: transparent; box-shadow: none; overflow: hidden; }
  .shell .incident-grid-head { display: none; }
  .shell .incident-virtual-grid { --incident-grid-step: 156px; width: 100%; min-width: 0; height: min(62dvh, 560px); }
  .shell .incident-grid-canvas { width: 100%; min-width: 0; }
  .shell .incident-grid-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 28px minmax(0, 1fr) 44px; gap: 6px 8px; height: calc(var(--incident-grid-step) - 8px); min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
  .shell .incident-grid-row > div { min-width: 0; padding: 0; }
  .shell .incident-grid-row > div:nth-child(2) { grid-area: 2 / 1 / 3 / -1; }
  .shell .incident-grid-row > div:nth-child(2) > strong { font-size: 16px; line-height: 1.25; }
  .shell .incident-grid-row > div:nth-child(2) > p { margin: 2px 0 0; font-size: 14px; }
  .shell .incident-grid-row > div:nth-child(3) { grid-area: 1 / 2; justify-self: end; max-width: 112px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #a92535; font-weight: 700; }
  .shell .incident-grid-row > div:nth-child(4) { grid-area: 3 / 1; }
  .shell .incident-grid-row > div:nth-child(5) { grid-area: 3 / 2; gap: 6px; flex-wrap: nowrap; }
  .shell .incident-row-actions > .badge { display: none; }
  .shell .incident-row-actions > button { min-height: 44px; }
}

@media screen and (max-width: 760px) {
  :root {
    --phone-gap: 8px;
    --phone-dialog-left: max(8px, env(safe-area-inset-left));
    --phone-dialog-right: max(8px, env(safe-area-inset-right));
    --phone-dialog-top: max(8px, env(safe-area-inset-top));
    --phone-dialog-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .workspace .row, :is(.incident-dialog, .mobile-dialog) .row { gap: var(--phone-gap); }
  .shell .panel { margin-bottom: var(--phone-gap); }
  .shell .panel-head, .shell .panel-body { padding: 10px; }
  :is(.shell, .incident-dialog, .mobile-dialog) .form-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--phone-gap);
    margin: var(--phone-gap) 0;
  }
  :is(.shell, .incident-dialog, .mobile-dialog) .form-grid > label { margin: 0; gap: 4px; }
  :is(.shell, .incident-dialog, .mobile-dialog) .form-actions { flex-wrap: wrap; gap: var(--phone-gap); margin-top: var(--phone-gap); }
  :is(.shell, .incident-dialog, .mobile-dialog) .form-grid > *, :is(.incident-dialog, .mobile-dialog) fieldset { min-width: 0; }
  :is(.workspace, .incident-dialog, .mobile-dialog, .property-dialog) :is(input, select, textarea) { max-width: 100%; font-size: 16px; }
  :is(.incident-dialog, .mobile-dialog) :is(h2, .error) { min-width: 0; overflow-wrap: anywhere; }
  dialog:is(.incident-dialog, .mobile-dialog) {
    inset: var(--phone-dialog-top) var(--phone-dialog-right) var(--phone-dialog-bottom) var(--phone-dialog-left);
    width: min(560px, calc(100% - var(--phone-dialog-left) - var(--phone-dialog-right)));
    max-height: calc(100dvh - var(--phone-dialog-top) - var(--phone-dialog-bottom));
    margin: auto;
    padding: 10px;
    overflow: auto;
    overscroll-behavior: contain;
  }
  dialog:is(.incident-dialog, .mobile-dialog) > form { min-width: 0; padding: 0; }
  dialog:is(.incident-dialog, .mobile-dialog) > form > .between:first-child { flex-wrap: nowrap; margin-bottom: var(--phone-gap); }
  dialog:is(.incident-dialog, .mobile-dialog) > form > .between:first-child > h2 { margin: 0; font-size: 1.125rem; }
  dialog:is(.incident-dialog, .mobile-dialog) > form > .between:first-child > button { flex: 0 0 auto; }
  :is(.incident-dialog, .mobile-dialog) .error:empty { display: none; }

  .shell .incident-tabs, .shell .incident-list-heading .muted { display: none; }
  .shell .incident-prefix-picker { display: block; }
  .shell .incident-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
  .shell .incident-filters > input { grid-column: 1 / -1; }
  .shell .incident-filters > select { width: 100%; min-width: 0; font-size: 16px; padding: 6px; }
  .shell .incident-filters > .muted { grid-column: auto; justify-self: end; }
  .shell .incident-virtual-grid { --incident-grid-step: 130px; height: min(65dvh, 520px); }
  .shell .incident-grid-row { grid-template-rows: 20px minmax(0, 1fr) 44px; gap: 3px 6px; padding: 5px 8px; }
  .shell .incident-grid-row > div:first-child { display: flex; align-items: baseline; gap: 6px; }
  .shell .incident-grid-row > div:first-child > p { margin: 0; }
  .shell .incident-grid-row > div:nth-child(2) > p { margin: 0; }
  .shell .incident-grid-row > div:nth-child(3) { max-width: min(30vw, 112px); }

  .command-mobile-incident { gap: 8px; }
  .shell .command-incident-section { margin: 0; }
  .command-incident-section > summary { min-height: 44px; padding: 11px 10px; }
  .command-incident-section-body { padding: 0 10px 8px; }
  .command-incident-section-body p { margin: 5px 0; }
  .command-incident-facts { gap: 6px 8px; }
  .command-incident-section :is(th, td) { padding: 6px 4px; }

  .member-portal .portal-topbar { flex-wrap: wrap; padding: 10px 12px; gap: 6px 12px; }
  .portal-topbar .row { flex: 1 1 auto; min-width: 0; }
  .portal-topbar .portal-account { overflow-wrap: anywhere; }
  .member-portal .portal-main { padding: 16px 12px 32px; }
  .portal-intro, .portal-selector { margin-bottom: 12px; }
  .portal-record { gap: 12px; }
  .portal-record .panel-head, .portal-record .panel-body { padding: 12px; }
}
