:root {
  --navy: #13254A; --navy-2: #1E3563; --navy-3: #2C4270; --gold: #C9A24A;
  --blue: #2563EB; --blue-d: #1D4ED8; --bg: #F6F7F9; --card: #fff; --ink: #0F172A; --ink-2: #334155;
  --muted: #475569; --line: #E2E8F0; --line-2: #CBD5E1; --red: #B91C1C; --amber: #B45309; --green: #166534;
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'IBM Plex Sans Arabic', 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
html[dir="ltr"] body { font-family: 'Inter', 'IBM Plex Sans Arabic', system-ui, sans-serif; }
a { color: var(--blue-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; } h2 { font-size: 17px; font-weight: 600; } h2.big { font-size: 22px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.mono { font-family: 'Inter', monospace; font-size: 13px; }
.num { text-align: end; font-family: 'Inter', sans-serif; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* أزرار وحقول */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn-primary { background: var(--blue); color: #fff; } .btn-primary:hover { background: var(--blue-d); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line-2); } .btn-ghost:hover { background: #F1F5F9; }
.btn:disabled { opacity: .6; cursor: default; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--blue-d); cursor: pointer; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 15px; color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 12px; min-height: 42px; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
input[type=color] { padding: 4px; width: 80px; }
.file-btn input { display: none; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.narrow { max-width: 620px; }

/* شاشة الدخول */
.center-screen, .auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth { background: linear-gradient(180deg, var(--navy) 0, var(--navy) 42%, var(--bg) 42%); }
.auth-card { width: 100%; max-width: 460px; background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 10px 30px rgba(15, 23, 42, .12); display: flex; flex-direction: column; gap: 20px; }
.auth-brand { display: flex; align-items: center; gap: 14px; }
.auth-brand svg { width: 52px; height: 52px; }
.brand-name { font-family: 'Inter', sans-serif; font-size: 24px; font-weight: 700; color: var(--navy); }
.brand-name span { color: #9A7A2E; }
.auth-foot { display: flex; justify-content: space-between; font-size: 13px; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* الهيكل */
.layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 240px; max-width: 264px; background: var(--navy); color: #E2E8F0; padding: 18px 12px; display: flex; flex-direction: column; gap: 3px; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-family: 'Inter', sans-serif; font-size: 19px; color: #fff; }
.side-brand svg { width: 34px; height: 34px; } .side-brand b { color: #E2C27A; font-weight: 600; }
.tenant { background: var(--navy-2); border-radius: 10px; padding: 10px; margin: 0 4px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tenant img { max-width: 100%; max-height: 64px; background: #fff; border-radius: 8px; padding: 6px; }
.tenant .tenant-name { color: #fff; font-weight: 600; text-align: center; }
.tenant span { font-size: 12px; color: #CBD5E1; }
.tenant select { min-height: 34px; font-size: 13px; padding: 4px 8px; }
.nav-item { display: flex; align-items: center; justify-content: space-between; min-height: 40px; padding: 0 12px; border-radius: 8px; color: #CBD5E1; font-size: 14px; text-decoration: none !important; }
.nav-item:hover { background: var(--navy-2); color: #fff; }
.nav-item.on { background: var(--navy-3); color: #fff; font-weight: 600; }
.nav-item.disabled { opacity: .62; }
.pill-soon { font-size: 11px; background: rgba(255, 255, 255, .12); padding: 1px 8px; border-radius: 999px; }
.nav-group { font-size: 12px; color: #94A3B8; padding: 14px 12px 4px; }
.main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 18px 28px; }
.top h1 { margin-inline-end: auto; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none !important; padding: 2px 6px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.user-name { font-weight: 600; font-size: 14px; }
.content { padding: 0 28px 24px; display: flex; flex-direction: column; gap: 18px; }
.foot { padding: 12px 28px 20px; font-size: 12px; }

/* بطاقات */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.empty { align-items: center; text-align: center; padding: 48px 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi b { font-family: 'Inter', sans-serif; font-size: 28px; }
.stages { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 8px; }
.stage-tile { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 10px; background: #F1F5F9; color: var(--ink-2); text-decoration: none !important; }
.stage-tile:hover { background: #E2E8F0; }
.stage-tile b { font-family: 'Inter', sans-serif; font-size: 22px; color: var(--navy); }
.alert { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; border-inline-start: 4px solid; }
.alert-red { background: #FEF2F2; border-color: var(--red); } .alert-amber { background: #FFFBEB; border-color: var(--amber); }
.filters { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.filters label { flex: 1 1 170px; }
.filters.plain { padding: 0; border: 0; }

/* جداول */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
th { text-align: start; font-weight: 500; color: var(--muted); font-size: 13px; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 8px; border-bottom: 1px solid #F1F5F9; vertical-align: middle; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #F1F5F9; color: var(--ink-2); white-space: nowrap; }
.pill-request, .pill-boq { background: #F1F5F9; color: #334155; }
.pill-tender, .pill-clarifications, .pill-bids { background: #E0E7FF; color: #3730A3; }
.pill-evaluation, .pill-award, .pill-contract { background: #FEF3C7; color: #92400E; }
.pill-execution { background: #DBEAFE; color: #1E3A8A; }
.pill-handover, .pill-final_account, .pill-closed { background: #DCFCE7; color: #166534; }
.pill-cancelled { background: #FEE2E2; color: #991B1B; }

/* تفاصيل العملية */
.stepper { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.stepper li { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #F1F5F9; color: var(--muted); }
.stepper li.done { background: #DCFCE7; color: #166534; }
.stepper li.now { background: var(--navy); color: #fff; font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 0; }
.facts dt { font-size: 12px; color: var(--muted); } .facts dd { margin: 0; font-weight: 600; }
.desc { white-space: pre-line; margin: 0; color: var(--ink-2); }
.img-box { width: 140px; height: 80px; border: 1px dashed var(--line-2); border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.img-box img { max-width: 100%; max-height: 100%; }
.letterhead { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 3px solid; }
.letterhead img { max-height: 60px; max-width: 45%; }

/* رسائل */
.toast { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 50; max-width: 420px; padding: 12px 16px; border-radius: 10px; color: #fff; font-weight: 500; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.toast-ok { background: #14532D; } .toast-err { background: #991B1B; }

@media (max-width: 760px) {
  .side { max-width: none; flex-basis: 100%; flex-direction: row; flex-wrap: wrap; }
  .side-brand, .tenant { flex-basis: 100%; }
  .top, .content { padding-inline: 14px; }
}
