/* review_app — minimal stylesheet. No framework, no build step. */

:root {
  --bg:            #fafafa;
  --surface:       #ffffff;
  --border:        #e3e6ea;
  --text:          #20232a;
  --muted:         #6b7280;
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --success:       #15803d;
  --warning:       #b45309;
  --danger:        #b91c1c;
  --diff-bg:       #fffbe6;
  --diff-border:   #f59e0b;
  --badge-bg:      #eef2ff;
  --badge-text:    #3730a3;
  --shadow:        0 1px 2px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px; line-height: 1.45;
  color: var(--text); background: var(--bg);
  height: 100%;
}

body { display: flex; flex-direction: column; }
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ── Top bar ───────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.6rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a:hover { color: var(--text); }
.auth-badge { font-size: 0.9em; }

/* ── Review grid (two-column) ──────────────────────────────────────────── */
.review-grid {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
}
.pdf-pane {
  border-right: 1px solid var(--border);
  background: #000; min-height: 0;
  display: flex; flex-direction: column;
}
.pdf-frame {
  flex: 1; border: 0; width: 100%; height: 100%;
  background: #525659;
}
.pdf-missing {
  padding: 2rem; color: #fee;
  background: #1f2937; height: 100%; overflow-y: auto;
  display: flex; flex-direction: column; justify-content: center;
}
.pdf-missing h2 { margin-top: 0; color: #fde68a; }
.pdf-missing code { color: #fde68a; background: rgba(0,0,0,0.3); padding: 1px 4px; border-radius: 3px; }
.pdf-missing .muted { color: #9ca3af; }

.pdf-upload {
  background: rgba(255,255,255,0.05);
  border: 1px dashed rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 1rem; margin: 0.5rem 0;
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
}
.pdf-upload input[type=file] {
  color: #fee; flex: 1; min-width: 0;
}
.pdf-upload input[type=file]::file-selector-button {
  background: #374151; color: #fee; border: 1px solid #4b5563;
  padding: 0.35rem 0.75rem; border-radius: 4px; margin-right: 0.5rem;
  cursor: pointer; font-family: inherit; font-size: 0.95em;
}
.pdf-upload input[type=file]::file-selector-button:hover { background: #4b5563; }
.pdf-upload button {
  background: var(--primary); color: white; border: 0;
  padding: 0.4rem 0.9rem; border-radius: 4px; cursor: pointer;
  font-family: inherit; font-size: 0.95em;
}
.pdf-upload button:hover { background: var(--primary-dark); }

.form-pane {
  padding: 1rem 1.25rem;
  overflow-y: auto; min-height: 0;
  background: var(--surface);
}

/* ── Row header / progress ─────────────────────────────────────────────── */
.row-header { margin-bottom: 0.75rem; }
.row-position { font-size: 1.05em; }
.row-position .muted { font-size: 0.9em; }
.row-category { margin-top: 0.25rem; }
.row-key {
  font-family: SFMono-Regular, Menlo, monospace;
  font-size: 0.85em; color: var(--muted);
  margin: 0.25rem 0 0.5rem 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.progress-bar {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.progress-fill { height: 100%; background: var(--success); transition: width .2s; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  background: var(--badge-bg); color: var(--badge-text);
  font-size: 0.85em; font-weight: 500;
}

/* ── Order form ─────────────────────────────────────────────────────────── */
.order-form { margin: 0.5rem 0 1rem 0; font-size: 0.9em; color: var(--muted); }
.order-form.inline { display: inline-block; }
.order-form select { margin-left: 0.4rem; padding: 2px 6px; }

/* ── Form fields ───────────────────────────────────────────────────────── */
.field {
  margin-bottom: 0.65rem;
  padding: 0.4rem 0.5rem 0.4rem 0.65rem;
  border-left: 3px solid transparent;
  border-radius: 3px;
  transition: background .15s, border-color .15s;
}
.field.changed {
  background: var(--diff-bg);
  border-left-color: var(--diff-border);
}
.field label {
  display: block; font-weight: 500; font-size: 0.85em;
  color: var(--muted); margin-bottom: 0.2rem;
}
.field input[type=text], .field select {
  width: 100%; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 0.95em; background: white;
  font-family: inherit;
}
.field input[type=text]:focus, .field select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}
.field input[readonly] { background: #f3f4f6; color: var(--muted); }
.field .cat-custom { margin-top: 0.3rem; }
.hidden { display: none; }

/* ── Action buttons ─────────────────────────────────────────────────────── */
.actions {
  position: sticky; bottom: 0;
  background: linear-gradient(to bottom, transparent, var(--surface) 30%);
  padding: 1rem 0 0.5rem 0;
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin-top: 0.75rem;
}
.actions button {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border); border-radius: 5px;
  font-size: 0.95em; cursor: pointer;
  background: white; color: var(--text);
  font-family: inherit;
}
.actions button:hover { background: #f5f7fa; }
.btn-primary {
  background: var(--primary) !important; color: white !important;
  border-color: var(--primary) !important; flex: 1;
}
.btn-primary:hover { background: var(--primary-dark) !important; }
.btn-secondary { color: var(--muted); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2 !important; }

kbd {
  display: inline-block; padding: 1px 5px;
  font-family: SFMono-Regular, Menlo, monospace; font-size: 0.85em;
  background: rgba(255,255,255,0.2); color: inherit;
  border: 1px solid rgba(255,255,255,0.3); border-radius: 3px;
}
.btn-primary kbd { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.35); }

.hint {
  margin-top: 0.5rem; font-size: 0.8em; color: var(--muted);
}
.hint kbd { background: var(--bg); color: var(--text); border-color: var(--border); }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
  padding: 0.5rem 1rem; border-radius: 4px;
  background: #111827; color: white; font-size: 0.9em;
  opacity: 0; pointer-events: none;
  transition: opacity .15s;
  z-index: 100;
}
.toast.show { opacity: 0.92; }
.toast.info { background: #1e40af; }

/* ── Stats page ────────────────────────────────────────────────────────── */
.stats-page { max-width: 1100px; margin: 0 auto; padding: 1rem 1.5rem 3rem; }
.stat-cards {
  display: grid; gap: 0.75rem; margin-bottom: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 1rem; text-align: center;
  box-shadow: var(--shadow);
}
.card-num { font-size: 1.8em; font-weight: 600; color: var(--text); }
.card-lbl { font-size: 0.85em; color: var(--muted); margin-top: 0.2rem; }

.field-rates {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden;
}
.field-rates th, .field-rates td {
  padding: 0.45rem 0.75rem; text-align: left;
  border-bottom: 1px solid var(--border);
}
.field-rates th { background: #f5f7fa; font-weight: 600; font-size: 0.9em; }
.field-rates .num { text-align: right; font-variant-numeric: tabular-nums; }
.field-rates tr:last-child td { border-bottom: 0; }
.rate-bar-cell { width: 200px; }
.rate-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.rate-fill { height: 100%; background: var(--warning); }

.recent-corrections {
  list-style: none; padding: 0; margin: 0;
  max-height: 500px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
.recent-corrections li {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.recent-corrections li:last-child { border-bottom: 0; }
.rc-meta { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; font-size: 0.85em; margin-bottom: 0.2rem; }
.rc-meta code { font-size: 0.95em; color: var(--muted); }
.rc-diff { font-size: 0.95em; }
.rc-diff code { background: #f5f7fa; padding: 1px 4px; border-radius: 3px; }
.ai-was code { color: var(--danger); }
.human-now code { color: var(--success); }
.arrow { color: var(--muted); margin: 0 0.3rem; }

.muted { color: var(--muted); }

/* ── Done state ────────────────────────────────────────────────────────── */
.done-state { padding: 3rem; text-align: center; max-width: 600px; margin: 0 auto; }
.done-state h1 { color: var(--success); }
