/* app.css v12 */

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

:root {
  --bg: #eef0f6;
  --surface: #ffffff;
  --border: #dde1ea;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 14px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.14), 0 3px 10px rgba(0,0,0,0.07);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ── Nav ── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-weight: 800;
  font-size: 18px;
  color: var(--primary);
  cursor: pointer;
  letter-spacing: -0.3px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.nav-logo {
  flex-shrink: 0;
  display: block;
}
.nav-actions { display: flex; gap: 12px; align-items: center; }
.nav-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.05em;
  transition: background 0.14s;
}
.nav-avatar:hover { background: var(--primary-hover); }
.btn-text {
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--text-muted); font-weight: 500;
  padding: 5px 8px; border-radius: 6px;
  font-family: inherit;
  transition: color 0.12s, background 0.12s;
}
.btn-text:hover { color: var(--text); background: var(--bg); }

/* ── Step progress bar ── */
#step-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 99;
}
.step-bar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  height: 46px;
}
.step-item {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  white-space: nowrap;
}
.step-item.step-active { color: var(--primary); }
.step-item.step-done   { color: var(--success); }
.step-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.step-active .step-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.step-done   .step-num { background: var(--success); border-color: var(--success); color: #fff; font-size: 12px; }
.step-connector {
  flex: 1; height: 1.5px; background: var(--border); margin: 0 10px; min-width: 24px;
}
.step-connector.step-connector--done { background: #86efac; }

/* ── Views ── */
.view { display: none; }
.view-inner { max-width: 960px; margin: 0 auto; padding: 36px 24px 24px; }

/* ── View section header ── */
.view-header { margin-bottom: 24px; }
.view-header h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 4px; }
.view-subtitle { color: var(--text-muted); font-size: 14px; }

/* ── Auth ── */
.auth-card {
  max-width: 420px; margin: 80px auto; padding: 52px 44px 44px;
  background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow-lg); text-align: center;
}
.auth-card::before {
  content: '';
  display: block;
  width: 60px; height: 60px; border-radius: 15px;
  background: var(--primary)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z'/%3E%3Cpolyline points='13 2 13 9 20 9'/%3E%3C/svg%3E")
    no-repeat center / 27px;
  margin: 0 auto 22px;
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
}
.auth-card h1 { margin-bottom: 10px; font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.auth-card p { color: var(--text-muted); margin-bottom: 32px; font-size: 15px; line-height: 1.65; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
  font-size: 14px; font-weight: 500; font-family: inherit;
  transition: background 0.14s, box-shadow 0.14s, transform 0.08s;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 1px 4px rgba(37,99,235,0.3);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 3px 8px rgba(37,99,235,0.35); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: #c4c9d6; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); box-shadow: 0 1px 4px rgba(220,38,38,0.25); }
.btn-danger:hover { background: #b91c1c; }

/* ── Home ── */
.home-wrap { max-width: 500px; margin: 52px auto; }
.home-wrap h2 { font-size: 23px; font-weight: 700; margin-bottom: 24px; letter-spacing: -0.3px; text-align: center; }

.home-provider-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 22px 20px;
  margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.home-provider-label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.07em; margin-bottom: 9px;
}
/* ── Custom provider dropdown ── */
.csel { position: relative; }
.csel-trigger {
  width: 100%; padding: 10px 40px 10px 13px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; font-weight: 500; font-family: inherit;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 13px center;
  color: var(--text); cursor: pointer; text-align: left;
  transition: border-color 0.12s;
}
.csel-trigger:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.csel--open .csel-trigger { border-color: var(--primary); }
.csel-panel {
  display: none;
  position: absolute; top: calc(100% + 5px); left: 0; right: 0; z-index: 200;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 50vh; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: #d1d5db transparent;
}
.csel-panel::-webkit-scrollbar { width: 6px; }
.csel-panel::-webkit-scrollbar-track { background: transparent; margin: 8px; }
.csel-panel::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 99px; }
.csel-panel::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
.csel--open .csel-panel { display: block; }
.csel-option {
  padding: 10px 14px; cursor: pointer; font-size: 14px; font-weight: 500;
  transition: background 0.1s;
}
.csel-option:first-child { border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; }
.csel-option:last-child  { border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px); }
.csel-option:hover { background: var(--primary-light); color: var(--primary); }
.csel-option--selected { color: var(--primary); font-weight: 600; }
.csel-option--other { color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 4px; }

