/* Kraft Clinic — styles
   --brand is replaced by each clinic's own colour after login */
:root {
  --brand: #0F766E;
  --brand-ink: #FFFFFF;
  --ink: #16232A;
  --muted: #566870;
  --line: #D8E0DE;
  --paper: #F3F6F5;
  --surface: #FFFFFF;
  --danger: #B42318;
  --danger-bg: #FDECEA;
  --pending: #B45309;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.muted { color: var(--muted); }

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
}
.login-brand {
  position: relative;
  overflow: hidden;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 56px;
  display: flex;
  align-items: flex-end;
}
.login-brand-inner { position: relative; z-index: 1; max-width: 26rem; }
.wordmark {
  font-size: clamp(3.5rem, 7vw, 6rem);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.03em;
}
.tagline { margin-top: 24px; font-size: 1.125rem; max-width: 22rem; opacity: 0.92; }
.slots {
  position: absolute;
  top: 40px;
  right: 48px;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: right;
  font-variant-numeric: tabular-nums;
  line-height: 2.2;
  opacity: 0.38;
}
.slots .booked { opacity: 1; font-weight: 700; }
.slots .booked::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 10px; vertical-align: middle; }

.login-form-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 48px 24px;
  background: var(--surface);
}
.login-form { width: 100%; max-width: 24rem; display: flex; flex-direction: column; }
.login-form h1 { font-size: 1.75rem; line-height: 1.2; }
.login-form .muted { margin: 8px 0 20px; }
.login-form label { font-weight: 700; font-size: 0.9375rem; margin: 16px 0 6px; }
.login-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  font-size: 1rem;
}
.login-form input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18); }
.pw { position: relative; }
.pw input { padding-right: 76px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; padding: 6px 10px; cursor: pointer;
  color: var(--brand); font-weight: 700; border-radius: var(--radius-s);
}
.login-form .btn-primary { margin-top: 28px; padding: 13px 18px; }
.btn-primary {
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius-s);
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.help { margin-top: 20px; font-size: 0.9375rem; color: var(--muted); }
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-s);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.9375rem;
}
.powered { margin-top: 48px; font-size: 0.875rem; color: var(--muted); }

@media (max-width: 820px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 32px 24px; }
  .wordmark { font-size: 3rem; }
  .tagline { margin-top: 12px; font-size: 1rem; }
  .slots { display: none; }
  .login-form-wrap { justify-content: flex-start; padding-top: 32px; }
}

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px; border-bottom: 1px solid var(--line); }
.brand-mark {
  flex: none; width: 40px; height: 40px; border-radius: var(--radius-m);
  background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 700;
}
.brand-logo { flex: none; width: 40px; height: 40px; object-fit: contain; border-radius: var(--radius-s); }
.brand-name { font-weight: 700; line-height: 1.25; }
.brand-sub { font-size: 0.8125rem; color: var(--muted); }
.sidebar nav { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: block; padding: 10px 12px; border-radius: var(--radius-s); color: var(--ink); text-decoration: none; }
.nav-link:hover { background: var(--paper); }
.nav-link[aria-current="page"] {
  background: var(--paper);
  color: var(--brand);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--brand);
}
.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 16px 20px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
}
.who { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.who strong { overflow-wrap: anywhere; }
.who span { font-size: 0.8125rem; color: var(--muted); }
.btn-quiet {
  border: 1.5px solid var(--line); background: var(--surface);
  padding: 7px 12px; border-radius: var(--radius-s);
  cursor: pointer; font-size: 0.875rem; font-weight: 700; white-space: nowrap;
}
.btn-quiet:hover { border-color: var(--ink); }

.main-wrap { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 32px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.topbar h1 { font-size: 1.5rem; line-height: 1.2; flex: 1; }
.today { color: var(--muted); font-size: 0.9375rem; }
.menu-btn { display: none; }
main { padding: 32px; max-width: 72rem; width: 100%; }
main:focus { outline: none; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 24px; margin-bottom: 20px; }
.panel h2 { font-size: 1.125rem; margin-bottom: 8px; }
.panel-plain { background: transparent; }
.lead { font-size: 1.125rem; max-width: 40rem; }
.status { margin-top: 12px; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.status-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--pending); }
.access-list { margin: 8px 0 0; padding-left: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); margin-top: 4px; }
.error-text { color: var(--danger); }

