/*
 * National Peanut Board brand palette, taken from the tokens published on
 * nationalpeanutboard.org (theme: peanutsusa).
 */

:root {
    /* Brand */
    --green: #0fbc9b;
    --green-light: #13d3ae;
    --green-dark: #10997f;
    --peanut-butter: #bc883e;
    --peanut-butter-light: #d39448;
    --peanut-butter-dark: #996a36;
    --roasted: #3d2f2a;
    --soft-white: #f8efda;
    --soft-white-light: #fffef5;
    --soft-white-dark: #d6cfc1;
    --flower: #fdc851;
    --white: #fff;

    /* Applied roles */
    --bg: var(--soft-white-light);
    --surface: var(--white);
    --border: var(--soft-white-dark);
    --text: var(--roasted);
    --muted: #7a6a63;
    --danger: #b3261e;
    --danger-dark: #8f1e18;
    --danger-bg: #fdeceb;
    --radius: 10px;

    --font-head: Figtree, "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-body: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.6 var(--font-body);
}

h1,
h2,
h3,
.brand-lg {
    font-family: var(--font-head);
    font-weight: 800;
    letter-spacing: -0.01em;
}

/* ---------- top bar ---------- */

/* The bar sits on the page rather than floating above it: no fill, one hairline. */
#topbar {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 0 32px;
    height: 76px;
    background: transparent;
    border-bottom: 1px solid var(--border);
}

/*
 * An id selector with `display: flex` outranks the browser's default
 * `[hidden] { display: none }`, so the bar has to be hidden explicitly —
 * otherwise it shows on the login page, complete with a "Log out" button.
 */
#topbar[hidden],
[hidden] {
    display: none !important;
}

#topbar .brand img {
    display: block;
    height: 34px;
    width: auto;
}

#topbar nav {
    display: flex;
    gap: 4px;
    flex: 1;
}

#topbar nav a {
    padding: 8px 14px;
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-family: var(--font-head);
}

#topbar nav a:hover {
    background: var(--soft-white);
    color: var(--roasted);
}

#topbar nav a.active {
    background: var(--green);
    color: var(--roasted);
}

#topbar .session {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
    font-size: 14px;
}

#topbar .account {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    transition: background .15s ease;
}

#topbar .account:hover {
    background: var(--soft-white);
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--roasted);
    color: var(--soft-white);
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 13px;
    letter-spacing: .02em;
    flex: none;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.avatar-lg {
    width: 84px;
    height: 84px;
    font-size: 28px;
}

/* The camera button rides the rim of the photo. */
.avatar-edit {
    position: relative;
    flex: none;
}

.photo-btn {
    position: absolute;
    right: -2px;
    bottom: -2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid var(--bg);
    background: var(--green);
    color: var(--roasted);
    cursor: pointer;
    transition: background .15s ease;
}

.photo-btn:hover {
    background: var(--green-light);
}

.link-btn {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-size: 13px;
    color: var(--muted);
    text-decoration: underline;
    cursor: pointer;
}

.link-btn:hover {
    color: var(--danger);
}

/* Visible to screen readers only. */
.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- profile ---------- */

