:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-2: #eef4ef;
  --ink: #1f2b24;
  --muted: #66756c;
  --line: #dbe2dc;
  --brand: #2f7d61;
  --brand-2: #b54635;
  --gold: #b58b2b;
  --danger: #a12f2f;
  --shadow: 0 14px 32px rgba(31, 43, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(47, 125, 97, 0.12), transparent 42%),
    linear-gradient(315deg, rgba(181, 70, 53, 0.08), transparent 46%),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  color: var(--brand);
  font-weight: 800;
  margin-bottom: 18px;
}

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

.login-card h1 {
  font-size: 26px;
  margin-bottom: 8px;
}

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

.form-grid {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
}

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

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 125, 97, 0.12);
}

.btn {
  min-height: 39px;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--brand);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

.btn.secondary {
  background: var(--panel-2);
  color: var(--brand);
}

.btn.danger {
  background: var(--danger);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 278px 1fr;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
}

.side-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.side-title strong {
  display: block;
  font-size: 17px;
}

.role-pill,
.tag,
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  white-space: nowrap;
}

.role-pill {
  background: var(--panel-2);
  color: var(--brand);
}

.status-pill {
  background: #fff3d3;
  color: #815d09;
}

.status-pill.ok {
  background: #eef8f1;
  color: #2f7d61;
}

.status-pill.danger-light {
  background: #ffeceb;
  color: var(--danger);
}

.tag {
  background: #eef4ef;
  color: #356350;
  margin: 0 6px 6px 0;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  width: 100%;
  min-height: 40px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 0 12px;
}

.nav button.active {
  background: var(--brand);
  color: white;
}

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

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

.topbar h1 {
  font-size: 24px;
  margin: 0 0 4px;
}

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

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

.stat b {
  display: block;
  font-size: 27px;
  margin-bottom: 4px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(290px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(31, 43, 36, 0.04);
}

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

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 17px;
}

.panel-body {
  padding: 14px;
}

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

.patient-row {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
}

.patient-row.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 125, 97, 0.11);
}

.row-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

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

.field {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px;
  background: #fff;
  min-height: 72px;
}

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

.wide {
  grid-column: 1 / -1;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tabs button {
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  min-height: 34px;
  padding: 0 12px;
}

.tabs button.active {
  background: var(--brand);
  color: #fff;
}

.timeline {
  display: grid;
  gap: 12px;
}

.entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.entry h4 {
  margin: 0 0 7px;
}

.entry p {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.suggestion {
  border-left: 4px solid var(--brand);
  background: #f5faf6;
  padding: 12px;
  border-radius: 6px;
}

.suggestion.warning {
  border-color: var(--brand-2);
  background: #fff7f4;
}

.suggestion ul {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.7;
}

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

.meal-plan-head h4 {
  margin-bottom: 3px;
}

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

.meal-columns section,
.daily-menu {
  border: 1px solid var(--line);
  padding: 11px;
  border-radius: 6px;
  background: #f8faf8;
}

.meal-columns ul {
  margin: 7px 0 0;
  padding-left: 19px;
  line-height: 1.7;
}

.meal-columns .warning-block {
  background: #fff7f4;
  border-color: #eccfc2;
}

.daily-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}

.daily-menu > strong {
  grid-column: 1 / -1;
}

.daily-menu div {
  line-height: 1.55;
}

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

.pending-line,
.reviewed-line,
.notice {
  border-left: 4px solid var(--brand-2);
  background: #fff7f4;
  padding: 9px 11px;
  border-radius: 4px;
}

.reviewed-line {
  border-color: var(--brand);
  background: #f5faf6;
}

.audit-panel {
  margin-top: 16px;
}

.password-reveal {
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  background: #f5faf6;
  border-radius: 6px;
  padding: 11px;
  display: grid;
  gap: 8px;
}

.password-reveal code {
  display: block;
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.entry-title-row,
.section-head,
.ai-feedback-bar,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.entry-title-row h4,
.section-head h2 {
  margin: 0;
}

.outcome-block {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.outcome-row {
  margin-top: 9px;
  padding: 9px 10px;
  background: #f7faf7;
  border-left: 3px solid var(--brand);
}

.outcome-row p {
  margin: 5px 0;
}

.outcome-row small,
.asset-stat small {
  color: var(--muted);
}

.evidence-pill {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid #aac7b0;
  border-radius: 999px;
  background: #f3f9f4;
  color: #315e3b;
  font-size: 12px;
}

.checkbox-line {
  display: flex;
  gap: 8px;
  align-items: center;
}

.checkbox-line input {
  width: auto;
}

.ai-feedback-bar {
  padding: 12px;
  border: 1px solid var(--line);
  background: #f7faf7;
}

.ai-feedback-bar > div:first-child span {
  display: block;
  margin-top: 3px;
}

.asset-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

.asset-stat b,
.asset-stat span,
.asset-stat small {
  display: block;
}

.asset-stat b {
  font-size: 28px;
  margin-bottom: 5px;
}

.asset-stat span {
  font-weight: 700;
  margin-bottom: 5px;
}

.asset-quality {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  border-top: 1px solid var(--line);
  padding: 18px 0;
}

.asset-quality > section {
  min-width: 0;
}

.quality-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.quality-meter {
  height: 8px;
  background: #e5ebe6;
  margin-top: 6px;
  overflow: hidden;
}

.quality-meter i {
  display: block;
  height: 100%;
  background: var(--brand);
}

.decision-list,
.syndrome-list,
.compact-timeline {
  display: grid;
  gap: 8px;
  margin-top: 13px;
}

.decision-list div,
.syndrome-list > div,
.compact-timeline > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.compact-timeline > div {
  display: grid;
  gap: 3px;
}

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

.compact-timeline p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.assistant-launch {
  width: 100%;
  margin-top: auto;
}

.assistant-drawer {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9;
  width: min(420px, calc(100vw - 36px));
  height: min(680px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(24, 39, 28, 0.2);
}

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

.assistant-head strong,
.assistant-head span {
  display: block;
}

.assistant-head span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.assistant-context {
  padding: 8px 16px;
  color: var(--muted);
  background: #f5f8f5;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.assistant-messages {
  min-height: 0;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-message {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 7px;
  line-height: 1.6;
}

.chat-message > div {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-message small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.chat-message.user {
  align-self: flex-end;
  background: var(--brand);
  color: #fff;
}

.chat-message.user small {
  color: rgba(255, 255, 255, 0.75);
}

.chat-message.assistant {
  align-self: flex-start;
  background: #f0f4f0;
  border: 1px solid var(--line);
}

.assistant-empty {
  margin: auto;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.quick-prompts {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}

.quick-prompts button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 12px;
}

.assistant-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px 12px 12px;
}

.assistant-form textarea {
  min-height: 68px;
  max-height: 140px;
  resize: vertical;
}

.assistant-form .btn {
  align-self: end;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 22, 0.35);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 10;
}

.modal {
  width: min(900px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.password-required {
  z-index: 20;
}

.password-modal {
  width: min(480px, 100%);
}

.modal .panel-head {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}

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

.error {
  color: var(--danger);
  min-height: 20px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

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

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace,
  .stats,
  .suggestion-grid,
  .meal-columns,
  .daily-menu,
  .asset-stats,
  .asset-quality,
  .detail-grid,
  .two-col {
    grid-template-columns: 1fr;
  }
}

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

  .assistant-drawer {
    inset: 0;
    width: 100%;
    height: 100%;
  }

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

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}
