/* ===================== v82 — refinements ON TOP of the glass look (branch phase2/ui-and-fixes) =====================
   The glass / lux look and the navy-blue identity are untouched. This layer only improves structure and ergonomics:
   labelled menu groups, page crumb, centred content width, filter grid, readable tables, client-first contract rows, phone fixes. */

/* ---------- menu groups + crumb ---------- */
html:not(.classic) body .side .nav-grp{font-size:11.5px;font-weight:600;letter-spacing:.02em;color:var(--side-mute,rgba(200,214,245,.55));padding:16px 14px 6px}
html:not(.classic) body .side .nav-grp:first-child{padding-top:6px}
html:not(.classic) body .tb-crumb{font-weight:700;font-size:16px;white-space:nowrap;color:var(--fg)}
html:not(.classic) body .tb-crumb small{display:block;font-weight:500;font-size:11.5px;color:var(--muted);margin-top:-2px}

/* ---------- content width + rhythm ---------- */
html:not(.classic) body main#main{max-width:1500px;margin-inline:auto;width:100%}
html:not(.classic) body .vhead{margin-bottom:12px}
html:not(.classic) body .lx-sec{margin:22px 0 12px}
html:not(.classic) body .lx-qa{grid-template-columns:repeat(auto-fill,minmax(220px,1fr))}
html:not(.classic) body .lx-tile.main{grid-column:span 2}

/* ---------- filters: an aligned grid instead of ragged wrapping ---------- */
html:not(.classic) body .filters{display:grid!important;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:12px;align-items:end}
html:not(.classic) body .filters .q{grid-column:1/-1;display:flex;gap:8px;align-items:center}
html:not(.classic) body .filters .q label,html:not(.classic) body .filters .q input{flex:1;width:100%}
html:not(.classic) body .filters .seg,html:not(.classic) body .filters .fcount{grid-column:1/-1}
html:not(.classic) body .filters .fcount{margin:0;display:flex;gap:12px;align-items:center}
html:not(.classic) body .filters label,html:not(.classic) body .filters .fld{text-align:start;align-items:stretch}

/* ---------- tables ---------- */
html body table{font-variant-numeric:tabular-nums}
html:not(.classic) body table thead th{position:sticky;top:0;z-index:2;white-space:nowrap}
html:not(.classic) body table tbody tr{transition:background .12s}
html:not(.classic) body table tbody tr:hover td{background:color-mix(in srgb,var(--surface-2) 70%,transparent)}
html:not(.classic) body .tw{scrollbar-width:thin}

/* ---------- client first: the client is the main line, the worker sits under it ---------- */
html body .party{min-width:190px}
html body .party .pname{display:block;font-size:16px;font-weight:700;line-height:1.35;text-align:start;padding:0}
html body .party .pwork{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;margin-top:2px;font-size:13px;color:var(--muted)}
html body .party .pwork .link{font-weight:600;font-size:13px}
html body .m-b .pname{font-size:18px;font-weight:700}
.classic .party .pname{font-size:15px}
.classic .party .pwork{font-size:12.5px}

