/* سجل الطفح الجلدي
   Cool porcelain paper, ink-blue for actions, and one colour per case classification.
   The classification colours are the only strong colour on the page; everything else stays grey. */
:root {
  color-scheme: light;
  --paper: #f2f4f6; --surface: #ffffff; --sunk: #e9edf1; --line: #d9dee4; --line-strong: #b7c0ca;
  --ink: #18212b; --ink-2: #4e5966; --ink-3: #6b7581;
  --act: #23408e; --act-ink: #ffffff; --act-soft: #e3e9f7;
  --measles: #b0213b; --measles-soft: #fbe6ea;
  --rubella: #8a3597; --rubella-soft: #f4e6f6;
  --pending: #9a6200; --pending-soft: #fcf0d6;
  --discarded: #2f6b52; --discarded-soft: #e2f0e8;
  --vaccine: #4a5c78; --vaccine-soft: #e6ebf2;
  --none: #8b95a1;
  --window: rgb(47 107 82 / .10); --infectious: rgb(176 33 59 / .10);
  --radius-s: 6px; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #12161b; --surface: #1a2027; --sunk: #222a33; --line: #2e3742; --line-strong: #46515e;
    --ink: #e9edf1; --ink-2: #b4bdc7; --ink-3: #8f99a5;
    --act: #8fa8f0; --act-ink: #0e1730; --act-soft: #1f2b4b;
    --measles: #f08a9b; --measles-soft: #3d1b23;
    --rubella: #d79be2; --rubella-soft: #351d3a;
    --pending: #e5b45a; --pending-soft: #372a12;
    --discarded: #7fcfa8; --discarded-soft: #16332a;
    --vaccine: #a9b9d4; --vaccine-soft: #232d3c;
    --none: #6d7783;
    --window: rgb(127 207 168 / .12); --infectious: rgb(240 138 155 / .14);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #12161b; --surface: #1a2027; --sunk: #222a33; --line: #2e3742; --line-strong: #46515e;
  --ink: #e9edf1; --ink-2: #b4bdc7; --ink-3: #8f99a5;
  --act: #8fa8f0; --act-ink: #0e1730; --act-soft: #1f2b4b;
  --measles: #f08a9b; --measles-soft: #3d1b23;
  --rubella: #d79be2; --rubella-soft: #351d3a;
  --pending: #e5b45a; --pending-soft: #372a12;
  --discarded: #7fcfa8; --discarded-soft: #16332a;
  --vaccine: #a9b9d4; --vaccine-soft: #232d3c;
  --none: #6d7783;
  --window: rgb(127 207 168 / .12); --infectious: rgb(240 138 155 / .14);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.65 "Readex Pro", "Geeza Pro", Tahoma, sans-serif; font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 600; }
