/* eTabib staff + public styles */
:root {
  --lapis: #1F4E8C; --lapis-deep: #163A69; --lapis-wash: #E6EDF6;
  --paper: #F4F6F3; --surface: #FFFFFF; --ink: #1A2230; --muted: #5B6676; --line: #D9DED8;
  --saffron: #B7791A; --saffron-wash: #FBF1DF; --green: #2E7D4F; --green-wash: #E3F1E8;
  --red: #B3261E; --red-wash: #FBE7E5;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --naskh: "Noto Naskh Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, serif;
  --r-sm: 4px; --r-md: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--lapis); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--lapis) 45%, transparent); outline-offset: 2px;
}
.rtl { direction: rtl; font-family: var(--naskh); line-height: 1.9; }

/* top bar */
.bar { background: var(--lapis-deep); color: #fff; }
.bar-in { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; gap: 24px; align-items: center; }
.mark { font-weight: 600; font-size: 18px; letter-spacing: .2px; color: #fff; text-decoration: none; }
.mark b { font-weight: 400; opacity: .7; }
.bar nav { display: flex; gap: 18px; flex: 1; }
.bar nav a { color: #DCE6F3; text-decoration: none; font-size: 14px; }
.bar nav a[aria-current="page"] { color: #fff; border-bottom: 2px solid #fff; }
.bar form { margin: 0; }
.bar .who { font-size: 13px; color: #BCCBE0; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }
h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px 20px; margin-bottom: 16px; }
.panel.urgent { border-left: 4px solid var(--red); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
dl.facts { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* status chips */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.chip.act { background: var(--lapis-wash); color: var(--lapis-deep); }
.chip.wait { background: var(--saffron-wash); color: #7A4F0C; }
.chip.plan { background: #EEF0EC; color: #3B4450; }
.chip.live { background: var(--green); color: #fff; }
.chip.done { background: var(--green-wash); color: #1F5A37; }
.chip.bad { background: var(--red-wash); color: var(--red); }
.chip.quiet { background: #EEF0EC; color: var(--muted); }
.flag { color: var(--red); font-weight: 600; }

/* tabs + table */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-color: var(--lapis); font-weight: 500; }
.tabs .n { font-size: 12px; margin-left: 4px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 500; color: var(--muted); font-size: 13px; background: #FAFBF9; }
tr.row-link:hover { background: #F7F9FC; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.empty { padding: 32px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-md); }

/* forms */
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #C5CCC4; border-radius: var(--r-sm); font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); font-size: 14px; margin: 8px 0; }
.check input { margin-top: 4px; }
.btn { display: inline-block; padding: 8px 16px; border-radius: var(--r-sm); border: 1px solid var(--lapis); background: var(--lapis); color: #fff;
  font: 500 14px var(--sans); cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--lapis-deep); }
.btn.quiet { background: #fff; color: var(--lapis); }
.btn.quiet:hover { background: var(--lapis-wash); }
.btn.danger { background: #fff; color: var(--red); border-color: #E3B1AC; }
.btn.go { background: var(--green); border-color: var(--green); }
.btn.big { padding: 12px 22px; font-size: 16px; }
.btn.ghost { background: transparent; border-color: #5E7FAF; color: #fff; padding: 5px 12px; font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1; min-width: 140px; }
details.act { border-top: 1px solid var(--line); padding: 10px 0; }
details.act summary { cursor: pointer; font-weight: 500; }
details.act[open] summary { margin-bottom: 8px; }

/* messages */
.note { padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 14px; }
.note.ok { background: var(--green-wash); color: #1F5A37; }
.note.err { background: var(--red-wash); color: var(--red); }
.note.info { background: var(--lapis-wash); color: var(--lapis-deep); }
.notices { list-style: none; padding: 0; margin: 0 0 8px; }
.notices li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.notices li.urgent, .notices li.error { color: var(--red); }

.timeline { list-style: none; padding: 0; margin: 0; max-height: 360px; overflow-y: auto; }
.timeline li { padding: 6px 0; border-bottom: 1px dotted var(--line); font-size: 14px; }
.timeline .when { color: var(--muted); font-size: 12px; margin-right: 8px; }
.timeline .dir-echo { color: var(--lapis); }
.files { list-style: none; padding: 0; margin: 0; }
.files li { padding: 5px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* doctor call card */
.callcard { display: flex; gap: 18px; align-items: center; }
.callcard img { border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }
.callcard ol { margin: 0; padding-left: 18px; }

/* medicine rows */
.med { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 10px; background: #FBFCFA; }
.med .row > * { min-width: 110px; }
.med .name { flex: 2.2; }
.preview-frame { width: 100%; height: 900px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }

/* login */
.login { max-width: 380px; margin: 10vh auto; }

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

/* ---- additions: forms, cards, public pages ---- */
main .btn.ghost { color: var(--lapis); border-color: var(--lapis); background: #fff; font-size: 14px; }
.btn.primary { background: var(--lapis); }
.btn.warn { background: var(--saffron); border-color: var(--saffron); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.stack { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin: 0 0 18px; }
.stack select, .stack input:not([type=checkbox]):not([type=radio]), .stack textarea { width: 100%; }
label { display: block; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { display: block; margin-top: 3px; color: var(--ink); }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; }
label.check { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); font-size: 14px; }
.inline-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 12px; align-items: end; }
.medgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.medgrid .wide { grid-column: span 2; }
fieldset.med { border: 1px solid var(--line); border-radius: var(--r-md); margin: 0 0 12px; padding: 10px 12px; background: #FBFCFB; }
fieldset.med legend { font-weight: 600; font-size: 13px; padding: 0 4px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; margin-bottom: 10px; }
.rtl-ok { unicode-bidi: plaintext; }
.steps { padding-left: 18px; }
.qrrow { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 8px 0 16px; }
.qrrow img { border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }
details { margin: 0 0 16px; } summary { cursor: pointer; color: var(--lapis); }
ul.files { list-style: none; padding: 0; } ul.files li { padding: 6px 0; border-bottom: 1px solid var(--line); }
ul.files audio { display: block; margin-top: 4px; max-width: 100%; }
ul.audit, ul.plain { list-style: none; padding: 0; margin: 0; }
.signbox { margin-top: 16px; border-left: 4px solid var(--green); }
.actions { margin: 16px 0 40px; }
.preview-frame iframe { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; }

/* public pages (patient-facing, RTL) */
body.public { background: var(--paper); font-family: var(--naskh); }
.pub { max-width: 720px; margin: 0 auto; padding: 24px 18px 48px; }
.pub-mark { font: 700 26px var(--sans); color: var(--lapis); letter-spacing: .5px; }
.pub-hero { background: var(--surface); border-radius: var(--r-md); padding: 22px; margin: 16px 0; border-top: 5px solid var(--lapis); }
.pub-hero h1 { font-size: 24px; margin: 0 0 6px; color: var(--lapis-deep); }
.pub-hero [lang] + [lang] { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.pub-hero p, .pub-steps li, .pub-warn p { font-size: 17px; line-height: 1.9; }
.btn.wa { background: #1F8F4E; border-color: #1F8F4E; margin-top: 16px; font-family: var(--naskh); font-size: 19px; width: 100%; text-align: center; }
.pub-steps { display: grid; gap: 12px; } .pub-steps ol { background: var(--surface); border-radius: var(--r-md); padding: 14px 34px 14px 14px; margin: 0; }
.pub-warn { background: var(--red-wash); border-radius: var(--r-md); padding: 12px 16px; margin-top: 16px; }
.pub-foot { color: var(--muted); font-size: 15px; margin-top: 20px; }
.verify { font-family: var(--sans); }
.vbox { background: var(--surface); border-radius: var(--r-md); padding: 20px; margin-top: 16px; border-top: 6px solid var(--green); }
.vbox.bad { border-top-color: var(--red); } .vbox h1 { margin-top: 0; }
@media (max-width: 720px) { .medgrid .wide { grid-column: 1 / -1; } }
