/* ====== DOBS Premium Design System ====== */
:root {
  --primary: #4A3DB8;
  --primary-hover: #3D348B;
  --primary-light: #EEEDFA;
  --primary-glow: rgba(74, 61, 184, 0.12);
  --accent: #6C5CE7;
  --danger: #E74C3C;
  --danger-light: #FDF0EF;
  --success: #00B894;
  --success-light: #E8F8F5;
  --warning: #F39C12;
  --warning-light: #FEF9E7;
  --text: #1A1537;
  --text-secondary: #4A4562;
  --text-muted: #8E89A8;
  --bg: #F4F3F9;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #E5E1F0;
  --border-light: #F4F3F9;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.04);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ====== Reset ====== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ====== Login Screen ====== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #1A1537 0%, #2D2766 30%, #3D348B 60%, #5046C0 100%);
  position: relative;
  overflow: hidden;
}

#login-screen::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 50%, rgba(108, 92, 231, 0.15) 0%, transparent 50%),
              radial-gradient(circle at 70% 30%, rgba(74, 61, 184, 0.1) 0%, transparent 50%);
  animation: loginBg 20s ease-in-out infinite;
}

@keyframes loginBg {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-2%, 2%); }
}

.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 44px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.1);
  text-align: center;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(20px);
}

.login-card h1 {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text);
}

.login-card .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}

.login-logo {
  width: 200px;
  height: auto;
  margin: 0 auto 16px;
  display: block;
}

.btn-link {
  background: none; border: none; color: var(--primary);
  font-size: 13px; font-weight: 500; cursor: pointer;
  text-decoration: underline; padding: 0;
}
.btn-link:hover { color: var(--primary-hover); }

/* Biometric login */
.btn-biometric {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all var(--transition);
  margin-bottom: 0;
}
.btn-biometric:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74, 61, 184, 0.3);
}
.btn-biometric:active {
  transform: translateY(0);
}

.login-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  gap: 12px;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.login-divider span {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* Enable biometrics button — hidden on desktop, visible on mobile only */
.btn-enable-biometric {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(74, 61, 184, 0.15);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-enable-biometric:hover {
  background: var(--primary);
  color: white;
}

.header-logo {
  height: 70px;
  width: auto;
}

/* ====== Form Elements ====== */
.form-group {
  margin-bottom: 18px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all var(--transition);
  background: var(--surface);
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group textarea {
  resize: vertical;
  min-height: 72px;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 8px;
  font-weight: 500;
}

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  touch-action: manipulation;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  width: 100%;
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover, .btn-primary:active {
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.btn-secondary:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--primary);
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.btn-danger:hover { background: #fee2e2; }

.btn-small {
  padding: 5px 12px;
  font-size: 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition);
}

.btn-ghost {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

.btn-ghost:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.15);
}

/* ====== App Layout ====== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.92);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.staff-badge {
  background: linear-gradient(135deg, var(--primary-light), rgba(139, 92, 246, 0.1));
  color: var(--primary);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid rgba(99, 102, 241, 0.15);
}

.app-body {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ====== Resident Bar ====== */
.resident-bar {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
}

.resident-bar select {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  transition: all var(--transition);
}

.resident-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  outline: none;
}

/* ====== Body Map Section ====== */
.bodymap-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  align-items: start;
}

.bodymap-col { min-width: 0; overflow: hidden; }

.bodymap-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}

#bodymap-container { width: 100%; cursor: crosshair; user-select: none; -webkit-user-select: none; overflow: hidden; }
#bodymap-container svg { width: 100%; height: auto; display: block; }

.period-info { font-size: 12px; color: var(--text-muted); margin-top: 10px; text-align: center; }

/* ====== Observations Panel ====== */
.entries-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
  border: 1px solid var(--border);
}

.entries-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
}

#entry-list { flex: 1; overflow-y: auto; padding: 12px; }

.entry-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  transition: all var(--transition);
  cursor: pointer;
  background: var(--surface);
}

.entry-card:hover {
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: var(--shadow-md);
}

