:root {
    --ink: #2d3142;
    --paper: #f7fff7;
    --accent: #ff9f1c;
    --teal: #2ec4b6;
    --line: rgba(45, 49, 66, 0.18);
    --muted: rgba(45, 49, 66, 0.68);
    --danger: #d64045;
    --white: #ffffff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
    background:
        linear-gradient(90deg, rgba(45, 49, 66, 0.055) 1px, transparent 1px),
        linear-gradient(180deg, rgba(45, 49, 66, 0.055) 1px, transparent 1px),
        var(--paper);
    background-size: 28px 28px;
}

.command-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto minmax(150px, 1fr);
    gap: 18px;
    align-items: center;
    padding: 14px 22px;
    color: var(--paper);
    background: var(--ink);
    border-bottom: 4px solid var(--accent);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.brand img {
    flex: 0 0 auto;
}

.brand strong {
    display: block;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(24px, 3vw, 36px);
    line-height: 0.95;
}

.brand small,
.stream-title small,
.application-row small,
.document-row small,
.finance-row small,
.metric span {
    display: block;
    color: currentColor;
    opacity: 0.72;
}

.tabs {
    display: flex;
    gap: 6px;
    padding: 4px;
    border: 1px solid rgba(247, 255, 247, 0.22);
}

.tab,
.row-action,
.primary-action,
.status-pill {
    cursor: pointer;
    border: 0;
    transition: transform 160ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.tab {
    min-height: 42px;
    padding: 0 14px;
    color: var(--paper);
    background: transparent;
}

.tab.is-active,
.tab:hover {
    color: var(--ink);
    background: var(--accent);
}

.sync-status {
    justify-self: end;
    max-width: 100%;
    padding: 9px 12px;
    color: var(--paper);
    border: 1px solid rgba(247, 255, 247, 0.24);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sync-status[data-mode="ok"] {
    border-color: var(--teal);
}

.sync-status[data-mode="error"] {
    border-color: var(--danger);
    color: #ffd6d6;
}

main {
    padding: 22px;
}

.screen {
    display: none;
    animation: rise 280ms ease both;
}

.screen.is-active {
    display: block;
}

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

.overview-grid {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.status-rail {
    display: grid;
    gap: 12px;
}

.metric {
    min-height: 118px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    background: var(--white);
    border-left: 6px solid var(--ink);
    box-shadow: 0 1px 0 var(--line);
}

.metric.accent {
    border-color: var(--accent);
}

.metric.alert {
    border-color: var(--danger);
}

.metric strong {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 36px;
}

.board-workspace,
.event-stream,
.form-layout,
.document-list,
.finance-grid {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--line);
}

.board-workspace {
    min-width: 0;
}

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

.section-head.compact {
    align-items: center;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(28px, 4vw, 48px);
    line-height: 1;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

input,
select {
    min-height: 42px;
    max-width: 100%;
    padding: 0 12px;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 0;
}

.filters input {
    width: min(360px, 100%);
}

.status-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
}

.status-pill {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 0 12px;
    color: var(--ink);
    background: transparent;
    border: 1px solid var(--line);
}

.status-pill:hover {
    border-color: var(--teal);
    transform: translateY(-1px);
}

.status-pill strong {
    color: var(--teal);
}

.board-table {
    overflow-x: auto;
}

.table-head,
.application-row {
    display: grid;
    grid-template-columns: minmax(190px, 1.2fr) minmax(250px, 1.6fr) 80px 115px 120px 132px;
    gap: 12px;
    align-items: center;
    min-width: 940px;
    padding: 12px 18px;
}

.table-head {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line);
}

.application-row {
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.64);
}

.application-row:hover {
    background: #fff8eb;
}

.application-row strong,
.document-row strong,
.finance-row strong {
    display: block;
    line-height: 1.25;
}

.score {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 22px;
    border: 2px solid var(--ink);
    border-radius: 50%;
}

.state-badge {
    display: inline-block;
    min-width: 92px;
    padding: 7px 9px;
    text-align: center;
    color: var(--paper);
    background: var(--ink);
}

.state-new {
    background: var(--accent);
    color: var(--ink);
}

.state-review,
.state-route {
    background: var(--teal);
    color: var(--ink);
}

.state-approved {
    background: #237b4b;
}

.state-rejected {
    background: var(--danger);
}

.row-action,
.primary-action {
    min-height: 42px;
    padding: 0 14px;
    color: var(--ink);
    background: var(--accent);
}

.row-action:hover,
.primary-action:hover {
    transform: translateY(-1px);
    background: var(--teal);
}

.event-stream {
    margin-top: 22px;
}

.stream-title {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 18px;
    color: var(--paper);
    background: var(--ink);
}

.stream-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(200px, 1fr));
}

.stream-row {
    min-height: 104px;
    padding: 14px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.stream-row span {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--teal);
    font-size: 12px;
    text-transform: uppercase;
}

.form-layout {
    max-width: 980px;
}

.grant-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 18px;
}

.grant-form label {
    display: grid;
    gap: 7px;
    min-width: 0;
    color: var(--muted);
}

.grant-form .primary-action {
    align-self: end;
}

.submission-result {
    min-height: 48px;
    padding: 0 18px 18px;
    color: #237b4b;
}

.document-list {
    display: grid;
}

.document-row,
.finance-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 140px 120px;
    gap: 14px;
    align-items: center;
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
}

.document-row b,
.finance-row span {
    justify-self: end;
}

.doc-ready {
    color: #237b4b;
}

.doc-review {
    color: var(--accent);
}

.doc-missing {
    color: var(--danger);
}

.finance-grid {
    display: grid;
    grid-template-columns: 310px minmax(0, 1fr);
}

.finance-ledger {
    padding: 18px;
    color: var(--paper);
    background: var(--ink);
}

.finance-ledger div + div {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(247, 255, 247, 0.18);
}

.finance-ledger span {
    display: block;
    opacity: 0.72;
}

.finance-ledger strong {
    display: block;
    margin-top: 6px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 28px;
}

.finance-events {
    min-width: 0;
}

.finance-row {
    grid-template-columns: minmax(0, 1fr) 150px;
}

.finance-row .inflow {
    color: #237b4b;
}

.finance-row .outflow {
    color: var(--danger);
}

.empty-state {
    padding: 24px 18px;
    color: var(--muted);
}

@media (max-width: 980px) {
    .command-bar {
        grid-template-columns: 1fr;
    }

    .sync-status {
        justify-self: stretch;
    }

    .tabs {
        overflow-x: auto;
    }

    .overview-grid,
    .finance-grid {
        grid-template-columns: 1fr;
    }

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

    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .filters {
        justify-content: stretch;
    }

    .filters input,
    .filters select {
        flex: 1 1 220px;
    }

    .stream-list {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 640px) {
    main {
        padding: 12px;
    }

    .command-bar {
        padding: 12px;
    }

    .brand strong {
        font-size: 26px;
    }

    .status-rail,
    .grant-form,
    .stream-list {
        grid-template-columns: 1fr;
    }

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

    .tab {
        padding: 0 8px;
    }

    .document-row {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .document-row b,
    .finance-row span {
        justify-self: start;
    }
}

