:root {
  color-scheme: light dark;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --text: #17202b;
  --muted: #667487;
  --border: #d6dde7;
  --primary: #0f5bd7;
  --primary-strong: #0a46aa;
  --primary-text: #ffffff;
  --danger: #b3261e;
  --danger-soft: #fff1f0;
  --camera: #141b23;
  --shadow: 0 16px 42px rgba(34, 46, 62, 0.13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
}

.screen { min-height: 100vh; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(18px + env(safe-area-inset-top)) 18px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-header h1,
.app-header h2,
.report-heading h2 { margin: 0; font-weight: 650; letter-spacing: -0.02em; }
.app-header h1 { font-size: 1.45rem; }
.eyebrow { margin: 0 0 3px; color: var(--primary); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

.compact-header { padding-left: 10px; padding-right: 10px; }
.header-center { min-width: 0; text-align: center; }
.header-center h1 { font-size: 1.05rem; }
.header-center p { max-width: 190px; margin: 2px auto 0; overflow: hidden; color: var(--muted); font-size: 0.78rem; text-overflow: ellipsis; white-space: nowrap; }
.toolbar-spacer { width: 64px; }

.form-panel,
.report-actions {
  display: grid;
  gap: 14px;
  padding: 20px 16px;
}

.field { display: grid; gap: 7px; }
.field > span { font-size: 0.88rem; font-weight: 600; }
.field b { color: var(--danger); }

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}

textarea { min-height: 86px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 91, 215, 0.14); }
input::placeholder, textarea::placeholder { color: #929dac; }

.form-error,
.action-status { min-height: 20px; margin: -5px 0 0; color: var(--danger); font-size: 0.82rem; }
.action-status { color: var(--muted); text-align: center; }

.primary-button,
.secondary-button,
.danger-button,
.choice-button {
  min-height: 50px;
  padding: 11px 15px;
  border-radius: 13px;
  font-weight: 650;
  cursor: pointer;
}

.primary-button { border: 1px solid var(--primary); background: var(--primary); color: var(--primary-text); }
.primary-button:active { background: var(--primary-strong); }
.secondary-button { border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.danger-button { border: 1px solid #efc6c3; background: var(--danger-soft); color: var(--danger); }
.text-button { min-height: 44px; min-width: 64px; padding: 8px; border: 0; background: transparent; color: var(--primary); font-size: 0.86rem; font-weight: 650; cursor: pointer; }

.camera-panel { padding: 14px 12px 0; }
.camera-preview {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  max-height: 66vh;
  overflow: hidden;
  border-radius: 22px;
  background: var(--camera);
  box-shadow: var(--shadow);
}
.camera-preview img { width: 100%; height: 100%; object-fit: cover; }
.camera-placeholder { display: grid; justify-items: center; gap: 12px; color: #d8e0ea; text-align: center; }
.camera-placeholder p { margin: 0; }
.camera-mark { width: 128px; height: 92px; border: 2px solid #d8e0ea; border-radius: 16px; opacity: 0.75; }
.photo-counter { margin: 10px 2px 0; color: var(--muted); font-size: 0.84rem; text-align: center; }

.camera-actions {
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  gap: 14px;
  padding: 16px;
}
.shutter-button {
  width: 72px;
  height: 72px;
  justify-self: center;
  border: 7px solid var(--surface);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 2px var(--primary), var(--shadow);
  cursor: pointer;
}

.sheet-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  align-items: end;
  background: rgba(6, 11, 18, 0.52);
}
.bottom-sheet {
  width: min(100%, 720px);
  max-height: min(86vh, 780px);
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  box-shadow: 0 -12px 38px rgba(6, 11, 18, 0.24);
}
.sheet-handle { width: 44px; height: 5px; margin: 0 auto 14px; border-radius: 99px; background: var(--border); }
.sheet-title { margin: 0 0 14px; font-size: 1.16rem; }
.choice-list { display: grid; gap: 9px; }
.choice-button { width: 100%; border: 1px solid var(--border); background: var(--surface-soft); color: var(--text); text-align: left; }
.choice-button:active { border-color: var(--primary); background: #edf4ff; }
.choice-button.other { color: var(--primary); }
.sheet-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.sheet-actions .primary-button { flex: 1; }
.sheet-back { min-height: 48px; padding: 9px 12px; border: 0; background: transparent; color: var(--primary); font-weight: 650; cursor: pointer; }
.selection-summary { display: grid; gap: 7px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-soft); }
.selection-summary strong { font-size: 1rem; }
.selection-summary p { margin: 0; color: var(--muted); font-size: 0.87rem; }

.report-document { margin: 14px 12px; padding: 18px 14px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.report-heading { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.report-heading h2 { font-size: 1.55rem; }
.vehicle-data { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 13px 0 0; font-size: 0.84rem; }
.vehicle-data dt { color: var(--muted); }
.vehicle-data dd { margin: 0; font-weight: 600; }
.report-list { display: grid; gap: 12px; margin-top: 14px; }
.report-item { display: grid; grid-template-columns: 108px 1fr; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.report-item:last-child { padding-bottom: 0; border-bottom: 0; }
.report-photo { width: 108px; aspect-ratio: 1; border-radius: 12px; background: var(--surface-soft); object-fit: cover; }
.report-copy h3 { margin: 0 0 5px; font-size: 0.98rem; }
.report-copy p { margin: 4px 0; color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.report-copy .comment { color: var(--text); }
.item-actions { margin-top: 7px; }
.delete-item { min-height: 40px; padding: 7px 0; border: 0; background: transparent; color: var(--danger); font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.empty-report { padding: 30px 12px; color: var(--muted); text-align: center; }

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 11px 15px;
  transform: translateX(-50%);
  border-radius: 12px;
  background: #17202b;
  color: #ffffff;
  box-shadow: var(--shadow);
  font-size: 0.86rem;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151b;
    --surface: #1b222b;
    --surface-soft: #252e38;
    --text: #f2f5f8;
    --muted: #adb8c5;
    --border: #3a4653;
    --primary: #76a7ff;
    --primary-strong: #94b9ff;
    --primary-text: #07101d;
    --danger: #ffb4ab;
    --danger-soft: #45211f;
    --camera: #070a0e;
    --shadow: 0 16px 42px rgba(0, 0, 0, 0.35);
  }
  input::placeholder, textarea::placeholder { color: #8592a0; }
  .choice-button:active { background: #263a57; }
}

@media (min-width: 721px) {
  .app-shell { border-inline: 1px solid var(--border); }
  .form-panel { max-width: 560px; margin: 0 auto; }
  .camera-preview { aspect-ratio: 4 / 3; }
}

@media (max-width: 380px) {
  .report-item { grid-template-columns: 88px 1fr; gap: 10px; }
  .report-photo { width: 88px; }
  .camera-actions { grid-template-columns: 78px 1fr; gap: 10px; }
}

@media print {
  :root { color-scheme: light; --bg: #ffffff; --surface: #ffffff; --text: #111111; --muted: #555555; --border: #d6d6d6; }
  body, .app-shell, .screen { min-height: auto; background: #ffffff; }
  .screen:not(#report-screen), .no-print, .report-actions, .delete-item { display: none !important; }
  #report-screen { display: block !important; padding: 0; }
  .report-document { margin: 0; padding: 0; border-radius: 0; box-shadow: none; }
  .report-item { break-inside: avoid; }
  .report-photo { print-color-adjust: exact; }
}
