/* ============ РодДом Связь — панель персонала ============ */
/* Палитра сохранена: акцент #0F4C81, фон #f6f7fb */

:root {
  --accent: #0F4C81;
  --accent-dark: #0A3558;
  --accent-soft: #E4EFF8;
  --accent-soft-2: #fff0f5;
  --bg: #F3F6FA;
  --card: #ffffff;
  --text: #22262e;
  --muted: #8b93a1;
  --border: #eceef3;
  --danger: #fa5252;
  --ok: #2b8a3e;
  --warn: #e8890c;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --sh-1: 0 1px 2px rgba(34, 38, 46, .05);
  --sh-2: 0 6px 20px rgba(34, 38, 46, .08);
  --sh-3: 0 14px 44px rgba(34, 38, 46, .16);
}

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  height: 100dvh; overflow: hidden; background: var(--bg); color: var(--text); font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ---------- Вход ---------- */
.login-wrap {
  height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #fff0f5, var(--bg));
}
.login-box {
  background: var(--card); padding: 34px 30px; border-radius: var(--r-lg);
  box-shadow: var(--sh-3); display: flex; flex-direction: column; gap: 14px; width: 340px;
  border: 1px solid rgba(15, 76, 129, .07);
}
.login-box h1 { font-size: 19px; text-align: center; font-weight: 700; }
.login-box input {
  padding: 13px 14px; border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: 16px; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.login-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,76,129,.12); }
.login-box button {
  background: linear-gradient(135deg, var(--accent), #1B6FA8); color: #fff; border: none;
  padding: 13px; border-radius: var(--r-sm); font-size: 15px; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 18px rgba(15, 76, 129, .28); font-family: inherit;
}
.login-box button:hover { box-shadow: 0 8px 22px rgba(15, 76, 129, .36); }

/* ---------- Каркас ---------- */
#workbench { display: flex; height: 100dvh; }
.sidebar { width: 320px; background: var(--card); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar-head {
  padding: 15px 18px; font-weight: 800; font-size: 13px; letter-spacing: .6px;
  text-transform: uppercase; color: var(--accent-dark); border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--accent-soft-2), #fff);
}
#conv-list { flex: 1; overflow-y: auto; }
#right-tools {
  width: 76px; background: var(--card); border-left: 1px solid var(--border);
  padding: 12px 8px; display: flex; flex-direction: column; gap: 10px;
}
#right-tools button {
  width: 100%; border: 1.5px solid var(--border); color: var(--accent-dark); background: #fff;
  border-radius: var(--r-md); padding: 10px 4px; font-size: 11.5px; line-height: 1.3; cursor: pointer;
  font-weight: 600; font-family: inherit; transition: background .15s, border-color .15s;
}
#right-tools button:hover { background: var(--accent-soft-2); border-color: var(--accent); }