/* ---------- accessibility ---------- */
html body :is(button,[role=button],a,input,select,textarea):focus-visible{outline:2px solid var(--b5,#1565d8);outline-offset:2px}
@media (prefers-reduced-motion:reduce){html body *{transition:none!important;animation:none!important}}

/* ---------- phone ---------- */
@media (max-width:900px){
  html:not(.classic) body .topbar .searchbtn .lbl,html:not(.classic) body .topbar .searchbtn kbd{display:none}
  html:not(.classic) body .topbar .searchbtn{width:40px;min-width:40px;padding:0;justify-content:center;flex:0 0 auto}
  html:not(.classic) body .tb-crumb{flex:1;font-size:15px}
  html:not(.classic) body .side nav{padding-bottom:90px}
  html:not(.classic) body main#main{padding-bottom:96px}
  html:not(.classic) body .lx-qa{grid-template-columns:repeat(2,minmax(0,1fr))}
  html:not(.classic) body .filters{grid-template-columns:repeat(2,minmax(0,1fr))}
  html:not(.classic) body #sbxTasks{display:none}
}
@media print{html body .tb-crumb,html body .nav-grp{display:none}}

/* ---------- phone: page-head actions wrap instead of overflowing ---------- */
@media (max-width:900px){
  html:not(.classic) body .vhead .acts,html:not(.classic) body .vhead .actions,html:not(.classic) body .vhead>div:last-child:not(:first-child){display:flex;flex-wrap:wrap;gap:8px;max-width:100%}
  html:not(.classic) body .vhead .btn,html:not(.classic) body .vhead button{flex:1 1 auto;min-width:0}
}

/* ---------- colour punch (glass look kept; only saturation/contrast raised) ---------- */
html:not(.classic) body .side{background-image:linear-gradient(180deg,rgba(14,42,110,.78),rgba(7,20,62,.72))!important}
html:not(.classic) body .side .nav-grp{color:rgba(170,200,255,.85)!important;font-weight:700}
html:not(.classic) body .side .nav-i{color:#eef3ff!important;font-weight:600}
html:not(.classic) body .side .nav-i .ic{filter:saturate(1.45) brightness(1.12);box-shadow:inset 0 0 0 1px rgba(255,255,255,.14)}
html:not(.classic) body .side .nav-i:hover{background:rgba(70,130,255,.18)!important}
html:not(.classic) body .side .nav-i[aria-current="page"]{background:linear-gradient(135deg,rgba(45,120,255,.55),rgba(30,80,200,.35))!important;box-shadow:0 0 0 1px rgba(120,170,255,.55),0 6px 18px rgba(20,70,200,.35)}
html:not(.classic) body .side .nav-i[aria-current="page"] .ic{filter:saturate(1.8) brightness(1.2)}
/* light theme: stronger blue for links, headers, pills, KPI numbers */
html:not(.classic)[data-theme="light"] body{--accent:#0b57d0}
html:not(.classic)[data-theme="light"] body table thead th{color:#0a2a6b;font-weight:700}
html:not(.classic)[data-theme="light"] body .link{color:#0b57d0}
html:not(.classic) body .kpi b,html:not(.classic) body .home-kpis b{font-weight:800}
html:not(.classic) body .pill{font-weight:700;filter:saturate(1.35)}
html:not(.classic) body .tabs .on,html:not(.classic) body .hubtabs [aria-selected="true"]{color:#0b57d0;font-weight:700}

/* ---------- phone surfaces: 70% opaque + blur (keeps text readable, glass look kept) ---------- */
html:not(.classic) body .sheet,html:not(.classic) body .msheet{background:rgba(255,255,255,.70)!important;-webkit-backdrop-filter:blur(18px) saturate(1.4)!important;backdrop-filter:blur(18px) saturate(1.4)!important;box-shadow:0 -12px 40px rgba(5,13,36,.35)!important}
html[data-theme="dark"]:not(.classic) body .sheet,html[data-theme="dark"]:not(.classic) body .msheet{background:rgba(11,29,68,.70)!important;border-top:1px solid rgba(120,160,255,.25)!important}
html:not(.classic) body .sheet-ov{background:rgba(3,9,26,.45)!important}
html:not(.classic) body .bkbar,html:not(.classic) body .bnav{background:rgba(255,255,255,.70)!important;-webkit-backdrop-filter:blur(18px) saturate(1.4)!important;backdrop-filter:blur(18px) saturate(1.4)!important}
html[data-theme="dark"]:not(.classic) body .bkbar,html[data-theme="dark"]:not(.classic) body .bnav{background:rgba(11,29,68,.70)!important}
@media (max-width:900px){
  html:not(.classic) body .side{background:rgba(255,255,255,.70)!important;background-image:none!important;-webkit-backdrop-filter:blur(18px) saturate(1.4)!important;backdrop-filter:blur(18px) saturate(1.4)!important}
  html[data-theme="dark"]:not(.classic) body .side{background:rgba(8,23,58,.70)!important}
  html:not(.classic) body .scrim{background:rgba(3,9,26,.45)!important}
}

/* ---------- Document studio ---------- */
.ds-ed{position:fixed;inset:0;z-index:9000;display:flex;flex-direction:column;background:var(--bg,#eef3fb);color:var(--fg,#0c1630)}
.ds-top{display:flex;align-items:center;gap:8px;padding:8px 12px;border-bottom:1px solid var(--line,#c9d4ea);background:var(--surface,#fff);flex-wrap:wrap}
.ds-top .grow{flex:1}.ds-title{flex:1 1 220px;min-width:140px;font-size:16px;font-weight:700;border:1px solid var(--line,#c9d4ea);border-radius:8px;padding:6px 10px;background:var(--surface-2,#f6f8fd);color:inherit}
.ds-rib{display:flex;flex-wrap:wrap;gap:4px;align-items:center;padding:6px 12px;border-bottom:1px solid var(--line,#c9d4ea);background:var(--surface,#fff)}
.ds-b{min-width:34px;height:34px;padding:0 8px;border:1px solid var(--line,#c9d4ea);border-radius:8px;background:var(--surface-2,#f6f8fd);color:inherit;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;font:inherit;font-size:13px;position:relative}
.ds-b:hover{background:rgba(11,87,208,.12)}.ds-b input[type=color]{position:absolute;inset:0;opacity:0;cursor:pointer;width:100%;height:100%}
.ds-rib select{height:34px;border:1px solid var(--line,#c9d4ea);border-radius:8px;background:var(--surface-2,#f6f8fd);color:inherit;padding:0 6px}
.ds-sep{width:1px;height:24px;background:var(--line,#c9d4ea);margin:0 4px}
.ds-main{flex:1;display:flex;min-height:0}
.ds-side{width:290px;flex:0 0 290px;overflow:auto;border-inline-end:1px solid var(--line,#c9d4ea);background:var(--surface,#fff);padding:10px}
.ds-tabs{display:flex;gap:4px;margin-bottom:10px}.ds-tabs button{flex:1;padding:6px 4px;border:0;border-radius:8px;background:transparent;color:inherit;font:inherit;font-size:13px;cursor:pointer}
.ds-tabs button.on{background:#0b57d0;color:#fff;font-weight:700}
.ds-chips{display:flex;flex-wrap:wrap;gap:6px}.ds-chip{border:1px solid var(--line,#c9d4ea);background:var(--surface-2,#f6f8fd);color:inherit;border-radius:999px;padding:4px 10px;font:inherit;font-size:12.5px;cursor:pointer;display:flex;flex-direction:column;align-items:center;line-height:1.2}
.ds-chip small{font-size:10px;color:var(--muted,#667);direction:ltr}
.ds-grid2{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.ds-note{background:rgba(11,87,208,.10);border:1px solid rgba(11,87,208,.35);border-radius:10px;padding:8px 10px;font-size:12.5px;margin:8px 0}
.ds-lg{display:flex;flex-direction:column;gap:2px;padding:6px 0;border-bottom:1px dashed var(--line,#c9d4ea);font-size:13px}.ds-lg span{color:var(--muted,#667);font-size:12px}
.ds-canvas{flex:1;overflow:auto;padding:14px 12px 80px;background:#8a96b0}
html[data-theme="dark"] .ds-canvas{background:#0a1430}
.ds-sheetwrap{margin:0 auto;position:relative}
.ds-sheet{background:#fff;color:#0c1630;box-shadow:0 8px 30px rgba(5,13,36,.35);box-sizing:border-box;position:relative;background-image:repeating-linear-gradient(to bottom,transparent 0,transparent calc(var(--pg-h) - 2px),rgba(220,60,60,.5) calc(var(--pg-h) - 2px),rgba(220,60,60,.5) var(--pg-h));}
.ds-sheet.wm::before{content:"";position:absolute;top:50%;left:50%;width:55%;aspect-ratio:560/380;transform:translate(-50%,-50%) rotate(-12deg);background:url(icons/globe-navy.webp) center/contain no-repeat;opacity:.05;pointer-events:none}
.ds-body{outline:0;min-height:400px;line-height:1.7;position:relative}
.ds-body:focus{outline:0}.ds-body table{border-collapse:collapse}.ds-body td,.ds-body th{min-width:24px}
.ds-body .ds-blank{background:#fff3a8;border-radius:3px}
.ds-body .ds-slot{border:2px dashed #0b57d0;border-radius:8px;min-height:60px;margin:8px 0;position:relative}.ds-body .ds-slot::after{content:"موضع الختم والتوقيع (يظهر بعد الاعتماد)";position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#0b57d0;font-size:12px}
.ds-body .ds-pb{border-top:2px dashed #c33;margin:14px 0;height:0}.ds-body .ds-pb::after{content:"فاصل صفحة";font-size:10px;color:#c33}
.ds-lh{display:flex;justify-content:space-between;align-items:center;gap:12px;border-bottom:2px solid #0a2a6b;padding-bottom:6px;margin-bottom:10px;direction:ltr}
.ds-lh img{height:48px}.ds-lh-r{text-align:right;direction:rtl;display:flex;flex-direction:column;font-size:12px}.ds-lh-r b{font-size:18px;color:#0a2a6b}
.ds-ft{border-top:1px solid #9aa8c8;padding-top:4px;margin-top:12px;font-size:10px;color:#445;text-align:center}.ds-pn{font-size:10px;color:#889;text-align:center}
.ds-cmd{margin-bottom:10px}.ds-cmdrow{display:flex;gap:8px;margin-top:6px}.ds-cmdrow input{flex:1;min-width:0;border:1px solid var(--line,#c9d4ea);border-radius:10px;padding:10px 12px;background:var(--surface-2,#f6f8fd);color:inherit;font:inherit}
.ds-seg{display:flex;gap:6px;margin:8px 0}.ds-seg button{padding:8px 16px;border-radius:999px;border:1px solid var(--line,#c9d4ea);background:var(--surface-2,#f6f8fd);color:inherit;font:inherit;cursor:pointer}.ds-seg button.on{background:#0b57d0;color:#fff;font-weight:700}
.ds-tpls{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px}.ds-tpl{display:flex;flex-direction:column;gap:8px;justify-content:space-between}.ds-tpl b{display:block}.ds-tpl .muted{font-size:12px}
.ds-pick{display:flex;flex-direction:column;gap:6px;max-height:50vh;overflow:auto}.ds-pick .btn{text-align:start;justify-content:flex-start}
@media (max-width:900px){.ds-main{flex-direction:column}.ds-side{width:auto;flex:0 0 auto;max-height:38vh;border-inline-end:0;border-bottom:1px solid var(--line,#c9d4ea)}.ds-canvas{padding:8px 4px 90px}}

/* ===== v83: stat strips + KPI grid fix (additive; Classic keeps its own flat style) ===== */
@media (min-width:901px){html:not(.classic) body .kpis{grid-template-columns:repeat(auto-fit,minmax(168px,1fr))!important;gap:12px!important}}
.skstrip{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,170px),1fr));gap:12px;margin:0 0 14px}
.sk{position:relative;overflow:hidden;display:flex;flex-direction:column;gap:2px;padding:14px 16px 12px;border-radius:14px;background:var(--surface);border:1px solid color-mix(in srgb,var(--line) 80%,transparent);border-top:3px solid var(--accent);min-height:92px;--sc:var(--accent)}
.sk.ok{--sc:var(--ok);border-top-color:var(--ok)}.sk.warn{--sc:var(--warn);border-top-color:var(--warn)}.sk.bad{--sc:var(--bad);border-top-color:var(--bad)}.sk.acc{--sc:#2563eb;border-top-color:#2563eb}
.sk span{font-size:12.5px;color:var(--muted);font-weight:600}
.sk b{font-size:24px;line-height:1.2;color:var(--fg)}
.sk small{font-size:11.5px;color:var(--muted)}
.sk .sp{position:absolute;left:12px;top:14px;width:34%;height:36px;opacity:.9;pointer-events:none}
.sk .sp polygon{fill:var(--sc);opacity:.13}.sk .sp polyline{fill:none;stroke:var(--sc);stroke-width:1.8;stroke-linejoin:round;stroke-linecap:round;vector-effect:non-scaling-stroke}.sk .sp circle{fill:var(--sc)}
html[data-glass] .sk{background:color-mix(in srgb,var(--surface) 72%,transparent);backdrop-filter:blur(10px)}
.classic .sk{border:0;border-radius:5px;border-top:3px solid var(--sc);background:var(--c-blue2,var(--surface));box-shadow:none;text-align:center;align-items:center;min-height:0}
.classic .sk .sp{display:none}
@media (max-width:600px){.skstrip{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.sk b{font-size:20px}.sk .sp{width:30%;top:12px}}

/* v102: primary busy button — lux.css forces the label color with !important, which showed text over the spinner */
html .btn.pri.busy,html:not([data-glass="off"]) .btn.pri.busy{color:transparent!important}
html:not([data-glass="off"]) .btn.pri.busy::after{border-color:#1d1508 transparent #1d1508 transparent}

/* v103: the contract file (openFile → modal "wide file") opens as a side drawer on desktop so the list stays visible behind it. Phones keep the bottom sheet. CSS only. */
@keyframes drawerIn{from{opacity:0;transform:translateX(-24px)}}
@media (min-width:900px){
  .ov:has(.modal.file){justify-content:flex-end;align-items:stretch;padding:0}
  .modal.file{width:min(600px,100%)!important;height:100vh;max-height:100vh;overflow-y:auto;border-radius:0 22px 22px 0!important;animation:drawerIn .22s cubic-bezier(.2,.8,.2,1)}
}

/* v106 flags: inline SVG, readable on both themes (hairline keeps white flags visible on a white card) */
.flg{width:20px;height:14px;border-radius:3px;vertical-align:-2px;margin-inline-end:6px;box-shadow:0 0 0 1px rgba(128,128,128,.4);flex:none}

/* v111 AI hub: assistant switcher */
.ai-hub{display:flex;flex-wrap:wrap;gap:6px;padding:8px 12px;border-bottom:1px solid var(--line)}
.ai-hub .chip{cursor:pointer}
.ai-hub .chip.on{background:var(--acc);color:#1d1508;border-color:transparent;font-weight:700}

/* v113 urgent notifications */
.nitem.urgent{border-inline-start:3px solid #d64545}
.nitem.urgent .dot{background:#d64545}

/* v114 table sort + columns */
.ts-h{cursor:pointer;user-select:none}.ts-h:focus-visible{outline:2px solid currentColor;outline-offset:-2px}
.ts-h[data-tsn]:not([data-tsn=""])::after{content:" " attr(data-tsn);font-size:.8em;opacity:.8}
.ts-cols{margin:0 0 6px;font-size:.85rem}.ts-cols summary{cursor:pointer;display:inline-block;padding:2px 10px;border-radius:999px;border:1px solid var(--line,#8884)}
.ts-cols>div{display:flex;flex-wrap:wrap;gap:4px 14px;padding:8px 2px}.ts-cols label{display:flex;gap:4px;align-items:center}
