/* stc project tracking and governance portal */
:root {
  --purple: #4f008c;
  --purple-deep: #2b004f;
  --purple-mid: #7a3db8;
  --lav: #c9aeea;
  --tint: #f4eefb;
  --tint-2: #e7dcf4;
  --coral: #ff375e;
  --green: #128c5f;
  --amber: #c77b00;
  /* fills that carry white text: 4.5:1 or better (coral 5.2, amber 5.4) */
  --coral-strong: #d6123f;
  --amber-strong: #9a5b00;
  /* the plan bar: 3:1 against white and against the purple delivered bar */
  --plan: #a47fd6;
  --ink: #16121d;
  --muted: #6b6478;
  --line: #e4dcef;
  --surface: #f8f6fb;
  --paper: #ffffff;
  --rail: 232px;
  --radius: 10px;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --sans-ar: "IBM Plex Sans Arabic", "Segoe UI", "Noto Sans Arabic", Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

body[dir="rtl"] { font-family: var(--sans-ar); }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 0.98rem; }
p { margin: 0 0 0.6rem; }
a { color: var(--purple); }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.right { text-align: end; }
.nowrap { white-space: nowrap; }
/* minmax(0, 1fr) lets a wide child (a table) scroll inside its card instead of
   pushing the column wider than its grid track and under the next column */
.stack { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }

/* ----------------------------------------------------------------- sign in */
.signin {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--paper);
}
.signin-brand {
  background: linear-gradient(150deg, #5e12a8 0%, #4f008c 55%, #2b004f 100%);
  color: #fff;
  padding: 56px 56px 40px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.signin-brand .orb { position: absolute; border-radius: 50%; }
.signin-brand .orb-1 { width: 460px; height: 460px; background: rgba(255,255,255,.1); inset-block-start: 90px; inset-inline-end: -140px; }
.signin-brand .orb-2 { width: 200px; height: 200px; background: rgba(255,255,255,.14); inset-block-end: 60px; inset-inline-end: 120px; }
.signin-brand .orb-3 { width: 84px; height: 84px; background: var(--coral); inset-block-end: 190px; inset-inline-end: 60px; }
.signin-brand h1 { font-size: 2.2rem; line-height: 1.15; max-width: 12ch; position: relative; }
.signin-brand p { max-width: 42ch; color: rgba(255,255,255,.86); position: relative; }
.wordmark { font-size: 1.6rem; font-weight: 700; position: relative; }
.signin-form { padding: 56px; display: flex; flex-direction: column; justify-content: center; max-width: 520px; }
.credit { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 0.8rem; color: var(--muted); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 0.85rem; color: var(--muted); }
input, select, textarea {
  font-family: inherit; font-size: 0.95rem; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink);
}
.demo-user {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  width: 100%; text-align: start; padding: 10px 12px; margin-bottom: 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
}
.demo-user:hover { border-color: var(--purple); background: var(--tint); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--tint-2); color: var(--purple);
  display: grid; place-items: center; font-weight: 650; font-size: 0.8rem;
}

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail {
  background: var(--purple-deep); color: #fff; padding: 18px 14px;
  display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh;
}
.rail .wordmark { padding: 4px 10px 18px; }
.rail button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: start;
  padding: 9px 12px; border: 0; border-radius: 8px; background: transparent;
  color: rgba(255,255,255,.8); font-size: 0.92rem;
}
.rail button:hover { background: rgba(255,255,255,.09); color: #fff; }
.rail button[aria-current="page"] { background: rgba(255,255,255,.15); color: #fff; font-weight: 600; }
.rail .badge { margin-inline-start: auto; background: var(--coral-strong); color: #fff;
  border-radius: 999px; padding: 0 7px; font-size: 0.8rem; font-weight: 700; }
.rail-foot { margin-top: auto; font-size: 0.8rem; color: rgba(255,255,255,.6); padding: 10px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--paper); border-bottom: 1px solid var(--line);
  padding: 12px 24px; display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 5;
}
.topbar .who { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px;
  font-size: 0.8rem; background: var(--paper); color: var(--ink); white-space: nowrap;
}
.chip-purple { background: var(--tint); border-color: var(--tint-2); color: var(--purple); font-weight: 600; }
.content { padding: 22px 24px 60px; max-width: 1440px; width: 100%; }

/* ------------------------------------------------------------------ cards */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
/* a card that stretches to its row's height and centres its body */
.card-center { display: flex; flex-direction: column; }
.card-center > :last-child { flex: 1; }
.donut-row { gap: 16px 20px; justify-content: center; align-content: center; }

/* document upload on the project Documents tab */
.upload-card { margin-bottom: 14px; }
/* six tracks: file, type, version on the first row, the two titles on the second */
.upload-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0 12px; }
.upload-grid .span-2 { grid-column: span 2; }
.upload-grid .span-3 { grid-column: span 3; }
.upload-grid input, .upload-grid select { width: 100%; min-width: 0; }
@media (max-width: 820px) {
  .upload-grid { grid-template-columns: minmax(0, 1fr); }
  .upload-grid > * { grid-column: auto; }
}
.grid { display: grid; gap: 14px; }
/* minmax(0, 1fr), not 1fr: a wide table scrolls inside its card instead of widening the page */
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr); }
.grid-detail { grid-template-columns: minmax(0, 1fr) 320px; }

