:root {
  color-scheme: light;
  --ink: #14213d;
  --muted: #5c667a;
  --line: #d9deea;
  --paper: #ffffff;
  --soft: #f5f7fb;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --gold: #b7791f;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #eef4f8 0%, #ffffff 42%);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 32px;
  display: grid;
  gap: 18px;
}

.capture-panel,
.ledger-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(20, 33, 61, 0.08);
  padding: 18px;
}

.brand-row,
.ledger-toolbar,
.item-heading,
.item-meta,
.item-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-row,
.ledger-toolbar {
  justify-content: space-between;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2rem, 12vw, 4.7rem);
}

h2 {
  font-size: 1.35rem;
}

.total-pill {
  min-width: 104px;
  border: 1px solid #c7b06a;
  border-radius: 8px;
  background: #fff8e7;
  padding: 10px 12px;
  text-align: right;
}

.total-pill span,
.status-text,
.empty-state,
.confidence {
  color: var(--muted);
  font-size: 0.9rem;
}

.total-pill strong {
  display: block;
  color: var(--gold);
  font-size: 1.25rem;
}

.capture-form {
  display: grid;
  gap: 12px;
}

.file-input {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.camera-drop {
  position: relative;
  min-height: 280px;
  border: 1px dashed #8ba4a0;
  border-radius: 8px;
  background: #eef7f5;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
}

.camera-drop img {
  width: 100%;
  height: 100%;
  max-height: 440px;
  object-fit: contain;
  background: #111827;
  pointer-events: none;
}

.webcam-video {
  width: 100%;
  height: 100%;
  max-height: 440px;
  object-fit: contain;
  background: #111827;
  pointer-events: none;
}

#cameraPlaceholder {
  color: var(--accent-dark);
  font-weight: 800;
}

.photo-button {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  min-width: 132px;
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(15, 118, 110, 0.22);
  z-index: 2;
}

.webcam-controls {
  display: block;
}

.webcam-controls .secondary-button {
  width: 100%;
}

.webcam-capture-controls {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  z-index: 3;
  pointer-events: auto;
}

.notes-label {
  font-weight: 800;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  padding: 10px 12px;
}

textarea:focus,
input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 2px;
}

.primary-button,
.secondary-button,
.delete-button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  font-weight: 850;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 0 12px;
}

.delete-button {
  margin-left: auto;
  background: #fff1f0;
  color: var(--danger);
  padding: 0 12px;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 28px 16px;
  text-align: center;
}

.ledger-list {
  display: grid;
  gap: 12px;
}

.item-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 10px;
}

.item-image {
  width: 96px;
  height: 96px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--soft);
}

.item-body {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.item-name {
  font-weight: 850;
}

.item-value {
  max-width: 120px;
  text-align: right;
}

.item-meta {
  flex-wrap: wrap;
}

.item-meta select {
  width: auto;
  min-width: 130px;
}

.evidence-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-text {
  min-height: 1.25rem;
  margin: 0;
}

@media (min-width: 860px) {
  .app-shell {
    grid-template-columns: 0.9fr 1.1fr;
    align-items: start;
    padding-top: 28px;
  }

  .capture-panel {
    position: sticky;
    top: 18px;
  }
}

@media (max-width: 560px) {
  .brand-row,
  .ledger-toolbar {
    align-items: flex-start;
  }

  .toolbar-actions {
    width: 100%;
  }

  .ledger-toolbar {
    flex-direction: column;
  }

  .secondary-button {
    flex: 1;
  }

  .webcam-capture-controls {
    grid-template-columns: 1fr;
  }

  .item-card {
    grid-template-columns: 82px 1fr;
  }

  .item-image {
    width: 82px;
    height: 82px;
  }

  .item-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .item-value {
    max-width: none;
    text-align: left;
  }
}
