:root {
  --red: #c41e1a;
  --red-dark: #991b18;
  --ink: #151515;
  --muted: #68686d;
  --line: #dedee2;
  --surface: #ffffff;
  --surface-alt: #f5f5f7;
  --success: #237a45;
  --warning: #a55a05;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  color: var(--ink);
  background: var(--surface-alt);
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
}

.brand, .header-actions, .review-actions, .photo-meta {
  display: flex;
  align-items: center;
}

.brand { gap: 12px; }
.brand img { width: 48px; height: 48px; object-fit: contain; }
.brand h1 { margin: 0; font-size: 20px; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.header-actions { justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.guide-link { display: inline-flex; align-items: center; justify-content: center; }

.sync-status-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 700;
}
.sync-status-dot { width: 9px; height: 9px; border-radius: 50%; background: #98989e; }
.sync-status-button[data-state="saved"] .sync-status-dot { background: var(--success); }
.sync-status-button[data-state="saved"] {
  border-color: transparent;
  background: transparent;
}
.sync-status-button[data-state="saved"]:hover { background: var(--surface-alt); }
.sync-status-button[data-state="syncing"] .sync-status-dot { background: #2f6fbd; animation: sync-pulse 1s infinite alternate; }
.sync-status-button[data-state="offline"] .sync-status-dot { background: var(--warning); }
.sync-status-button[data-state="error"] .sync-status-dot { background: var(--red); }
@keyframes sync-pulse { to { opacity: .35; } }

.view-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  padding: 3px;
  border-radius: 7px;
  background: #e9e9ed;
}
.view-tab {
  min-height: 34px;
  padding: 6px 14px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 750;
}
.view-tab.active { color: var(--ink); background: white; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.secondary-button, .primary-button, .add-photo-button {
  min-height: 40px;
  border-radius: 7px;
  padding: 9px 14px;
  font-weight: 700;
}

.file-button {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
}
.secondary-button:hover { border-color: #c8c8cd; background: var(--surface-alt); }

.primary-button {
  border: 1px solid var(--red);
  color: white;
  background: var(--red);
}
.primary-button:hover { background: var(--red-dark); }
.primary-button:disabled { opacity: 0.55; cursor: default; }

.delete-item-button {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #d8b0ae;
  border-radius: 7px;
  color: var(--red-dark);
  background: white;
  font-weight: 700;
}
.delete-item-button:hover { border-color: var(--red); background: #fff1f0; }

.dashboard-view {
  min-height: calc(100vh - 72px);
  padding: 30px clamp(22px, 4vw, 64px) 44px;
  background: var(--surface);
}
.dashboard-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto 26px;
}
.dashboard-kicker, .section-kicker {
  margin: 0 0 5px;
  color: var(--red);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.dashboard-heading h2 { margin: 0; font-size: 30px; }
.dashboard-date { margin: 7px 0 0; color: var(--muted); font-size: 13px; }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 1440px;
  margin: 0 auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.metric-cell { min-width: 0; padding: 22px 24px; border-right: 1px solid var(--line); }
.metric-cell:first-child { padding-left: 0; }
.metric-cell:last-child { padding-right: 0; border-right: 0; }
.metric-cell span, .metric-cell small { display: block; color: var(--muted); }
.metric-cell span { margin-bottom: 7px; font-size: 12px; font-weight: 700; }
.metric-cell strong { display: block; margin-bottom: 4px; font-size: 28px; line-height: 1.05; }
.metric-cell small { font-size: 11px; }
.attention-metric strong { color: var(--red-dark); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
  gap: 0 36px;
  max-width: 1440px;
  margin: 30px auto 0;
}
.analysis-section { min-width: 0; padding: 26px 0 30px; border-bottom: 1px solid var(--line); }
.storage-analysis { border-right: 1px solid var(--line); padding-right: 36px; }
.date-analysis { padding-left: 0; }
.exception-analysis, .concentration-analysis { grid-column: 1 / -1; padding-right: 0; border-right: 0; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.section-heading h3 { margin: 0; font-size: 19px; }
.section-stat { color: var(--red-dark); font-size: 13px; }
.exception-controls { display: flex; align-items: center; gap: 12px; }
.compact-button { min-height: 34px; padding: 6px 10px; font-size: 12px; }

.storage-profile { display: grid; gap: 18px; }
.storage-row { display: grid; gap: 7px; }
.storage-label { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.storage-label strong { font-size: 14px; }
.storage-label span { color: var(--muted); font-size: 12px; }
.bar-track { height: 12px; overflow: hidden; border-radius: 4px; background: #ededf0; }
.bar-fill { height: 100%; min-width: 2px; border-radius: 4px; background: var(--red); }
.storage-row:nth-child(2) .bar-fill { background: #56565d; }
.storage-detail { display: flex; gap: 18px; color: var(--muted); font-size: 11px; }

.summary-rows { display: grid; }
.summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid #ececef;
}
.summary-row:last-child { border-bottom: 0; }
.summary-row span { color: var(--muted); font-size: 12px; }
.summary-row strong { font-size: 17px; }
.summary-row[data-tone="danger"] strong { color: var(--red-dark); }
.summary-row[data-tone="warning"] strong { color: var(--warning); }

.table-scroll { max-width: 100%; overflow-x: auto; }
.analysis-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.analysis-table th { padding: 0 10px 10px; color: var(--muted); font-size: 10px; text-align: left; text-transform: uppercase; }
.analysis-table td { padding: 12px 10px; border-top: 1px solid #ececef; vertical-align: middle; }
.analysis-table th:first-child, .analysis-table td:first-child { padding-left: 0; }
.analysis-table th:last-child, .analysis-table td:last-child { padding-right: 0; }
.analysis-table td:nth-last-child(-n+3), .analysis-table th:nth-last-child(-n+3) { white-space: nowrap; }
.product-name { display: grid; gap: 3px; min-width: 180px; }
.product-name strong { font-size: 12px; }
.product-name span { color: var(--muted); font-size: 10px; }
.inline-bar { display: inline-block; width: 70px; height: 6px; margin-left: 8px; overflow: hidden; border-radius: 3px; background: #ededf0; vertical-align: middle; }
.inline-bar span { display: block; height: 100%; background: var(--red); }

.exception-table td:nth-child(3) { min-width: 300px; }
.priority-badge { display: inline-block; min-width: 58px; padding: 4px 6px; border-radius: 4px; text-align: center; font-size: 10px; font-weight: 800; }
.priority-badge[data-priority="High"] { color: #8f1815; background: #fde5e3; }
.priority-badge[data-priority="Medium"] { color: #8a4b02; background: #fff0d8; }
.priority-badge[data-priority="Unranked"] { color: #5f6065; background: #eeeeF1; }
.review-item-button { min-height: 30px; padding: 5px 9px; border: 1px solid #d5d5da; border-radius: 5px; color: var(--ink); background: white; font-size: 11px; font-weight: 750; }
.exception-action-group { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: max-content; }
.exception-action-button { min-height: 30px; padding: 5px 9px; border: 1px solid #d5d5da; border-radius: 5px; color: var(--ink); background: white; font-size: 11px; font-weight: 750; }
.exception-action-button.resolve-action { color: #17663b; border-color: #a9d9bd; background: #eff9f3; }
.exception-action-button.ignore-action { color: #5f6065; background: #f4f4f6; }
.exception-action-button.reopen-action { color: var(--red-dark); border-color: #e1aaa7; }
.processed-status { padding: 4px 7px; border-radius: 4px; font-size: 10px; font-weight: 800; }
.processed-status[data-status="resolved"] { color: #17663b; background: #e6f5ec; }
.processed-status[data-status="ignored"] { color: #5f6065; background: #eeeeF1; }
.empty-table-row { padding: 28px 0 !important; color: var(--success); text-align: center; }
.print-report { display: none; }

.review-shell {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

body:not(.has-data) .review-shell { grid-template-columns: 1fr; }
body:not(.has-data) .inventory-panel { display: none; }
body:not(.has-data) #downloadBackupButton,
body:not(.has-data) #exportButton { display: none; }

.empty-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.sync-dialog {
  width: min(92vw, 470px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .24);
}
.sync-dialog::backdrop { background: rgba(0, 0, 0, .42); backdrop-filter: blur(3px); }
.sync-dialog form, .conflict-dialog { padding: 24px; }
.devices-dialog { width: min(94vw, 640px); }
.devices-dialog-content { padding: 24px; }
.pairing-panel {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  margin: 0 0 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-alt);
}
.pairing-qr { display: grid; place-items: center; padding: 10px; background: white; }
.pairing-qr svg { display: block; width: 170px; height: 170px; }
.pairing-panel strong { display: block; font-size: 17px; }
.pairing-panel p { margin: 8px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.pairing-panel span { color: var(--red-dark); font-size: 13px; font-weight: 750; }
.devices-dialog .primary-button { width: 100%; }
.device-list-heading { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 8px; }
.device-list-heading .text-button { margin: 0; }
.device-list { display: grid; border-top: 1px solid var(--line); }
.device-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.device-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--red-dark); background: #f9e9e8; font-size: 24px; }
.device-row strong, .device-row span { display: block; }
.device-row strong { font-size: 13px; }
.device-row span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.device-list-empty { margin: 0; padding: 18px 0; color: var(--muted); font-size: 13px; text-align: center; }
.access-current-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-alt); }
.access-current-row span, .access-current-row strong { display: block; }
.access-current-row span { color: var(--muted); font-size: 11px; }
.access-current-row strong { margin-top: 2px; font-size: 14px; }
.access-section + .access-section { margin-top: 24px; padding-top: 2px; border-top: 1px solid var(--line); }
.add-staff-form { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: 8px; margin-bottom: 10px; }
.add-staff-form input { min-width: 0; min-height: 38px; padding: 8px 9px; }
.add-staff-form button { grid-column: 1 / -1; }
.field-help { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.sync-dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.sync-dialog-heading p { margin: 0 0 4px; color: var(--red-dark); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.sync-dialog-heading h2 { margin: 0; font-size: 24px; }
.dialog-close { width: 36px; height: 36px; padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 27px; line-height: 1; }
.sync-dialog-copy { margin: 18px 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.sync-dialog label { display: grid; gap: 7px; font-size: 13px; font-weight: 750; }
.sync-dialog form > label, .sync-dialog form > div:not(.sync-dialog-heading) { margin-top: 12px; }
.sync-dialog input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #c9c9ce; border-radius: 6px; }
.sync-dialog .primary-button { width: 100%; margin-top: 14px; }
.sync-dialog-error { min-height: 18px; margin: 8px 0 0; color: var(--red-dark); font-size: 12px; }
.conflict-actions { display: grid; gap: 9px; }
.conflict-actions .primary-button { margin-top: 0; }
.text-button { display: block; margin: 14px auto 0; padding: 6px; border: 0; color: var(--muted); background: transparent; font-weight: 700; }

@media (max-width: 700px) {
  .add-staff-form { grid-template-columns: 1fr; }
  .pairing-panel { grid-template-columns: 1fr; }
  .pairing-qr { width: min(100%, 210px); margin: 0 auto; }
}

.inventory-panel {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.inventory-tools {
  position: sticky;
  top: 72px;
  z-index: 3;
  display: grid;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.search-field input, .field-grid input, .field-grid select, .field-grid textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #c9c9ce;
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
}

.search-field input { height: 42px; padding: 0 12px; background: var(--surface-alt); }

.filter-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 3px;
  border-radius: 7px;
  background: #e9e9ed;
}

.filter-button {
  min-height: 32px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}
.filter-button.active { color: var(--ink); background: white; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.item-count { margin: 0; color: var(--muted); font-size: 12px; }
.inventory-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inventory-new-button { min-height: 34px; padding: 6px 12px; font-size: 12px; }
.inventory-new-button span { font-size: 18px; font-weight: 500; line-height: .8; }

.item-list { display: grid; }

.item-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  width: 100%;
  min-height: 82px;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid #ececef;
  text-align: left;
  color: var(--ink);
  background: var(--surface);
}
.item-row:hover { background: #fafafa; }
.item-row.selected { box-shadow: inset 4px 0 var(--red); background: #fff6f5; }
.item-row img { width: 58px; height: 58px; border-radius: 6px; object-fit: cover; background: var(--surface-alt); }
.item-row-body { display: grid; gap: 4px; min-width: 0; }
.item-row-body strong, .item-row-body span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row-body strong { font-size: 14px; }
.item-row-body span { color: var(--muted); font-size: 12px; }

.review-panel { min-width: 0; }

.empty-review {
  display: grid;
  place-items: center;
  align-content: start;
  min-height: calc(100vh - 72px);
  padding: clamp(70px, 13vh, 150px) 32px 48px;
  text-align: center;
  background: var(--surface-alt);
}
.empty-drop-zone {
  display: grid;
  justify-items: center;
  width: min(660px, 100%);
  min-height: 360px;
  padding: 46px 34px;
  border: 2px dashed #c9c9ce;
  border-radius: 8px;
  background: white;
  transition: border-color .16s ease, background .16s ease;
}
.empty-review img { width: 104px; height: 104px; object-fit: contain; }
.empty-review h2 { margin: 8px 0 8px; font-size: 28px; }
.empty-review p { margin: 0; color: var(--muted); }
.empty-kicker { margin-top: 18px !important; color: var(--red) !important; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.empty-copy { margin-bottom: 24px !important; font-size: 15px; }
.empty-review.drag-active .empty-drop-zone { border-color: var(--red); background: #fff6f5; }

.review-form { min-height: calc(100vh - 72px); background: var(--surface); }
.hidden { display: none !important; }

.review-toolbar {
  position: sticky;
  top: 72px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
}
.position-label { margin: 0 0 3px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.review-toolbar h2 { margin: 0; font-size: 20px; }
.review-actions { gap: 8px; }
.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: white;
  font-size: 28px;
  line-height: 1;
}
.icon-button:disabled { opacity: .35; cursor: default; }

.review-content {
  display: grid;
  grid-template-columns: minmax(340px, 1.05fr) minmax(380px, .95fr);
  min-height: calc(100vh - 148px);
}

.photo-workspace {
  min-width: 0;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #eeeeF1;
}

.photo-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin-bottom: 10px;
  color: #4e4e53;
  font-size: 12px;
  font-weight: 750;
}
.photo-viewer-controls { display: flex; align-items: center; gap: 6px; }
.viewer-tool {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #c9c9ce;
  border-radius: 6px;
  color: var(--ink);
  background: white;
  font-size: 20px;
  line-height: 1;
}
.viewer-tool:disabled, .zoom-control:has(input:disabled) { opacity: .35; cursor: default; }
.fit-tool { width: 42px; font-size: 12px; font-weight: 800; }
.zoom-control {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid #c9c9ce;
  border-radius: 6px;
  background: white;
  font-size: 14px;
}
.zoom-control input { width: 104px; accent-color: var(--red); }

.main-photo {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: clamp(500px, 66vh, 780px);
  overflow: hidden;
  border: 1px solid #d2d2d6;
  border-radius: 7px;
  background: #202023;
}
.main-photo.zoomed { cursor: grab; touch-action: none; }
.main-photo.dragging { cursor: grabbing; }
.main-photo img {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: none;
  max-height: none;
  transform-origin: center;
  will-change: transform;
}
.no-photo { color: #b7b7bd; font-weight: 700; }
.photo-meta { justify-content: space-between; margin: 12px 0; color: var(--muted); font-size: 12px; }
.add-photo-button { min-height: 34px; padding: 7px 10px; color: var(--red); border: 1px solid #d8b0ae; background: white; cursor: pointer; }

.photo-strip { display: flex; gap: 10px; max-width: 100%; overflow-x: auto; padding: 2px 0 10px; }
.photo-thumb-wrapper { position: relative; flex: 0 0 auto; }
.photo-thumb { width: 82px; height: 82px; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: 6px; background: white; }
.photo-thumb.active { border-color: var(--red); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: white;
  background: rgba(0,0,0,.7);
  font-size: 17px;
}

.field-workspace { min-width: 0; padding: 22px; background: var(--surface); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field-grid label { display: grid; align-content: start; gap: 6px; min-width: 0; color: #4e4e53; font-size: 12px; font-weight: 750; }
.field-grid input, .field-grid select, .field-grid textarea { padding: 10px 11px; }
.field-grid input, .field-grid select { height: 42px; }
.field-grid textarea { resize: vertical; min-height: 96px; }
.date-entry { display: grid; gap: 6px; }
.date-entry [hidden] { display: none; }
.wide-field { grid-column: 1 / -1; }
.followup-field { display: flex !important; align-items: center; min-height: 42px; padding-top: 21px; }
.followup-field input { width: 18px; height: 18px; }

.audit-details { display: grid; gap: 8px; margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.audit-details div { display: grid; grid-template-columns: 120px 1fr; gap: 12px; }
.audit-details dt { color: var(--muted); font-size: 12px; }
.audit-details dd { margin: 0; font-size: 12px; font-weight: 650; }

.photo-dialog { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; padding: 0; border: 0; background: #090909; }
.photo-dialog::backdrop { background: #090909; }
.photo-dialog img { width: 100%; height: 100%; object-fit: contain; }
.viewer-close { position: fixed; top: 18px; right: 18px; z-index: 2; width: 44px; height: 44px; border: 0; border-radius: 50%; color: white; background: rgba(40,40,40,.8); font-size: 28px; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; translate: -50% 20px; padding: 10px 16px; border-radius: 7px; color: white; background: #222; opacity: 0; pointer-events: none; transition: .18s ease; }
.toast.visible { translate: -50% 0; opacity: 1; }
.toast.error { background: var(--red-dark); }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 1050px) {
  .app-header { flex-wrap: wrap; }
  .view-tabs { order: 3; width: 100%; }
  .dashboard-view { min-height: calc(100vh - 116px); }
  .metric-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .storage-analysis { padding-right: 0; border-right: 0; }
  .exception-analysis, .concentration-analysis { grid-column: auto; }
  .review-shell { grid-template-columns: 300px minmax(0, 1fr); }
  .review-content { grid-template-columns: 1fr; }
  .photo-workspace { border-right: 0; border-bottom: 1px solid var(--line); }
  .main-photo { height: min(66vh, 620px); }
}

@media (max-width: 720px) {
  .app-header { position: static; padding: 10px 14px; }
  .brand h1, .brand p, #exportButton { display: none; }
  .header-actions { gap: 6px; }
  .header-actions #downloadBackupButton { margin-left: 0; }
  .header-actions .secondary-button, .header-actions .primary-button { min-height: 36px; padding: 7px 9px; font-size: 12px; }
  .dashboard-view { padding: 22px 14px 36px; }
  .dashboard-heading { align-items: flex-start; flex-direction: column; }
  .dashboard-heading h2 { font-size: 25px; }
  .metric-strip { grid-template-columns: 1fr; }
  .metric-cell, .metric-cell:first-child, .metric-cell:nth-child(3), .metric-cell:last-child { padding: 17px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .metric-cell:last-child { border-bottom: 0; }
  .exception-table td:nth-child(3) { min-width: 230px; }
  .exception-heading { align-items: flex-start; flex-direction: column; }
  .review-shell { grid-template-columns: 1fr; }
  .inventory-panel { border-right: 0; }
  .inventory-tools { position: static; }
  .review-toolbar { top: 0; padding: 10px 14px; }
  .review-actions .icon-button { display: none; }
  .delete-item-button { min-height: 36px; padding: 7px 9px; font-size: 12px; }
  .review-content { min-height: 0; }
  .photo-workspace, .field-workspace { padding: 14px; }
  .main-photo { height: min(62vh, 480px); }
  .photo-viewer-toolbar { align-items: flex-start; flex-direction: column; }
  .photo-viewer-controls { width: 100%; }
  .zoom-control { flex: 1; }
  .zoom-control input { width: 100%; }
  .field-grid { grid-template-columns: 1fr; }
  .wide-field { grid-column: auto; }
  .followup-field { padding-top: 0; }
  .empty-review { padding: 28px 14px; }
  .empty-drop-zone { min-height: 330px; padding: 36px 20px; }
  .pairing-panel { grid-template-columns: 1fr; text-align: center; }
}

@media print {
  @page { size: Letter portrait; margin: 0.5in 0.52in 0.55in; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  html, body { color: #171717; background: white !important; }
  body > :not(#printReport) { display: none !important; }
  #printReport { display: block !important; font-family: Arial, Helvetica, sans-serif; }
  .print-report-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; border-bottom: 3px solid var(--red); }
  .print-report-brand { display: flex; align-items: center; gap: 12px; }
  .print-report-brand img { width: 56px; height: 56px; object-fit: contain; }
  .print-report-brand p, .print-section-heading p { margin: 0 0 3px; color: var(--red-dark); font-size: 8px; font-weight: 800; text-transform: uppercase; }
  .print-report-brand h1 { margin: 0; font-size: 23px; }
  .print-report-id { display: grid; gap: 3px; text-align: right; }
  .print-report-id span, .print-report-meta span { color: #68686d; font-size: 8px; text-transform: uppercase; }
  .print-report-id strong { font-size: 11px; }
  .print-report-meta { display: grid; grid-template-columns: .85fr .85fr 1.3fr; margin: 12px 0 22px; border: 1px solid #d8d8dc; }
  .print-report-meta div { display: grid; gap: 4px; min-width: 0; padding: 8px 10px; border-right: 1px solid #d8d8dc; }
  .print-report-meta div:last-child { border-right: 0; }
  .print-report-meta strong { overflow: hidden; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
  .print-section { break-inside: avoid; margin: 0 0 22px; }
  .print-section-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; }
  .print-section-heading > span { display: grid; place-items: center; width: 27px; height: 27px; color: white; background: var(--red); font-size: 10px; font-weight: 800; }
  .print-section-heading h2 { margin: 0; font-size: 15px; }
  .print-section-heading.compact > span { width: 24px; height: 24px; }
  .print-section-heading.compact h2 { font-size: 13px; }
  .print-report-metrics { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid #bfc0c4; border-bottom: 1px solid #bfc0c4; }
  .print-report-metrics div { display: grid; gap: 4px; padding: 12px; border-right: 1px solid #d8d8dc; }
  .print-report-metrics div:last-child { border-right: 0; }
  .print-report-metrics span, .print-report-metrics small { color: #68686d; font-size: 8px; }
  .print-report-metrics strong { font-size: 18px; }
  .print-report-columns { display: grid; grid-template-columns: 1.1fr .9fr; gap: 24px; }
  .print-table { width: 100%; border-collapse: collapse; font-size: 8px; }
  .print-table thead { display: table-header-group; }
  .print-table th { padding: 6px; color: white; background: #3b3b3f; font-size: 7px; text-align: left; text-transform: uppercase; }
  .print-table td { padding: 7px 6px; border-bottom: 1px solid #dedee2; vertical-align: top; white-space: pre-line; }
  .print-table tr { break-inside: avoid; }
  .print-table td:not(:first-child), .print-table th:not(:first-child) { text-align: right; }
  .print-check-table td:first-child { width: 65%; }
  .print-findings { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 24px; margin: 0; padding: 0; list-style: none; counter-reset: finding; }
  .print-findings li { position: relative; min-height: 42px; padding: 8px 8px 8px 30px; border-top: 1px solid #dedee2; font-size: 9px; line-height: 1.4; counter-increment: finding; }
  .print-findings li::before { content: counter(finding); position: absolute; left: 0; top: 7px; display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--red); color: var(--red-dark); font-size: 8px; font-weight: 800; }
  .print-action-section { break-before: page; break-inside: auto; margin-top: 0; }
  .print-action-count { margin-left: auto; color: var(--red-dark); font-size: 9px; }
  .print-action-table { font-size: 7px; }
  .print-action-table th:nth-child(1) { width: 7%; }
  .print-action-table th:nth-child(2) { width: 17%; }
  .print-action-table th:nth-child(3) { width: 39%; }
  .print-action-table th:nth-child(4) { width: 5%; }
  .print-action-table th:nth-child(5) { width: 9%; }
  .print-action-table th:nth-child(6) { width: 23%; }
  .print-action-table td:not(:first-child), .print-action-table th:not(:first-child) { text-align: left; }
  .print-action-table td:nth-child(4) { text-align: right; }
  .print-action-table tr[data-priority="High"] td:first-child { color: #8f1815; background: #fde5e3; font-weight: 800; }
  .print-inventory-section { break-before: page; break-inside: auto; margin-top: 0; }
  .print-inventory-table { table-layout: fixed; font-size: 6.5px; }
  .print-inventory-table th { padding: 5px 4px; font-size: 6px; }
  .print-inventory-table td { padding: 5px 4px; line-height: 1.25; overflow-wrap: anywhere; }
  .print-inventory-table th:nth-child(1) { width: 24%; }
  .print-inventory-table th:nth-child(2) { width: 12%; }
  .print-inventory-table th:nth-child(3) { width: 10%; }
  .print-inventory-table th:nth-child(4) { width: 5%; }
  .print-inventory-table th:nth-child(5) { width: 6%; }
  .print-inventory-table th:nth-child(6) { width: 12%; }
  .print-inventory-table th:nth-child(7) { width: 15%; }
  .print-inventory-table th:nth-child(8) { width: 9%; }
  .print-inventory-table td:not(:first-child), .print-inventory-table th:not(:first-child) { text-align: left; }
  .print-inventory-table td:nth-child(4), .print-inventory-table th:nth-child(4),
  .print-inventory-table td:nth-child(5), .print-inventory-table th:nth-child(5) { text-align: right; }
  .print-inventory-table tr[data-review-status="open"] td:last-child { color: #8f1815; font-weight: 800; }
  .print-inventory-table tr[data-review-status="resolved"] td:last-child { color: #17663b; font-weight: 800; }
  .print-inventory-table tr[data-review-status="ignored"] td:last-child { color: #5f6065; font-weight: 800; }
  .print-approval { break-inside: avoid; margin-top: 22px; padding-top: 13px; border-top: 2px solid #3b3b3f; }
  .print-approval h2 { margin: 0 0 10px; font-size: 13px; }
  .print-review-status { display: flex; gap: 24px; margin-bottom: 20px; font-size: 8px; }
  .print-review-status span { display: flex; align-items: center; gap: 6px; }
  .print-review-status i { display: block; width: 12px; height: 12px; border: 1px solid #555; }
  .print-signatures { display: grid; grid-template-columns: 1.4fr .8fr 1fr; gap: 18px; }
  .print-signatures div { height: 28px; border-bottom: 1px solid #555; }
  .print-signatures span, .print-notes-lines span { color: #68686d; font-size: 7px; text-transform: uppercase; }
  .print-notes-lines { height: 58px; margin-top: 14px; border-bottom: 1px solid #aaa; background: repeating-linear-gradient(to bottom, transparent 0, transparent 18px, #dedee2 19px); }
}
