:root {
    --ink: #22223b;
    --paper: #fefae0;
    --olive: #606c38;
    --amber: #dda15e;
    --line: rgba(34, 34, 59, 0.18);
    --muted: rgba(34, 34, 59, 0.66);
    --danger: #9d2d25;
    --white: #fffdf1;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    margin: 0;
    min-height: 100vh;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

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

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
    font-weight: 800;
    letter-spacing: 0;
}

.brand img {
    width: 42px;
    height: 42px;
}

.nav {
    display: grid;
    gap: 7px;
}

.nav__item {
    min-height: 42px;
    border: 1px solid rgba(254, 250, 224, 0.16);
    border-radius: 7px;
    color: rgba(254, 250, 224, 0.78);
    background: transparent;
    text-align: left;
    padding: 0 12px;
}

.nav__item.is-active,
.nav__item:hover {
    color: var(--ink);
    background: var(--amber);
    border-color: var(--amber);
}

.rail__note {
    margin-top: auto;
    display: grid;
    gap: 8px;
    padding-top: 20px;
    border-top: 1px solid rgba(254, 250, 224, 0.18);
}

.rail__note strong {
    font-size: 14px;
    line-height: 1.45;
}

.mono,
.eyebrow,
.metric span,
label span,
.badge {
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    letter-spacing: 0;
}

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

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

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

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

h1 {
    margin-bottom: 0;
    font-size: clamp(28px, 4vw, 48px);
    line-height: 1;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 10px;
    font-size: 24px;
    line-height: 1.12;
    letter-spacing: 0;
}

h3 {
    margin-bottom: 10px;
    font-size: 13px;
    text-transform: uppercase;
}

.sync {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    white-space: nowrap;
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    color: var(--olive);
}

.pulse {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--olive);
    box-shadow: 0 0 0 0 rgba(96, 108, 56, 0.5);
    animation: pulse 1.8s infinite;
}

.ledger {
    display: grid;
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    margin: 18px 0;
    border: 1px solid var(--line);
    background: var(--white);
}

.metric {
    min-height: 92px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    padding: 15px;
    border-right: 1px solid var(--line);
}

.metric:last-child {
    border-right: 0;
}

.metric span {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}

.metric strong {
    font-size: clamp(21px, 2.4vw, 31px);
    line-height: 1;
}

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

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

.metric.accent span {
    color: rgba(254, 250, 224, 0.75);
}

.canvas {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(310px, 0.85fr);
    gap: 18px;
    align-items: start;
}

.map-panel,
.inspector,
.screen {
    border: 1px solid var(--line);
    background: var(--white);
}

.map-panel {
    min-width: 0;
}

.filters {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) 180px;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
}

label {
    display: grid;
    gap: 6px;
}

label span {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}

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

.map {
    position: relative;
    min-height: 310px;
    overflow: hidden;
    background:
        linear-gradient(90deg, rgba(34, 34, 59, 0.08) 1px, transparent 1px),
        linear-gradient(0deg, rgba(34, 34, 59, 0.08) 1px, transparent 1px),
        radial-gradient(circle at 22% 35%, rgba(221, 161, 94, 0.24), transparent 22%),
        radial-gradient(circle at 72% 65%, rgba(96, 108, 56, 0.2), transparent 24%),
        #f7f0cf;
    background-size: 36px 36px, 36px 36px, auto, auto, auto;
}

.map__grid {
    position: absolute;
    inset: 0;
}

.map::before,
.map::after {
    position: absolute;
    left: 10%;
    right: 8%;
    height: 2px;
    background: rgba(34, 34, 59, 0.28);
    transform: rotate(-13deg);
    content: "";
}

.map::before {
    top: 35%;
}

.map::after {
    top: 67%;
    transform: rotate(15deg);
}

.marker {
    position: absolute;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 7px;
    transform: translate(-10px, -10px);
    max-width: 140px;
    border: 0;
    color: var(--ink);
    background: transparent;
}

.marker span {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border: 3px solid var(--white);
    border-radius: 50%;
    background: var(--olive);
    box-shadow: 0 0 0 2px rgba(34, 34, 59, 0.25);
}

.marker strong {
    overflow: hidden;
    max-width: 100px;
    padding: 3px 6px;
    border-radius: 5px;
    background: rgba(254, 250, 224, 0.92);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.marker.status-critical span,
.status-critical .badge,
.badge.status-critical {
    background: var(--danger);
}

.marker.status-watch span,
.status-watch .badge,
.badge.status-watch {
    background: var(--amber);
}

.marker.is-selected span {
    outline: 3px solid rgba(221, 161, 94, 0.55);
}

.object-list {
    display: grid;
}

.object-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 86px 112px;
    gap: 12px;
    align-items: center;
    width: 100%;
    min-height: 72px;
    border: 0;
    border-top: 1px solid var(--line);
    color: var(--ink);
    background: transparent;
    padding: 12px;
    text-align: left;
}

