/* =====================================================================
   نظام الشكاوي — نقابة الكهربائيين رام الله والبيرة
   الهوية اللونية مأخوذة من ترميز أسلاك الكهرباء (IEC):
   بني = خط حي  |  أزرق = محايد  |  أصفر-أخضر = أرضي
   ===================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Kufi+Arabic:wght@500;700&family=IBM+Plex+Sans+Arabic:wght@400;500;600&display=swap');

:root {
  --ink:      #0F1720;   /* لوحة التوزيع */
  --ink-2:    #1C2733;
  --ink-3:    #2E3D4D;
  --steel:    #E9EDF1;   /* الخلفية */
  --paper:    #FFFFFF;
  --line:     #D3DAE2;
  --text:     #16202B;
  --muted:    #63707E;

  --live:     #6E3B23;   /* بني — الخط الحي: الإجراءات الحاسمة */
  --neutral:  #1E5A8E;   /* أزرق — الإجراء الأساسي */
  --neutral-w:#E4EEF7;
  --earth:    #B99400;   /* أصفر-أخضر — التنبيه والانتظار */
  --earth-w:  #FBF3D8;
  --ok:       #24705A;
  --ok-w:     #DEF0E9;
  --bad:      #A32B2B;
  --bad-w:    #F8E3E3;

  --r: 6px;
  --shadow: 0 1px 2px rgba(15,23,32,.06), 0 4px 16px rgba(15,23,32,.05);
  --display: 'Noto Kufi Arabic', 'Segoe UI', Tahoma, sans-serif;
  --body: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--steel); color: var(--text);
  font-family: var(--body); font-size: 15px; line-height: 1.65;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; line-height: 1.35; margin: 0 0 .6rem; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.1rem; } h3 { font-size: .98rem; }
a { color: var(--neutral); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--earth); outline-offset: 2px; }

