:root {
  --primary: #0a2540;
  --primary-2: #123f68;
  --accent: #f6b73c;
  --accent-dark: #d58d00;
  --surface: rgba(255, 255, 255, 0.96);
  --text: #122033;
  --muted: #68758a;
  --border: #dce3eb;
  --success: #0d8a58;
  --danger: #c93636;
  --shadow: 0 24px 70px rgba(5, 29, 51, 0.25);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

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

button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }

.page-background {
  position: fixed;
  inset: 0;
  z-index: -3;
  background-image: url("assets/invoice-rewards-background.png");
  background-size: cover;
  background-position: center;
  transform: scale(1.02);
}

.background-overlay {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 15% 20%, rgba(246, 183, 60, 0.08), transparent 36%),
    linear-gradient(110deg, rgba(3, 20, 35, 0.38), rgba(4, 35, 58, 0.12) 48%, rgba(4, 22, 38, 0.3));
}

.app-shell {
  width: min(100% - 32px, 560px);
  margin: 0 auto;
  padding: 32px 0 22px;
}

.brand-bar {
  display: flex;
  align-items: center;
  gap: 13px;
  color: #fff;
  padding: 0 4px 18px;
}

.brand-mark {
  width: 47px;
  height: 47px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--accent), #ffd881);
  color: #193149;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(246, 183, 60, 0.25);
}

.brand-bar h1 { margin: 2px 0 0; font-size: clamp(20px, 5vw, 26px); }
.eyebrow { margin: 0; font-size: 10px; letter-spacing: 0.16em; color: rgba(255,255,255,.66); font-weight: 700; }
.secure-pill { margin-left: auto; padding: 7px 11px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; font-size: 11px; color: rgba(255,255,255,.82); backdrop-filter: blur(6px); }

.campaign-card {
  position: relative;
  overflow: hidden;
  min-height: 520px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 27px;
  padding: clamp(22px, 5vw, 34px);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.campaign-card[aria-busy="true"] { overflow: hidden; }

.section-heading { margin-bottom: 24px; }
.section-heading h2 { margin: 8px 0 8px; font-size: clamp(23px, 6vw, 31px); line-height: 1.12; letter-spacing: -0.035em; }
.section-heading p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 14px; }
.step-label { font-size: 11px; letter-spacing: .12em; font-weight: 800; color: var(--accent-dark); }

