:root {
    --ink: #252422;
    --paper: #fffcf2;
    --paper-deep: #f3efe1;
    --line: #ded8c9;
    --accent: #eb5e28;
    --blue: #4f6d7a;
    --green: #5e7c61;
    --muted: #777168;
    --white: #ffffff;
    --shadow: 0 18px 50px rgba(37, 36, 34, 0.10);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--paper);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(79, 109, 122, 0.10) 0 1px, transparent 1px 100%),
        linear-gradient(180deg, rgba(37, 36, 34, 0.05) 0 1px, transparent 1px 100%),
        var(--paper);
    background-size: 42px 42px;
    font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
    letter-spacing: 0;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
}

.rail {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 18px;
    color: var(--paper);
    background: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    color: inherit;
    text-decoration: none;
}

.brand strong {
    display: block;
    font-size: 22px;
    line-height: 1;
}

.brand small,
.source-box small {
    display: block;
    margin-top: 4px;
    color: rgba(255, 252, 242, 0.66);
    line-height: 1.35;
}

.tabs {
    display: grid;
    gap: 8px;
}

.tab {
    width: 100%;
    border: 1px solid rgba(255, 252, 242, 0.12);
    border-radius: 8px;
    padding: 11px 12px;
    color: rgba(255, 252, 242, 0.78);
    background: transparent;
    text-align: left;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab:hover,
.tab.is-active {
    color: var(--paper);
    background: rgba(235, 94, 40, 0.20);
    transform: translateX(2px);
}

.source-box {
    margin-top: auto;
    border-top: 1px solid rgba(255, 252, 242, 0.14);
    padding-top: 16px;
}

.source-box strong {
    display: block;
    margin-top: 6px;
    color: var(--accent);
}

.workspace {
    min-width: 0;
    padding: 26px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.eyebrow,
.mono {
    margin: 0;
    color: var(--blue);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(30px, 4vw, 54px);
    line-height: 0.95;
}

h2 {
    margin-bottom: 8px;
    font-size: 21px;
    line-height: 1.08;
}

p {
    color: var(--muted);
    line-height: 1.65;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.search {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
}

input,
textarea,
select {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 11px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.74);
    outline: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(79, 109, 122, 0.14);
}

.icon-button,
.primary-button {
    min-height: 40px;
    border-radius: 8px;
    border: 1px solid var(--ink);
    padding: 0 14px;
    color: var(--paper);
    background: var(--ink);
}

.icon-button {
    width: 42px;
    padding: 0;
    font-size: 20px;
}

.primary-button {
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 800;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--line);
    margin-bottom: 18px;
}

.metric {
    min-width: 0;
    padding: 18px;
    background: rgba(255, 252, 242, 0.94);
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: clamp(26px, 3vw, 40px);
    line-height: 1;
}

.metric small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
}

.metric-accent {
    background: var(--blue);
    color: var(--paper);
}

.metric-accent .mono,
.metric-accent small {
    color: rgba(255, 252, 242, 0.78);
}

.view {
    display: none;
}

.view.is-visible {
    display: block;
    animation: rise 180ms ease-out;
}

.workflow-ribbon {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.stage-pill {
    position: relative;
    min-height: 94px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: rgba(255, 252, 242, 0.86);
    overflow: hidden;
}

.stage-pill::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--score-width, 0%);
    background: rgba(79, 109, 122, 0.12);
}

.stage-pill > * {
    position: relative;
}

.stage-pill strong {
    display: block;
    font-size: 19px;
}

.stage-pill span:last-child {
    color: var(--muted);
    font-size: 13px;
}

.inbox {
    display: grid;
    grid-template-columns: minmax(260px, 0.86fr) minmax(360px, 1.32fr) minmax(260px, 0.82fr);
    gap: 14px;
    align-items: stretch;
}

.queue-panel,
.record-panel,
.action-panel,
.grant-form,
.review-strip,
.document-table,
.finance-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 252, 242, 0.94);
    box-shadow: var(--shadow);
}

.queue-panel,
.record-panel,
.action-panel {
    min-width: 0;
    padding: 16px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.section-head p {
    margin-bottom: 0;
    font-size: 14px;
}

.case-list {
    display: grid;
    gap: 8px;
}

.case-row {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 12px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.58);
    text-align: left;
    transition: border-color 150ms ease, transform 150ms ease, background 150ms ease;
}

