/* Cambium Therapies practice manager. Matches the website's colours; system fonts so it works offline. */
:root {
  --bg: #F2F0EB; --card: #FAFAF7; --line: #DDE5DF; --ink: #1C2820; --soft: #3D4E42; --muted: #667869;
  --deep: #152E24; --accent: #234F3D; --accent-dark: #3D7560; --alert-bg: #F8F1E6; --ok: #3D7560; --gold: #B89A6A;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 17px; line-height: 1.45; }
a { color: var(--accent); }
h1, h2, h3 { color: var(--deep); margin: 0; }
h2 { font-family: var(--serif); font-size: 20px; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.card h2 { margin-top: 0; }
h3 { font-size: 16px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.error { color: #A1291A; font-weight: 600; margin: 0; }
.count { font-family: var(--sans); font-size: 13px; font-weight: 700; background: var(--deep); color: #fff; border-radius: 999px; padding: 1px 9px; }

/* Lock screen */
.lock { max-width: 440px; margin: 0 auto; padding: max(48px, env(safe-area-inset-top)) 20px 40px; display: flex; flex-direction: column; gap: 14px; }
.lock-logo { height: 72px; width: auto; align-self: flex-start; }
.lock h1 { font-family: var(--serif); font-size: 30px; }
.lock p { margin: 0; color: var(--soft); }
.lock form { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.warn { background: var(--alert-bg); border: 1px solid #D4BC94; border-radius: 12px; padding: 12px 14px; font-size: 15px; color: var(--soft); }

/* Top bar and tabs */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: rgba(242, 240, 235, 0.96); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top h1 { flex: 1; font-family: var(--serif); font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-logo { height: 32px; width: auto; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; border: 0; background: none; font-size: 24px; color: var(--deep); text-decoration: none; cursor: pointer; padding: 0 4px; }
.sync { border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 999px; font-size: 13px; padding: 4px 10px; cursor: pointer; }
.sync:empty { display: none; }
.sync.synced { color: var(--ok); }
.sync.error { color: #A1291A; border-color: #E5B9A6; }
.content { max-width: 760px; margin: 0 auto; padding: 14px 14px calc(96px + env(safe-area-inset-bottom)); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; text-align: center; padding: 14px 0; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 15px; }
.tabs a.on { color: var(--deep); box-shadow: inset 0 3px 0 var(--gold); }

/* Lists */
.list { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); min-height: 60px; }
.row:last-child { border-bottom: 0; }
.row:active { background: #E4EDE8; }
.row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-main small { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side { color: var(--muted); font-size: 14px; text-align: right; white-space: nowrap; }
.unpaid { color: #9A5B2E; font-style: normal; font-weight: 700; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.toolbar input { flex: 1; }
.empty { text-align: center; padding: 40px 10px; color: var(--soft); }

/* Cards and details */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.alerts { display: flex; flex-wrap: wrap; gap: 6px; }
.alerts span { background: var(--alert-bg); border: 1px solid #D4BC94; color: #7A5A2E; border-radius: 999px; padding: 3px 10px; font-size: 14px; font-weight: 600; }
.details { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.details dt { color: var(--muted); font-size: 15px; }
.details dd { margin: 0; }
.notes { white-space: pre-wrap; margin: 0; color: var(--soft); }
.big { font-family: var(--serif); font-size: 32px; color: var(--deep); margin: 0; }

/* Forms */
.form .card { gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 15px; color: var(--soft); }
.field em { font-weight: 400; font-style: normal; color: var(--muted); }
.label { margin: 0; font-weight: 600; font-size: 15px; color: var(--soft); }
input[type=text], input[type=tel], input[type=email], input[type=date], input[type=number], input[type=password], input[type=search], textarea, select {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid #B9C7BE; border-radius: 10px; font: inherit; font-size: 17px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus, .btn:focus-visible { outline: 3px solid #9EBFB0; outline-offset: 1px; }
textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 12px; border: 1px solid #B9C7BE; border-radius: 10px; background: #fff; font-size: 16px; cursor: pointer; }
.choice.wide { width: 100%; }
.choice input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--deep); }
.choice:has(input:checked) { border-color: var(--accent); background: #E4EDE8; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 20px; border-radius: 999px; border: 0; background: var(--accent); color: #fff; font: inherit; font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--accent-dark); color: #fff; }
.btn:disabled { opacity: 0.6; }
.btn.ghost { background: transparent; color: var(--deep); border: 1px solid #B9C7BE; }
.btn.danger { background: transparent; color: #A1291A; border: 1px solid #E5B9A6; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions.sticky { position: sticky; bottom: calc(60px + env(safe-area-inset-bottom)); background: var(--bg); padding: 10px 0; }
.actions.sticky .btn:first-child { flex: 1; }

[hidden] { display: none !important; }
.small { font-size: 14px; margin: 0; }
.row-time { min-width: 52px; font-weight: 700; color: var(--deep); font-variant-numeric: tabular-nums; }
.tag { font-size: 12px; font-weight: 700; background: #EEF3F1; color: var(--deep); border-radius: 6px; padding: 1px 6px; vertical-align: 2px; }
h2 small { font-family: var(--sans); font-size: 14px; font-weight: 400; }
input[type=time] { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid #B9C7BE; border-radius: 10px; font: inherit; font-size: 17px; background: #fff; color: var(--ink); }

/* Medical history, logs, signature */
.pre { white-space: pre-wrap; }
.log { margin: 0; padding-left: 18px; color: var(--soft); }
.log li { margin: 4px 0; }
.ok { color: var(--ok); font-weight: 700; }
.warn .list { margin-top: 8px; }
.sig { position: relative; border: 1px solid #B9C7BE; border-radius: 12px; background: #fff; }
.sig canvas { display: block; width: 100%; height: auto; aspect-ratio: 3 / 1; touch-action: none; border-radius: 12px; cursor: crosshair; }
.sig::after { content: "Sign here"; position: absolute; left: 14px; bottom: 10px; color: #B9B1A3; font-size: 14px; pointer-events: none; }
.sig.signed::after { content: ""; }
.sig-clear { position: absolute; top: 6px; right: 6px; min-height: 34px; padding: 4px 12px; font-size: 14px; background: #fff; }
.sig-svg { display: block; width: 60mm; max-width: 100%; height: auto; }
.sig-svg polyline { fill: none; stroke: #1F2E2C; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.sig-svg circle { fill: #1F2E2C; }

.pad { padding: 14px; margin: 0; }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--deep); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 600; z-index: 20; }

@media (min-width: 700px) {
  .content { padding-top: 22px; }
}

/* Printing a patient record: only the #print area is printed. */
#print { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
  #app, .toast { display: none !important; }
  #print { display: block; color: #1F2E2C; font-family: Arial, Helvetica, sans-serif; }
  .p-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2pt solid #234F3D; padding-bottom: 6pt; margin-bottom: 10pt; }
  .p-brand { font-family: Georgia, serif; font-weight: bold; color: #234F3D; }
  .p-head h1 { font-family: Georgia, serif; font-size: 20pt; color: #234F3D; }
  .p-meta { text-align: right; font-size: 9pt; color: #5A6B68; }
  .p-table { width: 100%; border-collapse: collapse; margin-bottom: 8pt; }
  .p-table th, .p-table td { text-align: left; vertical-align: top; padding: 3pt 5pt; border-bottom: 0.5pt solid #D5CFC4; font-size: 10pt; }
  .p-table th { width: 32%; color: #3E4F4C; font-weight: normal; }
  .p-alerts { border: 1.5pt solid #B89A6A; background: #F8F1E6; padding: 6pt 8pt; margin: 8pt 0; font-size: 10pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print h2 { font-family: Georgia, serif; font-size: 14pt; border-bottom: 1.5pt solid #234F3D; margin: 14pt 0 6pt; display: block; }
  .p-visit { margin-bottom: 10pt; }
  .p-visit h3 { font-size: 11pt; margin: 10pt 0 3pt; break-after: avoid; }
  .p-table tr { break-inside: avoid; }
  .p-table td { white-space: pre-line; }
  /* Letters and receipts */
  .l-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2pt solid #234F3D; padding-bottom: 8pt; margin-bottom: 16pt; font-size: 10pt; color: #3E4F4C; }
  .l-brand { font-family: Georgia, serif; font-size: 20pt; font-weight: bold; color: #234F3D; }
  .l-contact { text-align: right; line-height: 1.5; }
  .l-body { font-size: 11pt; line-height: 1.5; }
  .l-body p { margin: 0 0 10pt; }
  .l-date { text-align: right; }
  .l-to { margin-bottom: 14pt !important; }
  .l-urgent { font-weight: bold; color: #234F3D; letter-spacing: 0.04em; }
  .l-urgent.soon { letter-spacing: 0; }
  .l-findings { white-space: pre-line; border-left: 2pt solid #E3DDD2; padding-left: 8pt; }
  .l-sign { margin-top: 18pt !important; }
  .r-title { font-family: Georgia, serif; font-size: 22pt; color: #234F3D; margin: 0 0 10pt; }
  .r-table th { width: 30%; }
  .p-notes, .l-findings-plain { white-space: normal; }
  .p-notes { margin: 2pt 0 4pt; font-size: 10pt; }
  .p-pay { margin: 0; font-size: 9pt; color: #5A6B68; }
  .p-foot { margin-top: 14pt; font-size: 8.5pt; color: #5A6B68; }
}

/* Tasks */
.tabs .badge { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: #fff; font-size: 12px; line-height: 20px; }
.row.task .row-main { text-decoration: none; color: inherit; }
.row.task.done b { text-decoration: line-through; color: var(--muted); }
.tick { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #9EBFB0; background: #fff; color: #fff; font-weight: 700; cursor: pointer; }
.row.task.done .tick { background: var(--ok); border-color: var(--ok); }
.row.stacked { flex-direction: column; align-items: stretch; gap: 10px; }
.row.stacked .row-main { text-decoration: none; color: inherit; }
.row.stacked .btn { min-height: 42px; padding: 8px 16px; font-size: 15px; }
a.list { text-decoration: none; color: inherit; }
