:root {
    --navy: #1d3557;
    --cream: #fff8f0;
    --teal: #2a9d8f;
    --coral: #e76f51;
    --ink: #172033;
    --muted: #6c7380;
    --line: rgba(29, 53, 87, 0.16);
    --surface: #fffdf8;
    --shadow: 0 22px 60px rgba(29, 53, 87, 0.12);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(29, 53, 87, 0.06) 1px, transparent 1px),
        linear-gradient(180deg, rgba(29, 53, 87, 0.05) 1px, transparent 1px),
        var(--cream);
    background-size: 72px 72px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

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

.brand {
    display: grid;
    grid-template-columns: 46px 1fr;
    gap: 12px;
    align-items: center;
    color: inherit;
    text-decoration: none;
}

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

.brand small,
.mono {
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    letter-spacing: 0;
    text-transform: uppercase;
}

.brand small {
    color: rgba(255, 248, 240, 0.68);
}

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

.tab,
.icon-button,
.primary-button,
.dialog-actions button {
    border: 0;
    border-radius: 8px;
    min-height: 42px;
}

.tab {
    padding: 11px 12px;
    color: rgba(255, 248, 240, 0.72);
    background: transparent;
    text-align: left;
}

.tab.is-active,
.tab:hover {
    color: var(--cream);
    background: rgba(255, 248, 240, 0.12);
}

.rail-status {
    margin-top: auto;
    padding: 14px;
    border-top: 1px solid rgba(255, 248, 240, 0.18);
}

.rail-status strong {
    display: block;
    margin-top: 6px;
    color: var(--teal);
}

.rail-status strong.has-warning {
    color: var(--coral);
}

.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(--muted);
    font-size: 13px;
}

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

h1 {
    margin-bottom: 0;
    color: var(--navy);
    font-size: clamp(30px, 4vw, 54px);
    line-height: 0.98;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 6px;
    font-size: 22px;
    line-height: 1.1;
    letter-spacing: 0;
}

h3 {
    margin-bottom: 4px;
    font-size: 16px;
    line-height: 1.15;
    letter-spacing: 0;
}

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

.search-box {
    display: grid;
    gap: 4px;
}

.search-box input,
.dialog-form textarea {
    width: 260px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    padding: 10px 12px;
    outline-color: var(--teal);
}

.icon-button {
    width: 42px;
    color: var(--navy);
    background: var(--surface);
    border: 1px solid var(--line);
    font-size: 22px;
}

.primary-button {
    padding: 0 16px;
    color: #fff;
    background: var(--teal);
    font-weight: 700;
}

.primary-button.full {
    width: 100%;
}

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

.metric {
    min-width: 0;
    padding: 16px;
    background: rgba(255, 253, 248, 0.92);
}

.metric strong {
    display: block;
    margin: 6px 0 3px;
    color: var(--navy);
    font-size: 28px;
    line-height: 1;
}

.metric small {
    color: var(--muted);
}

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

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

.view {
    display: none;
}

.view.is-visible {
    display: block;
}

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

.section-head p {
    margin-bottom: 0;
    color: var(--muted);
}

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

.board-wrap,
.table-zone,
.inspector,
.timeline,
.workflow-grid,
.team-grid {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 253, 248, 0.9);
}

.board-wrap {
    padding: 16px;
    margin-bottom: 18px;
}

.lane-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(210px, 1fr));
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 3px;
}

.lane {
    min-height: 270px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        repeating-linear-gradient(180deg, rgba(29, 53, 87, 0.045) 0, rgba(29, 53, 87, 0.045) 1px, transparent 1px, transparent 46px),
        #fffdf8;
}

.lane header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.lane header b {
    color: var(--navy);
    font-size: 28px;
}

.lane-track {
    height: 7px;
    margin-bottom: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(29, 53, 87, 0.1);
}

.lane-resource {
    height: 100%;
    border-radius: inherit;
    background: var(--teal);
}

.lane-items {
    display: grid;
    gap: 9px;
}

