:root {
  color-scheme: light;
  --paper: #f5efe2;
  --ink: #222226;
  --muted: #66645e;
  --line: #d8cbb8;
  --teal: #2f6f73;
  --teal-dark: #214e51;
  --red: #ba4b42;
  --green: #4a8a62;
  --gold: #c78b31;
  --blue: #496d9d;
  --panel: #fffaf0;
  --shadow: 0 12px 26px rgba(60, 47, 35, 0.14);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(47, 111, 115, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(47, 111, 115, 0.08) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
}

button {
  border: 0;
  font: inherit;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: end;
  padding: 16px 0 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 4vw, 3.2rem);
  line-height: 1;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.12rem;
}

h3 {
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(86px, 1fr));
  gap: 8px;
}

.stats div,
.panel,
.room-panel,
.controls {
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.94);
  box-shadow: var(--shadow);
}

.stats div {
  min-height: 66px;
  padding: 12px;
  border-radius: 8px;
}

.stats span {
  display: block;
  font-weight: 850;
}

.stats small,
.worker-card small,
.patient-card small,
.room-tile small {
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding: 8px;
  border-radius: 8px;
}

.controls button {
  min-width: 64px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 7px;
  background: #eadcc8;
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.controls button.active,
.controls button:hover {
  background: var(--teal);
  color: white;
}

.controls .ghost {
  margin-left: auto;
  background: transparent;
  color: var(--red);
  outline: 1px solid rgba(186, 75, 66, 0.35);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 14px;
  align-items: stretch;
}

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

.room-tile {
  display: grid;
  grid-template-rows: minmax(150px, 1fr) auto auto;
  min-height: 245px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff8e9;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.room-tile:hover,
.room-tile.selected {
  border-color: var(--teal);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.room-tile img {
  width: 100%;
  height: 100%;
  min-height: 150px;
  object-fit: cover;
  border-radius: 6px;
  background: #eadcc8;
}

.room-tile span {
  display: block;
  margin-top: 9px;
  font-weight: 850;
}

.room-panel,
.panel {
  border-radius: 8px;
  padding: 14px;
}

.room-panel p {
  color: var(--muted);
}

.room-art {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 12px;
  background: #eadcc8;
}

.workbox {
  margin: 14px 0;
  padding: 12px;
  border-radius: 8px;
  background: #e9f1eb;
  border: 1px solid rgba(74, 138, 98, 0.25);
}

.workbox.idle {
  background: #f7edd7;
  border-color: rgba(199, 139, 49, 0.28);
}

.workbox strong,
.workbox span {
  display: block;
}

.workbox span {
  color: var(--muted);
  font-size: 0.9rem;
}

.meter {
  width: 100%;
  height: 9px;
  overflow: hidden;
  margin-top: 10px;
  border-radius: 999px;
  background: rgba(34, 34, 38, 0.13);
}

.meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.patience i {
  background: var(--gold);
}

.queue {
  margin-top: 16px;
}

.queue-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.2fr) minmax(240px, 0.8fr) minmax(280px, 1fr);
  gap: 14px;
  margin-top: 14px;
}

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

.patient-card,
.worker-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: #fff5e1;
  border: 1px solid var(--line);
}

.patient-card img,
.worker-card img {
  width: 64px;
  height: 64px;
  border-radius: 7px;
  object-fit: cover;
  background: #eadcc8;
}

.patient-card h3,
.patient-card p,
.worker-card h3,
.worker-card p {
  margin-bottom: 2px;
}

.patient-card p,
.worker-card p,
.empty {
  color: var(--muted);
}

.log {
  margin: 0;
  padding: 10px;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #f8f2e5;
  color: #3c3932;
}

.log.good {
  border-color: var(--green);
}

.log.bad {
  border-color: var(--red);
}

.log.new {
  border-color: var(--gold);
}

@media (max-width: 980px) {
  .topbar,
  .layout,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .room-panel {
    order: -1;
  }
}

@media (max-width: 620px) {
  .shell {
    padding: 12px;
  }

  .clinic-map {
    grid-template-columns: 1fr;
  }

  .room-tile {
    min-height: 210px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .controls .ghost {
    margin-left: 0;
    width: 100%;
  }
}