/* ---------------- الهيكل ---------------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  background: var(--ink); color: #C9D3DD; padding: 1rem .75rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  /* الشريط الأرضي: أصفر-أخضر */
  border-inline-start: 4px solid transparent;
  border-image: repeating-linear-gradient(180deg, var(--earth) 0 14px, #2F6B3C 14px 28px) 1;
}
.brand { display: flex; gap: .6rem; align-items: center; padding: .4rem .5rem 1rem; border-bottom: 1px solid var(--ink-3); margin-bottom: .75rem; }
.brand b { font-family: var(--display); color: #fff; font-size: .92rem; display: block; line-height: 1.4; }
.brand small { color: #7E8D9C; font-size: .72rem; }
.bolt { width: 34px; height: 34px; flex: 0 0 34px; background: var(--earth); border-radius: 4px; display: grid; place-items: center; color: var(--ink); font-weight: 700; }

.nav a {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  color: #C9D3DD; padding: .5rem .6rem; border-radius: var(--r); font-size: .9rem; margin-bottom: 2px;
}
.nav a:hover { background: var(--ink-2); text-decoration: none; color: #fff; }
.nav a.on { background: var(--ink-2); color: #fff; box-shadow: inset 3px 0 0 var(--earth); }
.nav .sec { color: #5D6C7B; font-size: .68rem; letter-spacing: .06em; padding: .9rem .6rem .3rem; font-family: var(--display); }
.nav .pill { background: var(--ink-3); color: #C9D3DD; font-size: .72rem; padding: 0 .4rem; border-radius: 20px; }

.main { padding: 1.25rem 1.5rem 3rem; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.who { font-size: .82rem; color: var(--muted); text-align: start; }
.who b { color: var(--text); display: block; font-size: .88rem; }

/* ---------------- البطاقات ---------------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 1rem; }
.card > h2, .card > h3 { padding: .75rem 1rem; margin: 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.card .body { padding: 1rem; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g-main { grid-template-columns: 2fr 1fr; align-items: start; }

.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: .85rem 1rem; }
.stat .n { font-family: var(--display); font-size: 1.7rem; line-height: 1.2; }
.stat .l { color: var(--muted); font-size: .8rem; }

/* ---------------- الجداول ---------------- */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: start; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #F5F7F9; font-family: var(--display); font-size: .78rem; color: var(--muted); font-weight: 500; white-space: nowrap; }
tbody tr:hover { background: #FAFBFC; }
td.ref { font-weight: 600; white-space: nowrap; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.empty p { margin: .3rem 0 1rem; }

/* ---------------- الشارات ---------------- */
.chip {
  display: inline-block; font-size: .74rem; padding: .12rem .5rem; border-radius: 3px;
  border: 1px solid transparent; white-space: nowrap; font-weight: 500;
}
.chip.muted { background: #EDF0F3; color: var(--muted); border-color: var(--line); }
.chip.info  { background: var(--neutral-w); color: var(--neutral); border-color: #C3DCF0; }
.chip.warn  { background: var(--earth-w); color: #7A6200; border-color: #EBDCA0; }
.chip.ok    { background: var(--ok-w); color: var(--ok); border-color: #B9DDD0; }
.chip.bad   { background: var(--bad-w); color: var(--bad); border-color: #EEC4C4; }
.chip.done  { background: var(--ink-2); color: #C9D3DD; }

/* ---------------- النماذج ---------------- */
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
input[type=text], input[type=tel], input[type=number], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: .48rem .6rem; border: 1px solid var(--line); border-radius: var(--r);
  font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--neutral); outline: none; box-shadow: 0 0 0 3px var(--neutral-w); }
textarea { resize: vertical; min-height: 76px; }
.field { margin-bottom: .8rem; }
.req::after { content: ' *'; color: var(--bad); }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: .9rem; margin: 0 0 1rem; }
legend { font-family: var(--display); font-size: .85rem; padding: 0 .4rem; color: var(--ink); }
.inline { display: flex; gap: 1rem; align-items: center; }
.inline label { margin: 0; font-size: .85rem; color: var(--text); }

.btn {
  display: inline-flex; align-items: center; gap: .35rem; font: inherit; font-size: .87rem;
  padding: .45rem .9rem; border-radius: var(--r); border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer; text-decoration: none;
}
.btn:hover { background: #F5F7F9; text-decoration: none; }
.btn.primary { background: var(--neutral); border-color: var(--neutral); color: #fff; }
.btn.primary:hover { background: #17507F; }
.btn.live { background: var(--live); border-color: var(--live); color: #fff; }
.btn.live:hover { background: #5C301B; }
.btn.danger { color: var(--bad); border-color: #EEC4C4; background: var(--bad-w); }
.btn.sm { padding: .25rem .55rem; font-size: .78rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------------- التنبيهات ---------------- */
.alert { padding: .6rem .9rem; border-radius: var(--r); margin-bottom: .9rem; font-size: .88rem; border: 1px solid; }
.alert.ok  { background: var(--ok-w); border-color: #B9DDD0; color: #17513F; }
.alert.bad { background: var(--bad-w); border-color: #EEC4C4; color: #7E1F1F; }
.alert ul { margin: .3rem 0 0; padding-inline-start: 1.2rem; }

/* ---------------- خط السير: قضيب توصيل رأسي ---------------- */
.rail { list-style: none; margin: 0; padding: 0 1.4rem 0 0; position: relative; }
.rail::before {
  content: ''; position: absolute; inset-inline-start: .32rem; top: .4rem; bottom: .4rem;
  width: 2px; background: repeating-linear-gradient(180deg, var(--line) 0 4px, transparent 4px 8px);
}
.rail li { position: relative; padding: 0 0 1rem 0; }
.rail li::before {
  content: ''; position: absolute; inset-inline-start: -1.4rem; top: .42rem;
  width: 11px; height: 11px; border-radius: 50%; background: var(--paper);
  border: 2px solid var(--ink-3); margin-inline-start: .32rem; transform: translateX(50%);
}
.rail li.node-ok::before   { background: var(--ok);   border-color: var(--ok); }
.rail li.node-warn::before { background: var(--earth);border-color: var(--earth); }
.rail li.node-bad::before  { background: var(--bad);  border-color: var(--bad); }
.rail .t { font-size: .88rem; font-weight: 500; }
.rail .m { font-size: .76rem; color: var(--muted); }
.rail .n { font-size: .82rem; color: var(--text); background: #F5F7F9; border-inline-start: 2px solid var(--line); padding: .3rem .5rem; border-radius: 0 var(--r) var(--r) 0; margin-top: .3rem; }

/* ---------------- تفاصيل الطلب ---------------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .88rem; }
.kv dt { color: var(--muted); font-size: .8rem; }
.kv dd { margin: 0; }
.prose { white-space: pre-wrap; font-size: .9rem; }
.hint { font-size: .78rem; color: var(--muted); }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
.filters .field { margin: 0; min-width: 130px; }

.type-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.type-pick a { border: 1px solid var(--line); background: var(--paper); border-radius: var(--r); padding: 1rem; display: block; color: var(--text); }
.type-pick a:hover { border-color: var(--neutral); box-shadow: var(--shadow); text-decoration: none; }
.type-pick b { font-family: var(--display); display: block; }
.type-pick small { color: var(--muted); }

/* ---------------- الدخول ---------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--ink);
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.02) 0 1px, transparent 1px 22px); padding: 1rem; }
.login { width: 100%; max-width: 380px; background: var(--paper); border-radius: 8px; padding: 1.6rem; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login .brand { border: 0; justify-content: center; text-align: center; flex-direction: column; padding-bottom: 1rem; }
.login .brand b { color: var(--text); }

/* ---------------- الطباعة ---------------- */
.sheet { max-width: 780px; margin: 1rem auto; background: #fff; padding: 2.2cm 1.8cm; box-shadow: var(--shadow); }
.sheet .head { text-align: center; margin-bottom: 1.4rem; }
.sheet .head b { font-family: var(--display); font-size: 1.05rem; display: block; }
.sheet .meta { display: flex; justify-content: space-between; font-size: .85rem; border-bottom: 2px solid var(--ink); padding-bottom: .5rem; margin-bottom: 1.2rem; }
.sheet .sign { margin-top: 2.5rem; text-align: center; font-size: .9rem; }
.sheet table { border: 1px solid #999; }
.sheet th, .sheet td { border: 1px solid #999; }
.no-print { }

@media print {
  body { background: #fff; font-size: 12pt; }
  .no-print, .side, .topbar { display: none !important; }
  .sheet { box-shadow: none; margin: 0; max-width: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-image: none; border-inline-start: 0; border-bottom: 3px solid var(--earth); }
  .g2, .g3, .g-main, .type-pick { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
  .scroll-x { overflow-x: auto; }
}

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