:root {
  --background: #edf2f6;
  --surface: #ffffff;
  --ink: #152333;
  --muted: #697b89;
  --border: #dce4e9;
  --primary: #159bd7;
  --primary-dark: #087bab;
  --danger: #d94343;
  --shadow: 0 12px 28px rgba(27, 48, 66, 0.12);
  --font: "Avenir Next", Avenir, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); scroll-behavior: smooth; }
body { min-height: 100%; margin: 0; color: var(--ink); background: var(--background); font-family: var(--font); font-size: 16px; }
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.is-hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.1rem max(1.25rem, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 8%, rgba(21, 155, 215, 0.2), transparent 23rem),
    radial-gradient(circle at 88% 90%, rgba(123, 200, 66, 0.16), transparent 22rem),
    #edf2f6;
}
.login-card {
  width: min(100%, 430px);
  padding: 2rem 1.5rem 1.4rem;
  border: 1px solid rgba(218, 227, 233, 0.9);
  border-radius: 1.8rem;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 22px 55px rgba(27, 48, 66, 0.14);
}
.login-brand { width: 4.8rem; height: 4.8rem; margin-bottom: 1rem; }
.login-brand img { width: 100%; height: 100%; }
.eyebrow { margin: 0 0 0.2rem; color: #6d7e8b; font-size: 0.76rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; }
.login-card h1 { margin: 0; font-size: 2rem; letter-spacing: -0.045em; }
.login-intro { margin: 0.45rem 0 1.35rem; color: var(--muted); line-height: 1.5; }
.login-form { display: grid; gap: 0.55rem; }
.login-form label, .app-dialog label { margin-top: 0.45rem; font-weight: 750; }
.login-form input, .app-dialog input, .app-dialog textarea, .app-dialog select {
  width: 100%;
  border: 1px solid #cad5dc;
  border-radius: 0.9rem;
  background: #fff;
  color: var(--ink);
  padding: 0.85rem 0.9rem;
  outline: 0;
}
.login-form input:focus, .app-dialog input:focus, .app-dialog textarea:focus, .app-dialog select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21, 155, 215, 0.15); }
.login-form .primary-button { margin-top: 0.75rem; }
.primary-button, .secondary-button, .danger-button {
  min-height: 3.25rem;
  border: 0;
  border-radius: 1rem;
  padding: 0.75rem 1rem;
  font-weight: 800;
  cursor: pointer;
}
.primary-button { color: #fff; background: var(--primary); box-shadow: 0 8px 18px rgba(21, 155, 215, 0.24); }
.primary-button:active { background: var(--primary-dark); }
.secondary-button { color: #344856; background: #eef3f6; }
.danger-button { color: #fff; background: var(--danger); }
.demo-notice { margin: 1.2rem 0 0; color: #8796a1; text-align: center; font-size: 0.8rem; }
.alert { margin: 1rem 0; border-radius: 0.9rem; padding: 0.8rem 0.9rem; line-height: 1.4; }
.alert-error { color: #862929; background: #ffeded; border: 1px solid #f5caca; }

.prototype-canvas { min-height: 100vh; background: radial-gradient(circle at 20% 0%, rgba(21, 155, 215, 0.1), transparent 28rem), #edf2f6; }
.app-shell {
  min-height: 100vh;
  max-width: 540px;
  margin: 0 auto;
  padding-bottom: calc(5.25rem + env(safe-area-inset-bottom));
  position: relative;
  background: #f8fafb;
  box-shadow: 0 0 44px rgba(27, 48, 66, 0.12);
}
.app-header, .detail-header {
  min-height: 5.6rem;
  padding: calc(1rem + env(safe-area-inset-top)) 1.1rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid #e2e8ec;
  backdrop-filter: blur(14px);
}
.brand-lockup { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.brand-mark { width: 3rem; height: 3rem; flex: 0 0 auto; }
.app-header h1, .detail-header h1 { margin: 0; font-size: 1.5rem; line-height: 1.05; letter-spacing: -0.035em; }
.app-header form { margin: 0; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.45rem; }
.header-icon, .back-button, .close-button {
  width: 2.8rem;
  height: 2.8rem;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #2b3d4b;
  background: #edf4f7;
  cursor: pointer;
}
.header-icon span { font-size: 1.35rem; transform: rotate(180deg); }
#mileage-settings-button span { transform: none; font-weight: 900; }
.back-button { flex: 0 0 auto; font-size: 1.6rem; }
.header-add-button { min-height: 2.8rem; border: 0; border-radius: 999px; padding: 0.6rem 0.9rem; color: #fff; background: var(--primary); font-weight: 850; box-shadow: 0 7px 16px rgba(21, 155, 215, 0.22); cursor: pointer; }

.week-picker { padding: 0.9rem 0 0.8rem; background: #fff; border-bottom: 1px solid #e0e6ea; }
.month-row { padding: 0 1.1rem 0.65rem; display: flex; align-items: center; justify-content: space-between; color: #324656; font-weight: 800; }
.demo-pill { border-radius: 999px; padding: 0.3rem 0.65rem; color: #735608; background: #fff1c8; font-size: 0.75rem; font-weight: 850; }
.day-strip {
  display: flex;
  gap: 0.42rem;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding: 0.1rem 1rem 0.3rem;
}
.day-strip::-webkit-scrollbar { display: none; }
.day-button {
  flex: 0 0 3.25rem;
  min-height: 4.25rem;
  border: 0;
  border-radius: 1.15rem;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.14rem;
  color: #697987;
  background: transparent;
  scroll-snap-align: center;
  cursor: pointer;
}
.day-button span { font-size: 0.73rem; font-weight: 750; }
.day-button strong { font-size: 1.08rem; }
.day-button i { width: 0.3rem; height: 0.3rem; border-radius: 50%; background: #17a5df; }
.day-button.is-active { color: #fff; background: var(--primary); box-shadow: 0 8px 18px rgba(21, 155, 215, 0.28); }
.day-button.is-active i { background: #fff; }

.schedule-list { padding: 0.35rem 0 1.5rem; }
.reports-list, .clients-list { padding: 1rem 0.85rem 1.6rem; }
.reports-intro, .clients-intro { margin-bottom: 0.9rem; padding: 1rem 1.05rem; border: 1px solid #dce8ee; border-radius: 1.2rem; background: #eef8fc; }
.reports-intro h2, .clients-intro h2 { margin: 0; font-size: 1.18rem; }
.reports-intro p, .clients-intro p { margin: 0.35rem 0 0; color: #58707f; line-height: 1.5; }
.report-client-list { display: grid; gap: 0.75rem; }
.report-client-card {
  width: 100%;
  min-height: 6.9rem;
  border: 0;
  border-radius: 1.25rem;
  padding: 0.9rem;
  display: grid;
  grid-template-columns: 3.7rem minmax(0, 1fr) 1.2rem;
  align-items: center;
  gap: 0.8rem;
  color: inherit;
  text-align: left;
  box-shadow: 0 10px 23px rgba(32, 51, 69, 0.13);
  cursor: pointer;
}
.report-client-avatar { width: 3.7rem; height: 3.7rem; border: 3px solid rgba(255, 255, 255, 0.76); border-radius: 50%; object-fit: cover; background: rgba(255, 255, 255, 0.9); }
.report-client-copy { min-width: 0; display: flex; flex-direction: column; gap: 0.12rem; }
.report-client-copy strong { font-size: 1.13rem; }
.report-client-copy span { font-size: 0.86rem; font-weight: 700; }
.report-client-copy small { margin-top: 0.18rem; font-size: 0.72rem; opacity: 0.86; }
.report-chevron { font-size: 1.8rem; font-weight: 500; opacity: 0.8; }
.client-directory-list { display: grid; gap: 0.75rem; }
.client-directory-card { width: 100%; min-height: 6.7rem; border: 0; border-radius: 1.25rem; padding: 0.9rem; display: grid; grid-template-columns: 3.7rem minmax(0, 1fr) 1.2rem; align-items: center; gap: 0.8rem; color: inherit; text-align: left; box-shadow: 0 10px 23px rgba(32, 51, 69, 0.13); cursor: pointer; }
.directory-avatar { width: 3.7rem; height: 3.7rem; border: 3px solid rgba(255, 255, 255, 0.76); border-radius: 50%; object-fit: cover; background: rgba(255, 255, 255, 0.9); }
.directory-copy { min-width: 0; display: flex; flex-direction: column; gap: 0.12rem; }
.directory-copy strong { font-size: 1.13rem; }
.directory-copy span { font-size: 0.83rem; opacity: 0.92; }
.directory-copy small { margin-top: 0.18rem; font-size: 0.72rem; opacity: 0.88; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.directory-copy .directory-alert { font-weight: 850; }
.day-group { padding: 1.05rem 0.85rem 1.2rem; display: grid; grid-template-columns: 4.4rem minmax(0, 1fr); gap: 0.58rem; scroll-margin-top: 12.9rem; }
.day-group + .day-group { border-top: 1px solid #e1e7eb; }
.date-heading { padding-top: 0.15rem; display: flex; flex-direction: column; align-items: center; color: var(--primary); text-align: center; }
.date-heading > span { font-size: 1.5rem; line-height: 1; font-weight: 700; }
.date-heading div { margin-top: 0.25rem; display: flex; flex-direction: column; }
.date-heading strong { font-size: 0.76rem; }
.date-heading small { color: #8795a1; font-size: 0.68rem; }
.visit-stack { display: grid; gap: 0.75rem; min-width: 0; }
.visit-card, .client-summary {
  color: #fff;
  background: #57437c;
}
.visit-card {
  width: 100%;
  min-height: 9.2rem;
  border: 0;
  border-radius: 1.35rem;
  padding: 0.95rem;
  display: grid;
  grid-template-columns: 3.7rem minmax(0, 1fr);
  align-items: start;
  gap: 0.8rem;
  color: inherit;
  text-align: left;
  box-shadow: 0 12px 25px rgba(32, 51, 69, 0.13);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.visit-card:active { transform: scale(0.985); box-shadow: 0 7px 16px rgba(32, 51, 69, 0.12); }
.client-avatar, .summary-avatar {
  width: 3.7rem;
  height: 3.7rem;
  border: 3px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 5px 15px rgba(18, 32, 45, 0.18);
}
.avatar-fallback { display: grid; place-items: center; color: #203443; font-weight: 850; }
.visit-copy { min-width: 0; display: flex; flex-direction: column; }
.visit-copy > strong { margin-bottom: 0.46rem; font-size: 1.18rem; line-height: 1.2; letter-spacing: -0.025em; }
.client-line { display: flex; align-items: center; gap: 0.35rem; font-size: 0.96rem; line-height: 1.4; font-weight: 750; }
.time-line { margin-top: 0.12rem; font-size: 0.96rem; line-height: 1.4; font-weight: 650; opacity: 0.94; }
.carer-line { margin-top: 0.15rem; font-size: 0.91rem; line-height: 1.35; opacity: 0.92; }
.readonly-chip { align-self: flex-start; margin-top: 0.55rem; border-radius: 99px; padding: 0.22rem 0.48rem; color: #334653; background: rgba(255, 255, 255, 0.76); font-size: 0.67rem; font-weight: 800; }

.colour-purple { color: #fff; background: #57437c; }
.colour-coral { color: #fff; background: #cf7479; }
.colour-blue { color: #172431; background: #82a9d0; }
.colour-teal { color: #fff; background: #2b9b91; }
.colour-gold { color: #18232d; background: #d2aa2f; }
.colour-green { color: #fff; background: #37a848; }

.loading-state, .empty-state { margin: 2.5rem 1.1rem; padding: 1.8rem 1.2rem; border-radius: 1.35rem; background: #fff; text-align: center; box-shadow: 0 10px 24px rgba(30, 52, 69, 0.08); }
.loading-state { display: grid; justify-items: center; gap: 0.6rem; color: var(--muted); }
.loading-state p, .empty-state p { margin: 0; }
.empty-state h2 { margin: 0 0 0.35rem; font-size: 1.2rem; }
.empty-state p { color: var(--muted); }
.spinner { width: 1.7rem; height: 1.7rem; border: 3px solid #d9ebf2; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.bottom-nav {
  width: min(100%, 540px);
  min-height: calc(4.9rem + env(safe-area-inset-bottom));
  padding: 0.5rem 0.35rem calc(0.45rem + env(safe-area-inset-bottom));
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid #dbe3e8;
  backdrop-filter: blur(16px);
}
.bottom-nav button { min-width: 0; border: 0; border-radius: 0.9rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem; color: #768592; background: transparent; cursor: pointer; }
.bottom-nav button > span:last-child { font-size: 0.76rem; font-weight: 750; }
.nav-icon { min-height: 1.45rem; display: grid; place-items: center; font-size: 1.22rem; line-height: 1; }
.bottom-nav button.is-active { color: #118fca; background: #e9f6fb; }

.detail-page { min-height: 100vh; padding-bottom: calc(1.4rem + env(safe-area-inset-bottom)); background: #f3f6f8; }
.detail-header { justify-content: flex-start; padding-inline: 0.65rem 1rem; }
.detail-header > div { min-width: 0; flex: 1; }
.detail-date { color: #5f7280; font-size: 0.88rem; font-weight: 800; }
.detail-header > .detail-header-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 0.45rem; }
.header-edit-button { min-height: 2.45rem; border: 0; border-radius: 999px; padding: 0.5rem 0.72rem; color: #087bab; background: #e5f4fa; font-size: 0.76rem; font-weight: 850; cursor: pointer; }
.detail-content { padding: 1rem 0.85rem 1.8rem; }
.client-summary { border-radius: 1.55rem; padding: 1.1rem; display: grid; grid-template-columns: 5.1rem minmax(0, 1fr); gap: 0.95rem; align-items: start; box-shadow: 0 14px 30px rgba(30, 48, 66, 0.18); }
.summary-avatar { width: 5.1rem; height: 5.1rem; }
.client-summary h2 { margin: 0.1rem 0 0.2rem; font-size: 1.72rem; line-height: 1; letter-spacing: -0.04em; }
.client-summary p { margin: 0.12rem 0; line-height: 1.35; opacity: 0.94; }
.client-summary strong, .summary-carer { display: block; margin-top: 0.36rem; }
.summary-label { display: block; font-size: 0.69rem; font-weight: 850; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.78; }
.summary-carer { font-size: 0.88rem; opacity: 0.92; }
.view-only-banner { margin: 0.85rem 0 0; border-radius: 0.95rem; padding: 0.68rem 0.8rem; color: #38515f; background: #e7eff3; font-size: 0.82rem; line-height: 1.4; }

.action-grid { margin: 0.95rem 0 1.05rem; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.55rem; }
.action-button { min-width: 0; min-height: 6rem; border: 0; border-radius: 1.15rem; padding: 0.68rem 0.28rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.45rem; line-height: 1.05; box-shadow: 0 8px 18px rgba(35, 55, 72, 0.08); cursor: pointer; }
.action-button:disabled { opacity: 0.5; cursor: default; }
.action-icon { min-height: 1.8rem; display: grid; place-items: center; font-size: 1.65rem; line-height: 1; }
.action-label { max-width: 100%; overflow-wrap: anywhere; font-size: 0.7rem; font-weight: 850; }
.tone-blue { color: #087eb1; background: #e4f4fb; }
.tone-teal { color: #167d74; background: #e4f6f3; }
.tone-green { color: #568b0f; background: #edf7df; }
.tone-orange { color: #d25c32; background: #fff0e9; }

.info-card { margin-top: 0.8rem; border: 1px solid rgba(218, 226, 232, 0.8); border-radius: 1.3rem; padding: 1.05rem; background: #fff; box-shadow: 0 10px 24px rgba(33, 54, 70, 0.08); }
.info-card-title { margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.55rem; }
.info-card-title .section-icon { color: #1e90c3; font-size: 1.1rem; }
.info-card-title h2 { margin: 0; font-size: 1.08rem; }
.mileage-card { border-color: #cfe3dc; background: #fbfefd; }
.mileage-rows { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0; }
.mileage-rows dt, .mileage-rows dd { margin: 0; padding: 0.48rem 0; border-top: 1px solid #e3ebe8; font-size: 0.82rem; line-height: 1.35; }
.mileage-rows dt:first-of-type, .mileage-rows dt:first-of-type + dd { padding-top: 0; border-top: 0; }
.mileage-rows dt { padding-right: 0.8rem; color: #536b63; }
.mileage-rows dd { color: #213a32; text-align: right; font-weight: 800; }
.mileage-rows .is-total { color: #152f26; font-weight: 900; }
.daily-mileage-summary { margin-top: 0.8rem; border-radius: 0.95rem; padding: 0.78rem; background: #edf7f3; }
.daily-mileage-summary h3 { margin: 0 0 0.55rem; font-size: 0.88rem; }
.mileage-status { margin: 0.75rem 0 0; border-radius: 0.8rem; padding: 0.65rem 0.72rem; color: #526963; background: #eef3f1; font-size: 0.76rem; font-weight: 750; line-height: 1.4; }
.mileage-status.is-active { color: #126e64; background: #e1f6f1; }
.mileage-status.is-warning { color: #765317; background: #fff2d6; }
.contact-row { padding: 0.5rem 0; display: flex; align-items: flex-start; gap: 0.65rem; line-height: 1.45; }
.contact-row .section-icon { flex: 0 0 auto; color: #6a7d89; }
.instruction-copy { margin: 0.65rem 0 0; padding: 0.78rem; border-radius: 0.9rem; color: #455866; background: #f2f6f8; line-height: 1.5; }
.support-notes { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.62rem; }
.support-notes li { position: relative; padding: 0.78rem 0.8rem 0.78rem 1.9rem; border-radius: 0.9rem; background: #f4f7f9; line-height: 1.45; }
.support-notes li::before { content: "✓"; position: absolute; left: 0.7rem; top: 0.74rem; color: #2b9b91; font-weight: 900; }
.note-meta { display: block; margin-top: 0.3rem; color: #768591; font-size: 0.72rem; }
.empty-note { margin: 0; color: #6f7f8b; }
.report-summary { margin-bottom: 0.9rem; }
.report-notes-card { margin-top: 0; }
.report-notes { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.75rem; }
.report-notes li { padding: 0.9rem; border: 1px solid #e2e8ec; border-radius: 1rem; background: #f7f9fa; }
.report-note-text { margin: 0; line-height: 1.5; white-space: pre-wrap; }
.report-visit-meta, .report-carer-meta { display: block; margin-top: 0.32rem; color: #536b79; font-size: 0.75rem; line-height: 1.35; }
.report-visit-meta { margin-top: 0.58rem; padding-top: 0.55rem; border-top: 1px solid #e1e7eb; font-weight: 750; }
.client-profile-summary { margin-bottom: 0.9rem; }
.profile-facts { margin: 0; display: grid; gap: 0; }
.profile-fact { padding: 0.68rem 0; border-top: 1px solid #e5eaed; }
.profile-fact:first-child { padding-top: 0; border-top: 0; }
.profile-fact:last-child { padding-bottom: 0; }
.profile-fact dt { margin: 0 0 0.2rem; color: #71828e; font-size: 0.73rem; font-weight: 850; letter-spacing: 0.03em; text-transform: uppercase; }
.profile-fact dd { margin: 0; color: #263947; line-height: 1.5; white-space: pre-wrap; }
.profile-alert-card { border-color: #eccd74; background: #fffaf0; }
.profile-risk-card { border-color: #edd3ce; }
.medication-card { border-color: #d8e3e8; }
.medication-warning { margin: 0 0 0.85rem; border-left: 4px solid #d7892f; border-radius: 0.75rem; padding: 0.72rem 0.78rem; color: #644614; background: #fff6df; font-size: 0.8rem; font-weight: 750; line-height: 1.45; }
.medication-list { display: grid; gap: 0.65rem; }
.medication-item { border: 1px solid #e0e7eb; border-radius: 0.95rem; padding: 0.8rem; background: #f7f9fa; }
.medication-item h3 { margin: 0; font-size: 1rem; }
.medication-item p { margin: 0.3rem 0 0; line-height: 1.4; }
.medication-item small { display: block; margin-top: 0.45rem; color: #647784; line-height: 1.4; white-space: pre-wrap; }
.profile-updated { margin: 1rem 0 0; color: #6d7f8c; text-align: center; font-size: 0.73rem; }
.client-documents-card { border-color: #cfe2ec; background: #fbfdfe; }
.client-documents-heading { margin-bottom: 0.8rem; display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; }
.client-documents-heading .info-card-title { margin: 0; }
.upload-document-button { min-height: 2.55rem; border: 0; border-radius: 0.8rem; padding: 0.55rem 0.72rem; color: #fff; background: var(--primary); font-size: 0.76rem; font-weight: 850; cursor: pointer; }
.client-document-list { display: grid; gap: 0.68rem; }
.client-document-item { border: 1px solid #dce6eb; border-radius: 1rem; padding: 0.78rem; background: #fff; box-shadow: 0 5px 13px rgba(33, 54, 70, 0.05); }
.client-document-open { width: 100%; border: 0; padding: 0; display: grid; grid-template-columns: 2.35rem minmax(0, 1fr) 1rem; align-items: center; gap: 0.65rem; color: inherit; background: transparent; text-align: left; cursor: pointer; }
.document-type-icon { width: 2.35rem; height: 2.35rem; border-radius: 0.75rem; display: grid; place-items: center; color: #0c82b5; background: #e6f5fb; font-size: 1.1rem; font-weight: 900; }
.client-document-copy { min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.client-document-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.94rem; }
.client-document-copy span { color: #5f7380; font-size: 0.72rem; line-height: 1.35; }
.client-document-meta { margin: 0.6rem 0 0; padding-top: 0.55rem; border-top: 1px solid #e5ebee; color: #687b87; font-size: 0.72rem; line-height: 1.45; }
.client-document-notes { margin: 0.42rem 0 0; color: #405462; font-size: 0.78rem; line-height: 1.45; white-space: pre-wrap; }
.visit-documents-link { width: 100%; min-height: 3.65rem; margin: 0 0 0.9rem; border: 1px solid #c9e2ec; border-radius: 1.05rem; padding: 0.78rem 0.9rem; display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; color: #136f98; background: #eaf7fc; text-align: left; font-weight: 850; box-shadow: 0 8px 18px rgba(32, 76, 96, 0.07); cursor: pointer; }
.visit-documents-link span:first-child { display: flex; align-items: center; gap: 0.6rem; }
.concern-card { border-color: #f0d4cf; }
.concern-card .info-card-title .section-icon { width: 1.35rem; height: 1.35rem; border-radius: 50%; display: grid; place-items: center; color: #fff; background: #d65d46; font-size: 0.82rem; font-weight: 900; }
.report-concern-button, .concern-submit-button { min-height: 3.1rem; border: 0; border-radius: 0.95rem; padding: 0.72rem 1rem; color: #fff; background: #d65d46; font-weight: 850; cursor: pointer; }
.report-concern-button { width: 100%; }
.concern-submit-button:disabled { opacity: 0.55; cursor: default; }
.empty-concern { margin: 0.72rem 0 0; color: #6f7f8b; }
.concern-list { margin: 0.8rem 0 0; padding: 0; list-style: none; display: grid; gap: 0.68rem; }
.concern-item { padding: 0.82rem; border-left: 4px solid #d7a241; border-radius: 0.9rem; background: #fff8e9; }
.concern-item.priority-urgent { border-left-color: #d94343; background: #fff0f0; }
.concern-item-heading { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.concern-item-heading strong { font-size: 0.9rem; }
.concern-item p { margin: 0.48rem 0 0; line-height: 1.45; white-space: pre-wrap; }
.concern-status { border-radius: 99px; padding: 0.2rem 0.48rem; color: #5d4930; background: rgba(255, 255, 255, 0.72); font-size: 0.66rem; font-weight: 850; text-transform: capitalize; }
.admin-card { border-color: #f0d2d2; }
.admin-card p { margin: 0 0 0.8rem; color: #6e7d88; font-size: 0.86rem; line-height: 1.45; }
.admin-card .danger-button { width: 100%; }
.prototype-footnote { margin: 1.3rem 0 0; color: #7b8b97; text-align: center; font-size: 0.75rem; }

.app-dialog { width: min(calc(100% - 1.5rem), 500px); max-height: calc(100vh - 1.5rem); border: 0; border-radius: 1.55rem; padding: 0; color: var(--ink); background: #fff; box-shadow: 0 25px 70px rgba(20, 35, 48, 0.3); }
.app-dialog::backdrop { background: rgba(17, 29, 40, 0.58); backdrop-filter: blur(2px); }
.app-dialog form { padding: 1.25rem; }
.dialog-heading { margin-bottom: 1rem; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.dialog-heading h2 { margin: 0; font-size: 1.4rem; }
.close-button { flex: 0 0 auto; font-size: 1.45rem; }
.app-dialog input, .app-dialog textarea, .app-dialog select { margin-top: 0.5rem; }
.app-dialog textarea { min-height: 8rem; resize: vertical; }
.app-dialog select { min-height: 3.1rem; }
.field-help { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.78rem; }
.dialog-actions { margin-top: 1.1rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.delete-options { margin: 0.8rem 0 0; border: 0; border-radius: 1rem; padding: 0.3rem 0.75rem; display: grid; background: #f4f6f8; }
.delete-options label { margin: 0; padding: 0.75rem 0.2rem; display: flex; align-items: flex-start; gap: 0.6rem; border-top: 1px solid #e1e6e9; font-weight: 650; line-height: 1.35; }
.delete-options label:first-child { border-top: 0; }
.delete-options input { margin-top: 0.15rem; accent-color: var(--primary); }

.intake-dialog { width: min(calc(100% - 0.7rem), 540px); height: calc(100dvh - 0.7rem); max-height: calc(100dvh - 0.7rem); border-radius: 1.2rem; overflow: hidden; }
.intake-dialog form { height: 100%; padding: 0; overflow-y: auto; overscroll-behavior: contain; }
.intake-heading { margin: 0; padding: 1rem 1rem 0.85rem; position: sticky; top: 0; z-index: 3; background: rgba(255, 255, 255, 0.97); border-bottom: 1px solid #e1e7eb; backdrop-filter: blur(12px); }
.intake-heading p:not(.eyebrow) { margin: 0.3rem 0 0; color: #677a87; font-size: 0.8rem; line-height: 1.4; }
.intake-section { margin: 0.9rem; border: 1px solid #dce5ea; border-radius: 1.1rem; padding: 0.85rem; background: #fafdff; }
.intake-section legend { padding: 0 0.35rem; color: #263a49; font-size: 1rem; font-weight: 850; }
.intake-section > label { display: block; margin-top: 0.75rem; }
.intake-section > label:first-of-type { margin-top: 0.2rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-grid label { min-width: 0; margin: 0; display: block; font-size: 0.82rem; font-weight: 800; }
.form-grid .full-width { grid-column: 1 / -1; }
.intake-section input, .intake-section textarea, .intake-section select { min-height: 3rem; }
.intake-section textarea { min-height: 5.2rem; }
.medication-intake-section .medication-warning { margin-top: 0.15rem; }
.medication-rows { display: grid; gap: 0.75rem; }
.medication-entry { border: 1px solid #dfe7eb; border-radius: 0.95rem; padding: 0.75rem; background: #fff; }
.medication-entry-heading { margin-bottom: 0.7rem; display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; }
.medication-entry-heading h3 { margin: 0; font-size: 0.95rem; }
.remove-medication-button { border: 0; padding: 0.4rem 0.55rem; color: #a53838; background: #ffeded; border-radius: 0.7rem; font-size: 0.72rem; font-weight: 850; cursor: pointer; }
.add-medication-button { width: 100%; margin-top: 0.75rem; }
.intake-save-help { margin: 0.9rem; }
.intake-actions { margin: 0; padding: 0.8rem 0.9rem calc(0.8rem + env(safe-area-inset-bottom)); position: sticky; bottom: 0; z-index: 3; background: rgba(255, 255, 255, 0.97); border-top: 1px solid #e1e7eb; backdrop-filter: blur(12px); }
.rota-repeat-section { background: #f8fbfd; }
.repeat-toggle { margin: 0 !important; display: flex !important; align-items: center; gap: 0.65rem; }
.repeat-toggle input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--primary); }
.repeat-controls { margin-top: 0.9rem; display: grid; gap: 0.9rem; }
.field-label { display: block; margin-bottom: 0.5rem; font-size: 0.82rem; font-weight: 800; }
.weekday-choices { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.35rem; }
.weekday-choices label { margin: 0; position: relative; }
.weekday-choices input { position: absolute; opacity: 0; pointer-events: none; }
.weekday-choices span { min-height: 2.4rem; border: 1px solid #cad8df; border-radius: 50%; display: grid; place-items: center; color: #506571; background: #fff; font-size: 0.78rem; font-weight: 850; cursor: pointer; }
.weekday-choices input:checked + span { border-color: var(--primary); color: #fff; background: var(--primary); }
.edit-scope-options { display: grid; gap: 0.2rem; }
.edit-scope-options label { margin: 0; padding: 0.7rem 0; display: flex; align-items: flex-start; gap: 0.6rem; border-top: 1px solid #e2e8eb; line-height: 1.4; }
.edit-scope-options label:first-child { border-top: 0; }
.edit-scope-options input { width: 1.2rem; height: 1.2rem; margin: 0.1rem 0 0; accent-color: var(--primary); }
.dialog-intro { margin: 0.28rem 0 0; color: #627683; font-size: 0.8rem; }
.document-date-grid { margin-top: 0.65rem; }
.document-upload-dialog textarea { min-height: 5rem; }
.document-viewer-dialog { width: min(calc(100% - 0.4rem), 540px); height: calc(100dvh - 0.4rem); max-height: calc(100dvh - 0.4rem); border-radius: 1rem; overflow: hidden; }
.document-viewer-shell { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); background: #eef3f6; }
.document-viewer-header { padding: calc(0.8rem + env(safe-area-inset-top)) 0.9rem 0.8rem; display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; background: #fff; border-bottom: 1px solid #dce4e9; }
.document-viewer-header h2 { margin: 0; max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.08rem; }
.document-viewer-content { min-height: 0; overflow: auto; display: grid; place-items: stretch; }
.document-viewer-content iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.document-viewer-content img { max-width: 100%; height: auto; margin: auto; display: block; background: #fff; }
.mileage-settings-dialog form { display: grid; gap: 0.7rem; }
.mileage-settings-dialog label { display: block; }
.money-input { margin-top: 0.45rem; border: 1px solid #cad5dc; border-radius: 0.9rem; display: grid; grid-template-columns: 2.8rem minmax(0, 1fr); align-items: center; overflow: hidden; background: #f1f6f8; }
.money-input > span { color: #5a6f7c; text-align: center; font-weight: 850; }
.money-input input { margin: 0; border: 0; border-left: 1px solid #cad5dc; border-radius: 0; }

.toast { min-width: min(calc(100% - 2rem), 420px); max-width: calc(100% - 2rem); padding: 0.8rem 1rem; position: fixed; left: 50%; top: max(0.8rem, env(safe-area-inset-top)); z-index: 100; transform: translate(-50%, -1rem); border-radius: 1rem; color: #fff; background: #223746; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; text-align: center; font-weight: 700; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #9f3434; }

@media (min-width: 700px) {
  .prototype-canvas { padding: 1.5rem 0; }
  .app-shell { min-height: calc(100vh - 3rem); border-radius: 2rem; overflow: clip; }
  .app-header, .detail-header { padding-top: 1rem; }
  .bottom-nav { bottom: 1.5rem; border-radius: 0 0 2rem 2rem; }
}

@media (max-width: 390px) {
  .day-group { grid-template-columns: 3.7rem minmax(0, 1fr); padding-inline: 0.6rem; }
  .visit-card { grid-template-columns: 3rem minmax(0, 1fr); padding: 0.82rem; }
  .client-avatar { width: 3rem; height: 3rem; }
  .report-client-card { grid-template-columns: 3rem minmax(0, 1fr) 1rem; padding: 0.82rem; }
  .report-client-avatar { width: 3rem; height: 3rem; }
  .client-directory-card { grid-template-columns: 3rem minmax(0, 1fr) 1rem; padding: 0.82rem; }
  .directory-avatar { width: 3rem; height: 3rem; }
  .action-grid { gap: 0.35rem; }
  .action-button { min-height: 5.55rem; }
  .action-label { font-size: 0.64rem; }
  .client-summary { grid-template-columns: 4.3rem minmax(0, 1fr); padding: 0.95rem; }
  .summary-avatar { width: 4.3rem; height: 4.3rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full-width { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
