:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #dbe3ee;
  --accent: #1f6feb;
  --accent-dark: #1557b0;
  --danger: #b42318;
  --warning: #9a6700;
  --success: #067647;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 750;
  font-size: 18px;
  color: var(--text);
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.user-email { color: var(--muted); font-size: 14px; }
.inline-form { display: inline; }

.link-button {
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.container {
  width: min(1100px, calc(100% - 32px));
  margin: 28px auto 60px;
}

h1, h2, h3 { line-height: 1.25; margin-top: 0; }
h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 16px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

.diagnosis-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 0;
  font-size: 14px;
}
.diagnosis-codes {
  padding: 2px 8px;
  border-radius: 6px;
  background: #eef3fb;
  color: var(--accent);
  font-weight: 650;
}
.diagnosis-name {
  color: var(--text);
  font-weight: 650;
}
.pdf-link {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 650;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}

.auth-card { max-width: 460px; margin: 40px auto; }
.delete-card { max-width: 560px; margin: 40px auto; }
.delete-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 22px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

label {
  display: block;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 600;
}

input[type="email"],
input[type="password"],
input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
}

button, .button {
  display: inline-block;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button:hover, .button:hover { background: var(--accent-dark); text-decoration: none; }
.button.secondary { background: #eef3fb; color: var(--accent); }
.button.secondary:hover { background: #dfe9fb; }
.button.danger { background: #fde8e7; color: var(--danger); }
.button.danger:hover { background: #f9d4d1; }

.upload-form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.upload-form input[type="file"] { flex: 1 1 320px; margin-top: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2f7;
  color: #344054;
}
.status-queued { background: #fff4d6; color: #7a4d00; }
.status-processing { background: #e7f0ff; color: #1b4f9c; }
.status-completed { background: #e7f7ee; color: var(--success); }
.status-failed { background: #fde8e7; color: var(--danger); }

.alert { padding: 12px 14px; border-radius: 8px; margin: 14px 0; }
.alert.error { background: #fde8e7; color: var(--danger); border: 1px solid #f6c7c3; }
.alert.warning { background: #fff8e5; color: var(--warning); border: 1px solid #f1dfad; }
.alert.success { background: #e7f7ee; color: var(--success); border: 1px solid #b7e4c8; }

.score {
  font-size: 34px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  margin: 18px 0;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 20px 0;
}
.comparison-grid > div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.comparison-grid ul { margin: 8px 0 0; padding-left: 20px; }

.progress {
  height: 8px;
  background: #e8eef8;
  border-radius: 999px;
  overflow: hidden;
}
.progress span {
  display: block;
  width: 35%;
  height: 100%;
  background: var(--accent);
  animation: pulse 1.4s ease-in-out infinite alternate;
}
@keyframes pulse { from { margin-left: 0; } to { margin-left: 65%; } }

.raw-result { margin-top: 18px; }
.raw-result pre {
  max-height: 460px;
  overflow: auto;
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 10px;
  font-size: 12px;
}

.error-card { max-width: 560px; margin: 40px auto; text-align: center; }
.error-code { font-size: 56px; font-weight: 800; color: var(--danger); }

@media (max-width: 700px) {
  .topbar { padding: 12px 16px; align-items: flex-start; flex-direction: column; }
  .comparison-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
}
