:root {
  color-scheme: dark;
  --background: #090b0a;
  --panel: #101311;
  --panel-raised: #151916;
  --line: #292e2a;
  --muted: #8e978f;
  --text: #f0f3ee;
  --accent: #b8ff5a;
  --accent-soft: rgba(184, 255, 90, 0.12);
  --danger: #ff7b72;
  --radius: 18px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 74% 8%, rgba(184, 255, 90, 0.08), transparent 25rem),
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    var(--background);
  background-size: auto, 48px 48px, 48px 48px, auto;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  height: 74px;
  padding: 0 clamp(20px, 5vw, 76px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 10, 0.82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #090b0a;
  font-weight: 900;
  background: var(--accent);
  border-radius: 10px 2px 10px 2px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 14px;
  letter-spacing: 0.02em;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.safety-pill,
.source-tag {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  font-weight: 800;
}

.safety-pill {
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(184, 255, 90, 0.24);
  border-radius: 999px;
}

.safety-pill span {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent);
}

main {
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto;
}

.hero {
  padding: clamp(58px, 8vw, 108px) 0 52px;
  display: grid;
  grid-template-columns: 1fr minmax(260px, 380px);
  align-items: end;
  gap: 40px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  max-width: 850px;
  font-size: clamp(48px, 7vw, 104px);
  line-height: 0.92;
  letter-spacing: -0.065em;
  font-weight: 640;
}

h1 em {
  color: var(--muted);
  font-style: normal;
}

.hero-copy {
  max-width: 620px;
  margin: 28px 0 0;
  color: #aab1aa;
  font-size: clamp(15px, 1.6vw, 18px);
  line-height: 1.6;
}

.scope-card {
  border-left: 2px solid var(--accent);
  padding: 6px 0 6px 24px;
}

.scope-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
}

.scope-card strong {
  font-size: 17px;
}

.scope-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding-bottom: 70px;
}

.paper-lab {
  padding: 20px 0 90px;
}

.section-heading {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 54px);
  letter-spacing: -0.045em;
}

.paper-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.paper-controls,
.paper-results {
  padding: 24px;
}

.paper-controls > div:first-child {
  margin-bottom: 22px;
}

.paper-controls h3,
.paper-empty h3 {
  margin: 0;
  font-size: 18px;
}

.paper-controls p,
.paper-empty p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.paper-controls > label {
  margin-bottom: 16px;
}

.paper-results {
  min-height: 470px;
}