.scrim { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: 280px; height: auto; z-index: 20;
    transform: translateX(-100%); transition: transform 0.2s ease;
  }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(22, 35, 42, 0.25); }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(22, 35, 42, 0.4); z-index: 10; }
  .menu-btn {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 40px; height: 40px; padding: 0 10px; cursor: pointer;
    border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface);
  }
  .menu-btn span { display: block; height: 2px; background: var(--ink); border-radius: 1px; }
  .topbar { padding: 14px 16px; }
  .topbar h1 { font-size: 1.25rem; }
  .today { display: none; }
  main { padding: 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* =====================================================================
   Week 2 — shared controls
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-s); font-weight: 700; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn.btn-quiet { padding: 9px 14px; font-size: 0.9375rem; }
.btn-sm, .btn.btn-sm { padding: 6px 10px; font-size: 0.875rem; }
.btn-icon { width: 40px; padding: 0 !important; font-size: 1.375rem; line-height: 1; height: 40px; }
.btn-danger-quiet {
  border: 1.5px solid #F0C4BF; background: var(--surface); color: var(--danger);
  padding: 9px 14px; font-size: 0.9375rem;
}
.btn-danger-quiet:hover { border-color: var(--danger); }

select, input[type="date"], input[type="time"], input[type="search"], .field input, .field select, .field textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--radius-s);
  padding: 9px 12px; min-height: 40px;
}
.field input, .field select, .field textarea { width: 100%; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18); }
textarea { resize: vertical; }

.small { font-size: 0.875rem; }
.hint { font-size: 0.8125rem; color: var(--muted); margin-top: 4px; }
.prewrap { white-space: pre-wrap; }
.mt { margin-top: 20px; }
.empty, .empty-block { color: var(--muted); }
.empty-block { padding: 32px 0; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 20px; }
.toolbar .search { flex: 1 1 280px; }
.toolbar > .btn-primary { margin-left: auto; }

