:root {
  --primary: #20b2aa;
  --primary-dark: #189a93;
  --primary-light: #e8f8f7;
  --primary-muted: #b2e4e1;
  --accent-blue: #3182ce;
  --bg-page: #f0f2f5;
  --bg-card: #ffffff;
  --text-primary: #1a202c;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --sidebar-width: 200px;
  --header-height: 56px;
  --radius: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* ── Login ── */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(145deg, #e8f8f7 0%, var(--bg-page) 45%, #eef2ff 100%);
}

.service-date-fields {
  margin: 0 0 12px;
  display: grid;
  gap: 8px;
}

.service-date-fields.hidden {
  display: none;
}

.icp-beian {
  margin: 28px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted, #8a8580);
  text-align: center;
}

.icp-beian a {
  color: inherit;
  text-decoration: none;
}

.icp-beian a:hover {
  text-decoration: underline;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.login-logo {
  font-size: 1.75rem;
  line-height: 1;
}

.login-brand-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.login-card h1 {
  font-size: 1.25rem;
  margin: 0 0 8px;
  color: var(--text-primary);
}

/* ── App shell ── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  height: var(--header-height);
  padding: 0 20px 0 16px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(32, 178, 170, 0.25);
}

.app-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.app-logo {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}

.app-header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

#app:not(.senior-mode) .app-sidebar,
#app.senior-mode .app-sidebar {
  display: block;
}

#app:not(.senior-mode) #staffNav {
  display: flex;
}

#app.senior-mode #seniorNav {
  display: flex;
}

.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 32px;
  background: var(--bg-page);
}

.app-msg {
  position: sticky;
  bottom: 0;
  margin: 16px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.45;
}

.app-msg-ok {
  background: #f0fff4;
  border: 1px solid #9ae6b4;
  color: #276749;
}

.app-msg-err {
  background: #fff5f5;
  border: 1px solid #feb2b2;
  color: #c53030;
}

.app-msg:not(.app-msg-ok):not(.app-msg-err):not(:empty) {
  background: #f0fff4;
  border: 1px solid #9ae6b4;
  color: #276749;
}

.app-msg:empty {
  display: none;
}

h1 {
  font-size: 1.35rem;
  margin: 0 0 12px;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 14px;
  padding-left: 12px;
  border-left: 4px solid var(--primary);
  color: var(--text-primary);
  font-weight: 600;
}
.hint {
  font-size: 0.85rem;
  color: #4a5568;
  margin: 0 0 12px;
  line-height: 1.5;
}
.field-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #2d3748;
  margin: 8px 0 6px;
}
.input-file {
  padding: 8px 0;
  border: none;
  background: transparent;
}
.logo-preview {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid #cbd5e0;
  margin-bottom: 10px;
  background: #f7fafc;
}
.logo-preview.hidden {
  display: none;
}
.homepage-butler-block {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}
.homepage-butler-block h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.butler-avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
}
.course-img-preview {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid #cbd5e0;
  margin-bottom: 10px;
  background: #f7fafc;
}
.course-img-preview.hidden {
  display: none;
}
.course-img-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.course-img-item {
  position: relative;
  width: 96px;
}
.course-img-item img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #cbd5e0;
  display: block;
}
.course-img-remove {
  width: 100%;
  margin-top: 4px;
  padding: 4px 6px;
  font-size: 0.75rem;
}
.org-logo-block {
  margin: 12px 0;
  padding: 12px 0;
  border-top: 1px solid #e2e8f0;
}
.org-logo-block.hidden {
  display: none;
}
.org-invite-poster {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed #e2e8f0;
}
.org-invite-title {
  margin: 0 0 8px;
  font-size: 1rem;
}
.org-invite-card {
  max-width: 280px;
  margin: 12px 0;
  padding: 16px;
  text-align: center;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 12px;
}
.org-invite-logo-mini {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 8px;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.org-invite-logo-mini.hidden {
  display: none;
}
.org-invite-org-name {
  margin: 0 0 10px;
  font-weight: 700;
  color: #9a3412;
}
.org-invite-qr {
  width: 200px;
  height: 200px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}
.org-invite-qr.hidden {
  display: none;
}
.org-invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.org-invite-actions button,
.org-invite-actions a.btn-secondary {
  width: auto;
  margin-bottom: 0;
  text-decoration: none;
  display: inline-block;
  box-sizing: border-box;
}
input,
textarea,
select,
button {
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
}
button {
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s;
}
button:hover {
  background: var(--primary-dark);
}
button:active {
  opacity: 0.9;
}

.staff-header-org {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(240px, 42vw);
  padding: 4px 14px 4px 4px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

.staff-header-org-logo,
.staff-header-org-fallback {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
}

.staff-header-org-logo {
  object-fit: cover;
  background: #fff;
}

.staff-header-org-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.88);
}

.staff-header-org-fallback.hidden {
  display: none;
}

.staff-header-org-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.senior-badge {
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.login-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.login-tabs .tab-btn {
  flex: 1;
  width: auto;
  min-width: 0;
  margin-bottom: 0;
  text-align: center;
}

#app.senior-mode .staff-only {
  display: none !important;
}

#app:not(.senior-mode) #staffNav.staff-only {
  display: flex !important;
}

.senior-only {
  display: none;
}

#app.senior-mode #seniorNav.senior-only {
  display: flex !important;
}

select.org-locked {
  opacity: 0.85;
  pointer-events: none;
  background: #edf2f7;
}

#login input.hidden-field {
  display: none;
}
button.link {
  width: auto;
  margin: 0;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  font-size: 0.9rem;
}
button.link:hover {
  background: rgba(255, 255, 255, 0.25);
}
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.card-highlight {
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.err {
  color: #c53030;
  font-size: 0.9rem;
}
.msg {
  color: #276749;
  font-size: 0.95rem;
  white-space: pre-wrap;
}
.btn-secondary {
  background: #64748b;
  margin-top: 4px;
}
.btn-secondary:hover {
  background: #475569;
}
.btn-sm {
  width: auto;
  display: inline-block;
  padding: 6px 12px;
  font-size: 0.85rem;
  margin-top: 8px;
}
.list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}
.list-item {
  padding: 12px 0;
  border-bottom: 1px solid #e2e8f0;
}

.pending-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.pending-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f7fafc;
  flex-shrink: 0;
}

.pending-body {
  flex: 1;
  min-width: 0;
}

.pending-item .btn-sm {
  margin-top: 0;
  margin-right: 8px;
}
.list-item:last-child {
  border-bottom: none;
}
.checkin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.checkin-status {
  font-size: 13px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
}
.checkin-status.done {
  color: #0f5132;
  background: #d1e7dd;
}
.checkin-status.pending {
  color: #664d03;
  background: #fff3cd;
}
.checkin-answers {
  list-style: none;
  margin: 0;
  padding: 0;
}
.checkin-answers li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 12px;
  margin-bottom: 6px;
  background: #f7fafc;
  border-radius: 6px;
  font-size: 14px;
}
.checkin-q {
  color: #334155;
  flex: 1;
}
.checkin-a {
  color: #1e40af;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.checkin-note {
  margin: 4px 0 0;
  font-size: 13px;
}
.checkin-pending .checkin-empty {
  margin: 0;
}
.plan-item-row {
  padding-left: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.plan-item-row .btn-sm {
  margin-top: 0;
  margin-left: auto;
}
.message-thread {
  max-height: 360px;
  overflow-y: auto;
  margin: 12px 0;
  padding: 12px;
  background: #f7fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.msg-row {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
}
.msg-row.msg-elder {
  border-left: 4px solid var(--primary);
}
.msg-row.msg-unread {
  border-left-color: #ea580c;
  background: #fff7ed;
  border-color: #fdba74;
}
.msg-row.msg-reply {
  border-left: 4px solid var(--accent-blue);
  background: #ebf8ff;
}
.msg-meta {
  font-size: 0.8rem;
  color: #718096;
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.msg-unread-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: #ea580c;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.4;
}
.msg-body {
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.tab-row {
  display: flex;
  gap: 8px;
  margin: 8px 0 12px;
  flex-wrap: wrap;
}

.tab-row .tab-btn {
  width: auto;
  margin-bottom: 0;
}

.tab-btn {
  border: 1px solid #cbd5e0;
  background: #fff;
  color: #4a5568;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}

.tab-btn.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.ops-month-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
}

.ops-month-label {
  min-width: 96px;
  text-align: center;
  font-weight: 600;
  color: #2d3748;
}

.ops-bucket-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  margin: 0 0 14px;
}

.ops-bucket-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 6px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  color: #4a5568;
  cursor: pointer;
  min-height: 56px;
}

.ops-bucket-chip strong {
  font-size: 1.15rem;
  color: var(--primary);
  line-height: 1.1;
}

.ops-bucket-chip span {
  font-size: 0.78rem;
  color: #718096;
  line-height: 1.2;
}

.ops-bucket-chip.on {
  border-color: var(--primary);
  background: #ebf8ff;
}

.ops-bucket-chip.on span {
  color: #2c5282;
}

.ops-review-line {
  margin: 6px 0 0;
  color: #2d3748;
}

.ops-review-empty {
  color: #a0aec0;
}

.ops-dash {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.ops-stat {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
}

.ops-stat strong {
  display: block;
  font-size: 1.25rem;
  color: var(--primary);
  margin-bottom: 2px;
}

.ops-stat span {
  font-size: 0.82rem;
  color: #718096;
}

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

.ops-tag {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: #4a5568;
}

.ops-tag.referral-in {
  background: #fef3c7;
  color: #92400e;
}

.staff-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 12px 0;
  background: transparent;
  border: none;
  border-radius: 0;
}

.staff-nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 8px);
  margin: 0 0 0 8px;
  padding: 11px 16px;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 0 24px 24px 0;
  background: transparent;
  color: #475569;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  margin-bottom: 0;
}

.staff-nav-btn:hover {
  background: #f1f5f9;
  color: var(--text-primary);
}

.staff-nav-btn .nav-icon {
  width: 1.1em;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.75;
  font-size: 0.95rem;
}

.staff-nav-btn.on {
  background: var(--primary-light);
  border-left-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}

.staff-nav-btn.on .nav-icon {
  opacity: 1;
}

/* ── Page sub-tabs (content / settings) ── */
.staff-sub-nav {
  display: flex;
  gap: 4px;
  margin: 0 0 16px;
  padding: 0 4px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-page);
  position: sticky;
  top: 0;
  z-index: 5;
}

.staff-sub-tab {
  width: auto;
  margin: 0;
  padding: 10px 20px;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
}

.staff-sub-tab:hover {
  color: var(--primary-dark);
  background: transparent;
}

.staff-sub-tab.on {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
  font-weight: 600;
}

.staff-dash-todos {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.staff-todo-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 100px;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  color: var(--text-primary);
  font-weight: 400;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: auto;
  margin-bottom: 0;
}

.staff-todo-chip:hover {
  background: #fff;
  border-color: var(--primary-muted);
  box-shadow: var(--shadow-sm);
}

.staff-todo-chip strong {
  font-size: 1.35rem;
  color: var(--primary);
}

.staff-todo-chip span {
  font-size: 0.82rem;
  color: #718096;
}

.staff-todo-urgent {
  border-color: #fbbf24;
  background: #fffbeb;
}

.staff-todo-urgent strong {
  color: #b45309;
}

.staff-todo-muted {
  opacity: 0.72;
}

.staff-todo-muted:hover {
  opacity: 1;
}

.btn-primary-dash {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.btn-primary-dash:hover {
  background: var(--primary-dark);
}

.btn-sm-primary {
  background: var(--primary);
  color: #fff;
  border: none;
}

.btn-sm-primary:hover {
  background: var(--primary-dark);
}

.staff-nav-badge {
  position: absolute;
  top: 8px;
  right: 12px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.staff-nav-badge-msg {
  background: #ea580c;
}

.staff-nav-badge.hidden {
  display: none;
}

.btn-dash-messages {
  position: relative;
}

.dash-msg-badge {
  display: inline-block;
  margin-left: 6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ea580c;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  vertical-align: middle;
}

.dash-msg-badge.hidden {
  display: none;
}

.staff-todo-msg {
  border-color: #fdba74;
  background: #fff7ed;
}

.staff-todo-msg strong {
  color: #ea580c;
}

.elder-tab-badge {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #ea580c;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.elder-tab-badge.hidden {
  display: none;
}

.staff-sub-tab-muted {
  opacity: 0.65;
  font-weight: 400;
}

.staff-sub-tab-muted.on {
  opacity: 1;
}

.staff-dash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.staff-dash-actions button {
  width: auto;
  padding: 8px 18px;
  margin-bottom: 0;
}

.ops-dash-dual {
  margin-bottom: 12px;
}

.ops-dash-block {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
}

.ops-dash-label {
  margin: 0 0 8px;
  font-weight: 600;
  color: #2d3748;
}

.ops-dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.ops-listing-split {
  margin: 10px 0 0;
}

.ops-listing-filter.hidden {
  display: none;
}

.elder-detail-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 14px;
}

.elder-tab {
  position: relative;
  border: 1px solid #cbd5e0;
  background: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

.elder-tab.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.gallery-grid .gallery-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gallery-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.elder-detail-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.elder-detail-body.hidden {
  display: none;
}

.ops-tag.listing {
  background: #ebf8ff;
  color: var(--accent-blue);
}

.ops-tag.serve {
  background: #f0fff4;
  color: #276749;
}

.ops-tag.home {
  background: #faf5ff;
  color: #553c9a;
}

.elder-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.elder-row-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.elder-row-name {
  font-size: 1rem;
}

.elder-row-meta {
  font-size: 0.78rem;
  opacity: 0.75;
}

.elder-msg-btn {
  position: relative;
}

.elder-unread-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ea580c;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  box-sizing: border-box;
}

.elder-row-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.elder-detail-panel {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
}

.elder-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.elder-detail-head h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--primary-dark);
}