/* ---------- Список пациенток ---------- */
.conv {
  padding: 13px 16px; border-bottom: 1px solid #f6f7fa; cursor: pointer;
  border-left: 3px solid transparent; transition: background .12s;
}
.conv:hover { background: #faf7f9; }
.conv.active { background: var(--accent-soft-2); border-left-color: var(--accent); }
.conv .name { font-weight: 700; font-size: 14.5px; }
.conv .last {
  font-size: 13px; color: var(--muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv .badges { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.badge.unread { background: var(--accent); color: #fff; }
.badge.risk { background: var(--warn); color: #fff; }
.badge.emg { background: var(--danger); color: #fff; animation: blink 1.1s infinite; }
@keyframes blink { 50% { opacity: .45; } }

/* ---------- Чат ---------- */
#chat-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#chat-area.empty { align-items: center; justify-content: center; color: var(--muted); background: var(--bg); }
#chat-empty { text-align: center; font-size: 15px; }
#chat-empty::before { content: "👩‍⚕️"; display: block; font-size: 40px; margin-bottom: 10px; opacity: .5; }
#chat-inner { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#chat-head {
  background: var(--card); padding: 14px 20px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 15.5px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--sh-1); z-index: 2;
}
.rec-open {
  border: 1.5px solid var(--accent); color: var(--accent); background: #fff;
  border-radius: var(--r-pill); padding: 6px 14px; font-size: 12.5px; cursor: pointer;
  margin-left: auto; font-weight: 600; font-family: inherit; transition: background .15s;
}
.rec-open:hover { background: var(--accent-soft-2); }
#msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 9px; }
.msg {
  max-width: 66%; padding: 11px 15px; border-radius: 16px; font-size: 14.5px; line-height: 1.42;
  white-space: pre-wrap; word-wrap: break-word; animation: pop .16s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }
.msg .time { display: block; font-size: 11px; opacity: .5; margin-top: 5px; }
.msg.patient { background: #fff; align-self: flex-start; border: 1px solid var(--border); border-bottom-left-radius: 5px; box-shadow: var(--sh-1); }
.msg.staff { background: var(--accent-soft); align-self: flex-end; border-bottom-right-radius: 5px; color: #7a1039; }
.msg.emergency {
  background: #fff0f0; border: 2px solid var(--danger); align-self: center; font-weight: 700;
  color: #c92a2a; max-width: 88%; text-align: center; border-radius: var(--r-md);
}

/* ---------- Панель ответа ---------- */
.reply-bar { background: var(--card); border-top: 1px solid var(--border); padding: 10px 16px 14px; }
#quick-replies { display: flex; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
#quick-replies button {
  border: 1.5px solid var(--accent); color: var(--accent); background: #fff;
  padding: 6px 13px; border-radius: 999px; font-size: 12.5px; cursor: pointer; font-weight: 600;
  font-family: inherit; transition: background .15s;
}
#quick-replies button:hover { background: var(--accent-soft-2); }
.reply-row { display: flex; gap: 9px; }
.reply-row input {
  flex: 1; border: 1.5px solid var(--border); border-radius: 999px; padding: 12px 18px;
  font-size: 15px; font-family: inherit; background: #fbfbfc; transition: border-color .15s, box-shadow .15s;
}
.reply-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,76,129,.12); }
.reply-row button {
  background: linear-gradient(135deg, var(--accent), #1B6FA8); color: #fff; border: none;
  border-radius: 999px; padding: 0 22px; font-size: 14.5px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 76, 129, .28); font-family: inherit;
}

/* ---------- Модальные окна ---------- */
#rules-modal, .modal-ov {
  position: fixed; inset: 0; background: rgba(24, 26, 32, .42); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 18px;
  backdrop-filter: blur(2px);
}
.rules-box {
  background: var(--card); border-radius: var(--r-lg); padding: 24px; width: 580px; max-width: 94vw;
  max-height: 88vh; overflow-y: auto; display: flex; flex-direction: column; gap: 13px;
  box-shadow: var(--sh-3);
}
.rules-box h2 { font-size: 18px; font-weight: 700; }
.rule-item {
  border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px;
  margin-bottom: 8px; font-size: 14px; background: #fff;
}
.rule-item.off { opacity: .5; }
#sched-list .off { opacity: .45; }
.rule-item .kw { color: var(--accent-dark); font-weight: 700; }
.rule-item .del { float: right; border: none; background: none; color: var(--danger); cursor: pointer; font-size: 13px; font-family: inherit; }
.rule-item .txt { margin-top: 5px; color: #4b5563; line-height: 1.45; }
.rule-item .toggle {
  border: 1px solid #cbd2dc; background: #fff; border-radius: 999px; font-size: 12px;
  padding: 4px 11px; margin-top: 7px; cursor: pointer; font-family: inherit;
}
.rule-add { display: flex; flex-direction: column; gap: 9px; border-top: 1px dashed var(--border); padding-top: 14px; }
.rule-add input, .rule-add textarea {
  border: 1.5px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px;
  font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.rule-add input:focus, .rule-add textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,76,129,.12); }
.rule-add button, .rules-actions button {
  border: none; border-radius: var(--r-sm); padding: 11px; font-size: 14px; cursor: pointer;
  font-weight: 600; font-family: inherit;
}
#btn-add-rule { background: var(--accent-soft); color: var(--accent-dark); }
#btn-add-rule:hover { background: #ffd0e0; }
.rules-actions { display: flex; gap: 10px; margin-top: 4px; }
#btn-save-rules { flex: 1; background: linear-gradient(135deg, var(--accent), #1B6FA8); color: #fff; box-shadow: 0 4px 14px rgba(15,76,129,.25); }
#btn-close-rules, #btn-close-sched, #btn-close-appt, #btn-close-record { flex: 1; background: #eef0f4; color: #4b5563; }
#btn-close-rules:hover, #btn-close-sched:hover, #btn-close-appt:hover, #btn-close-record:hover { background: #e4e7ee; }

/* ---------- Расписание ---------- */
#s-days { display: flex; gap: 10px; flex-wrap: wrap; font-size: 14px; }
#s-days label { display: flex; align-items: center; gap: 4px; }
#s-days input { accent-color: var(--accent); }
.s-times { display: flex; gap: 8px; }
.s-times input { flex: 1; border: 1.5px solid var(--border); border-radius: var(--r-sm); padding: 9px; font-size: 14px; font-family: inherit; }

/* ---------- Заявки ---------- */
.appt-actions { display: flex; gap: 8px; margin-top: 9px; }
.appt-actions .ok { background: var(--ok); color: #fff; border: none; border-radius: var(--r-sm); padding: 9px 14px; font-size: 13px; cursor: pointer; font-weight: 600; font-family: inherit; }
.appt-actions .no { background: #fff; color: #c92a2a; border: 1.5px solid #c92a2a; border-radius: var(--r-sm); padding: 9px 14px; font-size: 13px; cursor: pointer; font-weight: 600; font-family: inherit; }

/* ---------- Анкета в модалке ---------- */
.risk-box {
  background: #fff8ee; border: 1.5px solid var(--warn); border-radius: var(--r-md);
  padding: 12px 14px; font-size: 14px; margin-bottom: 10px; line-height: 1.5;
}
.rec-head { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.rec-line { font-size: 14px; margin-bottom: 8px; line-height: 1.5; }
.rec-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rec-table td { border-bottom: 1px solid var(--border); padding: 8px 6px; vertical-align: top; }
.rec-table td:first-child { color: var(--muted); width: 45%; }

/* ---------- Адаптив ---------- */
@media (max-width: 980px) {
  .sidebar { width: 240px; }
  #right-tools { width: 64px; }
}
@media (max-width: 760px) {
  .msg { max-width: 82%; }
  #workbench { flex-direction: column; }
  .sidebar { width: 100%; max-height: 38dvh; border-right: none; border-bottom: 1px solid var(--border); }
  #right-tools { width: 100%; flex-direction: row; border-left: none; border-top: 1px solid var(--border); }
  #right-tools button { flex: 1; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(34, 38, 46, .16); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(34, 38, 46, .26); }
::-webkit-scrollbar-track { background: transparent; }

#btn-clear-all-float {
  position: fixed; top: 12px; right: 12px; z-index: 1000;
  background: #0F4C81; color: #fff; border: 0; border-radius: 10px;
  padding: 10px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 14px rgba(15,76,129,.35);
}
#btn-clear-all-float:hover { background: #0A3558; }

.sidebar-clear { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.sidebar-clear button { width: 100%; font-size: 12px; padding: 8px; border: 1px solid #C9D9E8; background: #fff; color: #0A3558; border-radius: 8px; cursor: pointer; font-weight: 600; }
.sidebar-clear button:hover { background: #ffe9f1; }

.sidebar-actions {
  padding: 8px 10px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px; background: var(--card); flex: 0 0 auto;
}
.sidebar-actions button {
  position: static !important; left: auto !important; right: auto !important;
  top: auto !important; bottom: auto !important;
  width: 100%; font-size: 12px; padding: 8px; border-radius: 8px;
  cursor: pointer; font-weight: 600; box-shadow: none;
}
.sidebar-actions #btn-clear-patients { background: #fff; color: #0A3558; border: 1px solid #C9D9E8; }
.sidebar-actions #btn-clear-all-float { background: #fff; color: #555; border: 1px solid #e5e7eb; }

#survey-questions .sq { border:1px solid #e5e7eb; border-radius:10px; padding:10px; margin:8px 0; display:grid; grid-template-columns:1fr 140px 32px; gap:6px; }
#survey-questions .sq input, #survey-questions .sq select { width:100%; padding:8px; border:1px solid #ddd; border-radius:7px; font:inherit; }
#survey-questions .sq .sq-opts { grid-column:1 / -1; }
#survey-questions .sq .sq-del { border:none; background:#fee2e2; color:#b91c1c; border-radius:8px; cursor:pointer; }
#survey-list .s-item { display:flex; gap:8px; align-items:center; justify-content:space-between; padding:8px 0; border-bottom:1px solid #eee; }
#survey-responses .s-resp { border:1px solid #eee; border-radius:10px; padding:10px; margin:8px 0; font-size:13px; }

.ans-layout { display:grid; grid-template-columns:320px 1fr; gap:14px; min-height:300px; }
#answers-list { max-height:55vh; overflow-y:auto; border:1px solid #eee; border-radius:10px; padding:6px; }
.ans-item { padding:10px; border-radius:8px; cursor:pointer; border-bottom:1px solid #f1f1f1; }
.ans-item:hover, .ans-item.active { background:#F1F7FC; }
.ans-item b { display:block; font-size:14px; }
.ans-item .muted { font-size:12px; }
#answers-detail { max-height:55vh; overflow-y:auto; padding:4px; }
.ans-table { width:100%; border-collapse:collapse; font-size:13px; }
.ans-table td { border-bottom:1px solid #eee; padding:7px 6px; vertical-align:top; }
.ans-table td:first-child { width:55%; color:#555; }
@media (max-width:700px){ .ans-layout{grid-template-columns:1fr} #answers-list{max-height:30vh} #answers-detail{max-height:40vh} }

/* ===== Survey modal redesign ===== */
.survey-modal-ov { padding: 24px; }
.survey-shell {
  width: min(1080px, 100%); max-height: calc(100dvh - 48px); background: #fff;
  border-radius: 20px; box-shadow: 0 24px 80px rgba(20, 24, 40, .22);
  display: flex; flex-direction: column; overflow: hidden; margin: 0 auto;
}
.survey-head {
  display: flex; align-items: center; gap: 14px; padding: 20px 24px;
  border-bottom: 1px solid #eef0f3; flex: 0 0 auto;
}
.survey-head-icon {
  width: 44px; height: 44px; border-radius: 13px; background: #E4EFF8;
  display: grid; place-items: center; font-size: 21px; flex: 0 0 auto;
}
.survey-head-text h2 { margin: 0; font-size: 20px; line-height: 1.2; }
.survey-head-text p { margin: 3px 0 0; font-size: 13px; color: #7b8494; }
.survey-x {
  margin-left: auto; width: 36px; height: 36px; border: none; border-radius: 10px;
  background: #f4f5f7; color: #555; font-size: 22px; line-height: 1; cursor: pointer;
}
.survey-x:hover { background: #eceef2; }
.survey-recipient {
  margin: 14px 24px 0; padding: 10px 14px; border-radius: 12px;
  background: #f8f9fb; border: 1px solid #eef0f3; color: #4b5563;
  font-size: 13px; display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
}
.survey-recipient.warn { background: #fff8e6; border-color: #ffe0a3; color: #8a5a00; }
.survey-body {
  display: grid; grid-template-columns: 330px minmax(0, 1fr); min-height: 0;
  flex: 1 1 auto; overflow: hidden;
}
.survey-side {
  border-right: 1px solid #eef0f3; background: #fbfbfc; padding: 16px;
  overflow-y: auto; min-height: 0;
}
.survey-side-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  color: #8a93a3; margin-bottom: 10px;
}
.survey-badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
  background: #E4EFF8; color: #0F4C81; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center;
}
.survey-tpl {
  display: flex; align-items: center; gap: 8px; background: #fff;
  border: 1px solid #e9ecf1; border-radius: 12px; padding: 10px 11px; margin-bottom: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.survey-tpl:hover { border-color: #C9D9E8; box-shadow: 0 4px 14px rgba(15,76,129,.08); }
.survey-tpl-main { flex: 1; min-width: 0; }
.survey-tpl-title {
  font-size: 13px; font-weight: 600; line-height: 1.35; color: #222;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.survey-tpl-meta { font-size: 11px; color: #9aa1ad; margin-top: 2px; }
.survey-tpl-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.survey-icon {
  width: 28px; height: 28px; border: 1px solid #e9ecf1; border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 13px; display: grid; place-items: center;
}
.survey-icon:hover { background: #F1F7FC; border-color: #C9D9E8; }
.survey-icon.danger:hover { background: #fee2e2; border-color: #fca5a5; }
.survey-empty {
  padding: 18px 12px; border: 1px dashed #dfe3ea; border-radius: 12px;
  color: #9aa1ad; font-size: 12.5px; text-align: center; line-height: 1.5;
}
.survey-responses .s-resp, .survey-resp {
  background: #fff; border: 1px solid #e9ecf1; border-radius: 10px;
  padding: 9px 10px; margin-bottom: 7px; font-size: 12px; color: #4b5563;
}
.survey-editor { padding: 18px 24px 24px; overflow-y: auto; min-height: 0; }
.survey-label { display: block; font-size: 12px; font-weight: 700; color: #8a93a3; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 7px; }
.survey-title-input {
  width: 100%; padding: 12px 14px; border: 1.5px solid #e3e7ee; border-radius: 11px;
  font: inherit; font-size: 15px; outline: none; background: #fff;
}
.survey-title-input:focus { border-color: #0F4C81; box-shadow: 0 0 0 3px rgba(15,76,129,.10); }
.survey-q-head {
  display: flex; align-items: center; gap: 8px; margin: 20px 0 10px;
  font-size: 12px; font-weight: 700; color: #8a93a3; text-transform: uppercase; letter-spacing: .4px;
}
.survey-questions .sq {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) 150px 30px;
  gap: 8px; align-items: center; background: #fff; border: 1px solid #e9ecf1;
  border-radius: 12px; padding: 11px; margin-bottom: 9px;
}
.survey-questions .sq:hover { border-color: #C9D9E8; }
.sq-num {
  width: 24px; height: 24px; border-radius: 50%; background: #E4EFF8;
  color: #0F4C81; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.survey-questions .sq input, .survey-questions .sq select {
  width: 100%; padding: 9px 10px; border: 1px solid #e3e7ee; border-radius: 8px;
  font: inherit; font-size: 13px; background: #fff; outline: none;
}
.survey-questions .sq input:focus, .survey-questions .sq select:focus { border-color: #0F4C81; }
.survey-questions .sq .sq-opts { grid-column: 2 / -1; }
.survey-questions .sq .sq-del {
  width: 28px; height: 28px; border: none; border-radius: 8px; background: #fee2e2;
  color: #b91c1c; cursor: pointer; font-size: 17px; line-height: 1;
}
.survey-add {
  border: 1px dashed #C9D9E8; background: #fff7fa; color: #0F4C81;
  border-radius: 11px; padding: 10px 14px; font-weight: 600; cursor: pointer;
}
.survey-add:hover { background: #ffeef5; }
.survey-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; border-top: 1px solid #eef0f3; background: #fff; flex: 0 0 auto;
}
.survey-foot-left, .survey-foot-right { display: flex; gap: 8px; align-items: center; }
.survey-btn {
  border: 1px solid #e3e7ee; background: #fff; color: #333; border-radius: 10px;
  padding: 10px 14px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.survey-btn:hover { background: #f7f8fa; }
.survey-btn.primary { background: #0F4C81; border-color: #0F4C81; color: #fff; }
.survey-btn.primary:hover { background: #0A3558; }
.survey-btn.ghost { color: #6b7280; }
@media (max-width: 860px) {
  .survey-modal-ov { padding: 10px; }
  .survey-shell { max-height: calc(100dvh - 20px); border-radius: 16px; }
  .survey-head { padding: 14px 16px; }
  .survey-head-icon { width: 38px; height: 38px; font-size: 18px; }
  .survey-head-text h2 { font-size: 17px; }
  .survey-head-text p { display: none; }
  .survey-recipient { margin: 10px 16px 0; }
  .survey-body { display: block; overflow-y: auto; }
  .survey-side { border-right: none; border-bottom: 1px solid #eef0f3; max-height: 230px; }
  .survey-editor { padding: 14px 16px 20px; overflow: visible; }
  .survey-questions .sq { grid-template-columns: 26px minmax(0,1fr) 28px; }
  .survey-questions .sq .sq-type { grid-column: 2 / 3; }
  .survey-questions .sq .sq-del { grid-column: 3 / 4; grid-row: 1; }
  .survey-questions .sq .sq-opts { grid-column: 2 / -1; }
  .survey-foot { flex-wrap: wrap; padding: 12px 16px; }
  .survey-foot-left, .survey-foot-right { width: 100%; }
  .survey-foot-right { justify-content: flex-end; }
}

/* override legacy survey question grid */
#survey-modal .survey-questions .sq {
  display:grid; grid-template-columns:28px minmax(0,1fr) 150px 30px; gap:8px;
  align-items:center; background:#fff; border:1px solid #e9ecf1; border-radius:12px;
  padding:11px; margin:0 0 9px;
}
#survey-modal .survey-questions .sq .sq-num { grid-column:1; grid-row:1; }
#survey-modal .survey-questions .sq .sq-text { grid-column:2; grid-row:1; }
#survey-modal .survey-questions .sq .sq-type { grid-column:3; grid-row:1; }
#survey-modal .survey-questions .sq .sq-del { grid-column:4; grid-row:1; }
#survey-modal .survey-questions .sq .sq-opts { grid-column:2 / -1; grid-row:2; }
#survey-modal .survey-questions .sq input, #survey-modal .survey-questions .sq select {
  width:100%; padding:9px 10px; border:1px solid #e3e7ee; border-radius:8px;
  font:inherit; font-size:13px; background:#fff;
}
#survey-modal .survey-questions .sq .sq-del {
  width:28px; height:28px; border:none; border-radius:8px; background:#fee2e2;
  color:#b91c1c; cursor:pointer; font-size:17px; line-height:1;
}
/* modals above the floating clear button */
.modal-ov { z-index: 2000 !important; }
@media (max-width:860px) {
  #survey-modal .survey-questions .sq { grid-template-columns:26px minmax(0,1fr) 28px; }
  #survey-modal .survey-questions .sq .sq-num { grid-column:1; grid-row:1; }
  #survey-modal .survey-questions .sq .sq-text { grid-column:2; grid-row:1; }
  #survey-modal .survey-questions .sq .sq-type { grid-column:2; grid-row:2; }
  #survey-modal .survey-questions .sq .sq-opts { grid-column:2 / -1; grid-row:3; }
  #survey-modal .survey-questions .sq .sq-del { grid-column:3; grid-row:1; }
}

/* ===== Answers modal redesign ===== */
.answers-modal-ov { padding: 24px; }
.answers-shell {
  width: min(1100px, 100%); max-height: calc(100dvh - 48px); background: #fff;
  border-radius: 20px; box-shadow: 0 24px 80px rgba(20,24,40,.22);
  display: flex; flex-direction: column; overflow: hidden; margin: 0 auto;
}
.answers-head { display: flex; align-items: center; gap: 14px; padding: 20px 24px; border-bottom: 1px solid #eef0f3; }
.answers-head-icon { width: 44px; height: 44px; border-radius: 13px; background: #e8f3ff; display: grid; place-items: center; font-size: 21px; }
.answers-head-text h2 { margin: 0; font-size: 20px; line-height: 1.2; }
.answers-head-text p { margin: 3px 0 0; font-size: 13px; color: #7b8494; }
.answers-x { margin-left: auto; width: 36px; height: 36px; border: none; border-radius: 10px; background: #f4f5f7; color: #555; font-size: 22px; cursor: pointer; }
.answers-x:hover { background: #eceef2; }
.answers-toolbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid #eef0f3; }
.answers-search-wrap { flex: 1; display: flex; align-items: center; gap: 8px; background: #f8f9fb; border: 1px solid #e9ecf1; border-radius: 11px; padding: 0 12px; }
.answers-search-wrap span { font-size: 14px; opacity: .65; }
.answers-search-wrap input { flex: 1; border: none; background: transparent; padding: 11px 0; font: inherit; font-size: 13px; outline: none; }
.answers-stats { flex: 0 0 auto; font-size: 12.5px; color: #6b7280; background: #f8f9fb; border: 1px solid #e9ecf1; border-radius: 999px; padding: 7px 12px; }
.answers-stats b { color: #0F4C81; }
.answers-body { display: grid; grid-template-columns: 350px minmax(0,1fr); min-height: 0; flex: 1 1 auto; overflow: hidden; }
.answers-side { border-right: 1px solid #eef0f3; background: #fbfbfc; padding: 14px; overflow-y: auto; min-height: 0; }
.answers-side-head { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: #8a93a3; margin: 2px 2px 10px; }
.answers-badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: #e8f3ff; color: #1d6fb8; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.answers-list { display: flex; flex-direction: column; gap: 8px; }
.answers-item { display: flex; align-items: flex-start; gap: 10px; background: #fff; border: 1px solid #e9ecf1; border-radius: 13px; padding: 11px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.answers-item:hover { border-color: #C9D9E8; }
.answers-item.active { border-color: #0F4C81; box-shadow: 0 4px 16px rgba(15,76,129,.10); background: #fff8fb; }
.answers-avatar { width: 34px; height: 34px; border-radius: 50%; background: #E4EFF8; color: #0F4C81; font-size: 12px; font-weight: 800; display: grid; place-items: center; flex: 0 0 auto; }
.answers-avatar.big { width: 52px; height: 52px; font-size: 17px; }
.answers-item-main { flex: 1; min-width: 0; }
.answers-item-name { font-size: 13px; font-weight: 700; color: #222; }
.answers-item-title { font-size: 12px; color: #4b5563; margin-top: 2px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.answers-item-meta { font-size: 11px; color: #9aa1ad; margin-top: 4px; }
.answers-check { color: #16a34a; font-size: 13px; font-weight: 700; flex: 0 0 auto; }
.answers-detail { padding: 18px 22px; overflow-y: auto; min-height: 0; }
.answers-empty, .answers-empty-state { padding: 40px 20px; text-align: center; color: #9aa1ad; font-size: 13px; }
.answers-detail-head { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg,#fff7fa,#f4f8ff); border: 1px solid #f1e3ea; border-radius: 14px; padding: 14px; margin-bottom: 16px; }
.answers-detail-head h3 { margin: 0; font-size: 17px; }
.answers-detail-sub { font-size: 12.5px; color: #4b5563; margin-top: 3px; }
.answers-detail-date { font-size: 11.5px; color: #9aa1ad; margin-top: 4px; }
.answers-status { margin-left: auto; align-self: flex-start; background: #e8f8ee; color: #15803d; border: 1px solid #bbf7d0; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.answers-groups { display: flex; flex-direction: column; gap: 12px; }
.answers-group { border: 1px solid #e9ecf1; border-radius: 13px; overflow: hidden; background: #fff; }
.answers-group-title { padding: 9px 13px; background: #f8f9fb; border-bottom: 1px solid #eef0f3; font-size: 11.5px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; color: #8a93a3; }
.answers-row { display: grid; grid-template-columns: minmax(0, 42%) minmax(0, 58%); gap: 10px; padding: 9px 13px; border-bottom: 1px solid #f1f3f6; font-size: 12.5px; }
.answers-row:last-child { border-bottom: none; }
.answers-label { color: #6b7280; line-height: 1.4; }
.answers-value { color: #222; font-weight: 600; line-height: 1.4; word-break: break-word; }
.answers-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid #eef0f3; background: #fff; flex: 0 0 auto; }
.answers-btn { border: 1px solid #e3e7ee; background: #fff; color: #333; border-radius: 10px; padding: 10px 14px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.answers-btn:hover { background: #f7f8fa; }
.answers-btn.ghost { color: #6b7280; }
@media (max-width: 860px) {
  .answers-modal-ov { padding: 10px; }
  .answers-shell { max-height: calc(100dvh - 20px); border-radius: 16px; }
  .answers-head { padding: 14px 16px; }
  .answers-head-icon { width: 38px; height: 38px; font-size: 18px; }
  .answers-head-text h2 { font-size: 17px; }
  .answers-head-text p { display: none; }
  .answers-toolbar { padding: 10px 14px; flex-wrap: wrap; }
  .answers-search-wrap { flex-basis: 100%; }
  .answers-body { display: block; overflow-y: auto; }
  .answers-side { border-right: none; border-bottom: 1px solid #eef0f3; max-height: 240px; }
  .answers-detail { overflow: visible; padding: 14px 16px 20px; }
  .answers-foot { padding: 12px 16px; }
}

/* ===== Schedule modal redesign ===== */
.sched-modal-ov { padding: 24px; }
.sched-shell {
  width: min(940px, 100%); max-height: calc(100dvh - 48px); background: #fff;
  border-radius: 20px; box-shadow: 0 24px 80px rgba(20,24,40,.22);
  display: flex; flex-direction: column; overflow: hidden; margin: 0 auto;
}
.sched-head { display: flex; align-items: center; gap: 14px; padding: 20px 24px; border-bottom: 1px solid #eef0f3; }
.sched-head-icon { width: 44px; height: 44px; border-radius: 13px; background: #eef7ff; display: grid; place-items: center; font-size: 21px; }
.sched-head-text h2 { margin: 0; font-size: 20px; line-height: 1.2; }
.sched-head-text p { margin: 3px 0 0; font-size: 13px; color: #7b8494; }
.sched-x { margin-left: auto; width: 36px; height: 36px; border: none; border-radius: 10px; background: #f4f5f7; color: #555; font-size: 22px; cursor: pointer; }
.sched-x:hover { background: #eceef2; }
.sched-body { display: grid; grid-template-columns: minmax(0,1fr) 380px; min-height: 0; flex: 1 1 auto; overflow: hidden; }
.sched-list-wrap { padding: 18px 20px; overflow-y: auto; border-right: 1px solid #eef0f3; background: #fbfbfc; min-height: 0; }
.sched-form { padding: 18px 20px 22px; overflow-y: auto; min-height: 0; }
.sched-section-head { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: #8a93a3; margin: 2px 2px 10px; }
.sched-badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: #eef7ff; color: #1d6fb8; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.sched-list { display: flex; flex-direction: column; gap: 8px; }
.sched-card { display: flex; align-items: flex-start; gap: 10px; background: #fff; border: 1px solid #e9ecf1; border-radius: 13px; padding: 12px; }
.sched-card.off { opacity: .55; }
.sched-avatar { width: 38px; height: 38px; border-radius: 50%; background: #eef7ff; color: #1d6fb8; font-size: 12px; font-weight: 800; display: grid; place-items: center; flex: 0 0 auto; }
.sched-main { flex: 1; min-width: 0; }
.sched-name { font-size: 13.5px; font-weight: 700; color: #222; line-height: 1.35; }
.sched-meta { font-size: 12px; color: #6b7280; margin-top: 3px; }
.sched-room { font-size: 11.5px; color: #9aa1ad; margin-top: 3px; }
.sched-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.sched-icon { width: 28px; height: 28px; border: 1px solid #e9ecf1; border-radius: 8px; background: #fff; cursor: pointer; font-size: 13px; display: grid; place-items: center; }
.sched-icon:hover { background: #F1F7FC; border-color: #C9D9E8; }
.sched-icon.del:hover { background: #fee2e2; border-color: #fca5a5; }
.sched-empty { padding: 24px 12px; border: 1px dashed #dfe3ea; border-radius: 12px; color: #9aa1ad; font-size: 12.5px; text-align: center; }
.sched-label { display: block; font-size: 11.5px; font-weight: 700; color: #8a93a3; text-transform: uppercase; letter-spacing: .4px; margin: 0 0 6px; }
.sched-input { width: 100%; padding: 10px 11px; border: 1.5px solid #e3e7ee; border-radius: 9px; font: inherit; font-size: 13px; background: #fff; outline: none; margin-bottom: 13px; }
.sched-input:focus { border-color: #0F4C81; box-shadow: 0 0 0 3px rgba(15,76,129,.10); }
.sched-days { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.sched-days label { position: relative; cursor: pointer; }
.sched-days input { position: absolute; opacity: 0; pointer-events: none; }
.sched-days span { display: inline-block; padding: 8px 11px; border: 1px solid #e3e7ee; border-radius: 9px; font-size: 12px; color: #6b7280; background: #fff; }
.sched-days input:checked + span { background: #F1F7FC; border-color: #0F4C81; color: #0F4C81; font-weight: 700; }
.sched-row3 { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 8px; }
.sched-row3 .sched-input { margin-bottom: 14px; }
.sched-btn { width: 100%; border: 1px solid #e3e7ee; background: #fff; color: #333; border-radius: 10px; padding: 11px 14px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.sched-btn:hover { background: #f7f8fa; }
.sched-btn.primary { background: #0F4C81; border-color: #0F4C81; color: #fff; }
.sched-btn.primary:hover { background: #0A3558; }
.sched-foot { display: flex; align-items: center; justify-content: flex-end; padding: 12px 24px; border-top: 1px solid #eef0f3; background: #fff; flex: 0 0 auto; }
.sched-foot .sched-btn { width: auto; }
@media (max-width: 860px) {
  .sched-modal-ov { padding: 10px; }
  .sched-shell { max-height: calc(100dvh - 20px); border-radius: 16px; }
  .sched-head { padding: 14px 16px; }
  .sched-head-icon { width: 38px; height: 38px; font-size: 18px; }
  .sched-head-text h2 { font-size: 17px; }
  .sched-head-text p { display: none; }
  .sched-body { display: block; overflow-y: auto; }
  .sched-list-wrap { border-right: none; border-bottom: 1px solid #eef0f3; max-height: 260px; }
  .sched-form { overflow: visible; }
  .sched-row3 { grid-template-columns: 1fr 1fr; }
  .sched-row3 > div:last-child { grid-column: 1 / -1; }
}

/* ===== Patient card modal ===== */
.record-modal-ov { padding: 24px; }
.record-shell { width: min(980px, 100%); max-height: calc(100dvh - 48px); background: #fff; border-radius: 20px; box-shadow: 0 24px 80px rgba(20,24,40,.22); display: flex; flex-direction: column; overflow: hidden; margin: 0 auto; }
.record-head { display: flex; align-items: center; gap: 13px; padding: 20px 24px; border-bottom: 1px solid #eef0f3; }
.record-avatar { width: 46px; height: 46px; border-radius: 50%; background: #E4EFF8; color: #0F4C81; display: grid; place-items: center; font-size: 15px; font-weight: 800; flex: 0 0 auto; }
.record-head-text h2 { margin: 0; font-size: 19px; line-height: 1.2; }
.record-head-text p { margin: 3px 0 0; font-size: 12.5px; color: #8a93a3; }
.record-x { margin-left: auto; width: 36px; height: 36px; border: none; border-radius: 10px; background: #f4f5f7; color: #555; font-size: 22px; cursor: pointer; }
.record-x:hover { background: #eceef2; }
.record-tabs { display: flex; gap: 4px; padding: 10px 24px 0; border-bottom: 1px solid #eef0f3; flex: 0 0 auto; }
.record-tab { border: none; background: transparent; padding: 9px 14px; font: inherit; font-size: 13px; font-weight: 600; color: #6b7280; cursor: pointer; border-radius: 10px 10px 0 0; }
.record-tab:hover { background: #f8f9fb; }
.record-tab.active { color: #0F4C81; background: #F1F7FC; box-shadow: inset 0 -2px 0 #0F4C81; }
.record-body { padding: 18px 24px 22px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.record-section.hidden { display: none; }
.record-group { border: 1px solid #e9ecf1; border-radius: 13px; padding: 13px 14px; margin-bottom: 12px; background: #fff; }
.record-group h3 { margin: 0 0 10px; font-size: 11.5px; letter-spacing: .4px; text-transform: uppercase; color: #8a93a3; }
.record-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.record-field { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: #6b7280; }
.record-field input, .record-field select { width: 100%; padding: 9px 10px; border: 1px solid #e3e7ee; border-radius: 8px; font: inherit; font-size: 13px; background: #fff; outline: none; }
.record-field input:focus, .record-field select:focus { border-color: #0F4C81; box-shadow: 0 0 0 3px rgba(15,76,129,.08); }
.record-checks { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.record-checks label { display: flex; align-items: center; gap: 6px; font-size: 12px; background: #f8f9fb; border: 1px solid #e9ecf1; border-radius: 8px; padding: 7px 9px; cursor: pointer; }
.record-checks input { accent-color: #0F4C81; }
.record-save-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.record-btn { border: 1px solid #e3e7ee; background: #fff; color: #333; border-radius: 10px; padding: 10px 14px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.record-btn:hover { background: #f7f8fa; }
.record-btn.primary { background: #0F4C81; border-color: #0F4C81; color: #fff; }
.record-btn.primary:hover { background: #0A3558; }
.record-saved { color: #15803d; font-size: 12.5px; font-weight: 600; }
.record-saved.hidden { display: none; }
.record-foot { display: flex; justify-content: flex-end; padding: 12px 24px; border-top: 1px solid #eef0f3; background: #fff; flex: 0 0 auto; }
.record-foot .record-btn { width: auto; }
.record-survey-item { display: flex; align-items: center; gap: 10px; border: 1px solid #e9ecf1; border-radius: 12px; padding: 11px 12px; margin-bottom: 8px; background: #fff; cursor: pointer; }
.record-survey-item:hover { border-color: #C9D9E8; }
.record-survey-main { flex: 1; min-width: 0; }
.record-survey-main b { font-size: 13px; }
.record-survey-meta { font-size: 11.5px; color: #8a93a3; margin-top: 2px; }
.record-survey-status { font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
.record-survey-status.done { background: #e8f8ee; color: #15803d; }
.record-survey-status.wait { background: #fff8e6; color: #8a5a00; }
.record-survey-detail { margin-top: 12px; }
.record-detail-head { background: linear-gradient(135deg,#fff7fa,#f4f8ff); border: 1px solid #f1e3ea; border-radius: 13px; padding: 12px 14px; margin-bottom: 10px; }
.record-detail-head b { font-size: 14px; }
.record-detail-head div { font-size: 11.5px; color: #8a93a3; margin-top: 3px; }
.record-answer-group { border: 1px solid #e9ecf1; border-radius: 12px; overflow: hidden; margin-bottom: 9px; }
.record-answer-title { padding: 8px 12px; background: #f8f9fb; border-bottom: 1px solid #eef0f3; font-size: 11px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; color: #8a93a3; }
.record-answer-row { display: grid; grid-template-columns: minmax(0,42%) minmax(0,58%); gap: 8px; padding: 8px 12px; border-bottom: 1px solid #f1f3f6; font-size: 12px; }
.record-answer-row:last-child { border-bottom: none; }
.record-answer-label { color: #6b7280; line-height: 1.4; }
.record-answer-value { color: #222; font-weight: 600; line-height: 1.4; word-break: break-word; }
.record-empty { padding: 26px 14px; text-align: center; color: #9aa1ad; font-size: 12.5px; border: 1px dashed #dfe3ea; border-radius: 12px; }
@media (max-width: 860px) {
  .record-modal-ov { padding: 10px; }
  .record-shell { max-height: calc(100dvh - 20px); border-radius: 16px; }
  .record-head { padding: 14px 16px; }
  .record-head-text h2 { font-size: 17px; }
  .record-tabs { padding: 8px 16px 0; }
  .record-body { padding: 14px 16px 18px; }
  .record-grid { grid-template-columns: 1fr; }
  .record-foot { padding: 12px 16px; }
}

/* ===== Staff three-column layout ===== */
#workbench { display: flex; flex-direction: column; height: 100dvh; }
.staff-topbar {
  height: 62px; flex: 0 0 auto; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 18px; z-index: 20;
}
.staff-brand { display: flex; align-items: center; gap: 8px; min-width: 210px; }
.staff-logo { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center; font-size: 17px; }
.staff-brand b { font-size: 15px; color: var(--accent-dark); white-space: nowrap; }
.staff-brand span:last-child { font-size: 11px; color: #9aa1ad; white-space: nowrap; }
.staff-nav { display: flex; align-items: center; gap: 4px; flex: 1; overflow-x: auto; }
.staff-nav button {
  border: 1px solid transparent; background: transparent; color: #6b7280; border-radius: 9px;
  padding: 8px 10px; font: inherit; font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.staff-nav button:hover { background: #f8f9fb; border-color: #e9ecf1; color: var(--accent-dark); }
.staff-logout {
  border: 1px solid #e3e7ee; background: #fff; color: #6b7280; border-radius: 9px;
  padding: 8px 12px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; flex: 0 0 auto;
}
.staff-main { display: grid; grid-template-columns: 300px minmax(0, 1fr) 330px; flex: 1; min-height: 0; overflow: hidden; }
.staff-main .sidebar { width: auto; min-height: 0; }
.staff-main #chat-area { min-height: 0; background: #f7f8fa; }
#chat-area.empty { background: #f7f8fa; }
#chat-area.empty #chat-empty { color: #9aa1ad; font-size: 14px; }
#chat-area.empty #chat-empty::before { content: "💬"; font-size: 44px; opacity: .65; }
.patient-panel { background: #fff; border-left: 1px solid var(--border); overflow-y: auto; min-height: 0; }
.patient-empty { padding: 48px 24px; text-align: center; color: #9aa1ad; font-size: 13px; line-height: 1.5; }
.patient-empty-ico { font-size: 36px; margin-bottom: 8px; }
.patient-empty b { display: block; color: #4b5563; font-size: 14px; margin-bottom: 4px; }
.patient-empty p { margin: 0; }
.pp-head { display: flex; align-items: center; gap: 11px; padding: 20px 18px; border-bottom: 1px solid #eef0f3; }
.pp-avatar { width: 48px; height: 48px; border-radius: 50%; background: #E4EFF8; color: #0F4C81; display: grid; place-items: center; font-size: 15px; font-weight: 800; flex: 0 0 auto; }
.pp-head h3 { margin: 0; font-size: 16px; line-height: 1.25; }
.pp-head p { margin: 3px 0 0; font-size: 12px; color: #8a93a3; }
.pp-actions { display: flex; gap: 6px; padding: 12px 16px; border-bottom: 1px solid #eef0f3; }
.pp-actions button { flex: 1; border: 1px solid #e3e7ee; background: #fff; color: #4b5563; border-radius: 9px; padding: 8px 6px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.pp-actions button:hover { background: #F1F7FC; border-color: #C9D9E8; color: #0F4C81; }
.pp-summary { padding: 14px 16px 22px; }
.pp-loading { color: #9aa1ad; font-size: 12.5px; padding: 12px 0; }
.pp-risk { background: #fff8e6; border: 1px solid #ffe0a3; color: #8a5a00; border-radius: 10px; padding: 9px 11px; font-size: 12px; line-height: 1.45; margin-bottom: 12px; }
.pp-section { margin-bottom: 14px; }
.pp-section h4 { margin: 0 0 6px; font-size: 10.5px; letter-spacing: .5px; text-transform: uppercase; color: #9aa1ad; }
.pp-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid #f1f3f6; font-size: 12.5px; }
.pp-row:last-child { border-bottom: none; }
.pp-row span:first-child { color: #7b8494; flex: 0 0 auto; }
.pp-row b { text-align: right; color: #222; font-weight: 600; word-break: break-word; }
@media (max-width: 1180px) {
  .staff-main { grid-template-columns: 270px minmax(0,1fr) 300px; }
  .staff-brand span:last-child { display: none; }
}
@media (max-width: 960px) {
  .staff-main { grid-template-columns: 250px minmax(0,1fr); }
  .patient-panel { display: none; }
}
@media (max-width: 700px) {
  .staff-topbar { height: 56px; padding: 0 10px; gap: 8px; }
  .staff-brand { min-width: 0; }
  .staff-brand b { font-size: 13px; }
  .staff-nav button { padding: 7px 8px; font-size: 11.5px; }
  .staff-main { display: flex; flex-direction: column; }
  .staff-main .sidebar { max-height: 34dvh; width: 100%; }
}

/* sticky header + top-right close for auto-reply rules */
.rules-head {
  position: sticky; top: -24px; margin: -24px -24px 0; padding: 20px 24px 8px;
  background: #fff; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; z-index: 3; border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.rules-head h2 { font-size: 18px; font-weight: 700; margin: 0; }
.rules-x {
  width: 34px; height: 34px; border: none; border-radius: 10px; background: #f4f5f7;
  color: #555; font-size: 21px; line-height: 1; cursor: pointer; flex: 0 0 auto;
}
.rules-x:hover { background: #eceef2; }
@media (max-width: 600px) {
  .rules-head { top: -18px; margin: -18px -18px 0; padding: 16px 18px 8px; }
}

/* ===== University staff login ===== */
.staff-login-wrap { background: radial-gradient(900px 500px at 20% 0%, #E4EFF8, #F3F6FA 70%); }
.staff-login-shell {
  width: min(980px, 100%); display: grid; grid-template-columns: 1fr 400px;
  background: #fff; border-radius: 24px; overflow: hidden; border: 1px solid #DDE5EE;
  box-shadow: 0 30px 80px rgba(10, 53, 88, .16);
}
.staff-login-brand {
  background: linear-gradient(145deg, #0A3558 0%, #0F4C81 58%, #1B6FA8 100%);
  color: #fff; padding: 42px; display: flex; flex-direction: column; gap: 26px; justify-content: space-between;
}
.staff-login-brand .univ-mark { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.26); }
.staff-login-brand .univ-kicker { color: rgba(255,255,255,.72); }
.staff-login-brand .login-dept { color: #C8A24A; }
.staff-login-brand h1 { font-family: Georgia, "Times New Roman", serif; font-size: 28px; margin: 0 0 10px; }
.staff-login-brand p { margin: 0; color: rgba(255,255,255,.8); font-size: 13px; line-height: 1.6; max-width: 400px; }
.staff-login-foot { font-size: 11px; color: rgba(255,255,255,.55); }
.staff-login-box {
  width: auto; box-shadow: none; border: none; border-radius: 0; padding: 42px 38px;
  justify-content: center; gap: 10px; background: #fff;
}
.staff-login-box h2 { font-size: 22px; margin: 0; color: #1F2937; }
.staff-login-box .login-sub { margin: 0 0 14px; }
.staff-login-box input { margin-bottom: 4px; }
.staff-login-box button {
  background: linear-gradient(135deg, #0F4C81, #1B6FA8); color: #fff; border: none;
  padding: 12px; border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 22px rgba(15,76,129,.22);
}
.staff-login-box button:hover { box-shadow: 0 10px 26px rgba(15,76,129,.30); }
@media (max-width: 820px) {
  .staff-login-shell { grid-template-columns: 1fr; border-radius: 18px; }
  .staff-login-brand { padding: 24px 22px; gap: 14px; }
  .staff-login-brand h1 { font-size: 24px; }
  .staff-login-foot { display: none; }
  .staff-login-box { padding: 24px 22px 28px; }
}
.site-logo-text, .staff-logo-text { font-size: 11px !important; font-weight: 800; letter-spacing: .5px; color: #0F4C81; }

.staff-login-brand .login-brand-top { display: flex; align-items: center; gap: 12px; }
.staff-login-brand .univ-mark { width: 52px; height: 52px; flex: 0 0 52px; display: grid; place-items: center; }
.staff-login-brand .univ-kicker { flex: 1; }

.staff-login-base { margin: 12px 0 0; font-size: 12px; line-height: 1.5; color: rgba(255,255,255,.85); border-left: 2px solid #C8A24A; padding-left: 10px; }
.staff-login-more { margin: 6px 0 0 12px; font-size: 11px; line-height: 1.5; color: rgba(255,255,255,.55); }

/* ===== Registration / invites ===== */
.reg-modal-ov { padding: 24px; }
.reg-shell { width: min(900px,100%); max-height: calc(100dvh - 48px); background:#fff; border-radius:20px; box-shadow:0 24px 80px rgba(20,24,40,.22); display:flex; flex-direction:column; overflow:hidden; margin:0 auto; }
.reg-head { display:flex; align-items:center; gap:13px; padding:20px 24px; border-bottom:1px solid #eef0f3; }
.reg-head-icon { width:44px;height:44px;border-radius:13px;background:#E4EFF8;display:grid;place-items:center;font-size:21px; }
.reg-head-text h2 { margin:0;font-size:20px; }
.reg-head-text p { margin:3px 0 0;font-size:13px;color:#7b8494; }
.reg-x { margin-left:auto;width:36px;height:36px;border:none;border-radius:10px;background:#f4f5f7;color:#555;font-size:22px;cursor:pointer; }
.reg-tabs { display:flex; gap:4px; padding:10px 24px 0; border-bottom:1px solid #eef0f3; }
.reg-tab { border:none;background:transparent;padding:9px 14px;font:inherit;font-size:13px;font-weight:600;color:#6b7280;cursor:pointer;border-radius:10px 10px 0 0; }
.reg-tab.active { color:#0F4C81;background:#F1F7FC;box-shadow:inset 0 -2px 0 #0F4C81; }
.reg-badge { display:inline-grid;place-items:center;min-width:20px;height:20px;padding:0 6px;margin-left:4px;border-radius:999px;background:#E4EFF8;color:#0F4C81;font-size:10px;font-weight:800; }
.reg-body { padding:18px 24px; overflow-y:auto; flex:1; min-height:0; }
.reg-section.hidden { display:none; }
.reg-card { display:flex; align-items:flex-start; gap:11px; background:#fff; border:1px solid #e9ecf1; border-radius:12px; padding:12px; margin-bottom:8px; }
.reg-avatar { width:36px;height:36px;border-radius:50%;background:#E4EFF8;color:#0F4C81;display:grid;place-items:center;font-size:12px;font-weight:800;flex:0 0 auto; }
.reg-main { flex:1;min-width:0; }
.reg-main b { font-size:13.5px; }
.reg-meta { font-size:11.5px;color:#8a93a3;margin-top:2px; }
.reg-actions { display:flex;gap:5px;flex-wrap:wrap;justify-content:flex-end; }
.reg-actions button { border:1px solid #e3e7ee;background:#fff;border-radius:8px;padding:7px 9px;font:inherit;font-size:11.5px;font-weight:700;cursor:pointer; }
.reg-actions .ok { background:#EAF7F0;border-color:#B7E4CD;color:#166534; }
.reg-actions .no { background:#FDECEC;border-color:#F3C2C2;color:#9B1C1C; }
.reg-empty { padding:30px 14px;text-align:center;color:#9aa1ad;font-size:12.5px;border:1px dashed #dfe3ea;border-radius:12px; }
.invite-create { border:1px solid #e9ecf1;border-radius:12px;padding:12px;margin-bottom:12px;background:#fbfbfc; }
.invite-grid { display:grid;grid-template-columns:1.2fr 1fr 110px;gap:8px;margin-bottom:8px; }
.invite-grid input,.invite-grid select { width:100%;padding:9px 10px;border:1px solid #e3e7ee;border-radius:8px;font:inherit;font-size:12.5px;background:#fff; }
.invite-new { background:#EAF7F0;border:1px solid #B7E4CD;border-radius:12px;padding:12px 14px;margin-bottom:12px; }
.invite-new .code { font-family:ui-monospace,Consolas,monospace;font-size:22px;font-weight:800;letter-spacing:1px;color:#0A3558;margin:4px 0 8px; }
.invite-new button { border:1px solid #B7E4CD;background:#fff;color:#166534;border-radius:8px;padding:6px 10px;font:inherit;font-size:12px;font-weight:700;cursor:pointer; }
.reg-subhead { font-size:11px;font-weight:800;letter-spacing:.5px;text-transform:uppercase;color:#8a93a3;margin:14px 0 8px; }
.invite-item { display:flex;align-items:center;gap:8px;border:1px solid #e9ecf1;border-radius:10px;padding:9px 11px;margin-bottom:6px;font-size:12px; }
.invite-item .inv-main { flex:1;min-width:0; }
.invite-item b { font-size:12.5px; }
.invite-item .meta { color:#8a93a3;font-size:11px;margin-top:2px; }
.invite-status { font-size:10.5px;font-weight:800;padding:3px 7px;border-radius:999px;white-space:nowrap; }
.invite-status.active { background:#EAF7F0;color:#166534; }
.invite-status.used { background:#F1F7FC;color:#0F4C81; }
.invite-status.expired { background:#FDECEC;color:#9B1C1C; }
.invite-item button { border:1px solid #e3e7ee;background:#fff;border-radius:7px;padding:5px 8px;font:inherit;font-size:11px;cursor:pointer; }
.reg-foot { display:flex;justify-content:flex-end;padding:12px 24px;border-top:1px solid #eef0f3;background:#fff; }
.reg-btn { border:1px solid #e3e7ee;background:#fff;color:#333;border-radius:10px;padding:10px 14px;font:inherit;font-size:13px;font-weight:600;cursor:pointer; }
.reg-btn.primary { background:#0F4C81;border-color:#0F4C81;color:#fff; }
@media(max-width:760px){ .reg-modal-ov{padding:10px} .reg-shell{max-height:calc(100dvh - 20px);border-radius:16px} .reg-head{padding:14px 16px} .reg-body{padding:12px 16px} .invite-grid{grid-template-columns:1fr} .reg-actions{width:100%;justify-content:flex-start} }

/* sidebar registration list */
.sidebar-tabs { display:flex; gap:4px; padding:8px 10px; border-bottom:1px solid var(--border); background:#fff; flex:0 0 auto; }
.side-tab { flex:1; border:1px solid transparent; background:#f8f9fb; color:#6b7280; border-radius:8px; padding:7px 6px; font:inherit; font-size:11px; font-weight:700; cursor:pointer; }
.side-tab.active { background:#E4EFF8; color:#0F4C81; border-color:#C9D9E8; }
.side-count { display:inline-grid; place-items:center; min-width:17px; height:17px; padding:0 5px; margin-left:3px; border-radius:999px; background:#0F4C81; color:#fff; font-size:9.5px; font-weight:800; }
#reg-side-list { flex:1; overflow-y:auto; padding:10px; min-height:0; }
.reg-side-head { display:flex; align-items:center; justify-content:space-between; gap:6px; margin-bottom:8px; font-size:10px; font-weight:800; letter-spacing:.4px; text-transform:uppercase; color:#8a93a3; }
.reg-side-invite { border:1px solid #C9D9E8; background:#F1F7FC; color:#0F4C81; border-radius:7px; padding:5px 7px; font:inherit; font-size:10px; font-weight:700; cursor:pointer; }
.side-reg-card { border:1px solid #e9ecf1; border-radius:10px; padding:10px; margin-bottom:7px; background:#fff; }
.side-reg-name { font-size:12.5px; font-weight:700; }
.side-reg-meta { font-size:11px; color:#8a93a3; margin-top:2px; line-height:1.35; }
.side-reg-actions { display:flex; gap:5px; margin-top:7px; }
.side-reg-actions button { flex:1; border:1px solid #e3e7ee; background:#fff; border-radius:7px; padding:6px 4px; font:inherit; font-size:10.5px; font-weight:700; cursor:pointer; }
.side-reg-actions .ok { background:#EAF7F0; border-color:#B7E4CD; color:#166534; }
.side-reg-actions .no { background:#FDECEC; border-color:#F3C2C2; color:#9B1C1C; }
