/* ═══════════════════════════════════════════════════════════════
   نظام مخازن الوسام ستيل — التنسيق
   خطوط النظام فقط: يعمل بلا إنترنت على تابلت المخزن، وبلا انتظار تحميل.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --ground: #0E1417;
  --surface: #161F23;
  --surface-2: #1B262A;
  --surface-3: #222E33;
  --ink: #E7EDEB;
  --ink-2: #9DAEB4;
  --ink-3: #77888F;
  --line: #2A363B;
  --line-soft: #222D31;
  --accent: #4FA6B6;
  --accent-dim: #12313A;
  --hot: #DC8248;
  --hot-dim: #33200F;
  --ok: #5EAE81;
  --ok-dim: #16281F;
  --warn: #C79A2E;
  --warn-dim: #2A2312;
  --crit: #D4776A;
  --crit-dim: #2C1A18;
  --f-body: "Segoe UI", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  --f-mono: "Cascadia Mono", "Consolas", "Courier New", monospace;
  --r: 4px;
}

/* الوضع الفاتح — لمن يعمل في ساحة مشمسة */
[data-theme="light"] {
  --ground: #EDF0EF;
  --surface: #FFFFFF;
  --surface-2: #F5F8F7;
  --surface-3: #EAEFED;
  --ink: #121A1D;
  --ink-2: #4B5B63;
  --ink-3: #77878E;
  --line: #D3DAD8;
  --line-soft: #E4E9E7;
  --accent: #155E6B;
  --accent-dim: #E2EEF0;
  --hot: #A94E1B;
  --hot-dim: #F7EAE1;
  --ok: #2A6D4A;
  --ok-dim: #E4EFE8;
  --warn: #8C6100;
  --warn-dim: #F6EFDC;
  --crit: #9E3529;
  --crit-dim: #F6E5E2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

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

.skip {
  position: absolute; inset-inline-start: -9999px;
  background: var(--accent); color: #fff; 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: .9rem;
  padding: .55rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
  min-height: 3.4rem;
}
.spacer { flex: 1; }

.brand { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.brand .mark {
  width: 2rem; height: 2rem; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-weight: 700; font-size: 1.05rem; border-radius: var(--r);
}
.brand .bt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand .bt b { font-size: .95rem; white-space: nowrap; }
.brand .bt small { color: var(--ink-3); font-size: .72rem; }

.mode-chip {
  font-size: .7rem; padding: .2rem .6rem; 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.3; }
.who .wn { font-size: .85rem; font-weight: 600; }
.who .wr { font-size: .7rem; color: var(--ink-3); }
.who .wr.ro { color: var(--warn); }

.burger {
  display: none; flex-direction: column; gap: 4px;
  background: none; border: 1px solid var(--line);
  border-radius: var(--r); padding: .5rem; cursor: pointer;
}
.burger span { display: block; width: 18px; height: 2px; background: var(--ink); }

/* ── الهيكل ──────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  align-items: start;
  min-height: calc(100vh - 3.4rem);
}

.side {
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
  padding: 1rem .6rem 1.5rem;
  position: sticky; top: 3.4rem;
  max-height: calc(100vh - 3.4rem);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 1px;
}
.ngroup {
  font-size: .65rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); margin: 1rem .6rem .35rem; font-weight: 600;
}
.ngroup:first-child { margin-top: 0; }
.nlink {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .5rem .65rem;
  color: var(--ink-2); text-decoration: none;
  border-radius: var(--r); font-size: .88rem;
  border-inline-start: 2px solid transparent;
}
.nlink:hover { background: var(--surface-2); color: var(--ink); }
.nlink[aria-current="page"] {
  background: var(--accent-dim); color: var(--accent);
  border-inline-start-color: var(--accent); font-weight: 600;
}
.badge {
  background: var(--crit); color: #fff; font-style: normal;
  font-size: .68rem; font-weight: 700; min-width: 1.25rem;
  text-align: center; padding: .05rem .35rem; border-radius: 999px;
}
.side-foot {
  margin-top: auto; padding: .75rem .65rem 0;
  border-top: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: .2rem;
  font-size: .72rem; color: var(--ink-3); font-family: var(--f-mono);
}

main { padding: 1.25rem 1.35rem 4rem; min-width: 0; }

@media (max-width: 860px) {
  .burger { display: flex; }
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 3.4rem 0 auto auto;
    width: 15rem; height: calc(100vh - 3.4rem);
    transform: translateX(100%); transition: transform .18s ease;
    z-index: 30; box-shadow: -8px 0 28px rgba(0, 0, 0, .45);
  }
  body.nav-open .side { transform: translateX(0); }
  .who .wr { display: none; }
  .mode-chip { display: none; }
  main { padding: 1rem .9rem 5rem; }
}

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

h2 { font-size: 1.05rem; margin: 1.75rem 0 .75rem; font-weight: 600; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; font-weight: 600; }

/* ── البطاقات والشبكات ───────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 1.1rem 1.2rem; margin-bottom: 1rem;
}
.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: .9rem;
  padding-bottom: .65rem; border-bottom: 1px solid var(--line-soft);
}
.card-h h2, .card-h h3 { margin: 0; }

.grid { display: grid; gap: 1rem; }
.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(12rem, 1fr));
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; margin-bottom: 1.25rem;
}
.kpi { background: var(--surface); padding: .85rem 1rem; }
.kpi .k { font-size: .78rem; color: var(--ink-2); margin: 0 0 .3rem; }
.kpi .v {
  font-family: var(--f-mono); font-size: 1.3rem; font-weight: 600;
  font-variant-numeric: tabular-nums; line-height: 1.15; margin: 0;
}
.kpi .s { font-size: .7rem; color: var(--ink-3); margin: .25rem 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: 1rem;
}
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th, td {
  padding: .5rem .7rem; text-align: start;
  border-bottom: 1px solid var(--line-soft); vertical-align: top;
}
thead th {
  background: var(--surface-2); font-weight: 600; font-size: .76rem;
  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: 2.5rem 1rem; text-align: center; color: var(--ink-3); }

/* ── الشارات ─────────────────────────────────────────────────── */
.pill {
  display: inline-block; font-size: .68rem; font-weight: 600;
  padding: .12rem .45rem; 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: .75rem 1rem; border-radius: var(--r); margin-bottom: 1rem;
  border-inline-start: 3px solid var(--accent); background: var(--surface);
  font-size: .88rem;
}
.alert b { display: block; margin-bottom: .2rem; }
.alert p { margin: 0; color: var(--ink-2); }
.alert pre {
  margin: .5rem 0 0; font-size: .75rem; 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: .8rem; color: var(--ink-2); margin-bottom: .3rem; }
label .req { color: var(--crit); }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=email], input[type=tel], input[type=file], select, textarea {
  width: 100%; padding: .5rem .65rem;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r);
  font-family: inherit; font-size: .9rem;
}
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: .9rem; }
.fields { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.hint { font-size: .74rem; color: var(--ink-3); margin: .25rem 0 0; }
.err { font-size: .78rem; color: var(--crit); margin: .25rem 0 0; }

/* ── الأزرار ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: var(--r); cursor: pointer;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  font-family: inherit; font-size: .88rem; 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); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #1a1400; }
.btn.sm { padding: .3rem .7rem; font-size: .78rem; }
.btn.lg { padding: .7rem 1.4rem; font-size: .95rem; width: 100%; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* ── صفحة الدخول ─────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: 2rem 1.25rem; background: var(--ground);
}
.login-box { width: 100%; max-width: 23rem; }
.login-box .lb-brand { text-align: center; margin-bottom: 1.75rem; }
.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-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;
}

/* ── مساعدات ─────────────────────────────────────────────────── */
.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: 1rem;
}
.tabs a {
  padding: .45rem .85rem; color: var(--ink-2); text-decoration: none;
  font-size: .85rem; 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: .6rem; flex-wrap: wrap; align-items: end;
  margin-bottom: 1rem; padding: .85rem 1rem;
  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); }

@media print {
  .topbar, .side, .toolbar, .btn { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .card, .tw { border-color: #999; break-inside: avoid; }
}
