/* ============================================================
   لوحة تحكم بصمة تصميم — نفس لغة b-t.sa البصرية
   ============================================================ */
:root {
  --ink-900: #07080d;
  --ink-800: #0b0d14;
  --ink-700: #10131d;
  --ink-600: #161a28;
  --ink-500: #1d2233;
  --c-cyan: #2de2ff;
  --c-violet: #7c5cff;
  --c-magenta: #ff3d8a;
  --c-yellow: #ffd166;
  --c-green: #34d399;
  --c-red: #ff5d5d;
  --grad-brand: linear-gradient(135deg, var(--c-cyan) 0%, var(--c-violet) 48%, var(--c-magenta) 100%);
  --text-1: #f2f5ff;
  --text-2: #aeb8d0;
  --text-3: #76829e;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --shadow-1: 0 10px 40px -12px rgba(0, 0, 0, .55);
  --font-display-ar: "Cairo", system-ui, sans-serif;
  --font-body-ar: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-display-en: "Space Grotesk", system-ui, sans-serif;
  --font-body-en: "Manrope", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
html[lang="ar"] body { font-family: var(--font-body-ar); }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3,
html[lang="ar"] .btn, html[lang="ar"] .display { font-family: var(--font-display-ar); }
html[lang="en"] body { font-family: var(--font-body-en); }
html[lang="en"] h1, html[lang="en"] h2, html[lang="en"] h3,
html[lang="en"] .btn, html[lang="en"] .display { font-family: var(--font-display-en); }
body {
  background: var(--ink-900);
  color: var(--text-2);
  line-height: 1.7;
  min-height: 100vh;
}
[hidden] { display: none !important; }
a { color: var(--c-cyan); }

/* خلفية */
.bg-orbs { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .28; }
.orb--violet { width: 480px; height: 480px; background: var(--c-violet); top: -140px; inset-inline-start: -120px; }
.orb--cyan { width: 380px; height: 380px; background: var(--c-cyan); bottom: -120px; inset-inline-end: -100px; opacity: .16; }
.orb--magenta { width: 260px; height: 260px; background: var(--c-magenta); top: 34%; inset-inline-end: 30%; opacity: .14; }

/* الدخول */
.auth-screen { position: relative; z-index: 1; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.2rem; }
.auth-card {
  width: min(440px, 100%);
  background: rgba(16, 19, 29, .92);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 2rem 1.8rem;
  box-shadow: var(--shadow-1);
}
.auth-brand { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.6rem; }
.auth-brand img { border-radius: 12px; }
.auth-brand strong { display: block; color: var(--text-1); font-size: 1.1rem; }
.auth-brand span { color: var(--text-3); font-size: .85rem; }
.auth-brand .lang-btn { margin-inline-start: auto; }

/* الأزرار والحقول */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 0; cursor: pointer; font-weight: 700;
  padding: .8rem 1.6rem; border-radius: 999px;
  background: var(--grad-brand); color: #07080d;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s;
  text-decoration: none; font-size: .95rem;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -10px rgba(255, 61, 138, .5); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn--ghost { background: transparent; color: var(--text-1); border: 1px solid var(--line-strong); box-shadow: none; }
.btn--ghost:hover { border-color: rgba(45, 226, 255, .5); box-shadow: 0 0 30px -8px rgba(45, 226, 255, .4); }
.btn--danger { background: linear-gradient(135deg, #ff5d5d, #c81e1e); color: #fff; }
.btn--sm { padding: .5rem 1.1rem; font-size: .85rem; }
.btn--xs { padding: .32rem .8rem; font-size: .78rem; }
.btn--block { width: 100%; }
.icon-btn {
  background: transparent; border: 1px solid var(--line-strong); color: var(--text-1);
  border-radius: 10px; padding: .4rem .65rem; cursor: pointer; font-size: 1rem;
}
.lang-btn {
  background: rgba(255,255,255,.06); border: 1px solid var(--line-strong);
  color: var(--text-1); border-radius: 999px; padding: .35rem .9rem;
  font-size: .8rem; font-weight: 700; cursor: pointer;
}
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-1); margin-bottom: .4rem; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--ink-600); border: 1px solid var(--line-strong);
  color: var(--text-1); border-radius: var(--radius-sm);
  padding: .7rem .9rem; font-size: .95rem; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--c-cyan); box-shadow: 0 0 0 3px rgba(45, 226, 255, .15);
}
.field textarea { resize: vertical; min-height: 90px; }
.field .hint { font-size: .78rem; color: var(--text-3); margin-top: .3rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.form-err { background: rgba(255, 93, 93, .1); border: 1px solid rgba(255, 93, 93, .4); color: #ffb4b4; border-radius: var(--radius-sm); padding: .6rem .9rem; font-size: .85rem; margin-bottom: 1rem; }
.form-ok { background: rgba(52, 211, 153, .1); border: 1px solid rgba(52, 211, 153, .4); color: #a7f3d0; border-radius: var(--radius-sm); padding: .6rem .9rem; font-size: .85rem; margin-bottom: 1rem; }
.temp-pass {
  background: rgba(255, 209, 102, .08); border: 1px dashed rgba(255, 209, 102, .6);
  border-radius: var(--radius-sm); padding: .8rem 1rem; margin: 1rem 0; font-size: .9rem;
}
.temp-pass code { display: block; font-size: 1.25rem; letter-spacing: 1px; color: var(--c-yellow); margin: .4rem 0; direction: ltr; text-align: center; user-select: all; }

/* التطبيق */
.app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: .8rem;
  padding: .7rem 1.1rem; border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 20, .9); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-brand { display: flex; align-items: center; gap: .6rem; color: var(--text-1); font-weight: 800; text-decoration: none; }
.topbar-brand img { border-radius: 8px; }
.topbar-spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: .55rem; font-size: .85rem; color: var(--text-1); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: #07080d; flex: none; }
.layout { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 240px; flex: none; border-inline-end: 1px solid var(--line);
  padding: 1.1rem .8rem; display: flex; flex-direction: column; gap: .25rem;
  background: rgba(11, 13, 20, .6);
}
.sidebar a.nav-it {
  display: flex; align-items: center; gap: .6rem;
  color: var(--text-2); text-decoration: none; font-size: .92rem; font-weight: 600;
  padding: .6rem .8rem; border-radius: var(--radius-sm); border: 1px solid transparent;
}
.sidebar a.nav-it:hover { background: rgba(255,255,255,.04); color: var(--text-1); }
.sidebar a.nav-it.active { background: rgba(124, 92, 255, .14); border-color: rgba(124, 92, 255, .4); color: var(--text-1); }
.side-home { margin-top: auto; color: var(--text-3); font-size: .85rem; text-decoration: none; padding: .6rem .8rem; }
.view { flex: 1; padding: 1.4rem clamp(1rem, 3vw, 2rem); max-width: 1180px; width: 100%; margin-inline: auto; }
.view h1 { color: var(--text-1); font-size: 1.5rem; margin-bottom: .3rem; }
.view .sub { color: var(--text-3); font-size: .9rem; margin-bottom: 1.2rem; }
.page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .spacer { flex: 1; }

/* بطاقات */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.card {
  background: rgba(22, 26, 40, .85); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 1.1rem 1.2rem; box-shadow: var(--shadow-1);
}
.card h3 { color: var(--text-3); font-size: .82rem; font-weight: 600; margin-bottom: .3rem; }
.card .big { color: var(--text-1); font-size: 1.8rem; font-weight: 800; }
.card .big.grad { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel { background: rgba(16, 19, 29, .9); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 1.2rem; margin-bottom: 1.2rem; }
.panel > h2 { color: var(--text-1); font-size: 1.1rem; margin-bottom: .9rem; }

/* شارات */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 700; padding: .18rem .65rem; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.b-in_progress { color: var(--c-cyan); border-color: rgba(45,226,255,.5); background: rgba(45,226,255,.08); }
.b-completed, .b-done, .b-accepted, .b-sent { color: var(--c-green); border-color: rgba(52,211,153,.5); background: rgba(52,211,153,.08); }
.b-incomplete, .b-cancelled, .b-rejected, .b-expired { color: var(--text-3); border-color: var(--line-strong); background: rgba(255,255,255,.04); }
.b-stalled, .b-urgent { color: var(--c-red); border-color: rgba(255,93,93,.5); background: rgba(255,93,93,.08); }
.b-deferred, .b-high { color: var(--c-yellow); border-color: rgba(255,209,102,.5); background: rgba(255,209,102,.08); }
.b-new, .b-read, .b-draft { color: var(--c-violet); border-color: rgba(124,92,255,.55); background: rgba(124,92,255,.1); }
.b-normal, .b-low { color: var(--text-2); border-color: var(--line-strong); background: rgba(255,255,255,.04); }
.b-private { color: var(--c-magenta); border-color: rgba(255,61,138,.5); background: rgba(255,61,138,.08); }
.b-public { color: var(--c-cyan); border-color: rgba(45,226,255,.5); background: rgba(45,226,255,.08); }

/* جداول وقوائم */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; background: rgba(16,19,29,.9); }
.tbl th, .tbl td { padding: .65rem .8rem; text-align: start; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--text-3); font-size: .76rem; font-weight: 600; background: rgba(255,255,255,.02); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: rgba(255,255,255,.02); }
.tbl .rowlink { color: var(--text-1); font-weight: 600; text-decoration: none; }
.tbl .rowlink:hover { color: var(--c-cyan); }
.list { display: flex; flex-direction: column; gap: .7rem; }
.item {
  background: rgba(22, 26, 40, .85); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: .95rem 1.1rem;
}
.item:hover { border-color: var(--line-strong); }
.item-top { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .35rem; }
.item-top .t { color: var(--text-1); font-weight: 700; }
.item-top .spacer { flex: 1; }
.item-meta { font-size: .78rem; color: var(--text-3); display: flex; gap: 1rem; flex-wrap: wrap; }
.item-actions { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: .6rem; }
.progress { height: 8px; background: rgba(255,255,255,.07); border-radius: 999px; overflow: hidden; margin-top: .5rem; }
.progress > i { display: block; height: 100%; background: var(--grad-brand); border-radius: 999px; transition: width .4s ease; }
.empty { text-align: center; color: var(--text-3); padding: 2.2rem 1rem; border: 1px dashed var(--line-strong); border-radius: var(--radius-md); }

/* فلاتر */
.filters { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.filters input, .filters select {
  background: var(--ink-600); border: 1px solid var(--line-strong);
  color: var(--text-1); border-radius: 999px; padding: .45rem .95rem; font-size: .85rem; font-family: inherit;
}

/* مودال */
.modal-back { position: fixed; inset: 0; background: rgba(4, 5, 9, .7); backdrop-filter: blur(3px); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; }
.modal { width: min(620px, 100%); background: var(--ink-700); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow-1); }
.modal h2 { color: var(--text-1); font-size: 1.15rem; margin-bottom: 1rem; }
.modal-foot { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.2rem; flex-wrap: wrap; }
.quote-items { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: .6rem; }
.qi-row { display: grid; grid-template-columns: 1fr 70px 110px 40px; gap: .5rem; padding: .5rem; border-bottom: 1px solid var(--line); align-items: center; }
.qi-row:last-child { border-bottom: 0; }
.qi-row input { background: var(--ink-600); border: 1px solid var(--line); color: var(--text-1); border-radius: 8px; padding: .45rem .6rem; font-size: .85rem; width: 100%; font-family: inherit; }
.qi-total { text-align: end; font-size: .9rem; color: var(--text-1); padding: .4rem .2rem; }
.qi-head { display: grid; grid-template-columns: 1fr 70px 110px 40px; gap: .5rem; padding: .35rem .5rem; font-size: .75rem; color: var(--text-3); font-weight: 600; }
.qi-box { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: .7rem .95rem; font-size: .88rem; background: rgba(255,255,255,.02); }
.qi-box .r { display: flex; justify-content: space-between; gap: 1rem; padding: .18rem 0; color: var(--text-2); }
.qi-box .r b { color: var(--text-1); font-variant-numeric: tabular-nums; }
.qi-box .r.grand { border-top: 1px solid var(--line-strong); margin-top: .45rem; padding-top: .55rem; color: var(--text-1); font-weight: 800; font-size: 1.05rem; }
.qi-box .r.grand b { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.switch { display: flex; align-items: center; gap: .6rem; font-size: .9rem; color: var(--text-1); cursor: pointer; }
.switch input { width: 1.1rem; height: 1.1rem; accent-color: var(--c-violet); }

/* تنبيهات */
.toasts { position: fixed; bottom: 1.2rem; inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: .5rem; z-index: 100; pointer-events: none; }
.toast { background: var(--ink-600); border: 1px solid var(--line-strong); color: var(--text-1); border-radius: 999px; padding: .6rem 1.3rem; font-size: .88rem; box-shadow: var(--shadow-1); animation: tin .25s ease; }
.toast.ok { border-color: rgba(52,211,153,.6); }
.toast.err { border-color: rgba(255,93,93,.6); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .8rem; margin: 1rem 0; }
.detail-grid .d { background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .8rem; }
.detail-grid .d small { display: block; color: var(--text-3); font-size: .72rem; }
.detail-grid .d b { color: var(--text-1); font-size: .92rem; }
.note-box { background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .7rem .9rem; font-size: .88rem; margin-top: .7rem; white-space: pre-wrap; }
.note-box small { display: block; color: var(--text-3); font-size: .72rem; margin-bottom: .2rem; }
.ws-color { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: none; }

/* سجل التقدّم الزمني */
.timeline { display: flex; flex-direction: column; }
.tline { display: flex; gap: .7rem; }
.tline-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--grad-brand); flex: none; margin-top: .4rem; box-shadow: 0 0 12px rgba(124, 92, 255, .6); }
.tline-body { flex: 1; border-inline-start: 1px solid var(--line-strong); padding-inline-start: .85rem; padding-bottom: 1rem; }
.tline:last-child .tline-body { padding-bottom: .2rem; }

/* جوال */
#side-toggle { display: none; }
@media (max-width: 860px) {
  #side-toggle { display: inline-block; }
  .sidebar { position: fixed; top: 0; bottom: 0; z-index: 40; background: var(--ink-800); transition: transform .25s ease; padding-top: 4rem; }
  html[dir="rtl"] .sidebar { inset-inline-start: 0; transform: translateX(105%); }
  html[dir="ltr"] .sidebar { inset-inline-start: 0; transform: translateX(-105%); }
  .sidebar.open { transform: translateX(0) !important; }
  .field-row { grid-template-columns: 1fr; }
  .user-chip .uinfo { display: none; }
  .qi-row { grid-template-columns: 1fr 60px 90px 34px; }
  .qi-head { grid-template-columns: 1fr 60px 90px 34px; }
}
