:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --ink: #1f2421;
  --muted: #69706b;
  --line: #d8ddd6;
  --surface: #ffffff;
  --accent: #0f766e;
  --accent-2: #b45309;
  --blue: #1d4ed8;
  --danger: #b42318;
  --soft: #e8f3ef;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.auth-widget {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 146px;
}

.auth-widget button,
.auth-form button,
.google-button,
.modal-close {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
}

.auth-widget > button {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.auth-widget.auth-unavailable > button {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.auth-widget button:disabled,
.auth-form button:disabled,
.google-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

#authUser {
  display: grid;
  gap: 3px;
  min-width: 220px;
  padding: 10px 12px;
  border: 1px solid #bcd8cf;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #f7fffb;
}

#authUser[data-role="admin"] {
  border-color: #d0a85a;
  border-left-color: var(--accent-2);
  background: #fffaf1;
}

#authUser strong,
#authUser span {
  overflow-wrap: anywhere;
}

#authUser .auth-kicker {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

#authUser strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
}

#authUser span {
  color: var(--muted);
  font-size: 12px;
}

#authUser .auth-role {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 20px;
  padding: 0 8px;
  border: 1px solid #d0a85a;
  border-radius: 999px;
  background: #fff2cc;
  color: #7c4a03;
  font-size: 11px;
  font-weight: 800;
}

#authProvider {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

#authUser button {
  min-height: 30px;
  margin-top: 4px;
  padding: 0 8px;
  font-size: 12px;
}

.author-block {
  max-width: min(42vw, 460px);
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  line-height: 1.28;
  text-align: right;
}

.author-block strong,
.author-block span,
.author-block a {
  display: block;
}

.author-block strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.author-block a {
  color: var(--accent);
  text-decoration: none;
}

.author-block a:hover {
  text-decoration: underline;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.1;
}

h2 {
  font-size: 17px;
}

.status {
  min-width: 108px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.status.ok {
  color: var(--accent);
  border-color: #8dd5c8;
  background: #effaf7;
}

.status.error {
  color: var(--danger);
  border-color: #f1a9a2;
  background: #fff4f2;
}

.layout {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 48px) 44px;
}

body.privacy-locked {
  overflow: hidden;
}

body.modal-open {
  overflow: hidden;
}

body.privacy-locked .topbar,
body.privacy-locked .layout {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

.agreement-backdrop[hidden] {
  display: none;
}

.auth-backdrop[hidden] {
  display: none;
}

.agreement-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 40px);
  background: rgba(31, 36, 33, 0.48);
  backdrop-filter: blur(10px);
}

.auth-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 40px);
  background: rgba(31, 36, 33, 0.42);
  backdrop-filter: blur(8px);
}

.agreement-modal {
  width: min(560px, 100%);
  padding: 24px;
  border: 1px solid rgba(216, 221, 214, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 64px rgba(31, 36, 33, 0.22);
}

.auth-modal {
  position: relative;
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid rgba(216, 221, 214, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 64px rgba(31, 36, 33, 0.22);
}

.auth-modal h2 {
  font-size: 22px;
}

.auth-modal p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  min-height: 34px;
  padding: 0;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.auth-tabs button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  color: var(--muted);
  cursor: pointer;
}

.auth-tabs button.active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
  font-weight: 700;
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.auth-form label {
  display: grid;
  gap: 6px;
}

.auth-form span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.auth-form input {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 8px 10px;
}

.auth-form button,
.google-button {
  width: 100%;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.google-button {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 15px 0;
  color: var(--muted);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.agreement-modal h2 {
  font-size: 22px;
}

.agreement-lead {
  margin: 10px 0 16px;
  color: var(--muted);
  line-height: 1.48;
}

.agreement-points {
  display: grid;
  gap: 10px;
}

.agreement-points div {
  padding: 12px 13px;
  border: 1px solid #c7d9d2;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #f7fffb;
}

.agreement-points strong,
.agreement-points span {
  display: block;
}

.agreement-points strong {
  font-size: 13px;
}

.agreement-points span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.38;
}

.agreement-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 16px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.42;
}

.agreement-check input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.agreement-modal button {
  width: 100%;
  min-height: 42px;
  margin-top: 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.agreement-modal button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
}

.upload-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 132px;
  padding: 24px;
  border: 1px dashed #8eb8ac;
  border-radius: 8px;
  background: var(--surface);
}

