:root {
  color-scheme: dark;
  --bg: #080a09;
  --bg-2: #0e1110;
  --panel: rgba(18, 24, 22, 0.86);
  --panel-strong: rgba(23, 29, 26, 0.96);
  --line: rgba(146, 177, 161, 0.24);
  --line-strong: rgba(103, 235, 184, 0.48);
  --text: #edf6f0;
  --muted: #95a8a0;
  --soft: #c5d6cd;
  --green: #46efb4;
  --lime: #b9f46b;
  --amber: #ffbd54;
  --pink: #f56b9d;
  --aqua: #6adbe6;
  --danger: #ff7568;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 22% 0%, rgba(70, 239, 180, 0.13), transparent 30rem),
    radial-gradient(circle at 90% 12%, rgba(255, 189, 84, 0.11), transparent 28rem),
    linear-gradient(135deg, #070907 0%, #0d100f 46%, #10100c 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

.shell-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(120, 170, 150, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 170, 150, 0.07) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.88), rgba(0, 0, 0, 0.16));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 14px max(24px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid rgba(128, 185, 160, 0.22);
  background: rgba(8, 10, 9, 0.84);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(70, 239, 180, 0.16), rgba(255, 189, 84, 0.08)),
    #0d1310;
  color: var(--green);
  font-weight: 800;
}

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

.brand strong {
  font-size: 1rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.nav-links a,
.command {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid rgba(143, 171, 158, 0.28);
  border-radius: 8px;
  background: rgba(14, 18, 17, 0.72);
  color: var(--soft);
  font-size: 0.9rem;
  white-space: nowrap;
}

.nav-links a:hover,
.command:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.command.primary {
  border-color: rgba(70, 239, 180, 0.7);
  background: linear-gradient(135deg, rgba(70, 239, 180, 0.18), rgba(185, 244, 107, 0.08));
  color: #eafff6;
}

main {
  position: relative;
  z-index: 1;
}

section {
  padding-right: max(24px, calc((100vw - 1240px) / 2));
  padding-left: max(24px, calc((100vw - 1240px) / 2));
}

.overview-band {
  min-height: calc(100vh - 76px);
  padding-top: 36px;
  padding-bottom: 30px;
  border-bottom: 1px solid rgba(128, 185, 160, 0.18);
}

.overview-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(520px, 1.35fr);
  gap: 34px;
  align-items: center;
  min-height: calc(100vh - 142px);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-family: "Segoe UI Mono", Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  max-width: 650px;
  margin: 0;
  font-size: 4.7rem;
  line-height: 0.98;
}

h2 {
  margin: 0;
  font-size: 2.15rem;
  line-height: 1.1;
}

h3 {
  margin: 0;
  font-size: 1rem;
}

.lead {
  max-width: 650px;
  margin: 22px 0 0;
  color: var(--soft);
  font-size: 1.06rem;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

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

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.kpi-strip article,
.result-panel article {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 24, 22, 0.82);
  box-shadow: var(--shadow);
}

.kpi-strip article {
  padding: 16px;
}

.kpi-strip span,
.result-panel strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: "Segoe UI Mono", Consolas, monospace;
  font-size: 1.55rem;
  font-weight: 800;
}

.kpi-strip small,
.result-panel small,
.result-panel span,
.report-card small,
.foundry-card small {
  color: var(--muted);
}

.wafer-stage {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  border: 1px solid rgba(103, 235, 184, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(70, 239, 180, 0.08), rgba(245, 107, 157, 0.05)),
    rgba(10, 14, 13, 0.92);
  box-shadow: var(--shadow);
}

#waferCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.wafer-readout {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(260px, calc(100% - 36px));
  padding: 14px;
  border: 1px solid rgba(255, 189, 84, 0.36);
  border-radius: 8px;
  background: rgba(9, 11, 10, 0.78);
  backdrop-filter: blur(14px);
}

.wafer-readout span,
.wafer-readout small,
.wafer-readout strong {
  display: block;
}

.wafer-readout strong {
  color: var(--amber);
  font-family: "Segoe UI Mono", Consolas, monospace;
  font-size: 2rem;
}

.insight-band,
.workbench-band,
.tool-band,
.reports-band {
  padding-top: 76px;
  padding-bottom: 76px;
}

.insight-band,
.tool-band.alt {
  background: linear-gradient(180deg, rgba(15, 18, 16, 0.64), rgba(10, 12, 11, 0.28));
}

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

.section-head.compact {
  margin-bottom: 18px;
}

.foundry-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.foundry-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.foundry-card strong {
  display: block;
  overflow-wrap: anywhere;
}

.foundry-card .mini-meter,
.scale-track {
  position: relative;
  overflow: hidden;
  height: 8px;
  margin-top: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.foundry-card .mini-meter span,
.scale-track span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--pink));
}

