:root {
  --bg: #eef3f6;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #697783;
  --line: #d9e2e8;
  --teal: #087f8c;
  --teal-dark: #075b65;
  --mint: #dff3ed;
  --coral: #c84c3c;
  --amber: #b5791f;
  --blue: #2f6fba;
  --green: #2c8064;
  --shadow: 0 18px 45px rgba(28, 45, 57, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
  background: #102933;
  color: #f7fbfc;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #b7e7db;
  color: #0e3038;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1 {
  margin: 2px 0 3px;
  font-size: 26px;
  letter-spacing: 0;
}

.brand p,
.brand-kicker {
  margin: 0;
  color: #b8cad0;
  font-size: 12px;
  line-height: 1.5;
}

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

.nav-item {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #d9e8eb;
  background: transparent;
  text-align: left;
  padding: 0 14px;
}

.nav-item:hover,
.nav-item.active {
  background: #183943;
  border-color: #2c5964;
  color: #ffffff;
}

.compliance-box {
  margin-top: auto;
  border: 1px solid #2c5964;
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.compliance-box h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.compliance-box p {
  margin: 0;
  color: #c9d8dc;
  line-height: 1.65;
  font-size: 13px;
}

main {
  min-width: 0;
  padding: 28px;
}

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

.topbar h2 {
  margin: 4px 0 0;
  font-size: clamp(24px, 3vw, 36px);
  letter-spacing: 0;
}

.backend-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin: 10px 0 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.backend-status.connected {
  border-color: #b9ddd1;
  background: #eaf7f2;
  color: var(--green);
}

.backend-status.error {
  border-color: #f1c6be;
  background: #fff0ed;
  color: var(--coral);
}

.eyebrow {
  margin: 0;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.access-hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(8, 127, 140, 0.08), rgba(47, 111, 186, 0.08)),
    #ffffff;
  box-shadow: var(--shadow);
}

.access-hero h3 {
  max-width: 860px;
  margin: 8px 0 10px;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.08;
  letter-spacing: 0;
}

.access-hero p {
  max-width: 820px;
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

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

.journey-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.journey-step {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
}

.journey-step span,
.flow-step span {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  margin-bottom: 10px;
  background: var(--teal);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.journey-step strong,
.journey-step small {
  display: block;
}

.journey-step small {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.role-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.role-choice {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: #fff;
  color: #40505a;
  font-weight: 800;
}

.role-choice.active,
.role-choice:hover {
  border-color: var(--teal);
  background: var(--mint);
  color: var(--teal-dark);
}

.access-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  gap: 18px;
}

.role-flow-panel {
  grid-row: span 2;
}

.role-flow {
  display: grid;
  gap: 12px;
}

.flow-step {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fbfdfe;
}

.flow-step span {
  margin: 0;
}

.flow-step strong,
.flow-step small {
  display: block;
}

.flow-step small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.5;
}

.result-box {
  margin-top: 14px;
  border: 1px dashed #a9bdc7;
  border-radius: 8px;
  padding: 12px;
  background: #f9fcfd;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

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

.review-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid #cfe0e6;
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfe;
}

.review-item strong,
.review-item span {
  display: block;
}

.review-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.review-item em {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 9px;
  background: #fff1d9;
  color: var(--amber);
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
}

.review-item em.approved {
  background: #e6f3ec;
  color: var(--green);
}

.login-links {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 14px;
}

.login-links button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
  color: var(--teal-dark);
  font-weight: 800;
}

.login-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.portal-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.portal-header h3 {
  margin: 4px 0 6px;
  font-size: 24px;
}

.portal-header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.public-banner {
  background: #f6fbf8;
  border-color: #cfe8dc;
}

.quick-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.quick-tabs span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  color: #40505a;
  background: #f8fbfc;
  font-size: 12px;
  font-weight: 800;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--teal);
  padding: 0 16px;
  font-weight: 700;
}

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

.primary-button:hover {
  background: var(--teal-dark);
}

.ghost-button {
  color: var(--teal-dark);
  background: #fff;
}

.full {
  width: 100%;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

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

.metric-card,
.panel,
.knowledge-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
  min-height: 138px;
  display: grid;
  align-content: space-between;
  border-top: 4px solid var(--blue);
}

.metric-card.accent {
  border-top-color: var(--coral);
}

.metric-card span,
.metric-card small {
  color: var(--muted);
}

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

.two-column,
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
  gap: 16px;
}

.panel {
  padding: 20px;
}

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

.panel h3 {
  margin: 4px 0 0;
  font-size: 20px;
  letter-spacing: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--mint);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.danger,
.risk-critical {
  background: #fde7e3;
  color: var(--coral);
}

.risk-medium {
  background: #fff1d9;
  color: var(--amber);
}

.risk-low {
  background: #e6f3ec;
  color: var(--green);
}

.case-list {
  display: grid;
  gap: 12px;
}

.case-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
  background: #fbfdfe;
}

.case-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.case-card h4 {
  margin: 0 0 6px;
  font-size: 16px;
}

.case-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

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

.case-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: #4f5f68;
  background: #fff;
  font-size: 12px;
}

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

.case-actions button {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font-weight: 700;
}

.case-actions button.primary-action {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.rule-list,
.governance-grid,
.hospital-list,
.timeline {
  display: grid;
  gap: 12px;
}

.rule-list div,
.governance-grid div,
.hospital-card,
.timeline-step {
  border-left: 4px solid var(--teal);
  background: #f7fbfc;
  border-radius: 8px;
  padding: 13px;
}

.rule-list strong,
.governance-grid strong,
.hospital-card strong,
.timeline-step strong {
  display: block;
  margin-bottom: 5px;
}

.rule-list span,
.governance-grid span,
.hospital-card span,
.timeline-step span {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

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

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

label {
  display: grid;
  gap: 6px;
  color: #40505a;
  font-weight: 700;
  font-size: 14px;
}

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 140, 0.14);
}

.checkline {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 9px;
  font-weight: 600;
  line-height: 1.5;
}

.checkline input {
  width: auto;
  margin-top: 4px;
}

.triage-result {
  border-radius: 8px;
  border: 1px dashed #a9bdc7;
  padding: 18px;
  background: #f9fcfd;
  min-height: 220px;
}

.triage-result p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.65;
}

.result-badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 14px;
}

.compact .case-card {
  box-shadow: none;
}

.expert-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.expert-card {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfe;
}

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--mint);
  color: var(--teal-dark);
  font-weight: 900;
}

.expert-card strong,
.expert-card span,
.expert-card small {
  display: block;
}

.expert-card span,
.expert-card small {
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.mini-form {
  margin-bottom: 14px;
}

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

.knowledge-card {
  min-height: 220px;
  padding: 22px;
  border-top: 5px solid var(--teal);
}

.knowledge-card.critical {
  border-top-color: var(--coral);
}

.knowledge-card span {
  color: var(--teal-dark);
  font-weight: 800;
  font-size: 13px;
}

.knowledge-card h3 {
  margin: 14px 0 10px;
  font-size: 22px;
}

.knowledge-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .metric-grid,
  .two-column,
  .workspace-grid,
  .access-grid,
  .journey-strip,
  .knowledge-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  main {
    padding: 18px;
  }

  .topbar,
  .access-hero,
  .portal-header,
  .case-top,
  .panel-heading {
    display: grid;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    flex: 1;
  }

  .metric-grid,
  .two-column,
  .workspace-grid,
  .access-grid,
  .journey-strip,
  .knowledge-grid,
  .form-row,
  .nav-list {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 20px;
  }
}