.object-row:hover,
.object-row.is-selected {
    background: rgba(221, 161, 94, 0.18);
}

.object-row__main,
.object-row__numbers {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.object-row strong,
.object-row small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.object-row small,
.muted,
.timeline small,
.task span,
.doc-row small {
    color: var(--muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    border-radius: 5px;
    color: var(--paper);
    background: var(--olive);
    padding: 0 8px;
    font-size: 11px;
    text-transform: uppercase;
    white-space: nowrap;
}

.inspector {
    position: sticky;
    top: 18px;
    min-width: 0;
    padding: 18px;
}

.inspector__head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.mini-ledger {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 1px solid var(--line);
    margin: 16px 0;
}

.mini-ledger div {
    display: grid;
    gap: 7px;
    min-height: 72px;
    padding: 10px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

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

.mini-ledger div:nth-last-child(-n + 2) {
    border-bottom: 0;
}

.mini-ledger span {
    color: var(--muted);
    font-size: 12px;
}

.timeline,
.task-strip {
    margin-top: 18px;
}

.timeline__item,
.task,
.doc-row,
.finance-row,
.finance-head {
    display: grid;
    gap: 10px;
    align-items: center;
    border-top: 1px solid var(--line);
    padding: 11px 0;
}

.timeline__item {
    grid-template-columns: 12px minmax(0, 1fr);
    align-items: start;
}

.timeline__item span {
    width: 10px;
    height: 10px;
    margin-top: 4px;
    border-radius: 50%;
    background: var(--olive);
}

.timeline__item.severity-critical span {
    background: var(--danger);
}

.timeline__item.severity-warning span {
    background: var(--amber);
}

.timeline__item div,
.task,
.doc-row,
.finance-row {
    min-width: 0;
}

.timeline__item strong,
.task b,
.doc-row strong,
.finance-row strong {
    overflow-wrap: anywhere;
}

.screen {
    display: none;
    margin-top: 18px;
    padding: 18px;
}

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

.form-head,
.screen.is-active.split {
    display: grid;
    grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr);
    gap: 18px;
}

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

.action-form label:nth-child(2) {
    grid-column: 1 / -1;
}

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

.primary:hover {
    background: var(--olive);
}

.form-status {
    align-self: center;
    margin: 0;
    color: var(--olive);
}

.doc-list,
.finance-table {
    border-top: 1px solid var(--line);
}

.doc-row {
    grid-template-columns: 76px minmax(0, 1fr) 100px 110px;
}

.file-type {
    display: inline-flex;
    justify-content: center;
    min-height: 28px;
    border: 1px solid var(--line);
    border-radius: 5px;
    align-items: center;
    color: var(--olive);
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
}

.finance-head,
.finance-row {
    grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(95px, 0.7fr));
}

.finance-head {
    color: var(--muted);
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    text-transform: uppercase;
}

.positive {
    color: var(--olive);
}

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

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

@keyframes pulse {
    70% {
        box-shadow: 0 0 0 9px rgba(96, 108, 56, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(96, 108, 56, 0);
    }
}

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

    .rail {
        position: static;
        height: auto;
        gap: 16px;
    }

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

    .nav__item {
        text-align: center;
        padding: 0 6px;
    }

    .rail__note {
        display: none;
    }

    .ledger,
    .canvas,
    .form-head,
    .screen.is-active.split {
        grid-template-columns: 1fr;
    }

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

    .metric {
        border-bottom: 1px solid var(--line);
    }

    .inspector {
        position: static;
    }
}

@media (max-width: 620px) {
    .workspace {
        padding: 14px;
    }

    .topbar {
        display: grid;
    }

    .ledger,
    .filters,
    .action-form,
    .nav {
        grid-template-columns: 1fr;
    }

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

    .object-row strong,
    .object-row small {
        white-space: normal;
    }

    .map {
        min-height: 260px;
    }

    .marker strong {
        display: none;
    }

    .mini-ledger,
    .doc-row,
    .finance-head,
    .finance-row {
        grid-template-columns: 1fr;
    }

    .mini-ledger div,
    .mini-ledger div:nth-child(2n),
    .mini-ledger div:nth-last-child(-n + 2) {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .mini-ledger div:last-child {
        border-bottom: 0;
    }
}
