/* Medit KSA simulator: a full-screen app styled after Medit Scan for Clinics */
:root{
  --blue:#1d63d8; --blue-d:#0f4fbf; --blue-soft:#e6efff;
  --ink:#1f2937; --muted:#6b7280; --line:#d5d9e0; --panel:#ffffff;
  --ok:#21a35a; --warn:#e5484d; --green-box:#35c83c;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%;overflow:hidden;background:#e7e8ea}
body{font-family:"Segoe UI",system-ui,-apple-system,"Cairo",sans-serif;color:var(--ink);-webkit-font-smoothing:antialiased}
[dir=rtl]{font-family:"Cairo","Segoe UI",system-ui,sans-serif}
button{font:inherit}
svg{display:block}

.app{display:flex;flex-direction:column;height:100vh;height:100dvh}

/* title bar */
.titlebar{position:relative;flex:none;height:36px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 8px;z-index:30}
.tb-left,.tb-right{display:flex;align-items:center;gap:6px}
.tb-btn,.tb-ico{width:28px;height:28px;border:0;background:none;border-radius:4px;display:grid;place-items:center;color:#4b5563;cursor:pointer;text-decoration:none}
.tb-btn:hover,.tb-ico:hover{background:#eef1f5}
.tb-btn svg,.tb-ico svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round}
.tb-ico.rec svg{fill:#e5484d;stroke:none}
.tb-ico.close:hover{background:#e5484d;color:#fff}
.appname{color:var(--blue);font-size:13px;font-weight:600;white-space:nowrap}
.appname b{font-weight:800;letter-spacing:.3px}
.tb-center{position:absolute;left:50%;transform:translateX(-50%);font-size:12px;color:#6b7280;pointer-events:none;white-space:nowrap}
.ver{font-style:normal;font-weight:400;color:#6b7280;margin-left:3px}
.tb-sep{width:1px;height:18px;background:var(--line);margin:0 3px}
.simple{position:relative;display:flex;align-items:center;gap:7px;font-size:12.5px;color:#374151;cursor:pointer;user-select:none;white-space:nowrap}
.simple input{position:absolute;opacity:0;pointer-events:none}
.simple i{position:relative;width:30px;height:16px;border-radius:99px;background:#9ca3af;transition:.2s}
.simple i::after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:.2s}
.simple input:checked+i{background:var(--blue)}
.simple input:checked+i::after{left:16px}
.simple input:focus-visible+i{outline:2px solid var(--blue);outline-offset:2px}

/* left panel */
.body{flex:1;display:flex;min-height:0}
.side{flex:none;width:214px;background:#fff;border-right:1px solid var(--line);display:flex;flex-direction:column;padding:8px 12px 12px;overflow-y:auto;z-index:6}
.sd-h{display:flex;justify-content:space-between;align-items:center;font-size:13.5px;color:#374151;margin:8px 0 7px}
.sd-col{border:0;background:none;color:#6b7280;cursor:pointer;font-size:17px;line-height:1;padding:2px 4px;border-radius:4px}
.sd-col:hover{background:#eef1f5}
.sd-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:2px}
.sd-t{aspect-ratio:1;border:1px solid var(--line);background:#f6f7f9;display:grid;place-items:center;color:#6b7280;cursor:pointer;padding:0}
.sd-t:hover{background:var(--blue-soft);color:var(--blue);border-color:#9db9ea}
.sd-t svg{width:34px;height:34px;fill:none;stroke:currentColor;stroke-width:1.3;stroke-linecap:round;stroke-linejoin:round}
.sd-t .fillc{fill:#fff}
.form-info{display:flex;flex-direction:column;gap:4px;padding:4px 2px}
.fi-arch{width:100%;height:auto}
.fi-arch .b{fill:#eef1f5;stroke:#a7b0bd;stroke-width:1}
.fi-arch .t{fill:#fff;stroke:#a7b0bd;stroke-width:1}
.fi-arch.cur .b{fill:#d3e3ff;stroke:var(--blue)}
.fi-arch.cur .t{stroke:var(--blue)}
.fi-arch.done .b{fill:#d9f2e3;stroke:var(--ok)}
.fi-arch.done .t{stroke:var(--ok)}
.sd-scanner{margin-top:auto;padding-top:14px;display:flex;flex-direction:column;align-items:center;gap:7px}
.sc-wand svg{width:150px;height:34px;fill:none;stroke:#6b7280;stroke-width:1.3;stroke-linejoin:round}
.sc-wand .body{fill:#fff}
.sc-wand .ring{stroke:var(--blue);stroke-width:2}
.sc-bar{width:100px;height:6px;border-radius:3px;background:#9ca3af;transition:background .2s}
.sc-bar.on{background:var(--ok)}
.sc-bar.lost{background:var(--warn)}
.sc-txt{font-size:11.5px;color:var(--muted);font-family:"Cairo",sans-serif;text-align:center}
.sc-btns{display:flex;gap:4px}
.sc-btns button{width:40px;height:36px;border:1px solid var(--line);background:#fff;border-radius:3px;color:#6b7280;display:grid;place-items:center;cursor:pointer;padding:0}
.sc-btns button:hover{color:var(--blue);border-color:#9db9ea}
.sc-btns svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round}
.side-open{display:none;position:absolute;left:0;bottom:110px;z-index:6;width:18px;height:48px;border:1px solid var(--line);border-left:0;background:#fff;border-radius:0 6px 6px 0;cursor:pointer;color:#6b7280;padding:0}
.app.side-off .side,.app.simple .side,.app.simple .adv{display:none}
.app.side-off .side-open{display:block}
.app.simple .side-open{display:none}
.device{font-size:12px;color:var(--muted);display:flex;align-items:center;gap:6px}
.device select{font:inherit;font-weight:700;color:var(--ink);border:1px solid var(--line);border-radius:4px;padding:3px 6px;background:#fff}
.menu{position:absolute;top:36px;left:6px;background:#fff;border:1px solid var(--line);border-radius:8px;box-shadow:0 12px 30px rgba(0,0,0,.15);padding:6px;min-width:220px;display:flex;flex-direction:column}
.menu[hidden]{display:none}
.menu a,.menu button{display:block;text-align:right;padding:9px 12px;border-radius:6px;color:var(--ink);text-decoration:none;border:0;background:none;cursor:pointer;font-size:14px;font-family:"Cairo",sans-serif}
.menu a:hover,.menu button:hover{background:var(--blue-soft);color:var(--blue)}
.m-lang{display:flex;gap:4px;border-top:1px solid var(--line);margin-top:4px;padding-top:6px}
.menu .m-lang button{flex:1;text-align:center;padding:6px 4px;font-size:13px;font-weight:700;border:1px solid var(--line)}
.menu .m-lang button.on{background:var(--blue);border-color:var(--blue);color:#fff}
html[lang=ur] .app [dir=rtl],html[lang=ur] .menu{font-family:"Noto Naskh Arabic","Cairo",sans-serif}
html.i18n-wait body{visibility:hidden}

/* viewport */
.viewport{position:relative;flex:1;min-width:0;overflow:hidden;background:radial-gradient(ellipse at 50% 40%,#f4f4f5 0%,#e3e4e6 70%,#d9dadd 100%);touch-action:none}
#gl{position:absolute;inset:0;width:100%;height:100%;display:block}
.viewport.scanning #gl{cursor:none}

.tool{position:relative;width:38px;height:38px;border:1px solid var(--line);background:#fff;border-radius:4px;display:grid;place-items:center;color:#4b5563;cursor:pointer;padding:0;box-shadow:0 1px 2px rgba(0,0,0,.06)}
.tool:hover:not([disabled]){border-color:#9db9ea;color:var(--blue)}
.tool.on{border-color:var(--blue);background:var(--blue-soft);color:var(--blue)}
.tool[disabled]{opacity:.4;cursor:not-allowed}
.tool svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.tool svg.multi{stroke:none}
.tool small{position:absolute;bottom:-15px;left:50%;transform:translateX(-50%);font-size:10px;color:var(--muted);white-space:nowrap}

/* step bar (top center) */
.steps{position:absolute;top:12px;left:50%;transform:translateX(-50%);display:flex;gap:6px;z-index:5}
.step{position:relative;width:60px;height:56px;border:1px solid var(--line);background:#fff;border-radius:3px;cursor:pointer;display:grid;place-items:center;padding:0;color:#6b7280;box-shadow:0 1px 2px rgba(0,0,0,.05)}
.step:hover:not([disabled]){border-color:#9db9ea}
.step svg{width:46px;height:36px;fill:none;stroke:currentColor;stroke-width:1.2;stroke-linecap:round;stroke-linejoin:round}
.step .g{fill:currentColor;opacity:.22;stroke:none}
.step .tt{fill:#fff}
.step .lens{fill:rgba(255,255,255,.85)}
.step.cur{border:2px solid var(--blue);background:#cfe0fb;color:var(--blue)}
.step[disabled]{cursor:not-allowed;opacity:.5}
.step.done::after{content:"✓";position:absolute;right:-5px;bottom:-5px;width:15px;height:15px;border-radius:50%;background:var(--ok);color:#fff;font-size:10px;display:grid;place-items:center;font-weight:800}
.step .lbl{position:absolute;top:60px;left:50%;transform:translateX(-50%);font-size:10.5px;color:var(--muted);white-space:nowrap;font-family:"Cairo",sans-serif}
.step.cur .lbl{color:var(--blue);font-weight:700}

/* stats (top right) */
.stats{position:absolute;top:14px;right:14px;display:flex;flex-direction:column;gap:6px;align-items:flex-end;z-index:5;font-size:13px;color:#4b5563;font-variant-numeric:tabular-nums}
.stats div{display:flex;align-items:center;gap:6px}
.stats svg{width:15px;height:15px;fill:none;stroke:#6b7280;stroke-width:1.6;stroke-linecap:round}

/* right tools */
.rtools{position:absolute;right:14px;top:50%;transform:translateY(-80%);display:flex;flex-direction:column;gap:8px;z-index:5}

/* zoom slider (left) */
.zoom{position:absolute;left:22px;top:44%;height:min(38%,300px);z-index:5;display:flex;flex-direction:column;align-items:center;gap:8px}
.zoom input{writing-mode:vertical-lr;direction:rtl;width:22px;flex:1;min-height:0;margin:0;accent-color:var(--blue);cursor:pointer}
.z-ico{flex:none;width:26px;height:26px;border-radius:50%;background:#fff;border:2px solid var(--blue);color:var(--blue);display:grid;place-items:center;cursor:pointer;padding:0}
.z-ico svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linejoin:round}

/* case info (opens from the first step) */
.casecard{position:absolute;top:96px;left:50%;transform:translateX(-50%);width:290px;background:#fff;border:1px solid var(--line);border-radius:8px;box-shadow:0 12px 30px rgba(0,0,0,.12);padding:12px 16px;z-index:8;font-family:"Cairo",sans-serif}
.casecard[hidden]{display:none}
.casecard h3{margin:0 0 6px;font-size:15px}
.casecard dl{display:grid;grid-template-columns:auto 1fr;gap:4px 12px;margin:0 0 8px;font-size:13px}
.casecard dt{color:var(--muted)}
.casecard dd{margin:0;font-weight:700;text-align:right}
.casecard p{margin:0;font-size:12px;color:var(--muted);line-height:1.7}

/* "Start scanning!" cue on an empty step */
.startcue{position:absolute;right:76px;bottom:24%;z-index:3;pointer-events:none;font:700 21px "Segoe UI",system-ui,sans-serif;color:#111827;transition:opacity .4s}
.startcue::before{content:"";position:absolute;width:280px;height:320px;right:-30px;bottom:34px;border-radius:50%;background:radial-gradient(circle at 50% 38%,rgba(110,150,255,.5),rgba(226,140,230,.38) 46%,transparent 70%);filter:blur(28px);z-index:-1;animation:cue 5s ease-in-out infinite alternate}
.startcue.off{opacity:0}
@keyframes cue{to{transform:translateY(-16px) scale(1.07)}}
@media (prefers-reduced-motion:reduce){.startcue::before{animation:none}}

/* coach card (top left) */
.coach-i{position:absolute;top:12px;left:14px;width:24px;height:24px;border-radius:50%;border:1.5px solid #6b7280;background:#fff;color:#4b5563;font:700 13px/1 Georgia,serif;cursor:pointer;z-index:6;padding:0}
.coach-i:hover{border-color:var(--blue);color:var(--blue)}
.coach[hidden]{display:none}
.c-nav{display:flex;align-items:center;gap:8px;font-size:13px;color:#6b7280;margin:-4px 0 4px;font-variant-numeric:tabular-nums}
.c-nav button{border:0;background:none;cursor:pointer;color:#6b7280;font-size:19px;width:24px;height:24px;border-radius:4px;padding:0;line-height:1}
.c-nav button:hover{background:#eef1f5;color:var(--blue)}
.c-nav .c-help{margin-left:auto;border:1.5px solid #9ca3af;border-radius:50%;font-size:12px;font-weight:700;width:22px;height:22px}
.c-fig{margin:0 0 8px;border-radius:6px;background:linear-gradient(#fff,#f6f8fb)}
.c-fig svg{width:100%;height:auto}
.c-fig .tt{fill:#fff;stroke:#b7bfca;stroke-width:1.2}
.c-fig .g{fill:#f3c3c8;stroke:none}
.c-fig .p1,.c-fig .p2,.c-fig .p3{fill:none;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round}
.c-fig .p1{stroke:var(--blue)} .c-fig .p2{stroke:#8b5cf6;stroke-dasharray:5 4} .c-fig .p3{stroke:#0ea5a4;stroke-dasharray:2 4}
.c-fig .p1d{fill:var(--blue)} .c-fig .p2d{fill:#8b5cf6} .c-fig .p3d{fill:#0ea5a4}
.c-fig .n1{fill:var(--blue)} .c-fig .n2{fill:#8b5cf6} .c-fig .n3{fill:#0ea5a4}
.c-fig text{fill:#fff;font:700 11px "Segoe UI",sans-serif;text-anchor:middle}
.c-fig .okc{fill:#e5f6ec;stroke:var(--ok);stroke-width:2}
.c-fig .okm{fill:none;stroke:var(--ok);stroke-width:5;stroke-linecap:round;stroke-linejoin:round}
.coach{position:absolute;top:44px;left:12px;width:296px;background:rgba(255,255,255,.96);border:1px solid var(--line);border-radius:8px;padding:12px 14px;box-shadow:0 8px 24px rgba(0,0,0,.08);z-index:6}
.c-step{font-size:12px;color:var(--blue);font-weight:700}
.coach h2{margin:2px 0 4px;font-size:17px}
.coach p{margin:0 0 10px;font-size:13px;color:#4b5563;line-height:1.7}
.c-bar{position:relative;height:8px;background:#e5e7eb;border-radius:99px;overflow:visible}
.c-bar i{display:block;height:100%;width:0;border-radius:99px;background:var(--blue);transition:width .2s}
.c-bar i.full{background:var(--ok)}
.c-bar b{position:absolute;top:-3px;width:2px;height:14px;background:#111827;border-radius:2px}
.c-meta{display:flex;justify-content:space-between;gap:8px;font-size:12px;color:var(--muted);margin-top:6px;flex-wrap:wrap}
.c-meta .ok{color:var(--ok);font-weight:700}
.c-next{margin-top:10px;width:100%;border:0;border-radius:6px;background:var(--ok);color:#fff;font-weight:700;padding:8px;cursor:pointer;font-family:"Cairo",sans-serif}
.c-next[hidden]{display:none}

/* scanner overlays */
.scanbox{position:absolute;left:0;top:0;border:2px solid var(--green-box);pointer-events:none;display:none;z-index:4;box-shadow:0 0 0 1px rgba(255,255,255,.4)}
.scanbox.lost{border-color:var(--warn)}
.lost{position:absolute;top:70px;left:50%;transform:translateX(-50%);background:var(--warn);color:#fff;padding:6px 14px;border-radius:6px;font-size:13px;font-weight:700;z-index:7}
.lost[hidden]{display:none}
.wand{position:absolute;left:0;top:0;width:84px;height:auto;pointer-events:none;display:none;z-index:8;transform-origin:50% 0.8%;filter:drop-shadow(8px 14px 10px rgba(0,0,0,.28))}

/* live view (bottom right) */
.live[hidden]{display:none}
.live{position:absolute;right:14px;bottom:78px;width:min(300px,34vw);border:1px solid var(--line);border-radius:4px;box-shadow:0 6px 18px rgba(0,0,0,.1);z-index:5;overflow:hidden}
/* the body stays see-through: the live camera is drawn into the WebGL canvas underneath */
.live-h{display:flex;justify-content:space-between;font-size:11.5px;padding:4px 8px;color:#374151;border-bottom:1px solid var(--line);background:#fff}
.live-h span{color:var(--muted)}
.live-h span.on{color:var(--ok);font-weight:700}
.live-b{position:relative;aspect-ratio:4/3;background:#2a2f36;display:grid;place-items:center}
.live-b span{color:#9ca3af;font-size:12px;font-family:"Cairo",sans-serif}

/* undo / redo (bottom left) and toolbar (bottom center) */
.undo{position:absolute;left:14px;bottom:28px;display:flex;gap:8px;z-index:5}
.toolbar{position:absolute;left:50%;bottom:24px;transform:translateX(-50%);display:flex;align-items:center;gap:6px;z-index:5;max-width:calc(100% - 140px)}
.toolbar .tool{width:42px;height:42px}
.tb-gap{flex:none;width:8px}
.tool .sw{position:absolute;bottom:3px;left:50%;transform:translateX(-50%);font-style:normal;font-size:8.5px;font-weight:700;background:#9ca3af;color:#fff;border-radius:99px;padding:0 5px;line-height:12px}
.tool.on .sw{background:var(--blue)}
.tool.sw-t svg,.tool.has-sw .hd{margin-top:-9px}
.toolbar .tool.play{width:48px;height:48px;background:var(--blue);border-color:var(--blue);color:#fff}
.tool.play svg{fill:currentColor;stroke:none;width:22px;height:22px}
.tool.play:hover:not([disabled]){background:var(--blue-d);color:#fff}
.tool.play.on{background:#fff;color:var(--blue);border:2px solid var(--blue)}
.hd{font-size:12px;font-weight:800;border:1.5px solid currentColor;border-radius:3px;padding:0 3px;line-height:15px}
.filter{display:flex;flex-direction:column;align-items:center;gap:2px;border:1px solid var(--line);border-radius:4px;padding:5px 8px 4px;background:#fff;height:42px;justify-content:center}
.filter input{width:110px;margin:0;accent-color:var(--blue)}
.f-ico{display:flex;justify-content:space-between;width:120px}
.f-ico svg{width:15px;height:15px;fill:none;stroke:#6b7280;stroke-width:1.3;stroke-linejoin:round}
.f-ico .pk{stroke:#e48a95}

.toast{position:absolute;left:50%;top:76px;transform:translate(-50%,-20px);opacity:0;background:#111827;color:#fff;padding:8px 16px;border-radius:6px;font-size:13.5px;z-index:9;transition:.25s;pointer-events:none;max-width:90%}
.toast.show{opacity:1;transform:translate(-50%,0)}

/* dialogs */
.modal{position:absolute;inset:0;z-index:20;background:rgba(17,24,39,.45);backdrop-filter:blur(3px);display:none;place-items:center;padding:16px}
.modal.show{display:grid}
.dlg{background:#fff;border-radius:12px;max-width:620px;width:100%;max-height:100%;overflow:auto;padding:24px 26px;box-shadow:0 30px 60px rgba(0,0,0,.3)}
.dlg h1{font-size:22px;margin:4px 0 8px}
.dlg p{color:#4b5563;line-height:1.8;margin:0 0 12px;font-size:14.5px}
.kick{font-size:12.5px;font-weight:700;color:var(--blue)}
.pick{display:grid;grid-template-columns:repeat(6,1fr);gap:8px;margin:6px 0 14px}
.pick button{border:1.5px solid var(--line);background:#fff;border-radius:8px;padding:6px 4px 8px;cursor:pointer;display:flex;flex-direction:column;align-items:center;gap:4px;font-size:12px;font-weight:700;direction:ltr}
.pick button img{width:100%;height:84px;object-fit:cover;border-radius:5px;background:#eef2f7}
.pick button.on{border-color:var(--blue);background:var(--blue-soft);color:var(--blue)}
.howto{margin:0 0 16px;padding-inline-start:18px;font-size:13.5px;color:#4b5563;line-height:1.9}
.acts{display:flex;gap:8px;flex-wrap:wrap}
.btn{border:1px solid var(--line);background:#fff;color:var(--ink);border-radius:8px;padding:10px 16px;font-weight:700;cursor:pointer;text-decoration:none;font-family:"Cairo",sans-serif;font-size:14px}
.btn.primary{background:var(--blue);border-color:var(--blue);color:#fff}
.btn:hover{border-color:var(--blue)}
.fine{font-size:12px !important;color:#9ca3af !important;margin:12px 0 0 !important}
.dstats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:12px 0}
.dstats div{background:#f3f6fb;border-radius:8px;padding:10px;text-align:center}
.dstats b{display:block;font-size:22px;font-variant-numeric:tabular-nums;direction:ltr}
.dstats span{font-size:12px;color:var(--muted)}
.dsteps{width:100%;border-collapse:collapse;font-size:13.5px;margin-bottom:12px}
.dsteps td{padding:6px 4px;border-bottom:1px solid #eef0f3}
.dsteps td:last-child{text-align:left;direction:ltr;font-variant-numeric:tabular-nums}
.dcmp{margin-bottom:16px}
.dcmp .row{display:grid;grid-template-columns:110px 1fr 60px;gap:8px;align-items:center;font-size:12.5px;margin:5px 0;direction:ltr}
.dcmp .bar{height:11px;background:#eef1f5;border-radius:99px;overflow:hidden}
.dcmp .bar i{display:block;height:100%;background:var(--blue);border-radius:99px}
.dcmp .bar i.est{background:repeating-linear-gradient(45deg,#9cc2f5 0 6px,#cfe1fb 6px 12px)}
.dcmp .row.me{font-weight:800}

/* mid-size laptops: the case name would run into the right-hand controls */
@media (max-width:1340px){.tb-center{display:none}}
@media (max-width:1100px){.tb-ico.x-tb,.tb-sep.x-tb{display:none}}

/* small screens */
@media (max-width:860px){
  .side,.side-open,.adv,.x-tb,.simple,.tb-sep,.ver,#winMax,.coach-i,.c-nav,.c-fig,.step .lbl{display:none !important}
  .steps{gap:4px}
  .step{width:44px;height:42px}
  .step svg{width:34px;height:27px}
  .startcue{right:auto;left:50%;transform:translateX(-50%);bottom:250px;font-size:17px;white-space:nowrap}
  .startcue::before{right:-60px;width:240px;height:260px}
  .casecard{top:64px}
  .coach{width:auto;right:12px;top:62px;padding:8px 12px}
  .coach p{display:none}
  .coach h2{font-size:15px}
  .live{width:42vw;bottom:84px}
  .rtools{top:auto;bottom:220px;transform:none}
  .zoom{display:none}
  .stats{top:auto;bottom:84px;right:auto;left:14px;align-items:flex-start;font-size:12px}
  .undo{display:none}
  .wand{width:52px}
  .toolbar{max-width:calc(100% - 16px);gap:6px}
  .filter{display:none}
  .tb-center,.tb-ico.rec{display:none}
  .appname{font-size:12px}
  .pick{grid-template-columns:repeat(3,1fr)}
}
@media (max-width:420px){.device{font-size:0}.device select{font-size:12px}}