/* KPI strip: one bordered band divided by rules, not separate floating cards */
.kpis {
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.kpi { padding: 14px 16px; border-inline-start: 1px solid var(--line); }
.kpi:first-child { border-inline-start: 0; }
.kpi .value { font-size: 1.7rem; font-weight: 700; color: var(--purple); line-height: 1.15; }
.kpi .value.alert { color: var(--coral); }
.kpi .label { font-size: 0.8rem; color: var(--muted); }
.kpi .sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

/* ------------------------------------------------------------- status dots */
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.on_track, .dot.low { background: var(--green); }
.dot.at_risk, .dot.medium { background: var(--amber); }
.dot.off_track, .dot.critical { background: var(--coral); }
.dot.high { background: var(--purple-mid); }

.pill { border-radius: 999px; padding: 2px 9px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.pill.critical { background: var(--coral-strong); color: #fff; }
.pill.high { background: var(--purple-mid); color: #fff; }
.pill.medium { background: #fdf0d6; color: #8a5600; }
.pill.low { background: #e6f3ec; color: #0d6444; }
.pill.on_track { background: #e6f3ec; color: #0d6444; }
.pill.at_risk { background: #fdf0d6; color: #8a5600; }
.pill.off_track { background: #ffe4ea; color: #b3092f; }
.pill.pending { background: var(--tint-2); color: var(--purple); }
.pill.approved { background: #e6f3ec; color: #0d6444; }
.pill.approved_with_conditions { background: #fdf0d6; color: #8a5600; }
.pill.held { background: #ffe4ea; color: #b3092f; }
.pill.ghost { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 720px; }
.table-wrap td:nth-child(2) { min-width: 130px; }
th, td { padding: 9px 10px; text-align: start; font-size: 0.88rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: 0.8rem; background: var(--surface); position: sticky; top: 0; }
tbody tr:hover { background: var(--tint); }
tr.clickable { cursor: pointer; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }

.bar { height: 7px; background: var(--tint-2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--purple); }
.bar.warn > span { background: var(--amber); }
.bar.bad > span { background: var(--coral); }

/* ------------------------------------------------------------- escalation */
.ladder { display: grid; gap: 8px; }
.rung { display: grid; grid-template-columns: 92px 1fr; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.rung .who { font-size: 0.8rem; color: var(--muted); }

.feed-item { display: grid; gap: 3px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-item .meta { display: flex; gap: 8px; align-items: center; font-size: 0.8rem; color: var(--muted); }

.insight { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.insight:last-child { border-bottom: 0; }

/* -------------------------------------------------------------- timeline */
.gantt { width: 100%; overflow-x: auto; }
.gantt svg { display: block; min-width: 640px; }

/* --------------------------------------------------------------- buttons */
.btn {
  border: 1px solid var(--purple); background: var(--purple); color: #fff;
  border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 0.88rem;
}
.btn:hover { background: #3f0070; }
.btn.ghost { background: transparent; color: var(--purple); }
.btn.ghost:hover { background: var(--tint); }
.btn.quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.quiet:hover { background: var(--surface); }
.btn.danger { background: var(--coral-strong); border-color: var(--coral-strong); }
.btn.danger:hover { background: #b80f36; }
.btn.warn { background: var(--amber-strong); border-color: var(--amber-strong); }
.btn.warn:hover { background: #7f4b00; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

.checklist { display: grid; gap: 6px; margin: 8px 0; }
.checklist div { display: flex; gap: 8px; align-items: center; font-size: 0.86rem; }
.tick { width: 18px; height: 18px; border-radius: 4px; display: grid; place-items: center;
  font-size: 0.8rem; color: #fff; flex: none; }
.tick.yes { background: #0d6444; }   /* white on this green is 7:1; the lighter --green is 4.25 */
.tick.no { background: var(--coral-strong); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 9px 13px; color: var(--muted);
  border-bottom: 2px solid transparent; font-size: 0.9rem; }
.tabs button[aria-selected="true"] { color: var(--purple); border-bottom-color: var(--purple); font-weight: 600; }

/* ------------------------------------------------------------- assistant */
.assistant {
  position: fixed; inset-block: 0; inset-inline-end: 0; width: min(430px, 100%);
  background: var(--paper); border-inline-start: 1px solid var(--line);
  box-shadow: -8px 0 30px rgba(43,0,79,.12); display: flex; flex-direction: column; z-index: 20;
  transform: translateX(var(--slide, 100%));
  transition: transform .18s ease-out;
}
body[dir="rtl"] .assistant { --slide: -100%; box-shadow: 8px 0 30px rgba(43,0,79,.12); }
.assistant.open { transform: translateX(0); }
.assistant header { padding: 14px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; }
.assistant .log { flex: 1; overflow-y: auto; padding: 14px 16px; display: grid; gap: 12px; align-content: start; }
.assistant footer { padding: 12px 16px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.msg { border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; white-space: pre-wrap; }
.msg.me { background: var(--purple); color: #fff; justify-self: end; max-width: 86%; }
.msg.bot { background: var(--surface); border: 1px solid var(--line); }
.msg .source { margin-top: 8px; font-size: 0.8rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.suggest { display: flex; gap: 6px; flex-wrap: wrap; }
.suggest button { border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 6px 12px; font-size: 0.8rem; color: var(--purple); }
.suggest button:hover { background: var(--tint); }
.ask-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.fab {
  position: fixed; inset-block-end: 22px; inset-inline-end: 22px; z-index: 15;
  border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 650;
  background: var(--purple); color: #fff; box-shadow: 0 6px 18px rgba(79,0,140,.32);
}
.fab:hover { background: #3f0070; }

.toast {
  position: fixed; inset-block-end: 22px; inset-inline-start: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 40; font-size: 0.88rem;
}

.empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; }
.spinner { width: 15px; height: 15px; border: 2px solid var(--tint-2); border-top-color: var(--purple);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-width: 1100px) {
  .grid-main, .grid-detail, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-top: 1px solid var(--line); }
  .kpi:nth-child(-n+2) { border-top: 0; }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; border-inline-start: 0; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; overflow-x: auto; }
  .rail .wordmark, .rail-foot { display: none; }
  .signin { grid-template-columns: 1fr; }
  .signin-brand { padding: 32px; }
  .signin-form { padding: 28px; }
  .content { padding: 16px; }
  /* menu wraps instead of hiding items off the edge; badges stay beside their labels */
  .rail { flex-wrap: wrap; }
  .rail button { width: auto; white-space: nowrap; }
  .rail .badge { margin-inline-start: 6px; }
  .topbar { flex-wrap: wrap; row-gap: 8px; padding: 10px 16px; }
  .topbar .who { flex-wrap: wrap; }
  /* 16px stops iOS zooming into a field on focus */
  input, select, textarea { font-size: 16px; }
}

/* progress against plan */
.progress-list { display: grid; gap: 2px; }
.progress-row {
  display: grid; grid-template-columns: minmax(120px, 190px) 1fr 62px; gap: 12px; align-items: center;
  background: transparent; border: 0; border-radius: 6px; padding: 7px 6px; text-align: start; width: 100%;
}
.progress-row:hover { background: var(--tint); }
.progress-name { font-size: 0.85rem; color: var(--ink); }
.progress-track { position: relative; height: 18px; }
.progress-track > span { position: absolute; inset-inline-start: 0; height: 7px; border-radius: 4px; }
.track-plan { top: 1px; background: var(--plan); }
.track-actual { top: 10px; background: var(--purple); }
.track-actual.warn { background: var(--amber); }
.track-actual.bad { background: var(--coral); }
.progress-figs { font-size: 0.8rem; color: var(--muted); text-align: end; font-variant-numeric: tabular-nums; }
.legend { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.legend .key { display: inline-block; width: 16px; height: 6px; border-radius: 3px; }
.legend .key-plan { background: var(--plan); }
.legend .key-actual { background: var(--purple); margin-inline-start: 8px; }
.progress-figs { white-space: nowrap; }
/* phones: project name and figures on one line, the bars full width below.
   Kept after the base progress rules so it wins at equal specificity. */
@media (max-width: 820px) {
  .progress-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name figs" "track track"; row-gap: 4px; }
  .progress-name { grid-area: name; }
  .progress-track { grid-area: track; }
  .progress-figs { grid-area: figs; }
}

/* ---------------------------------------------------------- accessibility */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; inset-inline-start: 12px; top: -60px; z-index: 50;
  background: var(--purple); color: #fff; padding: 10px 14px; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 12px; }
.content:focus { outline: none; }
/* keep the focused control clear of the sticky top bar */
html { scroll-padding-top: 72px; }
.row-link { color: inherit; text-decoration: none; display: inline-block; min-height: 24px; padding-block: 3px; }
.row-link:hover, .row-link:focus-visible { text-decoration: underline; }
.form-error { color: var(--coral-strong); font-size: 0.85rem; font-weight: 600; margin: -6px 0 12px; }
/* a closed assistant is also hidden once it has slid away */
.assistant:not(.open) { visibility: hidden; transition: transform .18s ease-out, visibility 0s linear .18s; }

/* touch screens: comfortable 44px targets */
@media (pointer: coarse) {
  .btn, button.chip, .tabs button, .rail button, .suggest button, .demo-user, input, select {
    min-height: 44px;
  }
  .btn, button.chip { display: inline-flex; align-items: center; justify-content: center; }
}
