/* Administration and sign-in screens — restrained, financial-software look. Tokens live in base.css. */
body.admin { background: #f6f5f0; font-size: .95rem; }
.admin-shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }

/* Sidebar */
.sidebar { background: var(--forest-950); background-image: var(--pattern-light); color: #cfded7; padding: 1rem 0 1.25rem; display: flex; flex-direction: column;
           position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none; padding: .35rem 1.15rem 1rem; font-weight: 800; }
.sidebar-brand:hover { color: #fff; }
.sidebar-brand .brand-mark { width: 34px; height: 34px; }
.sidebar-brand span { display: grid; line-height: 1.15; }
.sidebar-brand small { color: var(--gold-300); font-weight: 600; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.nav-section { margin: 1rem 1.15rem .35rem; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: #8fb0a3; }
.sidebar ul { list-style: none; margin: 0; padding: 0 .6rem; }
.sidebar a { display: block; padding: .48rem .7rem; color: #dbe7e2; text-decoration: none; border-radius: 8px; font-size: .92rem; }
.sidebar a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar a.active { background: rgba(255, 255, 255, .12); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--gold-500); }
.sidebar-foot { margin: auto 1.15rem 0; padding-top: 1rem; font-size: .85rem; }
.sidebar-foot a { padding: .3rem 0; color: #b8cfc5; }

/* Top bar */
.admin-main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 1rem; background: var(--surface); border-bottom: 1px solid var(--line); padding: .6rem 1.5rem; position: sticky; top: 0; z-index: 20; }
.topbar-search { flex: 1; max-width: 460px; position: relative; }
.topbar-search svg { position: absolute; inset-inline-start: .7rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--charcoal-faint); }
.topbar-search input { width: 100%; padding: .5rem .75rem .5rem 2.3rem; border: 1px solid var(--line); border-radius: 999px; background: var(--ivory); font: inherit; font-size: .9rem; }
.topbar-search input:focus { outline: none; border-color: var(--emerald-600); background: #fff; box-shadow: 0 0 0 3px rgba(31, 122, 90, .15); }
.topbar-user { display: flex; align-items: center; gap: .75rem; margin-inline-start: auto; }
.icon-link { position: relative; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--charcoal-soft); }
.icon-link:hover { background: var(--ivory); color: var(--forest-900); }
.icon-link svg { width: 21px; height: 21px; }
.icon-link .dot { position: absolute; top: 2px; inset-inline-end: 0; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; }
.user-chip { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--charcoal); font-weight: 600; font-size: .9rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--emerald-100); color: var(--forest-800); display: grid; place-items: center; font-size: .78rem; font-weight: 800; }
.inline { display: inline; }
.content { padding: 1.5rem 1.75rem 2.5rem; max-width: 1280px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 1.45rem; }
.nav-toggle { display: none; }

