:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f7fafb;
  --surface-strong: #eef3f6;
  --ink: #17202a;
  --muted: #657381;
  --line: #dce4ea;
  --teal: #0f8b8d;
  --blue: #2264ad;
  --green: #248a53;
  --amber: #c98212;
  --red: #bf3d3d;
  --graphite: #2d343c;
  --shadow: 0 18px 42px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui,
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(244, 246, 248, 0.9)),
    radial-gradient(circle at 8% 4%, rgba(15, 139, 141, 0.1), transparent 28%),
    radial-gradient(circle at 90% 2%, rgba(201, 130, 18, 0.08), transparent 26%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(15, 139, 141, 0.95), rgba(34, 100, 173, 0.95));
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.22;
  letter-spacing: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}

.status-strip {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  margin-bottom: 18px;
}

.status-row,
.side-row,
.metric-line,
.table-row,
.stream-row,
.gate-row,
.signal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-row span:first-child,
.metric-line span:first-child,
.side-row span:first-child,
.stream-row span:first-child,
.gate-row span:first-child,
.signal-row span:first-child {
  color: var(--muted);
}

.status-row strong {
  font-size: 13px;
}

.progress {
  height: 8px;
  border-radius: 99px;
  background: #d7e0e7;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  width: var(--value, 50%);
  background: linear-gradient(90deg, var(--teal), var(--green));
}

.side-nav {
  display: grid;
  gap: 8px;
  margin: 18px 0 24px;
}

.nav-button {
  min-height: 44px;
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--graphite);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.nav-button svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.9;
}

.nav-button.active {
  background: #e8f4f4;
  color: #075d5e;
  font-weight: 700;
}

.side-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: grid;
  gap: 12px;
}

.side-section h2 {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0;
}

