/*
 * ENTERPRISE Zambia 2.0 grant portal.
 *
 * Colours come from section 3 of the Partner Visibility and Branding
 * Requirements. Measured contrast against white:
 *
 *   navy   #182251  15.15:1  passes AA, used for text, headers, navigation
 *   blue   #1964AE   6.04:1  passes AA, used for links and primary actions
 *   purple #9D4490   5.73:1  passes AA, secondary accent, safe as text
 *   coral  #EB5F4C   3.35:1  large text only, so errors use #C2402F (5.16:1)
 *   teal   #19A7A3   2.96:1  fills and chips only, never text on white
 *   yellow #FCD503   1.43:1  highlight fills only, never text on white
 *
 * Teal, coral and yellow therefore appear only as tinted fills, chips and
 * borders carrying navy text, where contrast measures 12:1 or better. That
 * keeps the portal readable without leaving the approved palette.
 *
 * Typography follows section 5: Noto Sans for body, Arial as the documented
 * fallback and the standard for web compatibility.
 */

:root {
  --navy: #182251;
  --navy-dark: #0f1636;
  --blue: #1964ae;
  --blue-dark: #14528f;
  --purple: #9d4490;
  --coral: #eb5f4c;
  --coral-dark: #c2402f;
  --teal: #19a7a3;
  --teal-dark: #0f7a77;
  --yellow: #fcd503;

  --ink: #182251;
  --ink-muted: #4a5272;
  --line: #d7dae6;
  --line-soft: #e8eaf1;
  --surface: #ffffff;
  --surface-sunken: #f5f6fa;
  --surface-raised: #ffffff;

  --radius: 6px;
  --radius-lg: 10px;
  --gutter: 16px;
  --measure: 68ch;

  --font-body: "Noto Sans", Arial, Helvetica, sans-serif;
  --shadow: 0 1px 2px rgba(24, 34, 81, 0.08), 0 2px 8px rgba(24, 34, 81, 0.06);
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
img, picture, svg, video { max-width: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--surface-sunken);
}

/* Headings use bold uppercase for the top level, per section 5.1.1. */
h1, h2, h3, h4 {
  color: var(--navy);
  line-height: 1.25;
  margin: 0 0 0.5em;
  font-weight: 700;
}
h1 { font-size: 1.75rem; letter-spacing: 0.01em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
h4 { font-size: 1rem; }

p, li { max-width: var(--measure); }
p { margin: 0 0 1em; }

a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--blue-dark); }

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------------------------------------------------------------- layout */

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

main { padding: 28px 0 56px; }

.page-head {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--line-soft);
}
.page-head p.lede {
  color: var(--ink-muted);
  margin: 0;
  max-width: var(--measure);
}

.grid { display: grid; gap: 20px; }
@media (min-width: 760px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-sidebar { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
}

/* ------------------------------------------------- donor visibility strip */
/*
 * Section 2.1.1 fixes the order as Global Gateway, European Union co-funded
 * emblem, BMZ, then implementing partners. Layout Option A places Global
 * Gateway top left, the EU emblem and BMZ top right, and the partner logos
 * at the bottom. All logos carry equal visual weight, and the EU emblem is
 * matched to the height of the Global Gateway wordmark.
 */

.donor-bar {
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.donor-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 12px 0;
}
.donor-bar__group {
  display: flex;
  align-items: center;
  gap: 22px;
}
.donor-bar img { display: block; width: auto; }

/*
 * Equal visual weight, set optically rather than by a single number. The
 * EU mark is a vertical lockup, a flag above two lines of caption, so it
 * needs more overall height for its emblem to match the height of the
 * Global Gateway wordmark as section 2.1.1 requires.
 */
.donor-bar .logo-gg { height: 46px; }
.donor-bar .logo-eu { height: 58px; }
.donor-bar .logo-bmz { height: 46px; }

@media (max-width: 599px) {
  .donor-bar__inner { justify-content: flex-start; gap: 14px; }
  .donor-bar .logo-gg { height: 32px; }
  .donor-bar .logo-eu { height: 42px; }
  .donor-bar .logo-bmz { height: 32px; }
}

/* --------------------------------------------------------- site masthead */
/*
 * The project name sits below the logo strip and is styled as page content,
 * never as a logotype, because section 2.1.1 requires that it "must not be
 * positioned at the same hierarchical level" as the donor logos.
 */

.masthead {
  background: var(--navy);
  color: #fff;
}
.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 0;
}
.masthead__title { display: flex; flex-direction: column; }
.masthead__programme {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #b9c2e0;
}
.masthead__portal { font-size: 1.1rem; font-weight: 700; color: #fff; }
/*
 * Scoped to plain links. A button inside the masthead keeps its own
 * colours, otherwise .btn--secondary ends up white text on a white
 * background and reads as an empty box.
 */
.masthead a:not(.btn) { color: #fff; }
.masthead .btn--secondary {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.55);
}
.masthead .btn--secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: #fff;
  color: #fff;
}

