:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --line: #d8dee9;
  --line2: #edf0f5;
  --accent: #195a96;
  --accent-soft: #e8f1fb;
  --danger: #a42424;
  --warn: #9b5a00;
  --ok: #207245;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
  cursor: pointer;
}

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

button.danger {
  color: var(--danger);
  border-color: #e4b4b4;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

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

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

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

.hidden {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.authbar,
.tabs,
.panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid #bddbf4;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.layout {
  max-width: 1500px;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
}

.sidebar {
  position: sticky;
  top: 78px;
  align-self: start;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section-title {
  margin: 4px 0 0;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

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

.content {
  min-width: 0;
}

.tabs {
  margin-bottom: 14px;
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metrics div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metrics b {
  display: block;
  font-size: 25px;
}

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

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.week-board {
  padding: 14px;
  overflow-x: auto;
}

.week-columns {
  min-width: 1180px;
  display: grid;
  grid-template-columns: repeat(5, minmax(235px, 1fr));
  gap: 12px;
}

.day {
  min-height: 520px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  overflow: hidden;
}

.day-head {
  padding: 10px 11px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: var(--accent-soft);
  border-bottom: 1px solid #c7d9eb;
}

.day-head b {
  font-size: 15px;
}

.day-head span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.room {
  padding: 10px;
  border-bottom: 1px solid var(--line2);
}

.room-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.mini-list {
  display: grid;
  gap: 7px;
}

.mini-card {
  display: grid;
  gap: 5px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.mini-card.warn {
  border-color: #ead18a;
  background: #fffdf5;
}

.mini-card.conflict {
  border-color: #e4b4b4;
  background: #fff7f7;
}

.mini-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 8px;
}

.patient {
  font-weight: 800;
  line-height: 1.25;
}

.small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tagline {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #344054;
  font-size: 12px;
}

.tag.robot {
  background: #eef7ff;
  border-color: #bddbf4;
  color: #175284;
}

.tag.lap {
  background: #effaf3;
  border-color: #bfe3cc;
  color: var(--ok);
}

.tag.open {
  background: #fff4e6;
  border-color: #f1d0a6;
  color: #8a4b00;
}

.tag.warn {
  background: #fff8e5;
  border-color: #ead18a;
  color: var(--warn);
}

.tag.conflict {
  background: #fff1f1;
  border-color: #e4b4b4;
  color: var(--danger);
}

.slot-box {
  margin-top: auto;
  display: grid;
  gap: 7px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #f7f9fc;
}

.empty-slot {
  min-height: 38px;
  padding: 9px 10px;
  border: 1px dashed #aeb8c8;
  border-radius: 7px;
  background: #fff;
  color: #475467;
  text-align: left;
}

.empty-slot.admin {
  border-color: #7aa9d4;
  color: var(--accent);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 260px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line2);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fc;
  color: #344054;
  font-size: 12px;
}

tr:hover td {
  background: #fbfcff;
}

.analytics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 14px;
}

.audit-list {
  display: grid;
  gap: 14px;
  padding: 14px;
}

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

.bar-row {
  margin: 9px 0;
}

.bar-row div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.track {
  height: 8px;
  margin-top: 4px;
  border-radius: 999px;
  background: #edf0f5;
  overflow: hidden;
}

.fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.empty {
  padding: 34px 16px;
  color: var(--muted);
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, .46);
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(520px, 100%);
  max-height: 92vh;
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

.modal-card.wide {
  width: min(960px, 100%);
}

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

.modal-foot {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 14px;
}

.compact-form {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  align-items: end;
  padding: 12px 0 0;
}

.span-all {
  grid-column: 1 / -1;
}

.checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 9px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.checklist .section-title {
  grid-column: 1 / -1;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
}

.check-item input {
  width: auto;
}

.note,
.warning {
  margin: 0;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff9e8;
  color: #6f4200;
  border: 1px solid #ead18a;
  font-size: 13px;
}

.warning {
  margin: 0 14px 14px;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .week-columns {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .day {
    min-height: auto;
  }

  .analytics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    padding: 12px;
    gap: 12px;
  }

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

  .panel-head {
    flex-direction: column;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .checklist {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .sidebar,
  .tabs,
  .metrics,
  .panel-head,
  .slot-box,
  .mini-actions {
    display: none !important;
  }

  .layout {
    display: block;
    max-width: none;
    padding: 0;
  }

  .panel {
    border: 0;
    box-shadow: none;
  }

  .week-board {
    padding: 0;
    overflow: visible;
  }

  .week-columns {
    min-width: 0;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .day {
    min-height: auto;
    break-inside: avoid;
  }
}
