/* My Arbec — RTL ERP UI */
:root {
  --cobalt: #1E5BC6;
  --cobalt-dark: #1648A0;
  --cobalt-soft: #E8EFFB;
  --navy: #0F2240;
  --navy-2: #172E52;
  --paper: #F4F6F9;
  --surface: #FFFFFF;
  --line: #D8DEE8;
  --line-soft: #E9EDF3;
  --ink: #16202E;
  --ink-2: #4A5668;
  --ink-3: #7A8596;
  --green: #1F8A5B;
  --green-soft: #E3F4EC;
  --red: #C8372D;
  --red-soft: #FBE9E7;
  --amber: #D99A0B;
  --amber-soft: #FDF3DC;
  --radius: 6px;
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.55; color: var(--ink); background: var(--paper);
  font-variant-numeric: tabular-nums;
}
a { color: var(--cobalt); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.num, td.num, th.num { direction: ltr; text-align: left; white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  background: var(--navy); color: #C9D4E6; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 24px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { max-height: 34px; max-width: 150px; background: #fff; border-radius: 4px; padding: 3px 6px; }
.brand .name { color: #fff; font-weight: 700; font-size: 16px; }
.brand .sub { font-size: 11px; color: #8FA0BC; }
.nav { padding: 8px 8px 24px; }
.nav details { margin: 2px 0; }
.nav summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 5px;
  color: #E3EAF5; font-weight: 500;
}
.nav summary::-webkit-details-marker { display: none; }
.nav summary:hover { background: rgba(255,255,255,.06); }
.nav summary .chev { margin-inline-start: auto; transition: transform .15s; opacity: .6; }
.nav details[open] summary .chev { transform: rotate(-90deg); }
.nav .grp { font-size: 11px; color: #7F91AF; padding: 8px 12px 2px 0; padding-inline-start: 34px; }
.nav a.item { display: block; padding: 6px 10px; padding-inline-start: 34px; color: #B9C6DB; border-radius: 5px; font-size: 13px; }
.nav a.item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.item.active { background: var(--cobalt); color: #fff; }
.nav a.top { display: flex; align-items: center; gap: 10px; padding: 8px 10px; color: #E3EAF5; border-radius: 5px; font-weight: 500; }
.nav a.top:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav a.top.active { background: var(--cobalt); color: #fff; }
.nav .badge-count { margin-inline-start: auto; background: var(--amber); color: #2b1d00; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.ico { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.topbar select { min-width: 180px; }
.menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--cobalt-soft); color: var(--cobalt); display: grid; place-items: center; font-weight: 700; }
.content { padding: 20px 24px 48px; max-width: 1500px; width: 100%; }

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 220px; }
.page-head .crumbs { font-size: 12px; color: var(--ink-3); margin-bottom: 2px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #B9C3D3; text-decoration: none; }
.btn-primary { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.btn-primary:hover { background: var(--cobalt-dark); border-color: var(--cobalt-dark); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-danger { color: var(--red); border-color: #EBC3BF; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-amber { background: var(--amber); border-color: var(--amber); color: #241800; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-link { border: 0; background: none; color: var(--cobalt); padding: 0; height: auto; }
.inline { display: inline; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search],
input[type=time], input[type=month], input:not([type]), select, textarea {
  width: 100%; height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
  font: inherit; color: var(--ink);
}
textarea { height: auto; min-height: 74px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--cobalt); outline: 2px solid rgba(30,91,198,.15); outline-offset: 0; }
input[type=number], .ltr { direction: ltr; text-align: left; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--cobalt); vertical-align: middle; }
label.field { display: block; }
label.field > span { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
label.field > span .req { color: var(--red); }
.help { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.check { display: flex; align-items: center; gap: 8px; height: 34px; margin-top: 21px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.panel-head h2 { flex: 1; }
.panel-body { padding: 16px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; }
.grid .c2 { grid-column: span 2; }
.grid .c3 { grid-column: 1 / -1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; background: var(--surface); }
table.t th, table.t td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); text-align: right; vertical-align: middle; }
table.t thead th { background: #F7F9FC; color: var(--ink-2); font-weight: 600; font-size: 12.5px; position: sticky; top: 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t tbody tr:hover { background: #F8FAFE; }
table.t tfoot td { font-weight: 700; background: #F7F9FC; border-top: 1px solid var(--line); }
table.t tr.bold td { font-weight: 600; }
table.t td.wrap { white-space: normal; min-width: 240px; }
table.t tr.heading td { background: #F1F4F9; font-weight: 600; }
.row-link { cursor: pointer; }
.empty { padding: 36px 16px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

.toolbar { display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; align-items: center; }
.toolbar input[type=search] { max-width: 300px; }
.toolbar select { max-width: 200px; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 10px 16px; color: var(--ink-3); }

/* ---------- status stamps ---------- */
.badge {
  display: inline-block; padding: 1px 10px; border-radius: 3px; font-size: 12px; font-weight: 600; border: 1.5px solid currentColor;
  letter-spacing: 0; white-space: nowrap; transform: rotate(-1.5deg);
}
.badge-gray { color: #6B7586; }
.badge-amber { color: #A97300; background: var(--amber-soft); }
.badge-blue { color: var(--cobalt); background: var(--cobalt-soft); }
.badge-green { color: var(--green); background: var(--green-soft); }
.badge-red { color: var(--red); background: var(--red-soft); }
.stamp-lg { font-size: 15px; padding: 3px 16px; border-width: 2px; }
.pill { display: inline-block; padding: 0 8px; border-radius: 10px; background: var(--line-soft); font-size: 12px; color: var(--ink-2); }
.yes { color: var(--green); font-weight: 700; }
.no { color: var(--ink-3); }

/* ---------- flash ---------- */
.flashes { margin-bottom: 14px; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: var(--radius); border: 1px solid; font-weight: 500; white-space: pre-line; }
.flash-success { background: var(--green-soft); border-color: #B6E0CB; color: #145C3D; }
.flash-error { background: var(--red-soft); border-color: #F0C2BD; color: #8E2219; }
.flash-warning { background: var(--amber-soft); border-color: #F1D79A; color: #6E4A00; }
.flash-info { background: var(--cobalt-soft); border-color: #C3D4F2; color: #173E85; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 16px; }
.kpi { padding: 14px 18px; border-inline-start: 1px solid var(--line-soft); display: block; color: inherit; }
.kpi:hover { background: #F8FAFE; text-decoration: none; }
.kpi .label { font-size: 12.5px; color: var(--ink-2); }
.kpi .value { font-size: 22px; font-weight: 700; direction: ltr; text-align: right; margin: 2px 0; }
.kpi .sub { font-size: 11.5px; color: var(--ink-3); }

/* ---------- detail ---------- */
.dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.dl > div { padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.dl dt { font-size: 12px; color: var(--ink-3); }
.dl dd { margin: 2px 0 0; font-weight: 500; word-break: break-word; }
.dl .c3 { grid-column: 1 / -1; }
.doc-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.totals-box { display: grid; grid-template-columns: auto auto; gap: 4px 24px; justify-content: end; padding: 14px 16px; }
.totals-box .k { color: var(--ink-2); }
.totals-box .v { direction: ltr; text-align: left; font-weight: 600; }
.totals-box .grand { font-size: 16px; color: var(--ink); }
.timeline { list-style: none; margin: 0; padding: 0 16px 12px; }
.timeline li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--cobalt); border-bottom-color: var(--cobalt); font-weight: 600; }
.progress { height: 8px; background: var(--line-soft); border-radius: 4px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--cobalt); }

/* ---------- lines editor ---------- */
table.lines { width: 100%; border-collapse: collapse; }
table.lines th { background: #F7F9FC; font-size: 12px; color: var(--ink-2); font-weight: 600; padding: 6px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.lines td { padding: 4px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.lines input, table.lines select { height: 32px; padding: 4px 6px; min-width: 70px; }
table.lines td.ro { background: #F9FAFC; direction: ltr; text-align: left; padding: 9px 8px; color: var(--ink-2); white-space: nowrap; }
table.lines .del { color: var(--red); background: none; border: 0; cursor: pointer; font-size: 18px; line-height: 1; padding: 6px; }
.lines-wrap { overflow-x: auto; }
.lookup { position: relative; min-width: 200px; }
.lookup .menu {
  position: absolute; inset-inline: 0; top: 100%; z-index: 50; background: #fff; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(15,34,64,.14); max-height: 260px; overflow-y: auto; display: none;
}
.lookup .menu div { padding: 7px 10px; cursor: pointer; font-size: 13px; }
.lookup .menu div:hover, .lookup .menu div.on { background: var(--cobalt-soft); }
.lookup .menu .none { color: var(--ink-3); cursor: default; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth .art {
  background: var(--navy); color: #DCE5F3; padding: 48px; display: flex; flex-direction: column; justify-content: flex-end;
  background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px),
                    linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 20px 20px, 20px 20px, 100px 100px, 100px 100px;
}
.auth .art h2 { font-size: 30px; color: #fff; margin-bottom: 8px; max-width: 420px; }
.auth .art p { max-width: 420px; color: #A9B8D0; }
.auth .form { display: grid; place-items: center; padding: 32px; background: #fff; }
.auth form { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.auth .logo-word { font-size: 26px; font-weight: 700; color: var(--cobalt); }

/* ---------- tender grid ---------- */
.grid-wrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
table.sheet { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
table.sheet th { position: sticky; top: 0; background: #EEF2F8; z-index: 3; font-weight: 600; font-size: 12px; color: var(--ink-2); padding: 6px 8px; border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line-soft); white-space: nowrap; }
table.sheet th.grp-cost { background: #E6F0E9; }
table.sheet th.grp-price { background: #E5EDFB; }
table.sheet td { border-bottom: 1px solid var(--line-soft); border-inline-start: 1px solid var(--line-soft); padding: 0; height: 30px; }
table.sheet td .cell { padding: 5px 8px; min-height: 30px; outline: none; white-space: pre-wrap; }
table.sheet td.n .cell { direction: ltr; text-align: left; white-space: nowrap; }
table.sheet td.desc { min-width: 320px; max-width: 520px; }
table.sheet td.ro .cell { color: var(--ink-2); background: #FAFBFD; }
table.sheet td.calc .cell { font-weight: 600; }
table.sheet td [contenteditable=true]:focus { background: #FFFBEA; box-shadow: inset 0 0 0 2px var(--amber); }
table.sheet tr.heading td { background: #F1F4F9; font-weight: 700; }
table.sheet tr.flash-remote td { animation: remote 1.6s ease-out; }
table.sheet tr.saving td.desc .cell { opacity: .7; }
table.sheet td.rowno { position: sticky; inset-inline-start: 0; background: #F7F9FC; z-index: 2; color: var(--ink-3); font-size: 11px; text-align: center; min-width: 44px; }
table.sheet td.who { font-size: 11px; color: var(--ink-3); white-space: nowrap; padding: 0 6px; }
@keyframes remote { from { background: #DCEAFE; } to { background: transparent; } }
.presence { font-size: 12px; color: var(--ink-3); }
.sumbar { display: flex; gap: 24px; flex-wrap: wrap; align-items: baseline; padding: 10px 16px; background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; }
.sumbar .v { font-size: 18px; font-weight: 700; direction: ltr; display: inline-block; }
.stages { display: flex; gap: 0; margin: 0 0 12px; padding: 0; list-style: none; flex-wrap: wrap; }
.stages li { padding: 6px 14px; background: #fff; border: 1px solid var(--line); margin-inline-end: -1px; font-size: 12.5px; color: var(--ink-3); }
.stages li.done { color: var(--green); }
.stages li.now { background: var(--cobalt); border-color: var(--cobalt); color: #fff; font-weight: 600; }
.stages li.lost { background: var(--red-soft); color: var(--red); }

dialog { border: 1px solid var(--line); border-radius: 10px; padding: 0; width: min(520px, 92vw); }
dialog::backdrop { background: rgba(15,34,64,.4); }
dialog form { padding: 18px; display: grid; gap: 12px; }

/* ---------- self service (mobile first) ---------- */
.me { max-width: 560px; margin: 0 auto; }
.clock { background: var(--navy); color: #fff; border-radius: 12px; padding: 20px; text-align: center; }
.clock .time { font-size: 38px; font-weight: 700; direction: ltr; }
.clock .btn { height: 46px; font-size: 16px; width: 100%; margin-top: 12px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.tile .v { font-size: 20px; font-weight: 700; }
.tile .l { font-size: 12px; color: var(--ink-3); }

/* ---------- print ---------- */
.print-page { background: #fff; max-width: 210mm; margin: 0 auto; padding: 14mm; min-height: 297mm; }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--cobalt); padding-bottom: 10px; margin-bottom: 14px; }
.print-head img { max-height: 54px; }
.print-title { font-size: 20px; font-weight: 700; color: var(--cobalt); }
.sign-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 48px; text-align: center; }
.sign-row div { border-top: 1px solid var(--ink-3); padding-top: 6px; color: var(--ink-2); }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .print-page { padding: 0; min-height: 0; }
  table.t th { background: #EEF2F8 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 270px; z-index: 60; transform: translateX(100%); transition: transform .2s; }
  body.nav-open .side { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(15,34,64,.4); z-index: 55; }
  .menu-btn { display: inline-flex; }
  .content { padding: 14px 12px 40px; }
  .topbar { padding: 8px 12px; }
  .topbar select { min-width: 0; max-width: 150px; }
  .grid, .grid-2, .dl { grid-template-columns: 1fr; }
  .grid .c2, .grid .c3 { grid-column: auto; }
  .auth { grid-template-columns: 1fr; }
  .auth .art { display: none; }
  .user-chip .uname { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
table.sheet td.ro-auto .cell { color: var(--ink-3); }
/* mixed Arabic / English text: let each cell pick its own direction */
table.t td, table.lines td, table.sheet td .cell, .dl dd, h1 { unicode-bidi: plaintext; text-align: right; }
table.t td.num, .dl dd.num, table.sheet td.n .cell { unicode-bidi: normal; text-align: left; }
.sumbar input, .sumbar select { width: auto; }

/* ---------- pricing workbook (Excel-like grid) ---------- */
body.focus-mode .shell { grid-template-columns: 0 1fr; }
body.focus-mode .side { display: none; }
body.focus-mode .content { max-width: none; }
.content:has(.wb) { max-width: none; padding-top: 12px; }
.wb-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 22px; margin-bottom: 8px; }
.wb-head .titles { min-width: 260px; flex: 1 1 340px; }
.wb-head h1 { font-size: 18px; }
.wb-head .stages { margin: 0; }
.wb-totals { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.wb-totals b { font-size: 19px; direction: ltr; display: inline-block; margin-inline-start: 6px; }
.wb-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.people { display: flex; align-items: center; gap: 4px; }
.person { width: 24px; height: 24px; border-radius: 50%; color: #fff; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; }
.sync { font-size: 12px; color: var(--ink-3); padding: 2px 8px; border-radius: 10px; background: #EEF2F8; }
.sync.ok { color: var(--green); background: var(--green-soft); }
.sync.busy { color: #8a6100; background: var(--amber-soft); }
.sync.err { color: var(--red); background: var(--red-soft); }

.wb { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.sg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line); background: #F7F9FC; direction: ltr; }
.sg-toolbar button, .sg-toolbar select { height: 28px; min-width: 28px; padding: 0 7px; border: 1px solid transparent; background: transparent; border-radius: 4px; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; width: auto; }
.sg-toolbar button:hover, .sg-toolbar select:hover { background: #fff; border-color: var(--line); }
.sg-toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.sg-toolbar .clr { position: relative; display: inline-grid; place-items: center; width: 30px; height: 28px; cursor: pointer; border-radius: 4px; font-weight: 700; }
.sg-toolbar .clr:hover { background: #fff; }
.sg-toolbar .clr span { width: 16px; height: 16px; border: 1px solid #999; display: block; }
.sg-toolbar .clr.txt { color: #c00000; text-decoration: underline; }
.sg-toolbar .clr input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; padding: 0; border: 0; }
.sg-formula { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); direction: ltr; }
.sg-formula .sg-name { width: 110px; border: 0; border-inline-end: 1px solid var(--line); padding: 4px 8px; font: 13px/1.4 ui-monospace, Consolas, monospace; text-align: center; border-radius: 0; }
.sg-formula .fx { padding: 4px 10px; color: var(--ink-3); font-style: italic; border-inline-end: 1px solid var(--line-soft); }
.sg-formula .sg-bar { flex: 1; border: 0; padding: 4px 8px; font-size: 13px; border-radius: 0; unicode-bidi: plaintext; text-align: start; }
.sg-formula input:focus { outline: none; background: #FFFBEA; }
.sg-scroll { position: relative; overflow: auto; height: 520px; background: #fff; font-family: Calibri, "Segoe UI", "IBM Plex Sans Arabic", Tahoma, sans-serif; font-size: 13px; outline: none; }
.sg-inner { position: relative; }
.sg-top { position: sticky; top: 0; z-index: 5; display: flex; }
.sg-corner { position: sticky; inset-inline-start: 0; z-index: 6; background: #fff; flex: none; }
.sg-tophead { position: relative; flex: none; background: #fff; }
.sg-body { display: flex; }
.sg-left { position: sticky; inset-inline-start: 0; z-index: 4; background: #fff; flex: none; }
.sg-main { position: relative; flex: none; }
.sg-cells { position: absolute; inset: 0; }
.sg-all { position: absolute; top: 0; inset-inline-start: 0; background: #EEF1F5; border-inline-end: 1px solid #C9D1DC; border-bottom: 1px solid #C9D1DC; cursor: pointer; }
.sh, .rh { position: absolute; background: #EEF1F5; color: #4A5668; font-size: 11.5px; display: flex; align-items: center; justify-content: center; user-select: none; cursor: default; box-sizing: border-box; }
.sh { top: 0; height: 22px; border-inline-end: 1px solid #C9D1DC; border-bottom: 1px solid #C9D1DC; }
.rh { inset-inline-start: 0; width: 48px; border-inline-end: 1px solid #C9D1DC; border-bottom: 1px solid #DCE2EA; }
.sh.on, .rh.on { background: #D5E1F5; color: var(--cobalt-dark); font-weight: 600; }
.sh .rz { position: absolute; inset-inline-end: -3px; top: 0; width: 7px; height: 100%; cursor: col-resize; z-index: 2; }
.sc { position: absolute; box-sizing: border-box; border-inline-end: 1px solid #E3E7EE; border-bottom: 1px solid #E3E7EE; padding: 0 4px; display: flex; align-items: flex-end; overflow: hidden; white-space: nowrap; line-height: 1.25; color: #111; background-clip: padding-box; text-align: start; }
.sc > span { overflow: hidden; text-overflow: clip; unicode-bidi: plaintext; text-align: inherit; width: 100%; }
.sc.n { justify-content: flex-end; text-align: right; }
.sc.n > span { direction: ltr; unicode-bidi: normal; }
.sc.bo { justify-content: center; text-align: center; }
.sc.er { color: var(--red); justify-content: center; text-align: center; }
.sc.wr { white-space: pre-wrap; word-break: break-word; align-items: flex-start; }
.sc.wr > span { overflow: hidden; }
.sc.bd { border: 1px solid #7F8A9B; }
.sc.mg { background-color: #fff; z-index: 1; }
.sc.spl { overflow: visible; z-index: 1; }
.sc.spl > .sp { white-space: nowrap; flex: none; overflow: hidden; unicode-bidi: plaintext; text-align: inherit; }
.sc.in-sel { box-shadow: inset 0 0 0 9999px rgba(30, 91, 198, .10); }
.sc.act { outline: 2px solid var(--cobalt); outline-offset: -2px; z-index: 3; }
.sc.remote { animation: sg-flash 2.4s ease-out; }
@keyframes sg-flash { 0% { box-shadow: inset 0 0 0 9999px rgba(217, 154, 11, .45); } 100% { box-shadow: inset 0 0 0 9999px rgba(217, 154, 11, 0); } }
.pres { position: absolute; box-sizing: border-box; border: 2px solid; pointer-events: none; z-index: 4; }
.pres b { position: absolute; top: -15px; inset-inline-start: -2px; font-size: 10px; line-height: 13px; color: #fff; padding: 0 4px; border-radius: 3px 3px 3px 0; white-space: nowrap; font-weight: 600; }
.sg-editor { position: absolute; z-index: 8; box-sizing: border-box; border: 2px solid var(--cobalt); padding: 1px 3px; font: inherit; font-size: 13px; line-height: 1.25; resize: none; overflow: hidden; background: #fff; box-shadow: 0 4px 14px rgba(15, 34, 64, .18); white-space: pre-wrap; unicode-bidi: plaintext; text-align: start; border-radius: 0; }
.sg-kb { position: absolute; top: 0; left: -10000px; width: 10px; height: 10px; opacity: 0; }
.sg-tabs { display: flex; gap: 2px; padding: 4px 6px 0; border-top: 1px solid var(--line); background: #F2F4F8; overflow-x: auto; direction: ltr; }
.sg-tabs .tab { border: 1px solid var(--line); border-bottom: 0; background: #E8ECF2; padding: 5px 14px; font: inherit; font-size: 12.5px; border-radius: 6px 6px 0 0; cursor: pointer; white-space: nowrap; color: var(--ink-2); }
.sg-tabs .tab.on { background: #fff; color: var(--cobalt-dark); font-weight: 600; box-shadow: inset 0 2px 0 var(--cobalt); }
.sg-tabs .tab.add { font-weight: 700; padding: 5px 10px; }
.sg-status { display: flex; justify-content: space-between; gap: 12px; padding: 3px 10px; font-size: 12px; border-top: 1px solid var(--line-soft); background: #fff; direction: rtl; }
.sg-status .st-sel { direction: rtl; font-weight: 600; color: var(--ink-2); white-space: pre; }
.sg-status .st-help { font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sg-menu { display: none; position: fixed; z-index: 50; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 10px 30px rgba(15, 34, 64, .18); padding: 4px; min-width: 220px; }
.sg-menu button { display: block; width: 100%; text-align: start; border: 0; background: none; padding: 6px 10px; font: inherit; font-size: 13px; border-radius: 4px; cursor: pointer; }
.sg-menu button:hover { background: var(--cobalt-soft); }
.sg-menu hr { border: 0; border-top: 1px solid var(--line-soft); margin: 3px 0; }
.sg-toast { position: absolute; bottom: 44px; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--navy); color: #fff; padding: 8px 14px; border-radius: 6px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; max-width: 80%; }
.sg-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sg-toast.warn { background: #8a5a00; }
.sg-toast.err { background: var(--red); }
@media (max-width: 760px) {
  .sg-status .st-help { display: none; }
  .wb-totals b { font-size: 16px; }
}
/* mapping screen */
.map-sheet { border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: 12px; }
.map-sheet > header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.map-sheet .cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 12px; padding: 12px 14px; }
.map-sheet .cols label span { display: block; font-size: 12px; color: var(--ink-3); }
.map-sheet.off .cols { display: none; }

/* BOQ section headings: keep long specification text inside the item columns, clamp to 3 lines */
table.t tr.heading .heading-text { white-space: normal; max-width: 640px; display: -webkit-box;
  -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.5; }