h1 { font-size: 26px; letter-spacing: -.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
a { color: var(--act); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--act); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); padding: 7px 16px; border-radius: var(--radius-s); cursor: pointer; font-weight: 500; min-height: 40px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--sunk); }
.btn.primary { background: var(--act); border-color: var(--act); color: var(--act-ink); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--measles); border-color: currentColor; background: transparent; }
.btn.danger:hover { background: var(--measles-soft); }
.btn.sm { padding: 3px 11px; min-height: 32px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.input, select.input, textarea.input { width: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 8px 11px; min-height: 42px; }
.input:hover { border-color: var(--ink-3); }
.input:focus { border-color: var(--act); outline: 2px solid var(--act-soft); outline-offset: 0; }
select.input { cursor: pointer; }
textarea.input { min-height: 92px; resize: vertical; line-height: 1.7; }
label.field { display: block; }
label.field > span { display: block; font-size: 13.5px; color: var(--ink-2); margin-bottom: 5px; font-weight: 500; }
.req { color: var(--measles); }
.legacy-note { font-size: 12.5px; color: var(--pending); margin-top: 4px; }

.msg { padding: 10px 14px; border-radius: var(--radius-s); font-size: 14px; border-inline-start: 3px solid currentColor; }
.msg.error { background: var(--measles-soft); color: var(--measles); }
.msg.warn { background: var(--pending-soft); color: var(--pending); }
.msg.ok { background: var(--discarded-soft); color: var(--discarded); }
.msg.info { background: var(--act-soft); color: var(--act); }

/* sign in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; position: relative; }
.auth-card { width: 100%; max-width: 380px; display: grid; gap: 18px; }
.auth-card h1 { font-size: 28px; }
.auth-card .btn { width: 100%; }
.auth-theme { position: absolute; top: 16px; inset-inline-end: 16px; }
.mark { display: inline-grid; grid-template-columns: repeat(3, 6px); gap: 3px; vertical-align: middle; margin-inline-end: 10px; }
.mark i { width: 6px; height: 6px; border-radius: 50%; background: var(--measles); }
.mark i:nth-child(2), .mark i:nth-child(6) { opacity: .45; }
.mark i:nth-child(4) { opacity: .7; }

/* shell */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top-in { max-width: 1200px; margin: auto; padding: 0 16px; display: flex; align-items: center; gap: 4px 24px; flex-wrap: wrap; min-height: 56px; }
.brand { font-weight: 600; font-size: 16px; display: flex; align-items: center; color: inherit; text-decoration: none; }
.nav { display: flex; gap: 2px; align-self: stretch; }
.nav a { display: flex; align-items: center; padding: 0 12px; text-decoration: none; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--act); border-bottom-color: var(--act); }
.who { margin-inline-start: auto; display: flex; align-items: center; gap: 12px; font-size: 13.5px; }
main { max-width: 1200px; margin: auto; padding: 28px 16px 120px; display: grid; gap: 22px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card > h2 { margin-bottom: 14px; }
.card-sub { color: var(--ink-2); font-size: 13px; margin: -10px 0 14px; }
.loading { padding: 48px; text-align: center; color: var(--ink-2); }

/* classification colours */
.cls-measles { --c: var(--measles); --c-soft: var(--measles-soft); }
.cls-rubella { --c: var(--rubella); --c-soft: var(--rubella-soft); }
.cls-pending { --c: var(--pending); --c-soft: var(--pending-soft); }
.cls-discarded { --c: var(--discarded); --c-soft: var(--discarded-soft); }
.cls-vaccine { --c: var(--vaccine); --c-soft: var(--vaccine-soft); }
.cls-none { --c: var(--none); --c-soft: var(--sunk); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; background: var(--c-soft, var(--sunk)); color: var(--c, var(--ink-2)); }
.pill.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.bad { --c: var(--measles); --c-soft: var(--measles-soft); }
.pill.good { --c: var(--discarded); --c-soft: var(--discarded-soft); }
.pill.warn { --c: var(--pending); --c-soft: var(--pending-soft); }
.pill.info { --c: var(--act); --c-soft: var(--act-soft); }
.pill.none { --c: var(--ink-2); --c-soft: var(--sunk); }

/* the classification bar replaces a row of number boxes */
.overview { display: grid; gap: 14px; }
.overview-total { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.overview-total strong { font-size: 34px; font-weight: 600; line-height: 1; }
.bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--sunk); gap: 2px; }
.bar span { background: var(--c); min-width: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 4px; margin: 0; padding: 0; list-style: none; }
.legend button { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; background: none; border-radius: var(--radius-s); padding: 5px 10px; cursor: pointer; color: var(--ink); }
.legend button::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.legend button:hover { background: var(--sunk); }
.legend button[aria-pressed="true"] { border-color: var(--c); background: var(--c-soft); }
.legend b { font-weight: 600; }

