/* Tender evaluation — UI styles. Arabic-first (RTL), works LTR too. */
:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #ecf0ee;
  --ink: #15201d;
  --ink-2: #51615c;
  --ink-3: #7b8a85;
  --line: #d8dfdc;
  --accent: #0b6e5a;
  --accent-hover: #095c4b;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe8;
  --gold: #a07a1c;
  --good: #1d7a3b;
  --good-soft: #e0f1e5;
  --warn: #945700;
  --warn-soft: #fbeed6;
  --bad: #b3261e;
  --bad-soft: #fbe2df;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 40, 35, .06), 0 2px 8px rgba(20, 40, 35, .05);
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513; --surface: #151f1c; --surface-2: #1b2724; --ink: #e3ebe8; --ink-2: #a2b3ad; --ink-3: #74867f;
    --line: #2a3834; --accent: #3db497; --accent-hover: #52c5a9; --accent-ink: #04211a; --accent-soft: #15342c;
    --gold: #d6b25a; --good: #5cc27b; --good-soft: #163222; --warn: #e2a640; --warn-soft: #34270f; --bad: #f07268; --bad-soft: #3a1917;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14.5px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5rem; text-wrap: balance; }
h1 { font-size: 1.45rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--ink-2); }
.num, td.num, th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
/* Keep "4.30 / 5" style figures left-to-right inside Arabic text */
.num, .sec-pts, .crit-pts, .big-score, [data-run-count] { direction: ltr; unicode-bidi: isolate; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-in { max-width: 1320px; margin: 0 auto; padding: .55rem 16px; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand small { display: block; font-weight: 400; font-size: .75rem; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; margin-inline-start: auto; align-items: center; }
.nav a, .nav button.linklike { color: var(--ink-2); padding: .35rem .6rem; border-radius: 6px; font-size: .92rem; }
.nav a:hover, .nav a.on { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav form { display: inline; margin: 0; }
.who { font-size: .85rem; color: var(--ink-2); padding-inline: .4rem; }
.role-tag { font-size: .7rem; border: 1px solid var(--line); border-radius: 99px; padding: 0 .45rem; margin-inline-start: .3rem; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .sub { color: var(--ink-2); font-size: .9rem; }

/* Cards and grid */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Definition list for project info */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: .15rem 1.25rem; margin: 0; }
.facts div { padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.facts dt { font-size: .78rem; color: var(--ink-3); letter-spacing: .02em; }
.facts dd { margin: 0; font-weight: 500; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: .45rem .9rem; border-radius: 7px; font: inherit; font-size: .92rem; cursor: pointer; line-height: 1.3; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { padding: .25rem .6rem; font-size: .82rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }

/* Forms */
label { display: block; font-size: .85rem; color: var(--ink-2); margin-bottom: .25rem; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 7px; padding: .5rem .65rem; font: inherit; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { margin-bottom: .85rem; }
.field .hint { font-size: .78rem; color: var(--ink-3); margin-top: .2rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 0 1rem; }
.check { display: flex; gap: .5rem; align-items: flex-start; color: var(--ink); font-size: .9rem; }
.check input { margin-top: .3rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 1rem; }
legend { padding: 0 .4rem; font-weight: 600; }

/* Alerts */
.alert { border-radius: 7px; padding: .65rem .9rem; margin-bottom: 1rem; border: 1px solid; }
.alert-ok { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 35%, transparent); color: var(--good); }
.alert-err { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad); }
.alert-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.alert ul { margin: 0; padding-inline-start: 1.1rem; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 600; padding: .1rem .55rem; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .7rem; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; color: var(--ink-2); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
th.num { font-family: var(--font); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
td.num, th.num { text-align: right; }
[dir=rtl] td.num, [dir=rtl] th.num { text-align: left; }
tr.total td { font-weight: 700; background: var(--surface-2); }
tr.group-row td { background: var(--accent-soft); font-weight: 600; }

/* Project stepper + tabs */
.stepper { display: flex; gap: 0; margin: .25rem 0 1rem; flex-wrap: wrap; counter-reset: step; }
.step { flex: 1 1 150px; position: relative; padding: .5rem .75rem; border-bottom: 3px solid var(--line); color: var(--ink-3); font-size: .85rem; }
.step b { display: block; color: inherit; font-size: .92rem; }
.step.done { border-color: var(--accent); color: var(--ink-2); }
.step.current { border-color: var(--gold); color: var(--ink); }
.tabs { display: flex; gap: .15rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* Drop zone */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.1rem; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { display: block; }
.drop input[type=file] { display: none; }
.upload-list { list-style: none; margin: .6rem 0 0; padding: 0; font-size: .85rem; }
.upload-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .2rem 0; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }

/* Documents list */
.docs { list-style: none; margin: 0; padding: 0; }
.docs li { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.docs li:last-child { border-bottom: 0; }
.docs .name { font-weight: 500; flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.docs .meta { font-size: .78rem; color: var(--ink-3); }
.docs form { margin: 0; }

/* Run progress */
.run { border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--accent-soft); border-radius: var(--radius); padding: .8rem 1rem; }
.run .row { justify-content: space-between; }
.run .msg { font-size: .85rem; color: var(--ink-2); overflow-wrap: anywhere; }
.run.failed { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--accent); border-top-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .bar > span { transition: none; } }

/* Score summary */
.score-hero { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.big-score { font-family: var(--mono); font-size: 2.4rem; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.big-score small { font-size: 1rem; color: var(--ink-3); }
.meter { position: relative; height: 10px; background: var(--surface-2); border-radius: 99px; min-width: 180px; flex: 1; }
.meter > span { position: absolute; inset-block: 0; inset-inline-start: 0; background: var(--accent); border-radius: 99px; }
.meter > i { position: absolute; inset-block: -4px; width: 2px; background: var(--gold); }
.summary-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 1rem; }
.summary-lists ul { margin: .25rem 0 0; padding-inline-start: 1.1rem; }
.summary-lists h4 { margin: 0; font-size: .85rem; }

/* Scorecard */
.sec { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: .75rem; overflow: hidden; }
.sec-head { display: grid; grid-template-columns: auto 1fr auto auto; gap: .75rem; align-items: center; padding: .65rem .9rem; background: var(--surface-2); cursor: pointer; border: 0; width: 100%; text-align: start; font: inherit; color: var(--ink); }
.sec-no { font-family: var(--mono); background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 0 .45rem; font-size: .85rem; }
.sec-name { font-weight: 600; }
.sec-pts { font-family: var(--mono); font-size: .9rem; white-space: nowrap; }
.crit { border-top: 1px solid var(--line); }
.crit-main { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) auto 5.5rem; gap: .75rem; align-items: center; padding: .6rem .9rem; }
.crit-code { font-family: var(--mono); color: var(--ink-3); font-size: .85rem; }
.crit-name { background: none; border: 0; padding: 0; text-align: start; font: inherit; color: var(--ink); cursor: pointer; }
.crit-name small { display: block; }
.crit-pts { font-family: var(--mono); text-align: end; font-weight: 600; white-space: nowrap; }
.crit-pts small { color: var(--ink-3); font-weight: 400; }
.scale { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.scale button { width: 2rem; height: 2rem; border: 0; border-inline-start: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: 600 .85rem var(--mono); cursor: pointer; position: relative; }
.scale button:first-child { border-inline-start: 0; }
.scale button:hover:not([disabled]) { background: var(--surface-2); }
.scale button.on { background: var(--accent); color: var(--accent-ink); }
.scale button.ai::after { content: ""; position: absolute; bottom: 3px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--gold); }
.scale button[disabled] { cursor: default; }
.scale.override button.on { background: var(--surface-2); color: var(--ink-2); }
.crit-more { padding: 0 .9rem .9rem calc(3.2rem + 1.65rem); font-size: .88rem; }
[dir=rtl] .crit-more { padding: 0 calc(3.2rem + 1.65rem) .9rem .9rem; }
.crit-more .kv { display: grid; grid-template-columns: 7rem 1fr; gap: .3rem .75rem; margin-bottom: .6rem; }
.crit-more .kv dt { color: var(--ink-3); }
.crit-more .kv dd { margin: 0; }
.evidence { background: var(--surface-2); border-radius: 6px; padding: .5rem .7rem; font-size: .82rem; margin-bottom: .6rem; }
.evidence p { margin: 0 0 .35rem; }
.evidence p:last-child { margin: 0; }
.adjust { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; }
.adjust input[type=number] { width: 7rem; }
.adjust textarea { min-height: 42px; flex: 1 1 260px; }
.tag-adjusted { font-size: .7rem; color: var(--gold); font-weight: 600; margin-inline-start: .35rem; }

/* Ranking list */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: grid; grid-template-columns: 2rem 1fr auto; gap: .75rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.rank-list li:last-child { border-bottom: 0; }
.rank-no { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font: 600 .9rem var(--mono); }
.rank-list li:first-child .rank-no { background: var(--gold); color: #fff; }

/* Criteria editor */
.cg { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .75rem; background: var(--surface); }
.cg-head { display: grid; grid-template-columns: 4.5rem 1fr 1fr auto auto; gap: .5rem; padding: .6rem; background: var(--surface-2); align-items: center; border-radius: var(--radius) var(--radius) 0 0; }
.ci { display: grid; grid-template-columns: 4.5rem 1fr 1fr 5.5rem auto; gap: .5rem; padding: .5rem .6rem; border-top: 1px solid var(--line); align-items: start; }
.ci textarea { min-height: 38px; font-size: .82rem; }
.ci > .btn, .cg-head > .btn { justify-self: end; align-self: start; }
.ci .guid { grid-column: 2 / 4; }
.weight-total { position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; box-shadow: var(--shadow); }
.weight-total .num { font-size: 1.3rem; font-weight: 700; }
.weight-total.bad .num { color: var(--bad); }
.weight-total.ok .num { color: var(--good); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(100%, 400px); padding: 1.75rem; }

/* Dialog */
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 1.25rem; max-width: min(92vw, 480px); }
dialog::backdrop { background: rgba(10, 20, 18, .45); }

.pagination { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: 1rem; }
.pagination a, .pagination span { padding: .3rem .65rem; border: 1px solid var(--line); border-radius: 6px; font-size: .85rem; }
.pagination .active span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.empty { text-align: center; color: var(--ink-2); padding: 2rem 1rem; }
.empty h3 { color: var(--ink); }

@media (max-width: 720px) {
  .crit-main { grid-template-columns: 2.6rem minmax(0, 1fr) 5.2rem; }
  .crit-main .scale { grid-column: 2 / 4; grid-row: 2; justify-self: start; }
  .crit-more, [dir=rtl] .crit-more { padding: 0 .9rem .9rem; }
  .cg-head, .ci { grid-template-columns: 1fr 1fr; }
  .ci .guid { grid-column: 1 / -1; }
  .sec-head { grid-template-columns: auto 1fr auto; }
  .sec-head .sec-w { display: none; }
}
