/* Mobile-first: base = phone, min-width = tablet/desktop */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #d8dee9;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --touch: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
}

.offline-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  padding-top: calc(0.6rem + var(--safe-top));
  background: #fef3c7;
  color: #92400e;
  font-size: 0.9rem;
  font-weight: 600;
  border-bottom: 1px solid #fcd34d;
}

.offline-banner[hidden] {
  display: none !important;
}

.btn-light {
  background: #fff;
  color: #92400e;
  border: 1px solid #fcd34d;
}

/* —— Header & nav —— */
.site-header {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: #fff;
  padding: 1rem 0.75rem 0;
  padding-top: calc(1rem + var(--safe-top));
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 0.25rem;
}

.site-header h1 {
  margin: 0 0 0.2rem;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.tagline {
  margin: 0;
  opacity: 0.85;
  font-size: 0.8rem;
  line-height: 1.35;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  max-width: 960px;
  margin: 1rem auto 0;
  padding: 0 0.25rem;
}

.tab {
  flex: 1;
  min-height: var(--touch);
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 0.5rem 0.5rem;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.25);
}

.tab.active {
  background: var(--bg);
  color: var(--text);
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 0.75rem calc(5rem + var(--safe-bottom));
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  color: #0f172a;
}

.hint,
.empty-state {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0 0 0.85rem;
}

/* —— Grids: single column on phone —— */
.grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}

.grid-2,
.grid-3 {
  grid-template-columns: 1fr;
}

.span-2 {
  grid-column: span 1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
}

.required {
  color: var(--danger);
}

