/* Asanias Polyclinic: palette, type scale and layout tokens.
   Green and gold come from the clinic logo (the green A and the gold caduceus). */
:root {
  --ink: #14231b;
  --paper: #f3f6f2;
  --surface: #ffffff;
  --sage: #13723a;       /* clinic green: buttons, links */
  --sage-soft: #e1efe4;
  --band: #0f4a28;       /* deep green for the home page band */
  --band-ink: #ffffff;
  --gold: #f4c534;       /* caduceus gold, used only for the phone number on the band */
  --alert: #a33a2c;
  --line: #d3ddd5;
  --muted: #4f6157;
  --radius: 6px;
  --measure: 68ch;
  --step-0: 1.125rem;
  --step-1: 1.375rem;
  --step-2: 1.75rem;
  --step-3: 2.5rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e6f0e9;
    --paper: #0e1a13;
    --surface: #15251b;
    --sage: #7fd39a;
    --sage-soft: #1b3a26;
    --band: #0b3a1f;
    --alert: #f08a7a;
    --line: #2a4233;
    --muted: #9fb7a7;
  }
}
:root[data-theme="dark"] {
  --ink: #e6f0e9;
  --paper: #0e1a13;
  --surface: #15251b;
  --sage: #7fd39a;
  --sage-soft: #1b3a26;
  --band: #0b3a1f;
  --alert: #f08a7a;
  --line: #2a4233;
  --muted: #9fb7a7;
}

:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; -webkit-tap-highlight-color: rgba(19, 114, 58, 0.15); }
a, button, summary, label, input, select, textarea { touch-action: manipulation; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; overflow-x: clip;
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: var(--step-0);
  line-height: 1.6;
  background: var(--paper);
  color: var(--ink);
}
h1, h2, h3 { line-height: 1.15; margin: 0; text-wrap: balance; }
p { text-wrap: pretty; }
h1 { font-size: var(--step-3); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: var(--step-2); font-weight: 700; margin-bottom: 1rem; }
h3 { font-size: var(--step-1); font-weight: 700; margin: 0.15rem 0 0.4rem; }
p { margin: 0.4rem 0; max-width: var(--measure); }
a { color: var(--sage); text-underline-offset: 3px; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
:focus-visible { outline: 3px solid var(--sage); outline-offset: 3px; border-radius: 2px; }

/* header */
.site-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem 1.5rem; padding: 0.9rem 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.15rem; }
.brand img { height: 44px; width: 44px; border-radius: 50%; object-fit: cover; }
.skip { position: absolute; left: -999px; top: 0.5rem; z-index: 20; background: var(--surface); padding: 0.5rem 1rem; }
.skip:focus { left: 0.5rem; }
.site-header nav .call-btn { color: #fff; text-decoration: none; }
.site-header nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.1rem; }
.site-header nav a { text-decoration: none; color: var(--ink); }
.site-header nav a:hover { color: var(--sage); text-decoration: underline; text-underline-offset: 4px; }
.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; padding: 0; color: var(--sage); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 3px; }
button.link.danger { color: var(--alert); }

/* layout */
.container { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem 2.5rem; }
.block { margin-top: 3.5rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem; margin: 1.25rem 0;
}
.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.between { justify-content: space-between; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.25rem; align-items: center; }
.actions-cell { white-space: nowrap; }
.actions-cell > * { margin-right: 0.8rem; }