.upload-panel.dragging {
  border-color: var(--accent);
  background: var(--soft);
}

.upload-panel p {
  margin: 8px 0 0;
  color: var(--muted);
}

.upload-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.target-control {
  display: grid;
  gap: 6px;
  min-width: 260px;
}

.target-control span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.target-control select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 0 10px;
}

.privacy-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.privacy-panel div {
  min-height: 78px;
  padding: 13px 14px;
  border: 1px solid #bcd8cf;
  border-radius: 8px;
  background: #f7fffb;
}

.privacy-panel strong,
.privacy-panel span {
  display: block;
}

.privacy-panel strong {
  color: var(--accent);
  font-size: 13px;
}

.privacy-panel span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.file-button,
.actions button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 0 16px;
  cursor: pointer;
  white-space: nowrap;
}

.file-button input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

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

.actions button {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.actions button:hover,
.file-button:hover {
  filter: brightness(0.98);
}

.actions button.member-locked,
#downloadGraphSvg.member-locked {
  border-color: #d99b34;
  background: #fff8ec;
  color: #7c3d08;
}

.actions button.member-locked::after,
#downloadGraphSvg.member-locked::after {
  content: "Member";
  margin-left: 8px;
  color: #7c3d08;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.metric {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 21px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.insight-dashboard {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.insight-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.76fr) minmax(0, 1.24fr);
  gap: 14px;
  align-items: stretch;
}

.readiness-card {
  min-height: 204px;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid #cfd7d2;
  border-radius: 8px;
  background: #fbfcfa;
}

.score-ring {
  --score-deg: 0deg;
  --score-color: var(--accent);
  width: 112px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--score-color) var(--score-deg), #e4e8e3 0deg);
  position: relative;
}

.score-ring::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: white;
  box-shadow: inset 0 0 0 1px var(--line);
}

.score-ring span {
  position: relative;
  z-index: 1;
  color: var(--ink);
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.score-ring.good {
  --score-color: var(--accent);
}

.score-ring.warn {
  --score-color: var(--accent-2);
}

.score-ring.risk {
  --score-color: var(--danger);
}

.readiness-card strong {
  display: block;
  font-size: 20px;
  line-height: 1.18;
}

.readiness-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.insight-card {
  min-height: 126px;
  padding: 12px;
  border: 1px solid var(--line);
  border-top: 3px solid #aeb8b1;
  border-radius: 8px;
  background: white;
}

.insight-card.good {
  border-top-color: var(--accent);
}

.insight-card.warn {
  border-top-color: var(--accent-2);
}

.insight-card.risk {
  border-top-color: var(--danger);
}

.insight-card span,
.mini-panel-head span,
.roofline-bar span,
.signal-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.insight-card strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.insight-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.38;
}

.professional-panels {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr) minmax(0, 0.75fr);
  gap: 12px;
  margin-top: 14px;
}