.home-records-banner {
  background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.home-records-actions { display: flex; gap: 8px; }

.home-upload-zone {
  background: var(--surface); border: 2px dashed var(--border);
  border-radius: var(--radius); padding: 44px 24px 36px;
  text-align: center; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.home-upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.home-upload-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--primary-light); margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  transition: background 0.15s;
}
.home-upload-zone:hover .home-upload-icon { background: #dbeafe; }
.home-upload-zone .home-sub {
  color: var(--text-muted); font-size: 14px;
  margin-bottom: 22px; line-height: 1.6;
}
.home-upload-zone .home-actions { display: flex; justify-content: center; }
.home-upload-zone .btn-primary { padding: 11px 30px; font-size: 15px; font-weight: 600; }

.home-sub { color: var(--text-muted); margin-bottom: 14px; }
.home-actions { display: flex; gap: 12px; justify-content: center; }
.home-manual-link {
  display: block; margin-top: 16px; font-size: 13px; text-align: center;
  color: var(--text-muted); cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px;
}
.home-manual-link:hover { color: var(--primary); }

/* ── Manual entry form ── */
.modal-box--wide { min-width: 480px; max-width: 600px; max-height: 90vh; overflow-y: auto; padding-bottom: 20px; }
.manual-count { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }
.manual-form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.form-group--sm { flex: 0 0 88px; }
.form-group--grow { flex: 1; }
.form-group label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.form-group input {
  padding: 8px 11px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; width: 100%;
  background: var(--bg); font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); background: var(--surface); }
