/* ─── Mobile-first bill upload page ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

:root {
  --bg:           #FFFFFF;
  --surface:      #FFFFFF;
  --border:       #E5E7EB;
  --text:         #000000;
  --muted:        #9CA3AF;
  --primary:      #2563EB;
  --primary-dark: #1D4ED8;
  --primary-bg:   #EEF2FF;
  --primary-border: #BFDBFE;
  --submit:       #2563EB;
  --submit-dark:  #1D4ED8;
  --success:      #059669;
  --success-bg:   #ECFDF5;
  --warn:         #DC2626;
  --warn-bg:      #FEF2F2;
  --radius:       14px;
  --radius-sm:    10px;
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  --safe-top:     env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overscroll-behavior: none;
}

/* ─── Page layout ───────────────────────────────────────────── */
.page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: calc(14px + var(--safe-top)) 20px 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0;
}

.footer {
  text-align: center;
  padding: 16px 24px calc(16px + var(--safe-bottom));
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
  background: var(--bg);
}

/* ─── State panels ──────────────────────────────────────────── */
.state-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 20px 0;
}

.state-form {
  padding-bottom: 0;
}

.form-intro {
  margin-bottom: 20px;
}

.form-intro .state-desc {
  color: var(--primary);
  font-weight: 500;
}

.state-title {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.state-desc {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.55;
}

.state-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.state-icon-success { background: var(--success-bg); color: var(--success); }
.state-icon-warn    { background: var(--warn-bg);    color: var(--warn);    }

/* ─── Trust strip ───────────────────────────────────────────── */
.trust-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.trust-strip span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.trust-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #CBD5E1;
}

/* ─── Upload form ───────────────────────────────────────────── */
.upload-form {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ─── File preview ──────────────────────────────────────────── */
.file-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--primary-bg);
  border: 1.5px solid var(--primary-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.file-preview-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.file-preview-info {
  flex: 1;
  min-width: 0;
}

.file-preview-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary-dark);
  margin-bottom: 2px;
}

.file-preview-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-change {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-dark);
  cursor: pointer;
  padding: 8px 4px;
  flex-shrink: 0;
}

/* ─── Upload option buttons ─────────────────────────────────── */
.upload-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: border-color 0.15s, background 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.option-btn:active {
  background: #F8FAFC;
  border-color: #CBD5E1;
}

.option-primary {
  border-color: var(--primary-border);
  background: var(--primary-bg);
}

.option-primary:active {
  background: #EBF2FF;
}

.option-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.option-primary .option-icon {
  background: var(--primary);
  color: #fff;
  box-shadow: none;
}

.option-text {
  flex: 1;
  min-width: 0;
}

.option-text strong {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.option-text small {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.option-chevron {
  color: #CBD5E1;
  flex-shrink: 0;
}

.dropzone-desktop {
  display: none;
}

/* ─── Submit bar (sticky on mobile) ─────────────────────────── */
.submit-bar {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 20px 0 calc(20px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.btn-submit {
  width: 100%;
  display: block;
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  background: var(--submit);
  border: none;
  border-radius: var(--radius);
  padding: 16px 24px;
  cursor: pointer;
  letter-spacing: -0.01em;
  transition: background 0.15s, opacity 0.15s;
  min-height: 54px;
}

.btn-submit:active:not(:disabled) {
  background: var(--submit-dark);
}

.btn-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  margin-top: 8px;
  width: 100%;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 24px;
  cursor: pointer;
  min-height: 50px;
}

/* ─── Error ─────────────────────────────────────────────────── */
.field-error {
  font-size: 0.85rem;
  color: var(--warn);
  margin-bottom: 8px;
  padding: 0 4px;
}

/* ─── Spinner & progress ────────────────────────────────────── */
.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  align-self: center;
  margin-bottom: 20px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar-wrap {
  background: var(--border);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  width: 0%;
  transition: width 0.3s ease;
}

/* ─── Desktop enhancements ──────────────────────────────────── */
@media (min-width: 540px) {
  .main {
    padding: 32px 0 24px;
  }

  .state-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.04);
    padding: 36px 32px 0;
    margin: 0 16px;
  }

  .state-form {
    padding-bottom: 0;
  }

  .submit-bar {
    padding: 24px 0 32px;
    background: none;
    position: static;
  }

  .dropzone-desktop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 24px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 0.88rem;
    cursor: pointer;
    margin-top: 4px;
    transition: border-color 0.15s, background 0.15s;
  }

  .dropzone-desktop:hover,
  .dropzone-desktop.drag-over {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--text);
  }

  .option-btn:hover {
    border-color: #CBD5E1;
    background: #FAFBFC;
  }

  .option-primary:hover {
    border-color: var(--primary-border);
    background: #EBF2FF;
  }

  .btn-submit:hover:not(:disabled) {
    background: var(--submit-dark);
  }
}
