:root {
  --bg:           #f8fafc;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --border-dash:  #cbd5e1;
  --text:         #0f172a;
  --muted:        #64748b;
  --primary:      #2563eb;
  --primary-h:    #1d4ed8;
  --radius:       10px;

  --green:        #15803d;
  --green-bg:     #dcfce7;
  --orange:       #b45309;
  --orange-bg:    #fef3c7;
  --red:          #b91c1c;
  --red-bg:       #fee2e2;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  padding: 48px 16px 80px;
}

.container {
  max-width: 720px;
  margin: 0 auto;
}

/* ── Header ──────────────────────────────── */
header {
  text-align: center;
  margin-bottom: 32px;
}

header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

header p {
  color: var(--muted);
  font-size: 14px;
}

/* ── Card ────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* ── Form ────────────────────────────────── */
form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── File zone ───────────────────────────── */
.file-zone {
  position: relative;
  border: 2px dashed var(--border-dash);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  transition: border-color 0.15s, background 0.15s;
}

.file-zone:hover,
.file-zone.drag-over {
  border-color: var(--primary);
  background: #eff6ff;
}

.file-zone.has-file {
  border-style: solid;
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--text);
}

.file-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.file-zone-inner svg        { color: var(--muted); transition: color 0.15s; }
.file-zone.has-file svg,
.file-zone.drag-over svg    { color: var(--primary); }

#file-label-text {
  font-size: 14px;
  font-weight: 500;
}

.file-zone-inner span {
  font-size: 12px;
  color: var(--muted);
}

/* ── Buttons ─────────────────────────────── */
.btn-primary {
  align-self: flex-start;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover    { background: var(--primary-h); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover { background: #eff6ff; }

/* ── Loading ─────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 4px;
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ───────────────────────────────── */
.error-banner {
  background: var(--red-bg);
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--red);
  font-size: 14px;
  margin-bottom: 16px;
}

/* ── Results ─────────────────────────────── */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.results-header h2 {
  font-size: 16px;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

.col-field {
  font-weight: 600;
}

.col-value {
  word-break: break-word;
}

/* ── Confidence badges ───────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}

.badge.high   { background: var(--green-bg);  color: var(--green); }
.badge.medium { background: var(--orange-bg); color: var(--orange); }
.badge.low    { background: var(--red-bg);    color: var(--red); }

/* ── Source tags ─────────────────────────── */
.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.tag-rule { background: #f1f5f9; color: #475569; }
.tag-llm  { background: #ede9fe; color: #6d28d9; }

/* ── Meta bar ────────────────────────────── */
.meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.meta-bar b { color: var(--text); }

/* ── Utility ─────────────────────────────── */
.hidden { display: none !important; }