.elder-detail-body {
  margin-top: 8px;
}

.elder-suggested-plans {
  margin-bottom: 16px;
}

.elder-suggested-item .btn-sm {
  margin-top: 8px;
}

.elder-suggested-hint {
  margin: 0 0 12px;
}

.elder-invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.elder-invite-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.elder-invite-row select {
  flex: 1;
  min-width: 180px;
}

.elder-invite-pending {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: #f0faf6;
  border: 1px solid #b8dfd0;
  border-radius: 8px;
}

.elder-invite-pending-item {
  margin: 4px 0 0;
}

.elder-hp-invites {
  margin: 12px 0;
}

.elder-history-compare {
  color: #c05621;
}

.elder-record-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.elder-record-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.tag-checkin-mini {
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  background: #e65100;
  padding: 2px 10px;
  border-radius: 999px;
}

.elder-answer-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.elder-answer-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #edf2f7;
}

.elder-answer-list li:last-child {
  border-bottom: none;
}

.elder-answer-q {
  color: #4a5568;
  min-width: 120px;
}

.elder-answer-a {
  color: var(--primary);
  font-weight: 600;
}

.elder-card-kind {
  font-size: 0.8rem;
  color: #718096;
  background: #edf2f7;
  padding: 2px 10px;
  border-radius: 999px;
}