.page-section { display: none; animation: fadeIn .32s ease; }
.page-section.active { display: block; }
.page-section h2:focus { outline: none; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.field-group { margin-bottom: 19px; }
.field-group label, .label-row label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.label-row { display: flex; align-items: center; justify-content: space-between; }

input[type="tel"], input[type="text"] {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 15px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

input:focus { border-color: var(--primary-2); box-shadow: 0 0 0 4px rgba(18,63,104,.1); }
input.input-error { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(201,54,54,.08); }

.phone-input-wrap { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 14px; background: #fff; transition: border-color .2s, box-shadow .2s; }
.phone-input-wrap:focus-within { border-color: var(--primary-2); box-shadow: 0 0 0 4px rgba(18,63,104,.1); }
.phone-input-wrap.input-error { border-color: var(--danger); }
.phone-input-wrap input { border: 0; border-radius: 0 14px 14px 0; box-shadow: none !important; }
.country-code { padding: 0 13px 0 15px; font-weight: 700; border-right: 1px solid var(--border); color: #435369; }
.text-button { border: 0; padding: 6px; background: transparent; color: var(--primary-2); font-weight: 700; font-size: 13px; }

.error-message { display: block; min-height: 17px; color: var(--danger); margin-top: 6px; font-size: 11px; }
.field-hint { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; }

.primary-button {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  border: 0;
  border-radius: 15px;
  padding: 13px 18px;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-weight: 750;
  box-shadow: 0 13px 28px rgba(10, 37, 64, .2);
  transition: transform .2s, opacity .2s;
}
.primary-button:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 16px 32px rgba(10, 37, 64, .25); }
.primary-button:not(:disabled):active { transform: translateY(0); }
.primary-button:focus-visible, .secondary-button:focus-visible, .text-button:focus-visible, .upload-zone:focus-visible {
  outline: 3px solid rgba(246, 183, 60, .55);
  outline-offset: 3px;
}
.primary-button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.secondary-button { border: 1px solid var(--border); background: #fff; color: var(--primary); padding: 9px 13px; border-radius: 10px; font-weight: 700; }

.trust-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; margin-top: 20px; font-size: 10px; color: var(--muted); }
.trust-row span { color: var(--success); font-weight: 800; }

.upload-zone {
  min-height: 220px;
  border: 1.5px dashed #b8c5d4;
  border-radius: 20px;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(145deg, #fbfcfe, #f3f7fa);
  text-align: center;
  transition: border-color .2s, background .2s;
  outline: none;
}
.upload-zone:hover, .upload-zone.dragover, .upload-zone:focus { border-color: var(--primary-2); background: #f4f8fb; }
.upload-zone.dragover { transform: scale(1.01); }
.upload-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 16px; background: #e7eef5; color: var(--primary); font-size: 25px; font-weight: 800; }
.upload-prompt h3 { margin: 0 0 7px; font-size: 16px; }
.upload-prompt p { margin: 0 0 7px; color: var(--muted); font-size: 13px; }
.upload-prompt span { font-size: 10px; color: #8a96a7; }
.preview-wrap { width: 100%; }
.preview-wrap img { display: block; width: 100%; max-height: 270px; object-fit: contain; border-radius: 14px; background: #e9eef3; }
.preview-meta { display: flex; justify-content: space-between; gap: 12px; padding: 12px 2px; text-align: left; font-size: 11px; }
.preview-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-meta span { color: var(--muted); white-space: nowrap; }

.progress-panel { margin-top: 20px; padding: 17px; border: 1px solid var(--border); border-radius: 17px; background: #fbfcfd; }
.progress-item { display: flex; align-items: center; gap: 12px; }
.progress-item div { display: flex; flex-direction: column; gap: 3px; }
.progress-item strong { font-size: 12px; }
.progress-item small { color: var(--muted); font-size: 10px; }
.progress-dot { width: 18px; height: 18px; border: 3px solid #cad4df; border-radius: 50%; }
.progress-item.active .progress-dot { border-color: var(--accent); border-top-color: transparent; animation: spin .7s linear infinite; }
.progress-item.done .progress-dot { border-color: var(--success); background: var(--success); box-shadow: inset 0 0 0 4px white; }
.progress-item.error .progress-dot { border-color: var(--danger); background: var(--danger); box-shadow: inset 0 0 0 4px white; }
.progress-line { width: 2px; height: 22px; margin: 4px 0 4px 8px; background: #d8e0e7; }
@keyframes spin { to { transform: rotate(360deg); } }

.response-section { margin-top: 22px; padding: 18px; border-radius: 19px; border: 1px solid #cfe3d9; background: linear-gradient(145deg, #f8fffb, #f0faf5); }
.response-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.response-header h3 { margin: 6px 0 0; font-size: 18px; }
.success-badge { font-size: 9px; letter-spacing: .11em; font-weight: 800; color: var(--success); }
.response-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 17px 0; }
.summary-card { padding: 11px; border: 1px solid rgba(13,138,88,.14); border-radius: 11px; background: rgba(255,255,255,.72); }
.summary-card small { display: block; margin-bottom: 4px; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .07em; }
.summary-card strong { display: block; overflow-wrap: anywhere; font-size: 12px; }
.full-width { grid-column: 1 / -1; }
.invoice-items h4 { margin: 3px 0 9px; font-size: 13px; }
.invoice-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid rgba(13,138,88,.14); border-radius: 11px; background: rgba(255,255,255,.72); }
.invoice-item + .invoice-item { margin-top: 8px; }
.invoice-item > strong { min-width: 0; overflow-wrap: anywhere; font-size: 11px; }
.invoice-item span { min-width: 55px; font-size: 11px; font-weight: 700; text-align: right; }
.invoice-item span small { display: block; margin-bottom: 2px; color: var(--muted); font-size: 8px; font-weight: 500; text-transform: uppercase; }
.empty-items { margin: 0; padding: 12px; color: var(--muted); border-radius: 11px; background: rgba(255,255,255,.72); font-size: 11px; }
.total-card { margin-top: 12px; border-color: rgba(17,34,53,.18); }
.total-card .reward-card { margin-top: 12px; border-color: rgba(13,138,88,.35); background: #e5f8ee; }
.reward-card { border-color: rgba(13,138,88,.35); background: #e5f8ee; }
.total-card strong, .reward-card strong { font-size: 18px; }
.alert { margin-bottom: 18px; padding: 12px 14px; border-radius: 12px; font-size: 12px; line-height: 1.5; }
.alert.error { color: #8e2525; background: #fff0f0; border: 1px solid #f0c3c3; }
.alert.success { color: #087145; background: #effaf4; border: 1px solid #bfe3d0; }
.alert.info { color: #244b72; background: #edf5fc; border: 1px solid #c5d9ec; }

.global-loader { position: absolute; inset: 0; z-index: 20; display: grid; align-content: center; justify-items: center; gap: 13px; background: rgba(255,255,255,.9); backdrop-filter: blur(6px); }
.global-loader p { margin: 0; color: var(--muted); font-size: 12px; }
.spinner { width: 36px; height: 36px; border: 4px solid #dce4ec; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }

footer { text-align: center; color: rgba(255,255,255,.7); font-size: 9px; line-height: 1.6; padding: 15px 10px 0; }
footer p { margin: 2px 0; }
.session-text { opacity: .72; }
.hidden { display: none !important; }

.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 20, 35, .72);
  backdrop-filter: blur(8px);
  animation: modalFade .2s ease;
}
.reward-modal {
  position: relative;
  width: min(100%, 390px);
  padding: 34px 28px 28px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 25px;
  background: #fff;
  text-align: center;
  box-shadow: 0 28px 80px rgba(0,0,0,.32);
  animation: modalRise .28s ease;
}
.modal-close { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f0f3f6; color: var(--muted); font-size: 24px; line-height: 1; }
.reward-icon { width: 68px; height: 68px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 22px; background: linear-gradient(145deg, var(--accent), #ffe19a); color: var(--primary); font-size: 32px; box-shadow: 0 14px 30px rgba(246,183,60,.3); }
.reward-kicker { margin: 0 0 8px; color: var(--success); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.reward-modal h2 { margin: 0; font-size: 27px; letter-spacing: -.03em; }
.reward-modal > p:not(.reward-kicker) { margin: 10px 0 4px; color: var(--muted); font-size: 14px; }
.reward-amount { display: block; margin: 4px 0 22px; color: var(--success); font-size: 38px; line-height: 1.2; }
.reward-modal .primary-button { margin-top: 0; }
@keyframes modalFade { from { opacity: 0; } }
@keyframes modalRise { from { opacity: 0; transform: translateY(12px) scale(.98); } }

@media (max-width: 480px) {
  .app-shell { width: min(100% - 20px, 560px); padding: max(18px, env(safe-area-inset-top)) 0 max(18px, env(safe-area-inset-bottom)); }
  .campaign-card { border-radius: 22px; padding: 22px 18px; }
  .secure-pill { display: none; }
  .response-summary { grid-template-columns: 1fr; }
  .invoice-item { grid-template-columns: 1fr 1fr; }
  .invoice-item > strong { grid-column: 1 / -1; }
  .invoice-item span:first-of-type { text-align: left; }
  .trust-row { justify-content: flex-start; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (min-width: 900px) {
  .app-shell { width: min(100% - 48px, 620px); padding-top: 52px; }
  .campaign-card { padding: 38px 42px; }
}
