/* ═══════════════════════════════════════════════════════════════
   نظام مخازن الوسام ستيل — التنسيق
   خطوط النظام فقط: يعمل بلا إنترنت على تابلت المخزن، وبلا انتظار تحميل.
   شاشات داخل شاشات: لا قائمة جانبية؛ الرئيسية أقسام، والقسم بنود، والبند شاشة كاملة.
   ═══════════════════════════════════════════════════════════════ */

/* ── الواجهة الداكنة (الافتراضية): أسود مريح، كتابة بيضاء دافئة، ذهبي للأزرار والروابط، أحمر للتنبيه ── */
:root {
  --ground: #0A0B0E;
  --surface: #12141A;
  --surface-2: #191C24;
  --surface-3: #21252F;
  --ink: #F3F0EA;
  --ink-2: #BDB7AB;
  --ink-3: #8B857A;
  --line: #2B2F39;
  --line-soft: #21252D;
  --accent: #D6AE3A;
  --accent-dim: #33290F;
  --hot: #E0604F;
  --hot-dim: #3A1714;
  --ok: #7FB78C;
  --ok-dim: #17291D;
  --warn: #E2B04A;
  --warn-dim: #332810;
  --crit: #E24B3E;
  --crit-dim: #3B1411;
  --btn-ink: #1A1400;
  --shadow: rgba(0, 0, 0, .45);
  --f-body: "Segoe UI", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  --f-mono: "Cascadia Mono", "Consolas", "Courier New", monospace;
  --r: 4px;
  --top: 3rem;
}

/* ── الواجهة الفاتحة: أبيض دافئ، كتابة فحمية، ذهبي غامق للأزرار والروابط ── */
[data-theme="light"] {
  --ground: #F4F3EF;
  --surface: #FFFFFF;
  --surface-2: #F8F7F3;
  --surface-3: #EEECE5;
  --ink: #1F1E1A;
  --ink-2: #5A564D;
  --ink-3: #807B70;
  --line: #DCD8CE;
  --line-soft: #EAE7DF;
  --accent: #9A7514;
  --accent-dim: #F6ECCF;
  --hot: #B8401F;
  --hot-dim: #FBE9E2;
  --ok: #2E7A4D;
  --ok-dim: #E2F0E7;
  --warn: #8F6400;
  --warn-dim: #FBF1D4;
  --crit: #B3261E;
  --crit-dim: #FBE5E3;
  --btn-ink: #FFFFFF;
  --shadow: rgba(30, 28, 22, .14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }     /* يغلب display على الأزرار والحاويات المخفية */

/* حجم الخط الأساسي بحسب الشاشة: أصغر على اللابتوب كي لا يتزاحم الكلام */
html { font-size: 14px; }
@media (max-width: 1366px) { html { font-size: 13px; } }
@media (min-width: 1900px) { html { font-size: 15px; } }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  transition: background-color .2s, color .2s;
}

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

.skip {
  position: absolute; inset-inline-start: -9999px;
  background: var(--accent); color: var(--btn-ink); padding: .6rem 1rem; z-index: 100;
}
.skip:focus { inset-inline-start: 1rem; top: 1rem; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── الشريط العلوي ───────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: .7rem;
  padding: .35rem .9rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
  min-height: var(--top);
}
.spacer { flex: 1; }

.brand { display: flex; align-items: center; gap: .5rem; min-width: 0; text-decoration: none; color: inherit; }
/* الشعار الرسمي: النسخة البيضاء للواجهة الداكنة، والملوّنة للفاتحة */
.brand .logo { height: 2.1rem; width: auto; display: block; flex-shrink: 0; }
.brand .logo.lt { display: none; }
[data-theme="light"] .brand .logo.dk { display: none; }
[data-theme="light"] .brand .logo.lt { display: block; }
.themebtn .ico { font-size: .95rem; line-height: 1; }
.brand .bt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand .bt b { font-size: .86rem; white-space: nowrap; }