.case-row:hover,
.case-row.is-active {
    border-color: var(--accent);
    background: var(--white);
    transform: translateY(-1px);
}

.case-row strong,
.case-row small {
    display: block;
}

.case-row strong {
    line-height: 1.18;
}

.case-row small {
    margin-top: 5px;
    color: var(--muted);
    line-height: 1.4;
}

.chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 3px 9px;
    color: var(--paper);
    background: var(--blue);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.chip.hot {
    background: var(--accent);
}

.chip.good {
    background: var(--green);
}

.record-panel {
    position: relative;
    overflow: hidden;
}

.record-panel::after {
    content: "";
    position: absolute;
    right: -70px;
    top: -80px;
    width: 210px;
    height: 210px;
    border: 1px solid rgba(79, 109, 122, 0.22);
    border-radius: 50%;
}

.record-panel > * {
    position: relative;
}

#recordTitle {
    margin-top: 12px;
    font-size: clamp(28px, 4.2vw, 52px);
    max-width: 760px;
}

#recordSummary {
    max-width: 680px;
}

.vote-line {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 18px 0;
    padding: 14px 0;
    border-block: 1px solid var(--line);
}

.vote-line strong {
    font-size: 34px;
}

.facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 18px;
}

.facts div {
    min-width: 0;
}

.facts dt {
    color: var(--muted);
    font-size: 12px;
}

.facts dd {
    margin: 3px 0 0;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.discussion {
    display: grid;
    gap: 9px;
    margin-top: 16px;
}

.note {
    border-left: 3px solid var(--blue);
    padding: 4px 0 4px 10px;
}

.note strong,
.note small {
    display: block;
}

.note small {
    color: var(--muted);
    margin-top: 3px;
}

.action-panel {
    background: var(--paper-deep);
}

.note-form {
    display: grid;
    gap: 12px;
    margin-top: 20px;
}

.note-form label,
.grant-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
}

textarea {
    resize: vertical;
}

.form-layout {
    display: grid;
    grid-template-columns: minmax(300px, 0.9fr) minmax(260px, 0.6fr);
    gap: 14px;
}

.grant-form,
.review-strip {
    padding: 18px;
}

.grant-form {
    display: grid;
    gap: 13px;
}

.review-strip {
    background: var(--ink);
    color: var(--paper);
}

.review-strip h2 {
    margin-top: 12px;
}

.review-strip ul {
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.review-strip li {
    border-top: 1px solid rgba(255, 252, 242, 0.16);
    padding: 14px 0;
}

.document-table {
    overflow: hidden;
}

.doc-row,
.finance-card {
    display: grid;
    gap: 8px;
    padding: 16px;
}

.doc-row {
    grid-template-columns: 1.25fr 0.8fr 0.7fr 0.7fr;
    align-items: center;
    border-top: 1px solid var(--line);
}

.doc-row:first-child {
    border-top: 0;
}

.doc-row > * {
    min-width: 0;
}

.doc-row strong,
.doc-row span {
    overflow-wrap: anywhere;
}

.finance-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.finance-card {
    min-height: 180px;
}

.finance-card strong {
    font-size: 30px;
}

.bar {
    height: 10px;
    border-radius: 999px;
    background: rgba(79, 109, 122, 0.16);
    overflow: hidden;
}

.bar span {
    display: block;
    height: 100%;
    width: var(--bar-width, 0%);
    background: var(--accent);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: min(360px, calc(100vw - 36px));
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--paper);
    background: var(--ink);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    .rail {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
    }

    .tabs {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        flex: 1 1 440px;
    }

    .source-box {
        margin-top: 0;
        border-top: 0;
        border-left: 1px solid rgba(255, 252, 242, 0.14);
        padding: 0 0 0 14px;
    }

    .inbox {
        grid-template-columns: 1fr;
    }

    .workflow-ribbon,
    .finance-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .workspace {
        padding: 18px 12px;
    }

    .topbar,
    .section-head {
        display: grid;
    }

    .toolbar,
    .search,
    .search input,
    .section-head select {
        width: 100%;
    }

    .metrics,
    .workflow-ribbon,
    .finance-grid,
    .form-layout,
    .facts {
        grid-template-columns: 1fr;
    }

    .tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .source-box {
        width: 100%;
        border-left: 0;
        border-top: 1px solid rgba(255, 252, 242, 0.14);
        padding: 12px 0 0;
    }

    .doc-row {
        grid-template-columns: 1fr;
    }
}