/* Cards and stats */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; box-shadow: var(--shadow-sm); }
.card h2 { margin-top: 0; font-size: 1.05rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card.narrow { max-width: 560px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.15rem; display: grid; gap: .3rem; box-shadow: var(--shadow-sm); position: relative; }
.stat-card.accent { border-top: 3px solid var(--gold-500); }
.stat-card.primary { border-top: 3px solid var(--emerald-600); }
.stat-label { color: var(--charcoal-soft); font-size: .84rem; font-weight: 500; }
.stat-value { font-size: 1.55rem; font-weight: 800; color: var(--forest-900); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-card a.small { font-weight: 600; text-decoration: none; }
.stat-card a.small:hover { text-decoration: underline; }

.dash-grid { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .dash-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); } }
.welcome { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; background: var(--forest-900); background-image: var(--pattern-light);
           color: #dbe7e2; border-radius: 14px; padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; }
.welcome h2 { color: #fff; margin: 0 0 .2rem; font-size: 1.2rem; }
.welcome p { margin: 0; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.task-list li:last-child { border-bottom: 0; }
.task-list a { text-decoration: none; font-weight: 600; }
.task-count { min-width: 2rem; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; padding: .1rem .55rem; border-radius: 999px; background: var(--warn-bg); color: #6b4600; }
.task-count.zero { background: var(--ivory); color: var(--charcoal-faint); font-weight: 600; }
.fund-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem 1rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.fund-row:last-child { border-bottom: 0; }
.fund-row .bar-track { grid-column: 1 / -1; height: .4rem; }
.fund-name { font-weight: 600; }
.fund-type { display: block; font-size: .78rem; color: var(--charcoal-faint); font-weight: 500; }

.toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; min-width: 160px; padding: .5rem .65rem; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: start; padding: .62rem .85rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: #faf9f5; font-weight: 600; white-space: nowrap; color: var(--charcoal-soft); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:hover { background: #fbfaf6; }
.table tbody tr:last-child td { border-bottom: 0; }
.card .table-wrap { border: 0; border-radius: 0; margin: 0 -1.4rem; }
.card .table th:first-child, .card .table td:first-child { padding-inline-start: 1.4rem; }
.card .table th:last-child, .card .table td:last-child { padding-inline-end: 1.4rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.span-2 { grid-column: span 2; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0 0 1rem; }
.details dt { color: var(--charcoal-soft); }
.details dd { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.perm-group { margin: 0; }
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form input { width: auto !important; }
.steps li { margin-bottom: .8rem; }
.secret-key code { font-size: 1.15rem; letter-spacing: .08em; padding: .4rem .6rem; display: inline-block; }
.result-group { margin-bottom: 1.25rem; }
.notif { display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: start; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.notif:last-child { border-bottom: 0; }
.notif .pip { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); margin-top: .45rem; }
.notif.unread .pip { background: var(--emerald-600); }
.notif p { margin: .15rem 0 0; color: var(--charcoal-soft); }

/* Sign-in pages */
body.auth { background-color: var(--forest-900); background-image: var(--pattern-light); min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { background: #fff; border-radius: 16px; padding: 2rem; width: 100%; max-width: 420px; box-shadow: 0 18px 40px rgba(0, 0, 0, .25); }
.auth-card h1 { font-size: 1.35rem; margin: .75rem 0 1rem; }
.auth-brand a { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--forest-900); text-decoration: none; }
.auth-brand .brand-mark { width: 34px; height: 34px; }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 50; box-shadow: var(--shadow-lg); }
  .sidebar.open { display: flex; }
  .nav-toggle { display: inline-flex; }
  .topbar { padding: .55rem 16px; gap: .5rem; }
  .user-name { display: none; }
  .content { padding: 1rem 16px 2rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .filters input, .filters select { min-width: 0; flex: 1 1 140px; }
  .card { padding: 1.1rem 1rem; }
  .card .table-wrap { margin: 0 -1rem; }
  .card .table th:first-child, .card .table td:first-child { padding-inline-start: 1rem; }
  .card .table th:last-child, .card .table td:last-child { padding-inline-end: 1rem; }
}

/* ---- Stage 3: content editing ---- */
.layout-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; align-items: start; }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .4rem; }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
.editor-preview { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; min-height: 200px; background: #fff; }
.editor-preview img { max-width: 100%; }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span { padding: .55rem .6rem; background: var(--bg-soft); border: 1px solid #b9c4bf; border-right: 0; border-radius: var(--radius) 0 0 var(--radius); color: var(--ink-soft); font-size: .85rem; white-space: nowrap; }
.input-prefix input { border-radius: 0 var(--radius) var(--radius) 0 !important; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.media-item { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.media-item img { display: block; width: 100%; height: 160px; object-fit: cover; background: var(--bg-soft); }
.media-item figcaption { padding: .6rem .8rem; }
.media-item p { margin: .2rem 0; }
.copy-field { width: 100%; font-size: .8rem; padding: .3rem; border: 1px solid var(--line); border-radius: 4px; }
.tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: #fff; }
.tabs a[aria-current="page"] { background: var(--green-700); color: #fff; border-color: var(--green-700); }
.row-strong td { font-weight: 600; }
.message-body { white-space: normal; background: var(--bg-soft); padding: 1rem; border-radius: var(--radius); }
.add-row { margin-top: 1rem; }
.add-field { margin-top: 1rem; }
.add-field > summary { display: inline-block; list-style: none; margin-bottom: 1rem; }
.add-field > summary::-webkit-details-marker { display: none; }
@media (max-width: 1000px) { .layout-main-side { grid-template-columns: 1fr; } }

/* ---- Stage 4a ---- */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1.25rem; }
.grid-2.gap { gap: 1.25rem; }
.grid-2.gap > .card { margin-bottom: 0; }
.grid-2.gap + * { margin-top: 1.25rem; }
.badge-lg { font-size: .9rem; padding: .25rem .7rem; }
.status-approved, .status-completed, .status-disbursed, .donation-confirmed { background: var(--success-bg); border-color: #b7dfc7; }
.status-rejected, .donation-cancelled, .donation-failed { background: var(--danger-bg); border-color: #f3b9b3; }
.status-submitted, .status-under_review, .status-recommended, .donation-pending { background: var(--info-bg); border-color: #bcd4ef; }
.status-info_required { background: var(--warn-bg); border-color: #f0d79b; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 .9rem .9rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--green-700); }
.timeline p { margin: .25rem 0 0; }
.assessment { border-bottom: 1px solid var(--line); padding: .5rem 0; }
.assessment p { margin: .25rem 0; }
.alert-box { border-color: #f0d79b; background: var(--warn-bg); }
.cards.compact { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin: 0; }
.check.inline { display: inline-flex; margin-right: 1.25rem; }
.label { display: block; font-weight: 600; margin-bottom: .3rem; }
.guidance { margin-bottom: 1rem; }
.upload-form { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.actions form { display: inline; }
@media (max-width: 860px) { .grid-3 { grid-template-columns: 1fr; } }

/* ---- Stage 4b ---- */
details.record { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: .6rem; background: #fff; }
details.record > summary { cursor: pointer; }
details.record[open] > summary { margin-bottom: .8rem; }
progress { width: 90px; height: .7rem; vertical-align: middle; accent-color: var(--green-700); }

/* ---- Stage 5: finance ---- */
.table.num td, .table.num th { text-align: right; white-space: nowrap; }
.table.num td.text, .table.num th.text, .table.num td:first-child, .table.num th:first-child { text-align: left; white-space: normal; }
.link-card { text-decoration: none; color: inherit; }
.link-card:hover { border-color: var(--green-600); }
.disb-pending { background: var(--info-bg); border-color: #bcd4ef; }
.disb-posted { background: var(--success-bg); border-color: #b7dfc7; }
.disb-rejected, .disb-cancelled { background: var(--danger-bg); border-color: #f3b9b3; }
.je-draft { background: var(--warn-bg); border-color: #f0d79b; }
.je-posted { background: var(--success-bg); border-color: #b7dfc7; }
.je-reversed { background: var(--bg-soft); }
.journal-lines select, .journal-lines input { width: 100%; min-width: 120px; padding: .35rem .45rem; border: 1px solid #b9c4bf; border-radius: 6px; font: inherit; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
@media print {
  .sidebar, .topbar, .tabs, .toolbar, .no-print { display: none !important; }
  .admin-shell { display: block; }
  .card { box-shadow: none; border: 0; }
}
