:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1a1d23;
  --muted: #6b7280;
  --brand: #10403b;
  --brand-2: #1d7a6e;
  --accent: #0f6cf5;
  --green-bg: #e8f7ee;
  --green-fg: #17803d;
  --red-bg: #fdecec;
  --red-fg: #c0392b;
  --amber-bg: #fff6e0;
  --amber-fg: #9a6700;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --border: #2a2f37;
    --text: #e7e9ec;
    --muted: #9aa1ab;
    --brand: #1d7a6e;
    --brand-2: #2fa392;
    --green-bg: #123322;
    --green-fg: #4ade80;
    --red-bg: #3a1717;
    --red-fg: #f87171;
    --amber-bg: #3a2c0d;
    --amber-fg: #facc15;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
  font-weight: 700;
  font-size: 18px;
}

.brand h1 { font-size: 18px; margin: 0; }
.brand p { font-size: 13px; color: var(--muted); margin: 0; }

.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--green-fg); }
.dot.bad { background: var(--red-fg); }

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel h2 { margin-top: 0; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone:focus, .dropzone.dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  outline: none;
}
.dropzone-icon { font-size: 32px; margin-bottom: 8px; }
.dropzone p { margin: 4px 0; }

.samples { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.sample-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.sample-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.sample-btn:hover { border-color: var(--accent); }
.sample-btn:active { transform: scale(0.97); }

.error {
  margin-top: 16px;
  background: var(--red-bg);
  color: var(--red-fg);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
}

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.steps li {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted);
  font-size: 14px;
}
.step-dot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  position: relative;
}
.steps li.active .step-dot {
  border-color: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.done .step-dot {
  border-color: var(--green-fg);
  background: var(--green-fg);
}
.steps li.done .step-dot::after {
  content: "";
  position: absolute; left: 6px; top: 2px;
  width: 4px; height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.steps li.done { color: var(--text); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 35%, transparent); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

.decision-card { text-align: center; padding: 12px 0 20px; }
.decision-badge {
  display: inline-block;
  padding: 10px 24px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: var(--border);
}
.decision-badge.approved { background: var(--green-bg); color: var(--green-fg); }
.decision-badge.declined { background: var(--red-bg); color: var(--red-fg); }
.decision-badge.review { background: var(--amber-bg); color: var(--amber-fg); }

.decision-reason { margin: 14px auto 0; max-width: 560px; font-weight: 600; }
.decision-explain { margin: 6px auto 0; max-width: 560px; color: var(--muted); font-style: italic; }

.extracted-note {
  background: var(--amber-bg); color: var(--amber-fg);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 18px;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 8px; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }

.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 18px 0 8px; }
.card h3:first-child { margin-top: 0; }

table.fields { width: 100%; border-collapse: collapse; font-size: 14px; }
table.fields td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
table.fields td:first-child { color: var(--muted); width: 55%; }
table.fields td:last-child { text-align: right; font-weight: 600; }

.raw-details { margin-top: 18px; font-size: 13px; }
.raw-details summary { cursor: pointer; color: var(--muted); }
.raw-details pre {
  margin-top: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

button.secondary {
  margin-top: 24px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
button.secondary:hover { border-color: var(--accent); }

footer { text-align: center; padding: 0 20px 40px; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-form {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-brand { margin-bottom: 10px; }
.login-form label { font-size: 13px; color: var(--muted); margin-top: 6px; }
.login-form input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}
.login-error { color: var(--red-fg); font-size: 13px; margin: 0; }
button.primary {
  margin-top: 8px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button.primary:hover { background: var(--brand-2); }
button.primary:disabled { opacity: 0.6; cursor: default; }

.signed-in { margin-left: 8px; }
button.linklike {
  background: none;
  border: none;
  padding: 0;
  margin-left: 6px;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}