.entry-card.entry-highlight {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.entry-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

.entry-number {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; color: white;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}

.entry-type { font-weight: 600; font-size: 14px; color: var(--text); }

.entry-view {
  margin-left: auto; font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600;
  background: var(--bg); padding: 3px 8px; border-radius: 4px;
}

.entry-description { font-size: 13px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 8px; }
.entry-action { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; line-height: 1.4; }
.entry-followup { font-size: 11px; color: var(--primary); font-weight: 600; margin-bottom: 6px; padding: 3px 8px; background: var(--primary-light); border-radius: 4px; display: inline-block; }
.entry-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); padding-top: 8px; border-top: 1px solid var(--border-light); }

.empty-state { text-align: center; color: var(--text-muted); padding: 48px 20px; font-size: 14px; }

/* ====== Modals ====== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
}

.modal-content h3 {
  font-size: 18px; font-weight: 700; margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text);
}

.modal-close {
  background: var(--bg); border: none; font-size: 20px; cursor: pointer;
  color: var(--text-muted); padding: 4px 8px; border-radius: 6px;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }

/* ====== Archive ====== */
.archive-bar {
  background: var(--warning-light); border: 1px solid #fde68a;
  border-radius: var(--radius); padding: 12px 18px; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.archive-bar span { font-size: 13px; color: #92400e; font-weight: 500; }

.archive-list-section { margin-top: 14px; }
.archive-list-section h4 { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }

.archive-btn {
  display: block; width: 100%; text-align: left; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 6px; cursor: pointer; font-size: 13px; color: var(--text);
  transition: all var(--transition); font-weight: 500;
}
.archive-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* ====== Admin ====== */
.admin-container { max-width: 680px; margin: 0 auto; padding: 24px; }

.admin-container h2 {
  font-size: 24px; font-weight: 800; margin-bottom: 24px;
  color: var(--text); letter-spacing: -0.02em;
}

.admin-section {
  background: var(--surface); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); margin-bottom: 20px; border: 1px solid var(--border);
}

.admin-section h3 {
  font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.03em;
}

.admin-card {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: var(--bg); border-radius: var(--radius-sm); margin-bottom: 6px;
  border: 1px solid transparent; transition: all var(--transition);
}
.admin-card:hover { border-color: var(--border); }
.admin-card strong { flex: 1; font-size: 14px; }

.badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 3px 8px;
  border-radius: 4px; background: var(--primary-light); color: var(--primary);
  letter-spacing: 0.5px;
}

.admin-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.admin-form input,
.admin-form select {
  flex: 1; min-width: 100px; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; transition: all var(--transition);
}
.admin-form input:focus, .admin-form select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); outline: none;
}
.admin-form .btn { flex-shrink: 0; }

/* ====== Toasts ====== */
#toast-container { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }

.toast {
  padding: 12px 20px; border-radius: var(--radius-sm); color: white;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg);
  transform: translateX(120%); transition: transform 0.3s ease; max-width: 340px;
  backdrop-filter: blur(8px);
}
.toast-show { transform: translateX(0); }
.toast-success { background: var(--success); }
.toast-warning { background: var(--warning); color: #000; }
.toast-info { background: var(--primary); }
.toast-error { background: var(--danger); }

/* ====== Dashboard ====== */
/* ====== Dashboard Header ====== */
.dash-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.dash-greeting {
  font-size: 26px; font-weight: 800; color: var(--text);
  letter-spacing: -0.03em; margin-bottom: 4px;
}
.dash-subtitle { font-size: 14px; color: var(--text-muted); font-weight: 400; }
.dash-date {
  font-size: 13px; color: var(--text-muted); font-weight: 500;
  background: var(--surface); padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); white-space: nowrap;
}
.dash-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.dash-section-header h3 {
  font-size: 15px; color: var(--text-secondary); text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 700;
}
.dash-section-count {
  font-size: 12px; color: var(--text-muted); font-weight: 500;
  background: var(--bg); padding: 3px 10px; border-radius: 20px;
}

/* ====== Stat Cards ====== */
.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 8px; }