input,
textarea,
select {
  font: inherit;
  font-size: 16px;
  min-height: var(--touch);
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  width: 100%;
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.checklist {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.check-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  align-items: stretch;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  transition: opacity 0.15s, border-color 0.15s;
}

.check-row .item-name {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}

.status-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.status-option {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  min-height: var(--touch);
}

.status-option input {
  margin: 0;
  min-height: auto;
  accent-color: var(--primary);
}

.item-note {
  grid-column: 1 / -1;
  margin-top: 0.25rem;
}

.item-note input {
  width: 100%;
  font-weight: 400;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.form-actions .btn {
  width: 100%;
}

.form-actions .toggle-filter {
  width: 100%;
  justify-content: flex-start;
}

.btn {
  font: inherit;
  font-weight: 600;
  min-height: var(--touch);
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-sm {
  min-height: 38px;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

.message {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-weight: 500;
}

.message.success {
  background: #d1fae5;
  color: #065f46;
}

.message.error {
  background: #fee2e2;
  color: #991b1b;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.history-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.history-item:hover {
  border-color: var(--primary);
  background: #eff6ff;
}

.history-item .meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.history-item .vehicle {
  font-weight: 700;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-s {
  background: #d1fae5;
  color: #065f46;
}

.badge-nr {
  background: #fee2e2;
  color: #991b1b;
}

.badge-c {
  background: #dbeafe;
  color: #1e40af;
}

.badge-nc {
  background: #fef3c7;
  color: #92400e;
}

.detail-panel {
  margin-top: 1rem;
}

.detail-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.detail-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.detail-grid dt {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-grid dd {
  margin: 0.15rem 0 0;
  font-weight: 600;
}

.detail-items {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.detail-items th,
.detail-items td {
  text-align: left;
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.detail-items th {
  background: #f1f5f9;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-notes {
  margin-top: 1rem;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 0.9rem;
}

.detail-notes h3 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.signature-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
  width: 100%;
}

#signature-pad {
  width: 100%;
  max-width: none;
  height: 160px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}

.photo-preview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.photo-thumb {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.photo-thumb img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.photo-thumb input,
.photo-thumb select {
  font-size: 0.8rem;
  min-height: 38px;
}

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.photo-gallery img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.photo-gallery figcaption {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.detail-photos h3,
.detail-signature h3,
.detail-section-title {
  margin: 1rem 0 0.5rem;
  font-size: 0.95rem;
}

.detail-signature img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.detail-actions .btn {
  width: 100%;
}

.unit-badge {
  display: inline-block;
  background: #dbeafe;
  color: #1e40af;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.35rem;
}

#photo-input {
  margin-top: 0.25rem;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.25rem;
  padding: 0 0.25rem;
}

.admin-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.admin-table th {
  background: #f1f5f9;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
}

.admin-table .admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.row-inactive {
  opacity: 0.65;
  background: #f8fafc;
}

.site-footer {
  text-align: center;
  padding: 1rem 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
}

/* —— Form progress & sections —— */
.form-progress {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 0.5rem 0.65rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  position: sticky;
  top: var(--safe-top);
  z-index: 20;
  box-shadow: var(--shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.form-progress::-webkit-scrollbar {
  display: none;
}

.progress-step {
  flex: 0 0 auto;
  min-width: 4.25rem;
  border: none;
  background: transparent;
  padding: 0.5rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
}

.progress-step.active {
  background: #eff6ff;
  color: var(--primary);
}

.progress-step.done .prog-dot {
  background: var(--success);
}

.progress-step.partial .prog-dot {
  background: var(--warning);
}

.prog-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
}

.section-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.section-head h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.section-tools {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
}

.section-tools .btn {
  width: 100%;
}

.progress-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  background: #e2e8f0;
  border-radius: 999px;
  color: #475569;
  align-self: flex-start;
}

.toggle-filter {
  font-size: 0.875rem;
  font-weight: 500;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  min-height: var(--touch);
}

.toggle-filter input {
  width: auto;
  min-height: auto;
}

.vehicle-context {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.context-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.fleet-hint {
  margin-top: 0.5rem;
  margin-bottom: 0;
  font-size: 0.8rem;
  line-height: 1.4;
}

.context-label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
}

.inline-alert {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.inline-alert.warn {
  background: #fef3c7;
  color: #92400e;
}

.inline-alert.ok {
  background: #ecfdf5;
  color: #065f46;
}

.text-warn {
  color: var(--warning);
}

.check-row.row-pass {
  border-color: #a7f3d0;
  background: #f0fdf4;
}

.check-row.row-fail {
  border-color: #fecaca;
  background: #fef2f2;
}

.check-row.row-warn {
  border-color: #fde68a;
  background: #fffbeb;
}

.check-row.hidden-row {
  display: none;
}

.checklist.filter-issues .check-row:not(.row-fail):not(.row-warn) {
  display: none;
}

.status-pills {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
}

.status-pill {
  cursor: pointer;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.55rem 0.5rem;
  text-align: center;
  min-height: var(--touch);
  transition: all 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.status-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  min-height: 0;
}

.status-pill span {
  display: block;
  font-weight: 800;
  font-size: 1rem;
}

.status-pill small {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
}

.status-pill:has(input:checked) {
  border-color: var(--primary);
  background: #eff6ff;
}

.status-pill-s:has(input:checked) {
  border-color: #34d399;
  background: #ecfdf5;
}

.status-pill-nr:has(input:checked) {
  border-color: #f87171;
  background: #fef2f2;
}

.status-pill-c:has(input:checked) {
  border-color: #60a5fa;
  background: #eff6ff;
}

.status-pill-nc:has(input:checked) {
  border-color: #fbbf24;
  background: #fffbeb;
}

.snippet-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.snippet-label {
  width: 100%;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.snippet-chip {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  min-height: 38px;
  -webkit-tap-highlight-color: transparent;
}

.snippet-chip:hover {
  background: #e2e8f0;
}

.char-count {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.photo-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 1.25rem 1rem;
  text-align: center;
  background: #f8fafc;
  transition: border-color 0.15s, background 0.15s;
}

.photo-dropzone p {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.photo-dropzone .btn {
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}

.photo-type-select {
  font-size: 0.78rem;
}

.certify-check {
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
  min-height: var(--touch);
}

.certify-check input {
  width: 1.25rem;
  height: 1.25rem;
  min-height: auto;
  flex-shrink: 0;
}

.signature-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.sticky-actions {
  position: fixed;
  left: var(--safe-left);
  right: var(--safe-right);
  bottom: 0;
  margin: 0;
  padding: 0.75rem;
  padding-bottom: calc(0.75rem + var(--safe-bottom));
  background: linear-gradient(transparent 0%, var(--bg) 18%, var(--bg) 100%);
  z-index: 30;
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
}

.sticky-actions .btn {
  width: 100%;
}

.btn-lg {
  padding: 0.9rem 1.25rem;
  font-size: 1.05rem;
}

.review-modal {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 520px;
  width: calc(100% - 1.5rem);
  margin: auto;
  max-height: calc(100dvh - 2rem - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
}

.review-modal::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

.review-modal-inner {
  padding: 1.25rem;
}

.review-modal-inner .form-actions {
  position: static;
  box-shadow: none;
  padding: 0;
}

.review-dl {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.review-dl dt {
  font-size: 0.75rem;
  color: var(--muted);
}

.review-issues {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-card.stat-warn {
  border-color: #fcd34d;
  background: #fffbeb;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.history-item.has-issues {
  border-left: 4px solid var(--danger);
}

.history-main {
  flex: 1;
  width: 100%;
}

.history-badges {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.35rem;
}

.issue-count-badge {
  background: #fee2e2;
  color: #991b1b;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.pass-badge {
  background: #d1fae5;
  color: #065f46;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.detail-alert-banner {
  background: #fef2f2;
  color: #991b1b;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  font-weight: 700;
  margin-bottom: 1rem;
}

.row-fail-table {
  background: #fff5f5;
}

.gallery-img {
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-top: calc(1rem + var(--safe-top));
  padding-bottom: calc(1rem + var(--safe-bottom));
}

.lightbox[hidden] {
  display: none !important;
}

.lightbox img {
  max-width: 100%;
  max-height: 85dvh;
  border-radius: 8px;
}

.lightbox img:not([src]),
.lightbox img[src=""] {
  display: none;
}

.lightbox-close {
  position: absolute;
  top: calc(1rem + var(--safe-top));
  right: calc(1rem + var(--safe-right));
  background: #fff;
  border: none;
  width: var(--touch);
  height: var(--touch);
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.search-input {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.vin-cell {
  font-size: 0.75rem;
}

.pending-queue-panel {
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.pending-list {
  margin: 0;
  padding-left: 1.25rem;
}

.filters-card .form-actions .btn,
.filters-card .form-actions #export-csv {
  width: 100%;
}

#export-csv {
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* —— Tablet —— */
@media (min-width: 480px) {
  .site-header h1 {
    font-size: 1.4rem;
  }

  .tagline {
    font-size: 0.9rem;
  }

  .stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }

  .stat-value {
    font-size: 1.75rem;
  }

  .status-pills {
    display: flex;
    flex-wrap: wrap;
  }

  .status-pill {
    flex: 1;
    min-width: 4.5rem;
  }

  .photo-preview,
  .photo-gallery {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* —— Small desktop / large tablet —— */
@media (min-width: 640px) {
  .site-header {
    padding: 1.5rem 1rem 0;
    padding-top: calc(1.5rem + var(--safe-top));
  }

  .site-header h1 {
    font-size: 1.6rem;
  }

  .container {
    padding: 1.5rem 1rem 3rem;
  }

  .card {
    padding: 1.25rem 1.5rem;
  }

  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .span-2 {
    grid-column: span 2;
  }

  .history-item {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }

  .history-badges {
    flex-direction: column;
    align-items: flex-end;
    flex-wrap: nowrap;
  }

  .detail-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .detail-actions {
    flex-direction: row;
    width: auto;
  }

  .detail-actions .btn {
    width: auto;
  }

  .form-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .form-actions .btn {
    width: auto;
  }

  .form-actions .toggle-filter {
    width: auto;
  }

  .filters-card .form-actions .btn,
  .filters-card .form-actions #export-csv {
    width: auto;
  }

  .section-head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .section-tools {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    width: auto;
  }

  .section-tools .btn {
    width: auto;
  }

  .snippet-label {
    width: auto;
  }

  .sticky-actions {
    position: sticky;
    left: auto;
    right: auto;
    bottom: 0;
    padding: 1rem 0 0.5rem;
    box-shadow: none;
    background: linear-gradient(transparent, var(--bg) 12%);
  }

  .sticky-actions .btn {
    width: auto;
  }

  .progress-step {
    flex: 1;
    min-width: 4.5rem;
    font-size: 0.72rem;
  }

  .form-progress {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .search-input {
    min-width: 200px;
    max-width: 280px;
    width: auto;
  }

  .photo-dropzone .btn {
    width: auto;
  }
}

/* —— Desktop —— */
@media (min-width: 768px) {
  .detail-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .context-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  #signature-pad {
    max-width: 500px;
    height: 140px;
  }

  .signature-wrap {
    align-items: flex-start;
  }
}

@media print {
  .site-header,
  .tabs,
  .form-progress,
  .filters-card,
  .detail-actions,
  .offline-banner,
  .site-footer,
  .sticky-actions {
    display: none !important;
  }

  .container {
    padding-bottom: 1rem;
  }

  .detail-panel {
    box-shadow: none;
    border: none;
  }
}