.masthead__user {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.9rem;
  color: #d4daf0;
}

.nav {
  background: var(--navy-dark);
  border-bottom: 3px solid var(--teal);
}
.nav__inner {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  overflow-x: auto;
}
.nav a {
  color: #dfe3f2;
  text-decoration: none;
  padding: 11px 15px;
  font-size: 0.92rem;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
}
.nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav a[aria-current="page"] {
  color: #fff;
  border-bottom-color: var(--yellow);
  font-weight: 600;
}

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card__head h2, .card__head h3 { margin: 0; }

.card--accent { border-left: 4px solid var(--teal); }
.card--warn { border-left: 4px solid var(--coral); }
.card--note { border-left: 4px solid var(--purple); }

/* ------------------------------------------------------------ status pips */
/*
 * Chips put navy text on a tinted fill, so teal, coral and yellow can be
 * used without putting low-contrast colour on white.
 */

.pip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--navy);
  background: var(--line-soft);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pip--ok      { background: #d6f2f1; border-color: var(--teal); }
.pip--wait    { background: #fff6c2; border-color: #d9b703; }
.pip--stop    { background: #fde0db; border-color: var(--coral); }
.pip--info    { background: #dce9f8; border-color: var(--blue); }
.pip--muted   { background: var(--surface-sunken); }
.pip--accent  { background: #f2e0ef; border-color: var(--purple); }

/* ----------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}
table.data caption {
  text-align: left;
  color: var(--ink-muted);
  padding-bottom: 8px;
}
table.data th,
table.data td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
table.data th {
  color: var(--navy);
  font-weight: 600;
  background: var(--surface-sunken);
  border-bottom: 2px solid var(--line);
}
table.data tbody tr:hover { background: #fafbfd; }
table.data td p, table.data td li { max-width: none; }

/* ------------------------------------------------------------------ forms */

.field { margin-bottom: 22px; max-width: var(--measure); }
.field > label,
.field > .field__label {
  display: block;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 4px;
}
.field__guidance {
  font-size: 0.88rem;
  color: var(--ink-muted);
  margin: 0 0 8px;
}
.field__required { color: var(--coral-dark); font-weight: 700; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  padding: 9px 11px;
  border: 1px solid #9aa2bd;
  border-radius: var(--radius);
  background: #fff;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); }

.choices { display: grid; gap: 8px; }
.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
}
.choice:hover { border-color: var(--blue); background: #fafcff; }
.choice input { margin-top: 3px; flex-shrink: 0; }
.choice span { max-width: none; }

.word-count { font-size: 0.82rem; color: var(--ink-muted); margin-top: 4px; }
.word-count.over { color: var(--coral-dark); font-weight: 600; }

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 22px;
}
legend { font-weight: 700; color: var(--navy); padding: 0 6px; }

/* Disaggregated count tables and fixed tables. */
table.matrix { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.matrix th, table.matrix td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: left;
}
table.matrix th { background: var(--surface-sunken); color: var(--navy); }
table.matrix input { min-width: 90px; }
table.matrix td.total {
  background: #f2f4fa;
  font-weight: 700;
  color: var(--navy);
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}
.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:hover { background: var(--blue-dark); color: #fff; }
.btn--secondary {
  background: #fff;
  color: var(--navy);
  border-color: #9aa2bd;
}
.btn--secondary:hover { border-color: var(--navy); }
.btn--danger { background: var(--coral-dark); color: #fff; }
.btn--danger:hover { background: #a6341f; color: #fff; }
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 24px;
}

/* --------------------------------------------------------------- messages */

.notice {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  background: #fff;
}
.notice h2, .notice h3 { margin-top: 0; font-size: 1rem; }
.notice p:last-child, .notice ul:last-child { margin-bottom: 0; }
.notice--info { border-left-color: var(--blue); background: #f4f8fd; }
.notice--ok { border-left-color: var(--teal); background: #f2fbfa; }
.notice--warn { border-left-color: #d9b703; background: #fffdf0; }
.notice--error { border-left-color: var(--coral); background: #fef6f4; }
.notice ul { margin: 8px 0 0; padding-left: 20px; }

.errorlist {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  color: var(--coral-dark);
  font-size: 0.88rem;
  font-weight: 600;
}

/* -------------------------------------------------------- receipt and key */

.receipt {
  background: #f2fbfa;
  border: 1px solid var(--teal);
  border-radius: var(--radius-lg);
  padding: 20px;
}
/*
 * Definition lists stack on a narrow screen.
 *
 * A `max-content` first column plus a grid item's default `min-width:auto`
 * means one long value, such as a full date with a timezone, sets a floor
 * wider than a phone screen and pushes the whole page sideways. Stacking
 * below 560px removes the floor, and `min-width: 0` lets the value column
 * shrink and wrap at wider sizes.
 */
.receipt dl,
.keyvalue {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px 18px;
  margin: 0;
}
.receipt dl > *,
.keyvalue > * { min-width: 0; overflow-wrap: anywhere; }

@media (min-width: 560px) {
  .receipt dl,
  .keyvalue {
    grid-template-columns: minmax(auto, max-content) minmax(0, 1fr);
    gap: 6px 18px;
  }
}

.receipt dt { font-weight: 600; color: var(--navy); }
.receipt dd { margin: 0; }

.keyvalue { font-size: 0.94rem; }
.keyvalue dt { color: var(--ink-muted); }
.keyvalue dd { margin: 0 0 8px; color: var(--ink); }
@media (min-width: 560px) { .keyvalue dd { margin: 0; } }

/* ------------------------------------------------------------- trail, log */

.trail { list-style: none; margin: 0; padding: 0; }
.trail li {
  padding: 12px 0 12px 18px;
  border-left: 2px solid var(--line);
  position: relative;
  max-width: none;
}
.trail li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
}
.trail li.denied::before { background: var(--coral); }
.trail li.blocked::before { background: var(--yellow); }
.trail__meta { font-size: 0.84rem; color: var(--ink-muted); }

/* ----------------------------------------------------------------- footer */

.site-footer {
  background: var(--navy);
  color: #d4daf0;
  padding: 28px 0;
  margin-top: 48px;
}
.site-footer a { color: #fff; }
.site-footer p { font-size: 0.88rem; }
.site-footer .partner-strip {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  display: inline-block;
  margin-bottom: 18px;
  max-width: 100%;
}
.site-footer .partner-strip img {
  display: block;
  height: 40px;
  width: auto;
  max-width: 100%;
}
@media (max-width: 599px) {
  .site-footer .partner-strip img { height: auto; width: 100%; }
}

/* ----------------------------------------------------------------- utility */

.muted { color: var(--ink-muted); }
.small { font-size: 0.88rem; }
.stack > * + * { margin-top: 12px; }
.inline-list { list-style: none; padding: 0; margin: 0; display: flex; gap: 10px; flex-wrap: wrap; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.empty {
  padding: 32px;
  text-align: center;
  color: var(--ink-muted);
  background: var(--surface-sunken);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* HTMX autosave indicator. */
.autosave { font-size: 0.84rem; color: var(--ink-muted); }
.htmx-request .autosave__idle { display: none; }
.autosave__busy { display: none; }
.htmx-request .autosave__busy { display: inline; }

@media print {
  .nav, .masthead__user, .btn-row, .site-footer { display: none; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #999; }
}