.side-row {
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.green {
  color: #14613b;
  background: #dff3e8;
}

.badge.amber {
  color: #7b4e0d;
  background: #f6e6c8;
}

.badge.red {
  color: #872b2b;
  background: #f6dada;
}

.badge.blue {
  color: #174d85;
  background: #dfeaf8;
}

.badge.teal {
  color: #075d5e;
  background: #dcefee;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-title h2 {
  margin: 0;
  font-size: clamp(22px, 2.35vw, 31px);
  line-height: 1.12;
  letter-spacing: 0;
}

.page-title p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 860px;
  line-height: 1.55;
  font-size: 14px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.action {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 9px 13px;
  color: #fff;
  background: var(--graphite);
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(45, 52, 60, 0.12);
}

.action.secondary {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: none;
}

.action svg {
  width: 17px;
  height: 17px;
}

.action.compact {
  min-height: 36px;
  padding: 7px 11px;
}

.file-input {
  display: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.panel,
.kpi,
.template-card,
.unit-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 116px;
  padding: 16px;
  display: grid;
  align-content: space-between;
  gap: 12px;
}

.kpi-label {
  color: var(--muted);
  font-size: 13px;
}

.kpi-value {
  font-size: 29px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0;
}

.kpi-foot {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: 1.35;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
  background: var(--green);
}

.dot.amber {
  background: var(--amber);
}

.dot.red {
  background: var(--red);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.52fr) minmax(348px, 0.88fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
}

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

.three-column {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  overflow: hidden;
}

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

.panel-header h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 16px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.template-card {
  min-height: 142px;
  padding: 14px;
  display: grid;
  gap: 10px;
  align-content: start;
  cursor: pointer;
  box-shadow: none;
  transition:
    border-color 0.16s ease,
    transform 0.16s ease,
    background 0.16s ease;
}

.template-card:hover,
.template-card.active {
  border-color: rgba(15, 139, 141, 0.54);
  background: #f1fbfa;
}

.template-card.active {
  transform: translateY(-1px);
}

.template-card h3 {
  margin: 0;
  font-size: 15px;
}

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

.template-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.digital-twin {
  min-height: 446px;
  display: grid;
  grid-template-rows: auto minmax(276px, 1fr) auto auto;
}

#flowCanvas {
  width: 100%;
  height: 328px;
  display: block;
  cursor: pointer;
  background:
    linear-gradient(180deg, #f9fbfd 0%, #eef5f6 100%);
}

.twin-footer {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.twin-cell {
  min-height: 84px;
  padding: 13px 15px;
  border-right: 1px solid var(--line);
}

.twin-cell:last-child {
  border-right: 0;
}

.twin-cell strong {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}

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

.control-list {
  display: grid;
  gap: 17px;
}

.control label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.control label strong {
  color: var(--ink);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.recommendation {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #cfe4e4;
  border-radius: 8px;
  background: #f1fbfa;
  line-height: 1.55;
  color: #175f60;
  font-size: 13px;
}

.warning {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid #efd6aa;
  border-radius: 8px;
  background: #fff8ec;
  color: #7b4e0d;
  line-height: 1.5;
  font-size: 12px;
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.unit-card {
  min-height: 148px;
  padding: 13px;
  box-shadow: none;
  display: grid;
  gap: 9px;
  align-content: start;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.unit-card.active {
  border-color: rgba(15, 139, 141, 0.74);
  background: #f1fbfa;
}

.unit-card h4 {
  margin: 0;
  font-size: 14px;
}

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

.unit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.unit-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.unit-score strong {
  font-size: 13px;
}

.unit-score strong.green {
  color: var(--green);
}

.unit-score strong.amber {
  color: var(--amber);
}

.unit-score strong.red {
  color: var(--red);
}

.unit-detail-panel {
  border-top: 1px solid var(--line);
  padding: 16px;
  background: #fbfcfd;
}

.unit-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.unit-detail-head h4 {
  margin: 0;
  font-size: 15px;
}

.unit-detail-head p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 12px;
}

.unit-detail-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

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

.detail-block {
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px;
}

.detail-block h5 {
  margin: 0 0 9px;
  font-size: 12px;
  color: var(--muted);
}

.detail-block ul {
  margin: 0;
  padding-left: 17px;
  color: var(--graphite);
  font-size: 12px;
  line-height: 1.45;
}

.detail-row {
  min-height: 28px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row span {
  color: var(--muted);
}

.detail-row strong {
  text-align: right;
}

.constraint-row {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.constraint-row:last-child {
  border-bottom: 0;
}

.constraint-row strong {
  display: block;
  font-size: 12px;
}

.constraint-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.unit-control-panel {
  display: grid;
  gap: 10px;
}

.unit-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 10px;
  align-items: center;
  font-size: 12px;
}

.unit-control span {
  color: var(--muted);
}

.unit-control strong {
  font-size: 12px;
}

.unit-control input {
  grid-column: 1 / -1;
}

.model-list,
.table,
.stream-table,
.gate-list {
  display: grid;
  gap: 8px;
}

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

.sensitivity-card {
  min-height: 118px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.sensitivity-rank {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e8f4f4;
  color: #075d5e;
  font-weight: 800;
  font-size: 12px;
}

.sensitivity-card h4 {
  margin: 0;
  font-size: 13px;
}

.sensitivity-card p {
  margin: 5px 0 6px;
  color: var(--graphite);
  font-size: 12px;
  line-height: 1.4;
}

.sensitivity-card small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.model-row {
  display: grid;
  grid-template-columns: 122px 1fr 82px;
  align-items: center;
  gap: 12px;
  min-height: 42px;
}

.model-row strong {
  font-size: 13px;
}

.track {
  height: 9px;
  border-radius: 999px;
  background: #e0e7ed;
  overflow: hidden;
}

.track span {
  display: block;
  height: 100%;
  width: var(--score);
  background: linear-gradient(90deg, var(--blue), var(--teal));
}

.table-row,
.stream-row,
.gate-row {
  min-height: 48px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.table-row:last-child,
.stream-row:last-child,
.gate-row:last-child {
  border-bottom: 0;
}

.table-row strong,
.stream-row strong,
.gate-row strong {
  display: block;
  font-size: 13px;
}

.table-row small,
.stream-row small,
.gate-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

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

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

.mini-panel h4 {
  margin: 0 0 10px;
  font-size: 13px;
}

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

.balance-card {
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.balance-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 9px;
}

.balance-card strong {
  display: block;
  font-size: 20px;
  line-height: 1;
  margin-bottom: 8px;
}

.balance-card small {
  color: var(--muted);
  line-height: 1.35;
}

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

.phase {
  min-height: 136px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
  display: grid;
  gap: 10px;
  align-content: start;
}

.phase h4 {
  margin: 0;
  font-size: 14px;
}

.phase p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 12px;
}

.phase-meter {
  height: 6px;
  border-radius: 99px;
  background: #dfe7ed;
  overflow: hidden;
}

.phase-meter span {
  display: block;
  height: 100%;
  width: var(--phase);
  background: var(--phase-color, var(--teal));
}

.business-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 18px;
  line-height: 1.6;
  color: var(--muted);
}

.comparison-controls {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) repeat(3, auto);
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.comparison-controls input {
  min-height: 36px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--ink);
  background: #fff;
}

.slides {
  display: grid;
  gap: 9px;
}

.slide-row {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.slide-row strong {
  font-size: 13px;
}

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

@media (max-width: 1280px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .brand,
  .field,
  .status-strip,
  .side-nav,
  .side-section {
    margin-bottom: 0;
  }

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

  .topbar,
  .workspace-grid,
  .two-column,
  .three-column {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .toolbar {
    justify-content: start;
  }

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

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

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

@media (max-width: 760px) {
  .main,
  .sidebar {
    padding: 14px;
  }

  .sidebar,
  .kpi-grid,
  .template-grid,
  .unit-grid,
  .phase-grid,
  .twin-footer,
  .stream-grid,
  .balance-grid {
    grid-template-columns: 1fr;
  }

  .unit-detail-head,
  .comparison-controls {
    grid-template-columns: 1fr;
  }

  .unit-detail-head {
    display: grid;
  }

  .unit-detail-badges {
    justify-content: flex-start;
  }

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

  .sensitivity-card {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .side-nav {
    grid-template-columns: 1fr;
  }

  .twin-cell {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .twin-cell:last-child {
    border-bottom: 0;
  }

  .model-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }
}
