:root {
    --ink: #22223b;
    --paper: #fefae0;
    --olive: #606c38;
    --amber: #dda15e;
    --line: rgba(34, 34, 59, 0.15);
    --muted: #6a665a;
    --surface: #fffdf0;
    --danger: #9f3a38;
    --ok: #426b42;
    --shadow: 0 18px 60px rgba(34, 34, 59, 0.14);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100%;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(34,34,59,0.045) 1px, transparent 1px),
        linear-gradient(0deg, rgba(34,34,59,0.035) 1px, transparent 1px),
        var(--paper);
    background-size: 32px 32px;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

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

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

.brand strong {
    display: block;
    font-size: 20px;
    line-height: 1.05;
}

.brand small,
.eyebrow,
.ledger-strip span,
.rail-note span,
.panel-head span,
.task-row small,
.doc-meta {
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    letter-spacing: 0;
}

.brand small {
    color: rgba(254, 250, 224, 0.66);
    font-size: 11px;
    text-transform: uppercase;
}

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

.tab {
    width: 100%;
    min-height: 44px;
    border: 1px solid rgba(254, 250, 224, 0.18);
    border-radius: 8px;
    color: rgba(254, 250, 224, 0.74);
    background: transparent;
    text-align: left;
    padding: 10px 12px;
}

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

.rail-note {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(254, 250, 224, 0.18);
}

.rail-note span {
    display: block;
    color: var(--amber);
    font-size: 12px;
    text-transform: uppercase;
}

.rail-note strong {
    display: block;
    margin-top: 8px;
    font-size: 15px;
    line-height: 1.45;
}

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

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

.eyebrow {
    margin: 0 0 6px;
    color: var(--olive);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

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

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

h2 {
    margin-bottom: 0;
    font-size: 20px;
    line-height: 1.15;
}

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

.search {
    display: grid;
    gap: 5px;
}

.search span {
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}

input,
select {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 11px;
    color: var(--ink);
    background: var(--surface);
}

.primary-action {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--paper);
    background: var(--olive);
    font-weight: 700;
}

.ledger-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--ink);
    background: var(--ink);
    box-shadow: var(--shadow);
}

.ledger-strip div {
    min-width: 0;
    padding: 16px;
    color: var(--paper);
    border-right: 1px solid rgba(254, 250, 224, 0.18);
}

.ledger-strip div:last-child {
    border-right: 0;
}

.ledger-strip span,
.ledger-strip small {
    display: block;
    color: rgba(254, 250, 224, 0.68);
    font-size: 11px;
    text-transform: uppercase;
}

.ledger-strip strong {
    display: block;
    margin: 8px 0 2px;
    color: var(--amber);
    font-size: clamp(24px, 3vw, 36px);
    line-height: 1;
}

.view {
    display: none;
    margin-top: 20px;
}

.view.is-active {
    display: block;
    animation: rise 220ms ease-out;
}

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

.canvas-grid,
.finance-grid,
.form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.7fr);
    gap: 18px;
}

.map-canvas,
.audit-panel,
.task-board,
.request-form,
.workflow-preview,
.document-list,
.finance-grid > section,
.retention-box {
    border: 1px solid var(--line);
    background: rgba(255, 253, 240, 0.92);
}

.map-canvas,
.audit-panel,
.request-form,
.workflow-preview,
.finance-grid > section,
.retention-box {
    padding: 18px;
}

.canvas-head,
.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.canvas-head span,
.panel-head span {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}

.route-map {
    position: relative;
    min-height: 390px;
    overflow: hidden;
    border: 1px solid var(--ink);
    background:
        linear-gradient(90deg, rgba(96,108,56,0.18) 1px, transparent 1px),
        linear-gradient(0deg, rgba(96,108,56,0.16) 1px, transparent 1px),
        #fbf6d9;
    background-size: 54px 54px;
}

.route-map::before,
.route-map::after {
    position: absolute;
    content: "";
    pointer-events: none;
}

.route-map::before {
    inset: 14% -10% auto -5%;
    height: 2px;
    background: var(--olive);
    transform: rotate(-9deg);
}

.route-map::after {
    inset: auto -8% 24% -6%;
    height: 2px;
    background: var(--amber);
    transform: rotate(8deg);
}

.map-node {
    position: absolute;
    width: min(220px, 42%);
    min-height: 92px;
    border: 1px solid var(--ink);
    background: var(--surface);
    padding: 12px;
    box-shadow: 7px 7px 0 rgba(34, 34, 59, 0.11);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.map-node:hover {
    transform: translateY(-3px);
    box-shadow: 9px 10px 0 rgba(34, 34, 59, 0.15);
}

.map-node strong {
    display: block;
    margin-bottom: 8px;
    line-height: 1.15;
}

.map-node small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-bottom: 8px;
    border-radius: 50% 50% 50% 0;
    color: var(--paper);
    background: var(--olive);
    transform: rotate(-45deg);
}

