/* STEP Management — one stylesheet, logical properties throughout so Arabic mirrors cleanly. */

/* Brand type: public/fonts.css (shared with the printable reports). */
:root {
  /* STEP brand colours (Brand Guidelines v1, p. 16). src/views/brand.ts holds the same values for SVG and PDF. */
  --brand-primary: #003f4c;
  --brand-grey: #d0d1cf;
  --brand-panel: #f0f1f1;
  --brand-accent: #55c5cf;
  --brand-gradient: linear-gradient(90deg, #273b75 0%, #5468a4 25%, #36888a 50%, #199878 75%, #37a750 100%);
  --teal-90: #1a525e;
  --teal-80: #336570;
  --teal-70: #4c7982;
  --teal-60: #668c94;
  --teal-50: #809fa6;
  --teal-40: #99b2b7;
  --teal-30: #b2c5c9;
  --teal-20: #ccd9db;
  --teal-10: #e6eced;
  --grey-90: #d5d6d4;
  --grey-80: #d9dad9;
  --grey-70: #dedfdd;
  --grey-60: #e3e3e2;
  --grey-50: #e8e8e7;
  --grey-40: #ecedec;
  --grey-30: #f1f1f1;
  --grey-20: #f6f6f5;
  --teal: var(--brand-primary);
  --teal-dark: #002a33;
  --teal-soft: var(--teal-10);
  --navy: #273b75;
  --ink: #1d2b30;
  --muted: #515a5c;
  --sage: var(--grey-90);
  --border: var(--grey-60);
  --bg: var(--brand-panel);
  --card: #ffffff;
  --danger: #b3261e;
  --ok: #1f6b35;
  --focus: #273b75;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0, 63, 76, 0.05), 0 6px 18px rgba(0, 63, 76, 0.06);
  --font: 'STEP Sans', 'Segoe UI', system-ui, -apple-system, 'Geeza Pro', Tahoma, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-synthesis: none; font-family: var(--font); font-size: 1rem; line-height: 1.55; color: var(--ink); background: var(--bg); }
img, svg { max-width: 100%; }
a { color: var(--teal); text-underline-offset: 2px; }
a:hover { color: var(--navy); }
h1, h2, h3 { color: var(--teal); line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); font-weight: 700; }
p { margin: 0 0 0.75rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em; }
.prose { white-space: pre-line; max-width: 75ch; unicode-bidi: plaintext; }
.deflist dd, .chip a { unicode-bidi: plaintext; }
.nowrap-pair { white-space: nowrap; }
.print-only { display: none; }
html.js .js-hide { display: none; }
.icon { flex: none; vertical-align: middle; }

