:root {
    --bg: #ffffff;
    --ink: #26231d;
    --ink-soft: #6e6759;
    --line: #dfd8c9;
    --accent: #2e6653;
    --accent-soft: #e2efe8;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Manrope", "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.55;
}

.bg-layer {
    display: none;
}

.app-shell {
    width: 100vw;
    min-height: 100vh;
    margin: 0;
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr;
    gap: 0;
    align-items: stretch;
}

.sidebar,
.content-panel {
    background: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.sidebar {
    position: sticky;
    top: 0;
    max-height: 100vh;
    padding: 1.1rem 1rem 1rem;
    overflow: auto;
    border-right: 1px solid var(--line);
}

.sidebar-header h1 {
    margin: 0.4rem 0 0.3rem;
    font-family: "Newsreader", Georgia, serif;
    font-size: clamp(1.35rem, 2vw, 1.9rem);
    line-height: 1.2;
}

.subhead {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.eyebrow {
    margin: 0;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
    font-size: 0.72rem;
    color: var(--ink-soft);
}

.search-wrap,
.lead-filter-wrap {
    margin-top: 0.9rem;
    display: grid;
    gap: 0.35rem;
    font-size: 0.84rem;
    color: var(--ink-soft);
}

.search-wrap input,
.lead-filter-wrap select {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--line);
    font: inherit;
    padding: 0.48rem 0.7rem;
    color: var(--ink);
    background: #fff;
}

.search-wrap input:focus,
.lead-filter-wrap select:focus {
    outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
    border-color: var(--accent);
}

.lead-filter-wrap small {
    font-size: 0.76rem;
    color: #7b7364;
    line-height: 1.2;
}

.table-actions {
    margin-top: 0.9rem;
    display: grid;
    gap: 0.35rem;
}

.table-actions button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 9px;
    padding: 0.42rem 0.62rem;
    text-align: left;
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}

.table-actions button:hover {
    border-color: color-mix(in srgb, var(--accent) 65%, var(--line));
    background: var(--accent-soft);
}

.toc-list {
    margin: 0.9rem 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0.14rem;
}

.toc-list li {
    --toc-level: 1;
    position: relative;
    padding-left: calc((var(--toc-level) - 1) * 0.72rem);
}

.toc-list li::before {
    content: "";
    position: absolute;
    left: calc((var(--toc-level) - 1) * 0.72rem + 0.12rem);
    top: 50%;
    width: 0.34rem;
    height: 1px;
    background: color-mix(in srgb, var(--ink-soft) 50%, transparent);
    transform: translateY(-50%);
}

.toc-list li a {
    display: block;
    border-radius: 8px;
    text-decoration: none;
    color: var(--ink);
    padding: 0.26rem 0.48rem;
    font-size: 0.84rem;
}

.toc-list li a:hover,
.toc-list li a:focus {
    background: var(--accent-soft);
}

.toc-list li[style*="--toc-level: 1"] a {
    font-weight: 700;
}

.toc-list li[style*="--toc-level: 3"] a,
.toc-list li[style*="--toc-level: 4"] a,
.toc-list li[style*="--toc-level: 5"] a,
.toc-list li[style*="--toc-level: 6"] a {
    color: var(--ink-soft);
}

.toc-list li.toc-lead-match a {
    background: color-mix(in srgb, var(--accent-soft) 68%, white);
}

.toc-list li.is-active a {
    background: color-mix(in srgb, var(--accent-soft) 88%, white);
    box-shadow: inset 3px 0 0 #2f6e56;
    font-weight: 700;
}

.content-panel {
    padding: 1rem 1.15rem 1.5rem;
    overflow: hidden;
    min-width: 0;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.75rem;
}

.content-header h2 {
    margin: 0.28rem 0 0;
    font-family: "Newsreader", Georgia, serif;
    font-size: clamp(1.1rem, 1.8vw, 1.45rem);
}

.raw-link {
    font-size: 0.8rem;
    color: var(--accent);
    text-decoration: none;
    border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
    border-radius: 999px;
    padding: 0.33rem 0.56rem;
    white-space: nowrap;
}

.raw-link:hover {
    background: var(--accent-soft);
}

.status {
    margin-top: 0.9rem;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
}

.prose {
    margin-top: 0.85rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: clamp(0.9rem, 1.8vw, 1.4rem);
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
    font-family: "Newsreader", Georgia, serif;
    margin-top: 1.25em;
    margin-bottom: 0.36em;
    scroll-margin-top: 1rem;
}

.prose h1 {
    font-size: 1.85rem;
}

.prose h2 {
    font-size: 1.5rem;
}

.prose h3 {
    font-size: 1.24rem;
}

.prose p,
.prose li {
    color: #312c22;
}

.prose a {
    color: #1b5a43;
}

