:root {
  color-scheme: light;
  --primary: #14756f;
  --primary-dark: #0f5f5a;
  --text: #203331;
  --muted: #6f807f;
  --line: #dce7e6;
  --background: #f3f7f6;
  --warning: #fff5e4;
  --danger: #b33d35;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.page { width: min(760px, 100%); margin: 0 auto; padding: 24px 16px 56px; }
.hero {
  margin-bottom: 20px;
  padding: 34px 26px;
  border-radius: 24px;
  background: linear-gradient(145deg, #116b66, #23958a);
  color: white;
  box-shadow: 0 16px 38px rgba(20, 117, 111, .2);
}
.hero small { display: inline-block; padding: 4px 12px; border-radius: 99px; background: rgba(255,255,255,.16); }
.hero h1 { margin: 14px 0 8px; font-size: clamp(30px, 8vw, 44px); }
.hero p { margin: 0; color: rgba(255,255,255,.88); }
.card {
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid #e1eaea;
  border-radius: 20px;
  background: white;
  box-shadow: 0 8px 24px rgba(17, 83, 80, .05);
}
.card h2 { margin: 0 0 18px; font-size: 21px; }
.card.disease { border-top: 5px solid #6d63a8; }
.card.appointment { border-top: 5px solid #18837b; }
.card.admission { border-top: 5px solid #4385a7; }
.card.notice-card { border-top: 5px solid #d39a43; }
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
label { display: block; margin-bottom: 7px; font-weight: 650; }
.required { color: #c84038; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fbfb;
  color: var(--text);
  padding: 13px 14px;
}
textarea { min-height: 110px; resize: vertical; }
.muted { color: var(--muted); font-size: 14px; }
.advice, .selected {
  margin-top: 12px;
  padding: 14px;
  border-radius: 12px;
  background: #f2effb;
  color: #514978;
}
.selected { background: #edf8f6; color: var(--primary-dark); text-align: center; font-weight: 700; }
.notice-line { display: flex; gap: 10px; margin-bottom: 12px; color: #526665; }
.notice-number {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 50%;
  background: #edf4f3;
  text-align: center;
  line-height: 26px;
}
.warning { padding: 14px; border-radius: 12px; background: var(--warning); color: #72531e; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0; }
.check input { width: 20px; margin-top: 5px; }
.primary, .secondary {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 13px;
  font-weight: 700;
}
.link-button { display: flex; align-items: center; justify-content: center; text-decoration: none; margin-top: 18px; }
.flow-card { position: relative; padding-left: 84px; }
.flow-number { position: absolute; left: 24px; top: 24px; display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: #e4f4f2; color: var(--primary-dark); font-size: 20px; font-weight: 800; }
.flow-card p { margin-bottom: 0; color: var(--muted); }
.compact-card { padding: 20px 24px; }
.compact-card h2 { margin-bottom: 8px; }
.primary { background: var(--primary); color: white; }
.primary:hover { background: var(--primary-dark); }
.secondary { border: 1px solid var(--primary); background: white; color: var(--primary); }
.links { display: flex; justify-content: center; gap: 20px; margin-top: 22px; }
.links a { color: var(--primary); }
.hidden { display: none !important; }
.message { margin: 15px 0; padding: 13px; border-radius: 10px; }
.message.error { background: #fdebea; color: var(--danger); }
.message.success { background: #edf8f6; color: var(--primary-dark); }
.save-result + .save-result { margin-top: 10px; }
.save-result strong { display: block; margin-bottom: 6px; }
.save-result ul { margin: 0; padding-left: 18px; }
.save-result.error { color: var(--danger); }
.save-result.success { color: var(--primary-dark); }
.success-box { text-align: center; }
.success-box .icon { font-size: 48px; color: var(--primary); }
.success-box code { display: block; margin: 10px 0; overflow-wrap: anywhere; }

.admin-page { width: min(1120px, 100%); }
.admin-header, .toolbar, .record-top, .record-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-header { justify-content: space-between; }
.admin-header .secondary { width: auto; padding: 0 18px; }
.toolbar { flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; min-width: 170px; flex: 1; }
.toolbar .primary, .toolbar .secondary { width: auto; padding: 0 18px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0; }
.stat { padding: 16px; border-radius: 14px; background: #edf8f6; text-align: center; }
.stat strong { display: block; font-size: 28px; color: var(--primary); }
.record { margin-bottom: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.record.cancelled-conflict { border-color: #e3a3a0; background: #fff6f5; }
.record-top { justify-content: space-between; }
.status-danger { color: var(--danger); }
.record h3 { margin: 0; }
.record-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 18px; margin: 14px 0; }
.record-grid div { overflow-wrap: anywhere; }
.record-grid b { color: #526665; }
.record-actions { justify-content: flex-end; }
.record-actions select { width: auto; }
.record-actions .secondary { width: auto; padding: 0 16px; min-height: 44px; }
.phone-editor { display: flex; align-items: end; gap: 10px; margin-top: 12px; }
.phone-editor label { flex: 1; margin: 0; }
.phone-editor input { margin-top: 6px; }
.phone-editor button { width: auto; min-height: 46px; padding: 0 16px; }
.bed-summary, .bed-admin-header { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.bed-summary p { margin: 0 0 0 auto; }
.legend { display: inline-block; width: 13px; height: 13px; margin-right: 6px; border-radius: 4px; vertical-align: -1px; }
.legend.free, .bed-cell.free { background: #e8f6f1; border-color: #57a884; color: #1f6d4f; }
.legend.occupied, .bed-cell.occupied { background: #fce9e7; border-color: #d4746c; color: #963d37; }
.bed-cell.manual { background: #fff1df; border-color: #d39a43; color: #8b5b10; }
.bed-cell.auto { background: #eef3ff; border-color: #5f84da; color: #3356a8; }
.bed-cell.package { box-shadow: inset 0 0 0 2px #7a56d8; }
.floor-card { border-top: 5px solid #4385a7; }
.floor-card h2 { margin-bottom: 18px; }
.bed-group { margin-top: 20px; }
.bed-group h3 { margin: 0 0 10px; font-size: 15px; color: #526665; }
.bed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 9px; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.room-card { position: relative; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfc; }
.room-card.male { border-top: 4px solid #5281b8; }
.room-card.female { border-top: 4px solid #c46689; }
.room-card.unset { border-top: 4px solid #a9b7b6; }
.room-title { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.room-title strong { font-size: 17px; }
.room-title span { color: var(--muted); font-size: 13px; }
.room-gender { margin: 11px 0; font-size: 13px; color: #526665; }
.room-gender select { margin-top: 5px; padding: 8px 10px; }
.room-beds { display: grid; grid-template-columns: repeat(auto-fit, minmax(62px, 1fr)); gap: 7px; }
.room-beds .bed-cell { min-height: 58px; }
.room-beds .bed-cell span { line-height: 1.3; }
.package-badge { margin-top: 10px; display: inline-flex; padding: 4px 10px; border-radius: 999px; background: #f3ecff; color: #6540ba; font-size: 12px; font-weight: 700; }
.room-gender-badge { position: absolute; top: 14px; right: 14px; padding: 2px 8px; border-radius: 99px; background: #edf4f3; color: #526665; font-size: 12px; }
.room-card.male .room-gender-badge { background: #e8f0fa; color: #356798; }
.room-card.female .room-gender-badge { background: #f9e8ef; color: #a34d70; }
.bed-cell { min-height: 66px; padding: 8px; border: 1px solid; border-radius: 11px; text-align: center; }
.bed-cell strong, .bed-cell span { display: block; }
.bed-cell strong { font-size: 17px; }
.bed-cell span { margin-top: 2px; font-size: 12px; }
button.bed-cell { cursor: pointer; font: inherit; }
.bed-admin-header { justify-content: space-between; }
.bed-admin-header h2 { margin-bottom: 2px; }
.bed-admin-header .primary { width: auto; padding: 0 18px; }

@media (max-width: 640px) {
  .page { padding: 14px 12px 40px; }
  .hero, .card { border-radius: 17px; padding: 20px; }
  .stats { grid-template-columns: 1fr; }
  .record-grid { grid-template-columns: 1fr; }
  .admin-header { align-items: flex-start; }
  .toolbar > * { width: 100% !important; }
  .phone-editor { align-items: stretch; flex-direction: column; }
  .phone-editor button { width: 100%; }
  .bed-summary p { width: 100%; margin-left: 0; }
  .bed-admin-header { align-items: stretch; }
  .bed-admin-header .primary { width: 100%; }
  .flow-card { padding-left: 76px; }
  .flow-number { left: 20px; }
}
