/* Hallmark · app-screen audit · custom SPOT IT responsive adaptation · copy: verbatim
   Critique: legacy landscape placements separated the location, capture and record panels.
   Scope: tablet portrait and desktop only; existing phone styling and wiring are preserved.
   Existing brand tokens, labels and app chrome take precedence over generic style gates. */

@media (min-width: 48rem) and (max-width: 63.999rem) and (orientation: portrait) {
  html:root #inspection-view > main,
  html:root .capture-session-bar,
  html:root #log-view,
  html:root #settings-view,
  html:root #team-view {
    width: calc(100% - 48px);
    max-width: 680px;
    margin-inline: auto;
  }

  html:root #inspection-view > main { padding-inline: 0; }
  html:root .capture-session-bar { padding-inline: 0; }
  html:root #log-view,
  html:root #settings-view,
  html:root #team-view { padding-inline: 0; }
  html:root .app-tab-bar { width: 680px; max-width: 100%; }
}

@media (min-width: 64rem) {
  :root {
    --wide-shell: 1440px;
    --wide-nav-space: 208px;
    --wide-space-5: 20px;
    --wide-gutter: 32px;
    --app-nav-h: 0px;
  }

  html:root body {
    box-sizing: border-box;
    max-width: var(--wide-shell);
    margin-inline: auto;
    padding-inline-start: var(--wide-nav-space);
    padding-bottom: 0;
  }

  html:root .top-shell { margin-inline-start: calc(-1 * var(--wide-nav-space)); }
  html:root .top-shell header { padding-inline: var(--space-6); min-height: 72px; }
  html:root .top-shell .header-logo { height: 32px; max-height: 32px; }

  html:root .app-tab-bar {
    top: calc(var(--app-header-h, 72px) + 24px);
    bottom: auto;
    left: max(24px, calc((100% - var(--wide-shell)) / 2 + 24px));
    transform: none;
    width: 160px;
    max-width: none;
    height: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
    padding: var(--space-2);
    border: 1px solid var(--ds-border);
    border-radius: var(--radius-card);
    background: var(--ds-card);
    box-shadow: none;
  }

  html:root .app-tab-bar .app-tab-btn {
    min-height: 52px;
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-control);
    font: 600 14px/1.3 var(--font-ui);
    color: var(--ds-fg-muted);
  }

  html:root .app-tab-bar .app-tab-btn svg { width: 20px; height: 20px; }
  html:root .app-tab-bar .app-tab-btn.active,
  html:root .app-tab-bar #settings-tab.active { background: var(--ds-muted); color: var(--ds-fg); }
  html:root .app-tab-bar .app-tab-btn.active::after {
    top: 14px;
    bottom: 14px;
    left: 0;
    right: auto;
    width: 3px;
    height: auto;
    background: var(--ds-primary);
  }
  html:root .app-tab-bar .app-tab-btn:focus-visible { outline: 2px solid var(--ds-secondary); outline-offset: 2px; }

  html:root .capture-session-bar {
    width: calc(100% - 2 * var(--wide-gutter));
    max-width: 1200px;
    margin: var(--space-6) auto var(--wide-space-5);
    padding: 0;
  }

  html:root #inspection-view > main {
    box-sizing: border-box;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, .38fr);
    grid-template-rows: auto auto;
    grid-template-areas: "location recent" "capture recent";
    align-items: start;
    gap: var(--space-6);
    width: calc(100% - 2 * var(--wide-gutter));
    max-width: 1200px;
    margin: 0 auto 40px;
    padding: 0;
  }

  html:root #inspection-view > main > #instrument-panel {
    grid-area: location;
    display: block;
    width: 100%;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
  }

  html:root #inspection-view #instrument-panel .instrument-head { padding: var(--wide-space-5) var(--wide-space-5) var(--space-1); }
  html:root #inspection-view #instrument-panel .instrument-main { padding-inline: var(--wide-space-5); }
  html:root #inspection-view #instrument-panel .kmvalue { font-size: 44px; }
  html:root #inspection-view #instrument-panel .instrument-foot { overflow-wrap: anywhere; }

  html:root #inspection-view > main > #defect-section {
    grid-area: capture;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--wide-space-5);
    margin: 0;
    min-width: 0;
  }
  html:root #inspection-view #defect-section .defect-focus-bar,
  html:root #inspection-view #defect-section .defect-gate { grid-column: 1 / -1; margin: 0; }
  html:root #inspection-view #defect-section .defect-category { min-width: 0; margin: 0; }
  html:root #inspection-view #defect-section .category-label { margin: 0 0 var(--space-3); }
  html:root #inspection-view > main > .lane-divider { display: none; }

  html:root #inspection-view > main > #log-host-inspection {
    grid-area: recent;
    position: sticky;
    top: calc(var(--app-header-h, 72px) + 24px);
    align-self: start;
    width: 100%;
    min-width: 0;
    margin: 0;
  }
  html:root #inspection-view #log-host-inspection #log-register { margin: 0; width: 100%; }
  html:root #inspection-view .inspection-record-list .log-empty { padding: var(--space-6) var(--space-4); }

  html:root #log-view,
  html:root #team-view,
  html:root #settings-view {
    box-sizing: border-box;
    width: calc(100% - 2 * var(--wide-gutter));
    max-width: 1200px;
    margin: var(--space-6) auto 40px;
    padding: 0;
    min-width: 0;
  }
  html:root #log-view .register-scopes { max-width: 600px; }
  html:root #log-view .register-search { max-width: 720px; }
  html:root #log-view .inspection-record-list { grid-template-columns: minmax(0, 1fr); }
  html:root #log-view .team-inspector-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html:root #log-view .register-toolbar { align-items: center; }
  html:root #log-view .register-result { flex: 1; }
  html:root #log-view .register-filter-chips { flex-wrap: wrap; }

  html:root #team-view { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--wide-space-5); align-items: start; }
  html:root #team-view .team-heading,
  html:root #team-view .team-account-card,
  html:root #team-view [aria-labelledby="team-permissions-title"] { grid-column: 1 / -1; }
  html:root #team-view .team-heading { margin: 0; }
  html:root #team-view .team-card { margin: 0; padding: var(--wide-space-5); }

  html:root #settings-view #more-home { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-6); align-items: start; }
  html:root #settings-view #more-home > .ds-view-head { grid-column: 1 / -1; }
  html:root #settings-view .more-group { min-width: 0; margin: 0; }
  html:root #settings-view .more-screen { max-width: 820px; }

  html:root #map-view {
    position: fixed;
    top: var(--app-header-h, 72px);
    bottom: 0;
    left: max(var(--wide-nav-space), calc((100% - var(--wide-shell)) / 2 + var(--wide-nav-space)));
    right: max(0px, calc((100% - var(--wide-shell)) / 2));
    width: auto;
    max-width: none;
    height: auto;
    margin: 0;
    padding: 0;
    min-width: 0;
  }
}

@media (min-width: 80rem) {
  html:root #inspection-view > main > #defect-section:not(.focused) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html:root #log-view .team-inspector-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
