/* Hemaya — accreditation portal. Brand: shield gradient orange → deep red. */

:root {
  --orange: #E07B26;
  --orange-lt: #F0973C;
  --red: #B4281B;
  --brand: linear-gradient(135deg, #E8912F 0%, #AF2418 100%);
  --ink: #1B1A18;
  --ink-2: #55504A;
  --ink-3: #8A837A;
  --line: #E4DFD8;
  --bg: #F7F5F2;
  --card: #FFFFFF;
  --ok: #1E7A4C;
  --warn: #B07600;
  --bad: #B4281B;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(27,26,24,.06), 0 8px 24px rgba(27,26,24,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.55 "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 .8em; }

/* ── Top bar ───────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 28px;
  padding: 0 22px; height: 64px;   /* sized to clear the 45px brand mark */
  /* If the navigation ever outgrows the width — a narrow window, a longer set of
     Arabic labels — the bar scrolls rather than the page, so the document never
     drifts sideways. */
  overflow-x: auto; scrollbar-width: none;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar::-webkit-scrollbar { display: none; }
.topbar .brand { display: flex; align-items: center; gap: 10px; color: var(--ink); flex: none; }
.topbar .brand:hover { text-decoration: none; }
.topbar .brand img { width: 45px; height: 45px; object-fit: contain; }
.topbar .brand span { display: flex; flex-direction: column; line-height: 1.15; }
.topbar .brand strong { font-size: 15px; letter-spacing: .02em; }
.topbar .brand small { font-size: 11px; color: var(--ink-3); }
.topbar nav { display: flex; gap: 4px; margin-right: auto; }
.topbar nav a {
  padding: 7px 12px; border-radius: 7px; color: var(--ink-2);
  font-size: 14px; font-weight: 500;
}
.topbar nav a:hover { background: #F2EFEA; color: var(--ink); text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.bell { position: relative; font-size: 14px; color: var(--ink-2); }
.bell i {
  font-style: normal; background: var(--red); color: #fff;
  border-radius: 9px; font-size: 11px; padding: 1px 6px; margin-left: 5px;
}
.who { display: flex; flex-direction: column; line-height: 1.2; color: var(--ink); }
.who small { font-size: 11px; color: var(--ink-3); }
.out { font-size: 13px; color: var(--ink-3); }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.shell { max-width: 1120px; margin: 0 auto; padding: 26px 22px 60px; }
.centered { min-height: 100vh; display: grid; place-items: center; padding: 30px 20px; }
.foot { text-align: center; color: var(--ink-3); font-size: 12px; padding: 0 0 26px; }
body.bare .foot { display: none; }

.page-head { display: flex; align-items: flex-end; gap: 20px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 3px 0 0; color: var(--ink-3); font-size: 13.5px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card > h2:first-child { margin-top: 0; }
.card-tight { padding: 0; overflow: hidden; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.auth { width: 100%; max-width: 380px; }
.auth .mark { text-align: center; margin-bottom: 22px; }
.auth .mark img { width: 304px; }
.auth .mark h1 { font-size: 19px; margin: 12px 0 2px; }
.auth .mark p { color: var(--ink-3); font-size: 13px; margin: 0; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
label .req { color: var(--red); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=url], select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(224,123,38,.14);
}
textarea { min-height: 84px; resize: vertical; }
input[type=file] { font-size: 13px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit; font-size: 14px; font-weight: 550;
  cursor: pointer;
}
.btn:hover { background: #F7F4F0; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: #EBCFCB; }
.btn.danger:hover { background: #FCF3F2; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.wide { width: 100%; justify-content: center; }

/* ── Tables ────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); font-weight: 650; padding: 11px 16px; border-bottom: 1px solid var(--line);
  background: #FBFAF8;
}
td { padding: 12px 16px; border-bottom: 1px solid #F0ECE6; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #FCFAF7; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ref { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; font-size: 13px; }

/* ── Badges & flashes ──────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: #F0ECE6; color: var(--ink-2);
}
.badge.green { background: #E7F4ED; color: var(--ok); }
.badge.amber { background: #FBF1DC; color: var(--warn); }
.badge.blue  { background: #E7EFF8; color: #1B5FA8; }
.badge.red   { background: #FBEBE9; color: var(--bad); }
.badge.grey  { background: #F0ECE6; color: var(--ink-2); }

.flash {
  padding: 11px 16px; border-radius: 8px; margin-bottom: 18px;
  font-size: 14px; border: 1px solid;
}
.flash.ok  { background: #E7F4ED; border-color: #BFE0CE; color: #145F39; }
.flash.err { background: #FBEBE9; border-color: #EBCFCB; color: #8E1F14; }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }

/* ── Workflow rail ─────────────────────────────────────────────────────── */
.rail { display: flex; gap: 0; margin: 0 0 22px; overflow-x: auto; }
.rail .step {
  flex: 1; min-width: 108px; padding: 10px 12px 11px;
  border-top: 3px solid var(--line); font-size: 12px; color: var(--ink-3);
}
.rail .step b { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.rail .step.done { border-top-color: var(--ok); }
.rail .step.done b { color: var(--ink-2); }
.rail .step.here { border-top-color: var(--orange); }
.rail .step.here b { color: var(--red); }

/* ── Document checklist ────────────────────────────────────────────────── */
.doclist { list-style: none; margin: 0; padding: 0; }
.doclist li {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border-bottom: 1px solid #F0ECE6;
}
.doclist li:last-child { border-bottom: 0; }
.doclist .name { flex: 1; min-width: 0; }
.doclist .name b { display: block; font-weight: 600; font-size: 14px; }
.doclist .name .ar {
  display: block; direction: rtl; text-align: right; font-size: 13px;
  color: var(--ink-3); margin-top: 2px;
}
.doclist .name .meta { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.doclist li.locked { opacity: .45; }
.doclist li.reviewed { background: #FAFDFB; }
.doclist .stat { min-width: 108px; text-align: right; }

/* ── Stat tiles ────────────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 17px;
}
.tile .n { display: block; font-size: 27px; font-weight: 660; letter-spacing: -.02em; line-height: 1.1; }
.tile .k { display: block; font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.tile.accent { background: var(--brand); border-color: transparent; color: #fff; }
.tile.accent .k { color: rgba(255,255,255,.85); }
/* Most tiles are links onto the files they count. */
a.tile { display: block; color: var(--ink); }
a.tile:hover { text-decoration: none; border-color: var(--orange); }
a.tile.accent { color: #fff; }
a.tile.accent:hover { border-color: rgba(255,255,255,.5); }

dl.kv { display: grid; grid-template-columns: 190px 1fr; gap: 9px 18px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--ink-3); font-size: 13px; }
dl.kv dd { margin: 0; }

@media (max-width: 760px) {
  .topbar { gap: 14px; padding: 0 14px; overflow-x: auto; }
  .topbar nav { gap: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dd { margin-bottom: 9px; }
}

/* Repeating grids on the data entry page (product lists, consultant details). */
table.grid { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.grid th { padding: 8px 10px; font-size: 11px; }
table.grid td { padding: 5px 6px; }
table.grid input { padding: 6px 8px; font-size: 13px; }

/* Stage boxes on the lab director's dashboard — each opens that stage's caseload. */
.stages {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.stage {
  display: flex; flex-direction: column; gap: 3px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; color: var(--ink); opacity: .55;
}
.stage.has { opacity: 1; border-color: #D8D0C5; }
.stage:hover { text-decoration: none; border-color: var(--orange); }
.stage .n {
  font-size: 26px; font-weight: 660; line-height: 1.05; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stage.has .n { color: var(--red); }
.stage .l { font-size: 13px; font-weight: 600; line-height: 1.35; }
.stage .r { font-size: 11.5px; color: var(--ink-3); }

/* A submit button that has to read as a quiet link inside a line of text. */
button.linkish {
  background: none; border: 0; padding: 0; margin-inline-start: 10px;
  font: inherit; font-size: 12.5px; color: var(--red); cursor: pointer; text-decoration: underline;
}
button.linkish:hover { opacity: .78; }

/* ── Language toggle ───────────────────────────────────────────────────── */
.lang {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 26px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 12.5px; font-weight: 650; color: var(--ink-2);
}
.lang:hover { background: #F2EFEA; color: var(--ink); text-decoration: none; }

/* ── Arabic: mirror the handful of rules that carry a direction ─────────── */
[dir="rtl"] .topbar nav { margin-right: 0; margin-left: auto; }
[dir="rtl"] .page-actions { margin-left: 0; margin-right: auto; }
[dir="rtl"] th { text-align: right; }
[dir="rtl"] td.num, [dir="rtl"] th.num { text-align: left; }
[dir="rtl"] .bell i { margin-left: 0; margin-right: 5px; }
[dir="rtl"] .doclist .stat { text-align: left; }
[dir="rtl"] .doclist .name .ar { text-align: right; }
[dir="rtl"] li.blocks { border-left: 0; border-right: 3px solid var(--flag); }
[dir="rtl"] .head .ref { text-align: right; direction: rtl; }

/* Latin fragments inside Arabic text — reference codes, emails, filenames —
   keep their own direction so they don't reorder. */
[dir="rtl"] .ref, [dir="rtl"] code { direction: ltr; unicode-bidi: embed; display: inline-block; }

/* Arabic reads better with slightly more line height and a face that has it. */
[dir="rtl"] body {
  font-family: "Segoe UI", "Dubai", "Tahoma", system-ui, sans-serif;
  line-height: 1.7;
}
[dir="rtl"] th { letter-spacing: 0; text-transform: none; font-size: 12.5px; }