/* filters and the case table */
.filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.filters label.field { min-width: 140px; }
.search { flex: 1 1 280px; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { font-size: 13px; color: var(--ink-2); font-weight: 500; text-align: start; background: var(--sunk); white-space: nowrap; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
.cases-table td { font-size: 14px; white-space: nowrap; }
.cases-table td.wrap { white-space: normal; min-width: 170px; }
.cases-table tbody td:first-child { border-inline-start: 4px solid var(--c, transparent); }
.cases-table tbody tr { cursor: pointer; }
.cases-table tbody tr:hover td { background: var(--paper); }
.cases-table th button { all: unset; cursor: pointer; }
.cases-table th button:focus-visible { outline: 2px solid var(--act); outline-offset: 2px; }
.cases-table .name-cell { font-weight: 500; }
.empty-state { padding: 36px 16px; text-align: center; color: var(--ink-2); display: grid; gap: 12px; justify-items: center; }

/* due appointments */
.due { list-style: none; margin: 0; padding: 0; display: grid; }
.due li { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.due li:last-child { border-bottom: 0; }
.due .when { font-weight: 500; }

/* sectioned form and case page: section name in a side column, like a paper investigation form */
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.sec { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; padding: 22px 22px; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec-head h2 { font-size: 16px; }
.sec-head p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.field-wrap { min-width: 0; }
.field-wrap.full { grid-column: 1 / -1; }
.detail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; margin: 0; }
.detail > div { min-width: 0; }
.detail .full { grid-column: 1 / -1; }
.detail dt { font-size: 13px; color: var(--ink-2); }
.detail dd { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 500; }
.detail dd.empty { color: var(--ink-3); font-weight: 400; }
.savebar { position: sticky; bottom: 0; z-index: 15; background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); padding: 12px 22px; display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.sheet-foot { margin: 0; padding: 12px 22px; font-size: 13px; color: var(--ink-2); border-top: 1px solid var(--line); }
.savebar .hint { margin-inline-end: auto; font-size: 13px; color: var(--ink-2); }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 14px; cursor: pointer; background: var(--surface); min-height: 38px; }
.check:has(input:checked) { background: var(--act-soft); border-color: var(--act); color: var(--act); font-weight: 500; }
.check:has(input:focus-visible) { outline: 2px solid var(--act); outline-offset: 2px; }
.check input { accent-color: var(--act); margin: 0; }

/* case header and the rash timeline */
.case-head { display: grid; gap: 10px; }
.case-head .back { font-size: 13.5px; }
.case-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.case-title h1 { font-size: 30px; }
.case-meta { display: flex; gap: 6px 16px; flex-wrap: wrap; color: var(--ink-2); font-size: 14px; }
.tl { padding: 20px 22px 16px; }
.tl-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 8px; }
.tl-key { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.tl-key span::before { content: ""; display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-inline-end: 6px; vertical-align: -1px; }
.tl-key .k-inf::before { background: var(--infectious); border: 1px solid var(--measles); }
.tl-key .k-win::before { background: var(--window); border: 1px solid var(--discarded); }
.tl-scroll { overflow-x: auto; padding-bottom: 4px; }
/* Axis geometry: the line sits at y=95; two label lanes above it, two below, the day scale at the bottom. */
.tl-axis { position: relative; min-width: 640px; height: 196px; }
.tl-band { position: absolute; }
.tl-band.inf { top: 70px; height: 52px; background: var(--infectious); border-inline: 1px dashed var(--measles); }
.tl-band.win { top: 77px; height: 38px; background: var(--window); }
.tl-line { position: absolute; top: 95px; inset-inline: 0; height: 2px; background: var(--line-strong); }
/* Points are zero-width anchors placed from the right (RTL); children centre on them with translateX(50%). */
.tl-tick { position: absolute; top: 0; width: 0; height: 100%; }
.tl-tick::before { content: ""; position: absolute; top: 176px; inset-inline-start: 0; width: 1px; height: 5px; background: var(--line-strong); }
.tl-tick span { position: absolute; top: 180px; inset-inline-start: 0; transform: translateX(50%); font-size: 11.5px; color: var(--ink-3); white-space: nowrap; direction: ltr; }
.tl-ev { position: absolute; top: 0; width: 0; height: 100%; text-align: center; }
.tl-ev .dot, .tl-ev .lab { position: absolute; inset-inline-start: 0; transform: translateX(50%); }
.tl-ev .dot { top: 89px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--ink-2); }
.tl-ev.rash .dot { top: 86px; width: 20px; height: 20px; background: var(--measles); border-color: var(--measles); box-shadow: 0 0 0 4px var(--measles-soft); }
.tl-ev .lab { white-space: nowrap; font-size: 12px; line-height: 1.35; color: var(--ink-2); }
.tl-ev .lab b { display: block; font-weight: 600; font-size: 13px; color: var(--ink); }
.tl-ev.rash .lab b { color: var(--measles); }
.tl-ev.up .lab { top: 50px; }
.tl-ev.up2 .lab { top: 12px; }
.tl-ev.down .lab { top: 112px; }
.tl-ev.down2 .lab { top: 143px; }
.tl-note { font-size: 13px; color: var(--ink-2); margin: 8px 0 0; }
.tl-note.warn { color: var(--pending); }
.tl-empty { padding: 18px 22px; color: var(--ink-2); font-size: 14px; }

/* attachments, follow-up, ready replies */
.drop { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 20px; text-align: center; color: var(--ink-2); display: grid; gap: 10px; justify-items: center; }
.drop.over { border-color: var(--act); background: var(--act-soft); }
.drop-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.drop-row select { width: auto; }
.files { list-style: none; margin: 14px 0 0; padding: 0; display: grid; }
.files li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.files li:last-child { border-bottom: 0; }
.files .name { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.timeline { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 12px; }
.timeline li { border-inline-start: 2px solid var(--line-strong); padding-inline-start: 12px; }
.timeline p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.audit-detail { font-size: 12.5px; color: var(--ink-2); overflow-wrap: anywhere; white-space: normal; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chips:empty { display: none; }
.chip { display: inline-flex; max-width: 100%; border: 1px solid var(--line); border-radius: 999px; background: var(--sunk); overflow: hidden; }
.chip button { border: 0; background: none; cursor: pointer; font-size: 13px; }
.chip-text { padding: 4px 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; text-align: start; }
.chip-text:hover { background: var(--act-soft); color: var(--act); }
.chip-x { padding: 4px 9px; color: var(--ink-3); border-inline-start: 1px solid var(--line) !important; }
.chip-x:hover { background: var(--measles-soft); color: var(--measles); }
.chips-save { margin-top: 6px; }
.combo { position: relative; }
.combo-box { position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 30; max-height: 260px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-s); box-shadow: 0 8px 24px rgb(15 25 40 / .16); }
.combo-box[hidden] { display: none; }
.combo-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 11px; cursor: pointer; font-size: 14px; }
.combo-item:hover, .combo-item.on { background: var(--act-soft); }
.combo-x { border: 0; background: none; cursor: pointer; color: var(--ink-3); font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.combo-x:hover { background: var(--measles-soft); color: var(--measles); }

dialog { border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); max-width: 480px; width: calc(100% - 32px); padding: 24px; }
dialog::backdrop { background: rgb(10 15 25 / .5); }
dialog h2 { margin-bottom: 10px; }
dialog.wide { max-width: min(960px, calc(100% - 32px)); }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.preview-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; }
.preview-img { display: block; max-width: 100%; max-height: 70vh; margin: auto; }
.theme-btn { white-space: nowrap; }

@media (max-width: 820px) {
  .sec { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 18px 16px; }
  .savebar { padding: 12px 16px; }
  .tl { padding: 16px; }
}
@media (max-width: 560px) {
  .form-grid, .detail { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 23px; }
  .case-title h1 { font-size: 24px; }
  .overview-total strong { font-size: 28px; }
  .who a { display: none; }
  .due li { grid-template-columns: 1fr auto; }
  .due .when { grid-column: 1 / -1; }
}
@media print { .top, .toolbar, .savebar { display: none; } }