/* table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.panel .table-wrap { border: 0; border-radius: 0; margin: 0 -24px -24px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { font-size: 0.875rem; color: var(--muted); font-weight: 700; background: var(--paper); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFBFB; }
.row-link { color: var(--ink); font-weight: 700; text-decoration: none; }
.row-link:hover { color: var(--brand); text-decoration: underline; }
#p-count { margin-top: 10px; }

/* status badges — colour always paired with the word */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.8125rem; font-weight: 700; white-space: nowrap; }
.badge-booked { background: #E8EEF6; color: #2F4A6D; }
.badge-waiting { background: #FEF3C7; color: #8A4B08; }
.badge-in_consultation { background: #DDF1EE; color: #0B5E57; }
.badge-completed { background: #E3F4E6; color: #22643A; }
.badge-cancelled { background: #EEF0F0; color: #5B6B73; }
.badge-no_show { background: #FDECEA; color: #9B1C12; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-booked { background: #5B7BA6; }
.dot-waiting { background: #D97706; }
.dot-in_consultation { background: #0F766E; }
.dot-completed { background: #2F855A; }
.dot-cancelled { background: #A0ACB1; }
.dot-no_show { background: #C0392B; }

/* modal */
.modal {
  border: 0; padding: 0; border-radius: var(--radius-m);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  box-shadow: 0 24px 60px rgba(22, 35, 42, 0.3); color: var(--ink);
}
.modal-wide { width: min(760px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(22, 35, 42, 0.45); }
.modal-form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.25rem; }
.icon-btn { border: 0; background: none; font-size: 1.75rem; line-height: 1; cursor: pointer; padding: 0 6px; border-radius: var(--radius-s); color: var(--muted); }
.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); background: var(--paper); }
.form-error { margin: 0 24px 16px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--danger-bg); color: var(--danger); font-size: 0.9375rem; }

.field { display: flex; flex-direction: column; margin-bottom: 14px; min-width: 0; }
.field label, .field .label { font-weight: 700; font-size: 0.9375rem; margin-bottom: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.span-2 { grid-column: span 2; }

/* patient picker in booking */
.picker { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.picker input { width: 100%; }
.picker-results { list-style: none; margin: 0; padding: 0; width: 100%; }
.picker-results:empty { display: none; }
.picker-results li { border-bottom: 1px solid var(--line); }
.picker-results li.muted { padding: 10px 4px; border: 0; }
.picker-item { width: 100%; text-align: left; border: 0; background: none; padding: 10px 8px; cursor: pointer; border-radius: var(--radius-s); }
.picker-item:hover, .picker-item:focus-visible { background: var(--paper); }
.chip-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chip { padding: 8px 14px; border-radius: var(--radius-s); background: var(--paper); border: 1.5px solid var(--brand); }
.subpanel { border: 1.5px dashed var(--line); border-radius: var(--radius-m); padding: 14px 14px 12px; }
.subpanel .hint { margin: -6px 0 10px; }

/* toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--radius-s); font-size: 0.9375rem; box-shadow: 0 8px 24px rgba(22, 35, 42, 0.25); }
.toast-error { background: var(--danger); }

/* =====================================================================
   Patients
   ===================================================================== */
.crumb { margin-bottom: 12px; }
.crumb a { color: var(--brand); font-weight: 700; }
.patient-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.patient-name { font-size: 1.625rem !important; line-height: 1.2; margin-bottom: 4px !important; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.allergy { background: var(--danger-bg); color: var(--danger); border-left: 4px solid var(--danger); padding: 12px 16px; border-radius: var(--radius-s); margin-bottom: 20px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; }

/* =====================================================================
   Appointments
   ===================================================================== */
.date-nav { display: flex; align-items: center; gap: 6px; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 8px 14px; cursor: pointer; font-weight: 700; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.day-heading { font-size: 1.25rem; margin-bottom: 2px; }
.summary { color: var(--muted); margin-bottom: 16px; min-height: 1.5em; }

.appt-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.appt {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) 190px auto;
  align-items: center; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.appt:last-child { border-bottom: 0; }
.appt-time { font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }
.appt-time span { display: block; font-weight: 400; font-size: 0.8125rem; color: var(--muted); }
.appt-name { font-weight: 700; font-size: 1.0625rem; color: var(--ink); text-decoration: none; }
.appt-name:hover { color: var(--brand); text-decoration: underline; }
.appt-status { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.wait { font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.appt-waiting .wait { color: #8A4B08; font-weight: 700; }
.appt-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.appt-cancelled .appt-name, .appt-no_show .appt-name { text-decoration: line-through; color: var(--muted); }
.appt-in_consultation { background: #F2FAF9; box-shadow: inset 4px 0 0 var(--brand); }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; min-width: 200px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: 0 12px 28px rgba(22, 35, 42, 0.16); padding: 6px; display: flex; flex-direction: column;
}
.menu-list button { text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: var(--radius-s); cursor: pointer; }
.menu-list button:hover { background: var(--paper); }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.week-day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); min-height: 180px; display: flex; flex-direction: column; }
.week-day.is-today { border-color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }
.week-head { border: 0; background: none; cursor: pointer; padding: 10px 12px; text-align: left; display: flex; align-items: baseline; gap: 8px; border-bottom: 1px solid var(--line); }
.week-head span { color: var(--muted); font-size: 0.875rem; }
.week-head strong { font-size: 1.25rem; }
.week-day ul { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.week-item { width: 100%; border: 0; background: none; cursor: pointer; text-align: left; padding: 6px; border-radius: var(--radius-s); display: grid; grid-template-columns: 8px auto; gap: 2px 6px; align-items: center; font-size: 0.875rem; }
.week-item:hover { background: var(--paper); }
.week-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.week-who { grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-none { padding: 6px; }

@media (max-width: 1100px) {
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .appt { grid-template-columns: 76px minmax(0, 1fr); gap: 8px 12px; padding: 14px 16px; }
  .appt-status { grid-column: 2; flex-direction: row; align-items: center; gap: 10px; }
  .appt-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .two-col { grid-template-columns: 1fr; }
  .toolbar > .btn-primary { margin-left: 0; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .week { grid-template-columns: 1fr; }
  .week-day { min-height: 0; }
  .date-nav { width: 100%; }
  .date-nav input { flex: 1; }
  .toolbar > * { flex: 1 1 auto; }
  .modal-body { padding: 16px; }
}

/* =====================================================================
   Week 3 — prescriptions, billing, documents
   ===================================================================== */
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.table tr.clickable { cursor: pointer; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0 !important; }
.rx-hint { margin: -4px 0 12px; }
.allergy-inline { margin: 12px 0 0; }
.list-btn { width: 100%; text-align: left; border: 0; background: none; padding: 2px 0; cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.list-btn:hover strong { color: var(--brand); text-decoration: underline; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400 !important; min-height: 40px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }

/* prescription form */
.rx-form .panel h2 { margin-bottom: 12px; }
.vitals { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0 12px; }
.med-row {
  display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr) 32px;
  gap: 0 10px; align-items: start;
}
.med-row .field { margin-bottom: 10px; }
.med-header { font-size: 0.8125rem; font-weight: 700; color: var(--muted); padding-bottom: 6px; }
.med-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.med-remove { margin-top: 4px; height: 36px; }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 3;
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
  padding: 14px 0; background: linear-gradient(to top, var(--paper) 75%, rgba(243, 246, 245, 0));
}
.rx-form > .form-error { margin: 0 0 12px; }

/* invoice form */
.bill-row { display: grid; grid-template-columns: minmax(0, 3fr) 80px 120px 110px 32px; gap: 0 10px; align-items: start; }
.bill-row .field { margin-bottom: 8px; }
.bill-header { font-size: 0.8125rem; font-weight: 700; color: var(--muted); padding-bottom: 6px; }
.bill-header span:nth-child(4) { text-align: right; }
.bill-amt { text-align: right; padding-top: 9px; font-variant-numeric: tabular-nums; font-weight: 700; }
.bill-summary { margin: 4px 0 18px auto; max-width: 320px; display: flex; flex-direction: column; gap: 6px; }
.bill-summary p { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.bill-summary input { width: 120px; text-align: right; font: inherit; padding: 7px 10px; border: 1.5px solid var(--line); border-radius: var(--radius-s); }
.bill-total { border-top: 1.5px solid var(--line); padding-top: 8px; font-size: 1.25rem; }
.pay-now { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 14px; border-radius: var(--radius-m); background: #FEF3C7; color: #6B3A06; }
.pay-now p { flex: 1 1 200px; }

/* document preview in dialogs */
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.doc-preview { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 24px; background: #fff; box-shadow: 0 2px 10px rgba(22, 35, 42, 0.06); }

/* the document itself (same look on screen and paper) */
.doc {
  color: #111; font-size: 13px; line-height: 1.45;
  /* standard font for paper documents: plain zeros, familiar look */
  font-family: Arial, "Helvetica Neue", "Segoe UI", sans-serif;
}
.doc p { margin: 0; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 10px; border-bottom: 2px solid var(--brand); }
.doc-clinic { display: flex; gap: 12px; align-items: center; }
.doc-logo { max-height: 56px; max-width: 120px; object-fit: contain; }
.doc-clinic-name { font-size: 1.6em; font-weight: 700; color: var(--brand); line-height: 1.15; margin-bottom: 2px !important; }
.doc-right { text-align: right; }
.doc-doctor { font-weight: 700; font-size: 1.15em; }
.doc-title { font-size: 1.5em; font-weight: 700; color: var(--brand); }
.doc-patient { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; background: #F3F6F5; padding: 8px 12px; margin: 12px 0; border-radius: 4px; }
.doc-vitals { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 8px; }
.doc-allergy { color: #B42318; margin-bottom: 8px !important; }
.doc-block { margin: 8px 0; }
.doc-block h3 { font-size: 0.9em; margin: 0 0 2px; color: #555; }
.doc-block p { white-space: pre-wrap; }
.doc-rx-mark { font-family: Georgia, "Times New Roman", serif; font-size: 2.2em; line-height: 1; margin: 10px 0 4px !important; color: var(--brand); }
.doc-table { width: 100%; border-collapse: collapse; margin: 6px 0 10px; }
.doc-table th, .doc-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #D5DCDA; vertical-align: top; }
.doc-table th { background: #F3F6F5; font-size: 0.9em; }
.doc-money tfoot td { border-bottom: 0; padding-top: 4px; padding-bottom: 4px; }
.doc-total td { font-weight: 700; font-size: 1.15em; border-top: 2px solid #111; }
.doc-words { font-style: italic; margin: 4px 0 !important; }
.doc-paid { margin: 6px 0 !important; }
.doc-follow { margin-top: 8px !important; }
.doc-muted { color: #666; }
.doc-foot { margin-top: 36px; display: flex; flex-direction: column; gap: 14px; }
.doc-sign { margin-left: auto; width: 200px; text-align: center; }
.doc-sign span { display: block; border-top: 1px solid #333; margin-bottom: 4px; }
.doc-gen { font-size: 0.8em; color: #777; text-align: center; }

#print-root { display: none; }
@media print {
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  html, body { background: #fff !important; }
  #print-root * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-root.doc-a5 .doc { font-size: 11px; padding: 9mm 9mm; }
  #print-root.doc-a4 .doc { font-size: 13px; padding: 14mm 14mm; }
  .doc-table tr { break-inside: avoid; }
}

@media (max-width: 900px) {
  .vitals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .med-header, .bill-header { display: none; }
  .med-row { grid-template-columns: 1fr 1fr 32px; border-bottom: 1px dashed var(--line); padding: 8px 0; }
  .med-row .field:first-child { grid-column: 1 / 3; }
  .med-row .med-remove { grid-column: 3; grid-row: 1; }
  .med-label, .bill-row .med-label { position: static; width: auto; height: auto; clip: auto; font-size: 0.8125rem !important; }
  .bill-row { grid-template-columns: 1fr 1fr 32px; border-bottom: 1px dashed var(--line); padding: 8px 0; }
  .bill-row .field:first-child { grid-column: 1 / 3; }
  .bill-row .med-remove { grid-column: 3; grid-row: 1; }
  .bill-amt { grid-column: 1 / 3; text-align: left; padding-top: 0; }
  .doc-patient { grid-template-columns: 1fr; }
  .doc-preview { padding: 14px; }
}
@media (max-width: 640px) {
  .vitals { grid-template-columns: 1fr 1fr; }
}

/* =====================================================================
   Week 4 — money, dashboard, reports
   ===================================================================== */
.money-in { color: #22643A; }
.money-out { color: #9B1C12; }
.stat-of { font-size: 1rem; font-weight: 400; color: var(--muted); }
.toolbar-end { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.custom-range { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inline-label { font-weight: 700; }
.dot-label { display: inline-flex; align-items: center; gap: 8px; }
.table tfoot td { border-top: 2px solid var(--line); border-bottom: 0; background: var(--paper); }

.notice { background: #FEF3C7; color: #6B3A06; padding: 12px 16px; border-radius: var(--radius-m); margin-bottom: 20px; }
.notice a { color: inherit; font-weight: 700; }
.panel-head a.small { color: var(--brand); font-weight: 700; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list li > :nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list a { color: var(--ink); font-weight: 700; text-decoration: none; }
.mini-list a:hover { color: var(--brand); text-decoration: underline; }
.mini-time { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 72px; font-size: 0.9375rem; }
.big-line { font-size: 1.5rem; margin-bottom: 8px; }
.big-line .muted { font-size: 1rem; }
.month-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.month-strip p { display: flex; flex-direction: column; }
.month-strip strong { font-size: 1.375rem; font-variant-numeric: tabular-nums; }

/* charts */
.chart { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-axis { font-size: 12px; fill: var(--muted); font-family: var(--font); }
.ch-legend { display: flex; gap: 18px; margin-bottom: 6px; font-size: 0.875rem; color: var(--muted); }
.ch-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.hbar-top { display: flex; justify-content: space-between; gap: 12px; }
.hbar-top strong { font-variant-numeric: tabular-nums; }
.hbar-track { height: 8px; background: var(--paper); border-radius: 4px; overflow: hidden; margin: 4px 0 2px; }
.hbar-track span { display: block; height: 100%; border-radius: 4px; }
.hbar-share { font-size: 0.8125rem; color: var(--muted); }

/* daily report */
.report-preview { max-width: 900px; }
.report-figures { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 14px 0; }
.report-figures p { display: flex; flex-direction: column; background: #F3F6F5; border-radius: 4px; padding: 8px 10px; }
.report-figures span { font-size: 0.85em; color: #555; }
.report-figures strong { font-size: 1.4em; }

@media (max-width: 900px) {
  .report-figures { grid-template-columns: repeat(3, 1fr); }
  .toolbar-end { margin-left: 0; }
}
@media (max-width: 640px) {
  .month-strip { grid-template-columns: 1fr; }
  .report-figures { grid-template-columns: repeat(2, 1fr); }
}
@media print {
  #print-root .report-figures { grid-template-columns: repeat(6, 1fr); }
}

/* =====================================================================
   Week 5 — super admin, settings, support
   ===================================================================== */
.form-section { font-size: 1rem; margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.modal-body .form-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.set-hint { margin: -4px 0 14px; }
.readonly { padding: 9px 0; font-weight: 700; }
.due-soon { color: #8A4B08; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.colour-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; padding: 0; }
.swatch.is-on { box-shadow: 0 0 0 2.5px var(--ink); }
.swatch-custom { display: inline-flex; align-items: center; gap: 6px; font-weight: 400 !important; margin: 0 0 0 6px !important; font-size: 0.9375rem; }
.swatch-custom input[type="color"] { width: 40px; height: 34px; padding: 2px; border: 1.5px solid var(--line); border-radius: var(--radius-s); background: var(--surface); cursor: pointer; }

.logo-field { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.logo-preview { width: 88px; height: 88px; border: 1.5px dashed var(--line); border-radius: var(--radius-m); display: grid; place-items: center; overflow: hidden; background: var(--surface); flex: none; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-field input[type="file"] { font: inherit; font-size: 0.9375rem; max-width: 100%; }

.clinic-cell { display: flex; align-items: center; gap: 12px; }
.clinic-cell img { width: 36px; height: 36px; object-fit: contain; border-radius: var(--radius-s); flex: none; }
.clinic-cell > span:last-child { display: flex; flex-direction: column; }
.brand-mark.sm { width: 36px; height: 36px; font-size: 0.9375rem; border-radius: var(--radius-s); color: #fff; flex: none; }

.pw-row { display: flex; gap: 8px; align-items: center; }
.pw-row input { flex: 1; font-variant-numeric: tabular-nums; }
.creds { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 14px; font-family: ui-monospace, Consolas, monospace; font-size: 0.9375rem; white-space: pre-wrap; word-break: break-all; margin: 12px 0; }
.reset-box { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.reset-box summary { cursor: pointer; font-weight: 700; color: var(--brand); margin-bottom: 10px; }

.ticket-body { white-space: pre-wrap; background: var(--paper); border-radius: var(--radius-s); padding: 12px 14px; margin: 10px 0 16px; }
.ticket-list { list-style: none; margin: 0; padding: 0; }
.ticket-list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.ticket-list li:last-child { border-bottom: 0; }
.ticket-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.ticket-reply { margin-top: 8px; padding: 10px 12px; border-left: 3px solid var(--brand); background: var(--paper); border-radius: 0 var(--radius-s) var(--radius-s) 0; }

.sub-banner { background: #FEF3C7; color: #6B3A06; padding: 10px 32px; border-bottom: 1px solid #F3D98B; }
.sub-banner a { color: inherit; font-weight: 700; }
.sub-banner-soft { background: #EEF4F3; color: var(--ink); border-bottom-color: var(--line); }
@media (max-width: 900px) { .sub-banner { padding: 10px 16px; } }

/* Kraft Media logo */
.login-logo { width: 200px; height: auto; margin: 0 0 20px -6px; }
.brand-logo-km { background: #fff; border: 1px solid var(--line); padding: 2px; }

/* =====================================================================
   Week 6 — WhatsApp, share page, privacy policy
   ===================================================================== */
.btn-whatsapp { background: #1F8F4E; color: #fff; border: 0; padding: 9px 14px; font-size: 0.9375rem; }
.btn-whatsapp:hover { background: #197A42; }
.powered a { color: inherit; }

.share-page { background: var(--paper); }
#share { max-width: 860px; margin: 0 auto; padding: 16px 12px 40px; }
.share-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.share-bar p { display: flex; flex-direction: column; }
.share-bar span { color: var(--muted); font-size: 0.9375rem; }
.share-doc { overflow-x: auto; }
.share-doc .doc { min-width: 560px; }
.share-note { color: var(--muted); font-size: 0.875rem; margin-top: 12px; }
.share-message { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 28px; margin-top: 40px; text-align: center; }
.share-message h1 { font-size: 1.375rem; margin-bottom: 8px; }

.legal-page { background: var(--surface); }
.legal { max-width: 760px; margin: 0 auto; padding: 40px 20px 64px; }
.legal-logo { width: 160px; height: auto; margin-bottom: 20px; }
.legal h1 { font-size: 2rem; margin-bottom: 4px; }
.legal h2 { font-size: 1.1875rem; margin: 28px 0 8px; }
.legal p, .legal li { margin-bottom: 8px; }
.legal ul { padding-left: 22px; margin: 0 0 8px; }
.legal a { color: var(--brand); }
.wa-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.wa-result { margin-bottom: 6px; }
.wa-connect-intro { margin: 10px 0 14px; max-width: 46rem; }
.wa-connect { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 10px; }
.wa-option { border: 1.5px solid var(--line); border-radius: var(--radius-m); padding: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.wa-option h3 { font-size: 1rem; margin: 0; }
.wa-option p { flex: 1; }
.notice-ok { background: #E3F4E6; color: #1C4D2C; padding: 14px 16px; border-radius: var(--radius-m); margin-top: 10px; }
.notice-ok ul { margin: 6px 0; }
.notice-ok li { border: 0; padding: 3px 0; }
@media (max-width: 640px) { .wa-connect { grid-template-columns: 1fr; } }
.usage-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 8px; }
.usage-strip p { display: flex; flex-direction: column; background: var(--paper); border-radius: var(--radius-s); padding: 10px 12px; }
.usage-strip strong { font-size: 1.375rem; font-variant-numeric: tabular-nums; }
.wa-usage-period { min-height: 34px; padding: 5px 10px; }
#wa-usage .table-wrap { margin: 0 -24px 14px; border-bottom: 1px solid var(--line); }