.profile-head {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 28px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.profile-name {
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 22px;
    margin: 0;
}

.profile-mail {
    color: var(--muted);
    margin: 2px 0 10px;
}

.profile-tags {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-meta {
    margin: 0 0 0 auto;
    text-align: right;
}

.profile-meta dt:first-child {
    margin-top: 0;
}

/*
 * Two equal columns. Needs to out-rank .work-grid's 300px sidebar track, which is
 * defined later in this file — hence the doubled class, not a bare .profile-grid.
 */
.work-grid.profile-grid {
    grid-template-columns: 1fr 1fr;
    gap: 56px;
}

.work-grid.profile-grid .panel {
    max-width: 420px;
}

@media (max-width: 900px) {
    .profile-head {
        flex-wrap: wrap;
    }

    .profile-meta {
        margin-left: 0;
        text-align: left;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }
}

.hint {
    color: var(--muted);
    font-size: 13px;
    margin: 8px 0 16px;
}

/* Section labels can carry a small leading icon. */
.section-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-label .icon {
    color: var(--peanut-butter-dark);
}

/* ---------- layout ---------- */

main {
    max-width: 1320px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

h1 {
    font-size: 26px;
    margin: 0 0 4px;
}

.subtitle {
    color: var(--muted);
    margin: 0 0 24px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 26px;
    margin-bottom: 18px;
    box-shadow: 0 1px 2px rgba(61, 47, 42, .04);
}

.row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.muted {
    color: var(--muted);
}

.empty {
    text-align: center;
    padding: 48px 16px;
    color: var(--muted);
}

a {
    color: var(--green-dark);
}

/* ---------- login ---------- */

.login-wrap {
    max-width: 400px;
    margin: 7vh auto;
}

.login-wrap .brand-lg {
    text-align: center;
    margin-bottom: 28px;
}

.login-wrap .brand-lg img {
    width: 260px;
    max-width: 100%;
}

.login-wrap .brand-lg .tag {
    display: block;
    margin-top: 10px;
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 14px;
    color: var(--muted);
    letter-spacing: 0;
}

/* ---------- forms ---------- */

label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin: 0 0 6px;
    font-family: var(--font-head);
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: var(--white);
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--green);
    outline-offset: -1px;
    border-color: var(--green);
}

textarea {
    min-height: 92px;
    resize: vertical;
}

.field {
    margin-bottom: 16px;
}

/*
 * Buttons follow the site's own .btn-green token: roasted text on green,
 * lightening on hover. Dark-on-green also clears WCAG AA, which white-on-green
 * would not.
 */
.btn {
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 999px;
    font: inherit;
    font-family: var(--font-head);
    font-weight: 700;
    cursor: pointer;
    background: var(--green);
    color: var(--roasted);
    transition: background .15s ease;
}

.btn:hover {
    background: var(--green-light);
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-block {
    width: 100%;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: var(--danger-dark);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--soft-white);
    color: var(--roasted);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 13px;
}

/* ---------- table ---------- */

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 15px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    font-family: var(--font-head);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    padding-top: 0;
}

/* Timestamps line up column-wise, so equal-width digits are right here. */
td.when {
    font-size: 13px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--soft-white-light);
}

/* ---------- badges ---------- */

/*
 * Quiet status chips: a tinted wash with the status hue as a hairline, so they
 * read as annotation rather than as loud filled pills.
 */
.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-family: var(--font-head);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    white-space: nowrap;
}

.badge-PENDING {
    background: #fef4de;
    border-color: var(--flower);
    color: #8a6410;
}

.badge-APPROVED,
.badge-ACTIVE {
    background: #e4f8f3;
    border-color: var(--green);
    color: var(--green-dark);
}

.badge-REJECTED,
.badge-DISABLED {
    background: var(--danger-bg);
    border-color: #e8b3af;
    color: var(--danger);
}

.badge-SUPER_ADMIN {
    background: var(--peanut-butter);
    color: var(--white);
}

.badge-USER {
    background: var(--soft-white);
    color: var(--peanut-butter-dark);
}

/* ---------- editorial page ---------- */

/*
 * The agreements page has no cards. Sections are separated by hairline rules and
 * whitespace — the type does the structuring, so nothing is boxed inside a box.
 */
/*
 * A short accent stroke instead of a rule across the whole page — the heavy
 * full-width line read as a divider bar rather than as part of the heading.
 */
.masthead {
    padding-bottom: 26px;
    margin-bottom: 0;
}

.masthead::before {
    content: "";
    display: block;
    width: 44px;
    height: 3px;
    border-radius: 2px;
    background: var(--green);
    margin-bottom: 18px;
}

.masthead h1 {
    font-size: 40px;
    line-height: 1.1;
    margin: 0 0 6px;
}

.masthead .subtitle {
    margin: 0;
    max-width: 60ch;
}

.section-label {
    font-family: var(--font-head);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--muted);
    margin: 0 0 18px;
}

/* ---------- KPI band ---------- */

.kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

@media (max-width: 720px) {
    .kpis {
        grid-template-columns: repeat(2, 1fr);
    }
}

/*
 * Each figure is a filter, so it is a real <button>: keyboard-reachable, and the
 * active one is marked with aria-pressed rather than by colour alone.
 */
.kpi {
    position: relative;
    display: block;
    text-align: left;
    font: inherit;
    cursor: pointer;
    background: none;
    border: none;
    border-left: 1px solid var(--border);
    border-radius: 0;
    padding: 26px 0 26px 22px;
    transition: background .15s ease;
}

.kpi:first-child {
    border-left: none;
    padding-left: 0;
}

.kpi:hover {
    background: var(--soft-white);
}

/* Active reads as a rule drawn under the figure — no box, no fill. */
.kpi::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: transparent;
}

.kpi[aria-pressed="true"]::after {
    background: var(--roasted);
}