.pin span {
    transform: rotate(45deg);
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
}

.audit-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.audit-list li {
    padding: 10px 0 10px 14px;
    border-left: 3px solid var(--amber);
}

.audit-list strong {
    display: block;
    font-size: 13px;
}

.audit-list time {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
}

.task-board {
    margin-top: 18px;
    padding: 18px;
}

.tasks-table {
    display: grid;
    gap: 10px;
}

.task-row,
.doc-row,
.finance-row {
    display: grid;
    grid-template-columns: minmax(210px, 1.4fr) minmax(150px, 0.7fr) minmax(130px, 0.6fr) minmax(120px, 0.55fr) auto;
    gap: 12px;
    align-items: center;
    border-top: 1px solid var(--line);
    padding: 12px 0 0;
}

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

.task-row strong,
.doc-row strong {
    display: block;
    line-height: 1.2;
}

.task-row small,
.doc-meta,
.finance-row small {
    color: var(--muted);
    font-size: 12px;
}

.status {
    display: inline-flex;
    justify-content: center;
    width: 112px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 8px;
    background: #fffaf1;
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
}

.status.accepted {
    color: var(--ok);
    border-color: rgba(66, 107, 66, 0.42);
}

.status.route,
.status.loading {
    color: #84521f;
    border-color: rgba(221, 161, 94, 0.7);
}

.row-action {
    min-height: 34px;
    border: 1px solid var(--ink);
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    font-weight: 700;
}

.request-form form {
    display: grid;
    gap: 12px;
}

.request-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    text-transform: uppercase;
}

.request-form input {
    width: 100%;
}

.workflow-preview p,
.retention-box p {
    color: var(--muted);
    line-height: 1.55;
}

.flow-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 18px 0;
}

.flow-steps span {
    min-height: 76px;
    border: 1px solid var(--ink);
    padding: 12px;
    background: var(--paper);
    font-weight: 800;
}

.document-list,
.finance-ledger {
    padding: 18px;
}

.doc-row {
    grid-template-columns: minmax(210px, 1.2fr) minmax(130px, 0.55fr) minmax(140px, 0.7fr) minmax(110px, 0.45fr);
}

.finance-row {
    grid-template-columns: minmax(210px, 1.4fr) minmax(140px, 0.6fr) minmax(100px, 0.45fr);
}

.delta-positive {
    color: var(--ok);
}

.delta-negative {
    color: var(--danger);
}

.retention-box {
    text-align: center;
}

.retention-ring {
    display: grid;
    place-items: center;
    width: 190px;
    height: 190px;
    margin: 22px auto;
    border-radius: 50%;
    border: 18px solid var(--olive);
    outline: 1px solid var(--line);
    background: var(--paper);
}

.retention-ring span {
    font-size: 42px;
    font-weight: 900;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    max-width: min(420px, calc(100vw - 40px));
    padding: 12px 14px;
    border: 1px solid var(--ink);
    color: var(--paper);
    background: var(--ink);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 180ms ease, transform 180ms ease;
    pointer-events: none;
}

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

.empty-state {
    padding: 20px;
    color: var(--muted);
    border: 1px dashed var(--line);
}

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

    .side-rail {
        position: static;
        height: auto;
    }

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

    .topbar,
    .canvas-head,
    .panel-head {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar {
        justify-content: flex-start;
    }

    .ledger-strip,
    .canvas-grid,
    .finance-grid,
    .form-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .workspace,
    .side-rail {
        padding: 16px;
    }

    .nav-tabs {
        grid-template-columns: 1fr 1fr;
    }

    .ledger-strip {
        grid-template-columns: 1fr 1fr;
    }

    .ledger-strip div:nth-child(2) {
        border-right: 0;
    }

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

    .status {
        width: 100%;
    }

    .row-action {
        width: 100%;
    }

    .route-map {
        min-height: 540px;
    }

    .map-node {
        width: calc(100% - 28px);
        left: 14px !important;
    }

    .map-node:nth-child(1) {
        top: 18px !important;
    }

    .map-node:nth-child(2) {
        top: 144px !important;
    }

    .map-node:nth-child(3) {
        top: 270px !important;
    }

    .map-node:nth-child(4) {
        top: 396px !important;
    }

    .flow-steps {
        grid-template-columns: 1fr 1fr;
    }
}