.doc-toc-collapsible {
    margin: 0.42rem 0 1rem;
}

.doc-toc-collapsible > summary {
    cursor: pointer;
    font-size: 0.82rem;
    color: #2f6250;
    font-weight: 700;
    user-select: none;
}

.doc-toc-collapsible[open] > summary {
    margin-bottom: 0.4rem;
}

.doc-toc {
    margin: 0;
    border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line));
    background: linear-gradient(165deg, #fcf8ef 0%, #fffdf7 72%);
    border-radius: 12px;
    padding: 0.4rem 0.56rem;
}

.doc-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.03rem;
}

.doc-toc-list li {
    --toc-level: 1;
    padding-left: calc((var(--toc-level) - 1) * 0.84rem);
}

.doc-toc-list a {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    column-gap: 0.75rem;
    text-decoration: none;
    border-radius: 8px;
    padding: 0.12rem 0.35rem;
    color: #1f5a44;
    font-weight: 600;
    font-size: 0.86rem;
    line-height: 1.1;
}

.doc-toc-title {
    min-width: 0;
}

.doc-toc-page {
    justify-self: end;
    min-width: 1.4rem;
    text-align: right;
    color: #6a7269;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.doc-toc-list a:hover,
.doc-toc-list a:focus {
    background: color-mix(in srgb, var(--accent-soft) 75%, white);
}

.doc-toc-list li[style*="--toc-level: 1"] a {
    font-weight: 700;
}

.doc-toc-list li[style*="--toc-level: 3"] a,
.doc-toc-list li[style*="--toc-level: 4"] a,
.doc-toc-list li[style*="--toc-level: 5"] a,
.doc-toc-list li[style*="--toc-level: 6"] a {
    color: #336a54;
    font-weight: 500;
}

.page-section {
    margin: 0.5rem 0 0.68rem;
    border: 1px solid #e7dfcf;
    border-radius: 10px;
    background: #fffdf7;
}

.page-section-summary {
    cursor: pointer;
    padding: 0.42rem 0.62rem;
    font-family: "Newsreader", Georgia, serif;
    font-size: 1.1rem;
    color: #244d3d;
}

.page-section-summary::marker {
    color: #2a5f49;
}

.page-section-body {
    padding: 0 0.7rem 0.5rem;
}

.page-section.page-section-muted {
    opacity: 0.6;
}

.page-section.page-section-match {
    border-color: color-mix(in srgb, var(--accent) 36%, #d9cfbc);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
}

.prepared-by {
    margin: 0.95rem 0 1.25rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.75rem;
    background: linear-gradient(130deg, #fffdf8 0%, #f7f3ea 100%);
}

.prepared-by-title {
    margin: 0 0 0.5rem;
    font-size: 0.74rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--ink-soft);
}

.prepared-by-row {
    display: flex;
    gap: 0.85rem;
    overflow-x: auto;
    padding-bottom: 0.18rem;
}

.prepared-by-person {
    margin: 0;
    min-width: 88px;
    display: grid;
    justify-items: center;
    gap: 0.34rem;
}

.prepared-by-avatar,
.prepared-by-fallback {
    width: 64px;
    height: 64px;
    border-radius: 999px;
    border: 2px solid #f3ece0;
    box-shadow: 0 8px 18px rgba(32, 27, 18, 0.12);
}

.prepared-by-avatar {
    object-fit: cover;
    background: #efe8db;
}

.prepared-by-fallback {
    display: inline-grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: #2a5b47;
    background: #e2efe8;
}

.prepared-by-fallback[hidden] {
    display: none;
}

.prepared-by-person figcaption {
    font-size: 0.75rem;
    line-height: 1.2;
    color: #4f473a;
    text-align: center;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.9rem 0 1.1rem;
    font-size: 0.92rem;
}

.prose th,
.prose td {
    border: 1px solid var(--line);
    padding: 0.44rem 0.54rem;
    vertical-align: top;
}

.prose th {
    background: #f7f2e8;
    text-align: left;
}

.requirements-block {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fcfaf4;
    margin: 0.9rem 0 1.1rem;
}

.requirements-block summary {
    cursor: pointer;
    padding: 0.58rem 0.72rem;
    font-weight: 700;
    color: #1e5d47;
}

.requirements-block summary::marker {
    color: #1e5d47;
}

.requirements-block table {
    margin: 0;
    border-top: 1px solid var(--line);
}

@media (max-width: 1024px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        top: 0;
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
}

@media (max-width: 680px) {
    .content-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .raw-link {
        white-space: normal;
    }

    .prose {
        padding: 0.8rem;
    }

    .prose table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .prepared-by-person {
        min-width: 80px;
    }

    .prepared-by-avatar,
    .prepared-by-fallback {
        width: 56px;
        height: 56px;
    }
}
