/* منصة مسار — design system. Petrol-ink archive, brass accent, bone text. RTL-first. */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0c1211;
  --bg-2: #0f1615;
  --panel: #121b19;
  --panel-2: #16211f;
  --line: #223230;
  --line-soft: #1a2825;
  --text: #e9efea;
  --text-2: #93a8a0;
  --text-3: #5d726b;
  --brass: #d9a441;
  --brass-soft: rgba(217, 164, 65, .12);
  --brass-line: rgba(217, 164, 65, .35);
  --jade: #4fbf9f;
  --jade-soft: rgba(79, 191, 159, .12);
  --red: #e06b5d;
  --red-soft: rgba(224, 107, 93, .12);
  --violet: #9d8cf0;
  --violet-soft: rgba(157, 140, 240, .13);
  --shadow: 0 24px 60px rgba(0, 0, 0, .5);
  --f-display: "Alexandria", "IBM Plex Sans Arabic", sans-serif;
  --f-body: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, monospace;
}
html { color-scheme: dark; scroll-behavior: smooth; }
body {
  font-family: var(--f-body); background: var(--bg); color: var(--text);
  min-height: 100vh; font-size: 14px; -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(1100px 500px at 15% -10%, rgba(217,164,65,.05), transparent 60%),
    radial-gradient(800px 480px at 110% 115%, rgba(79,191,159,.05), transparent 55%);
}
::selection { background: var(--brass-soft); }
a { color: var(--jade); }
button { font-family: inherit; }

/* fine blueprint grid on the login + header bands */
.gridded {
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 44px 44px;
}

/* ─── login ─────────────────────────────────────────── */
.login {
  min-height: 100vh; display: grid; grid-template-columns: 1.15fr .85fr;
}
.login-hero { position: relative; padding: 64px 72px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; border-inline-end: 1px solid var(--line); }
.login-hero .brand { display: flex; align-items: center; gap: 12px; }
.wordmark { font-family: var(--f-display); font-weight: 800; font-size: 22px; letter-spacing: .01em; }
.wordmark small { display: block; font-family: var(--f-body); font-weight: 400; font-size: 11px; color: var(--text-3); letter-spacing: .14em; margin-top: 2px; }
.login-thesis { max-width: 620px; }
.login-thesis h1 { font-family: var(--f-display); font-weight: 800; font-size: clamp(34px, 4.2vw, 52px); line-height: 1.28; }
.login-thesis h1 em { font-style: normal; color: var(--brass); }
.login-thesis p { color: var(--text-2); font-size: 15.5px; line-height: 1.9; margin-top: 18px; max-width: 44ch; }
.rail-stage { margin-top: 30px; }
.login-foot { color: var(--text-3); font-size: 12px; display: flex; gap: 18px; }
.login-foot b { color: var(--text-2); font-weight: 600; }

.login-panel { display: grid; place-items: center; padding: 48px 40px; }
.login-card { width: min(400px, 100%); }
.login-card h2 { font-family: var(--f-display); font-size: 21px; font-weight: 700; margin-bottom: 6px; }
.login-card .sub { color: var(--text-2); font-size: 13px; margin-bottom: 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; color: var(--text); font-size: 14px; font-family: inherit; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 10px; padding: 11px 18px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: transform .15s, border-color .15s, background .15s;
}
.btn:hover { border-color: var(--brass-line); transform: translateY(-1px); }
.btn:focus-visible, .field input:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.btn.primary { background: var(--brass); border-color: var(--brass); color: #1d1608; font-weight: 700; width: 100%; padding: 13px; font-size: 14.5px; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: var(--red-soft); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.login-err { color: var(--red); background: var(--red-soft); border: 1px solid transparent; border-radius: 10px; padding: 10px 13px; font-size: 12.5px; margin-bottom: 14px; display: none; }
.login-err.show { display: block; }

.roles-demo { margin-top: 26px; border-top: 1px dashed var(--line); padding-top: 18px; }
.roles-demo p { font-size: 11.5px; color: var(--text-3); margin-bottom: 10px; }
.role-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.role-chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--text-2);
  font-size: 12px; padding: 7px 12px; border-radius: 99px; cursor: pointer; transition: all .15s;
}
.role-chip:hover { border-color: var(--brass); color: var(--brass); background: var(--brass-soft); }

/* ─── the signature: workflow rail ──────────────────── */
.rail { width: 100%; }
.rail .rl-line { stroke: var(--line); stroke-width: 2; }
.rail .rl-glow { stroke: var(--brass); stroke-width: 2.5; filter: drop-shadow(0 0 6px rgba(217,164,65,.55)); }
.rail .rl-node { fill: var(--panel-2); stroke: var(--line); stroke-width: 2; }
.rail .rl-node.lit { fill: var(--brass); stroke: var(--brass); filter: drop-shadow(0 0 8px rgba(217,164,65,.6)); }
.rail .rl-node.jade { fill: var(--jade); stroke: var(--jade); filter: drop-shadow(0 0 8px rgba(79,191,159,.55)); }
.rail text { fill: var(--text-2); font-size: 11px; font-family: var(--f-body); font-weight: 600; }
.rail text.lit { fill: var(--text); }
.rail text.count { fill: var(--brass); font-family: var(--f-mono); font-weight: 700; font-size: 13px; }