.elder-card-status {
  margin: 0;
}

.elder-health-edit {
  margin: 12px 0 16px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.elder-health-edit summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary-dark);
}

.elder-checkin-title {
  margin: 16px 0 8px;
  font-size: 0.95rem;
  color: var(--primary-dark);
}

.elder-health-portrait {
  margin-bottom: 8px;
}

.elder-detail-tabs .elder-tab {
  width: auto;
  margin-bottom: 0;
}

.hp-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.hp-chip {
  border: 1px solid #cbd5e0;
  background: #fff;
  color: #4a5568;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.88rem;
}

.hp-chip-row .hp-chip {
  width: auto;
  margin-bottom: 0;
}

.hp-chip:hover {
  background: var(--primary-light);
}

.hp-chip.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-body {
    flex-direction: column;
  }

  .app-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .staff-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 6px;
  }

  .staff-nav-btn {
    width: auto;
    margin: 0;
    padding: 8px 14px;
    border-left: none;
    border-radius: 999px;
    border: 1px solid var(--border);
  }

  .staff-nav-btn.on {
    border-color: var(--primary);
  }

  .app-main {
    padding: 16px;
  }

  .staff-sub-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .staff-sub-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 0.88rem;
  }

  .app-header h1 {
    font-size: 0.95rem;
  }

  .staff-header-org {
    max-width: min(180px, 38vw);
    padding-right: 10px;
  }

  .staff-header-org-name {
    font-size: 0.82rem;
  }
}

.content-edit-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
}

.content-edit-panel h3,
.pub-block-title {
  margin: 16px 0 10px;
  font-size: 1rem;
  color: #2d3748;
}

.content-readonly {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  line-height: 1.55;
}

.pending-weak {
  margin-top: 28px;
  padding: 12px 14px;
  border: 1px dashed #cbd5e0;
  border-radius: 10px;
  background: #fafafa;
}

.pending-weak summary {
  cursor: pointer;
  font-weight: 600;
  color: #718096;
  margin-bottom: 8px;
}
