:root {
  --bg: #f7f3ea;
  --panel: rgba(255, 251, 245, 0.94);
  --ink: #1f2937;
  --muted: #5f6b7a;
  --accent: #9a3412;
  --accent-dark: #7c2d12;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --line: #ddcfbf;
  --success: #166534;
  --error: #b42318;
  color-scheme: light;
  font-family: "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
}

body.is-busy {
  overflow: hidden;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top, rgba(15, 118, 110, 0.16), transparent 32%),
    linear-gradient(135deg, #efe7d7, #f3efe6);
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  background: rgba(255, 250, 242, 0.96);
  border: 1px solid #d8cfc2;
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(29, 26, 22, 0.14);
}

.app-body {
  background:
    radial-gradient(circle at top left, rgba(154, 52, 18, 0.14), transparent 30%),
    linear-gradient(180deg, #fdf8ef, var(--bg));
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px;
  backdrop-filter: blur(10px);
}

.topbar h1,
.login-card h1 {
  margin: 0 0 10px;
  font-size: 30px;
}

.topbar p,
.intro,
.hint {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.hint-compact {
  margin-top: 14px;
  margin-bottom: 0;
}

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

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 14px 40px rgba(31, 41, 55, 0.08);
}

h2 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 22px;
}

label {
  display: block;
  margin-top: 12px;
  margin-bottom: 6px;
  font-weight: 600;
}

input,
textarea,
button {
  width: 100%;
  border-radius: 12px;
  font-size: 15px;
}

input,
textarea {
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: white;
}

textarea {
  min-height: 150px;
  resize: vertical;
  font-family: Consolas, monospace;
}

button {
  border: none;
  padding: 13px 16px;
  cursor: pointer;
  background: linear-gradient(135deg, #c2410c, var(--accent));
  color: white;
  font-weight: 700;
  margin-top: 16px;
}

.login-card button {
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
}

.secondary {
  width: auto;
  margin-top: 0;
  padding: 10px 16px;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}

.status {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  display: none;
  white-space: pre-wrap;
}

.status.show {
  display: block;
}

.status.success {
  background: #ecfdf3;
  color: var(--success);
  border: 1px solid #abefc6;
}

.status.error {
  background: #fef3f2;
  color: var(--error);
  border: 1px solid #fecdca;
}

pre {
  margin: 16px 0 0;
  padding: 16px;
  border-radius: 14px;
  background: #1f2937;
  color: #f9fafb;
  overflow: auto;
  min-height: 220px;
}

.page-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
}

.result-shell {
  width: min(1100px, calc(100vw - 32px));
  margin: 24px auto 40px;
}

.result-hero {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 14px 40px rgba(31, 41, 55, 0.08);
}

.hero-eyebrow {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff1eb;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.result-hero h1 {
  margin: 14px 0 10px;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.05;
}

.summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 16px;
}

.result-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(280px, 340px) 1fr;
  margin-top: 20px;
}

.stack {
  display: grid;
  gap: 20px;
}

.result-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 14px 40px rgba(31, 41, 55, 0.08);
}

.result-card h2,
.result-card h3 {
  margin-top: 0;
}

.facts {
  display: grid;
  gap: 14px;
}

.fact-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fact-value {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.finding-list {
  display: grid;
  gap: 16px;
}

.finding {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.finding-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.finding-head h3 {
  margin: 0;
  font-size: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge.high {
  background: #fee4e2;
  color: #b42318;
}

.badge.medium {
  background: #fff3db;
  color: #b54708;
}

.badge.low {
  background: #ecfdf3;
  color: #166534;
}

.finding-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.finding p {
  margin: 0;
  line-height: 1.7;
}

.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.loader-overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(247, 243, 234, 0.86);
  backdrop-filter: blur(6px);
  z-index: 1000;
}

.loader-overlay.show {
  display: grid;
}

.loader-panel {
  width: min(480px, calc(100vw - 32px));
  text-align: center;
  background: rgba(255, 251, 245, 0.98);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(31, 41, 55, 0.14);
}

.loader-panel h2 {
  margin: 18px 0 10px;
}

.loader-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.spinner {
  width: 60px;
  height: 60px;
  margin: 0 auto;
  border-radius: 999px;
  border: 6px solid #f3d8c7;
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

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

@media (max-width: 860px) {
  .result-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .actions {
    justify-content: space-between;
  }
}
