*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #EDF0F8;
  --card:          #FFFFFF;
  --border:        #C8CEE3;
  --accent:        #1E2460;
  --accent-hover:  #161A4A;
  --text:          #1A1D2E;
  --muted:         #5A6282;
  --success:       #2E7D5E;
  --error:         #C0392B;
  --error-bg:      #FDF0EE;
  --shadow:        0 2px 24px rgba(30,36,96,0.09);
  --radius:        12px;
  --radius-sm:     6px;
}

html { font-size: 16px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px 48px;
  line-height: 1.5;
}

/* ── Card ── */
.page { width: 100%; max-width: 520px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 24px;
}

/* ── Header ── */
.card-header {
  text-align: center;
  margin-bottom: 28px;
}

.brand {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: clamp(1.5rem, 5vw, 1.85rem);
  color: var(--accent);
  letter-spacing: 0.12em;
  line-height: 1.2;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 6px;
}

/* ── Layout ── */
.row-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Fields ── */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
}

.field:last-child { margin-bottom: 0; }

label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.required {
  color: var(--accent);
  font-size: 1rem;
  line-height: 0;
  vertical-align: middle;
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235A6282' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

input::placeholder { color: #B0B7CC; }

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30,36,96,0.12);
}

input.is-error,
select.is-error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.1);
}

.field-error {
  font-size: 0.78rem;
  color: var(--error);
  min-height: 1em;
  display: block;
}

/* ── AI pre-fill highlight ── */
input.is-ai,
select.is-ai {
  background: rgba(30,36,96,0.06);
  border-color: var(--accent);
}

/* ── Upload zone ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  overflow: hidden;
  position: relative;
}

.upload-zone:hover,
.upload-zone:focus {
  border-color: var(--accent);
  background: #E8ECF5;
  outline: none;
}

.upload-zone.drag-over {
  border-color: var(--accent);
  background: #E8ECF5;
  box-shadow: 0 0 0 3px rgba(30,36,96,0.12);
}

.upload-zone.is-error { border-color: var(--error); }

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  gap: 8px;
  text-align: center;
}

.camera-icon {
  width: 36px;
  height: 36px;
  color: var(--border);
  flex-shrink: 0;
}

.upload-text {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}

.upload-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.upload-hint {
  font-size: 0.75rem;
  color: #A0A8C0;
}

.upload-preview {
  position: relative;
}

.upload-preview img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: var(--bg);
}

.remove-photo {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(26,29,46,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.remove-photo:hover { background: rgba(26,29,46,0.85); }

.remove-photo svg {
  width: 16px;
  height: 16px;
  stroke: #fff;
}

/* ── Other store name ── */
.other-store-wrap {
  margin-top: 6px;
}

/* ── Step-two progressive reveal ── */
.step-two {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.45s ease, opacity 0.35s ease;
}

.step-two.visible {
  max-height: 800px;
  opacity: 1;
  margin-top: 16px;
}

/* ── Submit button ── */
.btn-submit {
  width: 100%;
  height: 52px;
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.2s ease, transform 0.1s ease;
  margin-top: 24px;
  letter-spacing: 0.02em;
}

.btn-submit:hover { background: var(--accent-hover); }
.btn-submit:active { transform: scale(0.98); }
.btn-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* ── Analyse button ── */
.btn-analyse {
  width: 100%;
  height: 40px;
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease, color 0.15s ease;
  margin-top: 8px;
}

.btn-analyse:hover:not(:disabled) { background: var(--accent); color: #fff; }
.btn-analyse:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-analyse:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Continue without receipt button ── */
.btn-continue {
  width: 100%;
  height: 40px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.btn-continue:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-continue:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Accent-coloured spinner for outline button */
.btn-spinner--accent {
  border-color: rgba(30,36,96,0.25);
  border-top-color: var(--accent);
}

.analyse-info {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 6px;
  text-align: center;
  line-height: 1.4;
}

/* Spinner */
.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Form-level error ── */
.form-error {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--error-bg);
  border: 1px solid rgba(192,57,43,0.25);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 0.88rem;
  line-height: 1.4;
}

/* ── Success screen ── */
.success-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 8px 8px;
  gap: 12px;
}

.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.success-icon svg {
  width: 30px;
  height: 30px;
  stroke: #fff;
}

.success-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.success-msg {
  font-size: 0.92rem;
  color: var(--muted);
  max-width: 280px;
}

.btn-reset {
  margin-top: 8px;
  padding: 0 28px;
  height: 46px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-reset:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Utilities ── */
.hidden { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* ── Mobile overrides ── */
@media (max-width: 480px) {
  body { padding: 12px 12px 32px; }
  .card { padding: 20px 16px 24px; }
  .card-header { margin-bottom: 20px; }

  .row-two {
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 16px;
  }
  .row-two .field { margin-bottom: 8px; }
  .row-two .field:last-child { margin-bottom: 0; }

  .brand { font-size: 1.5rem; }
  .upload-placeholder { padding: 20px 12px; }
  .btn-submit { margin-top: 16px; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .step-two { transition: none; }
}