.mini-panel {
  min-height: 168px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

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

.mini-panel h3 {
  margin: 0;
  font-size: 14px;
}

.roofline-bars {
  display: grid;
  gap: 12px;
}

.roofline-bar > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.roofline-bar strong {
  color: var(--ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border: 1px solid #d5dbd4;
  border-radius: 999px;
  background: #edf0eb;
}

.bar-track i {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
}

.bar-track .compute-bound,
.legend-swatch.compute-bound {
  background: var(--accent);
}

.bar-track .mixed,
.legend-swatch.mixed {
  background: var(--accent-2);
}

.bar-track .memory-bound,
.legend-swatch.memory-bound {
  background: var(--danger);
}

.signal-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.signal-item {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-left: 4px solid #aeb8b1;
  border-radius: 6px;
  background: white;
}

.signal-item.compute-bound,
.signal-item.good {
  border-left-color: var(--accent);
}

.signal-item.mixed,
.signal-item.warn {
  border-left-color: var(--accent-2);
}

.signal-item.memory-bound,
.signal-item.risk {
  border-left-color: var(--danger);
}

.signal-item.neutral {
  border-left-color: #aeb8b1;
}

.signal-item strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.legend-stack {
  display: grid;
  gap: 11px;
}

.legend-stack div {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
}

.legend-swatch,
.legend-dot {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(31, 36, 33, 0.16);
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 2px white, 0 0 0 3px rgba(180, 83, 9, 0.45);
}

.preprocess-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.preprocess-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(280px, 0.62fr) minmax(360px, 1.1fr);
  gap: 14px;
  align-items: start;
}

.preprocess-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.preprocess-controls .secondary-file-button,
.preprocess-controls button {
  grid-column: 1 / -1;
}

.preprocess-controls label:not(.secondary-file-button) {
  display: grid;
  gap: 6px;
}

.preprocess-controls span {
  color: var(--muted);
  font-size: 12px;
}

.preprocess-controls input,
.preprocess-controls select {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 8px 10px;
}

.preprocess-controls button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.preprocess-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.preprocess-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111815;
  overflow: hidden;
}

.preprocess-preview canvas {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  background: #050807;
}

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

.diagram-section,
.insight-dashboard,
.preprocess-panel,
.graph-explorer,
.inference-panel,
.tables {
  margin-top: 22px;
}

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

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.inference-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.controls label {
  display: grid;
  gap: 6px;
  min-width: 136px;
}

.controls label span {
  color: var(--muted);
  font-size: 12px;
}

.controls select,
.controls input {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 0 10px;
}

.controls button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 0 14px;
  cursor: pointer;
}

.controls button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.runtime-signals {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.runtime-signal {
  min-height: 58px;
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 9px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.runtime-signal i {
  width: 9px;
  height: 9px;
  grid-row: 1 / span 2;
  border-radius: 50%;
  background: var(--muted);
}

.runtime-signal span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.runtime-signal strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.runtime-signal.good {
  border-color: #9cc9bd;
  background: #f4fbf8;
}

.runtime-signal.good i {
  background: var(--accent);
}

.runtime-signal.warn {
  border-color: #e1bf8f;
  background: #fff8ed;
}

.runtime-signal.warn i {
  background: var(--accent-2);
}

.runtime-signal.risk {
  border-color: #e3a6a0;
  background: #fff5f4;
}

.runtime-signal.risk i {
  background: var(--danger);
}

.table-wrap.compact {
  margin-top: 12px;
  max-height: 260px;
}

.graph-explorer {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.graph-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.graph-tools label {
  display: grid;
  gap: 6px;
  min-width: min(100%, 260px);
}

.graph-tools span {
  color: var(--muted);
  font-size: 12px;
}

.graph-tools input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 8px 10px;
}

.graph-tools button,
.secondary-file-button,
.graph-map-toolbar button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
}

.secondary-file-button input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.graph-map-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  margin-bottom: 16px;
  overflow: hidden;
}

.graph-map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: white;
}

.graph-map-toolbar label {
  display: grid;
  gap: 5px;
  min-width: 120px;
}

.graph-map-toolbar label span,
.graph-map-toolbar > span {
  color: var(--muted);
  font-size: 12px;
}

.graph-map-toolbar select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 0 8px;
}

.graph-map-toolbar button {
  min-width: 38px;
  min-height: 34px;
}