.skip-link { position: absolute; inset-inline-start: 1rem; top: -4rem; z-index: 100; background: #fff; color: var(--navy); padding: 0.6rem 1rem; border-radius: 8px; font-weight: 700; }
.skip-link:focus { top: 0.75rem; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem; min-height: 64px; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); background: var(--teal); color: #fff; --focus: #ffd48a; }
.topbar-title { font-weight: 500; font-size: 1.15rem; letter-spacing: 0.02em; min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar::after { content: ''; position: absolute; inset-inline: 0; bottom: 0; height: 4px; background: var(--brand-gradient); }
html[dir='rtl'] .topbar::after { transform: scaleX(-1); }
html[lang='ar'] .topbar-title { text-transform: none; }
.topbar-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; justify-content: flex-end; flex: none; max-width: 75%; }
.lang-switch { color: #fff; display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.75rem; border: 1px solid rgba(255, 255, 255, 0.55); border-radius: 999px; text-decoration: none; font-weight: 600; min-height: 40px; }
.lang-switch:hover { color: #fff; background: rgba(255, 255, 255, 0.12); }
.welcome { font-weight: 600; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; border: 0; background: transparent; color: inherit; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: rgba(0, 0, 0, 0.06); }
.icon-btn.danger { color: var(--danger); }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
form.inline { display: inline; margin: 0; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 64px); }
body.bare .shell { grid-template-columns: minmax(0, 1fr); }
.sidebar { background: #fff; border-inline-end: 1px solid var(--border); padding-block: 1.25rem; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; padding: 0 1.25rem 1rem; text-decoration: none; border-bottom: 1px solid var(--border); }
.step-logo { display: block; width: 100%; max-width: 232px; height: auto; }
/* Clear space around the logo (guide p. 7): at least the height of the S on every side. */
.brand { padding: 1.5rem 1.5rem 1.25rem; background: #fff; }
.user-card { display: flex; gap: 0.75rem; align-items: center; padding: 1rem 1.25rem; background: #f3f6f7; border-bottom: 1px solid var(--border); }
.user-card strong { display: block; color: var(--navy); }
.user-card .muted { font-size: 0.85rem; }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 700; flex: none; }
.nav { list-style: none; margin: 1rem 0 0; padding: 0 0.75rem; }
.nav a, .nav summary { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.9rem; border-radius: 10px; color: #4b5560; text-decoration: none; font-weight: 500; cursor: pointer; min-height: 44px; }
.nav a:hover, .nav summary:hover { background: #f1f4f5; color: var(--navy); }
.nav a[aria-current='page'] { background: var(--teal-soft); color: var(--teal-dark); font-weight: 700; }
.nav summary { list-style: none; }
.nav summary::-webkit-details-marker { display: none; }
.nav summary::after { content: ''; margin-inline-start: auto; width: 0.5rem; height: 0.5rem; border-inline-end: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform 0.15s; }
.nav details[open] > summary::after { transform: rotate(-135deg); }
.nav-group ul { list-style: none; padding-inline-start: 1.25rem; margin: 0; }
main { padding: 1.75rem max(16px, 2vw) 3rem; min-width: 0; outline: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-actions, .page-actions-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.page-actions-row { margin-bottom: 1rem; justify-content: flex-end; }
.lead { color: var(--muted); max-width: 70ch; }
.back-link { display: inline-flex; gap: 0.35rem; align-items: center; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; min-width: 0; }
.card.narrow { max-width: 34rem; }
.card-title { font-size: 1.15rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; border-inline-start: 4px solid var(--teal); padding-inline-start: 0.6rem; margin-bottom: 0.75rem; }
.card-title.small { font-size: 1rem; }
.card-note { color: var(--muted); font-size: 0.9rem; }
.sub-title { font-size: 1rem; margin-top: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1.25rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .grid-2, .grid-2 + .card, .card + .grid-2 { margin-top: 1.25rem; }
.deflist { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); gap: 0.75rem 1.5rem; margin: 0 0 0.75rem; }
.deflist dt { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.deflist dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
ul.plain { list-style: none; padding: 0; margin: 0 0 0.5rem; }
ul.plain li { padding: 0.3rem 0; border-bottom: 1px dashed var(--border); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; min-height: 44px; padding: 0.5rem 1.1rem; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; line-height: 1.2; white-space: nowrap; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); color: #fff; }
.btn-secondary { background: #fff; color: var(--teal-dark); border-color: #9fb6be; }
.btn-secondary:hover { background: var(--teal-soft); color: var(--teal-dark); }
.btn-ghost { background: transparent; color: var(--teal-dark); border-color: var(--border); }
.btn-ghost:hover { background: #eef2f3; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: #0f2c52; color: #fff; }
.btn-small { min-height: 36px; padding: 0.3rem 0.75rem; font-size: 0.9rem; }
.btn-block { width: 100%; }
.btn.is-disabled { opacity: 0.55; cursor: default; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.field > label, .label-like, fieldset > legend { font-weight: 700; color: var(--navy); font-size: 0.92rem; }
.req { color: var(--danger); }
.hint { color: var(--muted); font-size: 0.87rem; margin: 0; }
input[type='text'], input[type='email'], input[type='tel'], input[type='url'], input[type='date'], input[type='password'], input[type='search'], input[type='file'], select, textarea {
  width: 100%; min-height: 44px; padding: 0.5rem 0.75rem; border: 1px solid #8e989f; border-radius: 8px; background: #fff; color: var(--ink); font: inherit;
}
input[type='color'] { width: 4rem; height: 44px; padding: 2px; border: 1px solid #8e989f; border-radius: 8px; background: #fff; }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--navy); }
[aria-invalid='true'] { border-color: var(--danger) !important; }
.field-error { color: var(--danger); font-weight: 600; font-size: 0.88rem; margin: 0; }
.error-summary { border: 2px solid var(--danger); background: #fdf1ef; border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; color: var(--danger); }
.error-summary h2 { color: var(--danger); font-size: 1rem; }
.error-summary a { color: var(--danger); font-weight: 600; }
.flash { display: flex; align-items: center; gap: 0.5rem; background: #e3f4ea; color: var(--ok); border: 1px solid #b6dfc6; border-radius: 10px; padding: 0.7rem 1rem; font-weight: 600; margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem 1.25rem; }
.field-wide { grid-column: 1 / -1; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); gap: 0.25rem 1rem; margin-top: 0.4rem; }
.check { display: flex; align-items: center; gap: 0.5rem; min-height: 40px; cursor: pointer; }
.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--teal); flex: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.5rem; }
.form-table input, .form-table select { min-width: 8rem; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--border); }
.inline-form .field { flex: 1 1 9rem; }
.stack { display: grid; gap: 1rem; }
.login-card { margin-inline: auto; }

/* ---------- toolbar, tables, pager ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1rem; }
.toolbar-form, .filter-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; flex: 1 1 auto; min-width: 0; }
.toolbar-form .field, .filter-form .field { flex: 1 1 11rem; max-width: 100%; }
.field-search { flex: 2 1 14rem !important; }
.toolbar-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.table-wrap { position: relative; overflow-x: auto; max-width: 100%; border-radius: 8px; }
.table-wrap:focus-visible { outline: 3px solid var(--focus); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.data th, table.data td { padding: 0.6rem 0.75rem; text-align: start; border-bottom: 1px solid #e7eaeb; vertical-align: middle; }
table.data thead th { background: #e9eef0; color: var(--navy); font-weight: 700; white-space: nowrap; }
table.data tbody tr:hover { background: #f7fafb; }
table.data tfoot th, table.data tfoot td { font-weight: 700; background: #f3f6f7; }
table.data caption { text-align: start; font-weight: 700; color: var(--navy); padding-bottom: 0.4rem; }
table.compact th, table.compact td { padding: 0.45rem 0.6rem; }
.num { text-align: end !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.empty, p.empty { color: var(--muted); text-align: center; padding: 1.5rem; }
.col-name { min-width: 14rem; }
.ref-link { font-weight: 700; white-space: nowrap; }
.sort-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 0.3rem; }
.sort-link:hover { text-decoration: underline; }
.sort-mark { display: inline-block; opacity: 0.45; }
.sort-mark::before { content: '↕'; font-size: 0.8rem; }
.sort-mark.is-asc, .sort-mark.is-desc { opacity: 1; }
.sort-mark.is-asc::before { content: '↑'; }
.sort-mark.is-desc::before { content: '↓'; }
.actions-col { width: 1%; white-space: nowrap; }
.pager { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: center; justify-content: space-between; margin-top: 1rem; }
.pager-count { margin: 0; color: var(--muted); }
.per-page { display: flex; align-items: center; gap: 0.5rem; }
.per-page select { width: auto; min-height: 36px; }
.pager-nav { display: flex; align-items: center; gap: 0.5rem; }
.pager-page { color: var(--muted); }

/* compact row actions menu */
.row-menu { position: relative; }
.row-menu summary { list-style: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 8px; cursor: pointer; color: var(--teal-dark); border: 1px solid var(--border); background: #fff; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu[open] summary { background: var(--teal-soft); }
.row-menu ul { position: absolute; inset-inline-end: 0; top: calc(100% + 4px); z-index: 20; list-style: none; margin: 0; padding: 0.35rem; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(22, 61, 112, 0.16); min-width: 12rem; }
.row-menu a { display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.7rem; border-radius: 6px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.row-menu a:hover, .row-menu a:focus-visible { background: var(--teal-soft); }
.row-menu a.danger { color: var(--danger); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.82rem; font-weight: 700; white-space: nowrap; background: #eef0f2; color: #3d4652; }
.badge-status-planned { background: #e7e9fb; color: #2f3a9e; }
.badge-status-processing { background: #e6eced; color: #1a525e; }
.badge .icon { margin-inline-end: 1px; }
.badge-status-ongoing, .badge-pending, .badge-scheduled { background: #fdf0e1; color: #7f4205; }
.badge-status-completed, .badge-ok, .badge-received, .badge-health-on_track, .badge-risk-low, .badge-user-active { background: #e3f4ea; color: #1f6b43; }
.badge-status-suspended { background: #f1ece4; color: #5e4a2a; }
.badge-status-cancelled, .badge-bad, .badge-health-overspent, .badge-risk-high, .badge-user-inactive { background: #f8e4e2; color: #8c2a20; }
.badge-muted { background: var(--brand-panel); color: #4a4d49; }
.badge-warn, .badge-health-slow_disbursement, .badge-health-low_spending, .badge-risk-medium { background: #fff4d6; color: #6b4a00; }
.badge-role-admin { background: #e3e8f4; color: var(--navy); }
.badge-role-editor { background: var(--teal-soft); color: var(--teal-dark); }
.rag-dot { width: 0.65rem; height: 0.65rem; border-radius: 50%; background: currentColor; display: inline-block; }
.badge-rag-red { background: #fbe4e2; color: #9b2c20; }
.badge-rag-red .rag-dot { border-radius: 2px; }
.badge-rag-amber { background: #fdf0e1; color: #7f4205; }
.badge-rag-amber .rag-dot { border-radius: 0; transform: rotate(45deg) scale(0.85); }
.badge-rag-green { background: #e3f4ea; color: #1f6b43; }
.badge-rag-not_rated { background: #eef0f2; color: #4b5563; }
.badge-rag-not_rated .rag-dot { background: transparent; border: 2px solid currentColor; }
.swatch-label { display: inline-flex; align-items: center; gap: 0.5rem; }

/* ---------- dashboard ---------- */
.filters-card .filter-form { margin-top: 0.5rem; }
.kpi-grid { display: grid; gap: 1.25rem; margin-bottom: 1.25rem; }
.kpi-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.kpi-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }
.kpi { display: flex; align-items: center; gap: 1rem; padding: 1.25rem; border-radius: 16px; border: 1px solid var(--border); background: linear-gradient(135deg, #ffffff 0%, #eef1f2 100%); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); min-width: 0; transition: transform 0.12s, box-shadow 0.12s; }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 63, 76, 0.12); color: var(--ink); }
.kpi-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 16px; color: #fff; flex: none; box-shadow: 0 6px 14px rgba(0, 63, 76, 0.18); }
.kpi-icon.small { width: 44px; height: 44px; border-radius: 12px; box-shadow: none; }
.tone-teal { background: linear-gradient(135deg, #00596a, #003f4c); }
.tone-purple { background: linear-gradient(135deg, #bb5a92, #a8467e); }
.tone-orange { background: linear-gradient(135deg, #d98a14, #b86d00); }
.tone-navy { background: linear-gradient(135deg, #3b4f8c, #273b75); }
.tone-green { background: linear-gradient(135deg, #2e8146, #1f6b35); }
.tone-indigo { background: linear-gradient(135deg, #6576b0, #5468a4); }
.tone-teal2 { background: linear-gradient(135deg, #24a1ad, #1d8f9a); }
.kpi-text { display: flex; flex-direction: column; align-items: flex-end; text-align: end; margin-inline-start: auto; min-width: 0; }
.kpi-label { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--teal); }
html[lang='ar'] .kpi-label { letter-spacing: 0; text-transform: none; font-size: 0.95rem; }
/* A figure never breaks: it scales with its card instead (the brand face is wider than the old one). */
.kpi { container-type: inline-size; }
.kpi-value { font-size: clamp(1.2rem, 8.5cqi, 2.1rem); font-weight: 700; color: var(--teal); line-height: 1.15; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi-unit { font-size: 0.55em; font-weight: 600; }
.filter-toggle { display: none; }
html.js .filter-toggle.is-active { display: inline-flex; }
html.js .filter-fields.is-collapsed { display: none; }
.filter-fields { display: contents; }
.kpi-sub { color: var(--muted); font-size: 0.88rem; display: flex; flex-wrap: wrap; gap: 0.35rem 0.75rem; justify-content: flex-end; }
.kpi-chip { font-weight: 700; }
.st-completed { color: #1f6b43; }
.st-ongoing { color: #7f4205; }
.st-planned { color: #2f3a9e; }
.panel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.panel-grid > .card { margin-bottom: 0; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.chart { min-height: 4rem; }
.chart-data { margin-top: 0.75rem; }
.chart-data summary, .audit-entry summary { cursor: pointer; color: var(--teal-dark); font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
.bar-list li { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) auto; align-items: center; gap: 0.6rem; }
.bar-label { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-value { font-size: 0.88rem; font-weight: 700; font-variant-numeric: tabular-nums; }
svg.bar { width: 100%; height: 14px; display: block; border-radius: 4px; }
.bar-track { fill: #eef1f3; }
.bar-stack { display: grid; gap: 3px; }
.bar-stack svg.bar { height: 9px; }
.doughnut { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.ring { width: 150px; height: 150px; transform: rotate(0deg); }
.ring-track { stroke: #eef1f3; }
.ring-centre { font-weight: 700; fill: var(--navy); font-family: var(--font); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; font-size: 0.9rem; flex: 1 1 10rem; }
.legend li { display: flex; align-items: center; gap: 0.45rem; }
.legend strong { margin-inline-start: auto; font-variant-numeric: tabular-nums; }
.legend-inline { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 0.75rem; }
.legend-inline li strong { margin: 0; }
.burn-line { margin-top: 0.75rem; }
.sector-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 1rem; }
.sector-card { position: relative; display: flex; flex-direction: column; gap: 0.15rem; padding: 1rem 1rem 1rem 1.4rem; padding-inline-start: 1.4rem; border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: var(--ink); background: #fbfcfc; overflow: hidden; }
.sector-card:hover { background: var(--teal-soft); color: var(--ink); }
.sector-bar { position: absolute; inset-block: 0; inset-inline-start: 0; width: 6px; display: flex; }
.sector-bar svg { height: 100%; }
.sector-total { font-size: 1.6rem; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.progress-row { margin-bottom: 0.9rem; }
.progress-head { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.92rem; }
.progress-foot { font-size: 0.82rem; color: var(--muted); margin: 0.2rem 0 0; }
.kpi-mini { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: 0.75rem; }
.kpi-mini > div { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.75rem; border: 1px solid var(--border); border-radius: 10px; background: #fbfcfc; }
.kpi-mini strong { font-size: 1.2rem; color: var(--navy); font-variant-numeric: tabular-nums; }

/* ---------- lists with side panel ---------- */
.list-layout, .report-layout { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 1.25rem; align-items: start; }
.saved-filters { position: sticky; top: 80px; }
.chips { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { display: inline-flex; align-items: center; gap: 0.2rem; background: var(--teal-soft); border-radius: 999px; padding-inline: 0.75rem 0.2rem; }
.chip a { font-weight: 600; text-decoration: none; }
.chip-x { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; background: transparent; border-radius: 50%; cursor: pointer; color: var(--teal-dark); }
.chip-x:hover { background: #cfe0e4; }
.save-filter { display: grid; gap: 0.4rem; }
.save-filter label { font-weight: 700; color: var(--navy); font-size: 0.9rem; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: inline-grid; place-items: center; background: #f3f6f7; color: var(--teal); }

/* ---------- reports ---------- */
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); gap: 1rem; }
.report-types { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.report-types legend { margin-bottom: 0.75rem; }
.report-type { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.9rem; border: 2px solid var(--border); border-radius: 12px; cursor: pointer; background: linear-gradient(135deg, #fff, #f1f4f5); }
.report-type:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.report-type input { margin-top: 0.3rem; width: 1.15rem; height: 1.15rem; accent-color: var(--teal); flex: none; }
.report-type strong { display: block; color: var(--navy); }
.report-type .muted { display: block; font-size: 0.86rem; }
.results-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem; align-items: center; }
.report-table + .report-table { margin-top: 1.25rem; }

/* ---------- audit ---------- */
.audit-list { list-style: none; padding: 0; margin: 1rem 0 0; }
.audit-entry { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.audit-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* ---------- printable summary ---------- */
.summary-page main.summary { max-width: 64rem; margin: 0 auto; padding: 1.5rem max(16px, 2vw); }
.summary-tools { display: flex; justify-content: space-between; margin-bottom: 1rem; }
.summary-head { display: flex; gap: 1.25rem; align-items: center; border-bottom: 3px solid var(--teal); padding-bottom: 1rem; margin-bottom: 1rem; }
.summary-head .step-logo { width: 150px; }
.summary section { margin-bottom: 1.25rem; }
.summary h2 { font-size: 1.1rem; }

/* ---------- responsive ---------- */
@media (min-width: 1201px) {
  #c-funding { grid-column: span 2; align-self: start; }
}
@media (max-width: 1200px) {
  .panel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: 1 / -1; }
}
@media (max-width: 1100px) {
  .list-layout, .report-layout { grid-template-columns: minmax(0, 1fr); }
  .saved-filters { position: static; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  html.js .sidebar { display: none; position: fixed; inset-block: 64px 0; inset-inline-start: 0; width: min(86vw, 300px); z-index: 25; overflow-y: auto; box-shadow: 0 0 40px rgba(0, 0, 0, 0.25); }
  html.js .sidebar.open { display: block; }
  html.js .nav-toggle { display: inline-flex; }
  .welcome { display: none; }
}
@media (max-width: 760px) {
  .panel-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar { gap: 0.5rem; }
  .topbar-title { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .topbar-tools { flex-wrap: nowrap; gap: 0.4rem; }
  .lang-switch { padding: 0.4rem; }
  /* Icon-only on phones; the words stay available to screen readers. */
  .btn-navy span, .lang-switch span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .kpi-value { font-size: clamp(1.2rem, 8.5cqi, 1.8rem); }
  .kpi-icon { width: 52px; height: 52px; }
  .bar-list li { grid-template-columns: minmax(0, 7rem) minmax(0, 1fr) auto; }
  main { padding-top: 1.25rem; }
  .page-actions-row { justify-content: stretch; }
  .page-actions-row .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Import issues */
.issue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.issue { border: 1px solid var(--border, #dbdedd); border-radius: 10px; padding: 12px 14px; }
.issue-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.issue p { margin: 8px 0; overflow-wrap: anywhere; }
.issue-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.issue-assign { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.issue-assign select { min-width: 0; max-width: 100%; }

/* Bulk import */
.import-steps { display: flex; flex-wrap: wrap; gap: 8px 24px; padding-inline-start: 1.2em; margin: 0 0 16px; color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.seg a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; color: inherit; }
.seg a.seg-on { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.seg a:focus-visible { outline: 3px solid var(--brand-accent); outline-offset: 2px; }
.column-guide { margin-top: 12px; }
.column-guide summary { cursor: pointer; font-weight: 600; }
.import-upload { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.import-upload .field { min-width: 0; flex: 1 1 260px; }
.import-upload input[type="file"] { max-width: 100%; }
.import-preview td, .import-preview th { white-space: nowrap; }
.import-preview tr.row-bad { background: #fff8f7; }
.row-errors { margin: 4px 0 0; padding-inline-start: 1.1em; white-space: normal; min-width: 18em; color: #8c2a20; }

/* Money: over-disbursed figures, and where each figure comes from */
.neg { color: var(--danger); font-weight: 700; }
.calc-note { display: block; margin-top: 4px; font-size: 0.78rem; line-height: 1.35; color: var(--muted); font-weight: 400; }
.funding-figures .btn { margin-top: 8px; }

/* Tabs (Settings, donor pages): each tab is a real link, comfortably large to tap */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; padding: 0; }
.tabs a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card, #fff); color: inherit; text-decoration: none; font-weight: 600; }
.tabs a[aria-current="page"] { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.tabs a:focus-visible { outline: 3px solid var(--brand-accent); outline-offset: 2px; }
/* Row actions in tables (Edit beside Delete) */
.row-actions { white-space: nowrap; }
.row-actions > a { display: inline-flex; align-items: center; min-height: 32px; padding: 0 8px; }
/* Settings list editors */
.list-editor input:not([type="checkbox"]), .list-editor select { width: 100%; min-width: 8rem; }
.list-editor input.narrow-num { min-width: 4.5rem; width: 5rem; }
.list-editor input.short { min-width: 6rem; }
.list-editor tr.new-row { background: var(--brand-panel); }
.list-index, .export-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 8px; padding: 0; list-style: none; }
.list-index a, .export-list a { display: block; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; min-height: 24px; }
td.wrap { white-space: normal; min-width: 16rem; }
.legacy-panel summary { cursor: pointer; }
.wrap-ok .badge, .wrap-ok .btn { white-space: normal; text-align: start; max-width: 100%; height: auto; }

/* User management: bulk actions above the table */
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0 0 0.75rem; }
.bulk-bar select { width: auto; min-height: 36px; }
.row-check { width: 1.15rem; height: 1.15rem; accent-color: var(--teal); }
.btn.danger { color: var(--danger); }
/* User management: the row actions stay in view while the wide table scrolls. */
.users-table .actions-col { position: sticky; inset-inline-end: 0; background: var(--card); box-shadow: -6px 0 8px -6px rgba(0, 0, 0, 0.18); z-index: 1; }
html[dir='rtl'] .users-table .actions-col { box-shadow: 6px 0 8px -6px rgba(0, 0, 0, 0.18); }
.users-table thead .actions-col { background: #e9eef0; }

/* Agreements: a flagged agreement or register row carries a red edge and words, never colour alone. */
.agr.is-flagged { border-inline-start: 4px solid var(--danger); }
.agr-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; align-items: center; }
.agr-badges { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; }
.agr-file { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.agr-actions { display: flex; gap: 0.5rem; margin: 0.75rem 0 0; }
.agr-upload { align-items: flex-end; }
.kpi-mini-card .kpi2-label { margin: 0; color: var(--muted); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-mini-card .kpi2-value { margin: 0.2rem 0 0; font-size: 1.6rem; font-weight: 700; color: var(--teal); }
table.register tr.is-flagged th, table.register tr.is-flagged td { background: #fdf1ef; }
table.register tr.is-flagged th:first-child { box-shadow: inset 4px 0 0 var(--danger); }
html[dir='rtl'] table.register tr.is-flagged th:first-child { box-shadow: inset -4px 0 0 var(--danger); }
.flag { display: block; color: var(--danger); font-weight: 700; font-size: 0.86rem; }

/* Reporting Engine: designed PDF reports */
.pdf-types { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 0.75rem; }
.pdf-types a { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.9rem; border: 1px solid var(--border); border-radius: 12px; text-decoration: none; min-height: 44px; }
.pdf-types a:hover { background: var(--teal-soft); }
.pdf-types .muted { font-size: 0.86rem; }
.pdf-records { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 1rem; }
.pdf-pick { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.pdf-pick .field { width: 100%; }
