:root {
    --ink: #2d3142;
    --paper: #f7fff7;
    --amber: #ff9f1c;
    --teal: #2ec4b6;
    --line: rgba(45, 49, 66, 0.18);
    --muted: rgba(45, 49, 66, 0.68);
    --danger: #b83232;
    --surface: #ffffff;
    --shadow: 0 18px 50px rgba(45, 49, 66, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--paper);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(90deg, rgba(46, 196, 182, 0.08) 1px, transparent 1px),
        linear-gradient(180deg, rgba(45, 49, 66, 0.06) 1px, transparent 1px),
        var(--paper);
    background-size: 28px 28px;
}

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

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.command-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: minmax(210px, 270px) minmax(280px, 1fr) auto;
    gap: 18px;
    align-items: center;
    min-height: 82px;
    padding: 12px 22px;
    border-bottom: 3px solid var(--ink);
    background: rgba(247, 255, 247, 0.94);
    backdrop-filter: blur(16px);
}

.brand {
    display: inline-grid;
    grid-template-columns: 54px 1fr;
    gap: 12px;
    align-items: center;
    color: var(--ink);
    text-decoration: none;
    min-width: 0;
}

.brand strong,
h1,
h2 {
    font-family: Georgia, 'Times New Roman', serif;
    letter-spacing: 0;
}

.brand strong {
    display: block;
    font-size: 1.35rem;
    line-height: 1;
}

.brand small,
.mono,
.eyebrow {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.screen-tabs,
.command-tools,
.filter-row,
.form-row,
.section-head {
    display: flex;
    align-items: center;
}

.screen-tabs {
    gap: 6px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.tab,
.filter-chip,
.secondary-button,
.icon-button,
.primary-button {
    border: 2px solid var(--ink);
    background: var(--paper);
    color: var(--ink);
    min-height: 42px;
    border-radius: 6px;
    transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.tab,
.filter-chip {
    padding: 9px 13px;
    white-space: nowrap;
}

.tab.is-active,
.filter-chip.is-active,
.primary-button {
    background: var(--ink);
    color: var(--paper);
}

.tab:hover,
.filter-chip:hover,
.secondary-button:hover,
.icon-button:hover,
.primary-button:hover,
.order-row:hover {
    transform: translateY(-1px);
    box-shadow: 4px 4px 0 var(--amber);
}

.command-tools {
    gap: 8px;
    justify-content: flex-end;
}

.search-box {
    display: grid;
    gap: 3px;
    min-width: 210px;
}

.search-box span,
label {
    color: var(--muted);
    font-size: 0.78rem;
}

input,
select,
textarea {
    width: 100%;
    border: 2px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.2);
}

.icon-button {
    width: 44px;
    padding: 0;
    font-size: 1.25rem;
}

.primary-button,
.secondary-button {
    padding: 0 16px;
    font-weight: 700;
}

.workspace {
    width: min(1500px, calc(100vw - 28px));
    margin: 0 auto;
    padding: 18px 0 20px;
}

.status-strip {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 18px;
}

.status-strip > div {
    min-width: 0;
    padding: 12px 14px;
    border-left: 6px solid var(--teal);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.status-strip strong {
    display: block;
    margin-top: 4px;
    font-size: clamp(1.15rem, 2vw, 1.8rem);
    line-height: 1;
}

.source-demo {
    color: var(--amber);
}

.source-ok {
    color: var(--teal);
}

.view {
    display: none;
}

.view.is-visible {
    display: block;
    animation: riseIn 220ms ease both;
}

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

.board-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: end;
    margin-bottom: 14px;
}

.board-head h1,
.request-form h1,
.section-head h1 {
    margin: 3px 0 0;
    font-size: clamp(1.9rem, 4vw, 4rem);
    line-height: 0.95;
}

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

.workflow-lane {
    min-height: 152px;
    padding: 14px;
    border: 2px solid var(--ink);
    background: var(--surface);
    box-shadow: 6px 6px 0 rgba(46, 196, 182, 0.45);
}

.workflow-lane h2 {
    margin: 8px 0 12px;
    font-size: clamp(1.3rem, 2.2vw, 2.1rem);
}

.lane-zone {
    display: inline-block;
    padding: 4px 8px;
    background: rgba(255, 159, 28, 0.18);
    color: var(--ink);
    font-size: 0.72rem;
    text-transform: uppercase;
}

.lane-stats {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 8px;
    align-items: baseline;
    color: var(--muted);
}

.lane-stats strong {
    color: var(--ink);
    font-size: 1.5rem;
}

.progress,
.dial-track {
    height: 9px;
    margin: 12px 0 6px;
    border: 1px solid var(--ink);
    background: var(--paper);
}

.progress i,
.dial-track i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--teal), var(--amber));
}

.registry-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.65fr);
    gap: 14px;
    align-items: start;
}

.orders-panel,
.inspector,
.request-form,
.policy-panel,
.margin-panel,
.document-table,
.finance-table {
    background: var(--surface);
    border: 2px solid var(--ink);
    box-shadow: var(--shadow);
}

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

.section-head {
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    border-bottom: 2px solid var(--ink);
}

.section-head.wide {
    margin-bottom: 12px;
    border: 2px solid var(--ink);
    background: var(--surface);
}

.section-head h2,
.section-head h1 {
    margin: 0;
}

.order-list {
    display: grid;
}