.graph-map-viewport {
  height: clamp(320px, 44vh, 560px);
  overflow: hidden;
  background:
    linear-gradient(#eef1ed 1px, transparent 1px),
    linear-gradient(90deg, #eef1ed 1px, transparent 1px);
  background-color: #fbfcfa;
  background-size: 28px 28px;
}

.graph-map-panel:has(#graphMapSvg.full-graph) .graph-map-viewport {
  height: clamp(440px, 62vh, 760px);
}

#graphMapSvg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
}

#graphMapSvg.dragging {
  cursor: grabbing;
}

.graph-edge {
  fill: none;
  stroke: #9aa39d;
  stroke-width: 1.5;
}

.graph-edge-label {
  fill: var(--muted);
  font-size: 10px;
}

.graph-node rect {
  fill: white;
  stroke: #aeb8b1;
  stroke-width: 1.2;
}

.graph-node.compute-bound rect {
  stroke: #0f766e;
}

.graph-node.memory-bound rect {
  stroke: #b42318;
}

.graph-node.chain-break rect {
  stroke: var(--danger);
  stroke-width: 2.6;
  stroke-dasharray: 7 4;
}

.graph-node.mixed rect {
  stroke: #b45309;
}

.graph-node.selected rect {
  stroke: #1f2421;
  stroke-width: 2.8;
}

.graph-node text {
  fill: var(--ink);
  font-size: 12px;
  pointer-events: none;
}

.graph-node .subtext {
  fill: var(--muted);
  font-size: 10px;
}

.graph-node .overlay-dot {
  fill: var(--accent-2);
  stroke: white;
  stroke-width: 1.5;
}

#graphMapSvg.full-graph .graph-edge {
  stroke-width: 1.1;
  stroke-opacity: 0.72;
}

#graphMapSvg.full-graph .graph-node rect {
  stroke-width: 1;
}

#graphMapSvg.full-graph .graph-node.selected rect {
  stroke-width: 2.6;
}

.graph-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.3fr) minmax(320px, 0.7fr);
  gap: 16px;
  align-items: start;
}

.graph-list-wrap {
  max-height: 620px;
}

tr.selected-row td {
  background: #eef8f5;
}

.op-detail {
  max-height: 620px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
}

.op-detail h3,
.op-detail h4 {
  margin: 0;
}

.op-detail h3 {
  font-size: 16px;
}

.op-detail h4 {
  margin-top: 16px;
  font-size: 13px;
}

.op-detail p,
.op-detail li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.op-detail ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px;
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.detail-grid strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.stage-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0 12px;
}

.stage {
  flex: 0 0 178px;
  min-height: 112px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stage b,
.stage span {
  display: block;
}

.stage b {
  font-size: 14px;
}

.stage span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tables {
  display: grid;
  grid-template-columns: minmax(260px, 0.6fr) minmax(420px, 1fr);
  gap: 20px;
  align-items: start;
}

.tables > div:last-child {
  grid-column: 1 / -1;
}

.table-wrap {
  max-height: 440px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #fbfcfa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.wrap {
  max-width: 360px;
  overflow-wrap: anywhere;
}

.good-text {
  color: var(--accent);
  font-weight: 700;
}

.warn-text {
  color: var(--accent-2);
  font-weight: 700;
}

.risk-text {
  color: var(--danger);
  font-weight: 700;
}

.muted-text {
  color: var(--muted);
}

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

  .topbar-meta {
    align-items: stretch;
    justify-content: flex-start;
  }

  .author-block {
    max-width: 100%;
    text-align: left;
  }

  .status {
    text-align: left;
  }

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

  .insight-layout,
  .professional-panels,
  .preprocess-layout {
    grid-template-columns: 1fr;
  }

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

  .runtime-signals {
    grid-template-columns: 1fr;
  }

  .graph-layout {
    grid-template-columns: 1fr;
  }

  .upload-controls,
  .file-button,
  .target-control {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .readiness-card {
    grid-template-columns: 1fr;
  }

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

  .preprocess-controls,
  .preprocess-report {
    grid-template-columns: 1fr;
  }
}
