:root {
    color-scheme: light;
    font-family: system-ui, sans-serif;
    color: #17212d;
    background: #edf2f4;
    --ink: #18392f;
    --accent: #176351;
    --line: #d6e2df;
}
* { box-sizing: border-box; }
body, h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.45rem, 4vw, 2rem); }
h2 { font-size: 1.1rem; }
a { color: inherit; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 15rem minmax(0, 1fr); }
.sidebar { background: var(--ink); color: #fff; padding: 1.4rem; }
.brand { display: block; font-size: 1.15rem; font-weight: 750; text-decoration: none; overflow-wrap: anywhere; }
.navigation { margin-top: 1.4rem; }
.navigation summary { cursor: pointer; padding: .5rem; }
nav { display: grid; gap: .35rem; }
nav a, .nav-button { display: block; width: 100%; font: inherit; padding: .7rem; text-align: left; text-decoration: none; border-radius: .45rem; }
nav a:hover, nav a[aria-current], .nav-button:hover { background: #2a5649; }
.nav-button { background: transparent; }
.content { display: grid; align-content: start; gap: 1rem; padding: clamp(1rem, 3vw, 2rem); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; font-weight: 700; }
.badge { color: var(--ink); background: #cfebe0; border-radius: 2rem; padding: .35rem .75rem; font-size: .8rem; }
.surface { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: .8rem; padding: 1.25rem; }
.hero { background: #dceee7; overflow-wrap: anywhere; }
.surface p { margin-top: .45rem; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.metric p { color: #52645f; font-size: .875rem; }
.profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(100%, 25rem); }
.login-card h1 { margin-top: 1rem; }
.fields { display: grid; gap: .8rem; margin-top: 1rem; }
.fields label { display: grid; gap: .3rem; font-weight: 600; }
input { width: 100%; min-width: 0; padding: .65rem; font: inherit; border: 1px solid #83958d; border-radius: .35rem; }
button { cursor: pointer; padding: .65rem .9rem; background: var(--accent); color: #fff; font: inherit; font-weight: 650; border: 0; border-radius: .45rem; }
:focus-visible { outline: 3px solid #c48619; outline-offset: 2px; }
.error { color: #a22136; }
@media (max-width: 1024px) {
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .navigation { margin-top: .5rem; }
    .cards { grid-template-columns: minmax(0, 1fr); }
}
.joining-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.report-search { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; align-items: end; }
.fields select { width: 100%; background: #fff; padding: .65rem; font: inherit; border: 1px solid #83958d; border-radius: .35rem; }
.table-scroll { overflow-x: auto; margin-top: 1rem; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
th, td { padding: .65rem .8rem; border-bottom: 1px solid var(--line); }
th { background: #e4f0eb; }
.report-pagination { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.report-pagination a { width: auto; }
.report-pagination a:hover { color: #fff; }
@media (max-width: 700px) {
    .joining-fields, .report-search { grid-template-columns: minmax(0, 1fr); }
}
.section-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .75rem; }
.section-heading a { color: var(--accent); font-weight: 650; }
.referral-list { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: .55rem; }
.referral-list li { display: grid; gap: .2rem; overflow-wrap: anywhere; background: #edf5f2; border-radius: .45rem; padding: .65rem; }
.referral-list time { font-size: .85rem; color: #52645f; }
@media (max-width: 700px) {
    .sidebar { padding: .85rem 1rem; }
    .sidebar nav a, .sidebar nav button { height: 100%; padding: .55rem; }
}

/* Keep report overflow inside its scroll region rather than widening the page. */
.content { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.topbar, .surface { overflow-wrap: anywhere; }
.table-scroll { max-width: 100%; }
.table-scroll form { white-space: normal; min-width: 10rem; }
.table-scroll td button { margin-block: .2rem; }
.fields label, .fields select { min-width: 0; }
.fields button { min-height: 2.75rem; }
.navigation-group h2 { margin: .75rem .65rem .25rem; font-size: .85rem; color: #cbe4d9; }
.navigation-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
.navigation-group a { overflow-wrap: anywhere; }
.skip-link { position: fixed; top: .5rem; left: .5rem; transform: translateY(-150%); z-index: 2; background: #fff; padding: .75rem; }
.skip-link:focus { transform: none; }
.content:focus { outline: none; }
@media (max-width: 700px) {
    .navigation summary { min-height: 2.75rem; padding: .65rem; border: 1px solid #63877a; border-radius: .45rem; }
    .sidebar nav { grid-template-columns: minmax(0, 1fr); margin-top: .65rem; }
    .navigation-group ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sidebar nav a, .sidebar nav button { min-height: 2.75rem; }
    .surface { padding: 1rem; }
}