/*
 * The icon is the only thing wearing the status hue; it sits in a soft tinted
 * disc so a light colour like the flower yellow still reads on cream.
 */
.kpi .ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    margin-bottom: 16px;
}

.ico-ALL {
    background: #f4ece0;
    color: var(--peanut-butter-dark);
}

.ico-PENDING {
    background: #fef4de;
    color: #8a6410;
}

.ico-APPROVED {
    background: #e4f8f3;
    color: var(--green-dark);
}

.ico-REJECTED {
    background: var(--danger-bg);
    color: var(--danger);
}

/* Proportional figures — equal-width digits make a big number look loose. */
.kpi .n {
    display: block;
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 42px;
    line-height: 1;
    color: var(--text);
}

.kpi .k {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: var(--muted);
}

/* The dot carries the status hue; the word beside it carries the meaning. */
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: none;
}

.dot-PENDING {
    background: var(--flower);
}

.dot-APPROVED {
    background: var(--green);
}

.dot-REJECTED {
    background: var(--danger);
}

.dot-ALL {
    background: var(--peanut-butter);
}

/* ---------- agreement list ---------- */

.agreements {
    list-style: none;
    margin: 0;
    padding: 0;
}

.agreements li {
    border-bottom: 1px solid var(--border);
}

.agreements a.entry {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 18px;
    padding: 20px 14px 20px 0;
    text-decoration: none;
    color: inherit;
    transition: background .15s ease, padding-left .15s ease;
}

.agreements a.entry:hover {
    background: var(--soft-white);
    padding-left: 14px;
}

.entry .no {
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 19px;
    letter-spacing: -0.01em;
    color: var(--text);
}

.entry .who {
    margin-top: 3px;
    font-size: 13.5px;
    color: var(--muted);
}

.entry .side {
    display: flex;
    align-items: center;
    gap: 18px;
}

.entry .when {
    font-size: 13px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .entry .when {
        display: none;
    }
}

/* ---------- charts ---------- */

/* Charts down the left, the agreement list down the right — divided by a rule. */
.work-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 48px;
    align-items: start;
    margin-top: 44px;
}

.work-grid > aside {
    border-right: 1px solid var(--border);
    padding-right: 48px;
}

@media (max-width: 1000px) {
    .work-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .work-grid > aside {
        border-right: none;
        padding-right: 0;
    }
}

/* Only stack panels that sit in the same column — grid siblings are already apart. */
aside .panel + .panel {
    margin-top: 44px;
}

.chart-note {
    color: var(--muted);
    font-size: 13px;
    margin: -8px 0 18px;
}

.chart svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

/*
 * The share bar is stretched horizontally on purpose (preserveAspectRatio="none"),
 * so its height must be pinned — `height: auto` would scale it with the card's
 * width and render a fat block instead of a bar.
 */
.chart svg.share-bar {
    height: 22px;
}

/* Identity lives in the dot + the word, never in the colour of the text. */
.legend {
    margin-top: 18px;
    font-size: 13px;
    color: var(--muted);
}

.legend .key {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
}

.legend .key:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.legend .key .name {
    flex: 1;
}

.legend .key .count {
    font-family: var(--font-head);
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.legend .key .pct {
    width: 42px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.axis-label {
    font-family: var(--font-body);
    font-size: 11px;
    fill: var(--muted);
}

.bar-label {
    font-family: var(--font-head);
    font-size: 11px;
    font-weight: 700;
    fill: var(--text);
}

.gridline {
    stroke: var(--border);
    stroke-width: 1;
}

/* ---------- agreement detail ---------- */

.pdf-frame {
    width: 100%;
    height: 640px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 18px;
    align-items: start;
}

@media (max-width: 900px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .pdf-frame {
        height: 460px;
    }

    #topbar {
        gap: 12px;
        padding: 0 12px;
    }

    #topbar .session span {
        display: none;
    }
}

.meta dt {
    font-family: var(--font-head);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    margin-top: 14px;
}

.meta dd {
    margin: 2px 0 0;
}

.timeline {
    list-style: none;
    padding: 0;
    margin: 0;
}

.timeline li {
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.timeline li:last-child {
    border-bottom: none;
}

/* ---------- misc ---------- */

.error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 11px 13px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

#toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--roasted);
    color: var(--soft-white-light);
    padding: 13px 22px;
    border-radius: 999px;
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(61, 47, 42, .22);
    z-index: 50;
}

#toast.error-toast {
    background: var(--danger);
    color: var(--white);
}
