:root {
  color-scheme: light;
  /* HalavBook look: look-1 colours (dusty rose) + look-3 type (Rubik / Fredoka). */
  --bg: #fbf6f8;
  --bg-accent: #f6e6ed;
  --panel: #ffffff;
  --border: #eddde4;
  --text: #34252d;
  --muted: #8d7a83;
  --accent: #a8728a;
  --accent-dark: #84526a;
  --accent-light: #f3e1e8;
  --font-body: 'Rubik', 'Segoe UI', Arial, sans-serif;
  --font-brand: 'Fredoka', 'Rubik', Arial, sans-serif;
  --shadow-sm: 0 1px 2px rgba(60, 40, 50, 0.05), 0 1px 3px rgba(60, 40, 50, 0.04);
  --shadow-md: 0 4px 14px rgba(60, 40, 50, 0.08);
  --shadow-lg: 0 10px 30px rgba(60, 40, 50, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 500px at 15% -10%, var(--bg-accent), transparent),
    var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.muted { color: var(--muted); font-size: 0.85em; }

/* Login page */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.login-box {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2.75rem 2.5rem;
  width: 340px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-box::before {
  content: '🤱';
  display: block;
  font-size: 2rem;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}
.login-box h1 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 1.75rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.login-box form { display: flex; flex-direction: column; gap: 0.85rem; }
.login-box label { text-align: right; font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.login-box input {
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.login-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.login-box button {
  margin-top: 0.6rem;
  padding: 0.75rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.login-box button:hover { filter: brightness(1.06); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.login-box button:active { transform: translateY(0); }
.login-box .error { color: #b3413a; font-size: 0.85rem; background: #fbeae8; padding: 0.6rem 0.75rem; border-radius: 8px; }

/* App shell */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.75rem;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--border);
}
.topbar-title { display: flex; align-items: baseline; gap: 0.55rem; flex-shrink: 0; }
.topbar h1 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  flex-shrink: 0;
}
.brand-mark { width: 30px; height: 30px; flex-shrink: 0; }
.brand-word {
  direction: ltr;
  font-family: var(--font-brand);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
  color: var(--text);
}
.brand-word em { font-style: normal; color: var(--accent); }
.client-count {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}
.client-count:empty { display: none; }

.topbar-actions { display: flex; align-items: center; gap: 1rem; flex: 1; min-width: 0; }
.search-wrap { position: relative; flex: 1; max-width: 320px; }
.search-wrap .search-icon {
  position: absolute;
  top: 50%;
  inset-inline-start: 0.85rem;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.topbar #search {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  padding: 0.55rem 0.9rem;
  padding-inline-start: 2.4rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--panel);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.topbar #search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.topbar button {
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.topbar button:hover { filter: brightness(1.06); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.topbar button:active { transform: translateY(0); }
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
  margin-inline-start: auto;
}
.topbar-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}
.topbar-link svg { flex-shrink: 0; }
.topbar-link:hover { background: var(--accent-light); color: var(--accent-dark); }

.layout {
  padding: 1.5rem;
}

.sort-bar {
  max-width: 720px;
  margin: 0 auto 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.sort-label { font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.sort-btn:hover { border-color: var(--accent); }
.sort-btn.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); font-weight: 600; }
.sort-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sort-dir { font-size: 0.75rem; font-weight: 500; }
.sort-dir:empty { display: none; }

.client-list {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.client-row {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.client-row:has(.accordion-body) { border-color: var(--accent); box-shadow: var(--shadow-md); }

.client-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  text-align: right;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 14px;
  padding: 0.9rem 1.2rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.client-card:hover { background: var(--accent-light); }
.client-row:has(.accordion-body) .client-card { border-radius: 14px 14px 0 0; }
.client-card.selected {
  background: linear-gradient(135deg, var(--accent-light), #fdf7f9);
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: var(--shadow-sm);
  padding-block: 0.6rem;
}
.client-card strong { font-size: 1.02rem; font-weight: 700; padding-inline-end: 5rem; }
.header-row { display: flex; align-items: center; gap: 0.5rem; width: 100%; cursor: pointer; }
.card-name-input {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 8px;
  padding-block: 0.2rem;
  padding-inline: 0.4rem;
  margin-inline-start: -0.4rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.card-name-input:hover { background: rgba(255, 255, 255, 0.6); }
.card-name-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.card-date {
  position: absolute;
  top: 0.9rem;
  left: 1.2rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
  background: var(--bg);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}
.receipt-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}
.receipt-toggle:hover { background: rgba(60, 40, 50, 0.05); }
.receipt-toggle:has(input:checked) { background: var(--accent-light); color: var(--accent-dark); }
.receipt-toggle input[type="checkbox"] {
  width: 1em;
  height: 1em;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-inline-start: auto;
}
.client-card.selected .card-date {
  position: static;
  display: inline-block;
  flex-shrink: 0;
}
.close-card-btn {
  flex-shrink: 0;
  width: 1.9rem;
  height: 1.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(60, 40, 50, 0.06);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.close-card-btn:hover { background: var(--accent-light); color: var(--accent-dark); }
.badge-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem; }
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  background: var(--border);
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
}
.badge-good { background: #dcf0e2; color: #2c6e42; }
.badge-monitor { background: #faecc8; color: #93670f; }
.badge-attention { background: #fadedb; color: #ad3b2c; }

/* First-birthday reminder on the client card. */
.birthday-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
  background: #fbe4ec;
  color: #a5416a;
  margin-inline-start: 0.4rem;
}

.accordion-body {
  border-top: 1px solid var(--border);
  border-radius: 0 0 14px 14px;
  padding: 1.75rem;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  transition: max-height 0.35s ease, opacity 0.25s ease, transform 0.25s ease;
}
.accordion-body.open {
  max-height: 3000px;
  opacity: 1;
  transform: translateY(0);
}

.form-section {
  margin-bottom: 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.9rem 1.1rem 1.15rem;
}
.form-section:last-of-type { margin-bottom: 0; }
.form-section-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-dark);
  letter-spacing: 0.01em;
  margin: -0.15rem -0.2rem 1.1rem;
  padding: 0.5rem 0.2rem 0.85rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  border-radius: 10px;
  transition: background 0.12s ease;
}
.form-section-title:active { background: rgba(60, 40, 50, 0.05); }
.form-section-title::before {
  content: '';
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}
.form-section-title::after {
  content: '';
  margin-inline-start: auto;
  width: 0.5rem;
  height: 0.5rem;
  flex-shrink: 0;
  border-inline-end: 2.5px solid var(--muted);
  border-block-end: 2.5px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}
.form-section.collapsed { padding-bottom: 0.9rem; }
.form-section.collapsed .form-section-title { margin-bottom: 0; padding-bottom: 0.5rem; border-bottom: none; }
.form-section.collapsed .form-section-title::after { transform: rotate(-45deg); }
.form-section.collapsed > *:not(.form-section-title) { display: none; }

.field-row {
  display: flex;
  gap: 1.1rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
  align-items: flex-start;
}
.field-row .field { flex: 1; min-width: 160px; }
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1.1rem; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 0.55rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--panel);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:not([type="checkbox"]):not([type="radio"]), .field select {
  height: 2.6rem;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.field textarea { resize: vertical; }

.field-inline { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
.field-inline label { flex-shrink: 0; white-space: nowrap; margin: 0; }
.field-inline input[type="text"], .field-inline input[type="date"] { flex: 1; min-width: 140px; }
.field-inline .computed-age { flex-basis: 100%; }

.radio-group {
  display: inline-flex;
  height: 2.6rem;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--panel);
}
.radio-group label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0 1.1rem;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.radio-group label:not(:last-child) { border-inline-end: 1.5px solid var(--border); }
.radio-group label:has(input:checked) {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
}
.radio-group input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.radio-group label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

.computed-age, .feeding-diff { margin: 0; }

.weight-gain-box {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: -0.5rem 0 1.1rem;
  padding: 0.7rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--border);
  border-radius: 10px;
}
.weight-gain-box[hidden] { display: none; }
.weight-gain-box.status-good { border-inline-start-color: #2c6e42; }
.weight-gain-box.status-monitor { border-inline-start-color: #93670f; }
.weight-gain-box.status-attention { border-inline-start-color: #ad3b2c; }
.weight-gain-details { margin: 0; }

.weight-log { display: flex; flex-direction: column; gap: 0.55rem; margin-bottom: 0.7rem; }
.weight-log:empty { margin-bottom: 0; }
.weight-log-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 0.5rem;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem;
}
.weight-log-row input[type="date"],
.weight-log-row input[type="number"] { min-width: 0; }
.remove-row-btn {
  flex-shrink: 0;
  width: 2.4rem;
  height: 2.4rem;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: color 0.15s ease, background 0.15s ease;
}
.remove-row-btn:hover { color: #ad3b2c; border-color: #f0b8b0; background: #fdf2f1; }
.add-row-btn {
  align-self: flex-start;
  padding: 0.5rem 1rem;
  border: 1.5px dashed var(--border);
  background: transparent;
  color: var(--accent-dark);
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.add-row-btn:hover { border-color: var(--accent); background: var(--accent-light); }

.reauth-box {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  background: #fdf6e3;
  border: 1px solid #f0dca0;
  border-radius: 12px;
}
.reauth-msg { margin: 0 0 0.65rem; font-size: 0.85rem; color: #7a5b12; font-weight: 600; }
.reauth-fields { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.reauth-fields input {
  flex: 1;
  min-width: 130px;
  padding: 0.55rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-family: inherit;
  font-size: 1rem;
  background: var(--panel);
  color: var(--text);
}
.reauth-fields input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.reauth-fields button {
  flex-shrink: 0;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.reauth-fields button:disabled { opacity: 0.6; cursor: default; }
.reauth-error { margin: 0.5rem 0 0; font-size: 0.8rem; color: #ad3b2c; min-height: 1em; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.form-actions button {
  padding: 0.65rem 1.4rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.form-actions button:hover { filter: brightness(1.06); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.form-actions button:active { transform: translateY(0); }
.form-actions button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
.form-actions button.secondary:hover { color: var(--text); background: var(--bg); box-shadow: none; transform: none; }
.form-actions button.danger {
  background: transparent;
  color: #b3432f;
  border: 1.5px solid #e3b3a8;
  box-shadow: none;
  margin-inline-start: auto;
}
.form-actions button.danger:hover { background: #b3432f; color: #fff; border-color: #b3432f; box-shadow: none; transform: none; filter: none; }

.stats-page { gap: 1.25rem; }
.stat-summary {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  text-align: center;
}
.stat-summary-number {
  font-size: 2.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text), var(--accent-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-summary-label { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 0;
}
/* Stats cards aren't collapsible (no JS wiring on this page) — the form-section
   chevron/cursor affordance would be misleading here, so drop it. */
.stat-card.form-section .form-section-title {
  cursor: default;
  margin-inline: 0;
  padding-inline: 0;
}
.stat-card.form-section .form-section-title::after { display: none; }
.stat-bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}
.stat-bar-row:last-child { margin-bottom: 0; }
.stat-bar-label { flex: 0 0 8rem; font-size: 0.85rem; color: var(--text); text-align: left; }
.stat-bar-track {
  flex: 1;
  height: 0.9rem;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.stat-bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 999px;
  min-width: 4px;
}
.stat-bar-count { flex: 0 0 2rem; font-size: 0.85rem; font-weight: 600; color: var(--muted); text-align: end; }

@media (max-width: 600px) {
  .stat-bar-label { flex-basis: 5.5rem; }
}

@media (max-width: 600px) {
  /* iOS Safari zooms in on any focused field under 16px, leaving the page
     zoomed and scrollable. Keep every field at 16px on phones. */
  input, select, textarea { font-size: 16px !important; }

  .topbar {
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    row-gap: 0.6rem;
  }
  .topbar-title { order: 1; }
  .brand-word { font-size: 1.2rem; }
  .brand-mark { width: 26px; height: 26px; }
  .client-count { display: none; }
  .topbar-nav { order: 2; margin-inline-start: auto; }
  .topbar-link span { display: none; }
  .topbar-link { padding: 0.5rem; }
  .topbar-actions { order: 3; flex-basis: 100%; }
  .search-wrap { flex: 1; max-width: none; min-width: 0; }
  .topbar #search { font-size: 1rem; }
  .topbar #newClientBtn { flex-shrink: 0; padding-inline: 0.9rem; }

  .layout { padding: 0.75rem 0; }
  .client-list { max-width: none; gap: 0; }
  .sort-bar { padding: 0 1rem; margin-bottom: 0.6rem; }
  .client-row {
    border-radius: 0;
    border-inline-width: 0;
    border-top-width: 0;
    box-shadow: none;
  }
  .client-row:first-child { border-top-width: 1px; }
  .client-row:has(.accordion-body) { box-shadow: none; }
  .client-card, .client-row:has(.accordion-body) .client-card { border-radius: 0; }
  .accordion-body { padding: 1.1rem; border-radius: 0; }
  .client-card { min-width: 0; }
  .client-card strong { word-break: break-word; }

  .field-row { gap: 0.6rem; row-gap: 0.9rem; }
  .field-row .field { min-width: 130px; }
  .field-row .field-full { flex-basis: 100%; }

  /* Inputs below 16px trigger an unwanted zoom-in on focus in iOS Safari. */
  .field input, .field select, .field textarea { font-size: 1rem; }
  .field input:not([type="checkbox"]):not([type="radio"]), .field select { height: 2.85rem; }
  .field label { font-size: 0.85rem; }

  .form-section { border-radius: 14px; padding: 0.8rem 0.9rem 1rem; }
  .form-section-title { font-size: 0.92rem; }

  .radio-group { height: 2.85rem; }
  .radio-group label { padding: 0 0.9rem; font-size: 0.88rem; }

  .weight-log-row { grid-template-columns: 1fr 0.85fr auto; }

  .form-actions { flex-wrap: wrap-reverse; }
  .form-actions button[type="submit"] { flex: 1 1 100%; order: 1; }
  .form-actions button.secondary { flex: 1; order: 2; }
  .form-actions .save-status { flex: 1 1 100%; order: 3; text-align: center; }
}

/* First-visit onboarding sheet (onboarding.js) */
.onboarding { position: fixed; inset: 0; z-index: 50; }
.onboarding-backdrop {
  position: absolute; inset: 0;
  background: rgba(52, 37, 45, 0.35);
  opacity: 0; transition: opacity 0.25s ease;
}
.onboarding-sheet {
  position: absolute; inset-inline: 0; bottom: 0;
  max-height: 88vh; overflow-y: auto;
  background: var(--panel);
  border-radius: 22px 22px 0 0;
  padding: 1.3rem 1.2rem calc(1.1rem + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-lg);
  display: grid; gap: 1rem;
  transform: translateY(100%); transition: transform 0.25s ease;
}
.onboarding.open .onboarding-backdrop { opacity: 1; }
.onboarding.open .onboarding-sheet { transform: translateY(0); }
.onboarding-head { display: flex; gap: 0.8rem; align-items: center; }
.onboarding-head img { width: 52px; height: 52px; border-radius: 13px; flex-shrink: 0; box-shadow: var(--shadow-sm); }
.onboarding-head h2 { margin: 0 0 0.2rem; font-size: 1.15rem; }
.onboarding-head p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.onboarding-body { display: grid; gap: 0.8rem; }
.onboarding-body .steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; counter-reset: step; }
.onboarding-body .steps li { display: grid; grid-template-columns: 1.8rem minmax(0, 1fr); gap: 0.65rem; align-items: start; line-height: 1.55; font-size: 0.95rem; }
.onboarding-body .steps li::before {
  counter-increment: step; content: counter(step);
  width: 1.8rem; height: 1.8rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 0.9rem;
}
.onboarding-body .steps b { font-weight: 600; }
.onboarding-body .ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem; vertical-align: middle;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg); color: var(--accent-dark); margin-inline: 0.15rem;
}
.onboarding-body .ico svg { width: 0.95rem; height: 0.95rem; }
.onboarding-body .note { margin: 0; font-size: 0.85rem; color: var(--muted); line-height: 1.5; }
.onboarding-actions { display: flex; gap: 0.6rem; }
.onboarding-actions button {
  flex: 1; padding: 0.75rem; border-radius: 12px;
  font-family: inherit; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.onboarding-done { border: none; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; }
.onboarding-later { border: 1.5px solid var(--border); background: var(--panel); color: var(--text); }
@media (prefers-reduced-motion: reduce) {
  .onboarding-backdrop, .onboarding-sheet { transition: none; }
}

/* Guided tour (tour.js): dark overlay with one lit-up spot and a bubble */
.tour { position: fixed; inset: 0; z-index: 60; }
.tour-catch { position: absolute; inset: 0; }
.tour-spot {
  position: fixed;
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(40, 26, 34, 0.68);
  outline: 2px solid rgba(255, 255, 255, 0.9);
  pointer-events: none;
  transition: top 0.3s ease, left 0.3s ease, width 0.3s ease, height 0.3s ease, opacity 0.2s ease;
}
.tour-tip {
  position: fixed;
  inset-inline: 1rem;
  max-width: 380px;
  margin-inline: auto;
  background: var(--panel);
  border-radius: 18px;
  padding: 1rem 1.1rem 0.9rem;
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 0.45rem;
  transition: top 0.3s ease, opacity 0.2s ease;
}
.tour.busy .tour-tip { opacity: 0.4; }
.tour-top { display: flex; justify-content: space-between; align-items: center; }
.tour-count { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.tour-skip { border: 0; background: none; color: var(--muted); font-family: inherit; font-size: 0.85rem; cursor: pointer; padding: 0.2rem 0.3rem; }
.tour-title { margin: 0; font-size: 1.1rem; color: var(--accent-dark); }
.tour-text { margin: 0; line-height: 1.6; font-size: 0.95rem; }
.tour-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 0.35rem; }
.tour-dots { display: flex; gap: 0.3rem; }
.tour-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.tour-dots span.on { background: var(--accent); width: 18px; border-radius: 4px; }
.tour-btns { display: flex; gap: 0.45rem; }
.tour-btns button {
  padding: 0.55rem 1.1rem; border-radius: 10px;
  font-family: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer;
}
.tour-next { border: none; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; }
.tour-prev { border: 1.5px solid var(--border); background: var(--panel); color: var(--text); }
.tour-btns button:focus-visible, .tour-skip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .tour-spot, .tour-tip { transition: none; }
}

/* Onboarding: in-app browser warning + Android one-tap install */
.onboarding-install {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  width: 100%; padding: 0.9rem; border: none; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff;
  font-family: inherit; font-size: 1.05rem; font-weight: 600; cursor: pointer;
}
.onboarding-or { margin: 0; text-align: center; font-size: 0.85rem; color: var(--muted); }
.onboarding-alert {
  background: #fdf3df; color: #6e4f12; border-radius: 12px;
  padding: 0.75rem 0.9rem; font-size: 0.92rem; line-height: 1.55;
}
.onboarding-alert b { font-weight: 600; }
.copy-link {
  display: flex; gap: 0.5rem; align-items: center;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 0.4rem 0.4rem 0.4rem 0.7rem;
}
.copy-link code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; direction: ltr; font-size: 0.85rem; }
.copy-link button {
  flex-shrink: 0; border: none; border-radius: 8px; padding: 0.45rem 0.8rem;
  background: var(--accent); color: #fff; font-family: inherit; font-weight: 600; cursor: pointer;
}
/* The tour button is a <button> styled as a topbar link, not as the main CTA. */
.topbar .tour-btn {
  border: 0; background: none; box-shadow: none; transform: none; filter: none;
  color: var(--muted); padding: 0.45rem 0.75rem; font-size: 0.85rem; font-weight: 600;
}
.topbar .tour-btn:hover { background: var(--accent-light); color: var(--accent-dark); transform: none; box-shadow: none; }
@media (max-width: 600px) { .topbar .tour-btn { padding: 0.5rem; } }
.onboarding-sheet > *, .onboarding-body > * { min-width: 0; }

/* Load error with a retry button (app.js / stats.js) */
.load-error { text-align: center; padding: 2rem 1rem; display: grid; gap: 0.8rem; justify-items: center; }
.load-error p { margin: 0; color: var(--muted); }
.retry-btn {
  padding: 0.6rem 1.4rem; border: none; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff;
  font-family: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer;
}

/* In-page "are you sure?" for deleting a client */
.delete-confirm {
  flex-basis: 100%;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem;
  background: #fbeae8; border-radius: 12px; padding: 0.7rem 0.9rem;
}
.delete-confirm p { margin: 0; color: #8a2f22; font-weight: 500; font-size: 0.92rem; }
.delete-confirm div { display: flex; gap: 0.5rem; }
.form-actions .delete-confirm button { padding: 0.5rem 1rem; }
@media (min-width: 601px) { .form-actions { flex-wrap: wrap; } }
/* Phones: in an open card the date is already shown in the list, so give
   its space to the name. */
@media (max-width: 600px) { .client-card.selected .card-date { display: none; } }

/* ---------- Visit summaries (summary.js) ---------- */
.summary-hint { margin: 0 0 0.75rem; font-size: 0.88rem; }
.summary-list { display: grid; gap: 0.5rem; margin-bottom: 0.75rem; }
.summary-empty { margin: 0; font-size: 0.88rem; }
.summary-item {
  display: grid; gap: 0.15rem; text-align: right;
  padding: 0.65rem 0.85rem; border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); font-family: inherit; color: var(--text); cursor: pointer;
}
.summary-item:hover { border-color: var(--accent); background: var(--accent-light); }
.summary-item-date { font-weight: 600; font-size: 0.92rem; }
.summary-item-text { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

body.summary-open { overflow: hidden; }
.summary-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(40, 26, 34, 0.55);
  display: grid; place-items: center;
  padding: 1rem;
}
.summary-panel {
  width: 100%; max-width: 1100px; max-height: 100%;
  background: var(--bg); border-radius: 20px; box-shadow: var(--shadow-lg);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden;
}
.summary-head { display: flex; justify-content: space-between; align-items: center; padding: 0.9rem 1.2rem; background: var(--panel); border-bottom: 1px solid var(--border); }
.summary-head h2 { margin: 0; font-size: 1.15rem; color: var(--accent-dark); }
.summary-close { border: 0; background: var(--bg); width: 2.2rem; height: 2.2rem; border-radius: 50%; font-size: 1rem; cursor: pointer; color: var(--muted); }
.summary-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1.2rem; padding: 1.2rem; overflow-y: auto; }
.summary-controls { display: grid; gap: 1rem; align-content: start; }
.summary-field { display: grid; gap: 0.35rem; }
.summary-field > span { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.summary-field input, .summary-field textarea {
  padding: 0.6rem 0.75rem; border: 1.5px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 1rem; background: var(--panel); color: var(--text); resize: vertical;
}
.summary-field input:focus, .summary-field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.summary-field small { font-size: 0.8rem; }
.summary-include { border: 1px solid var(--border); border-radius: 12px; padding: 0.6rem 0.9rem 0.8rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1.1rem; background: var(--panel); }
.summary-include legend { font-size: 0.85rem; color: var(--muted); font-weight: 600; padding: 0 0.3rem; }
.summary-include label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.95rem; cursor: pointer; }
.summary-include input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.summary-settings-link { color: var(--accent-dark); font-size: 0.9rem; font-weight: 500; justify-self: start; }
.summary-preview { align-self: start; }
.summary-preview canvas, .settings-preview canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 1240 / 1754;
  border-radius: 6px; background: #fff; box-shadow: var(--shadow-md);
}
.summary-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.85rem 1.2rem calc(0.85rem + env(safe-area-inset-bottom, 0px)); background: var(--panel); border-top: 1px solid var(--border); }
.summary-actions button {
  padding: 0.65rem 1.2rem; border-radius: 10px; font-family: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--panel); color: var(--text);
}
.summary-actions .summary-share { border: none; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; }
.summary-actions .summary-delete { border-color: #e6c3bc; color: #a8432b; margin-inline-start: auto; }
.summary-status { font-size: 0.88rem; }
@media (max-width: 760px) {
  .summary-overlay { padding: 0; }
  .summary-panel { border-radius: 0; height: 100%; max-height: none; }
  .summary-body { grid-template-columns: minmax(0, 1fr); padding: 1rem; }
  .summary-actions button { flex: 1 1 auto; }
  .summary-actions .summary-delete { margin-inline-start: 0; }
  .summary-status { flex-basis: 100%; text-align: center; }
}

/* ---------- Settings page (settings.js) ---------- */
.settings { max-width: 1000px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr); gap: 1.2rem 1.5rem; align-items: start; }
.settings-intro, .settings-actions { grid-column: 1 / -1; }
.settings-intro h2 { margin: 0 0 0.3rem; font-size: 1.35rem; }
.settings-intro p { margin: 0; }
.settings-grid { display: grid; gap: 1rem; }
.settings-grid .form-section { margin: 0; }
.settings-preview { position: sticky; top: 1rem; display: grid; gap: 0.6rem; }
.settings-preview h3 { margin: 0; font-size: 0.95rem; color: var(--muted); font-weight: 600; }
.settings-actions { display: flex; align-items: center; gap: 1rem; }
.logo-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.logo-box { width: 120px; height: 120px; border-radius: 16px; border: 1.5px dashed var(--border); background: #fff; display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.logo-box img { max-width: 88%; max-height: 88%; object-fit: contain; }
.logo-actions { display: grid; gap: 0.4rem; justify-items: start; min-width: 0; }
.logo-upload { cursor: pointer; }
.link-btn { border: 0; background: none; padding: 0.2rem 0; color: var(--accent-dark); font-family: inherit; font-size: 0.9rem; cursor: pointer; text-decoration: underline; }
.small { font-size: 0.82rem; margin: 0; }
.color-row { display: flex; flex-wrap: wrap; gap: 1rem 2rem; margin-bottom: 0.6rem; }
.color-field { display: flex; align-items: center; gap: 0.7rem; cursor: pointer; line-height: 1.3; }
.color-field input[type="color"] { width: 3rem; height: 3rem; border: 1.5px solid var(--border); border-radius: 12px; padding: 0.2rem; background: var(--panel); cursor: pointer; }
@media (max-width: 760px) {
  .settings { grid-template-columns: minmax(0, 1fr); padding: 0 1rem; }
  .settings-preview { position: static; }
}
.settings .form-section-title { cursor: default; }
.settings .form-section-title::after { display: none; }

/* Save state next to the name in an open card, and the "not sent yet" banner */
.header-save { font-size: 0.75rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.header-save[data-state="saved"] { color: #2c6e42; }
.header-save[data-state="offline"], .header-save[data-state="login"] { color: #a8432b; }
.sync-banner {
  max-width: 720px; margin: 0 auto 0.75rem;
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  background: #fdf3df; color: #6e4f12; border-radius: 12px; padding: 0.65rem 0.9rem;
  font-size: 0.9rem; line-height: 1.5;
}
.sync-banner span { flex: 1; min-width: 12rem; }
.sync-banner button {
  border: 1px solid #e3cf9c; background: #fff; color: #6e4f12; border-radius: 999px;
  padding: 0.35rem 0.9rem; font-family: inherit; font-weight: 600; cursor: pointer;
}
@media (max-width: 600px) { .sync-banner { margin: 0 1rem 0.6rem; } }
