:root {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #0d1726;
  --surface-raised: #101c2d;
  --header: #11233d;
  --border: #315275;
  --cyan: #7dd3fc;
  --cyan-soft: #a5f3fc;
  --text: #d8e2f0;
  --muted: #94a3b8;
  --teal: #0f766e;
  --teal-bright: #2dd4bf;
  --green: #86efac;
  --yellow: #facc15;
  --red: #ef4444;
  --red-bg: #3f1219;
  --radius: 14px;
  --body-font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono-font: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-family: var(--mono-font);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 80% -10%, rgba(3, 105, 161, 0.19), transparent 34rem),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--border);
  background: rgba(17, 35, 61, 0.94);
  backdrop-filter: blur(12px);
}

.brand { display: flex; gap: 12px; align-items: center; color: var(--cyan); text-decoration: none; }
.brand strong { display: block; letter-spacing: 0.12em; }
.brand small { display: block; color: var(--muted); }
.brand-mark {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border: 1px solid var(--cyan);
  border-radius: 12px;
  background: #0369a1;
  color: #f0f9ff;
  font-size: 1.4rem;
  font-weight: 800;
}
.brand-mark.small { width: 40px; height: 40px; border-radius: 10px; font-size: 1.1rem; }

.account { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.account #new-report { color: var(--cyan-soft); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal-bright); }

.app-shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 72px; }
.eyebrow, .section-kicker { margin: 0; color: var(--cyan); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.16em; }

