:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: #f4f6f8;
  color: #17202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

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

.title h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.title p {
  margin: 6px 0 0;
  color: #5c6670;
  font-size: 13px;
}

.status-badge {
  flex: 0 0 auto;
  min-width: 120px;
  text-align: center;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  color: #344050;
  font-size: 13px;
}

.status-badge[data-tone="ok"] {
  border-color: #7bb88a;
  color: #1d6b35;
}

.status-badge[data-tone="pending"],
.status-badge[data-tone="warn"] {
  border-color: #d9a441;
  color: #815300;
}

.status-badge[data-tone="error"] {
  border-color: #d16d6a;
  color: #a02f2a;
}

.patient-bar,
.workbench,
.templates-panel,
.results {
  background: #ffffff;
  border: 1px solid #d9e0e8;
  border-radius: 8px;
  margin-bottom: 14px;
}

.patient-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.patient-bar label {
  display: grid;
  gap: 6px;
  align-content: start;
  color: #52606d;
  font-size: 13px;
}

.field {
  width: 100%;
  min-height: 38px;
  border: 1px solid #c8d1dc;
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  color: #17202a;
  outline: none;
}

.field:focus {
  border-color: #4f7fb8;
  box-shadow: 0 0 0 3px rgba(79, 127, 184, 0.16);
}

.field-invalid {
  border-color: #c2410c;
  background: #fff7ed;
}

.field-invalid:focus {
  border-color: #c2410c;
  box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.16);
}

.field-error {
  min-height: 16px;
  color: #b33b12;
  font-size: 12px;
  line-height: 1.35;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid #e1e7ee;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

.button {
  min-height: 38px;
  border: 1px solid #b8c4d1;
  border-radius: 7px;
  padding: 8px 14px;
  background: #ffffff;
  color: #24313f;
  cursor: pointer;
}

.button.primary {
  border-color: #1f6aa5;
  background: #1f6aa5;
  color: #ffffff;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid #ccd5df;
  border-radius: 7px;
  background: #ffffff;
  color: #24313f;
  cursor: pointer;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid #edf1f5;
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #52606d;
  font-size: 13px;
  font-weight: 600;
  background: #f8fafc;
}

.project-cell {
  position: relative;
  min-width: 260px;
}

.suggestions {
  position: fixed;
  z-index: 20;
  max-height: 260px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #c8d1dc;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(21, 36, 55, 0.16);
}

.suggestion {
  display: grid;
  width: 100%;
  gap: 3px;
  border: 0;
  border-bottom: 1px solid #edf1f5;
  padding: 10px 12px;
  background: #ffffff;
  color: #17202a;
  text-align: left;
  cursor: pointer;
}

.suggestion:hover,
.suggestion.is-active {
  background: #eef5fb;
}

.suggestion.is-active {
  outline: 2px solid #4f7fb8;
  outline-offset: -2px;
}

.suggestion small {
  color: #697782;
  font-size: 12px;
}

.suggestion mark {
  border-radius: 3px;
  background: #ffe58a;
  color: inherit;
  padding: 0 1px;
}

.project-meta {
  margin-top: 6px;
  color: #697782;
  font-size: 12px;
  line-height: 1.35;
}

.templates-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.template-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 1.5fr) auto;
  gap: 12px;
  align-items: end;
}

.template-grid label {
  display: grid;
  gap: 6px;
  color: #52606d;
  font-size: 13px;
}

.template-apply {
  grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1.2fr);
  align-items: end;
  border-top: 1px solid #edf1f5;
  padding-top: 12px;
}

.template-note {
  margin: 0;
  padding-bottom: 10px;
  color: #697782;
  font-size: 13px;
  line-height: 1.5;
}

.results {
  padding: 12px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  color: #52606d;
  font-size: 13px;
  margin-bottom: 12px;
}

.result-list {
  display: grid;
  gap: 10px;
}

.empty-state {
  display: grid;
  min-height: 110px;
  place-items: center;
  color: #7a8793;
  border: 1px dashed #ccd5df;
  border-radius: 8px;
  background: #fafbfc;
}

.result-card {
  border: 1px solid #d8e1ea;
  border-left-width: 5px;
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.result-card[data-tone="pass"] {
  border-left-color: #328a52;
}

.result-card[data-tone="warn"],
.result-card[data-tone="review"] {
  border-left-color: #d39b2d;
}

.result-card[data-tone="block"] {
  border-left-color: #cf4f4a;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.result-head span {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #edf2f7;
  padding: 4px 8px;
  color: #344050;
  font-size: 12px;
}

.result-card p {
  margin: 0 0 10px;
}

.result-card dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.result-card dt {
  color: #697782;
  font-size: 12px;
}

.result-card dd {
  margin: 2px 0 0;
  color: #24313f;
  font-size: 13px;
  word-break: break-word;
}

.prompt {
  margin-top: 10px;
  border-radius: 7px;
  background: #f6f8fa;
  padding: 10px;
  color: #344050;
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .patient-bar {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: space-between;
  }

  .template-grid,
  .template-apply {
    grid-template-columns: 1fr;
  }

  .result-card dl {
    grid-template-columns: 1fr;
  }
}
