/* ============================================================
   مكتب علي — الأنماط
   عربي RTL بالكامل. داكن هادئ على طريقة Linear:
   قائمة جانبية خفيفة، قائمة طلبات مضغوطة، خط زمني،
   عمود تفاصيل جانبي. لون مميز واحد فقط: فيروزي #2DD4BF.
   ============================================================ */

:root {
  --bg: #0e1013;
  --bg-soft: #14171c;
  --surface: #181b21;
  --surface-hover: #1e222a;
  --border: #262b34;
  --border-soft: #1d2129;
  --text: #e6e8eb;
  --muted: #9aa1ad;
  --faint: #6b7280;
  --accent: #2dd4bf;
  --accent-dim: rgba(45, 212, 191, 0.12);
  --danger: #f87171;
  --radius: 10px;
  --sidebar-w: 232px;
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- الهيكل ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-soft);
  border-inline-end: 1px solid var(--border-soft);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-size: 19px;
  font-weight: 700;
  padding: 4px 10px 18px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.nav-label {
  font-size: 11.5px;
  color: var(--faint);
  padding: 14px 10px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar .who {
  margin-top: auto;
  border-top: 1px solid var(--border-soft);
  padding: 12px 10px 4px;
  font-size: 13px;
  color: var(--muted);
}
.sidebar .who strong { color: var(--text); }
.logout-btn {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 0 0;
}
.logout-btn:hover { color: var(--danger); }

.main { flex: 1; min-width: 0; padding: 28px 32px 120px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 21px; margin: 0 0 4px; font-weight: 700; }
.page-head p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ---------- سطر الملخص ---------- */
.summary-line {
  font-size: 13.5px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 14px;
  margin-bottom: 22px;
}
.summary-line b { color: var(--text); }
.summary-line .accent { color: var(--accent); font-weight: 700; }

/* ---------- الفلاتر ---------- */
.filters { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.filter {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
}
.filter.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ---------- مجموعات "الآن" ---------- */
.group { margin-bottom: 26px; }
.group-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  padding-inline-start: 2px;
}
.group-head h2 { font-size: 15px; margin: 0; font-weight: 700; }
.group-head .count {
  font-size: 12px;
  color: var(--faint);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 8px;
}
.group-empty {
  color: var(--faint);
  font-size: 13.5px;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---------- قائمة الطلبات المضغوطة ---------- */
.req-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.req-item { background: var(--surface); border-bottom: 1px solid var(--border-soft); }
.req-item:last-child { border-bottom: none; }
.req-item:hover { background: var(--surface-hover); }
.req-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: var(--text);
}
.req-link:hover { text-decoration: none; }
.req-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.req-dot.done { background: var(--faint); }
.req-dot.third { background: #c084fc; }
.req-main { flex: 1; min-width: 0; }
.req-title { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.req-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.req-due { font-size: 12.5px; color: var(--muted); flex-shrink: 0; }
.req-due.late { color: var(--danger); font-weight: 700; }
.req-amount { font-size: 12.5px; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* ---------- نقاط الحالة والشارات ---------- */
.badge {
  display: inline-block;
  font-size: 11.5px;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.badge.open { color: var(--accent); border-color: var(--accent); }
.badge.done { color: var(--faint); }
.badge.late { color: var(--danger); border-color: var(--danger); }
.badge.pending { color: #fbbf24; border-color: #fbbf24; }
.badge.approved { color: var(--accent); border-color: var(--accent); }
.badge.rejected { color: var(--danger); border-color: var(--danger); }
.sample-tag { color: var(--faint); font-size: 11.5px; }

/* ---------- صفحة الطلب ---------- */
.request-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}
.request-title { font-size: 22px; margin: 0 0 6px; font-weight: 700; }
.request-desc { color: var(--muted); white-space: pre-wrap; margin: 0 0 26px; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  inset-inline-start: 7px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--border);
}
.timeline-item { position: relative; padding: 0 28px 20px 0; }
.timeline-item .t-dot {
  position: absolute;
  inset-inline-start: 3px;
  top: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}
.timeline-item.history .t-dot { background: var(--faint); }
.timeline-meta { font-size: 12px; color: var(--faint); margin-bottom: 2px; }
.timeline-body { font-size: 14.5px; white-space: pre-wrap; }
.timeline-body .action { color: var(--muted); }

.details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 24px;
}
.details h2 { font-size: 14px; margin: 0 0 12px; }
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border-soft);
  font-size: 13.5px;
}
.detail-row:first-of-type { border-top: none; }
.detail-row .k { color: var(--muted); flex-shrink: 0; }
.detail-row .v { text-align: end; font-variant-numeric: tabular-nums; }

/* ---------- النماذج ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 22px;
}
.card h2, .card h3 { font-size: 15px; margin: 0 0 14px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-field { flex: 1; min-width: 180px; margin-bottom: 12px; }
.form-field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 84px; resize: vertical; }
.btn {
  background: var(--accent);
  color: #06231f;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
}
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); font-weight: 600; }
.btn-small { padding: 5px 12px; font-size: 13px; }
.inline-form { display: inline; }

/* ---------- جداول ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- مجاميع العملات ---------- */
.totals { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.total-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 16px;
  min-width: 200px;
}
.total-box .cur { font-size: 13px; color: var(--accent); font-weight: 700; }
.total-box .row { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; color: var(--muted); }
.total-box .row b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- رسائل ---------- */
.flash { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 18px; font-size: 14px; }
.flash.success { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent); }
.flash.error { background: rgba(248, 113, 113, 0.1); color: var(--danger); border: 1px solid var(--danger); }

/* ---------- الدخول ---------- */
.login-wrap { max-width: 380px; margin: 12vh auto 0; }
.login-wrap h1 { font-size: 22px; margin-bottom: 4px; }
.login-wrap p { color: var(--muted); font-size: 13.5px; }

/* ---------- شريط التنقل السفلي (موبايل فقط) ---------- */
.bottom-nav { display: none; }

/* ---------- موبايل ---------- */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: 18px 16px 110px; }
  .request-layout { grid-template-columns: 1fr; }
  .details { position: static; }
  /* صفحة الطلب بملء الشاشة على الموبايل */
  .request-layout .details { order: 2; }
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    background: var(--bg-soft);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 50;
    justify-content: space-around;
  }
  .bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--muted);
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 8px;
  }
  .bottom-nav a.active { color: var(--accent); }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav svg { width: 21px; height: 21px; }
  /* [office patch] المواعيد والمبالغ بعملتها تفضل ظاهرة على الموبايل في سطر لوحدها */
  .req-link { flex-wrap: wrap; align-items: flex-start; row-gap: 6px; }
  .req-main { flex: 1 1 calc(100% - 24px); }
  .req-title, .req-meta { display: block; line-height: 1.6; }
  .req-due, .req-amount { order: 3; font-size: 12.5px; line-height: 1.5; margin-inline-start: 20px; }
}