.panel {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(13, 23, 38, 0.96);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.2);
}
.panel-toggle {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 12px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(49, 82, 117, 0.72);
  border-radius: 6px;
  background: rgba(11, 18, 32, 0.72);
  color: var(--muted);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
}
.panel-toggle:hover { border-color: var(--cyan); color: var(--cyan-soft); }
.collapsed-panel-label { display: none; }
.collapsible-panel.is-collapsed {
  display: block;
  min-height: 44px;
  padding: 12px 18px;
  border-color: var(--border);
  background: rgba(13, 23, 38, 0.82);
  box-shadow: none;
}
.collapsible-panel.is-collapsed > :not(.panel-toggle, .collapsed-panel-label) { display: none; }
.collapsible-panel.is-collapsed .collapsed-panel-label {
  display: block;
  padding-right: 38px;
  color: var(--cyan-soft);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  line-height: 20px;
  text-transform: uppercase;
}
.collapsible-panel.is-collapsed .panel-toggle {
  position: absolute;
  top: 8px;
  right: 12px;
  display: grid;
  width: 26px;
  padding: 0;
  place-items: center;
  color: var(--cyan-soft);
}
.input-panel, .report-section, .warning-panel { padding: clamp(18px, 3vw, 28px); }
.input-panel { border-color: var(--teal); }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 16px; }
h2 { margin: 4px 0 0; color: #f0f9ff; font-size: clamp(1.05rem, 2.4vw, 1.35rem); font-weight: 650; }
.input-panel h1 { margin: 4px 0 0; color: #f0f9ff; font-size: clamp(1.2rem, 2.6vw, 1.5rem); font-weight: 650; }
.panel-description { max-width: 82ch; margin: 7px 0 0; color: var(--muted); font-size: 0.86rem; }
.mode-badge { padding: 5px 9px; border: 1px solid #0369a1; border-radius: 6px; color: var(--cyan); font-size: 0.72rem; }
.input-heading-actions { display: flex; align-items: center; gap: 8px; }
.collapse-input { font-size: 0.76rem; }

label { display: block; margin: 15px 0 6px; color: var(--cyan-soft); font-weight: 700; }
.optional { color: var(--muted); font-size: 0.78rem; font-weight: 400; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
  background: var(--surface-raised);
  color: var(--text);
  padding: 10px 12px;
  resize: vertical;
}
input:focus, select:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.1); }
.help-text, .muted { color: var(--muted); }
.help-text { margin: 6px 0 0; font-size: 0.76rem; }
.package-options {
  margin-top: 16px;
  padding: 10px 12px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(16, 28, 45, 0.55);
}
.package-options > summary { font-weight: 700; }
.package-options input[type="file"] { padding: 8px; font-size: 0.82rem; }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.reopen-input {
  display: none;
  width: 100%;
  justify-content: space-between;
  padding: 3px 1px;
  border: 0;
  background: transparent;
  color: var(--cyan-soft);
  font-weight: 650;
}
.input-panel.is-compact { padding: 13px 18px; border-color: var(--border); }
.input-panel.is-compact .reopen-input { display: flex; }
.input-panel.is-compact .panel-heading,
.input-panel.is-compact form { display: none; }

button, .link-button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 15px;
  color: #f0f9ff;
  cursor: pointer;
  text-decoration: none;
}
button:disabled { cursor: wait; opacity: 0.55; }
button:disabled.decision-settled { cursor: default; opacity: 0.72; }
.primary { background: var(--teal); }
.primary:hover { background: #0d9488; }
.secondary, .quiet { border-color: var(--border); background: var(--surface-raised); }
.secondary:hover, .quiet:hover { border-color: var(--cyan); }
.quiet { padding: 7px 10px; color: var(--muted); }

.progress-panel { margin-top: 16px; padding: 20px 24px; scroll-margin-block: 24px; }
.analysis-progress-panel {
  margin-top: 14px;
  padding: 13px 18px;
  border-color: var(--teal);
  scroll-margin-block: 88px;
}
.analysis-progress-panel h2 { font-size: 1rem; font-weight: 600; }
.analysis-progress-panel .progress-title { gap: 11px; }
.analysis-progress-panel .spinner { width: 20px; height: 20px; border-width: 2px; }
.progress-history {
  margin: 10px 0 0 31px;
  padding-top: 8px;
  border-top: 1px solid rgba(49, 82, 117, 0.55);
}
.progress-history summary { font-size: 0.78rem; }
.progress-history .progress-list { margin: 9px 0 0 20px; font-size: 0.78rem; }
.analysis-progress-panel.is-complete { border-color: #15803d; }
.analysis-progress-panel.is-complete .spinner { display: none; }
.analysis-progress-panel.is-failed { border-color: var(--red); background: var(--red-bg); }
.analysis-progress-panel.is-failed .spinner { display: none; }
.progress-title { display: flex; align-items: center; gap: 15px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--cyan); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-list { margin: 20px 0 0 43px; padding: 0; color: var(--muted); }
.progress-list li { margin: 7px 0; padding-left: 4px; }
.progress-list li::marker { color: var(--teal-bright); }

.error-panel { margin-top: 22px; padding: 24px; border-color: var(--red); background: var(--red-bg); }
.error-panel .section-kicker, .form-error { color: #fecaca; }
.error-next { color: #fecaca; }
.error-details {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 10px;
  background: rgba(22, 14, 20, 0.55);
}
.error-details summary { color: #fecaca; }
.details-list {
  margin: 10px 0 0 20px;
  padding: 0;
  color: #fecaca;
}
.details-list li { margin: 4px 0; }

.result { margin-top: 20px; scroll-margin-block: 20px; }
.score-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 22px;
  align-items: center;
  padding: 46px 24px 18px;
  border-color: var(--cyan);
}
.score-copy h2 { margin-top: 2px; color: var(--cyan); font-size: clamp(1.5rem, 4vw, 2rem); }
.decision-line { display: block; }
.rate-scale {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(520px, 100%);
  margin: 7px 0 9px;
  padding: 0;
  list-style: none;
}
.rate-scale li {
  position: relative;
  padding: 7px 7px 4px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.2;
  text-align: left;
}
.rate-scale li::before {
  position: absolute;
  top: -5px;
  left: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border);
  content: "";
}
.rate-scale li.current {
  border-top-color: var(--cyan);
  color: #f0f9ff;
  font-weight: 700;
}
.rate-scale li.current::before {
  background: var(--cyan);
  box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.12);
}
.rate-rationale { max-width: 72ch; margin: 4px 0 10px; color: var(--muted); font-size: 0.82rem; }
.result-actions {
  display: grid;
  width: 190px;
  min-width: 0;
  height: 100%;
  grid-template-rows: auto 1fr;
  gap: 12px;
  align-items: start;
}
.result-actions .link-button { justify-self: end; }
.decision-action-stack {
  display: grid;
  width: 100%;
  align-self: center;
  gap: 8px;
}
.decision-action-stack button { width: 100%; }
.drop-action-wrap { position: relative; display: block; }
.go-action { background: #15803d; }
.go-action:hover { background: #16a34a; }
.drop-action { border-color: #b91c1c; background: #7f1d1d; }
.drop-action:hover { background: #991b1b; }
.drop-action.decision-settled {
  border-color: #475569;
  background: #334155;
  color: #94a3b8;
}
.decision-tooltip {
  position: absolute;
  z-index: 5;
  top: calc(100% + 7px);
  right: 0;
  width: 280px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #111c2c;
  color: #cbd5e1;
  font-family: var(--body-font);
  font-size: 0.76rem;
  line-height: 1.4;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}
.drop-action-wrap:not(:hover, :focus-within) .decision-tooltip { display: none; }
.decision-tooltip[hidden] { display: none; }
}
.metadata-grid { display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 12px; }
.metadata-grid div { padding: 6px 10px; border-left: 2px solid var(--border); }
.metadata-grid span, .metadata-grid strong { display: block; }
.metadata-grid span { color: var(--muted); font-size: 0.74rem; text-transform: uppercase; }
.metadata-grid strong { margin-top: 3px; color: var(--text); }

.report-section { margin-top: 20px; }
.summary-section { border-color: #0f766e; }
.summary-label { font-size: 1rem; letter-spacing: 0.12em; }
.summary-copy { max-width: 88ch; margin: 12px 0 0; font-size: 1.05rem; }
.insights-panel {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(49, 82, 117, 0.65);
}
.insight-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-top: 14px;
  border-top: 1px solid rgba(49, 82, 117, 0.55);
}
.insight-group { min-width: 0; padding: 18px 22px 0 0; }
.insight-group + .insight-group {
  padding-right: 0;
  padding-left: 22px;
  border-left: 1px solid rgba(49, 82, 117, 0.55);
}
.insight-group h2 {
  margin: 0;
  color: #dbeafe;
  font-family: var(--body-font);
  font-size: 1rem;
  font-weight: 550;
}
.coverage-gaps h2 { color: #ddd6fe; }
.insight-description {
  margin: 4px 0 0;
  color: var(--muted);
  font-family: var(--body-font);
  font-size: 0.78rem;
}
.evidence-item { padding: 18px 0; border-top: 1px solid rgba(49, 82, 117, 0.65); }
.evidence-item:first-child { margin-top: 12px; }
.evidence-item > p { margin: 0; }
details { margin-top: 10px; color: var(--muted); font-size: 0.82rem; }
summary { cursor: pointer; color: var(--cyan); }
blockquote { margin: 9px 0 0; padding-left: 12px; border-left: 2px solid var(--border); }
.provenance { display: block; margin-top: 8px; color: var(--muted); }
.empty-evidence { color: var(--muted); }
.warning-panel { margin-top: 20px; border-color: #a16207; }
.warning-panel .section-kicker { color: var(--yellow); }

.analysis-result {
  margin-top: 28px;
  padding: clamp(22px, 4vw, 34px);
  border-color: #38bdf8;
  background: linear-gradient(145deg, rgba(14, 43, 68, 0.98), rgba(13, 23, 38, 0.98));
  box-shadow: 0 24px 70px rgba(2, 132, 199, 0.12);
  scroll-margin-block: 88px;
}
.analysis-result-heading {
  display: block;
  min-width: 0;
}
.analysis-result h2 { margin-top: 5px; font-family: var(--body-font); font-size: clamp(1.45rem, 3vw, 1.9rem); }
.analysis-explainer {
  max-width: 72ch;
  margin: 8px 0 0;
  color: #b6c8dc;
  font-family: var(--body-font);
  font-size: 0.9rem;
}
.analysis-rate {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 18px 0 0;
  padding: 7px 11px;
  border: 1px solid rgba(125, 211, 252, 0.55);
  border-radius: 999px;
  background: rgba(3, 105, 161, 0.28);
  color: #e0f2fe;
  font-family: var(--body-font);
  font-size: 0.8rem;
  font-weight: 750;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
}
.analysis-rate-rationale {
  max-width: 76ch;
  margin: 10px 0 0;
  color: #dbeafe;
  font-family: var(--body-font);
  font-size: 0.95rem;
  line-height: 1.55;
}
.analysis-summary {
  max-width: 84ch;
  margin: 24px 0 0;
  color: #f1f5f9;
  font-family: var(--body-font);
  font-size: clamp(1rem, 1.8vw, 1.1rem);
  line-height: 1.72;
}
.analysis-downloads { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 24px; }
.download-label {
  width: 100%;
  margin: 0 0 2px;
  color: #94a3b8;
  font-family: var(--body-font);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.12em;
}
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid #38bdf8;
  border-radius: 8px;
  background: #0369a1;
  color: #f0f9ff;
  font-family: var(--body-font);
  font-weight: 700;
  text-decoration: none;
}
.download-button:hover { background: #0284c7; }
.secondary-download { border-color: #64748b; background: #1e293b; }
.secondary-download:hover { border-color: #94a3b8; background: #334155; }

.login-body {
  display: grid;
  width: 100%;
  height: 100svh;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  padding: clamp(14px, 3vh, 24px);
}
.login-shell { width: min(400px, 100%); }
.login-card {
  padding: clamp(24px, 6vw, 36px);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
}
.login-card h1 {
  margin: 0 0 24px;
  color: #f0f9ff;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.login-card label { margin-top: 16px; font-size: 0.84rem; font-weight: 600; }
.login-card input { padding: 10px 12px; font-size: 0.88rem; }
.login-card button { font-size: 0.86rem; font-weight: 600; }
.stack .primary { width: 100%; margin-top: 22px; }
.form-error { margin: 14px 0 0; }

[hidden] { display: none !important; }

@media (max-width: 780px) {
  .topbar { position: static; }
  .account > span:not(.status-dot) { display: none; }
  .account { gap: 6px; }
  .account .quiet { padding: 6px 8px; font-size: 0.74rem; }
  .app-shell { width: min(100% - 22px, 680px); padding-top: 32px; }
  .score-panel { grid-template-columns: 1fr; justify-items: start; }
  .decision-line, .rate-scale { width: 100%; }
  .metadata-grid { grid-template-columns: 1fr; width: 100%; }
  .insight-columns { grid-template-columns: 1fr; }
  .insight-group { padding-right: 0; }
  .insight-group + .insight-group {
    margin-top: 18px;
    padding: 18px 0 0;
    border-top: 1px solid rgba(49, 82, 117, 0.55);
    border-left: 0;
  }
  .link-button { width: 100%; text-align: center; }
  .result-actions { width: 100%; }
  .decision-tooltip { right: auto; left: 0; width: min(280px, 100%); }
  .result-actions .link-button { justify-self: stretch; }
  .analysis-downloads { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

@media (max-height: 500px) {
  .login-body {
    height: auto;
    min-height: 100svh;
    align-items: start;
    overflow-y: auto;
  }
}