.lane-item {
    position: relative;
    display: grid;
    gap: 4px;
    width: 100%;
    min-height: 92px;
    padding: 10px;
    border: 1px solid rgba(29, 53, 87, 0.14);
    border-radius: 8px;
    background: rgba(255, 248, 240, 0.88);
    color: var(--ink);
    text-align: left;
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.lane-item:hover {
    transform: translateY(-2px);
    border-color: var(--teal);
    background: #fff;
}

.lane-item.is-conflict {
    border-color: rgba(231, 111, 81, 0.72);
    box-shadow: inset 4px 0 0 var(--coral);
}

.lane-item.is-watch {
    border-color: rgba(42, 157, 143, 0.45);
    box-shadow: inset 4px 0 0 var(--teal);
}

.lane-item small,
td small,
.team-row p,
.workflow-row p,
.scenario-result small {
    color: var(--muted);
}

.lane-time {
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    color: var(--coral);
}

.resource-chip {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    color: var(--navy);
    background: linear-gradient(90deg, rgba(42, 157, 143, 0.26) var(--value), rgba(29, 53, 87, 0.08) 0);
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    font-weight: 700;
}

.status-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    align-items: start;
}

.table-zone,
.inspector {
    padding: 16px;
}

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

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    color: var(--muted);
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    letter-spacing: 0;
    text-align: left;
    text-transform: uppercase;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

tr {
    transition: background 130ms ease;
}

tbody tr {
    cursor: pointer;
}

tbody tr:hover,
tbody tr.is-selected {
    background: rgba(42, 157, 143, 0.08);
}

td strong,
td small {
    display: block;
}

.stage-pill,
.signal {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.stage-pill {
    color: var(--navy);
    background: rgba(29, 53, 87, 0.08);
}

.signal.clear {
    color: var(--teal);
    background: rgba(42, 157, 143, 0.1);
}

.signal.watch {
    color: var(--navy);
    background: rgba(42, 157, 143, 0.2);
}

.signal.danger {
    color: var(--coral);
    background: rgba(231, 111, 81, 0.12);
}

.inspector {
    position: sticky;
    top: 24px;
}

.inspector h2 {
    color: var(--navy);
}

.inspector dl {
    display: grid;
    gap: 10px;
    margin: 16px 0;
}

.inspector dl div {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 10px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--line);
}

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

dd {
    margin: 0;
}

.scenario-panel {
    display: grid;
    gap: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.scenario-panel label {
    display: grid;
    gap: 7px;
    color: var(--muted);
}

input[type="range"] {
    accent-color: var(--teal);
}

.scenario-result {
    min-height: 82px;
    padding: 12px;
    border-radius: 8px;
    color: var(--cream);
    background: var(--navy);
}

.scenario-result strong {
    display: block;
    margin: 5px 0;
    font-size: 25px;
}

.timeline,
.workflow-grid,
.team-grid {
    padding: 8px;
}

.timeline-row,
.workflow-row,
.team-row {
    display: grid;
    gap: 14px;
    align-items: center;
    padding: 13px;
    border-bottom: 1px solid var(--line);
}

.timeline-row {
    grid-template-columns: 160px minmax(0, 1fr) 110px;
}

.timeline-row:last-child,
.workflow-row:last-child,
.team-row:last-child {
    border-bottom: 0;
}

.timeline-row time,
.timeline-row b,
.team-row b {
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    color: var(--muted);
}

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

.workflow-row div {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.workflow-row div span {
    color: var(--teal);
}

.team-row {
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 2fr) 90px;
}

.team-row > div {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: #fff;
    background: var(--navy);
    font-weight: 800;
}

.team-row.high .avatar {
    background: var(--coral);
}

.team-row.low .avatar {
    background: var(--teal);
}

.empty {
    margin: 0;
    padding: 12px;
    color: var(--muted);
}

dialog {
    width: min(520px, calc(100vw - 32px));
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: var(--shadow);
}

dialog::backdrop {
    background: rgba(29, 53, 87, 0.38);
}

.dialog-form {
    display: grid;
    gap: 16px;
    padding: 20px;
    background: var(--surface);
}

.dialog-form label {
    display: grid;
    gap: 8px;
}

.dialog-form textarea {
    width: 100%;
    resize: vertical;
}

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

.dialog-actions button:not(.primary-button) {
    padding: 0 14px;
    color: var(--navy);
    background: rgba(29, 53, 87, 0.08);
}

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

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

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

    .rail-status {
        margin-top: 0;
        border-top: 0;
        border-left: 1px solid rgba(255, 248, 240, 0.18);
    }

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

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

    .inspector {
        position: relative;
        top: 0;
    }
}

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

    .topbar {
        display: grid;
    }

    .toolbar {
        justify-content: stretch;
    }

    .search-box,
    .search-box input,
    .primary-button {
        width: 100%;
    }

    .metric-strip,
    .tabs {
        grid-template-columns: 1fr;
    }

    .lane-board {
        grid-template-columns: repeat(4, 82vw);
    }

    .timeline-row,
    .workflow-row,
    .team-row,
    .inspector dl div {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 34px;
    }
}
