:root {
  --navy: #0b3a7e; --navy-2: #0f4c9c; --cyan: #0ea5c6; --cyan-soft: #e3f6fb; --red: #d42020; --orange: #e8590c;
  --bg: #f4f7fb; --card: #ffffff; --line: #e3e9f1; --text: #0f1f33; --muted: #64748b; --ok: #0f9d58;
  --radius: 12px; --shadow: 0 1px 2px rgba(15,40,80,.06), 0 4px 18px rgba(15,40,80,.06);
  --font: "Segoe UI", Tahoma, "Noto Sans Arabic", "DejaVu Sans", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14.5px; }
a { color: var(--navy-2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.en { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* ---------- application header: lab banner + navigation tabs (fixed, scales with the window) ---------- */
@font-face { font-family: "Hacen Tunisia"; font-display: swap;
  src: local("Hacen Tunisia"), local("HacenTunisia"), local("Hacen Tunisia Regular"), url("/userfonts/HacenTunisia.ttf") format("truetype"); }
:root {
  --bfont: "Hacen Tunisia", "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
  --mx: 2cm;                                         /* side margins of the program window */
  --mt: 1cm;                                         /* top margin */
  --mb: 0.5cm;                                       /* bottom margin */
  --aw: calc(100vw - 2 * var(--mx));                 /* usable width inside the margins */
  --bh: min(4cm, calc(var(--aw) / 5.3), 25vh);       /* banner height: 4 cm at most (image ratio 2168:409) */
  --th: clamp(68px, 5.6vw, 88px);                    /* tab bar height: stays large in small windows */
  --hh: calc(var(--bh) + var(--th));
}
@media (max-width: 760px) { :root { --mx: 0.5cm; } }
html, body { background: #dde5ef; overflow: hidden; }
#app { position: fixed; inset: var(--mt) var(--mx) var(--mb); display: flex; flex-direction: column; background: var(--bg); border-radius: 12px;
  overflow: hidden; box-shadow: 0 6px 30px rgba(10,30,80,.22); }
.apphead { flex: none; z-index: 40; background: #fff; box-shadow: 0 3px 14px rgba(10,30,80,.18); }
.apphead .ah-banner { height: var(--bh); overflow: hidden; display: flex; justify-content: flex-end; direction: ltr;
  background: url("/static/img/app_banner_fill.png") repeat-x left top / auto 100%; }
.apphead .ah-banner img { height: 100%; width: auto; display: block; flex: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 60px); mask-image: linear-gradient(to right, transparent 0, #000 60px); }
.mtabs { height: var(--th); display: flex; align-items: stretch; padding: calc(var(--th) * .07) calc(var(--th) * .12);
  background: linear-gradient(180deg, #1f4aa8 0%, #143a8c 45%, #0c2a6e 100%); border-top: 2px solid #fff; border-bottom: 2px solid #e6edf7; }
.mtabs a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--th) * .05);
  color: #fff; font-family: var(--bfont); font-weight: 400; font-size: clamp(15px, calc(var(--aw) / 68), 21px); white-space: nowrap; letter-spacing: .2px; padding: 0 5px; text-align: center; line-height: 1.15;
  border-radius: 10px; position: relative; transition: background .15s; }
.mtabs a + a::before { content: ""; position: absolute; inset-inline-start: 0; top: 18%; bottom: 18%; width: 1px; background: rgba(255,255,255,.28); }
.mtabs a svg { width: calc(var(--th) * .38); height: calc(var(--th) * .38); stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mtabs a:hover { background: rgba(255,255,255,.10); }
.mtabs a.on { background: linear-gradient(180deg, #3a8fe8 0%, #1d6fd6 100%); box-shadow: inset 0 0 0 1px rgba(255,255,255,.35), 0 2px 8px rgba(0,0,0,.25); }
.mtabs a.on::before, .mtabs a.on + a::before { display: none; }
.mtabs .who { flex: none; display: flex; flex-direction: column; justify-content: center; gap: 3px; padding-inline-start: 12px; margin-inline-start: 6px;
  border-inline-start: 1px solid rgba(255,255,255,.28); color: #dbe7f6; font-size: 11.5px; max-width: 170px; }
.mtabs .who .u { color: #fff; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mtabs .who .row { display: flex; gap: 4px; }
.mtabs .who button { background: rgba(255,255,255,.13); border: 0; color: #fff; padding: 3px 8px; border-radius: 7px; cursor: pointer; font-family: var(--bfont); font-size: 11.5px; }
.mtabs .who button:hover { background: rgba(255,255,255,.25); }
@media (max-width: 1250px) { .mtabs .who { max-width: 120px; padding-inline-start: 8px; } .mtabs .who > div:nth-child(2) { display: none; } }
@media (max-width: 1180px) { .mtabs a { white-space: normal; } .mtabs .who .u { display: none; } .mtabs .who .row { flex-direction: column; } }
@media (max-width: 1050px) { .mtabs a svg { display: none; } }

/* ---------- layout ---------- */
.shell { flex: 1; min-height: 0; overflow: auto; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 26px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 19px; margin: 0; color: var(--navy); }
.topbar .sp { flex: 1; }
.content { padding: 22px 26px 90px; max-width: 1600px; margin: 0 auto; }

/* ---------- about ---------- */
.about { max-width: 760px; margin: 10px auto; text-align: center; padding: 34px 30px; }
.about img { width: 150px; height: 150px; object-fit: contain; }
.about h2 { color: #1b1464; margin: 14px 0 6px; font-size: 26px; }
.about .stmt { font-size: 18px; line-height: 2; color: #0f1f33; margin: 18px 0; }
.about .by { direction: ltr; font-family: Arial, sans-serif; font-weight: 700; color: #1b1464; font-size: 18px; letter-spacing: .3px; }

/* ---------- elements ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 700; color: var(--navy); }
.card > .hd .sp { flex: 1; }
.card > .bd { padding: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); } .g6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row .sp { flex: 1; }
.stack > * + * { margin-top: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 8px 15px; border-radius: 9px; cursor: pointer; font-weight: 600; white-space: nowrap; transition: .12s; }
.btn:hover { border-color: #c5d3e4; background: #f7fafd; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.cyan { background: var(--cyan); border-color: var(--cyan); color: #fff; }
.btn.cyan:hover { filter: brightness(1.05); }
.btn.green { background: #128c4a; border-color: #128c4a; color: #fff; }
.btn.danger { color: var(--red); border-color: #f3c7c7; }
.btn.danger:hover { background: #fff5f5; }
.btn.big { padding: 12px 22px; font-size: 15.5px; border-radius: 11px; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eef3f9; }

label.f { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
label.f .req { color: var(--red); }
.inp, select.inp, textarea.inp { width: 100%; border: 1px solid #d5dfeb; border-radius: 9px; padding: 9px 11px; background: #fff; outline: none; transition: .12s; }
.inp:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(14,165,198,.15); }
.inp.err { border-color: var(--red); box-shadow: 0 0 0 3px rgba(212,32,32,.1); }
textarea.inp { min-height: 70px; resize: vertical; }
.inp[readonly] { background: #f5f8fb; color: var(--muted); }
.fld { min-width: 0; }
.seg { display: inline-flex; border: 1px solid #d5dfeb; border-radius: 9px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 8px 16px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button + button { border-inline-start: 1px solid #d5dfeb; }
.seg button.on { background: var(--navy); color: #fff; }
.chk { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.chk input { width: 17px; height: 17px; accent-color: var(--navy); }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th { text-align: start; font-size: 12.5px; color: var(--muted); font-weight: 700; padding: 10px 12px; background: #f7f9fc; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 10px 12px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
table.tbl tr.click { cursor: pointer; }
table.tbl tr.click:hover td { background: #f6fafd; }
table.tbl tr.cancelled td { opacity: .55; text-decoration: line-through; }
.tbl-wrap { overflow: auto; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 30px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.pending { background: #fff4e0; color: #b45309; }
.chip.in_progress { background: #e3f0ff; color: #1d4ed8; }
.chip.completed { background: #e2f7ec; color: #0f7a43; }
.chip.sent { background: #dff6fb; color: #0b7f98; }
.chip.cancelled { background: #fde8e8; color: #b91c1c; }
.chip.gray { background: #eef2f7; color: #475569; }
.chip.warn { background: #fff4e0; color: #b45309; }
.chip.ok { background: #e2f7ec; color: #0f7a43; }
.tag { display: inline-block; background: #eef4fb; color: #1e3a8a; border-radius: 6px; padding: 2px 7px; font-size: 12px; margin: 2px; direction: ltr; }

.alert { border-radius: 10px; padding: 11px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.6; }
.alert.warn { background: #fff8eb; border: 1px solid #fde2b4; color: #8a4b08; }
.alert.err { background: #fff1f1; border: 1px solid #f9c9c9; color: #a11b1b; }
.alert.info { background: #eef8fc; border: 1px solid #c9eaf4; color: #0c5a70; }
.alert.ok { background: #ecfaf2; border: 1px solid #bfe9d1; color: #0f6a3b; }

/* ---------- dashboard ---------- */
.stat { padding: 16px; display: flex; gap: 12px; align-items: center; }
.stat .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 21px; flex: none; }
.stat .v { font-size: 23px; font-weight: 800; color: var(--navy); line-height: 1.1; }
.stat .l { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 3px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 20px 10px; text-align: center; color: var(--navy); font-weight: 700; transition: .15s; }
.tile .ic { font-size: 30px; }
.tile:hover { transform: translateY(-2px); border-color: var(--cyan); }
.tile.main { background: linear-gradient(135deg, var(--navy), #1560bd); color: #fff; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding: 8px 4px 0; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.bars .b i { display: block; width: 100%; max-width: 38px; background: linear-gradient(180deg, var(--cyan), #0b7fa0); border-radius: 6px 6px 2px 2px; min-height: 3px; }
.bars .b span { font-size: 11px; color: var(--muted); }
.bars .b em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--navy); }

/* ---------- registration ---------- */
.reg { display: grid; grid-template-columns: 370px minmax(0,1fr); gap: 18px; direction: ltr; align-items: start; }
.reg > * { direction: rtl; }
html[dir=ltr] .reg > * { direction: ltr; }
.picker { position: sticky; top: 72px; max-height: calc(100vh - var(--mt) - var(--mb) - var(--hh) - 92px); min-height: 360px; display: flex; flex-direction: column; }
.pkg-h { background: #fff4f4 !important; color: #b91c1c !important; }
.pkg { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid #f6e3e3; cursor: pointer; user-select: none; background: #fffafa; }
.pkg:hover { background: #fff1f1; }
.pkg.sel { background: #ffe9e9; }
.pkg .nm { flex: 1; font-weight: 700; }
.pkg .ts { font-size: 11.5px; color: var(--muted); direction: ltr; text-align: left; }
.design-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.mini-page { position: relative; width: 100%; aspect-ratio: 210/297; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); overflow: hidden; }
.mini-page .mh { position: absolute; }
.mini-page .mh img { width: 100%; display: block; }
.mini-page .mwm { position: absolute; left: 50%; top: 54%; transform: translate(-50%,-50%); z-index: 3; pointer-events: none; mix-blend-mode: multiply; }
.mini-page .mft { position: absolute; bottom: 0; display: flex; flex-direction: column; justify-content: center; font-family: Arial, Tahoma, sans-serif; overflow: hidden; }
.mini-page .mbody { position: absolute; }
.mini-page .mbody i { display: block; height: 4px; background: #e8eef5; margin: 5px 0; border-radius: 2px; }
.preset { border: 2px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 700; font-size: 12.5px; background: #fff; }
.preset span { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: middle; margin-inline-end: 6px; border: 1px solid rgba(0,0,0,.15); }
.picker .bd { padding: 0; overflow: auto; flex: 1; }
.picker .srch { padding: 12px; border-bottom: 1px solid var(--line); }
.cat-h { display: flex; align-items: center; gap: 8px; padding: 9px 14px; background: #f5f8fc; font-weight: 700; color: var(--navy); cursor: pointer; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1; font-size: 13.5px; }
.cat-h .n { margin-inline-start: auto; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.titem { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid #f0f3f7; cursor: pointer; user-select: none; }
.titem:hover { background: #f6fafd; }
.titem.sel { background: var(--cyan-soft); }
.titem.dis { opacity: .5; cursor: default; }
.titem input { width: 17px; height: 17px; accent-color: var(--navy); flex: none; }
.titem .nm { direction: ltr; text-align: left; flex: 1; font-weight: 600; font-size: 13.5px; }
.titem .pr { font-size: 12.5px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.sel-list { display: flex; flex-wrap: wrap; gap: 8px; }
.sel-pill { display: inline-flex; align-items: center; gap: 8px; background: #eef5fd; border: 1px solid #cfe0f5; border-radius: 30px; padding: 5px 6px 5px 12px; direction: ltr; font-weight: 600; font-size: 13px; }
.sel-pill b { color: var(--muted); font-size: 12px; }
.sel-pill button { border: 0; background: #fff; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; color: var(--red); }
.money { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; }
.money .m { background: #f7fafd; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; }
.money .m .l { font-size: 12px; color: var(--muted); font-weight: 700; }
.money .m .v { font-size: 19px; font-weight: 800; color: var(--navy); margin-top: 4px; }
.money .m.final { background: var(--navy); border-color: var(--navy); }
.money .m.final .l, .money .m.final .v { color: #fff; }
.money .m.rem .v { color: var(--orange); }
.suggest { position: absolute; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(15,40,80,.15); width: 100%; margin-top: 4px; overflow: hidden; }
.suggest div { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f1f4f8; }
.suggest div:hover, .suggest div.on { background: var(--cyan-soft); }

/* ---------- results entry ---------- */
.pbar { display: flex; flex-wrap: wrap; gap: 8px 26px; padding: 14px 18px; }
.pbar .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.pbar .v { font-weight: 800; color: var(--navy); }
.rtest { margin-top: 16px; }
.rtest .hd .nm { direction: ltr; }
table.rt { width: 100%; border-collapse: collapse; direction: ltr; }
table.rt th { text-align: left; font-size: 12px; color: var(--muted); padding: 8px 10px; background: #f7f9fc; border-bottom: 1px solid var(--line); }
table.rt td { padding: 6px 10px; border-bottom: 1px solid #eef2f7; text-align: left; }
table.rt td.pn { font-weight: 600; width: 28%; }
table.rt td.pn .req { color: var(--red); }
table.rt td.res { width: 21%; }
table.rt td.res .inp { padding: 7px 10px; font-weight: 700; text-align: left; direction: ltr; }
table.rt td.res .inp.fL { color: var(--red); border-color: #f2b8b8; background: #fff7f7; }
table.rt td.res .inp.fH, table.rt td.res .inp.fA { color: var(--orange); border-color: #f7cfb3; background: #fffaf5; }
table.rt td.flag { width: 11%; }
table.rt td.unit { width: 10%; color: var(--muted); font-size: 13px; }
table.rt td.ref { color: #334155; font-size: 13px; }
table.rt td.nt { width: 40px; }
.fl { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 800; letter-spacing: .3px; }
.fl.N { background: #e8f1fb; color: #1d4ed8; }
.fl.H, .fl.A { background: #fff0e4; color: var(--orange); }
.fl.L { background: #fdeaea; color: var(--red); }
.calc { font-size: 10.5px; color: var(--cyan); font-weight: 700; margin-inline-start: 5px; }
tr.noterow td { padding-top: 0; }
.actionbar { position: fixed; bottom: var(--mb); inset-inline-start: var(--mx); inset-inline-end: var(--mx); border-radius: 0 0 12px 12px; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: 12px 26px; display: flex; gap: 10px; align-items: center; z-index: 25; box-shadow: 0 -4px 20px rgba(15,40,80,.06); }
.actionbar .sp { flex: 1; }
.dirty-dot { color: var(--orange); font-weight: 700; font-size: 13px; }

/* ---------- modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10,25,50,.45); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .12s; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(1100px, 100%); }
.modal.mid { width: min(760px, 100%); }
.modal .mh { padding: 15px 18px; border-bottom: 1px solid var(--line); font-weight: 800; color: var(--navy); font-size: 16px; display: flex; align-items: center; }
.modal .mh .x { margin-inline-start: auto; border: 0; background: transparent; font-size: 20px; cursor: pointer; color: var(--muted); }
.modal .mb { padding: 18px; overflow: auto; }
.modal .mf { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0 } }
.toasts { position: fixed; top: calc(var(--mt) + var(--hh) + 14px); left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #0f1f33; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-weight: 600; animation: fade .2s; max-width: 600px; }
.toast.ok { background: #0f7a43; } .toast.err { background: #b91c1c; } .toast.warn { background: #b45309; }
.busy { position: fixed; inset: 0; background: rgba(255,255,255,.6); z-index: 150; display: grid; place-items: center; }
.busy .box { background: #fff; padding: 20px 28px; border-radius: 12px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; font-weight: 700; color: var(--navy); }
.spin { width: 22px; height: 22px; border: 3px solid #cfe3f3; border-top-color: var(--navy); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg) } }

/* ---------- login ---------- */
.login { flex: 1; overflow: auto; min-height: 0; display: grid; place-items: center; background: radial-gradient(circle at 20% 10%, #e1f4fa 0, transparent 45%), radial-gradient(circle at 90% 90%, #e6edf9 0, transparent 50%), #f4f7fb; }
.login .card { width: 400px; padding: 30px; text-align: center; }
.login img { width: 120px; height: 120px; }
.login h2 { margin: 10px 0 2px; color: var(--navy); font-size: 26px; }
.login form { text-align: start; margin-top: 18px; }

/* ---------- misc ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 10px 14px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--navy); border-bottom-color: var(--cyan); }
.catlist a { display: flex; justify-content: space-between; padding: 9px 14px; border-bottom: 1px solid #f0f3f7; color: var(--text); font-weight: 600; }
.catlist a.on { background: var(--cyan-soft); color: var(--navy); }
.catlist a .n { color: var(--muted); font-size: 12px; }
.price-inp { width: 110px; padding: 5px 8px; border: 1px solid transparent; border-radius: 7px; background: transparent; font-weight: 700; direction: ltr; }
.price-inp:hover { border-color: #d5dfeb; } .price-inp:focus { border-color: var(--cyan); background: #fff; outline: none; }
.pedit { border: 1px solid var(--line); border-radius: 11px; padding: 12px; margin-bottom: 12px; background: #fbfcfe; }
.pedit .ph { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; font-weight: 700; color: var(--navy); }
.rtbl { width: 100%; border-collapse: collapse; margin-top: 6px; }
.rtbl th { font-size: 11.5px; color: var(--muted); text-align: start; padding: 4px; }
.rtbl td { padding: 3px 4px; }
.rtbl .inp { padding: 6px 8px; }
.tpl-thumb { border: 2px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; background: #fff; }
.tpl-thumb.on { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(14,165,198,.2); }
.tpl-thumb img { width: 100%; aspect-ratio: 210/297; object-fit: fill; display: block; }
.tpl-thumb .cap { padding: 6px 8px; font-size: 12px; font-weight: 700; display: flex; gap: 6px; align-items: center; }
.paper { position: relative; width: 100%; aspect-ratio: 210/297; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.paper img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.paper .area { position: absolute; border: 2px dashed var(--cyan); background: rgba(14,165,198,.12); }
.paper .pi { position: absolute; left: 4%; right: 4%; height: 7%; background: rgba(11,58,126,.18); border: 1px solid rgba(11,58,126,.5); border-radius: 4px; font-size: 10px; color: var(--navy); display: grid; place-items: center; font-weight: 700; }
.paper .pn { position: absolute; left: 0; right: 0; text-align: center; font-size: 9px; color: #333; }
.visit-card { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; background: #fff; overflow: hidden; }
.visit-card .vh { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px; background: #f7f9fc; border-bottom: 1px solid var(--line); }
.visit-card .vb { padding: 12px 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv .k { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.empty .ic { font-size: 34px; opacity: .5; }
pre.json { white-space: pre-wrap; word-break: break-word; font-size: 11.5px; margin: 0; max-width: 520px; direction: ltr; text-align: left; }

@media (max-width: 1200px) {
  .g6 { grid-template-columns: repeat(3, 1fr); } .money { grid-template-columns: repeat(3, 1fr); }
  .reg { grid-template-columns: 320px minmax(0,1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; } .design-grid { grid-template-columns: 1fr; }
  .actionbar { inset-inline-start: 0; } .reg { grid-template-columns: 1fr; } .picker { position: static; max-height: 60vh; }
  .g4, .g3 { grid-template-columns: 1fr 1fr; }
}
@media print { .side, .topbar, .actionbar { display: none !important; } .shell { display: block; } }

/* ---------- buttons use Hacen Tunisia (falls back to Segoe UI / Tahoma when the font is not installed) ---------- */
button, .btn, .preset, .mtabs a, .tabs a, .seg button, input[type=button], input[type=submit] { font-family: var(--bfont) !important; font-weight: 400 !important; }
.btn { font-size: 15.5px; }
.btn.sm { font-size: 14px; }
.btn.big { font-size: 17px; }

.rt td.nt { white-space: nowrap; }
.rt .rmp { color: #b91c1c; }
.rt .rmp:hover { background: #fdecec; }
.removed-row { padding: 6px 12px 0; font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.removed-row button.chip { cursor: pointer; border: 0; }

/* "+ Add Patient" stands out in red */
.mtabs a[data-r="register"] { background: linear-gradient(180deg, #e3262b 0%, #c8161b 100%); box-shadow: inset 0 0 0 1px rgba(255,255,255,.35), 0 2px 8px rgba(0,0,0,.25); margin: 0 3px; }
.mtabs a[data-r="register"]:hover { background: linear-gradient(180deg, #ef3a3f 0%, #d41c21 100%); }
.mtabs a[data-r="register"].on { background: linear-gradient(180deg, #ff4a4f 0%, #e0262b 100%); box-shadow: inset 0 0 0 2px #fff, 0 2px 8px rgba(0,0,0,.3); }
.mtabs a[data-r="register"]::before, .mtabs a[data-r="register"] + a::before { display: none; }

.titem.inpanel { opacity: .62; cursor: not-allowed; }
.titem .inp-tag { margin-inline-start: auto; font-size: 11px; color: #0b3a7e; background: #e6eefb; border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
