:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #61717d;
  --line: #dbe3e8;
  --brand: #116b67;
  --brand-dark: #0c4e4b;
  --blue: #2368a2;
  --gold: #a06416;
  --red: #b33131;
  --green: #287245;
  --shadow: 0 8px 24px rgba(25, 42, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  background: #0e2c34;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.eyebrow {
  margin: 0 0 3px;
  color: #9fd7d1;
  font-size: 12px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

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

.role-btn,
.tab,
.primary-btn,
.icon-btn,
.small-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  min-height: 38px;
  padding: 8px 12px;
  font-weight: 700;
}

.role-btn {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.role-btn.active,
.tab.active,
.primary-btn {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.primary-btn:hover,
.role-btn.active:hover,
.tab.active:hover {
  background: var(--brand-dark);
}

main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 20px 24px 40px;
}

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

.metrics article,
.panel,
.patient-card,
.room-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 14px 16px;
}

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

.metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
}

.tabs,
.toolbar {
  margin-top: 16px;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.search-wrap {
  display: grid;
  gap: 6px;
  flex: 1 1 280px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

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

.view {
  display: none;
  margin-top: 16px;
}

.active-view {
  display: block;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(250px, 1fr));
  gap: 12px;
}

.lane {
  min-height: 300px;
}

.lane-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 2px;
  font-weight: 800;
}

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

.stack {
  display: grid;
  gap: 10px;
}

.patient-card {
  padding: 12px;
}

.patient-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.patient-name {
  display: block;
  font-size: 16px;
}

.patient-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}

.status-pill {
  background: #e7f3f1;
  color: var(--brand-dark);
}

.status-pill.alert {
  background: #f9e4e4;
  color: var(--red);
}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.tag {
  background: #edf2f5;
  color: #354652;
}

.tag.risk {
  background: #f9e4e4;
  color: var(--red);
}

.tag.vip {
  background: #fff0d7;
  color: var(--gold);
}

.step-row {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.small-btn {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 13px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 14px;
}

.panel {
  padding: 16px;
}

.ai-output {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
  min-height: 80px;
  white-space: pre-wrap;
}

.room-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 12px;
}

.room-card {
  padding: 14px;
}

.room-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.room-card .room-patient {
  color: var(--muted);
  line-height: 1.5;
}

.summary-item {
  border-left: 4px solid var(--brand);
  padding: 12px;
  background: #f8fbfb;
  border-radius: 8px;
}

.summary-item.warning {
  border-left-color: var(--red);
}

.hidden-for-role {
  display: none;
}

@media (max-width: 1100px) {
  .board,
  .room-grid,
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

  main {
    padding: 14px;
  }

  .metrics,
  .board,
  .room-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .role-switcher,
  .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .role-btn,
  .tab {
    width: 100%;
  }
}
