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

:root {
  --brand:    #1d4ed8;
  --brand-dk: #1e3a8a;
  --success:  #16a34a;
  --warn:     #d97706;
  --danger:   #dc2626;
  --bg:       #f8fafc;
  --surface:  #ffffff;
  --border:   #e2e8f0;
  --text:     #1e293b;
  --muted:    #64748b;
  --radius:   10px;
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

a { color: var(--brand); text-decoration: none; }

/* ── Layout ── */
.page-center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card        { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: 100%; max-width: 440px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card-wide   { max-width: 820px; }
.card-full   { max-width: 100%; }

header.top-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.top-bar .logo { font-size: 15px; font-weight: 700; color: var(--brand); display: flex; align-items: center; gap: 8px; }
.top-bar .phase-badge { font-size: 12px; background: #dbeafe; color: var(--brand); padding: 3px 10px; border-radius: 20px; font-weight: 600; }

.main-content { max-width: 900px; margin: 0 auto; padding: 32px 24px; }

/* ── Typography ── */
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.subtitle { font-size: 13px; color: var(--muted); margin-top: 4px; }
.label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; display: block; }

/* ── Inputs ── */
.input, select.input {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,78,216,.12); }
.form-group { margin-bottom: 16px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; font-size: 14px; font-weight: 600; border-radius: 8px; border: none; cursor: pointer; transition: opacity .15s, transform .1s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--brand);   color: #fff; }
.btn-primary:hover   { background: var(--brand-dk); }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-outline   { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-sm        { padding: 6px 14px; font-size: 13px; }
.btn-icon      { padding: 7px; border-radius: 6px; }
.btn-wa        { background: #25d366; color: #fff; }
.btn-wa:hover  { background: #1ebe5c; }

/* ── Status badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.badge-complete   { background: #dcfce7; color: #15803d; }
.badge-verified   { background: #dbeafe; color: #1d4ed8; }
.badge-incomplete { background: #fef9c3; color: #a16207; }
.badge-exported   { background: #f3f4f6; color: #6b7280; }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-value { font-size: 32px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-pct   { font-size: 13px; font-weight: 600; margin-top: 8px; }
.stat-pct.good { color: var(--success); }
.stat-pct.warn { color: var(--warn); }

/* ── Progress bar ── */
.progress-bar { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .4s; }
.progress-fill.complete { background: var(--success); }
.progress-fill.verified { background: var(--brand); }

/* ── Table / List ── */
.table-wrap  { overflow-x: auto; }
table        { width: 100%; border-collapse: collapse; font-size: 13px; }
th           { text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 2px solid var(--border); background: #f8fafc; }
td           { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td  { background: #f8fafc; }

/* ── Upload dropzone ── */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 40px 24px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag-over { border-color: var(--brand); background: #eff6ff; }
.dropzone svg { margin: 0 auto 12px; display: block; color: var(--muted); }
.dropzone p   { font-size: 14px; color: var(--muted); }
.dropzone strong { color: var(--brand); }

/* ── Column mapping table ── */
.map-row { display: grid; grid-template-columns: 1fr 24px 1fr 80px; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.map-arrow { color: var(--muted); text-align: center; }
.confidence-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 12px; }
.conf-high { background: #dcfce7; color: #15803d; }
.conf-med  { background: #fef9c3; color: #a16207; }
.conf-low  { background: #fee2e2; color: #b91c1c; }

/* ── Household list item ── */
.hh-item { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.hh-item:last-child { border-bottom: none; }
.hh-number { font-weight: 700; font-size: 15px; min-width: 80px; }
.hh-meta   { flex: 1; }
.hh-meta .street { font-size: 13px; color: var(--muted); }
.hh-chips  { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.chip      { font-size: 11px; background: #f1f5f9; color: var(--muted); padding: 2px 8px; border-radius: 12px; }
.hh-actions { display: flex; gap: 6px; }

/* ── Errors list ── */
.error-list { list-style: none; margin-top: 8px; }
.error-list li { font-size: 12px; color: var(--danger); display: flex; align-items: flex-start; gap: 6px; margin-bottom: 4px; }
.error-list li::before { content: "!"; background: var(--danger); color: #fff; border-radius: 50%; width: 14px; height: 14px; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }

/* ── Section header ── */
.section-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* ── Alert ── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-warn    { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-danger  { background: #fff1f2; border: 1px solid #fecdd3; color: #9f1239; }

/* ── Spinner ── */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Verify form ── */
.verify-header { text-align: center; padding: 24px 0 16px; }
.verify-address { font-size: 20px; font-weight: 700; margin: 8px 0 4px; }
.resident-row  { display: grid; grid-template-columns: 1fr 1fr 90px auto 28px; gap: 8px; align-items: center; margin-bottom: 8px; }
.vehicle-row   { display: grid; grid-template-columns: 1fr 1fr 40px; gap: 8px; align-items: end; margin-bottom: 8px; }
.btn-remove    { color: var(--danger); background: none; border: none; cursor: pointer; font-size: 18px; padding: 0 4px; }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast { padding: 12px 18px; border-radius: 8px; font-size: 13px; font-weight: 500; color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: toast-in .2s ease; }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--brand); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Responsive ── */
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
  .map-row  { grid-template-columns: 1fr 20px 1fr 60px; }
  .resident-row { grid-template-columns: 1fr 1fr 90px auto 28px; }
  .main-content { padding: 16px; }
}

.hidden { display: none !important; }
.mt-4 { margin-top: 16px; }
.mt-2 { margin-top: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--muted); }
.w-full { width: 100%; }

/* ── Bottom sheet ── */
.sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; animation: fade-in .2s; }
.sheet { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px 24px 32px; z-index: 101; box-shadow: 0 -4px 24px rgba(0,0,0,.12); animation: slide-up .25s ease; max-width: 560px; margin: 0 auto; }
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: 0 auto 20px; }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }

/* ── Verify form resident row (no role) ── */
.verify-resident-row { display: grid; grid-template-columns: 1fr 1fr 28px; gap: 8px; align-items: center; margin-bottom: 8px; }

/* ── Mobile ── */
@media (max-width: 600px) {
  .hh-item { flex-wrap: wrap; gap: 8px; }
  .hh-number { min-width: 60px; }
  .hh-actions { width: 100%; justify-content: flex-end; }
  .resident-row { grid-template-columns: 1fr 1fr 28px; }
  .resident-row .r-role, .resident-row label { display: none; }
  .verify-resident-row { grid-template-columns: 1fr 1fr 28px; }
  .vehicle-row { grid-template-columns: 1fr 28px; }
  .vehicle-row .v-make { display: none; }
  .section-hdr h1 { font-size: 18px; }
  .card-wide { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .sheet { padding: 20px 16px 28px; }
  header.top-bar { padding: 0 16px; }
  .main-content { padding: 16px; }
}
