:root {
  --ink: #17212b;
  --muted: #667383;
  --line: #d8dee6;
  --panel: #ffffff;
  --bg: #f4f7fa;
  --accent: #176b87;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 14px/1.45 "Segoe UI", Arial, sans-serif;
}

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

.edit-panel {
  background: #fbfcfd;
  border-right: 1px solid var(--line);
  padding: 22px;
  overflow: auto;
}

.brand-block {
  margin-bottom: 20px;
}

h1 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 12px;
  font-size: 16px;
  letter-spacing: 0;
}

p {
  margin: 0;
  color: var(--muted);
}

section {
  margin-bottom: 20px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: #334150;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
  min-height: 104px;
}

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

.check-line {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.check-line input,
.plot-controls input,
.organ-grid input {
  width: auto;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  opacity: .55;
  cursor: wait;
}

.workspace {
  padding: 18px;
  overflow: auto;
}

.status {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
}

.status.busy {
  border-color: #d6b15f;
  background: #fff8e6;
}

.status.error {
  border-color: #d9928e;
  background: #fff0ef;
  color: #842f2a;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

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

.plot-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.plot-controls label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.organ-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px 12px;
  margin-bottom: 14px;
}

.organ-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 500;
}

.pk-control-row {
  display: grid;
  grid-template-columns: minmax(220px, 320px);
  margin: 0 0 14px;
}

.pk-control-row label {
  margin: 0;
}

.plot {
  width: 100%;
  height: 360px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.plot svg {
  display: block;
  width: 100%;
  height: 100%;
}

.table-wrap {
  max-height: 330px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}

.score-badge {
  border-radius: 999px;
  padding: 7px 12px;
  background: #eef3f6;
  color: #334150;
  font-weight: 700;
}

.score-badge.good {
  background: #e7f4ee;
  color: #1f6b4b;
}

.score-badge.neutral {
  background: #f3f0e6;
  color: #6f5c22;
}

.network-legend {
  display: grid;
  grid-template-columns: auto auto minmax(260px, 1fr);
  gap: 12px 28px;
  align-items: center;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.legend-arrow {
  position: relative;
  display: inline-block;
  width: 54px;
  height: 16px;
}

.legend-arrow::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 38px;
  height: 4px;
  background: currentColor;
}

.legend-arrow::after {
  content: "";
  position: absolute;
  right: 0;
  top: 1px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 18px solid currentColor;
}

.legend-arrow.activate {
  color: #42b36b;
}

.legend-arrow.inhibit {
  color: #ef6b62;
}

.legend-shape.drug {
  width: 22px;
  height: 22px;
  background: #9b59b6;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}

.legend-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.disease {
  background: #e94b43;
}

.legend-dot.direct {
  background: #3498db;
}

.legend-dot.pathway {
  background: #9aa8aa;
}

#network-frame {
  width: 100%;
  height: 660px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

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

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