:root {
  --page: #f5f7f6;
  --surface: #ffffff;
  --surface-soft: #f0f5f3;
  --line: #d9e2de;
  --line-strong: #b9c8c3;
  --text: #17211d;
  --muted: #63726d;
  --teal: #0b776e;
  --teal-soft: #e5f3f0;
  --amber: #b97812;
  --amber-soft: #fff4df;
  --blue: #2f5e8f;
  --blue-soft: #eef5fb;
  --red: #9e4138;
  --red-soft: #fff0ed;
  --shadow: 0 16px 38px rgba(31, 51, 45, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #263731;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--line-strong);
  background: #f9fbfa;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

button:active {
  transform: translateY(1px);
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(11, 119, 110, 0.12);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  background: #fbfcfb;
}

td {
  font-size: 14px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.app-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}

.lab-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #17322d;
  color: #dff8f2;
  font-size: 14px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
}

.title-group p,
.pane-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.session-bar {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.split-workspace {
  display: grid;
  grid-template-columns: minmax(500px, 42%) minmax(560px, 1fr);
  gap: 16px;
  padding: 16px;
  min-width: 0;
}

.input-pane,
.result-pane {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pane-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.pane-head h2 {
  font-size: 18px;
  line-height: 1.25;
}

.status-badge,
.role-badge,
.purpose-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f3f6f5;
  color: var(--muted);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.status-badge.ok {
  border-color: #b9d8d0;
  background: var(--teal-soft);
  color: var(--teal);
}

.status-badge.warn {
  border-color: #efd5a8;
  background: var(--amber-soft);
  color: #8a550d;
}

.add-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(210px, 1.25fr) 80px 74px;
  gap: 10px;
  align-items: end;
  padding: 16px 18px 12px;
}

.add-row label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.primary-button {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
  font-weight: 760;
}

.primary-button:hover {
  background: #096961;
  border-color: #096961;
}

.batch-table-wrap,
.result-table-wrap {
  overflow: auto;
}

.calculate-row {
  display: grid;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: #fbfcfb;
}

.calculate-button {
  min-height: 44px;
  font-size: 16px;
}

.batch-table th:nth-child(1) {
  width: 112px;
}

.batch-table th:nth-child(2) {
  width: 86px;
}

.batch-table th:nth-child(3) {
  width: 110px;
}

.batch-table th:nth-child(4) {
  width: 68px;
}

.batch-table th:nth-child(6) {
  width: 54px;
}

.medium-code {
  display: block;
  font-size: 15px;
  font-weight: 780;
}

.medium-name {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.purpose-badge.micro {
  border-color: #b9d8d0;
  background: var(--teal-soft);
  color: var(--teal);
}

.purpose-badge.potency {
  border-color: #eed1a0;
  background: var(--amber-soft);
  color: #87520a;
}

.purpose-badge.sterile {
  border-color: #bfcee1;
  background: var(--blue-soft);
  color: var(--blue);
}

.qty-stepper {
  display: grid;
  grid-template-columns: 28px 44px 28px;
  gap: 5px;
  align-items: center;
}

.qty-stepper button,
.remove-button {
  width: 28px;
  min-height: 28px;
  padding: 0;
}

.qty-stepper input {
  height: 30px;
  text-align: center;
  padding: 0 4px;
}

.strain-preview {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
  line-height: 1.25;
}

.result-head {
  align-items: center;
}

.result-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

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

.metric {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  padding: 12px;
}

.metric strong {
  font-size: 26px;
  line-height: 1.1;
}

.result-table th:nth-child(1) {
  width: 56px;
}

.result-table th:nth-child(3) {
  width: 74px;
}

.result-table th:nth-child(4) {
  width: 98px;
}

.result-table td {
  vertical-align: top;
}

.volume-cell {
  font-size: 17px;
  font-weight: 820;
  color: var(--teal);
}

.source-cell {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.role-badge.promote {
  border-color: #b9d8d0;
  background: var(--teal-soft);
  color: var(--teal);
}

.role-badge.inhibit {
  border-color: #ecc1bb;
  background: var(--red-soft);
  color: var(--red);
}

.empty-state {
  display: block;
  padding: 20px;
  color: var(--muted);
  text-align: center;
  background: #f8faf9;
  border: 1px dashed #cbd8d3;
  border-radius: 8px;
}

.copy-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  border: 1px solid #b9d8d0;
  border-radius: 8px;
  background: #effaf7;
  color: var(--teal);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 760;
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(23, 33, 29, 0.42);
}

.confirm-backdrop.hidden {
  display: none;
}

.confirm-dialog {
  position: relative;
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 22px;
  box-shadow: 0 22px 54px rgba(23, 33, 29, 0.18);
}

.confirm-dialog h3 {
  font-size: 20px;
  line-height: 1.25;
}

.confirm-dialog p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 2px;
}

@media (max-width: 1120px) {
  .split-workspace {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .session-bar {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .app-header,
  .split-workspace {
    padding: 12px;
  }

  .add-row,
  .metrics-row {
    grid-template-columns: 1fr;
  }

  .batch-table,
  .result-table {
    min-width: 760px;
  }

  .confirm-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-header,
  .input-pane,
  .result-actions {
    display: none;
  }

  .split-workspace {
    display: block;
    padding: 0;
  }

  .result-pane {
    border: none;
    box-shadow: none;
  }
}