.control-rail {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr 140px;
  gap: 10px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(143, 171, 158, 0.3);
  border-radius: 8px;
  background: rgba(8, 10, 9, 0.82);
  color: var(--text);
  outline: none;
  padding: 9px 11px;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(70, 239, 180, 0.12);
}

.ranking-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(520px, 1.1fr);
  gap: 14px;
}

.rank-panel,
.table-panel,
.tool-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head span {
  color: var(--amber);
  font-family: "Segoe UI Mono", Consolas, monospace;
  font-size: 0.86rem;
}

.ranking-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.rank-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 94px;
  gap: 10px;
  align-items: center;
  min-height: 74px;
  padding: 11px;
  border: 1px solid rgba(143, 171, 158, 0.16);
  border-radius: 8px;
  background: rgba(7, 10, 9, 0.46);
}

.rank-index {
  color: var(--green);
  font-family: "Segoe UI Mono", Consolas, monospace;
  font-weight: 800;
}

.rank-main {
  min-width: 0;
}

.rank-main strong,
.rank-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-main span {
  color: var(--muted);
  font-size: 0.8rem;
}

.rank-value {
  text-align: right;
}

.rank-value strong {
  display: block;
  color: var(--amber);
  font-family: "Segoe UI Mono", Consolas, monospace;
}

.rank-value small {
  color: var(--muted);
}

.rank-bar {
  grid-column: 2 / 4;
  overflow: hidden;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.rank-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber));
}

.data-table-wrap {
  overflow: auto;
  max-height: 980px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
  font-size: 0.86rem;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(143, 171, 158, 0.14);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #111713;
  color: var(--green);
  font-size: 0.75rem;
  text-transform: uppercase;
}

td {
  color: var(--soft);
}

.numeric {
  color: var(--text);
  font-family: "Segoe UI Mono", Consolas, monospace;
  text-align: right;
  white-space: nowrap;
}

.confidence {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(143, 171, 158, 0.2);
  border-radius: 999px;
  color: var(--soft);
  font-size: 0.76rem;
  white-space: nowrap;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(520px, 1.28fr);
  gap: 14px;
  align-items: stretch;
}

.tool-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-content: start;
  padding: 16px;
}

.tool-panel .wide {
  grid-column: 1 / -1;
}

.result-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.yield-results {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.result-panel article {
  padding: 16px;
}

.result-panel strong {
  color: var(--amber);
}

.formula-box,
.nearest-match,
.yield-chart-wrap {
  grid-column: 1 / -1;
  border: 1px solid rgba(143, 171, 158, 0.18);
  border-radius: 8px;
  background: rgba(7, 10, 9, 0.48);
}

.formula-box {
  padding: 16px;
}

.formula-box > span {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-family: "Segoe UI Mono", Consolas, monospace;
  font-size: 0.82rem;
}

.nearest-match {
  min-height: 86px;
  padding: 16px;
}

.nearest-match strong,
.nearest-match span {
  display: block;
}

.nearest-match span {
  color: var(--muted);
  font-size: 0.88rem;
}

.yield-chart-wrap {
  overflow: hidden;
  min-height: 280px;
  padding: 10px;
}

#yieldCanvas {
  display: block;
  width: 100%;
  height: 280px;
}

.reports-band {
  background: linear-gradient(180deg, rgba(9, 12, 11, 0.18), rgba(13, 15, 12, 0.68));
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.report-card {
  display: grid;
  gap: 10px;
  min-height: 170px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(70, 239, 180, 0.11), rgba(245, 107, 157, 0.07)),
    var(--panel-strong);
  box-shadow: var(--shadow);
}

.report-card:hover {
  border-color: var(--line-strong);
}

.report-card span {
  width: max-content;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid rgba(255, 189, 84, 0.42);
  border-radius: 999px;
  color: var(--amber);
  font-family: "Segoe UI Mono", Consolas, monospace;
  font-size: 0.76rem;
}

.report-card strong {
  font-size: 1.16rem;
}

.site-footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 24px max(24px, calc((100vw - 1240px) / 2));
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #080a09;
  font-size: 0.86rem;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
}

@media (max-width: 1080px) {
  .overview-layout,
  .ranking-layout,
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .overview-layout {
    min-height: auto;
  }

  h1 {
    font-size: 3.4rem;
  }

  .foundry-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .control-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    position: relative;
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    justify-content: flex-start;
  }

  .overview-band {
    min-height: auto;
    padding-top: 26px;
  }

  .overview-layout {
    gap: 22px;
  }

  h1 {
    font-size: 2.45rem;
  }

  h2 {
    font-size: 1.7rem;
  }

  .lead {
    font-size: 1rem;
  }

  .kpi-strip,
  .foundry-grid,
  .control-rail,
  .tool-panel,
  .result-panel,
  .yield-results,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .wafer-stage,
  #waferCanvas {
    min-height: 340px;
  }

  .rank-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .rank-value {
    grid-column: 2;
    text-align: left;
  }

  .rank-bar {
    grid-column: 1 / -1;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