/* home band: full-width deep green, the phone number is the main action */
.hero {
  color: var(--band-ink);
  /* paints the band edge to edge without making the page wider */
  border-image: linear-gradient(var(--band) 0 0) fill 0 / / 0 100vw;
  padding: 3.5rem 0 3.75rem;
}
.hero-inner {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 3rem; align-items: center;
}
.hero-logo {
  width: 88px; height: 88px; border-radius: 50%; object-fit: cover;
  border: 4px solid #fff; background: #fff; margin-bottom: 1.25rem;
}
.hero h1 { font-size: clamp(2.2rem, 4.5vw, 3.25rem); letter-spacing: -0.015em; }
.lead { font-size: 1.25rem; margin-top: 0.6rem; opacity: 0.92; }
.book-label { margin: 2rem 0 0; font-size: 1.05rem; opacity: 0.92; }
.big-phone {
  display: inline-block; color: var(--gold); text-decoration: none; font-weight: 700;
  font-size: clamp(1.75rem, 4vw, 2.5rem); line-height: 1.1; letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums; margin-top: 0.2rem;
}
.big-phone:hover { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 8px; }
.hero :focus-visible { outline-color: var(--gold); }
.hero .actions { margin-top: 1.5rem; }
.btn.light { background: #fff; border-color: #fff; color: #0f4a28; }
.btn.ghost { background: transparent; border-color: rgba(255, 255, 255, 0.7); color: #fff; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.1); filter: none; }
.visit {
  background: var(--surface); color: var(--ink); border-radius: 10px; padding: 1.75rem;
}
.visit h2 { font-size: var(--step-1); margin-bottom: 1.1rem; }
.visit dl { margin: 0; display: grid; gap: 1rem; }
.visit dl > div { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 0.75rem; }
.visit dl > div + div { border-top: 1px solid var(--line); padding-top: 1rem; }
.visit dt { font-weight: 700; font-size: 0.95rem; color: var(--muted); padding-top: 0.1rem; }
.visit dd { margin: 0; }

/* buttons & forms */
.btn {
  display: inline-block; padding: 0.7rem 1.25rem; border-radius: var(--radius);
  border: 2px solid var(--sage); background: var(--sage); color: #fff;
  text-decoration: none; cursor: pointer; font: inherit; font-weight: 700; line-height: 1.2;
}
.btn:hover { filter: brightness(1.08); }
.btn.outline { background: transparent; color: var(--sage); }
.btn.outline:hover { background: var(--sage-soft); filter: none; }
.btn.small { padding: 0.3rem 0.8rem; font-size: 0.9rem; }
input, select, textarea {
  width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--muted); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: inherit;
}
input[type="checkbox"] { width: auto; }
label { display: block; font-weight: 700; font-size: 0.95rem; }
label input, label select, label textarea { margin-top: 0.35rem; font-weight: 400; }
label.checkbox { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
label .small { font-weight: 400; display: block; margin-top: 0.3rem; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem 1.25rem; }
.grid .full { grid-column: 1 / -1; }
.search { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1.25rem 0; }
.search input { flex: 1 1 280px; }
.auth { max-width: 440px; margin: 2.5rem auto; }
.auth form label { margin-bottom: 1rem; }

/* flash messages */
.flash { padding: 0.8rem 1rem; border-radius: var(--radius); margin: 1.25rem 0; border: 1px solid; }
.flash.success { background: var(--sage-soft); border-color: var(--sage); color: var(--ink); }
.flash.error { background: #fbeceb; border-color: var(--alert); color: var(--ink); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .flash.error { background: #3a1d1a; }
}
:root[data-theme="dark"] .flash.error { background: #3a1d1a; }

/* tables & details */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.9rem; color: var(--muted); font-weight: 700; }
td { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.details { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.5rem; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 700; }

/* announcements: text on the left, the poster on the right */
.post-list { border-top: 1px solid var(--line); }
.post { padding: 2rem 0; border-bottom: 1px solid var(--line); }
.post.has-image { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 2.5rem; align-items: start; }
.post h3 { font-size: var(--step-2); margin: 0.2rem 0 0.6rem; }
.when { color: var(--muted); font-size: 0.95rem; margin: 0; }
.tag { font-size: 0.9rem; font-weight: 700; color: var(--sage); margin: 0; }
.tag.news { color: var(--ink); }
.tag.announcement { color: var(--alert); }
.body { white-space: pre-line; margin: 0.5rem 0 0; }
.more { margin-top: 0.75rem; }
.more summary {
  cursor: pointer; color: var(--sage); font-weight: 700; width: fit-content;
  text-decoration: underline; text-underline-offset: 3px;
}
.more[open] summary { margin-bottom: 0.25rem; }
.post-image-link { display: block; border-radius: 8px; }
.post-image { display: block; width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); }
.services { padding-left: 1.2rem; columns: 2; }

/* records & results (doctor's patient page and patient's own page) */
.jump { margin: 0.4rem 0 0; font-weight: 700; }
.records-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.records-head h2 { margin: 0; }
.upload-panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  padding: 1.25rem 1.25rem 1.1rem; margin-bottom: 1.75rem;
}
.upload-panel h3 { font-size: 1.1rem; margin: 0 0 0.9rem; }
.upload-panel .actions { margin-top: 1rem; }
.upload-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: 1 / -1; }
.optional { font-weight: 400; color: var(--muted); }
.drop {
  border: 2px dashed var(--line); border-radius: 8px; padding: 1rem 1.1rem; background: var(--surface);
}
.drop:focus-within { border-color: var(--sage); }
.drop-label { font-weight: 400; }
.drop-title { display: block; font-weight: 700; }
.drop input[type="file"] { margin-top: 0.75rem; border-style: solid; background: var(--paper); cursor: pointer; }
.chosen { list-style: none; margin: 0.6rem 0 0; padding: 0; font-size: 0.95rem; }
.chosen li { padding: 0.15rem 0; overflow-wrap: anywhere; }
.chosen li.too-big { color: var(--alert); font-weight: 700; }
.btn:disabled { opacity: 0.7; cursor: progress; }

