:root {
  --brand: #52646d;
  --brand-dark: #344851;
  --brand-soft: #edf3f1;
  --accent: #bd4f3d;
  --success: #2f7a61;
  --warning: #936424;
  --text: #24343a;
  --muted: #687a80;
  --line: rgba(82, 100, 109, 0.20);
  --panel: rgba(255, 255, 255, 0.88);
  --shadow: 0 20px 55px rgba(41, 60, 67, 0.18);
  --radius: 24px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: #f7f8f5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-color: #f7f8f5;
  background-image: url("assets/hap-background.png");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: auto 100vh;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(247, 248, 245, 0.02), rgba(247, 248, 245, 0.08));
}

button, input { font: inherit; }
button { cursor: pointer; }

.page-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 126px 18px 155px;
}

.page-shell.top-aligned {
  align-items: flex-start;
  padding-top: 118px;
}

.panel {
  width: min(100%, 520px);
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.panel.wide { width: min(100%, 720px); }

.brand-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand-kicker::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(189, 79, 61, 0.12);
}

h1 {
  margin: 12px 0 8px;
  color: var(--brand-dark);
  font-size: clamp(25px, 5vw, 34px);
  letter-spacing: -0.045em;
  line-height: 1.07;
}

.subtitle {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.note {
  display: flex;
  gap: 10px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid rgba(147, 100, 36, 0.24);
  border-radius: 15px;
  background: rgba(255, 248, 225, 0.86);
  color: #76501d;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.note-icon { font-size: 17px; line-height: 1.2; }

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

.field { display: grid; gap: 7px; }

label {
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  text-align: center;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.input:focus {
  border-color: rgba(82, 100, 109, 0.7);
  box-shadow: 0 0 0 4px rgba(82, 100, 109, 0.11);
}

.input[readonly] { background: rgba(239, 243, 242, 0.95); }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 10px 22px rgba(52, 72, 81, 0.22);
}

.btn-secondary {
  border-color: var(--line);
  color: var(--brand-dark);
  background: rgba(255, 255, 255, 0.80);
}

.btn-danger {
  border-color: rgba(189, 79, 61, 0.18);
  color: var(--accent);
  background: rgba(255, 248, 246, 0.90);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

.btn.full { width: 100%; }

.helper {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.helper strong { color: var(--brand-dark); }

.alert {
  display: none;
  margin-bottom: 14px;
  padding: 11px 13px;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.alert.show { display: block; }
.alert.error { color: #a23f32; background: rgba(255, 235, 232, 0.92); border: 1px solid rgba(189, 79, 61, 0.22); }
.alert.success { color: #26614f; background: rgba(231, 248, 240, 0.94); border: 1px solid rgba(47, 122, 97, 0.20); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 34, 39, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 26px 70px rgba(31, 49, 55, 0.28);
}

.modal-card h2 {
  margin: 12px 0 8px;
  color: var(--brand-dark);
  font-size: clamp(22px, 4.5vw, 30px);
  letter-spacing: -0.04em;
  line-height: 1.08;
}

.modal-card .subtitle { margin-bottom: 16px; }

.modal-actions { margin-top: 16px; }

.modal-actions .btn { width: 100%; }

.stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 0 0 18px;
}

.step {
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(82, 100, 109, 0.14);
}

.step.done, .step.active { background: linear-gradient(90deg, var(--brand), #71848c); }

.camera-box {
  overflow: hidden;
  position: relative;
  min-height: 260px;
  border: 1px dashed rgba(82, 100, 109, 0.38);
  border-radius: 18px;
  background: rgba(240, 244, 242, 0.82);
}

.camera-placeholder {
  min-height: 260px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  line-height: 1.55;
}

.camera-placeholder .camera-emoji { display: block; font-size: 42px; margin-bottom: 7px; }

video {
  display: none;
  width: 100%;
  min-height: 260px;
  max-height: 360px;
  object-fit: cover;
  background: #1d292e;
}

video.active { display: block; }
canvas { display: none; }

.capture-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 18px;
}

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

.photo-card {
  display: grid;
  gap: 9px;
  min-height: 168px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
}

.photo-preview {
  overflow: hidden;
  position: relative;
  display: grid;
  place-items: center;
  min-height: 108px;
  border-radius: 12px;
  background: rgba(237, 243, 241, 0.96);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.photo-preview img { width: 100%; height: 128px; object-fit: cover; display: block; }

.photo-label { color: var(--brand-dark); font-size: 13px; font-weight: 800; }

.photo-card .btn { min-height: 39px; padding: 8px 10px; border-radius: 11px; font-size: 12px; }

.invoice-card {
  margin-top: 6px;
  min-height: 260px;
}

.invoice-card .photo-preview {
  min-height: 176px;
}

.invoice-card .photo-preview img {
  height: 220px;
}

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.progress {
  overflow: hidden;
  height: 8px;
  margin-top: 8px;
  border-radius: 99px;
  background: rgba(82, 100, 109, 0.14);
}

.progress > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #7e9499);
  transition: width 180ms ease;
}

.upload-zone {
  display: grid;
  place-items: center;
  min-height: 210px;
  padding: 24px;
  border: 1.5px dashed rgba(82, 100, 109, 0.42);
  border-radius: 18px;
  background: rgba(248, 251, 249, 0.78);
  text-align: center;
}

.upload-zone.dragging { background: rgba(233, 243, 240, 0.96); border-color: var(--brand); }

.upload-zone input { display: none; }
.upload-icon { font-size: 43px; }
.upload-zone h2 { margin: 9px 0 4px; color: var(--brand-dark); font-size: 18px; }
.upload-zone p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.file-preview {
  display: none;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.80);
}

.file-preview.show { display: flex; }
.file-preview img { width: 64px; height: 64px; border-radius: 11px; object-fit: cover; background: var(--brand-soft); }
.file-preview .file-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 11px; background: var(--brand-soft); font-size: 27px; }
.file-name { margin: 0 0 2px; color: var(--brand-dark); font-size: 13px; font-weight: 800; word-break: break-all; }
.file-meta { margin: 0; color: var(--muted); font-size: 12px; }

.thankyou {
  text-align: center;
}

.success-mark {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #3a8b70, #2f6f5c);
  box-shadow: 0 14px 30px rgba(47, 122, 97, 0.22);
  font-size: 36px;
  font-weight: 900;
}

.summary-card {
  margin: 18px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  text-align: left;
}

.small-link {
  border: 0;
  padding: 0;
  color: var(--brand-dark);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-text {
  position: fixed;
  right: 0;
  bottom: 8px;
  left: 0;
  padding: 0 12px;
  color: rgba(52, 72, 81, 0.78);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 1px 8px rgba(255,255,255,.92);
}

@media (max-width: 560px) {
  .page-shell { padding: 118px 14px 144px; }
  .page-shell.top-aligned { padding-top: 110px; }
  .panel { padding: 20px; border-radius: 20px; }
  .panel.wide { width: 100%; }
  .photo-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .photo-card { min-height: 154px; padding: 8px; }
  .photo-preview { min-height: 92px; }
  .photo-preview img { height: 104px; }
  .camera-box, .camera-placeholder, video { min-height: 220px; }
}

@media (max-width: 370px) {
  .photo-grid { grid-template-columns: 1fr; }
  .page-shell { padding-right: 10px; padding-left: 10px; }
}

.invoice-preview-content {
  width: 100%;
}

.invoice-preview-content img {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  margin-bottom: 12px;
  border-radius: 14px;
  background: rgba(237, 243, 241, 0.96);
}

.invoice-remove {
  display: inline-block;
  margin: 10px 0 2px;
}

.invoice-remove[hidden] {
  display: none;
}