.field-optional { font-weight: 400; color: var(--text-muted); font-size: 11px; text-transform: none; letter-spacing: 0; }
.form-details { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.form-details summary { cursor: pointer; font-size: 13px; font-weight: 500; user-select: none; }
.form-details-body { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

/* ── Flow layout — full-height shell for mapper / review / preview ── */
.flow-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px - 46px); /* viewport - nav - step bar */
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}
.flow-layout--narrow { max-width: 860px; }
.flow-header { flex-shrink: 0; padding: 24px 0 16px; }
.flow-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: var(--radius);
}
/* Card variant — replaces wrapper divs; overflow-y:auto clips to border-radius naturally */
.flow-body--card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.flow-body--table {
  overflow-x: auto;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.flow-footer {
  flex-shrink: 0;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ── Scrollbar styling — contained within rounded boxes ── */
.flow-body { scrollbar-width: thin; scrollbar-color: #d1d5db transparent; }
.flow-body::-webkit-scrollbar { width: 6px; height: 6px; }
.flow-body::-webkit-scrollbar-track { background: transparent; margin: 8px; }
.flow-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 99px; }
.flow-body::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
.flow-body::-webkit-scrollbar-corner { background: transparent; }

/* ── Mapper ── */
.mapper-header-row {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 20px;
}
.mapper-header-row .view-header { margin-bottom: 0; }
.mapper-provider-wrap { display: flex; flex-direction: column; gap: 5px; flex-shrink: 0; }
.mapper-provider-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; }
.mapper-provider-select {
  padding: 8px 36px 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; font-weight: 500; font-family: inherit;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text); cursor: pointer; appearance: none;
}
.mapping-table { width: 100%; border-collapse: collapse; }
.mapping-table th {
  text-align: left; padding: 9px 12px;
  border-bottom: 2px solid var(--border);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.mapping-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.mapping-table tr:last-child td { border-bottom: none; }
.mapping-table select {
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 6px; width: 100%; background: var(--bg); font-size: 13px; font-family: inherit;
}
.col-confirmed { box-shadow: inset 5px 0 0 var(--success); background: #f7fef8; }
.col-detected  { box-shadow: inset 5px 0 0 var(--warning); background: #fefcf0; }
.col-unknown   { box-shadow: inset 5px 0 0 var(--danger);  background: #fff7f7; }
.mapper-footer { display: flex; justify-content: flex-end; }

/* ── Preview ── */
.preview-header { flex-shrink: 0; }
.preview-summary { display: flex; gap: 10px; margin-bottom: 0; }
.badge-ready { background: #dcfce7; color: #15803d; padding: 4px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.badge-incomplete { background: #fef3c7; color: #b45309; padding: 4px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.preview-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.preview-table th {
  padding: 9px 12px; border-bottom: 2px solid var(--border);
  text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.preview-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); }
.row-ready { }
.row-incomplete { background: #fffbeb; }
.missing-badge { font-size: 12px; color: var(--warning); font-weight: 500; }
.preview-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ── Review ── */
.review-header { margin-bottom: 16px; }
.review-header h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 4px; }
.review-sub { color: var(--text-muted); font-size: 14px; }
.review-cards { display: flex; flex-direction: column; gap: 14px; padding-bottom: 8px; }
.review-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow-sm); position: relative; }
.review-card--resolved { opacity: 0.5; }
.review-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.review-raw-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.review-raw-value { font-family: 'SF Mono', 'Fira Code', monospace; color: var(--text); font-weight: 600; font-size: 14px; }
.review-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 99px; letter-spacing: 0.03em; }
.review-badge--usps   { background: #fef3c7; color: #92400e; }
.review-badge--low    { background: #fee2e2; color: #991b1b; }
.review-badge--check  { background: #e0f2fe; color: #075985; }
.review-badge--entity { background: #f3e8ff; color: #6b21a8; }
.review-badge--auto   { background: #d1fae5; color: #065f46; }
.review-entity-note { font-size: 12px; color: #7e22ce; margin: 0 0 10px; width: 100%; }
.review-banner { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 12px 16px; font-size: 13px; color: #14532d; margin-bottom: 18px; line-height: 1.65; }
.review-banner a.review-auto-toggle { color: #16a34a; font-weight: 700; text-decoration: underline; cursor: pointer; }
.review-auto-section { margin-bottom: 20px; }
.review-auto-header { font-size: 11px; font-weight: 700; color: #065f46; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 10px; }
.review-fields { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.review-field-group { display: flex; flex-direction: column; gap: 4px; }
.review-field-group--sm   { width: 100px; }
.review-field-group--xs   { width: 64px; }
.review-field-group--wide { flex: 1; min-width: 200px; }
.review-field-group--grow { flex: 1; min-width: 130px; }
.review-field-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.review-input {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 11px; font-size: 14px; width: 100%;
  background: var(--bg); font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.review-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); background: var(--surface); }
.review-usps-hint { width: 100%; font-size: 12px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 6px; padding: 7px 11px; color: #15803d; margin-bottom: 6px; }
.review-usps-label { font-weight: 600; }
.review-card-actions { display: flex; gap: 8px; justify-content: flex-end; }
.review-resolved-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding: 18px; pointer-events: none; border-radius: var(--radius); }
.review-resolved-check { background: #dcfce7; color: var(--success); font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 99px; }
.review-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); gap: 10px; flex-wrap: wrap; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-ghost { background: none; border: 1px solid var(--border); color: var(--text-muted); border-radius: 6px; cursor: pointer; font-size: 13px; padding: 6px 14px; font-family: inherit; transition: background 0.12s; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* ── Account ── */
.account-wrap { max-width: 480px; margin: 40px auto; background: var(--surface); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.account-wrap h2 { margin-bottom: 20px; font-size: 20px; font-weight: 700; letter-spacing: -0.2px; }
.account-wrap p { margin-bottom: 12px; color: var(--text-muted); font-size: 14px; }
.account-wrap p strong { color: var(--text); }
.account-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.account-row:last-of-type { border-bottom: none; margin-bottom: 20px; }
.account-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.account-value { font-weight: 600; font-size: 14px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 28px; right: 28px; z-index: 9999;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease; max-width: 340px;
}
.toast-info    { background: #1e293b; color: #fff; }
.toast-error   { background: var(--danger); color: #fff; }
.toast-success { background: var(--success); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal-box { background: var(--surface); border-radius: 14px; padding: 30px; min-width: 340px; max-width: 520px; box-shadow: var(--shadow-lg); }
.modal-box h3 { margin-bottom: 18px; font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ── Custom provider modal ── */
.custom-provider-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.6; }
.custom-provider-formats { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.custom-provider-filename { font-size: 13px; color: var(--text-muted); vertical-align: middle; margin-left: 6px; }
.custom-provider-table-wrap { overflow-y: auto; max-height: 280px; padding-bottom: 16px; }