.record-filter { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.chip {
  font: inherit; font-size: 0.95rem; padding: 0.35rem 0.9rem; min-height: 2.5rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.chip:hover { border-color: var(--sage); }
.chip[aria-pressed="true"] { background: var(--sage); border-color: var(--sage); color: #fff; }
.chip .count { opacity: 0.75; margin-left: 0.2rem; }

.record-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.record {
  display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) auto; gap: 0.5rem 1.5rem; align-items: start;
  padding: 1.1rem 0; border-bottom: 1px solid var(--line);
}
.record[hidden] { display: none; }
.record-date { color: var(--muted); font-size: 0.95rem; padding-top: 0.15rem; font-variant-numeric: tabular-nums; }
.record-title { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; }
.record-title a { font-weight: 700; color: var(--ink); font-size: 1.1rem; }
.record-title a:hover { color: var(--sage); }
.record-notes { margin: 0.35rem 0 0; }
.record-meta { display: flex; flex-wrap: wrap; gap: 0.2rem 1.25rem; margin: 0.35rem 0 0; font-size: 0.9rem; color: var(--muted); }
.file-name { overflow-wrap: anywhere; }
.record-actions { display: flex; align-items: center; gap: 0.5rem 0.75rem; flex-wrap: wrap; justify-content: flex-end; }
.record-actions .btn.small { min-height: 2.5rem; display: inline-flex; align-items: center; }
.record-actions .link { padding: 0.5rem 0.25rem; }
/* in-page record viewer */
.viewer {
  width: min(1100px, calc(100vw - 2rem)); height: calc(100dvh - 2rem); max-width: none; max-height: none;
  padding: 0; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  overscroll-behavior: contain;
}
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: rgba(10, 25, 16, 0.6); }
.viewer-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1.25rem; flex-wrap: wrap;
  padding: 0.85rem 1rem 0.85rem 1.25rem; border-bottom: 1px solid var(--line);
}
.viewer-heading { min-width: 0; }
.viewer-title { font-size: 1.15rem; margin: 0; overflow-wrap: anywhere; }
.viewer-date { margin: 0.1rem 0 0; font-size: 0.9rem; }
.viewer-actions { display: flex; align-items: center; gap: 0.5rem; }
.viewer-actions .btn.small { min-height: 2.5rem; display: inline-flex; align-items: center; }
.viewer-close {
  display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; margin-left: 0.25rem;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); cursor: pointer;
}
.viewer-close:hover { border-color: var(--sage); color: var(--sage); }
.viewer-body { position: relative; flex: 1; min-height: 0; background: #525659; }
.viewer-frame { display: block; width: 100%; height: 100%; border: 0; background: #525659; }
.viewer-loading { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: #fff; pointer-events: none; }
.viewer-loading[hidden] { display: none; }
html.viewer-open { overflow: hidden; }
@media (max-width: 760px) {
  .viewer { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .viewer-tab { display: none; }
}

.records-empty { border: 1px dashed var(--line); border-radius: 8px; padding: 1.25rem; }
.records-empty p { margin: 0.2rem 0; }
.record-none { margin-top: 1rem; }
/* category colours: a soft tint so a list scans quickly; the label still names the category */
.badge.cat-diagnosis { background: #e8eefb; border-color: #a9bde8; color: #23427f; }
.badge.cat-lab-result { background: var(--sage-soft); border-color: #9cc9aa; color: #0f5a2e; }
.badge.cat-prescription { background: #fbf1dc; border-color: #e4c682; color: #6d4c06; }
.badge.cat-imaging { background: #f1e9f8; border-color: #c8acdf; color: #55307a; }
:root[data-theme="dark"] .badge[class*="cat-"] { background: transparent; color: var(--ink); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge[class*="cat-"] { background: transparent; color: var(--ink); }
}
@media (max-width: 760px) {
  .upload-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .upload-fields .span-2 { grid-column: 1 / -1; }
  .record { grid-template-columns: minmax(0, 1fr); gap: 0.4rem; }
  .record-date { padding-top: 0; }
  .record-actions { justify-content: flex-start; margin-top: 0.4rem; }
}
@media (max-width: 420px) {
  .upload-fields { grid-template-columns: minmax(0, 1fr); }
}

/* doctor accounts (admin page) */
.accounts .page-head { margin: 0.5rem 0 2rem; }
.accounts .page-head p { margin-top: 0.6rem; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem; margin: 0 0 2.5rem;
}
.panel h2, .accounts section > h2 { font-size: var(--step-1); margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem 1.25rem; align-items: start; }
.form-grid > label { font-weight: 700; }
.form-grid > label > input { margin-top: 0.35rem; }
.form-foot {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem; margin-top: 0.25rem;
}
.form-foot label.checkbox { font-weight: 400; }
.form-foot label.checkbox input { margin: 0; }
.hint { display: block; margin-top: 0.3rem; font-size: 0.9rem; font-weight: 400; color: var(--muted); }
.badge {
  display: inline-block; padding: 0.15rem 0.7rem; border-radius: 999px; font-size: 0.85rem; font-weight: 700;
  border: 1px solid var(--line); color: var(--muted);
}
.badge.admin { background: var(--sage-soft); border-color: var(--sage); color: var(--sage); }
.account-table th, .account-table td { padding: 0.8rem 0.6rem; vertical-align: middle; }
.account-table td strong { font-weight: 700; }
.acct-actions { text-align: right; white-space: nowrap; width: 1%; }
.account-table .edit-row td { padding: 0 0.6rem 0.8rem; border-bottom: 1px solid var(--line); }
.account-table details summary {
  cursor: pointer; color: var(--sage); font-weight: 700; font-size: 0.95rem; padding: 0.2rem 0;
  text-decoration: underline; text-underline-offset: 3px;
}
.edit-box {
  margin-top: 0.6rem; padding: 1.25rem; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius);
}
@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr; }
  .acct-actions { width: auto; }
}

/* footer */
.site-footer {
  margin-top: 4rem; padding: 2rem 1.25rem; background: var(--surface); border-top: 1px solid var(--line);
}
.footer-inner {
  max-width: 1080px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem 2rem;
}
.footer-inner p { margin: 0.3rem 0; max-width: none; }
.footer-name { font-weight: 700; }

/* phones: a call bar stays at the bottom of public pages */
.call-bar { display: none; }
.footer-inner .copyright { grid-column: 1 / -1; color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--line); padding-top: 1rem; }

/* phones */
@media (max-width: 760px) {
  body { font-size: 1.05rem; }
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  .hero { padding: 2.25rem 0 2.5rem; }
  .hero-inner { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .hero-logo { width: 72px; height: 72px; }
  .lead { font-size: 1.1rem; }
  .services { columns: 1; }
  .post.has-image { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .post-image-link { max-width: 420px; }
  /* on phones the bottom call bar replaces the header links */
  .public .site-header nav a:not(.call-btn) { display: none; }
  .public .site-header nav .call-btn { display: none; }
  .public .site-footer { padding-bottom: 6rem; }
  .call-bar {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
    padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .call-bar .btn { text-align: center; }
  .call-bar .btn:only-child { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .post { grid-template-columns: 1fr; gap: 0.6rem; }
  .when { padding-top: 0; }
  .date-block { display: inline-flex; gap: 0.5rem; align-items: baseline; padding: 0.3rem 0.6rem; }
  .date-block strong { font-size: 1.2rem; }
  .date-block span { font-size: 0.95rem; }
  .details { grid-template-columns: 1fr; }
  .details dd { margin-bottom: 0.6rem; }
}
