:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --border: #e7e5dd;
  --border-strong: #d4d2c8;
  --text: #1a1a1a;
  --text-muted: #6a6862;
  --text-dim: #9a9892;
  --brand: #c8102e;        /* tow truck red */
  --brand-dark: #960c22;
  --accent: #1a3a5c;       /* deep navy */
  --pass: #1f7d3a;
  --pass-bg: #ecf7ee;
  --fail: #b91c1c;
  --fail-bg: #fdecec;
  --review: #b54708;
  --review-bg: #fef4e6;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg); color: var(--text);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Header */
.hdr { background: white; border-bottom: 1px solid var(--border); }
.hdr-inner {
  max-width: 720px; margin: 0 auto;
  padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 36px; height: 36px;
  background: var(--brand);
  border-radius: 4px;
  position: relative;
}
.logo-mark::after {
  content: ''; position: absolute; inset: 8px;
  border: 2px solid white;
  border-radius: 1px;
}
.logo-text .lt-1 {
  font-weight: 800; font-size: 16px; line-height: 1;
  letter-spacing: -0.01em;
}
.logo-text .lt-2 {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-top: 4px;
}
.hdr-link {
  font-size: 13px; font-weight: 600;
  color: var(--accent); text-decoration: none;
  border: 1px solid var(--border-strong);
  padding: 8px 12px; border-radius: 4px;
}
.hdr-link:hover { background: var(--bg); }

.hdr-actions { display: flex; align-items: center; gap: 8px; }
.lang-toggle {
  background: white; color: var(--text-muted);
  border: 1px solid var(--border-strong);
  padding: 7px 10px; border-radius: 4px;
  font-family: inherit; font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all .12s;
}
.lang-toggle:hover { border-color: var(--accent); }
.lang-toggle .lang-en, .lang-toggle .lang-es {
  color: var(--text-muted);
  padding: 0 2px;
  transition: color .12s;
}
.lang-toggle .lang-en.active, .lang-toggle .lang-es.active {
  color: var(--text); font-weight: 800;
}

/* Main */
main { max-width: 720px; margin: 0 auto; padding: 28px 20px 60px; }

.intro h1 {
  font-family: 'Instrument Serif', serif;
  font-size: 38px; line-height: 1.1; font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}
.intro .lede {
  font-size: 16px; color: var(--text-muted);
  max-width: 60ch;
}
@media (max-width: 540px) {
  .intro h1 { font-size: 30px; }
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px;
  margin-top: 18px;
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
}
.card-head h2 {
  font-size: 18px; font-weight: 700;
  letter-spacing: -0.01em;
}
.step-pill {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: white;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
}
.card-help { font-size: 14px; color: var(--text-muted); margin-bottom: 14px; }

/* Form fields */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 540px) { .grid-2 { grid-template-columns: 1fr; } }
.fld { display: block; }
.fld .lbl {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text); margin-bottom: 5px;
}
.fld .lbl em { font-style: normal; color: var(--text-dim); font-weight: 400; }
.fld input, .fld select, .fld textarea {
  width: 100%; background: white;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 11px 12px;
  font-family: inherit; font-size: 15px;
  color: var(--text);
  outline: none;
}
.fld input:focus, .fld select:focus, .fld textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,58,92,0.1);
}
.fld textarea { resize: vertical; }