/* ─── app shell ─────────────────────────────────────── */
.shell { display: none; min-height: 100vh; }
.shell.on { display: flex; }
.side {
  width: 216px; min-height: 100vh; position: sticky; top: 0; flex-shrink: 0;
  border-inline-end: 1px solid var(--line); background: var(--bg-2);
  display: flex; flex-direction: column; padding: 22px 14px; gap: 4px; z-index: 10;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.snav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.snav button {
  display: flex; align-items: center; gap: 11px; text-align: start;
  border: 0; background: transparent; color: var(--text-2); border-radius: 10px;
  padding: 10px 12px; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all .15s;
}
.snav button svg { width: 17px; height: 17px; flex-shrink: 0; }
.snav button:hover { color: var(--text); background: var(--line-soft); }
.snav button.active { color: var(--brass); background: var(--brass-soft); font-weight: 700; }
.side-user { border-top: 1px solid var(--line); padding: 14px 8px 2px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--brass-soft); color: var(--brass); display: grid; place-items: center; font-weight: 800; font-family: var(--f-display); font-size: 14px; }
.side-user .nm { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.side-user .rl { font-size: 10.5px; color: var(--text-3); }
.side-user .out { margin-inline-start: auto; background: none; border: 0; color: var(--text-3); cursor: pointer; font-size: 15px; }
.side-user .out:hover { color: var(--red); }

.main { flex: 1; min-width: 0; padding: 30px 38px 70px; max-width: 1360px; }
.pagehead { margin-bottom: 26px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pagehead h1 { font-family: var(--f-display); font-weight: 800; font-size: 26px; letter-spacing: -.01em; }
.pagehead .sub { color: var(--text-2); font-size: 13px; margin-top: 5px; }
.view { display: none; }
.view.active { display: block; }

/* ─── dashboard stage band ──────────────────────────── */
.stageband {
  border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(180deg, var(--panel), var(--bg-2));
  padding: 26px 30px 18px; margin-bottom: 22px; position: relative; overflow: hidden;
}
.stageband h3 { font-size: 12px; color: var(--text-3); font-weight: 700; letter-spacing: .1em; margin-bottom: 16px; }
.statline { display: flex; gap: 34px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.statline .st { display: flex; align-items: baseline; gap: 9px; }
.statline .st b { font-family: var(--f-mono); font-size: 22px; font-weight: 700; color: var(--text); }
.statline .st span { font-size: 12px; color: var(--text-2); }
.statline .st.gold b { color: var(--brass); }
.statline .st.jade b { color: var(--jade); }

.cols { display: grid; gap: 18px; grid-template-columns: 1.5fr 1fr; }
.cols3 { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
@media (max-width: 1080px) { .cols { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; }
.panel > h3 { font-size: 12.5px; font-weight: 700; color: var(--text-2); letter-spacing: .08em; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }
.panel > h3 .hint { font-weight: 500; letter-spacing: 0; color: var(--text-3); font-size: 11.5px; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: start; font-size: 11px; font-weight: 700; color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: rgba(217,164,65,.04); }
.tbl .mono { font-family: var(--f-mono); font-size: 12.5px; }
.tbl .muted { color: var(--text-2); font-size: 12px; }
.clickable { cursor: pointer; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.draft { background: var(--line-soft); color: var(--text-2); }
.badge.submitted { background: var(--violet-soft); color: var(--violet); }
.badge.in_review { background: var(--brass-soft); color: var(--brass); }
.badge.approved { background: var(--jade-soft); color: var(--jade); }
.badge.active { background: var(--jade-soft); color: var(--jade); }
.badge.closed { background: var(--line-soft); color: var(--text-3); }
.badge.review { background: var(--brass-soft); color: var(--brass); }
.badge.ready, .badge.ok { background: var(--jade-soft); color: var(--jade); }

/* masked token seal */
.seal {
  font-family: var(--f-mono); font-size: 12px; font-weight: 600; letter-spacing: .04em;
  border: 1px dashed var(--brass-line); background: var(--brass-soft); color: var(--brass);
  padding: 4px 10px; border-radius: 8px; display: inline-block;
}
.seal.masked { border-color: var(--line); background: var(--line-soft); color: var(--text-3); }

/* buttons row on lifecycle */
.acts { display: flex; gap: 7px; flex-wrap: wrap; }
.acts .btn { padding: 7px 13px; font-size: 12px; border-radius: 8px; }

/* project workspace */
.ws-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; flex-wrap: wrap; }
.ws-tabs button {
  border: 0; background: none; color: var(--text-2); padding: 11px 16px; font-size: 13.5px;
  font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s;
}
.ws-tabs button:hover { color: var(--text); }
.ws-tabs button.active { color: var(--brass); border-color: var(--brass); }
.ws-view { display: none; }
.ws-view.active { display: block; animation: rise .3s cubic-bezier(.2,.9,.3,1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kv .cell { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 14px; }
.kv .cell span { display: block; font-size: 10.5px; color: var(--text-3); font-weight: 700; letter-spacing: .06em; margin-bottom: 5px; }
.kv .cell b { font-size: 15px; font-family: var(--f-mono); }

/* dropzone */
.drop {
  border: 1.5px dashed var(--line); border-radius: 14px; padding: 34px; text-align: center;
  color: var(--text-2); cursor: pointer; transition: all .2s; font-size: 13.5px;
}
.drop:hover, .drop.over { border-color: var(--brass); background: var(--brass-soft); color: var(--brass); }
.drop b { display: block; font-size: 15px; margin-bottom: 6px; color: var(--text); }

/* OCR review grid */
.ocr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 980px) { .ocr-grid { grid-template-columns: 1fr; } }
.conf { font-family: var(--f-mono); font-size: 11px; padding: 2px 8px; border-radius: 6px; }
.conf.hi { color: var(--jade); background: var(--jade-soft); }
.conf.mid { color: var(--brass); background: var(--brass-soft); }
.conf.lo { color: var(--red); background: var(--red-soft); }
.ocr-field { display: grid; grid-template-columns: 110px 1fr 64px; align-items: center; gap: 10px; margin-bottom: 10px; }
.ocr-field label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.ocr-field input { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; color: var(--text); font-size: 13px; }
.ocr-field input:focus { border-color: var(--brass); outline: none; }

/* balance bars */
.bal { margin-bottom: 14px; }
.bal .bh { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; }
.bal .bh b { font-family: var(--f-mono); }
.bal .track { height: 10px; border-radius: 6px; background: var(--line-soft); position: relative; overflow: hidden; }
.bal .track i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 6px; background: linear-gradient(90deg, var(--brass), #b07f24); }
.bal .track .tick { position: absolute; inset-block: -2px; width: 2px; background: var(--jade); }

/* probability strip */
.probs { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.probs .p { font-family: var(--f-mono); font-size: 11.5px; color: var(--text-2); background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: 5px 10px; }
.probs .p b { color: var(--brass); }

/* visits matrix */
.vmx { display: grid; gap: 4px; font-size: 11px; }
.vmx .vrow { display: flex; align-items: center; gap: 4px; }
.vmx .vtok { width: 92px; font-family: var(--f-mono); font-size: 11px; color: var(--text-2); flex-shrink: 0; }
.vmx .vc { width: 26px; height: 18px; border-radius: 4px; background: var(--line-soft); }
.vmx .vc.done { background: var(--jade); opacity: .85; }
.vmx .vc.due { background: var(--red-soft); border: 1px solid var(--red); }
.vmx-legend { display: flex; gap: 14px; font-size: 11px; color: var(--text-2); margin-top: 10px; }
.vmx-legend i { display: inline-block; width: 12px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-inline-end: 4px; }

/* analytics */
.stat-callout { border: 1px solid var(--brass-line); background: var(--brass-soft); border-radius: 14px; padding: 16px 18px; font-size: 13.5px; line-height: 1.8; margin-bottom: 18px; }
.stat-callout b { color: var(--brass); font-family: var(--f-mono); }
.chart-wrap { overflow-x: auto; }
.chart-wrap svg text { font-family: var(--f-body); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }

/* audit feed */
.feed { list-style: none; }
.feed li { display: flex; gap: 13px; padding: 11px 2px; border-bottom: 1px solid var(--line-soft); font-size: 12.8px; }
.feed li:last-child { border-bottom: 0; }
.feed .t { color: var(--text-3); font-family: var(--f-mono); font-size: 11px; white-space: nowrap; padding-top: 2px; }
.feed .a b { color: var(--brass); font-weight: 600; }
.feed .a .muted { color: var(--text-2); }

/* modal-less inline create form */
.create-form { border: 1px solid var(--brass-line); border-radius: 16px; padding: 22px; margin-bottom: 20px; background: var(--panel); display: none; }
.create-form.show { display: block; animation: rise .25s ease; }
.create-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 780px) { .create-form .row { grid-template-columns: 1fr; } }
.arm-rows .arm-row { display: grid; grid-template-columns: 1fr 120px 36px; gap: 10px; margin-bottom: 8px; align-items: center; }

.toast {
  position: fixed; bottom: 26px; inset-inline-start: 26px; z-index: 90;
  background: var(--panel-2); border: 1px solid var(--brass-line); color: var(--text);
  border-radius: 12px; padding: 13px 18px; font-size: 13px; box-shadow: var(--shadow);
  transform: translateY(80px); opacity: 0; transition: all .3s cubic-bezier(.2,.9,.3,1);
}
.toast.show { transform: none; opacity: 1; }
.toast.err { border-color: var(--red); color: var(--red); }

.empty { text-align: center; padding: 42px 20px; color: var(--text-3); font-size: 13px; }
.empty b { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 6px; }

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { padding: 40px 28px; min-height: 46vh; }
  .side { width: 64px; padding: 18px 8px; }
  .side .brand .wordmark, .snav button span, .side-user .nm, .side-user .rl { display: none; }
  .main { padding: 20px 16px 60px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
