/* Geospatial Management Academy — executive learning workspace
   Palette: deep navy, white, restrained teal. Type: IBM Plex Sans + IBM Plex Sans Arabic. */
:root {
  --navy-900: #0C1C36;
  --navy-800: #13294B;
  --navy-700: #1F3A63;
  --navy-100: #E6ECF4;
  --paper: #FFFFFF;
  --mist: #F4F6F9;
  --line: #D8DFE8;
  --line-strong: #B9C4D2;
  --ink: #17212F;
  --ink-2: #4A5869;
  --teal: #0E7C7B;
  --teal-strong: #0A6261;
  --teal-soft: #E2F1F0;
  --teal-on-navy: #5CC8C2;
  --danger: #B42318; --danger-soft: #FDECEA;
  --warn: #8A5A00; --warn-soft: #FDF4E1;
  --ok: #1D7349; --ok-soft: #E5F3EB;
  --radius-s: 4px; --radius-m: 8px;
  --font: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --measure: 70ch;
  --focus: 0 0 0 3px rgba(14,124,123,.45);
}
html[lang="ar"] { --font: 'IBM Plex Sans Arabic', 'IBM Plex Sans', system-ui, Tahoma, sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.6; color: var(--ink); background: var(--mist); }
html[lang="ar"] body { line-height: 1.75; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; color: var(--navy-900); font-weight: 600; }
h1 { font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--teal-strong); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-s); }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; background: var(--paper); padding: 8px 12px; z-index: 100; }
.skip:focus { top: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar { background: var(--navy-800); color: #fff; }
.topbar-in { max-width: 1320px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; letter-spacing: .01em; }
.brand svg { flex: none; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.nav a { color: #C9D5E5; text-decoration: none; padding: 8px 10px; border-radius: var(--radius-s); font-size: .92rem; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav a[aria-current="page"] { color: #fff; box-shadow: inset 0 -2px 0 var(--teal-on-navy); border-radius: 0; }
.topbar-tools { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.topbar-tools .who { font-size: .88rem; color: #C9D5E5; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-ghost-light { background: transparent; border: 1px solid rgba(255,255,255,.28); color: #fff; padding: 5px 10px; border-radius: var(--radius-s); cursor: pointer; font-size: .88rem; }
.btn-ghost-light:hover { border-color: rgba(255,255,255,.6); }
.btn-ghost-light { white-space: nowrap; }
@media (max-width: 640px) {
  .topbar-in { gap: 8px 16px; padding: 8px 16px; }
  .topbar-tools { width: 100%; justify-content: flex-end; }
  .topbar-tools .who { display: none; }
  .btn-ghost-light { padding: 4px 8px; font-size: .8rem; }
  main { padding: 20px 16px 48px; }
  h1 { font-size: 1.45rem; }
  .directive q { font-size: 1.15rem; }
}

main { max-width: 1320px; margin: 0 auto; padding: 28px 20px 56px; }
.footer { max-width: 1320px; margin: 0 auto; padding: 18px 20px 28px; color: var(--ink-2); font-size: .82rem; border-top: 1px solid var(--line); }

/* ---------- Buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: var(--radius-s); padding: 9px 16px; cursor: pointer; font-weight: 500; text-decoration: none; line-height: 1.3; min-height: 40px; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-strong); }
.btn-navy { background: var(--navy-800); color: #fff; }
.btn-navy:hover { background: var(--navy-900); }
.btn-secondary { background: var(--paper); border-color: var(--line-strong); color: var(--navy-800); }
.btn-secondary:hover { border-color: var(--navy-700); }
.btn-danger { background: var(--paper); border-color: #E3A39C; color: var(--danger); }
.btn-link { background: none; border: 0; color: var(--teal-strong); padding: 4px 2px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; min-height: 0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-lg { padding: 12px 22px; font-size: 1.02rem; min-height: 48px; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .88rem; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: .9rem; font-weight: 500; color: var(--navy-800); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 9px 11px; background: var(--paper); }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.55; }
.input:focus { border-color: var(--teal); box-shadow: var(--focus); outline: none; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Surfaces ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 22px; }
.panel + .panel, .stack > * + * { margin-top: 18px; }
.panel-flat { background: transparent; border: 0; padding: 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title h2, .section-title h3 { margin: 0; }

.notice { border-radius: var(--radius-s); padding: 12px 14px; border-inline-start: 4px solid; font-size: .95rem; }
.notice p:last-child { margin: 0; }
.notice-error { background: var(--danger-soft); border-color: var(--danger); color: #6F1A12; }
.notice-warn { background: var(--warn-soft); border-color: #C58A12; color: #5A3B00; }
.notice-ok { background: var(--ok-soft); border-color: var(--ok); color: #124A2F; }
.notice-info { background: var(--navy-100); border-color: var(--navy-700); color: var(--navy-900); }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 500; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--paper); white-space: nowrap; }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip-not_started { color: #6A7787; }
.chip-in_progress { color: #8A5A00; border-color: #E8CF94; background: var(--warn-soft); }
.chip-evaluated { color: var(--navy-700); border-color: #AFC2DD; background: var(--navy-100); }
.chip-completed { color: var(--ok); border-color: #A9D3BC; background: var(--ok-soft); }
.chip-failed { color: var(--danger); border-color: #EBB4AD; background: var(--danger-soft); }
.chip-pending { color: var(--teal-strong); border-color: #A5D3D1; background: var(--teal-soft); }
.chip-plain::before { display: none; }
.badge-derived { font-size: .74rem; padding: 1px 7px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); border: 1px solid #E8CF94; margin-inline-start: 6px; font-weight: 500; }

/* ---------- Login ---------- */
.login-wrap { min-height: calc(100vh - 140px); display: grid; place-items: center; padding: 24px 0; }
.login { width: min(440px, 100%); }
.login .mark { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login .mark strong { font-size: 1.2rem; color: var(--navy-900); }
.login-intro { color: var(--ink-2); margin-bottom: 20px; }

/* ---------- Dashboard ---------- */
.dash-head { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end; margin-bottom: 22px; }
@media (max-width: 700px) { .dash-head { grid-template-columns: 1fr; } }
.progress-line { height: 8px; background: var(--navy-100); border-radius: 999px; overflow: hidden; }
.progress-line > i { display: block; height: 100%; background: var(--teal); }
.metric { padding: 18px 20px; }
.metric .label { font-size: .88rem; color: var(--ink-2); }
.metric .value { font-size: 2rem; font-weight: 600; color: var(--navy-900); line-height: 1.2; margin-top: 4px; }
.metric .value.empty { font-size: 1rem; font-weight: 400; color: var(--ink-2); padding-top: 10px; }

.case-list { list-style: none; margin: 0; padding: 0; }
.case-list li { border-top: 1px solid var(--line); }
.case-list li:first-child { border-top: 0; }
.case-link { display: grid; grid-template-columns: 3.2rem 1fr auto; gap: 14px; align-items: center; padding: 13px 4px; text-decoration: none; color: inherit; }
.case-link:hover .case-title { color: var(--teal-strong); }
.case-no { font-weight: 600; color: var(--navy-700); font-variant-numeric: tabular-nums; }
.case-title { font-weight: 500; color: var(--navy-900); }
.case-sub { font-size: .86rem; color: var(--ink-2); }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(9rem, 14rem) 1fr 3.5rem; gap: 12px; align-items: center; font-size: .92rem; }
.bar { height: 10px; background: var(--navy-100); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--navy-700); }
.bar.teal > i { background: var(--teal); }
@media (max-width: 600px) { .bar-row { grid-template-columns: 1fr 3rem; } .bar-row .bar { grid-column: 1 / -1; grid-row: 2; } }

/* ---------- Workspace ---------- */
.ws-head { margin-bottom: 18px; }
.ws-head .crumb { font-size: .9rem; margin-bottom: 8px; display: inline-block; }
.ws-head h1 { margin-bottom: 6px; }
.ws-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--ink-2); font-size: .9rem; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 1080px) { .workspace { grid-template-columns: 1fr; } }
.ws-tabs { display: none; }
@media (max-width: 1080px) {
  .ws-tabs { display: flex; gap: 4px; position: sticky; top: 0; z-index: 5; background: var(--mist); padding: 6px 0 10px; }
  .ws-tabs button { flex: 1; }
  .ws-tabs button[aria-selected="true"] { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }
  .workspace[data-tab="scenario"] .ws-right, .workspace[data-tab="response"] .ws-left { display: none; }
}

.brief { max-width: var(--measure); }
.brief h3 { margin-top: 22px; color: var(--navy-800); }
.brief h3:first-child { margin-top: 0; }
.brief ul { margin: 0 0 1em; padding-inline-start: 1.2em; }
.brief li { margin-bottom: .35em; }
.facts { width: 100%; border-collapse: collapse; margin: 4px 0 14px; font-size: .95rem; }
.facts th, .facts td { text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.facts th { font-weight: 500; color: var(--ink-2); width: 55%; }
.facts td { font-weight: 600; color: var(--navy-900); font-variant-numeric: tabular-nums; }
.authority { background: var(--mist); border: 1px solid var(--line); border-inline-start: 4px solid var(--navy-700); border-radius: var(--radius-s); padding: 12px 14px; }
.role-box { border-inline-start: 4px solid var(--teal); padding: 4px 14px; }

/* The Director's question — the one bold element */
.directive { position: relative; background: var(--navy-800); color: #fff; border-radius: var(--radius-m); padding: 22px 24px 22px 24px; margin: 22px 0; overflow: hidden; }
.directive .who { display: flex; align-items: center; gap: 10px; color: var(--teal-on-navy); font-weight: 500; font-size: .95rem; margin-bottom: 8px; }
.directive q { display: block; font-size: 1.32rem; line-height: 1.45; font-weight: 500; quotes: '“' '”'; }
html[lang="ar"] .directive q[lang="en"] { font-family: 'IBM Plex Sans', sans-serif; }
.directive .target { position: absolute; inset-inline-end: -26px; bottom: -26px; opacity: .16; pointer-events: none; }

.editor-panel { position: sticky; top: 16px; }
@media (max-width: 1080px) { .editor-panel { position: static; } }
.editor { width: 100%; min-height: 340px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 14px 16px; font-size: 1rem; line-height: 1.65; background: var(--paper); resize: vertical; }
.editor:focus { border-color: var(--teal); box-shadow: var(--focus); outline: none; }
.editor[dir="rtl"] { font-family: 'IBM Plex Sans Arabic', 'IBM Plex Sans', sans-serif; line-height: 1.85; }
.save-state { font-size: .86rem; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; }
.save-state .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.save-state[data-s="saved"] .dot { background: var(--ok); }
.save-state[data-s="saving"] .dot { background: var(--teal); animation: pulse 1s infinite; }
.save-state[data-s="failed"] { color: var(--danger); }
.save-state[data-s="failed"] .dot { background: var(--danger); }
.save-state[data-s="dirty"] .dot { background: #C58A12; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.editor-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0 14px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-s); overflow: hidden; }
.seg button { background: var(--paper); border: 0; padding: 6px 12px; cursor: pointer; font-size: .9rem; }
.seg button + button { border-inline-start: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--navy-800); color: #fff; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.dark { border-color: var(--navy-100); border-top-color: var(--teal); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Evaluation ---------- */
.eval-head { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; }
@media (max-width: 600px) { .eval-head { grid-template-columns: 1fr; } }
.score-dial { width: 120px; height: 120px; position: relative; }
.score-dial svg { transform: rotate(-90deg); }
.score-dial .v { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.score-dial .v b { font-size: 1.9rem; color: var(--navy-900); line-height: 1; font-variant-numeric: tabular-nums; }
.score-dial .v span { font-size: .78rem; color: var(--ink-2); }
.ai-label { font-weight: 600; color: var(--navy-800); display: flex; gap: 8px; align-items: center; }
.crit { border-top: 1px solid var(--line); padding: 14px 0; }
.crit:first-child { border-top: 0; }
.crit-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.crit-name { font-weight: 600; color: var(--navy-900); }
.pips { display: inline-flex; gap: 3px; vertical-align: middle; }
.pips i { width: 14px; height: 6px; border-radius: 2px; background: var(--navy-100); }
.pips i.on { background: var(--teal); }
.crit-score { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.quote { margin: 8px 0 0; padding: 6px 12px; border-inline-start: 3px solid var(--teal); background: var(--teal-soft); border-radius: 0 var(--radius-s) var(--radius-s) 0; font-size: .93rem; }
html[dir="rtl"] .quote { border-radius: var(--radius-s) 0 0 var(--radius-s); }
.quote.unmatched { border-color: #C58A12; background: var(--warn-soft); }
.list-block h3 { font-size: .98rem; margin-top: 18px; }
.list-block ul { margin: 0; padding-inline-start: 1.2em; }
.list-block li { margin-bottom: .4em; }

.reference { border: 2px solid var(--navy-800); border-radius: var(--radius-m); background: var(--paper); }
.reference-head { background: var(--navy-800); color: #fff; padding: 14px 22px; border-radius: 5px 5px 0 0; display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.reference-head h2 { color: #fff; margin: 0; font-size: 1.15rem; }
.reference-body { padding: 22px; }
.reference-text { white-space: pre-line; font-size: 1.02rem; line-height: 1.7; max-width: var(--measure); }
.translation { margin-top: 16px; padding: 14px 16px; background: var(--mist); border: 1px dashed var(--line-strong); border-radius: var(--radius-s); white-space: pre-line; }

.att-list { list-style: none; margin: 0; padding: 0; }
.att-list li { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.att-list li:first-child { border-top: 0; }
.delta-up { color: var(--ok); } .delta-down { color: var(--danger); }

/* ---------- Tables (admin) ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--paper); }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { background: var(--mist); color: var(--ink-2); font-weight: 500; white-space: nowrap; position: sticky; top: 0; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: end; font-variant-numeric: tabular-nums; }
.admin-layout { display: grid; gap: 18px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filters .field { margin: 0; min-width: 150px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .93rem; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; }
.answer-box { white-space: pre-wrap; background: var(--mist); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 14px; max-height: 420px; overflow: auto; }
.score-compare { display: flex; gap: 24px; flex-wrap: wrap; }
.score-compare div { min-width: 160px; }
.score-compare b { display: block; font-size: 1.5rem; color: var(--navy-900); font-variant-numeric: tabular-nums; }
details.version-list summary { cursor: pointer; color: var(--teal-strong); }
.crit-edit { display: grid; grid-template-columns: 9rem 1fr 1fr 6rem auto; gap: 8px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.crit-edit .wide { grid-column: 2 / 5; }
@media (max-width: 800px) { .crit-edit { grid-template-columns: 1fr 1fr; } .crit-edit .wide { grid-column: 1 / -1; } }
.toast { position: fixed; inset-inline-end: 20px; bottom: 20px; background: var(--navy-900); color: #fff; padding: 12px 16px; border-radius: var(--radius-s); max-width: min(420px, calc(100vw - 40px)); z-index: 50; box-shadow: 0 6px 24px rgba(12,28,54,.25); }
.empty { padding: 26px; text-align: center; color: var(--ink-2); }
.center-load { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 60px 0; color: var(--ink-2); }
