:root {
  --navy: #13233d;
  --navy-2: #1f3a5f;
  --gold: #b8923f;
  --gold-hover: #a17f36;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e2e5ea;
  --text: #1b2430;
  --text-2: #5b6472;
  --open: #2f5fa8;
  --filled: #2e7d5b;
  --completed: #5b6472;
  --warn: #b3432f;
  --radius: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 700; }
p { margin: 0 0 8px; }
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 13px 18px; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: opacity .12s;
}
.btn:active { opacity: .8; }
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--gold); color: #fff; }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--border); }
.btn-danger { background: #fff; color: var(--warn); border-color: var(--warn); }
.btn-logout { background: #fff; color: var(--text-2); border-color: var(--border); margin-top: 22px; }
.btn-logout:active { color: var(--warn); border-color: var(--warn); }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 14px; font-size: 13px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-2); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; color: var(--text); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--navy-2); }
.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1; min-width: 0; margin-bottom: 12px; }
.field-hint { font-size: 11.5px; color: var(--text-2); margin: 0 0 12px; line-height: 1.4; }
.field-hint-strong { color: var(--text); font-weight: 600; font-size: 12px; }
.field-notice {
  font-size: 11.5px; color: var(--text-2); background: var(--bg); border-radius: 8px;
  padding: 9px 11px; margin-bottom: 12px; line-height: 1.4;
}
.field-divider { height: 1px; background: var(--border); margin: 14px 0; }
.checkbox-line {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 500;
  color: var(--text); margin-bottom: 12px; cursor: pointer;
}
.checkbox-line input { width: 16px; height: 16px; margin: 0; accent-color: var(--navy); flex-shrink: 0; }
.error-msg { background: #fdeceb; color: var(--warn); border: 1px solid #f5c8c1; border-radius: var(--radius); padding: 12px 14px; font-size: 13px; margin-bottom: 16px; }

/* ---------- Login screen ---------- */
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--navy), var(--navy-2)); padding: 24px; }
.auth-box { background: #fff; border-radius: 16px; padding: 32px 26px; width: 100%; max-width: 380px; }
.brand { text-align: center; margin-bottom: 26px; }
.brand .brand-mark { width: 68px; height: 68px; margin: 0 auto 14px; display: block; object-fit: contain; }
.brand h1 { font-size: 20px; color: var(--navy); }
.brand p { color: var(--text-2); font-size: 13px; }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: 64px; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff;
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
  padding-top: max(14px, env(safe-area-inset-top));
}
.topbar h2 { font-size: 17px; color: #fff; }
.main-content { flex: 1; padding: 16px; }

.topbar-actions { display: flex; align-items: center; gap: 6px; }
.avatar-btn {
  width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.15); border: none;
  color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 0;
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

.bell-wrap { position: relative; }
.bell-btn { background: none; border: none; cursor: pointer; padding: 6px; color: #fff; position: relative; }
.bell-dot { position: absolute; top: 3px; right: 3px; width: 9px; height: 9px; border-radius: 50%; background: #e2574c; border: 2px solid var(--navy); }

/* ---------- Offline sync ---------- */
.sync-wrap { position: relative; }
.sync-btn { background: none; border: none; cursor: pointer; padding: 6px; color: #fff; position: relative; display: flex; align-items: center; }
.sync-btn.spinning svg { animation: sync-spin 1s linear infinite; }
@keyframes sync-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.sync-dot {
  position: absolute; top: 0; right: -2px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 20px;
  background: var(--gold); color: var(--navy); border: 2px solid var(--navy); font-size: 9.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.offline-banner {
  background: #3a2a12; color: #f5d9a8; font-size: 12px; font-weight: 600; text-align: center;
  padding: 8px 14px; line-height: 1.4;
}
.offline-cache-notice {
  background: var(--bg); color: var(--text-2); font-size: 11.5px; font-weight: 600; border-radius: var(--radius);
  padding: 9px 12px; margin-bottom: 10px;
}
.pill-pending { background: #fdf1de; color: #8a6215; }

.notif-panel {
  position: fixed; top: 58px; right: 10px; left: 10px; max-height: 70vh; overflow-y: auto;
  background: #fff; border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 50;
}
.notif-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.notif-panel-head h4 { font-size: 14.5px; }
.notif-item { padding: 13px 16px; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: #f8f9fc; }
.notif-item .title { font-weight: 700; font-size: 13.5px; margin-bottom: 2px; }
.notif-item .body { font-size: 12.5px; color: var(--text-2); }
.notif-item .time { font-size: 11px; color: #9aa3b0; margin-top: 5px; }
.notif-empty { padding: 34px 16px; text-align: center; color: var(--text-2); font-size: 13px; }
.btn-link { background: none; border: none; color: var(--open); cursor: pointer; padding: 0; font-weight: 700; font-size: 12.5px; }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--border); display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 9px 0 8px; color: var(--text-2); cursor: pointer; font-size: 10.5px; font-weight: 700;
}
.tabbar-item.active { color: var(--navy); }
.tabbar-item svg { width: 22px; height: 22px; }
.tabbar-item.active svg { stroke: var(--gold); }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.section-title { font-size: 12.5px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; margin: 16px 0 8px; }
.section-title:first-child { margin-top: 0; }

/* ---------- iOS "Add to Home Screen" install banner + walkthrough ---------- */
.install-banner {
  position: relative; display: flex; gap: 12px; align-items: flex-start;
  background: #fbf1e2; border: 1px solid #e8cf9f; border-radius: var(--radius); padding: 14px 34px 14px 14px; margin-bottom: 16px;
}
.install-banner-icon { font-size: 22px; line-height: 1; flex-shrink: 0; }
.install-banner-body strong { display: block; font-size: 13.5px; color: var(--navy); margin-bottom: 3px; }
.install-banner-body p { font-size: 12.5px; color: var(--text-2); margin: 0 0 8px; line-height: 1.4; }
.install-banner-close {
  position: absolute; top: 10px; right: 10px; background: none; border: none; font-size: 18px;
  line-height: 1; color: var(--text-2); cursor: pointer; padding: 4px;
}
.install-step { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.install-step:last-of-type { border-bottom: none; }
.install-step-num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--navy); color: #fff;
  font-size: 12.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.install-step-body { flex: 1; min-width: 0; }
.install-step-title { font-size: 13.5px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.install-step-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.4; }
.install-step-icon { color: var(--navy); flex-shrink: 0; }

.greeting-card { background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.greeting-card h3 { font-size: 19px; color: #fff; }
.greeting-card p { color: rgba(255,255,255,.75); font-size: 13px; margin-bottom: 0; }
.greeting-stat { display: flex; gap: 20px; margin-top: 14px; }
.greeting-stat .num { font-size: 24px; font-weight: 800; }
.greeting-stat .lbl { font-size: 11px; color: rgba(255,255,255,.7); }

.job-item { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.job-item h4 { font-size: 14.5px; }
.job-item .meta { font-size: 12.5px; color: var(--text-2); margin: 3px 0 8px; }
.job-item .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.job-item .pills { display: flex; gap: 4px; flex-wrap: wrap; }
.job-item .apply-options { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; background: var(--bg); color: var(--text-2); }
.pill-applied { background: #eef3fa; color: var(--open); }
.cancel-link { display: block; margin-top: 10px; font-size: 12px; color: var(--warn); }
.cancel-pending {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-2); line-height: 1.4;
}
.empty-state { text-align: center; padding: 40px 16px; color: var(--text-2); font-size: 13.5px; }

/* ---------- Availability calendar ---------- */
.cal-controls { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-controls button { background: none; border: none; font-size: 20px; color: var(--navy); padding: 6px 12px; cursor: pointer; }
.cal-controls h4 { font-size: 15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-dow { font-size: 10.5px; color: var(--text-2); font-weight: 700; padding-bottom: 4px; }
.cal-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 8px;
  font-size: 13px; cursor: pointer; background: #fff; border: 1px solid var(--border); position: relative;
}
.cal-day.empty { border: none; cursor: default; }
.cal-day.past { color: #c3c9d1; cursor: default; }
.cal-day.marked-day { background: #eef6f1; border-color: var(--filled); color: var(--filled); font-weight: 700; }
.cal-day.marked-night { background: #eef0fa; border-color: #4a52b3; color: #4a52b3; font-weight: 700; }
.cal-day.marked-full { background: #fbf1e2; border-color: var(--gold); color: var(--gold-hover); font-weight: 700; }
.cal-day.locked { cursor: default; opacity: 0.7; }
.cal-day.locked::after {
  content: '\1F512'; position: absolute; bottom: 1px; right: 2px; font-size: 7px; line-height: 1;
}
.avail-legend { display: flex; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.avail-legend span { font-size: 11.5px; color: var(--text-2); display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.type-picker { display: flex; gap: 8px; margin-top: 14px; }
.type-picker .btn { flex: 1; padding: 10px; font-size: 12.5px; }

/* ---------- Timesheet ---------- */
/* ---------- Timesheet: List Duty (grouped by care home + week) ---------- */
/* ---------- Timesheet: List Duty (grouped by care home + week) ---------- */
.ts-filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ts-filter-bar select {
  flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; color: var(--text); font-size: 13px;
}
.ts-filter-clear { font-size: 12px; color: var(--warn); white-space: nowrap; cursor: pointer; }
.ts-pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }
.ts-pagination span { font-size: 12.5px; color: var(--text-2); }

.duty-group-list { display: flex; flex-direction: column; gap: 10px; }
.duty-group-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.duty-group-top { display: flex; align-items: flex-start; justify-content: space-between; }
.duty-group-home { font-size: 14px; font-weight: 700; color: var(--text); }
.duty-group-range { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.duty-group-hours { font-size: 18px; font-weight: 800; color: var(--navy); }
.duty-group-hours span { font-size: 12px; font-weight: 600; color: var(--text-2); margin-left: 1px; }
.duty-group-actions { display: flex; gap: 16px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.duty-group-actions .btn-link { font-size: 12.5px; padding: 0; }

.duty-day-card { background: var(--bg); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.duty-day-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.duty-day-hours { color: var(--navy); }
.duty-day-row { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--text-2); padding: 3px 0; }
.duty-day-row span:last-child { color: var(--text); font-weight: 500; }
.duty-day-sig { height: 30px; margin-top: 6px; }
.duty-day-total { text-align: right; font-size: 13px; color: var(--text-2); margin: 12px 4px; }


/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(19,35,61,.55); display: flex; align-items: flex-end; z-index: 100; }
.modal-box { background: #fff; border-radius: 18px 18px 0 0; width: 100%; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { font-size: 17px; }
.modal-head .sub { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-2); cursor: pointer; padding: 4px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 78px; left: 16px; right: 16px; background: var(--navy); color: #fff; padding: 13px 16px; border-radius: var(--radius); font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 200; text-align: center; }

/* ---------- My Profile screen ---------- */
.profile-header-card {
  display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.profile-photo-circle {
  width: 56px; height: 56px; border-radius: 50%; background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; color: var(--text-2); cursor: pointer;
}
.profile-photo-circle img { width: 100%; height: 100%; object-fit: cover; }
.profile-header-card h3 { font-size: 16px; }
.profile-mobile { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

.profile-subtabs {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px;
  -ms-overflow-style: none; scrollbar-width: none;
}
.profile-subtabs::-webkit-scrollbar { display: none; }
.profile-subtab {
  flex-shrink: 0; padding: 8px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 700;
  color: var(--text-2); background: #fff; border: 1px solid var(--border); cursor: pointer; white-space: nowrap;
}
.profile-subtab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.profile-panel .field { margin-bottom: 14px; }

/* Shared search input style - Available Jobs, My Shifts, Blocked Homes */
.pwa-search-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13.5px; background: #fff; color: var(--text); margin-bottom: 12px;
}
.pwa-search-input:focus { border-color: var(--navy-2); outline: none; }
.pwa-load-more-btn { margin-top: 10px; }

.home-block-list { display: flex; flex-direction: column; gap: 8px; }
.home-block-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
.home-block-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.yn-radio { display: flex; gap: 20px; padding-top: 6px; }
.yn-radio label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--text); cursor: pointer; }
.yn-radio input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--navy); cursor: pointer; }

.profile-training-row {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px;
}
.profile-training-label { font-size: 12.5px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.profile-training-controls { display: flex; align-items: center; gap: 12px; }
.profile-training-row .yn-radio { padding-top: 0; gap: 12px; flex-shrink: 0; }
.profile-training-row input[type="date"] {
  flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12.5px;
}
.profile-training-row input[type="date"]:disabled { background: var(--bg); color: #b0b6c0; }

.profile-photo-preview {
  width: 170px; height: 160px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
  display: flex; align-items: center; justify-content: center; overflow: hidden; margin-top: 12px;
}
.profile-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.profile-photo-preview #pfPhotoPreviewEmpty { font-size: 12px; color: var(--text-2); }

/* ---------- Supervisor sign-off signature pad ---------- */
.sig-pad-wrap { position: relative; width: 100%; }
#cjSigPad {
  width: 100%; height: 90px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
  cursor: crosshair; display: block; touch-action: none;
}
.sig-clear-link { position: absolute; bottom: 6px; right: 10px; font-size: 11px; color: var(--text-2); text-decoration: underline; }
.sig-clear-link:hover { color: var(--navy); }