/* Tenant grid */
.tenant-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.t-opt {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px; border: 1.5px solid var(--border-strong);
  border-radius: 6px; cursor: pointer;
  background: white;
  transition: all .15s;
}
.t-opt:hover { border-color: var(--accent); }
.t-opt input { display: none; }
.t-opt:has(input:checked) {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(26,58,92,0.04), transparent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.t-name { font-weight: 700; font-size: 14px; }
.t-sub { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; letter-spacing: 0.02em; }

/* Doc list */
#docs-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.doc-row {
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 12px;
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
}
.doc-thumb {
  width: 56px; height: 56px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; overflow: hidden;
  display: grid; place-items: center;
}
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb .pdf-badge { font-size: 12px; font-weight: 700; color: var(--brand); }
.doc-meta .fname { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; word-break: break-all; }
.doc-meta select {
  width: 100%; padding: 7px 9px; font-size: 13px;
  border: 1px solid var(--border-strong); border-radius: 4px;
  background: white; font-family: inherit;
}
.doc-rm {
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--text-muted); cursor: pointer;
  padding: 6px 10px; border-radius: 4px; font-size: 12px;
  font-family: inherit;
}
.doc-rm:hover { border-color: var(--fail); color: var(--fail); }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: 8px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  background: white;
  transition: all .15s;
  display: block;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(26,58,92,0.02);
}
.uz-icon {
  font-size: 38px; line-height: 1;
  color: var(--accent);
  font-weight: 300;
  margin-bottom: 6px;
}
.uz-title { font-weight: 700; font-size: 15px; }
.uz-sub { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* Hint box */
.hint-box {
  margin-top: 16px; padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-muted);
}
.hint-box strong { color: var(--text); display: block; margin-bottom: 6px; }
.hint-box ul { margin: 0 0 10px 18px; }
.hint-box li { margin: 2px 0; }

/* Submit */
.submit-row {
  margin-top: 22px;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
}
.btn-primary {
  background: var(--brand); color: white;
  border: none; border-radius: 6px;
  padding: 16px 32px;
  font-family: inherit; font-size: 16px; font-weight: 700;
  cursor: pointer;
  width: 100%; max-width: 400px;
  transition: background .15s;
}
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-primary:disabled { background: var(--border-strong); color: var(--text-dim); cursor: not-allowed; }
.btn-secondary {
  background: white; color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 12px 20px; border-radius: 6px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--accent); }
.legal { font-size: 11px; color: var(--text-dim); text-align: center; max-width: 400px; }

/* Result */
.result-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px 24px;
  margin-top: 28px;
  position: relative;
  overflow: hidden;
}
.result-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: var(--text-dim);
}
.result-card.pass::before { background: var(--pass); }
.result-card.pass { background: linear-gradient(180deg, var(--pass-bg), white 200px); }
.result-card.fail::before { background: var(--fail); }
.result-card.fail { background: linear-gradient(180deg, var(--fail-bg), white 200px); }
.result-card.review::before { background: var(--review); }
.result-card.review { background: linear-gradient(180deg, var(--review-bg), white 200px); }
.rc-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-muted); margin-bottom: 8px;
}
.rc-verdict {
  font-family: 'Instrument Serif', serif;
  font-size: 56px; font-weight: 400;
  line-height: 1; letter-spacing: -0.02em;
  margin-bottom: 14px;
}
.result-card.pass .rc-verdict { color: var(--pass); }
.result-card.fail .rc-verdict { color: var(--fail); }
.result-card.review .rc-verdict { color: var(--review); }
.rc-summary { font-size: 15px; color: var(--text); margin-bottom: 22px; max-width: 60ch; }
.rc-ref {
  background: white; border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 16px;
  margin-bottom: 22px;
}
.rcref-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
.rcref-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px; font-weight: 700;
  letter-spacing: 0.05em;
  margin-top: 4px;
}
.rcref-help { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.rc-next h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 10px; }
.rc-next ol { padding-left: 20px; font-size: 14px; }
.rc-next li { margin: 6px 0; }
.rc-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* Loading overlay */
.overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.92);
  z-index: 100;
  display: grid; place-items: center;
  backdrop-filter: blur(2px);
}
.ov-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px 28px;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}
.ov-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
.ov-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.ov-sub { font-size: 13px; color: var(--text-muted); }
@keyframes spin { to { transform: rotate(360deg); } }

footer {
  max-width: 720px; margin: 30px auto 0;
  padding: 20px;
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-muted);
  border-top: 1px solid var(--border);
}
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--accent); }
