/* ----- base ----- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1a1a1a;
  background: #f4f5f7;
  font-size: 14px;
  line-height: 1.45;
}

a { color: #1a2332; }

.muted { color: #6b7280; }
.small { font-size: 0.85rem; }
.mono  { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace; font-size: 0.85rem; }
.error { color: #b00020; margin-top: 12px; font-size: 0.9rem; }
.info  { color: #15803d; background: #dcfce7; padding: 8px 12px; border-radius: 4px; }
.info.error { color: #b00020; background: #fee2e2; }

button, input[type=submit] {
  padding: 6px 14px; font-size: 0.95rem; cursor: pointer;
  background: #f5a623; color: #1a2332; border: 0; border-radius: 4px;
  font-weight: 500;
}
button:hover:not(:disabled) { background: #e8961a; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.btn-secondary { background: #e5e7eb; color: #1a2332; }
button.btn-secondary:hover { background: #d1d5db; }
.btn-link, .link-btn {
  background: transparent; color: #1d4ed8; border: 0; padding: 0; font-size: inherit;
  text-decoration: underline; cursor: pointer;
}

input[type=text], input[type=password], input[type=email], input[type=search], input[type=number],
input[type=date], select, textarea {
  padding: 6px 10px; font-size: 0.95rem; border: 1px solid #d1d5db; border-radius: 4px;
  background: #fff; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #f5a623; outline-offset: -1px; border-color: #f5a623; }

/* ----- topbar ----- */
.topbar {
  background: #1a2332; color: #fff;
  padding: 10px 24px; display: flex; align-items: center; gap: 24px;
  border-bottom: 3px solid #f5a623;
}
.topbar .brand a { color: #fff; text-decoration: none; font-weight: 600; font-size: 1.1rem; }
.topnav { display: flex; gap: 16px; flex: 1; }
.topnav a { color: #cbd5e1; text-decoration: none; padding: 4px 10px; border-radius: 4px; font-size: 0.95rem; }
.topnav a.active, .topnav a:hover { color: #fff; background: rgba(245, 166, 35, 0.18); }
.userblock { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }
.userblock .user-name { color: #cbd5e1; }
.userblock button { background: transparent; color: #cbd5e1; border: 1px solid #475569; padding: 4px 12px; }
.userblock button:hover { background: #334155; color: #fff; }
.role-badge { display: inline-block; background: #f5a623; color: #1a2332; padding: 1px 6px; border-radius: 3px; font-size: 0.7rem; margin-left: 4px; font-weight: 600; }

.page { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* ----- card / forms ----- */
.card { background: #fff; padding: 24px; border-radius: 8px; border: 1px solid #e5e7eb; margin-bottom: 16px; }
.card h1 { margin: 0 0 8px; font-size: 1.4rem; }
.card h2 { margin: 24px 0 8px; font-size: 1.1rem; }
.actions { margin-top: 16px; display: flex; align-items: center; gap: 12px; }
.form-stack { display: flex; flex-direction: column; gap: 10px; max-width: 460px; }
.form-stack label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: #374151; }

/* ----- login (existing) ----- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: #fff; padding: 32px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.08); width: 100%; max-width: 380px; }
.login-card h1 { margin: 0 0 4px; font-size: 1.5rem; }
.login-card p { margin: 0 0 20px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 0.875rem; color: #374151; }
.login-card input { padding: 8px 10px; font-size: 1rem; border: 1px solid #d1d5db; border-radius: 4px; }
.login-card button { margin-top: 8px; padding: 10px 16px; background: #f5a623; color: #1a2332; border: 0; border-radius: 4px; font-size: 1rem; cursor: pointer; }

/* ----- upload ----- */
.dropzone {
  margin-top: 16px; border: 2px dashed #cbd5e1; border-radius: 8px;
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.drag-over { border-color: #f5a623; background: #fffbeb; }
.dropzone-icon { font-size: 2.5rem; margin-bottom: 8px; }
.progress-track { background: #e5e7eb; height: 8px; border-radius: 4px; overflow: hidden; margin: 16px 0; }
.progress-bar { background: #f5a623; height: 100%; width: 0; transition: width 0.4s; }
.stage-list { list-style: none; padding: 0; margin: 16px 0; }
.stage-list li { padding: 6px 0; color: #6b7280; padding-left: 24px; position: relative; }
.stage-list li::before { content: "○"; position: absolute; left: 4px; }
.stage-list li.done { color: #16a34a; }
.stage-list li.done::before { content: "✓"; color: #16a34a; }
.stage-list li.active { color: #1a2332; font-weight: 500; }
.stage-list li.active::before { content: "▶"; color: #f5a623; }

/* ----- review ----- */
.review-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; background: #fff; padding: 24px; border-radius: 8px; border: 1px solid #e5e7eb; margin-bottom: 12px; }
.review-vehicle h1 { margin: 0 0 4px; font-size: 1.5rem; }
.verdict-block { text-align: center; min-width: 160px; }
.verdict-badge { font-size: 1.4rem; font-weight: 700; padding: 10px 20px; border-radius: 6px; display: inline-block; color: #fff; }
.verdict-pass    .verdict-badge, .verdict-pill.verdict-pass    { background: #16a34a; color: #fff; }
.verdict-fail    .verdict-badge, .verdict-pill.verdict-fail    { background: #dc2626; color: #fff; }
.verdict-needs_review .verdict-badge, .verdict-pill.verdict-needs_review { background: #f59e0b; color: #fff; }
.verdict-incomplete .verdict-badge, .verdict-pill.verdict-incomplete { background: #6b7280; color: #fff; }
.verdict-unknown .verdict-badge, .verdict-pill.verdict-unknown, .verdict-processing { background: #9ca3af; color: #fff; }
.verdict-pill { display: inline-block; padding: 2px 10px; border-radius: 3px; font-size: 0.8rem; font-weight: 600; }
.verdict-counts { margin-top: 8px; font-size: 0.85rem; }
.verdict-counts .count { display: inline-block; padding: 2px 8px; border-radius: 3px; margin: 0 2px; background: #f3f4f6; }
.verdict-counts .pass   { color: #16a34a; }
.verdict-counts .fail   { color: #dc2626; }
.verdict-counts .review { color: #f59e0b; }

.review-actions { background: #fff; padding: 12px 24px; border: 1px solid #e5e7eb; border-radius: 8px; margin-bottom: 12px; display: flex; gap: 16px; align-items: center; }
.review-actions .btn-link { margin-right: auto; }
.btn-pdf {
  display: inline-block; padding: 6px 14px; background: #1a2332; color: #fff;
  border-radius: 4px; text-decoration: none; font-size: 0.9rem; font-weight: 500;
}
.btn-pdf:hover { background: #2d3a4d; }

.checklist .cat-group { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; margin-bottom: 8px; padding: 12px 16px; }
.checklist summary { font-weight: 600; cursor: pointer; padding: 4px 0; }
.checklist .cat-count { color: #6b7280; font-weight: 400; font-size: 0.9rem; }
.rules-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.92rem; }
.rules-table th, .rules-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #f3f4f6; vertical-align: top; }
.rules-table th { font-weight: 600; color: #6b7280; font-size: 0.8rem; }
.rules-table .col-status { width: 28px; }
.rules-table .col-id { width: 60px; }
.rules-table .col-msg { width: 40%; }
.rule-row.status-fail   td { background: #fef2f2; }
.rule-row.status-review td { background: #fffbeb; }
.rule-row.status-na     td { color: #9ca3af; }
.rule-row.overridden    td { background: #ecfdf5 !important; }
.rule-row .msg { color: #4b5563; font-size: 0.9rem; margin-bottom: 4px; }
.ovr-badge { display: inline-block; background: #16a34a; color: #fff; font-size: 0.7rem; padding: 1px 6px; border-radius: 3px; margin-left: 6px; }

/* ----- modal ----- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card { background: #fff; border-radius: 8px; width: 100%; max-width: 480px; box-shadow: 0 12px 32px rgba(0,0,0,0.18); overflow: hidden; }
.modal-card.dragging { user-select: none; opacity: 0.96; }
.modal-drag-handle {
  cursor: move;
  background: #1a2332; color: #fff;
  padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 0.95rem;
  user-select: none;
}
.modal-close { background: transparent; color: #cbd5e1; border: 0; font-size: 1.4rem; line-height: 1; padding: 0 4px; cursor: pointer; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 20px 24px 24px; }
.modal-card h3 { margin: 0 0 8px; }
.modal-drag-handle #ovr-rule-id { color: #f5a623; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace; }
.ovr-rule-desc { margin: 0 0 4px; font-weight: 500; color: #1a2332; }
.ovr-rule-desc:empty { display: none; }
.ovr-rule-msg { margin: 0 0 12px; padding: 8px 10px; background: #fef2f2; border-left: 3px solid #dc2626; color: #4b5563; font-size: 0.9rem; border-radius: 2px; }
.ovr-rule-msg:empty { display: none; }
.modal-card label { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-size: 0.9rem; }
.modal-actions { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; }

/* ----- tables ----- */
.data-table { width: 100%; background: #fff; border-collapse: collapse; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; margin-top: 16px; font-size: 0.92rem; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #f3f4f6; vertical-align: top; }
.data-table thead { background: #f9fafb; }
.data-table thead th { font-weight: 600; font-size: 0.8rem; color: #4b5563; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table tbody tr.row-link:hover { background: #f9fafb; }
.data-table .details { max-width: 400px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ----- filters bar ----- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.filters input, .filters select { font-size: 0.9rem; }
.filters button { font-size: 0.9rem; }