.stat-card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 22px 24px;
  box-shadow: var(--shadow); min-width: 0;
  border: 1px solid var(--border); transition: all var(--transition);
  display: flex; align-items: center; gap: 16px;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-purple .stat-icon { background: #EEEDFA; color: #4A3DB8; }
.stat-blue .stat-icon { background: #E8F0FE; color: #3B82F6; }
.stat-green .stat-icon { background: #E8F8F5; color: #00B894; }
.stat-amber .stat-icon { background: #FEF9E7; color: #F39C12; }

.stat-number { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; font-weight: 600; }

/* ====== Resident Cards ====== */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.resident-card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 20px 22px;
  box-shadow: var(--shadow); cursor: pointer; transition: all var(--transition);
  border: 1.5px solid var(--border); position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 12px;
}
.resident-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0; transition: opacity var(--transition);
}
.resident-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.resident-card:hover::before { opacity: 1; }

.resident-card-top { display: flex; align-items: center; gap: 14px; }
.resident-avatar {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; font-weight: 700; font-size: 18px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.resident-info { flex: 1; min-width: 0; }
.resident-card-name { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.resident-card-room { font-size: 12px; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: 0.5px; }
.resident-card-carers {
  font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 5px;
}
.resident-card-carers--warn { color: var(--warning); }
.resident-card-actions { display: flex; gap: 8px; margin-top: auto; }

.btn-primary-soft {
  background: var(--primary-light); color: var(--primary); border: none;
  padding: 7px 14px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 5px;
}
.btn-primary-soft:hover { background: var(--primary); color: white; }

.btn-ghost-outlined {
  background: none; color: var(--text-secondary); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 5px;
}
.btn-ghost-outlined:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.followup-card {
  background: var(--danger-light); border: 1px solid #fecaca; border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 8px; cursor: pointer;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  transition: all var(--transition);
}
.followup-card:hover { background: #fee2e2; transform: translateY(-1px); box-shadow: var(--shadow); }
.followup-date { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--danger); }

/* ====== Carer Badges ====== */
.carer-badges { padding: 0 0 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.carer-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.carer-chip {
  display: inline-flex; align-items: center;
  background: linear-gradient(135deg, var(--primary-light), rgba(108, 92, 231, 0.08));
  color: var(--primary); padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600; border: 1px solid rgba(74, 61, 184, 0.15);
}

/* ====== Watermark ====== */
.watermark-container {
  position: relative;
  overflow: hidden;
}

.watermark-logo {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 280px;
  height: auto;
  opacity: 0.07;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 1;
}

/* Dashboard watermark - large, bottom right */
.dashboard-watermark {
  position: fixed;
  bottom: -80px;
  right: -100px;
  width: 900px;
  height: auto;
  opacity: 0.04;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 0;
}

/* Footer watermark */
.app-footer-watermark {
  text-align: center;
  padding: 16px 0 8px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.app-footer-watermark img {
  height: 16px;
  width: auto;
  opacity: 0.4;
}

/* ====== Activity Log ====== */
.log-filters {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px;
  background: var(--surface); padding: 16px 18px; border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.log-filters select, .log-filters input {
  flex: 1; min-width: 120px; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; background: var(--surface); transition: all var(--transition);
}
.log-filters select:focus, .log-filters input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); outline: none;
}

.log-entry {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--surface); border-radius: var(--radius-sm); margin-bottom: 4px;
  flex-wrap: wrap; border: 1px solid var(--border-light);
  transition: all var(--transition);
}
.log-entry:hover { border-color: var(--border); box-shadow: var(--shadow-xs); }

.log-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; min-width: 130px; font-variant-numeric: tabular-nums; }

.log-badge {
  font-size: 10px; font-weight: 700; color: white; padding: 3px 8px;
  border-radius: 4px; text-transform: uppercase; white-space: nowrap; letter-spacing: 0.5px;
}

.log-staff { font-size: 13px; font-weight: 600; color: var(--text); min-width: 80px; }
.log-details { font-size: 12px; color: var(--text-muted); flex: 1; }

/* ====== Voice Input ====== */
.voice-input-wrap { position: relative; }
.voice-input-wrap textarea { padding-right: 48px; }
.voice-btn {
  position: absolute; top: 8px; right: 8px;
  width: 36px; height: 36px;
  border-radius: 50%; border: 2px solid var(--border);
  background: var(--surface); cursor: pointer;
  font-size: 18px; line-height: 32px; text-align: center;
  transition: all 0.2s; z-index: 2;
  display: flex; align-items: center; justify-content: center;
}
.voice-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.voice-btn-active {
  background: var(--danger) !important; border-color: var(--danger) !important;
  color: white; animation: voice-pulse 1s infinite;
}
.voice-listening { border-color: var(--danger) !important; background: #fef2f2 !important; }
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ====== Measurements ====== */
.measurement-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.measurement-row input { text-align: center; }
.entry-measurement { font-size: 13px; color: var(--primary); font-weight: 600; margin-bottom: 4px; }

/* ====== Photo & Timeline ====== */
.photo-preview-container { margin-top: 8px; position: relative; display: inline-block; }
.photo-preview-img { max-width: 200px; max-height: 150px; border-radius: 8px; border: 1px solid var(--border); }
.photo-remove-btn { position: absolute; top: -6px; right: -6px; background: var(--danger); color: white; border: none; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; font-size: 14px; line-height: 22px; }
.entry-thumbnail { width: 100%; max-width: 200px; border-radius: 6px; margin-top: 8px; cursor: pointer; border: 1px solid var(--border); }

.timeline-grid { display: flex; flex-wrap: wrap; gap: 16px; overflow-x: auto; padding: 8px 0; }
.timeline-card { min-width: 200px; max-width: 250px; background: var(--bg); border-radius: 8px; padding: 12px; border: 1px solid var(--border); }
.timeline-photo { width: 100%; border-radius: 6px; cursor: pointer; margin-bottom: 8px; }
.timeline-no-photo { width: 100%; height: 80px; background: var(--border); border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }
.timeline-date { font-size: 12px; color: var(--text-muted); display: block; }
.timeline-type { font-size: 13px; font-weight: 600; display: block; margin: 2px 0; }
.timeline-desc { font-size: 12px; line-height: 1.4; margin: 4px 0; }
.timeline-staff { font-size: 11px; color: var(--text-muted); }

/* ====== Safeguarding Alerts ====== */
.alert-badge { position: absolute; top: -4px; right: -4px; background: var(--danger); color: white; border-radius: 50%; min-width: 18px; height: 18px; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.alert-card { background: var(--surface); border: 1px solid #fecaca; border-left: 4px solid var(--danger); border-radius: 8px; padding: 14px; margin-bottom: 8px; cursor: pointer; transition: all 0.2s; }
.alert-card:hover { box-shadow: var(--shadow-md); }
.alert-severity { padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; color: white; }
.alert-severity-medium { background: #f59e0b; }
.alert-severity-high { background: #ef4444; }
.alert-severity-critical { background: #dc2626; }

/* ====== Help System ====== */
.help-modal { max-width: 700px; max-height: 85vh; display: flex; flex-direction: column; }
.help-search {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 4px;
  transition: all var(--transition); background: var(--bg);
}
.help-search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.help-tabs {
  display: flex; gap: 4px; overflow-x: auto; padding: 8px 0;
  border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-shrink: 0;
}
.help-tab {
  padding: 6px 12px; border-radius: 6px; border: none; background: none;
  cursor: pointer; font-size: 12px; white-space: nowrap;
  color: var(--text-secondary); font-weight: 500; transition: all var(--transition);
}
.help-tab:hover { background: var(--bg); color: var(--text); }
.help-tab.active { background: var(--primary); color: white; }
.help-tab-match { background: var(--primary-light); color: var(--primary); }
.help-content { overflow-y: auto; flex: 1; padding-right: 4px; }
.help-content h4 {
  font-size: 14px; font-weight: 700; margin: 18px 0 10px; color: var(--text);
  padding-bottom: 6px; border-bottom: 1px solid var(--border-light);
}
.help-content h4:first-child { margin-top: 0; }
.help-content ol, .help-content ul {
  margin: 0 0 12px 20px; font-size: 13px; line-height: 1.7; color: var(--text-secondary);
}
.help-content ol li, .help-content ul li { margin-bottom: 4px; }
.help-content p { font-size: 13px; line-height: 1.6; color: var(--text-secondary); margin-bottom: 10px; }
.faq-item {
  padding: 14px 0; border-bottom: 1px solid var(--border-light);
}
.faq-item:last-child { border-bottom: none; }
.faq-item strong {
  display: block; font-size: 14px; color: var(--text); margin-bottom: 6px;
}
.faq-item p { margin-bottom: 0; }

/* ====== Hamburger Menu ====== */
.hamburger-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 8px; border-radius: var(--radius-sm); color: var(--text);
  transition: all var(--transition);
}
.hamburger-btn:hover { background: var(--bg); }

/* Mobile menu — hidden by default on all screens */
.mobile-menu {
  display: none; position: fixed; top: 0; right: 0; bottom: 0;
  width: 280px; background: var(--surface); z-index: 1001;
  flex-direction: column; box-shadow: -4px 0 24px rgba(0,0,0,0.15);
}
.mobile-menu.menu-open { display: flex; }
.mobile-menu-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 1000;
}
.mobile-menu-overlay.menu-open { display: block; }

.mobile-menu-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}

.mobile-menu-nav {
  flex: 1; overflow-y: auto; padding: 8px 0;
}
.mobile-menu-nav button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 20px; border: none; background: none;
  font-size: 15px; font-weight: 500; color: var(--text);
  cursor: pointer; transition: all var(--transition); text-align: left;
}
.mobile-menu-nav button:hover { background: var(--primary-light); color: var(--primary); }
.mobile-menu-nav button svg { flex-shrink: 0; color: var(--text-muted); }
.mobile-menu-nav button:hover svg { color: var(--primary); }

.mobile-menu-footer {
  padding: 16px 20px; border-top: 1px solid var(--border);
}

.admin-card-actions { display: flex; gap: 6px; margin-left: auto; }

.care-home-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.care-home-card-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}

/* ====== Care Home Switcher ====== */
.home-switcher {
  display: flex; align-items: center; gap: 6px;
  background: var(--primary-light); color: var(--primary);
  border: 1px solid rgba(74, 61, 184, 0.15);
  padding: 6px 14px; border-radius: 20px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
}
.home-switcher:hover { background: var(--primary); color: white; }
.home-switcher svg { flex-shrink: 0; }

/* Home picker modal */
.home-picker-list { display: flex; flex-direction: column; gap: 8px; }
.home-picker-option {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border: 1.5px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
  cursor: pointer; transition: all var(--transition); text-align: left;
  font-size: 15px; font-weight: 500; color: var(--text);
}
.home-picker-option:hover { border-color: var(--primary); background: var(--primary-light); }
.home-picker-option svg { color: var(--primary); flex-shrink: 0; }
.home-picker-role {
  margin-left: auto; font-size: 11px; font-weight: 600;
  text-transform: uppercase; color: var(--text-muted);
  background: var(--bg); padding: 2px 8px; border-radius: 4px;
}

/* ====== Responsive ====== */
@media (max-width: 768px) {
  .bodymap-layout { grid-template-columns: 1fr; }
  .entries-panel { max-height: 400px; }
  .app-header { padding: 10px 14px; }
  .header-logo { height: 48px !important; }
  .header-desktop { display: none !important; }
  .home-switcher { display: none !important; }
  .hamburger-btn { display: flex !important; align-items: center; justify-content: center; }
  /* mobile menu handled by base styles above */
  .dashboard-watermark { display: none !important; }
  .app-body { padding: 10px; }
  .resident-bar { flex-direction: column; align-items: stretch; }
  .admin-form { flex-direction: column; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-stats { grid-template-columns: 1fr; gap: 8px; }
  .stat-card { padding: 12px 14px; gap: 12px; }
  .stat-number { font-size: 20px; }
  .stat-label { font-size: 10px; letter-spacing: 0.3px; }
  .stat-icon { width: 36px; height: 36px; border-radius: 10px; }
  .stat-icon svg { width: 18px; height: 18px; }
  .log-entry { flex-direction: column; align-items: flex-start; gap: 4px; }
  .log-filters { flex-direction: column; }
  .followup-card { flex-direction: column; align-items: flex-start; }
  .modal-content { max-height: 90vh; margin: 10px; }
  .admin-container { padding: 10px; }
  .admin-section { padding: 12px; }
  .resident-cards { grid-template-columns: 1fr !important; }
  .resident-card { padding: 14px 16px; }
  .dash-greeting { font-size: 18px; }
  .dash-subtitle { font-size: 12px; }
  .dash-header { flex-direction: column; gap: 6px; }
  .dash-date { align-self: flex-start; font-size: 11px; padding: 5px 10px; }
  .dash-section-header { margin-top: 16px !important; }
  .btn-primary-soft, .btn-ghost-outlined { padding: 6px 10px; font-size: 11px; }
  .resident-card-name { font-size: 16px; }
  .app-footer-watermark { display: none; }
  .dash-date { align-self: flex-start; font-size: 12px; }
}

@media (min-width: 769px) {
  .modal-overlay { align-items: center; }
  .modal-content { border-radius: var(--radius-lg); }
}

/* ====== Resident View Tabs ====== */
.resident-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  border-bottom: 2px solid var(--border); padding-bottom: 0;
}
.resident-tab {
  padding: 10px 20px; border: none; background: none;
  font-size: 14px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all var(--transition);
  display: flex; align-items: center; gap: 6px;
}
.resident-tab:hover { color: var(--text); }
.resident-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.obs-level-badge {
  font-size: 10px; padding: 2px 6px; border-radius: 4px;
  background: var(--warning-light); color: #92400e; font-weight: 700;
  text-transform: uppercase;
}

/* ====== Psychiatric Observations ====== */
.obs-layout {
  display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start;
}
.obs-main { min-width: 0; }
.obs-sidebar {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; max-height: calc(100vh - 280px); overflow-y: auto;
}

.obs-header-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 14px;
}
.obs-level-display { display: flex; align-items: center; gap: 8px; }
.obs-level-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.obs-level-value {
  font-size: 14px; font-weight: 700; color: var(--primary);
  background: var(--primary-light); padding: 4px 12px; border-radius: 6px;
}

.obs-summary-cards {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 16px;
}
.obs-summary-card {
  background: var(--surface); border-radius: var(--radius-sm); padding: 10px 12px;
  border: 1px solid var(--border); text-align: center;
}
.obs-summary-card .obs-stat { font-size: 20px; font-weight: 800; color: var(--text); }
.obs-summary-card .obs-stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; margin-top: 2px; }

.obs-charts-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px;
}
.obs-chart-panel {
  background: var(--surface); border-radius: var(--radius-sm); padding: 12px;
  border: 1px solid var(--border);
}
.obs-chart-panel h4 { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.obs-chart-panel canvas { width: 100% !important; height: 150px !important; }

.obs-empty-state {
  text-align: center; padding: 30px 20px; color: var(--text-muted); font-size: 13px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}

/* Quick obs form */
.obs-tap-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px;
}
.obs-tap-group h5 { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.obs-tap-options { display: flex; flex-wrap: wrap; gap: 6px; }
.obs-tap-btn {
  padding: 8px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all var(--transition); color: var(--text);
}
.obs-tap-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.obs-tap-btn.selected { background: var(--primary); color: white; border-color: var(--primary); }

.mood-selector { display: flex; gap: 8px; justify-content: center; margin: 12px 0; }
.mood-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.mood-btn:hover { transform: scale(1.1); }
.mood-btn.selected { border-color: var(--primary); background: var(--primary-light); transform: scale(1.15); box-shadow: 0 0 0 3px var(--primary-glow); }

.obs-check-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 8px; background: var(--surface);
}
.obs-check-card.incident { border-left: 3px solid var(--danger); }
.obs-check-mood { font-size: 20px; flex-shrink: 0; }
.obs-check-details { flex: 1; min-width: 0; }
.obs-check-details .obs-loc-act { font-weight: 600; font-size: 13px; }
.obs-check-details .obs-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.obs-check-details .obs-notes { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.obs-risk-flag { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 3px; background: #fef2f2; color: var(--danger); font-weight: 600; margin-right: 4px; }

.obs-escalation-card {
  background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.obs-escalation-card .esc-info { flex: 1; }
.obs-escalation-card .esc-rule { font-weight: 700; color: var(--danger); font-size: 13px; }
.obs-escalation-card .esc-reason { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.obs-escalation-card .esc-actions { display: flex; gap: 6px; }

@media (max-width: 768px) {
  .obs-layout { grid-template-columns: 1fr; }
  .obs-sidebar { max-height: 400px; }
  .obs-charts-grid { grid-template-columns: 1fr; }
  .obs-tap-grid { grid-template-columns: 1fr; }
  .obs-summary-cards { grid-template-columns: 1fr 1fr; }
  .resident-tabs { overflow-x: auto; }
}

/* ====== Scrollbar ====== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

::selection { background: var(--primary-light); color: var(--primary); }