.order-row {
    display: grid;
    grid-template-columns: 14px minmax(220px, 1fr) minmax(80px, 0.35fr) 86px 78px 86px;
    gap: 12px;
    align-items: center;
    width: 100%;
    min-height: 74px;
    padding: 11px 14px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    text-align: left;
}

.order-row.is-selected {
    background: rgba(46, 196, 182, 0.12);
}

.order-main {
    min-width: 0;
}

.order-main strong,
.order-main small {
    display: block;
    overflow-wrap: anywhere;
}

.order-main small,
.order-meta,
.order-stage {
    color: var(--muted);
    font-size: 0.86rem;
}

.public-dot {
    width: 12px;
    height: 12px;
    border-radius: 99px;
    background: var(--teal);
    box-shadow: 0 0 0 4px rgba(46, 196, 182, 0.18);
}

.priority-watch .public-dot {
    background: var(--amber);
}

.priority-alert .public-dot {
    background: var(--danger);
}

.status-badge {
    justify-self: start;
    min-width: 68px;
    padding: 4px 7px;
    border: 1px solid currentColor;
    color: var(--ink);
    text-align: center;
    font-size: 0.78rem;
}

.inspector {
    position: sticky;
    top: 104px;
    padding: 16px;
}

.inspector h2,
.policy-panel h2,
.margin-panel strong {
    margin: 8px 0;
    font-size: clamp(1.35rem, 2.5vw, 2.3rem);
}

.inspector p,
.policy-panel li,
.margin-panel p {
    color: var(--muted);
    line-height: 1.45;
}

.inspector dl {
    display: grid;
    grid-template-columns: 98px 1fr;
    gap: 8px 10px;
    margin: 16px 0 0;
}

.inspector dt {
    color: var(--muted);
}

.inspector dd {
    margin: 0;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.split-work,
.finance-layout {
    display: grid;
    grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
    gap: 14px;
}

.request-form,
.policy-panel,
.margin-panel {
    padding: 18px;
}

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

.form-row {
    gap: 12px;
}

.form-row label {
    flex: 1;
}

pre {
    max-width: 100%;
    min-height: 70px;
    margin: 0;
    padding: 12px;
    overflow: auto;
    border: 1px solid var(--line);
    background: #fbfbfb;
    color: var(--ink);
    white-space: pre-wrap;
}

.policy-panel ul {
    display: grid;
    gap: 12px;
    padding-left: 18px;
}

.document-table,
.finance-table {
    display: grid;
}

.table-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.2fr) minmax(160px, 0.8fr) minmax(90px, 0.5fr) minmax(90px, 0.45fr) minmax(92px, 0.45fr);
    gap: 12px;
    align-items: center;
    min-height: 64px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
}

.table-row strong {
    overflow-wrap: anywhere;
}

.table-row span {
    color: var(--muted);
}

.doc-status-blocked,
.finance-status-risk {
    border-left: 6px solid var(--danger);
}

.doc-status-ready,
.doc-status-active,
.finance-status-paid {
    border-left: 6px solid var(--teal);
}

.margin-panel strong {
    display: block;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(3rem, 7vw, 6rem);
    line-height: 0.9;
}

.event-stream {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 12px;
    align-items: stretch;
    border-top: 3px solid var(--ink);
    background: var(--ink);
    color: var(--paper);
    padding: 12px 22px;
}

.stream-title {
    display: grid;
    align-content: center;
}

.event-stream .mono,
.event-stream small,
.event-stream span {
    color: rgba(247, 255, 247, 0.7);
}

.timeline {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(260px, 1fr);
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.event-item {
    min-height: 76px;
    padding: 10px 12px;
    border: 1px solid rgba(247, 255, 247, 0.28);
    background: rgba(247, 255, 247, 0.08);
}

.event-item strong,
.event-item small,
.event-item span {
    display: block;
    overflow-wrap: anywhere;
}

.event-item strong {
    margin: 4px 0;
}

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

dialog {
    width: min(560px, calc(100vw - 28px));
    border: 2px solid var(--ink);
    padding: 0;
    color: var(--ink);
}

dialog::backdrop {
    background: rgba(45, 49, 66, 0.55);
}

.dialog-form {
    display: grid;
    gap: 14px;
    padding: 18px;
}

.dialog-form h2 {
    margin: 4px 0 0;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.dialog-actions button:not(.primary-button) {
    min-height: 42px;
    padding: 0 14px;
    border: 2px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

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

    .command-tools {
        justify-content: stretch;
    }

    .search-box {
        min-width: 0;
        flex: 1;
    }

    .status-strip,
    .workflow-board,
    .registry-grid,
    .split-work,
    .finance-layout,
    .event-stream {
        grid-template-columns: 1fr;
    }

    .inspector {
        position: static;
    }

    .board-head {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .workspace {
        width: min(100% - 18px, 1500px);
        padding-top: 10px;
    }

    .command-bar {
        padding: 10px;
    }

    .command-tools {
        flex-wrap: wrap;
    }

    .screen-tabs,
    .filter-row {
        overflow-x: auto;
    }

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

    .order-row {
        grid-template-columns: 12px minmax(0, 1fr);
        gap: 8px;
    }

    .order-stage,
    .order-meta,
    .status-badge {
        grid-column: 2;
    }

    .table-row {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .event-stream {
        padding: 12px 10px;
    }

    .timeline {
        grid-auto-flow: row;
        grid-auto-columns: auto;
    }
}

