:root {
  color-scheme: light;
  --bg: #f6f3ed;
  --surface: #fffdf8;
  --surface-strong: #eef7f1;
  --ink: #17201d;
  --muted: #63706b;
  --line: #d9ddd4;
  --brand: #166f6b;
  --brand-dark: #0d4e4c;
  --accent: #bd4b2f;
  --gold: #d39d28;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 18px clamp(16px, 4vw, 42px);
  position: sticky;
  top: 0;
  z-index: 3;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1rem;
}

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

.header-actions,
.form-actions,
.dialog-title {
  align-items: center;
  display: flex;
  gap: 10px;
}

.dialog-title {
  justify-content: space-between;
}

.icon-button {
  align-items: center;
  background: #edf4f0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  display: inline-flex;
  height: 42px;
  justify-content: center;
  min-width: 42px;
  padding: 0 12px;
}

.primary-button,
.secondary-button {
  border-radius: var(--radius);
  border: 1px solid transparent;
  min-height: 42px;
  padding: 0 16px;
}

.primary-button {
  background: var(--brand);
  color: white;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--brand-dark);
}

.secondary-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.app-shell {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.3fr) minmax(290px, 0.7fr);
  padding: 18px clamp(16px, 4vw, 42px) 42px;
}

.capture-panel,
.status-panel,
.dashboard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.capture-panel {
  display: grid;
  gap: 18px;
}

.panel-copy p:last-child {
  color: var(--muted);
  margin-top: 6px;
  max-width: 62ch;
}

.capture-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1.2fr);
}

.capture-target {
  align-items: center;
  background: var(--surface-strong);
  border: 1px dashed var(--brand);
  border-radius: var(--radius);
  color: var(--brand-dark);
  display: flex;
  flex-direction: column;
  font-weight: 800;
  gap: 12px;
  justify-content: center;
  min-height: 250px;
  padding: 20px;
  text-align: center;
}

.capture-target input {
  inline-size: 1px;
  opacity: 0;
  position: absolute;
}

.capture-icon {
  align-items: center;
  border: 2px solid currentColor;
  border-radius: var(--radius);
  display: inline-flex;
  font-size: 2rem;
  height: 72px;
  justify-content: center;
  width: 72px;
}

.preview-frame {
  align-items: center;
  background: #202826;
  border-radius: var(--radius);
  display: flex;
  justify-content: center;
  min-height: 250px;
  overflow: hidden;
}

.preview-frame img {
  display: block;
  max-height: 390px;
  max-width: 100%;
  object-fit: contain;
}

.empty-preview {
  color: #e9ede8;
}

.review-form,
.settings-form {
  display: grid;
  gap: 14px;
}

.field-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  min-height: 42px;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.status-panel {
  align-self: start;
  display: grid;
  gap: 14px;
}

.status-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.status-list li {
  background: #f5f7f4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.muted {
  color: var(--muted);
}

.dashboard {
  display: grid;
  gap: 18px;
  grid-column: 1 / -1;
}

.dashboard-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.report-shell {
  background: var(--surface);
  color: var(--ink);
  min-height: 100vh;
  padding: 24px clamp(16px, 4vw, 42px) 48px;
}

.report-toolbar {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-bottom: 18px;
}

.report-content {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0 auto;
  max-width: 980px;
  padding: 28px;
}

.report-content h1,
.report-content h2,
.report-content h3,
.report-content p {
  margin: 0;
}

.report-content h1 {
  font-size: 1.8rem;
}

.report-content h2 {
  border-bottom: 1px solid var(--line);
  font-size: 1.15rem;
  margin: 26px 0 14px;
  padding-bottom: 8px;
}

.report-summary {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.report-metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.report-metric span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.report-metric strong {
  font-size: 1.25rem;
}

.report-charts {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.positive {
  color: var(--brand);
  font-weight: 800;
}

.negative {
  color: var(--accent);
  font-weight: 800;
}

.metric-strip {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-strip div {
  background: #f5f7f4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 4px;
  padding: 14px;
}

.metric-strip span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.metric-strip strong {
  font-size: 1.35rem;
}

.charts-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-block {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  padding-top: 16px;
}

canvas {
  height: auto;
  max-width: 100%;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend span {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.85rem;
  gap: 6px;
}

.legend i {
  border-radius: 50%;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 720px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.table-link {
  background: transparent;
  border: 0;
  color: var(--brand);
  font: inherit;
  font-weight: 800;
  padding: 0;
  text-decoration: underline;
}

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(23, 32, 29, 0.28);
  max-width: 560px;
  width: calc(100% - 28px);
}

dialog.is-open {
  display: block;
  inset: 50% auto auto 50%;
  position: fixed;
  transform: translate(-50%, -50%);
  z-index: 10;
}

dialog::backdrop {
  background: rgba(23, 32, 29, 0.35);
}

.check-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.check-row input {
  min-height: 18px;
  width: 18px;
}

.settings-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 880px) {
  .app-shell,
  .capture-grid,
  .charts-grid,
  .report-charts,
  .report-summary {
    grid-template-columns: 1fr;
  }

  .metric-strip,
  .field-row {
    grid-template-columns: 1fr;
  }
}

@media print {
  body > :not(#printReport) {
    display: none !important;
  }

  #printReport {
    display: block !important;
    min-height: auto;
    padding: 0;
  }

  .report-toolbar {
    display: none !important;
  }

  .report-content {
    border: 0;
    border-radius: 0;
    max-width: none;
    padding: 0;
  }
}

@media (display-mode: standalone) {
  .app-header {
    padding-top: calc(18px + env(safe-area-inset-top));
  }
}
