/* ------------------------------------------------------------------
   Design intent: this is a decision-making tool, not a marketing page.
   Palette reads "case file" — ink, paper, and one signal color used
   only for decisions (pass/fail/review), so the eye learns that color
   = a verdict has been made, nothing else competes for that meaning.
------------------------------------------------------------------- */

:root {
  --ink: #1c1f26;
  --ink-soft: #5b6270;
  --paper: #faf9f6;
  --paper-raised: #ffffff;
  --line: #e4e1d9;
  --accent: #3a5a63;       /* deep teal — used sparingly: primary actions */
  --accent-soft: #e8eeef;
  --pass: #2f6b4f;
  --fail: #a13d3d;
  --review: #a17a2c;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------------- Top bar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-raised);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 28px; height: 28px;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-weight: 500;
  border-radius: 6px;
  font-size: 14px;
}
.brand-name { font-weight: 600; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-name { color: var(--ink-soft); font-size: 14px; }
.role-pill {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 4px 9px;
  border-radius: 20px;
}

/* ---------------- Buttons ---------------- */
.btn-primary, .btn-ghost {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  padding: 11px 18px;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s ease;
}
.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
}
.btn-primary:hover { opacity: 0.88; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--accent-soft); }

/* ---------------- Views / layout ---------------- */
#app { min-height: 100vh; }
.view { padding: 32px 28px 80px; max-width: 1040px; margin: 0 auto; }
.view-centered {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.view-header { margin-bottom: 24px; }
.view-header h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.01em; }
.subtle { color: var(--ink-soft); font-size: 14px; margin: 0; }

/* ---------------- Login card ---------------- */
.login-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 36px 32px;
  width: 360px;
  text-align: center;
}
.login-mark {
  width: 40px; height: 40px;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  border-radius: 10px;
  margin: 0 auto 16px;
  font-size: 18px;
}
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-card .subtle { margin-bottom: 22px; }
#login-form { text-align: left; display: flex; flex-direction: column; gap: 4px; }
#login-form label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-top: 12px;
}
#login-form input {
  font-family: var(--sans);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
#login-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
#login-form .btn-primary { margin-top: 20px; }
.error-text { color: var(--fail); font-size: 13px; margin-top: 10px; }

/* ---------------- Spinner ---------------- */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

/* ---------------- Data table ---------------- */
.table-wrap {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.data-table tbody tr { cursor: pointer; transition: background 0.1s ease; }
.data-table tbody tr:hover { background: var(--accent-soft); }
.data-table tbody tr:last-child td { border-bottom: none; }
.empty-state { padding: 40px; text-align: center; color: var(--ink-soft); font-size: 14px; }

.decision-badge {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 20px;
}
.decision-badge.pass { background: #e8f1ec; color: var(--pass); }
.decision-badge.fail { background: #f4e8e8; color: var(--fail); }
.decision-badge.review { background: #f4eee0; color: var(--review); }
.decision-badge.pending { background: var(--accent-soft); color: var(--ink-soft); }

/* ---------------- Detail panel (slide-over) ---------------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(28, 31, 38, 0.35);
  z-index: 10;
}
.detail-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 400px;
  background: var(--paper-raised);
  border-left: 1px solid var(--line);
  padding: 28px;
  overflow-y: auto;
  z-index: 11;
  display: flex;
  flex-direction: column;
}
.detail-close { align-self: flex-end; margin-bottom: 16px; }
.detail-panel h2 { margin: 0 0 2px; font-size: 19px; }
.detail-stats { display: flex; gap: 24px; margin: 20px 0; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 11px; text-transform: uppercase; color: var(--ink-soft); letter-spacing: 0.05em; }
.stat-value { font-family: var(--mono); font-size: 20px; }
.integrity-note {
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--accent-soft);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 4px 0 20px;
}
.detail-panel label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-top: 4px;
  display: block;
}
.detail-panel select, .detail-panel textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 6px;
  margin-bottom: 16px;
  background: var(--paper);
  resize: vertical;
}
.save-status { font-size: 13px; margin-top: 10px; color: var(--pass); }
.save-status.error { color: var(--fail); }

/* ---------------- Admin: upload + mapping + preview ---------------- */
.admin-step { margin-bottom: 20px; }
.upload-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 48px 20px;
  cursor: pointer;
  background: var(--paper-raised);
  text-align: center;
}
.upload-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-icon { font-size: 22px; color: var(--accent); }
.upload-title { font-weight: 600; }

.mapping-rows {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 20px;
  margin: 16px 0;
}
.mapping-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.mapping-row:last-child { border-bottom: none; }
.mapping-row .field-name { width: 140px; font-weight: 600; font-size: 14px; }
.mapping-row .field-required { color: var(--fail); font-size: 12px; margin-left: 4px; }
.mapping-row select {
  flex: 1;
  font-family: var(--sans);
  font-size: 14px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.preview-actions { display: flex; gap: 12px; margin-top: 18px; }
.preview-actions .btn-primary, .preview-actions .btn-ghost { width: auto; }

@media (max-width: 640px) {
  .detail-panel { width: 100%; }
  .topbar { padding: 12px 16px; }
  .view { padding: 20px 16px 60px; }
}