/* شريط المسار: الرئيسية › القسم › الشاشة */
.crumb {
  display: flex; align-items: center; gap: .35rem; min-width: 0;
  font-size: .82rem; color: var(--ink-3); white-space: nowrap; overflow: hidden;
  border-inline-start: 1px solid var(--line); padding-inline-start: .7rem;
}
.crumb a { color: var(--ink-2); text-decoration: none; }
.crumb a:hover { color: var(--accent); }
.crumb .cur { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumb .sep { color: var(--ink-3); }

.mode-chip {
  font-size: max(.72rem, 10px); padding: .15rem .55rem; border-radius: 999px;
  background: var(--hot-dim); color: var(--hot);
  border: 1px solid var(--hot); white-space: nowrap;
}

.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.who .wn { font-size: .8rem; font-weight: 600; }
.who .wr { font-size: max(.72rem, 10px); color: var(--ink-3); }
.who .wr.ro { color: var(--warn); }

.navbtn .bars { display: inline-flex; flex-direction: column; gap: 3px; margin-inline-end: .1rem; }
.navbtn .bars span { display: block; width: 14px; height: 2px; background: currentColor; }
body.nav-open .navbtn { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* ── قائمة الانتقال السريع (تظهر عند الطلب فقط) ─────────────── */
.drawer {
  position: fixed; inset: var(--top) 0 0 0; z-index: 35;
  background: rgba(8, 12, 14, .55);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.drawer[hidden] { display: none; }
.dr-in {
  position: absolute; inset-block: 0; inset-inline-end: 0;
  width: min(62rem, 100%); background: var(--surface);
  border-inline-start: 1px solid var(--line);
  box-shadow: -12px 0 36px var(--shadow);
  display: flex; flex-direction: column; overflow-y: auto;
  animation: dr-in .16s ease-out;
}
@keyframes dr-in { from { transform: translateX(-2rem); opacity: 0; } to { transform: none; opacity: 1; } }
.dr-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem 1rem; border-bottom: 1px solid var(--line);
}
.dr-cols {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: .2rem 1rem; padding: .8rem 1rem 1rem;
}
.dr-sec { padding: .3rem 0 .6rem; }
.dr-h {
  display: flex; align-items: center; gap: .4rem;
  font-weight: 700; font-size: .86rem; color: var(--ink);
  text-decoration: none; padding: .35rem .5rem; margin-bottom: .15rem;
  border-bottom: 1px solid var(--line-soft);
}
.dr-h:hover { color: var(--accent); }
.dr-l {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .3rem .6rem; color: var(--ink-2); text-decoration: none;
  border-radius: var(--r); font-size: .82rem;
}
.dr-l:hover { background: var(--surface-2); color: var(--ink); }
.dr-l[aria-current="page"] { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.dr-foot {
  margin-top: auto; padding: .6rem 1rem; border-top: 1px solid var(--line-soft);
  display: flex; gap: 1rem; font-size: max(.74rem, 10px); color: var(--ink-3); font-family: var(--f-mono);
}
.dr-foot a { color: var(--ink-2); margin-inline-start: auto; font-family: var(--f-body); }

.badge {
  background: var(--crit); color: #fff; font-style: normal;
  font-size: max(.7rem, 10px); font-weight: 700; min-width: 1.2rem; line-height: 1.3;
  text-align: center; padding: .05rem .35rem; border-radius: 999px;
  display: inline-block; vertical-align: middle;
}

/* ── المحتوى ─────────────────────────────────────────────────── */
main { padding: .9rem 1.2rem 4.5rem; min-width: 0; max-width: 1720px; margin: 0 auto; }

@media (max-width: 860px) {
  .brand .bt, .who .wr, .mode-chip { display: none; }
  .crumb { border: 0; padding: 0; font-size: .76rem; }
  .crumb a:not(:last-of-type) { display: none; }
  .crumb .sep { display: none; }
  main { padding: .8rem .8rem 5rem; }
  .dr-in { width: 100%; }
}

/* ── الشاشة الرئيسية: الأقسام ───────────────────────────────── */
.home-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin: .4rem 0 1.1rem;
}
.home-hero h1 { font-size: 1.35rem; margin: 0 0 .15rem; }
.home-hero p { margin: 0; font-size: .82rem; }
.home-find { display: flex; gap: .4rem; flex: 1 1 22rem; max-width: 34rem; }
.home-find input { flex: 1; }

.tiles { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
/* الأقسام: 3×2 على اللابتوب، صف واحد على الشاشات العريضة، عمودان على الهاتف — وبعدد الأقسام المرئية */
.tiles.secs { grid-template-columns: repeat(3, 1fr); }
.tiles.secs[data-n="4"] { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 1100px) {
  .tiles.secs[data-n="4"] { grid-template-columns: repeat(4, 1fr); }
  .tiles.secs[data-n="5"] { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 1600px) { .tiles.secs, .tiles.secs[data-n="6"] { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 860px) { .tiles.secs, .tiles.secs[data-n] { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .tiles.secs, .tiles.secs[data-n] { grid-template-columns: 1fr; } }
.tile {
  display: flex; flex-direction: column; gap: .25rem;
  padding: 1rem 1.05rem; min-height: 6.2rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  color: inherit; text-decoration: none; position: relative;
  transition: border-color .12s, transform .12s, background .12s;
}
.tile:hover { border-color: var(--accent); background: var(--surface-2); transform: translateY(-1px); }
.tile .tt { font-weight: 700; font-size: 1rem; }
.tile .td { color: var(--ink-2); font-size: .8rem; line-height: 1.5; }
.tile .tf { color: var(--ink-3); font-size: max(.74rem, 10px); margin-top: auto; padding-top: .35rem; }
.tile.sec { min-height: 9rem; padding: 1.15rem 1.2rem; }
.tile.sec .tt { font-size: 1.2rem; }
.glyph {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 6px;
  font-size: 1.05rem; line-height: 1; background: var(--accent-dim); color: var(--accent);
  vertical-align: middle;
}
.tile.sec .glyph { width: 2.4rem; height: 2.4rem; font-size: 1.25rem; margin-bottom: .4rem; }
.dr-h .glyph { width: 1.4rem; height: 1.4rem; font-size: .8rem; border-radius: 4px; }
.s-cost  { background: var(--hot-dim);  color: var(--hot); }
.s-hr    { background: var(--ok-dim);   color: var(--ok); }
.s-gl    { background: var(--surface-3); color: var(--ink-2); }
.s-audit { background: var(--warn-dim); color: var(--warn); }
.s-admin { background: var(--crit-dim); color: var(--crit); }
.home-alerts { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.ha {
  padding: .4rem .8rem; border-radius: var(--r); font-size: .82rem; text-decoration: none;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.ha.warn { border-color: var(--warn); color: var(--warn); background: var(--warn-dim); }
.ha.hot  { border-color: var(--hot);  color: var(--hot);  background: var(--hot-dim); }
.ha.crit { border-color: var(--crit); color: var(--crit); background: var(--crit-dim); }

/* ── العناوين ────────────────────────────────────────────────── */
.ph { margin: 0 0 1rem; }
.ph h1 { font-size: 1.22rem; margin: 0 0 .2rem; font-weight: 700; }
.ph p { margin: 0; color: var(--ink-2); font-size: .84rem; max-width: 80ch; }
.ph .row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

h2 { font-size: 1rem; margin: 1.5rem 0 .6rem; font-weight: 600; }
h3 { font-size: .92rem; margin: 1.1rem 0 .45rem; font-weight: 600; }

/* ── البطاقات والشبكات ───────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: .9rem 1rem; margin-bottom: .9rem;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-h {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem;
  padding-bottom: .55rem; border-bottom: 1px solid var(--line-soft);
}
.card-h h2, .card-h h3 { margin: 0; }

.grid { display: grid; gap: .9rem; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }

/* ── مربعات المؤشرات ─────────────────────────────────────────── */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; margin-bottom: 1rem;
}
.kpi { background: var(--surface); padding: .75rem .9rem; }
.kpi .k { font-size: .76rem; color: var(--ink-2); margin: 0 0 .25rem; }
.kpi .v {
  font-family: var(--f-mono); font-size: 1.25rem; font-weight: 600;
  font-variant-numeric: tabular-nums; line-height: 1.15; margin: 0;
}
.kpi .s { font-size: max(.76rem, 10px); color: var(--ink-3); margin: .2rem 0 0; }
.kpi.ok .v { color: var(--ok); }
.kpi.warn .v { color: var(--warn); }
.kpi.crit .v { color: var(--crit); }
.kpi.acc .v { color: var(--accent); }

/* ── الجداول ─────────────────────────────────────────────────── */
.tw {
  overflow-x: auto; border: 1px solid var(--line);
  border-radius: var(--r); background: var(--surface); margin-bottom: .9rem;
}
table { border-collapse: collapse; width: 100%; font-size: .84rem; }
th, td {
  padding: .42rem .6rem; text-align: start;
  border-bottom: 1px solid var(--line-soft); vertical-align: top;
}
thead th {
  background: var(--surface-2); font-weight: 600; font-size: max(.76rem, 10px);
  color: var(--ink-2); white-space: nowrap;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.n, th.n {
  font-family: var(--f-mono); font-variant-numeric: tabular-nums;
  white-space: nowrap; text-align: end;
}
td.c, th.c { text-align: center; }
td.mono { font-family: var(--f-mono); font-size: .8rem; direction: ltr; text-align: left; }
.tw table tfoot td {
  background: var(--surface-2); font-weight: 600;
  border-top: 1px solid var(--line);
}
.empty { padding: 2rem 1rem; text-align: center; color: var(--ink-3); }

/* ── الشارات ─────────────────────────────────────────────────── */
.pill {
  display: inline-block; font-size: max(.7rem, 10px); font-weight: 600;
  padding: .1rem .42rem; border-radius: 3px; white-space: nowrap;
  font-family: var(--f-mono);
}
.pill.a { background: var(--crit-dim); color: var(--crit); }
.pill.b { background: var(--warn-dim); color: var(--warn); }
.pill.c { background: var(--ok-dim); color: var(--ok); }
.pill.i { background: var(--accent-dim); color: var(--accent); }
.pill.h { background: var(--hot-dim); color: var(--hot); }
.pill.g { background: var(--surface-3); color: var(--ink-2); }

.sev { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; }
.sev.crit { background: var(--crit); }
.sev.high { background: var(--hot); }
.sev.med { background: var(--warn); }
.sev.low { background: var(--ink-3); }

/* ── التنبيهات ───────────────────────────────────────────────── */
.alert {
  padding: .65rem .9rem; border-radius: var(--r); margin-bottom: .9rem;
  border-inline-start: 3px solid var(--accent); background: var(--surface);
  font-size: .86rem;
}
.alert b { display: block; margin-bottom: .15rem; }
.alert p { margin: 0; color: var(--ink-2); }
.alert pre {
  margin: .5rem 0 0; font-size: .74rem; overflow-x: auto;
  color: var(--ink-2); white-space: pre-wrap;
}
.alert.ok { border-inline-start-color: var(--ok); background: var(--ok-dim); }
.alert.warn { border-inline-start-color: var(--warn); background: var(--warn-dim); }
.alert.crit { border-inline-start-color: var(--crit); background: var(--crit-dim); }
.alert.info { border-inline-start-color: var(--accent); background: var(--accent-dim); }

/* ── النماذج ─────────────────────────────────────────────────── */
label { display: block; font-size: .78rem; color: var(--ink-2); margin-bottom: .25rem; }
label .req { color: var(--crit); }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], input[type=time],
input[type=search], input[type=email], input[type=tel], input[type=file], select, textarea {
  width: 100%; padding: .42rem .6rem;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r);
  font-family: inherit; font-size: .88rem;
}
input[type=number], .num-in { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); background: var(--surface);
}
input:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
textarea { min-height: 4.5rem; resize: vertical; }

.field { margin-bottom: .8rem; }
.fields { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.hint { font-size: max(.76rem, 10px); color: var(--ink-3); margin: .25rem 0 0; }
.hint a { color: var(--accent); }
.err { font-size: .78rem; color: var(--crit); margin: .25rem 0 0; }

/* ── الأزرار ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .45rem .95rem; border-radius: var(--r); cursor: pointer;
  background: var(--accent); color: var(--btn-ink); border: 1px solid var(--accent);
  font-family: inherit; font-size: .86rem; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); filter: none; }
.btn.danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #1a1400; }
.btn.sm { padding: .28rem .65rem; font-size: .76rem; }
.btn.lg { padding: .65rem 1.3rem; font-size: .95rem; width: 100%; }
.btn-row { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }

/* ── صفحة الدخول ─────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: 2rem 1.25rem; background: var(--ground);
  position: relative; isolation: isolate;
}
.login-box { width: 100%; max-width: 23rem; }
.login-box .lb-brand { text-align: center; margin-bottom: 1.5rem; }
.login-box .lb-brand .mark {
  width: 3rem; height: 3rem; margin: 0 auto .7rem;
  display: grid; place-items: center; background: var(--accent);
  color: #fff; font-size: 1.5rem; font-weight: 700; border-radius: 8px;
}
.login-box .lb-logo {
  height: 6.75rem; width: auto; margin: 0 auto .5rem; display: block;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, .45));
}
.login-box .lb-brand b { display: block; font-size: 1.05rem; }
.login-box .lb-brand small { color: var(--ink-3); font-size: .78rem; }
.login-box form {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; padding: 1.4rem;
}
.login-foot {
  text-align: center; font-size: .72rem; color: var(--ink-3); margin-top: 1.25rem;
  line-height: 1.7;
}

/* خلفية فيديو صامتة تعكس هوية الشركة — والنموذج شفاف لا يحجبها */
.login-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: #0E1417; }
.login-bg video { width: 100%; height: 100%; object-fit: cover; display: block; }
.login-bg::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(14, 20, 23, .35) 0%, rgba(14, 20, 23, .08) 45%, rgba(14, 20, 23, .55) 100%);
}
.has-video { align-items: center; justify-items: start; padding-inline: clamp(1.25rem, 8vw, 9rem); }
.has-video .login-box .lb-brand b,
.has-video .login-box .lb-brand small,
.has-video .login-foot { text-shadow: 0 1px 8px rgba(0, 0, 0, .7); }
.has-video .login-box .lb-brand small { color: #C9D4D8; }
.has-video .login-foot { color: #B9C6CB; }
.has-video .login-box form {
  background: rgba(22, 31, 35, .38); border-color: rgba(255, 255, 255, .16);
  -webkit-backdrop-filter: blur(6px) saturate(120%); backdrop-filter: blur(6px) saturate(120%);
  box-shadow: 0 14px 44px rgba(0, 0, 0, .35);
}
.has-video .login-box form label { color: #E7EDEB; }
.has-video .login-box form input {
  background: rgba(14, 20, 23, .5); border-color: rgba(255, 255, 255, .18); color: #fff;
}
.has-video .login-box form input:focus { border-color: var(--accent); }
.has-video .alert { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
@media (max-width: 760px) {
  .has-video { justify-items: center; align-items: start; padding-top: 2.25rem; }
  .login-box .lb-logo { height: 5.25rem; }
}
@media (prefers-reduced-motion: reduce) { .login-bg video { display: none; } }

/* ── الإكمال التلقائي ────────────────────────────────────────── */
.ac-pop {
  position: fixed; z-index: 120; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r);
  max-height: 17rem; overflow-y: auto; box-shadow: 0 12px 34px var(--shadow);
}
.ac-pop[hidden] { display: none; }
.ac-pop div {
  padding: .4rem .6rem; cursor: pointer; font-size: .84rem;
  border-bottom: 1px solid var(--line-soft);
}
.ac-pop div:last-child { border-bottom: 0; }
.ac-pop div:hover, .ac-pop div.on { background: var(--accent-dim); }
.ac-pop .s { color: var(--ink-3); font-size: .72rem; font-family: var(--f-mono); }

/* ── حاسبة التكلفة التقديرية ─────────────────────────────────── */
#ltab th, #ltab td { padding: .38rem .45rem; vertical-align: top; }
#ltab .itm { min-width: 14rem; }
#ltab .itm .nm { min-width: 13rem; }
#ltab .itm .sec { margin-top: .25rem; font-size: .72rem; padding: .18rem .45rem; opacity: .9; }
#ltab .calcc { min-width: 11rem; }
#ltab .mth { font-size: .8rem; padding: .28rem .4rem; }
#ltab .dims { display: flex; flex-wrap: wrap; gap: .25rem .4rem; margin-top: .3rem; }
#ltab .d { display: flex; flex-direction: column; gap: .05rem; margin: 0; font-size: max(.72rem, 10px); color: var(--ink-3); }
#ltab .d[hidden] { display: none; }
#ltab .d input { width: 4.8rem; padding: .18rem .3rem; font-size: .78rem; }
#ltab .qtyc .qty { display: block; font-weight: 600; font-size: .9rem; }
#ltab .qtyc .uom { width: 4.4rem; margin-top: .2rem; font-size: .72rem; padding: .15rem .3rem; text-align: center; }
#ltab .prc { width: 6.4rem; }
#ltab .pcts { white-space: nowrap; }
#ltab .pcts label { display: inline-flex; flex-direction: column; gap: .05rem; margin: 0 .08rem; font-size: max(.72rem, 10px); color: var(--ink-3); vertical-align: top; }
#ltab .pcts input { width: 3.5rem; padding: .18rem .25rem; font-size: .76rem; }
#ltab .pcts .cp { padding: .05rem .35rem; font-size: .72rem; vertical-align: bottom; margin-inline-start: .15rem; }
#ltab .tot b { font-size: .92rem; }
#ltab tr.lrow:hover td { background: var(--surface-2); }
.est-add { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
/* ترويسة التقدير: صف واحد على الشاشات العريضة، وتنثني على الضيّقة */
@media (min-width: 900px) {
  .fields.est-head { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr); }
  .fields.est-head.with-btn { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr) auto; align-items: end; }
}
.est-add .finder { flex: 1 1 22rem; }
.savebar {
  position: sticky; bottom: .5rem; z-index: 20;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .55rem .9rem; margin-top: .6rem;
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: 6px; box-shadow: 0 -10px 30px var(--shadow);
}
.savebar .big { font-family: var(--f-mono); font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.savebar .big small { font-size: .5em; opacity: .65; }
.savebar .k { color: var(--ink-2); font-size: .74rem; margin: 0; }
.savebar .mini { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .76rem; color: var(--ink-2); }
.savebar .mini b { font-family: var(--f-mono); color: var(--ink); }

/* ── لمسات الواجهة الفاتحة ───────────────────────────────────── */
[data-theme="light"] .topbar { box-shadow: 0 1px 3px rgba(30, 28, 22, .06); }
[data-theme="light"] .card, [data-theme="light"] .tile, [data-theme="light"] .toolbar,
[data-theme="light"] .tw, [data-theme="light"] .kpis { box-shadow: 0 1px 2px rgba(30, 28, 22, .05); }
[data-theme="light"] .drawer { background: rgba(30, 29, 26, .35); }
[data-theme="light"] .tile:hover { background: var(--surface); box-shadow: 0 6px 18px rgba(30, 28, 22, .10); }
[data-theme="light"] .btn.ghost { background: var(--surface); }
[data-theme="light"] .btn.ghost:hover { background: var(--surface-2); }
[data-theme="light"] tbody tr:hover { background: var(--surface-2); }
[data-theme="light"] .login-box form { box-shadow: 0 10px 30px rgba(30, 28, 22, .12); }

/* ── المسوّدة المحلية وحالة الاتصال ─────────────────────────── */
.draft-dot {
  position: fixed; inset-block-end: .6rem; inset-inline-end: .6rem; z-index: 60; pointer-events: none;
  font-size: max(.72rem, 10px); color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: .2rem .65rem;
  box-shadow: 0 2px 8px var(--shadow); max-width: min(92vw, 30rem);
}
option.draft-miss { font-style: italic; }
.net-bar {
  position: fixed; inset-inline: 0; top: var(--top); z-index: 45; text-align: center;
  padding: .45rem 1rem; font-size: .84rem; font-weight: 600;
}
.net-bar.off { background: var(--crit-dim); color: var(--ink); border-bottom: 2px solid var(--crit); }
.net-bar.on { background: var(--ok-dim); color: var(--ink); border-bottom: 2px solid var(--ok); }
.draft-banner { margin-bottom: .8rem; }
@media print { .draft-dot, .net-bar, .draft-banner { display: none !important; } }

/* ── مساعدات ─────────────────────────────────────────────────── */
.muted { color: var(--ink-3); }
.small { font-size: .8rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--f-mono); }
.tabs {
  display: flex; gap: .3rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); margin-bottom: .9rem;
}
.tabs a {
  padding: .4rem .8rem; color: var(--ink-2); text-decoration: none;
  font-size: .84rem; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a[aria-current="page"] {
  color: var(--accent); border-bottom-color: var(--accent); font-weight: 600;
}
.toolbar {
  display: flex; gap: .55rem; flex-wrap: wrap; align-items: end;
  margin-bottom: .9rem; padding: .7rem .9rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r);
}
.toolbar .field { margin: 0; min-width: 9rem; }

.idle-warn {
  position: fixed; inset-block-end: 1rem; inset-inline-start: 50%;
  transform: translateX(50%); z-index: 90;
  background: var(--warn-dim); color: var(--warn);
  border: 1px solid var(--warn); padding: .6rem 1.1rem;
  border-radius: var(--r); font-size: .85rem; max-width: 90vw;
}

/* شريط تقدّم بسيط للتغطية والدقة */
.bar { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar > i.ok { background: var(--ok); }
.bar > i.warn { background: var(--warn); }
.bar > i.crit { background: var(--crit); }

/* ── بطاقة الحديد الداخل في الإنتاج ─────────────────────────── */
.steel-kpis { margin-bottom: .7rem; }
.steel-kpis .unit { font-size: .55em; opacity: .7; }
.s-detail { margin-top: .3rem; }
.s-detail summary { cursor: pointer; color: var(--accent); font-size: .84rem; margin: .2rem 0 .5rem; }

/* ── الطباعة ─────────────────────────────────────────────────────
   1) أسود على أبيض مهما كانت الواجهة: الطابعة لا تطبع الخلفيات، فنص الواجهة
      الداكنة الفاتح كان يخرج باهتاً أو لا يظهر.
   2) لا شيء يتجاوز عرض الورقة: الخانات تأخذ عرض عمودها لا عرضها على الشاشة —
      وإلا قصّت الورقة الجزء الأيسر (عمودا النِّسب والإجمالي في التقدير).
   3) التقدير يُطبع ورقةً نظيفة (#printsheet) مكان الشاشة كلها. */
.printsheet { display: none; }
@media print {
  :root, :root[data-theme], [data-theme="dark"], [data-theme="light"] {
    --ground: #fff; --surface: #fff; --surface-2: #fff; --surface-3: #f1f1f1;
    --ink: #000; --ink-2: #222; --ink-3: #555; --line: #999; --line-soft: #ccc;
    --accent: #000; --accent-dim: #fff; --hot: #000; --hot-dim: #fff; --ok: #000; --ok-dim: #fff;
    --warn: #000; --warn-dim: #fff; --crit: #000; --crit-dim: #fff; --btn-ink: #000; --shadow: transparent;
  }
  @page { size: A4; margin: 10mm; }
  html { font-size: 10px; }
  body { background: #fff; color: #000; font-size: 9pt; }
  .topbar, .drawer, .toolbar, .btn, .btn-row, .savebar, .home-find, .no-print, .idle-warn, .ac-pop, .skip,
  .draft-dot, .net-bar, .draft-banner { display: none !important; }
  main { max-width: none; padding: 0; margin: 0; }
  .card { border: 1px solid #bbb; box-shadow: none !important; padding: 6px 8px; margin-bottom: 8px; }
  .tw { overflow: visible !important; border: 0; box-shadow: none !important; }
  * { transition: none !important; animation: none !important; }
  table { width: 100% !important; font-size: 8pt; }
  th, td { padding: 2px 4px !important; }
  th, .nowrap { white-space: normal !important; }
  td { overflow-wrap: anywhere; }
  td.n, th.n, td.mono { overflow-wrap: normal; }
  thead { display: table-header-group; }
  thead th { position: static; }
  tr, .kpi { break-inside: avoid; }
  [style*="min-width"] { min-width: 0 !important; }
  input, select, textarea {
    min-width: 0 !important; width: 100% !important; max-width: 100% !important;
    border: 0 !important; padding: 0 !important; background: transparent !important;
    color: #000 !important; box-shadow: none !important; font-size: inherit !important;
    appearance: none; -webkit-appearance: none;
  }
  input[type=checkbox], input[type=radio] { width: auto !important; appearance: auto; -webkit-appearance: auto; }
  input::placeholder, textarea::placeholder { color: transparent; }
  input::-webkit-calendar-picker-indicator { display: none; }
  .muted, .small, .hint, .pill, .badge, label { color: #000 !important; background: transparent !important; opacity: 1 !important; }
  a { color: #000 !important; text-decoration: none; }
  #ltab .cp, #ltab td.c, #ltab th.c:last-child { display: none !important; }

  /* ورقة التقدير */
  body.has-printsheet main > :not(.printsheet) { display: none !important; }
  body.has-printsheet main > .printsheet { display: block !important; }
  .printsheet { color: #000; font-size: 8.5pt; }
  .ps-head { display: flex; align-items: center; gap: 10px; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 8px; }
  .ps-logo { height: 40px; width: auto; }
  .ps-title { flex: 1; display: flex; flex-direction: column; gap: 2px; }
  .ps-title b { font-size: 12.5pt; }
  .ps-title span { font-size: 8pt; color: #333; }
  .ps-grand { text-align: center; border: 1.5px solid #000; padding: 4px 10px; border-radius: 4px; }
  .ps-grand span { display: block; font-size: 7.5pt; }
  .ps-grand b { display: block; font-size: 13pt; font-family: var(--f-mono); }
  .ps-grand small { font-size: 7pt; }
  .printsheet table { width: 100%; border-collapse: collapse; }
  .printsheet th, .printsheet td { border: 1px solid #bbb; vertical-align: top; font-size: 8pt; }
  .printsheet thead th { background: #eee; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ps-sec td { font-weight: 700; background: #f4f4f4; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ps-cnt { font-weight: 400; color: #555; }
  .ps-m, .ps-p { font-size: 7.5pt; color: #333; }
  .ps-foot { display: flex; gap: 10px; align-items: flex-start; margin-top: 8px; break-inside: avoid; }
  .ps-foot table { flex: 1; width: auto !important; }
  .ps-total td { font-weight: 700; border-top: 2px solid #000; font-size: 9pt; }
  .ps-note { font-size: 7pt; color: #555; margin-top: 6px; }
}