.paper-empty {
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.paper-empty div {
  max-width: 430px;
}

.paper-lock {
  width: 58px;
  height: 58px;
  flex: none;
  display: grid;
  place-items: center;
  color: #090b0a;
  background: var(--accent);
  border-radius: 15px 3px 15px 3px;
  font-weight: 900;
}

.paper-verdict {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.paper-verdict > div,
.candidate-card {
  padding: 16px;
  background: #0c0f0d;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.paper-verdict span,
.paper-verdict small,
.candidate-card span,
.candidate-card small {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.paper-verdict strong {
  display: block;
  margin: 8px 0 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px;
}

.candidate-card {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) 2fr;
  gap: 24px;
  align-items: center;
}

.candidate-card strong {
  display: block;
  margin: 7px 0 5px;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 17px;
}

.candidate-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.candidate-card dt {
  color: var(--muted);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.candidate-card dd {
  margin: 5px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.paper-detail-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.policy-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.policy-list li {
  padding: 8px 0 8px 15px;
  position: relative;
  color: var(--muted);
  border-bottom: 1px solid #222622;
  font-size: 10px;
  line-height: 1.45;
}

.policy-list li::before {
  content: "·";
  position: absolute;
  left: 2px;
  color: var(--accent);
}

.paper-order-gate {
  margin-top: 10px;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(190px, 260px);
  align-items: center;
  gap: 14px;
  background: rgba(184, 255, 90, 0.06);
  border: 1px solid rgba(184, 255, 90, 0.2);
  border-radius: 10px;
}

.confirmation {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  line-height: 1.4;
}

.confirmation input {
  width: 18px;
  height: 18px;
  flex: none;
  margin: 0;
}

.paper-order-gate > small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 10px;
}

.panel {
  background: rgba(16, 19, 17, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

.controls {
  padding: 24px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.025em;
}

.text-button {
  padding: 5px;
  color: var(--muted);
  border: 0;
  background: transparent;
  font-size: 12px;
}

.text-button:hover {
  color: var(--text);
}

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

.export-button {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

label {
  display: block;
  color: #aeb5ae;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

input,
select {
  width: 100%;
  height: 44px;
  margin-top: 7px;
  padding: 0 12px;
  color: var(--text);
  background: #0c0f0d;
  border: 1px solid #303631;
  border-radius: 9px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 255, 90, 0.08);
}

.controls > label,
.controls > .field-grid,
.controls > .date-range-control,
fieldset {
  margin-bottom: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-grid.three {
  grid-template-columns: repeat(3, 1fr);
}

.date-range-control small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.input-prefix,
.input-suffix {
  position: relative;
  display: block;
}

.input-prefix > span:first-child,
.input-suffix > span:last-child {
  position: absolute;
  top: 50%;
  z-index: 1;
  color: var(--muted);
  font-weight: 500;
}

.input-prefix > span:first-child {
  left: 12px;
  transform: translateY(-22%);
}

.input-prefix input {
  padding-left: 28px;
}

.input-suffix > span:last-child {
  right: 12px;
  transform: translateY(-22%);
}

.input-suffix input {
  padding-right: 42px;
}

fieldset {
  padding: 18px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

fieldset legend {
  padding: 0 10px 0 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 9px;
  font-weight: 800;
}

fieldset .field-grid {
  margin-bottom: 12px;
}

.data-import {
  margin: 8px 0 18px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #0c0f0d;
  border: 1px dashed #343a35;
  border-radius: 10px;
}

.data-import strong,
.data-import small {
  display: block;
}

.data-import strong {
  font-size: 11px;
}

.data-import small {
  max-width: 190px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-button {
  flex: none;
  padding: 8px 10px;
  color: var(--text);
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  font-size: 10px;
}

.file-button input {
  display: none;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #090b0a;
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  font-weight: 850;
}

.primary-button:hover {
  background: #c6ff7a;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.form-note {
  margin: 11px 0 0;
  color: #717971;
  text-align: center;
  font-size: 9px;
  line-height: 1.4;
}

.results {
  min-height: 720px;
  padding: clamp(22px, 3vw, 34px);
}

.source-tag {
  padding: 7px 9px;
  color: var(--muted);
  background: #0c0f0d;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.empty-state {
  min-height: 560px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
}

.empty-state h3 {
  margin: 26px 0 7px;
  font-size: 18px;
}

.empty-state p {
  max-width: 390px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.empty-orbit {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border: 1px solid #303630;
  border-radius: 50%;
  animation: orbit 10s linear infinite;
}

.empty-orbit::before {
  width: 38px;
  height: 38px;
  content: "";
  border: 1px solid #3c443c;
  border-radius: 50%;
}

.empty-orbit span {
  width: 8px;
  height: 8px;
  position: absolute;
  background: var(--accent);
  border-radius: 50%;
  transform: translateX(37px);
  box-shadow: 0 0 15px var(--accent);
}

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

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

.metric-grid article {
  min-width: 0;
  padding: 16px;
  background: #0c0f0d;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.metric-grid span,
.metric-grid small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-grid strong {
  display: block;
  margin: 10px 0 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(18px, 2.2vw, 28px);
  letter-spacing: -0.06em;
}

.positive {
  color: var(--accent);
}

.negative {
  color: var(--danger);
}

.chart-card,
.detail-card {
  background: #0c0f0d;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.chart-card {
  margin-top: 10px;
  padding: 20px 20px 4px;
}

.chart-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.chart-heading span,
.chart-heading strong {
  display: block;
}

.chart-heading span {
  color: var(--muted);
  font-size: 10px;
}

.chart-heading strong {
  margin-top: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 22px;
}

.chart-heading small {
  color: var(--muted);
  font-size: 10px;
}

.chart-meta,
.chart-legend {
  display: flex;
  align-items: flex-end;
}

.chart-meta {
  flex-direction: column;
  gap: 8px;
}

.chart-legend {
  gap: 6px;
  color: var(--muted);
  font-size: 9px;
}

.chart-legend i {
  width: 14px;
  height: 2px;
  display: inline-block;
  background: var(--accent);
}

.chart-legend i:last-of-type {
  background: repeating-linear-gradient(90deg, #737c74 0 4px, transparent 4px 7px);
}

#equity-chart {
  width: 100%;
  height: 260px;
  overflow: visible;
}

.detail-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 10px;
}

.detail-card {
  min-width: 0;
  padding: 18px;
}

.detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.detail-heading h3 {
  margin: 0;
  font-size: 13px;
}

.detail-heading span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

th,
td {
  padding: 9px 8px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid #222622;
}

th {
  color: var(--muted);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

td:nth-child(2) {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.warning-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.warning-list li {
  padding: 10px 0 10px 16px;
  position: relative;
  color: var(--muted);
  border-bottom: 1px solid #222622;
  font-size: 10px;
  line-height: 1.45;
}

.warning-list li::before {
  content: "!";
  position: absolute;
  left: 0;
  color: #d5a84b;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.error-box {
  margin-top: 18px;
  padding: 14px;
  color: #ffaaa4;
  background: rgba(255, 123, 114, 0.08);
  border: 1px solid rgba(255, 123, 114, 0.3);
  border-radius: 9px;
  font-size: 12px;
}

footer {
  padding: 25px clamp(20px, 5vw, 76px);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: #5e655e;
  border-top: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
}

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

  .scope-card {
    max-width: 500px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .paper-workspace {
    grid-template-columns: 1fr;
  }

  .results {
    min-height: 600px;
  }
}

@media (max-width: 700px) {
  main {
    width: min(100% - 24px, 1500px);
  }

  .topbar {
    padding: 0 14px;
  }

  .brand small {
    display: none;
  }

  .safety-pill {
    padding: 8px;
    font-size: 8px;
  }

  .hero {
    padding-top: 48px;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .section-heading,
  .paper-empty {
    align-items: flex-start;
  }

  .section-heading {
    flex-direction: column;
  }

  .paper-verdict,
  .paper-detail-grid,
  .candidate-card,
  .candidate-card dl,
  .paper-order-gate {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .field-grid.three {
    grid-template-columns: 1fr 1fr 1fr;
  }

  footer {
    flex-direction: column;
  }
}

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