:root {
  color-scheme: light;
  --ink: #17201f;
  --muted: #66706d;
  --line: #d9e1df;
  --surface: #fbfcfa;
  --surface-strong: #ffffff;
  --band: #edf4f1;
  --accent: #0d6b63;
  --accent-dark: #0a4c47;
  --warn: #b5662d;
  --shell: #eef6f3;
  --shell-end: #ffffff;
  --shadow: rgba(18, 39, 36, 0.08);
  --topbar: #103f3b;
  --field: #ffffff;
  --field-ink: #17201f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef7f4;
  --muted: #9cb3ad;
  --line: #263f3a;
  --surface: #101b19;
  --surface-strong: #14231f;
  --band: #172b27;
  --accent: #42c9b3;
  --accent-dark: #74e0cf;
  --warn: #f2a35f;
  --shell: #07100f;
  --shell-end: #0d1715;
  --shadow: rgba(0, 0, 0, 0.28);
  --topbar: #0b2421;
  --field: #0d1715;
  --field-ink: #eef7f4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--shell) 0%, var(--shell-end) 100%);
  color: var(--ink);
  font-size: 15px;
}

button, input, select, textarea { font: inherit; }
a { color: var(--accent-dark); font-weight: 750; }

.app-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
}

.panel, .status-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 55px var(--shadow);
}

.panel { overflow: hidden; }

.topbar {
  padding: 30px 32px;
  background: var(--topbar);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
}

.topbar-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0;
  font-size: 13px;
  opacity: .82;
  font-weight: 800;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 34px; line-height: 1.05; }
h2 { font-size: 24px; }

.language {
  display: grid;
  gap: 6px;
  min-width: 132px;
  font-size: 13px;
}

.language select, input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px 13px;
  background: var(--field);
  color: var(--field-ink);
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}

.step {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 14px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.step span {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 850;
}

.step strong {
  font-weight: 850;
}

.step.is-active {
  background: var(--band);
  color: var(--accent-dark);
  font-weight: 700;
}

.step.is-active span {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

form { padding: 30px 32px 0; }

.form-step { display: none; }
.form-step.is-active { display: block; }

.section-head {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.section-head p, .status-panel p {
  margin: 0;
  color: var(--muted);
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

.wide { margin-top: 16px; }

.camera-card {
  display: grid;
  gap: 14px;
}

#camera {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #122725;
  border-radius: 8px;
  object-fit: cover;
}

.camera-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  min-height: 46px;
  padding: 0 18px;
  font-weight: 850;
  cursor: pointer;
}

.theme-toggle {
  min-height: 42px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: white;
}

button.secondary {
  background: #e4ece9;
  color: var(--accent-dark);
}

[data-theme="dark"] button.secondary {
  background: #1c332e;
  color: var(--accent-dark);
}

button:disabled {
  opacity: .55;
  cursor: wait;
}

.file-fallback {
  width: fit-content;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
}

.file-fallback input { padding: 8px 0 0; border: 0; }

.captures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.capture {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-strong);
}

.capture img {
  width: 100%;
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.capture span {
  display: block;
  padding: 9px 10px;
  font-size: 13px;
  color: var(--muted);
}

.consent {
  grid-template-columns: 22px 1fr;
  align-items: start;
  padding: 14px;
  background: var(--band);
  border-radius: 8px;
}

.consent input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.signature-wrap {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

#signaturePad {
  width: 100%;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  touch-action: none;
}

.form-actions {
  margin: 30px -32px 0;
  padding: 18px 32px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: var(--surface-strong);
}

.status-panel {
  padding: 24px;
  align-self: start;
  position: sticky;
  top: 20px;
}

.status-panel h2 { margin-bottom: 16px; }

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.status-row strong { color: var(--warn); }
.status-row strong.is-done { color: var(--accent); }

#submitStatus {
  margin-top: 18px;
  line-height: 1.45;
}

.staff-link {
  display: inline-flex;
  margin-top: 18px;
}

.success-state {
  padding: 54px 32px;
  text-align: center;
}

.success-mark {
  width: 58px;
  height: 58px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 18px;
  background: var(--accent);
  color: white;
  font-size: 30px;
  font-weight: 900;
}

.success-state p:not(.success-mark) {
  margin: 10px auto 0;
  max-width: 520px;
  color: var(--muted);
}

.success-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 24px;
}

.confirm-summary {
  width: min(520px, 100%);
  margin: 24px auto 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.confirm-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-strong);
  text-align: left;
}

.confirm-summary dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.confirm-summary dd {
  margin: 6px 0 0;
  color: var(--ink);
  font-weight: 850;
}

.staff-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.staff-header {
  background: var(--topbar);
  color: white;
  border-radius: 8px;
  padding: 26px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.text-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--accent-dark);
  text-decoration: none;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 34px;
  line-height: 1;
  color: var(--accent-dark);
}

.toolbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}

.toolbar label {
  width: min(300px, 100%);
}

.table-panel {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

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

th, td {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--band);
}

td strong, td span {
  display: block;
}

td span {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.pill {
  display: inline-flex;
  width: fit-content;
  min-height: 26px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  text-transform: capitalize;
  font-size: 13px;
  font-weight: 800;
}

.pill.ready {
  color: #0c5b52;
  background: #dff1ec;
}

.pill.incomplete {
  color: #884614;
  background: #f8e9dc;
}

.file-cell {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.file-cell a {
  white-space: nowrap;
}

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

.empty-state, .staff-note {
  color: var(--muted);
}

.empty-state {
  margin: 0;
  padding: 24px;
}

.staff-note {
  margin: 14px 2px 0;
  font-size: 13px;
}

@media (max-width: 860px) {
  .app-shell {
    width: 100%;
    padding: 0;
    grid-template-columns: 1fr;
  }

  .panel, .status-panel {
    border-radius: 0;
    box-shadow: none;
    border-left: 0;
    border-right: 0;
  }

  .topbar {
    padding: 22px 18px;
    align-items: start;
  }

  h1 { font-size: 29px; }
  form { padding: 22px 18px 0; }
  .grid { grid-template-columns: 1fr; }
  .form-actions {
    margin-left: -18px;
    margin-right: -18px;
    padding: 14px 18px;
  }

  .step {
    flex-direction: column;
    gap: 5px;
    padding: 12px 6px;
  }

  .step strong {
    font-size: 13px;
  }

  .confirm-summary {
    grid-template-columns: 1fr;
  }

  .status-panel {
    position: static;
  }

  .staff-shell {
    width: 100%;
    padding: 0;
  }

  .staff-header {
    border-radius: 0;
    padding: 22px 18px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 14px;
  }

  .toolbar, .table-panel {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .toolbar {
    margin: 0;
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar label {
    width: 100%;
  }

  .staff-note {
    margin: 14px;
  }
}
