/* ADRA Foundations — styles based on the adra.org brand palette */
:root {
    --adra-green: #007B5F;
    --adra-green-dark: #004230;
    --adra-green-mid: #3A957F;
    --adra-green-light: #B5D7CF;
    --adra-green-tint: #E6F2EF;
    --adra-olive: #789D4A;
    --adra-yellow: #E9AA22;
    --adra-orange: #E57200;
    --adra-red: #B30031;
    --ink: #1d1f20;
    --ink-soft: #54585A;
    --muted: #8a8d8f;
    --line: #D9D9D6;
    --line-soft: #EEEEEF;
    --bg: #F8F8F8;
    --card: #FFFFFF;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,66,48,.06);
    --font-head: "Montserrat", Helvetica, Arial, sans-serif;
    --font-body: "Open Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font-body); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--adra-green); text-decoration: none; }
a:hover { color: var(--adra-green-dark); text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--ink); line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
small, .muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line-soft); margin: 1.25rem 0; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 1000; height: 60px; display: flex; align-items: center; gap: 12px;
    padding: 0 18px; background: var(--adra-green-dark); color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.brand:hover { text-decoration: none; color: #fff; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-app { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; letter-spacing: .02em;
    padding-left: 12px; border-left: 1px solid rgba(255,255,255,.35); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar-link { color: #fff; font-size: .85rem; opacity: .85; }
.topbar-link:hover { color: #fff; opacity: 1; }
.icon-btn { position: relative; color: #fff; display: inline-flex; padding: 6px; border-radius: 8px; }
.icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.dot-count { position: absolute; top: 0; right: -2px; background: var(--adra-orange); color: #fff; font-size: 10px;
    font-weight: 700; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; cursor: pointer; padding: 4px; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .88rem; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary small { display: block; opacity: .75; font-size: .75rem; color: #fff; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--adra-green); color: #fff; display: grid;
    place-items: center; font-family: var(--font-head); font-weight: 700; border: 2px solid rgba(255,255,255,.4); }
.user-menu-panel { position: absolute; right: 0; top: 46px; background: #fff; border-radius: 8px; box-shadow: var(--shadow);
    min-width: 180px; padding: 6px; border: 1px solid var(--line); }
.user-menu-panel a, .user-menu-panel button { display: block; width: 100%; text-align: left; padding: 8px 10px; color: var(--ink);
    background: none; border: 0; font: inherit; cursor: pointer; border-radius: 6px; }
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--adra-green-tint); text-decoration: none; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: calc(100vh - 60px - 48px); }
.sidebar { width: 236px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line-soft); padding: 18px 12px;
    display: flex; flex-direction: column; gap: 2px; position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; }
.sidebar a { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: 8px;
    color: var(--ink-soft); font-weight: 600; font-size: .92rem; }
.sidebar a:hover { background: var(--adra-green-tint); color: var(--adra-green-dark); text-decoration: none; }
.sidebar a.is-active { background: var(--adra-green); color: #fff; }
.sidebar .nav-cta { margin-top: 10px; border: 1.5px dashed var(--adra-green-light); color: var(--adra-green); justify-content: center; }
.nav-section { margin: 18px 12px 6px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.nav-foot { margin-top: auto; padding: 12px; }
.role-tag { font-size: .75rem; background: var(--line-soft); padding: 3px 8px; border-radius: 20px; color: var(--ink-soft); }
.main { flex: 1; min-width: 0; padding: 26px 30px 40px; }
.footer { height: 48px; display: flex; align-items: center; justify-content: center; font-size: .78rem; color: var(--muted);
    border-top: 1px solid var(--line-soft); background: #fff; }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--ink-soft); margin: 4px 0 0; }
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards & grids ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line-soft); padding: 20px; }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border-radius: var(--radius); padding: 16px 18px; border: 1px solid var(--line-soft); box-shadow: var(--shadow);
    border-top: 4px solid var(--adra-green); }
.kpi .kpi-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.kpi .kpi-value { font-family: var(--font-head); font-size: 1.75rem; font-weight: 800; color: var(--adra-green-dark); line-height: 1.2; margin-top: 4px; }
.kpi .kpi-note { font-size: .8rem; color: var(--ink-soft); }
.kpi.k-warn { border-top-color: var(--adra-yellow); }
.kpi.k-free { border-top-color: var(--line); }
.kpi.k-money { border-top-color: var(--adra-olive); }

/* ---------- Map ---------- */
#map { height: 430px; border-radius: 8px; border: 1px solid var(--line-soft); z-index: 1; }
.map-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: .8rem; color: var(--ink-soft); margin-top: 10px; }
.map-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.leaflet-popup-content { font-family: var(--font-body); font-size: .85rem; }
.leaflet-popup-content h4 { margin: 0 0 6px; font-size: .95rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700;
    padding: 10px 12px; border-bottom: 2px solid var(--line-soft); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tr:hover td { background: #fbfcfb; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .name a { font-weight: 600; color: var(--ink); }
.table .name a:hover { color: var(--adra-green); }
.table .meta { font-size: .8rem; color: var(--muted); }
tr.row-handled td:first-child { box-shadow: inset 4px 0 0 var(--adra-green); }
tr.row-pending td:first-child { box-shadow: inset 4px 0 0 var(--adra-yellow); }
tr.row-mine td:first-child { box-shadow: inset 4px 0 0 var(--adra-green-dark); }

/* ---------- Status badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-free { background: var(--line-soft); color: var(--ink-soft); }
.badge-active { background: var(--adra-green-tint); color: var(--adra-green-dark); }
.badge-mine { background: var(--adra-green); color: #fff; }
.badge-pending { background: #fdf3dc; color: #8a5a00; }
.badge-rejected, .badge-overdue { background: #f9e3e8; color: var(--adra-red); }
.badge-closed, .badge-withdrawn { background: var(--line-soft); color: var(--muted); }
.badge-received { background: var(--adra-green-tint); color: var(--adra-green-dark); }
.badge-pledged { background: #fdf3dc; color: #8a5a00; }
.badge-cancelled { background: var(--line-soft); color: var(--muted); }
.pill { display: inline-block; min-width: 20px; text-align: center; padding: 1px 7px; border-radius: 10px; font-size: .72rem; font-weight: 700; }
.pill-warn { background: var(--adra-orange); color: #fff; }
.tag { display: inline-block; background: var(--adra-green-tint); color: var(--adra-green-dark); font-size: .75rem; padding: 2px 9px;
    border-radius: 14px; margin: 0 4px 4px 0; font-weight: 600; }

/* ---------- Engagement banner ---------- */
.banner { border-radius: var(--radius); padding: 16px 20px; margin-bottom: 18px; display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.banner h3 { margin: 0 0 4px; }
.banner p { margin: 0; }
.banner .banner-body { flex: 1; min-width: 240px; }
.banner-free { background: #fff; border: 1.5px dashed var(--adra-green-light); }
.banner-active { background: var(--adra-green-tint); border: 1px solid var(--adra-green-light); }
.banner-mine { background: var(--adra-green); color: #fff; }
.banner-mine h3, .banner-mine a { color: #fff; }
.banner-pending { background: #fdf6e6; border: 1px solid #f1d899; }
.banner-lock { background: #fff4f0; border: 1px solid #f3c9b4; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field label, .label { display: block; font-size: .8rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 5px; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date], input[type=search], select, textarea {
    width: 100%; font: inherit; font-size: .92rem; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--adra-green); box-shadow: 0 0 0 3px rgba(0,123,95,.15); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; font-size: .9rem; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; }
fieldset { border: 0; padding: 0; margin: 0 0 22px; }
legend { font-family: var(--font-head); font-weight: 700; font-size: 1rem; margin-bottom: 12px; padding: 0; color: var(--adra-green-dark); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }
.filters { display: grid; grid-template-columns: 2fr repeat(5, minmax(0, 1fr)) auto; gap: 10px; align-items: end; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-family: var(--font-head); font-weight: 700;
    font-size: .85rem; padding: 9px 16px; border-radius: 7px; border: 1.5px solid var(--adra-green); background: var(--adra-green);
    color: #fff; cursor: pointer; white-space: nowrap; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--adra-green-dark); border-color: var(--adra-green-dark); color: #fff; text-decoration: none; }
.btn-outline { background: #fff; color: var(--adra-green); }
.btn-outline:hover { background: var(--adra-green-tint); color: var(--adra-green-dark); }
.btn-light { background: #fff; color: var(--adra-green-dark); border-color: #fff; }
.btn-light:hover { background: var(--adra-green-tint); color: var(--adra-green-dark); border-color: var(--adra-green-tint); }
.btn-danger { background: #fff; color: var(--adra-red); border-color: #e7b3c1; }
.btn-danger:hover { background: var(--adra-red); color: #fff; border-color: var(--adra-red); }
.btn-warn { background: var(--adra-orange); border-color: var(--adra-orange); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-link { background: none; border: 0; color: var(--adra-green); font: inherit; cursor: pointer; padding: 0; font-weight: 600; }
.inline { display: inline; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; font-size: .9rem; border-left: 4px solid; }
.flash-success { background: var(--adra-green-tint); color: var(--adra-green-dark); border-color: var(--adra-green); }
.flash-error { background: #fbeaee; color: var(--adra-red); border-color: var(--adra-red); }
.flash-warning { background: #fdf3dc; color: #7a5000; border-color: var(--adra-yellow); }
.flash-info { background: #eef4f8; color: #24506b; border-color: #4a8bb3; }

/* ---------- Detail lists, timelines ---------- */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; font-size: .9rem; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; border-left: 2px solid var(--line-soft); margin-left: 7px; }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -8px; top: 2px; width: 14px; height: 14px; border-radius: 50%;
    background: #fff; border: 3px solid var(--adra-green); }
.timeline .t-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.timeline .t-date { font-size: .8rem; color: var(--muted); }
.timeline .t-body { font-size: .9rem; color: var(--ink-soft); margin-top: 4px; white-space: pre-line; }
.next-step { margin-top: 6px; font-size: .85rem; background: #fdf6e6; border-radius: 6px; padding: 6px 10px; display: inline-flex; gap: 10px; align-items: center; }
.next-step.done { background: var(--line-soft); text-decoration: line-through; color: var(--muted); }
.contact-card { border: 1px solid var(--line-soft); border-radius: 8px; padding: 12px 14px; }
.contact-card + .contact-card { margin-top: 10px; }
.contact-card .c-name { font-weight: 700; }
.private-note { font-size: .78rem; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.empty { color: var(--muted); font-size: .9rem; text-align: center; padding: 18px 8px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 9px 0; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.list-plain li:last-child { border-bottom: 0; }
.bar-row { display: grid; grid-template-columns: 52px 1fr 90px; gap: 10px; align-items: center; font-size: .85rem; margin-bottom: 8px; }
.bar-track { background: var(--line-soft); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { background: var(--adra-green); height: 100%; border-radius: 4px; }
details.panel { border: 1px solid var(--line-soft); border-radius: 8px; padding: 0 14px; margin-top: 12px; background: #fff; }
details.panel > summary { cursor: pointer; padding: 12px 0; font-weight: 700; font-family: var(--font-head); font-size: .9rem; color: var(--adra-green); }
details.panel[open] > summary { border-bottom: 1px solid var(--line-soft); margin-bottom: 14px; }
details.panel > *:last-child { margin-bottom: 14px; }
.dup-box { margin-top: 8px; border: 1px solid #f1d899; background: #fdf6e6; border-radius: 8px; padding: 10px 12px; font-size: .85rem; }
.dup-box ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 11px; border-radius: 6px; border: 1px solid var(--line); font-size: .85rem; color: var(--ink-soft); background: #fff; }
.pagination .current { background: var(--adra-green); color: #fff; border-color: var(--adra-green); }

/* ---------- Auth ---------- */
body.bare { background: var(--adra-green-dark); }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-brand { color: #fff; padding: 10vh 8vw; display: flex; flex-direction: column; justify-content: center;
    background: linear-gradient(160deg, var(--adra-green) 0%, var(--adra-green-dark) 100%); }
.auth-brand h1 { color: #fff; font-size: 2.6rem; margin: 28px 0 10px; }
.auth-brand p { opacity: .85; max-width: 420px; font-size: 1.05rem; }
.auth-logo { width: 220px; }
.auth-card { background: #fff; padding: 10vh 7vw; display: flex; flex-direction: column; justify-content: center; }
.auth-card form { max-width: 380px; width: 100%; }
.auth-card .field { margin-bottom: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .filters .f-q { grid-column: 1 / -1; }
    .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .nav-toggle { display: inline-flex; }
    .sidebar { position: fixed; left: 0; top: 60px; z-index: 999; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
    .sidebar.open { transform: none; }
    .main { padding: 18px 16px 30px; }
    .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
    .hide-sm { display: none; }
    .brand-app { display: none; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-brand { padding: 40px 24px; }
    .auth-brand h1 { font-size: 1.8rem; }
    .auth-card { padding: 30px 24px; }
    .dl { grid-template-columns: 1fr; gap: 2px; }
    .dl dd { margin-bottom: 8px; }
    .filters { grid-template-columns: 1fr 1fr; }
    #map { height: 320px; }
}
