/* ActionAid palette (AAI Brand Guidelines 2021). Red is reserved for brand accents. */
:root {
  --charcoal: #1C1C1C; --red: #FB171C; --white: #FFFFFF;
  --aqua: #92CCBE; --blue: #2F7DA7; --coral: #FF7D69; --pink: #ECC4C5; --purple: #774C68;
  --sage: #677C5F; --steel: #8FB4BE; --stone: #C6BDAE; --yellow: #F4BC03;
  --ink: #1C1C1C; --ink-2: #4a4a4a; --ink-3: #767676; --line: #e6e3de; --bg: #f7f6f3; --surface: #fff;
  --radius: 10px; --shadow: 0 1px 2px rgba(28,28,28,.06), 0 2px 8px rgba(28,28,28,.04);
  --font: "Auxilia", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 700; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
small, .muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; } .mt-0 { margin-top: 0; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--charcoal); color: #fff; padding: 22px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; border-top: 4px solid var(--red); }
.brand { display: block; padding: 0 10px 18px; color: #fff; }
.brand:hover { text-decoration: none; }
.logo { font-weight: 800; font-size: 1.55rem; letter-spacing: -.5px; color: var(--red); line-height: 1; }
.logo.on-dark { color: #fff; } .logo .ex { color: var(--red); }
.brand small { display: block; color: #bdbdbd; font-size: .78rem; margin-top: 6px; line-height: 1.3; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.nav a { color: #e6e6e6; padding: 9px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; font-size: .93rem; }
.nav a:hover { background: #2c2c2c; text-decoration: none; }
.nav a.active { background: #fff; color: var(--charcoal); font-weight: 600; box-shadow: inset 3px 0 0 var(--red); }
.nav .sep { color: #8a8a8a; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 4px; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.sidebar .me { margin-top: auto; padding: 12px; border-top: 1px solid #333; font-size: .85rem; color: #cfcfcf; }
.sidebar .me strong { color: #fff; display: block; }
.sidebar .me form { display: inline; }
.linkbtn { background: none; border: 0; padding: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; }
.main { padding: 26px 32px 60px; min-width: 0; }
.topbar { display: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 2px 0 0; color: var(--ink-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--charcoal); color: #fff;
    padding: 10px 14px; position: sticky; top: 0; z-index: 40; border-top: 3px solid var(--red); }
  .topbar button { background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; }
  .main { padding: 16px 14px 70px; }
  h1 { font-size: 1.3rem; }
}

/* ---------- Cards & KPIs ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--steel)); }
.kpi .label { font-size: .78rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.85rem; font-weight: 700; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .82rem; color: var(--ink-2); }
.kpi.hero { background: var(--charcoal); color: #fff; border-color: var(--charcoal); }
.kpi.hero .label, .kpi.hero .sub { color: #cfcfcf; }
.kpi.hero::before { background: var(--red); }

.progress { height: 8px; background: #eeebe6; border-radius: 99px; overflow: hidden; min-width: 60px; }
.progress > span { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.progress.big { height: 10px; margin-top: 8px; }
.kpi.hero .progress { background: #3a3a3a; } .kpi.hero .progress > span { background: #fff; }
.pctcell { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.pctcell .progress { flex: 1; }
.pctcell .low > span, .progress.low > span { background: var(--coral); }
.pctcell .mid > span, .progress.mid > span { background: var(--yellow); }
.pctcell .high > span, .progress.high > span { background: var(--sage); }

.chart-box { position: relative; height: 290px; }
.chart-box.tall { height: 380px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f3f1ed; font-weight: 600; font-size: .8rem; color: var(--ink-2); white-space: nowrap; position: sticky; top: 0; }
tbody tr:hover { background: #fbfaf8; }
tr.total td { font-weight: 700; background: #f3f1ed; border-top: 2px solid var(--charcoal); }
td.num, th.num { text-align: right; }
.table-plain { border: 0; }
table.compact th, table.compact td { padding: 6px 8px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .76rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-ok { background: #e3eff6; color: #1f5876; border-color: #b9d6e6; }
.badge-info { background: #e6f4f0; color: #2e6457; border-color: #bfe0d7; }
.badge-warn { background: #fdf3d3; color: #7a5c00; border-color: #f4dd8f; }
.badge-muted { background: #f0eeea; color: #5e5a52; border-color: #e0dcd4; }
.badge-danger { background: #ffe7e3; color: #a3271a; border-color: #ffc9c0; }
.badge-dark { background: var(--charcoal); color: #fff; }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--charcoal); background: var(--charcoal); color: #fff; font: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer; text-decoration: none !important; white-space: nowrap; min-height: 40px; }
.btn:hover { background: #333; }
.btn-outline { background: #fff; color: var(--charcoal); border-color: #cfcac2; }
.btn-outline:hover { background: #f3f1ed; }
.btn-red { background: var(--red); border-color: var(--red); }
.btn-red:hover { background: #d90f14; }
.btn-danger { background: #fff; color: #b3261e; border-color: #e7b6b1; }
.btn-danger:hover { background: #fff1ef; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: progress; }
form p, .field { margin: 0 0 14px; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=time],
input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cfcac2; border-radius: 8px; font: inherit; background: #fff; color: var(--ink); min-height: 42px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--charcoal); vertical-align: -3px; margin-right: 6px; }
.helptext, .help { display: block; font-size: .8rem; color: var(--ink-3); margin-top: 4px; font-weight: 400; }
.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: #b3261e; font-size: .84rem; font-weight: 600; }
.errorlist.nonfield { background: #fff1ef; border: 1px solid #f3c2bc; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.checklist { max-height: 260px; overflow: auto; border: 1px solid #cfcac2; border-radius: 8px; padding: 8px 12px; background: #fff; }
.checklist label, .radiolist label { font-weight: 400; margin: 4px 0; }
.checklist ul, .radiolist ul, ul.radiolist { list-style: none; padding: 0; margin: 0; }
.form-narrow { max-width: 720px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 16px; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.filters .f { display: flex; flex-direction: column; min-width: 130px; flex: 1 1 130px; }
.filters .f.wide { flex: 2 1 220px; }
.filters label { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); margin-bottom: 3px; }
.filters select, .filters input { min-height: 38px; padding: 7px 10px; }
.active-filters { font-size: .85rem; color: var(--ink-2); margin: -6px 0 14px; }

/* ---------- Messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 11px 14px; border-radius: 8px; margin-bottom: 8px; border: 1px solid; font-size: .92rem; }
.messages .success { background: #edf4ea; border-color: #c8dbc1; color: #2f4429; }
.messages .info { background: #e9f3f8; border-color: #c6dfec; color: #1f5876; }
.messages .warning { background: #fdf6dc; border-color: #f0d98a; color: #6b5100; }
.messages .error { background: #fff1ef; border-color: #f3c2bc; color: #8e1f15; }

/* ---------- Champion activity cards ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a.active { color: var(--charcoal); border-bottom-color: var(--red); }
.tabs a:hover { text-decoration: none; color: var(--charcoal); }
.activity { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.activity.overdue { border-left: 4px solid var(--coral); }
.activity-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.activity h3 { margin: 0 0 2px; font-size: 1.02rem; }
.activity .meta { color: var(--ink-2); font-size: .87rem; }
.activity .meta span + span::before { content: "·"; margin: 0 6px; color: var(--stone); }
.session-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0 0; margin-top: 10px; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.session-row .when { font-size: .9rem; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { background: #f3f1ed; border-radius: 6px; padding: 3px 8px; font-size: .8rem; color: var(--ink-2); }
.chip b { color: var(--ink); }

/* ---------- Details ---------- */
dl.props { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; margin: 0; }
dl.props dt { color: var(--ink-3); font-size: .86rem; }
dl.props dd { margin: 0; }
@media (max-width: 640px) { dl.props { grid-template-columns: 1fr; } dl.props dt { margin-top: 6px; } }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line); position: relative; font-size: .88rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--stone); }
.timeline li.k-complete::before, .timeline li.k-verify::before { background: var(--sage); }
.timeline li.k-correct::before, .timeline li.k-delete::before { background: var(--coral); }
.diff { font-size: .82rem; color: var(--ink-2); margin-top: 3px; }
.diff del { color: #a3271a; } .diff ins { color: #3f5338; text-decoration: none; font-weight: 600; }
.files { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.file { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; font-size: .84rem; background: #fff; }
.file img { width: 34px; height: 34px; object-fit: cover; border-radius: 4px; }

.issue { font-size: .83rem; } .issue.err { color: #a3271a; } .issue.warn { color: #7a5c00; }
.empty { text-align: center; color: var(--ink-3); padding: 40px 10px; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.sticky-bar { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 12px; margin: 16px -18px -18px; border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.totbox { background: var(--charcoal); color: #fff; border-radius: 8px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.totbox b { font-size: 1.4rem; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--charcoal); border-top: 6px solid var(--red); }
.auth-card { background: #fff; border-radius: 14px; padding: 32px 28px; width: 100%; max-width: 410px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-card .logo { font-size: 2rem; margin-bottom: 18px; }
.auth-card h1 { font-size: 1.25rem; margin-bottom: 4px; }

@media print {
  .sidebar, .topbar, .filters, .actions, .btn { display: none !important; }
  .app { display: block; } .main { padding: 0; } .card, .kpi { box-shadow: none; break-inside: avoid; }
}

.legend-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--ink-2); }
.legend-inline i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
details.tableview summary { cursor: pointer; font-size: .84rem; color: var(--blue); margin-top: 10px; }

/* Official ActionAid logo (image). Height is fixed and width follows the image, so the aspect ratio is never distorted. */
.logo-img { display: block; height: auto; max-width: 100%; }
.logo-side { width: 156px; }
.logo-top { width: 118px; }
.logo-login { width: 190px; margin-bottom: 20px; }

/* Upload page steps */
.steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .steps { grid-template-columns: 1fr; } }
.steps .card + .card { margin-top: 0; }
.step { position: relative; padding-left: 64px; }
.step-no { position: absolute; left: 18px; top: 18px; width: 32px; height: 32px; border-radius: 50%; background: var(--charcoal);
  color: #fff; font-weight: 700; display: grid; place-items: center; }
ul.tight { margin: 0; padding-left: 18px; } ul.tight li { margin: 3px 0; }

/* Advanced search */
.search-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px 14px; }
.search-grid .f { display: flex; flex-direction: column; min-width: 0; }
.search-grid .f.wide { grid-column: span 2; }
@media (max-width: 520px) { .search-grid .f.wide { grid-column: auto; } }
.search-grid label { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); margin-bottom: 4px; font-weight: 600; }
.search-grid input { min-height: 40px; }
details.ms { position: relative; }
details.ms > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  min-height: 40px; padding: 8px 12px; border: 1px solid #cfcac2; border-radius: 8px; background: #fff; cursor: pointer;
  font-size: .92rem; color: var(--ink-2); }
details.ms > summary::-webkit-details-marker { display: none; }
details.ms > summary .ms-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.ms.has-value > summary { border-color: var(--charcoal); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--red); }
details.ms[open] > summary { outline: 2px solid var(--blue); outline-offset: 1px; }
.ms-panel { position: absolute; z-index: 30; left: 0; right: 0; min-width: 240px; margin-top: 4px; background: #fff;
  border: 1px solid #cfcac2; border-radius: 8px; box-shadow: 0 10px 28px rgba(28,28,28,.16); padding: 8px; }
.ms-panel .ms-search { min-height: 34px; padding: 6px 10px; margin-bottom: 6px; }
.ms-list { max-height: 260px; overflow: auto; }
.ms-opt { display: flex !important; align-items: center; gap: 2px; font-weight: 400 !important; text-transform: none !important;
  letter-spacing: 0 !important; font-size: .9rem !important; color: var(--ink) !important; padding: 5px 6px; border-radius: 6px; margin: 0 !important; cursor: pointer; }
.ms-opt:hover { background: #f3f1ed; }
.ms-actions { display: flex; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.ms-actions .linkbtn, .card .linkbtn { color: var(--blue); text-decoration: none; font-size: .85rem; }
.result-bar { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; font-size: .93rem; }
a.sort { color: var(--ink-2); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
a.sort::after { content: "↕"; color: #b5b0a8; font-size: .8em; }
a.sort.on { color: var(--charcoal); }
a.sort.on.asc::after { content: "▲"; color: var(--charcoal); }
a.sort.on.desc::after { content: "▼"; color: var(--charcoal); }
.per-page { margin-right: auto; }

/* Settings */
.settings-tabs { position: sticky; top: 0; background: var(--bg); z-index: 5; }
@media (max-width: 900px) { .settings-tabs { top: 52px; } }
.settings-section { scroll-margin-top: 60px; }
.settings-section + .settings-section { margin-top: 16px; }
details.add-box { margin-top: 12px; }
details.add-box > summary { list-style: none; display: inline-flex; }
details.add-box > summary::-webkit-details-marker { display: none; }
details.add-box[open] > summary { display: none; }
details.add-box .add-form { border: 1px dashed #cfcac2; border-radius: 8px; padding: 14px; background: #fcfbf9; }

.clip { display: block; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) {
  .search-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .search-grid .f.wide { grid-column: 1 / -1; }
  .search-grid .f:nth-child(even) .ms-panel { left: auto; right: 0; }
}

/* Clickable dashboard cards */
a.kpi-link { display: block; color: inherit; text-decoration: none !important; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
a.kpi-link::after { content: "→"; position: absolute; right: 12px; top: 10px; font-size: 1rem; color: #b5b0a8; transition: color .12s, transform .12s; }
a.kpi-link:hover, a.kpi-link:focus-visible { border-color: var(--charcoal); box-shadow: 0 6px 18px rgba(28,28,28,.12); transform: translateY(-2px); }
a.kpi-link:hover::after, a.kpi-link:focus-visible::after { color: var(--red); transform: translateX(2px); }
a.kpi-link:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
a.kpi-link.hero::after { color: #8a8a8a; }
a.kpi-link.hero:hover { border-color: var(--red); }
.card-context { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 14px; }
.card-context p { margin: 2px 0 0; color: var(--ink-2); font-size: .9rem; }
.totals-strip { display: flex; flex-wrap: wrap; gap: 8px 22px; background: var(--charcoal); color: #fff; border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 12px; font-size: .9rem; }
.totals-strip b { font-size: 1.15rem; }
.totals-strip span small { color: #cfcfcf; }
tfoot td { font-weight: 700; background: #f3f1ed; border-top: 2px solid var(--charcoal); }
a.kpi-link .label { padding-right: 18px; }

/* ===================== Activity detail page ===================== */
.eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; margin-bottom: 2px; }
.venue-line { display: flex; align-items: center; gap: 6px; color: var(--ink-2); margin: 2px 0 8px !important; }
.head-badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.head-badges a.badge { text-decoration: none; }
.count { display: inline-block; min-width: 22px; padding: 0 7px; margin-left: 4px; border-radius: 99px; background: #f0eeea;
  color: var(--ink-2); font-size: .78rem; text-align: center; vertical-align: 2px; }

.summary-panel { border-top: 4px solid var(--charcoal); }
.summary-grid { display: grid; grid-template-columns: 170px minmax(0, 1.1fr) minmax(0, 1fr); gap: 22px; align-items: center; }
@media (max-width: 1100px) { .summary-grid { grid-template-columns: 150px 1fr; } .gender-bars { grid-column: 1 / -1; } }
@media (max-width: 560px) { .summary-grid { grid-template-columns: 1fr; } .ring-box { justify-self: center; } }
.ring { --p: 0; width: 150px; height: 150px; border-radius: 50%;
  background: conic-gradient(var(--blue) calc(var(--p) * 1%), #ebe8e3 0); display: grid; place-items: center; }
.ring.ring-empty { background: repeating-conic-gradient(#ebe8e3 0 8deg, #f5f3ef 8deg 16deg); }
.ring-inner { width: 112px; height: 112px; border-radius: 50%; background: #fff; display: grid; place-content: center; text-align: center; }
.ring-inner b { font-size: 1.75rem; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-inner span { font-size: .72rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.stat-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: #f7f6f3; border-radius: 8px; padding: 10px 14px; }
.stat span { display: block; font-size: .76rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.stat b { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stat-accent { background: var(--charcoal); color: #fff; } .stat-accent span { color: #cfcfcf; }
.neg { color: #b3261e !important; } .pos { color: #3f5338 !important; }
.gbar { margin-bottom: 10px; }
.gbar-head { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; margin-bottom: 4px; }
.gbar-head em { font-style: normal; font-weight: 700; }
.gbar-track { height: 14px; background: #ebe8e3; border-radius: 99px; overflow: hidden; }
.gbar-fill { height: 100%; border-radius: 99px; background: var(--blue); }
.gbar-fill.female { background: var(--purple); }
.gbar small { color: var(--ink-3); font-size: .78rem; }
.summary-table td, .summary-table th { white-space: nowrap; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(280px, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-main > .card + .card, .detail-side > .card + .card { margin-top: 16px; }
.session-card { border: 1px solid var(--line); border-left: 4px solid var(--stone); border-radius: 8px; padding: 12px 14px; }
.session-card + .session-card { margin-top: 10px; }
.session-card.is-done { border-left-color: var(--blue); }
.session-card.is-overdue { border-left-color: var(--coral); }
.session-card h3 { margin: 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fact-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
@media (max-width: 640px) { .fact-grid { grid-template-columns: 1fr 1fr; } }
.fact-grid span { display: block; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.fact-grid b { font-weight: 600; }
.note { background: #f7f6f3; border-radius: 6px; padding: 8px 10px; margin: 10px 0 0; font-size: .9rem; }
.warn-note { background: #fdf6dc; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.thumb { position: relative; padding: 0; border: 0; border-radius: 8px; overflow: hidden; cursor: zoom-in; aspect-ratio: 4 / 3; background: #eee; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.thumb:hover img, .thumb:focus-visible img { transform: scale(1.04); }
.thumb:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.thumb-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 5px; font-size: .74rem; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.empty-mini { border: 1px dashed #d6d1c9; border-radius: 8px; padding: 18px; text-align: center; color: var(--ink-3); font-size: .92rem; }

.report-highlight { background: #e3eff6; border: 1px solid #b9d6e6; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: .92rem; }
.doc-group-title { font-size: .86rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); margin: 14px 0 6px; }
.doc-group-title small { text-transform: none; letter-spacing: 0; }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.doc-list li:last-child { border-bottom: 0; }
.doc-meta { flex: 1; min-width: 0; }
.doc-meta a { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta small { color: var(--ink-3); }
.doc-list .actions form { display: inline; }
.file-icon { flex: none; width: 40px; height: 46px; border-radius: 6px; display: grid; place-items: center; font-size: .68rem; font-weight: 800;
  color: #fff; background: var(--stone); letter-spacing: .03em; }
.file-icon.ext-pdf { background: #c0392b; } .file-icon.ext-doc, .file-icon.ext-docx { background: #2b579a; }
.file-icon.ext-xls, .file-icon.ext-xlsx { background: #217346; } .file-icon.ext-ppt, .file-icon.ext-pptx { background: #c4532a; }
.file-icon.ext-heic { background: var(--purple); }

.info-list { display: grid; grid-template-columns: 128px 1fr; gap: 7px 12px; margin: 0; font-size: .92rem; }
.info-list dt { color: var(--ink-3); }
.info-list dd { margin: 0; }
.prose p { margin: 0 0 8px; }
.mini-h { font-size: .86rem; margin: 10px 0 4px; color: var(--ink-2); }
.approval { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px;
  background: #fdf6dc; border: 1px solid #f0d98a; }
.approval + .approval { margin-top: 8px; }
.approval.ok { background: #edf4ea; border-color: #c8dbc1; }
.approval small { display: block; color: var(--ink-2); }
.related-list { list-style: none; padding: 0; margin: 0; }
.related-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }

.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(15,15,15,.92); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: 88vw; max-height: 86vh; text-align: center; }
.lightbox img { max-width: 88vw; max-height: 78vh; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lightbox figcaption { color: #ddd; font-size: .88rem; margin-top: 10px; }
.lb-close { position: absolute; top: 12px; right: 18px; font-size: 2.2rem; color: #fff; background: none; border: 0; cursor: pointer; line-height: 1; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 2.6rem; color: #fff; background: rgba(255,255,255,.12);
  border: 0; width: 52px; height: 72px; border-radius: 8px; cursor: pointer; }
.lb-nav:hover { background: rgba(255,255,255,.24); }
.lb-prev { left: 14px; } .lb-next { right: 14px; }
.lb-download { position: absolute; bottom: 16px; right: 18px; color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 6px; padding: 6px 12px; font-size: .86rem; }

@media print {
  .no-print, .lightbox, details.add-box { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .detail-grid { display: block; }
  .detail-side { margin-top: 12px; }
  .detail-side > .card, .detail-main > .card { margin-top: 12px; }
  .summary-panel, .session-card, .approval, .doc-list li, .thumb { break-inside: avoid; }
  .card { border-color: #ccc; box-shadow: none; }
  .print-brand { display: flex !important; align-items: center; justify-content: space-between; gap: 12px;
    border-bottom: 3px solid var(--red); padding-bottom: 8px; margin-bottom: 12px; font-size: 11px; color: #555; }
  .print-brand img { width: 130px; height: auto; }
  .ring, .gbar-fill, .stat-accent, .file-icon, .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .gallery { grid-template-columns: repeat(4, 1fr); }
  a { color: inherit; }
}
.upload-boxes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
@media (max-width: 760px) { .upload-boxes { grid-template-columns: 1fr; } }
.upload-box { border: 1px dashed #cfcac2; border-radius: 8px; padding: 12px; background: #fcfbf9; }
.upload-box .field:last-child { margin-bottom: 0; }
.upload-box input[type=file] { width: 100%; font-size: .85rem; }

/* ===================== Documents repository ===================== */
.doc-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip-link { padding: 6px 12px; border-radius: 99px; border: 1px solid #d6d1c9; background: #fff; color: var(--ink-2); font-size: .86rem; text-decoration: none !important; }
.chip-link span { color: var(--ink-3); margin-left: 3px; font-size: .8rem; }
.chip-link.on { background: var(--charcoal); border-color: var(--charcoal); color: #fff; }
.chip-link.on span { color: #cfcfcf; }
.view-toggle { display: inline-flex; border: 1px solid #d6d1c9; border-radius: 8px; overflow: hidden; }
.view-toggle a { padding: 5px 12px; color: var(--ink-2); font-size: .86rem; text-decoration: none !important; background: #fff; }
.view-toggle a.on { background: var(--charcoal); color: #fff; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.doc-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.doc-card .thumb { width: 100%; border-radius: 0; }
.doc-tile { aspect-ratio: 4 / 3; display: grid; place-items: center; background: #f3f1ed; }
.file-icon.big { width: 64px; height: 76px; font-size: .9rem; }
.file-icon.small { width: 28px; height: 32px; font-size: .58rem; display: inline-grid; vertical-align: middle; border-radius: 4px; }
.doc-card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.doc-card-body .badge { align-self: flex-start; }
.doc-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-activity { font-size: .84rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-card-body small { color: var(--ink-3); }

.print-only { display: none; }
