* {
    box-sizing: border-box;
}

:root {
    --navy: #0d1b2a;
    --cream: #f5ebe0;
    --steel: #778da9;
    --amber: #e0a458;
    --paper: #fff8ef;
    --ink: #13202f;
    --line: rgba(13, 27, 42, 0.16);
    --danger: #b94b3a;
    --ok: #3f7d58;
}

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

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(rgba(245, 235, 224, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(245, 235, 224, 0.035) 1px, transparent 1px),
        var(--navy);
    background-size: 24px 24px;
}

button,
input,
select {
    font: inherit;
}

button {
    min-height: 42px;
    border: 1px solid rgba(13, 27, 42, 0.28);
    border-radius: 6px;
    background: var(--cream);
    color: var(--ink);
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

button:hover {
    transform: translateY(-1px);
    border-color: var(--amber);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.primary {
    background: var(--amber);
    color: #17130d;
    font-weight: 800;
}

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

.rail {
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 22px;
    color: var(--cream);
    border-right: 1px solid rgba(245, 235, 224, 0.16);
    background: rgba(13, 27, 42, 0.94);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--cream);
    text-decoration: none;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 0;
}

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

.rail-nav {
    display: grid;
    gap: 10px;
}

.nav-button {
    width: 100%;
    background: rgba(245, 235, 224, 0.08);
    color: var(--cream);
    border-color: rgba(245, 235, 224, 0.18);
    text-align: left;
    padding: 0 14px;
}

.nav-button.is-active {
    background: var(--cream);
    color: var(--navy);
}

.rail-status {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(245, 235, 224, 0.78);
    font-size: 12px;
    line-height: 1.35;
}

.signal {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 0 5px rgba(224, 164, 88, 0.15);
}

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

.topbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    min-height: 82px;
    padding-bottom: 18px;
    color: var(--cream);
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--amber);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(24px, 3vw, 42px);
    line-height: 1.04;
    letter-spacing: 0;
}

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

h3 {
    margin-bottom: 8px;
    font-size: 15px;
    line-height: 1.2;
}

.search {
    display: flex;
    gap: 8px;
    width: min(460px, 100%);
}

.search input,
label input,
label select {
    width: 100%;
    min-height: 42px;
    border: 1px solid rgba(245, 235, 224, 0.18);
    border-radius: 6px;
    padding: 0 12px;
    background: rgba(245, 235, 224, 0.92);
    color: var(--ink);
}

.view {
    display: none;
    animation: enter 240ms ease both;
}

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

.control-grid {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr) 310px;
    gap: 16px;
    align-items: stretch;
}

.metrics-spine,
.quick-panel,
.record,
.resource-radar,
.calendar-screen,
.report-screen,
.report-grid > section {
    border: 1px solid rgba(245, 235, 224, 0.28);
    border-radius: 8px;
    background: var(--paper);
}

.metrics-spine {
    display: grid;
    gap: 10px;
    padding: 10px;
}

.metric {
    min-height: 98px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px;
    border-radius: 6px;
    background: var(--cream);
    border-left: 5px solid var(--steel);
}

.metric span {
    font-size: 12px;
    color: rgba(19, 32, 47, 0.72);
}

.metric strong {
    font-size: 34px;
    line-height: 1;
}

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

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

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

.kanban {
    display: grid;
    grid-template-columns: repeat(4, minmax(178px, 1fr));
    gap: 12px;
    min-width: 0;
    overflow-x: auto;
}

.lane {
    min-width: 178px;
    background: rgba(245, 235, 224, 0.9);
    border: 1px solid rgba(245, 235, 224, 0.24);
    border-radius: 8px;
    min-height: 560px;
}

.lane header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid var(--line);
}

.lane header h2 {
    margin: 0;
    font-size: 15px;
    text-transform: uppercase;
}

.lane header span {
    display: grid;
    place-items: center;
    min-width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--navy);
    color: var(--cream);
    font-weight: 800;
}

.lane-body {
    display: grid;
    gap: 10px;
    padding: 10px;
}

.ticket {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fffaf3;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.ticket:hover,
.ticket.is-selected {
    transform: translateY(-2px);
    border-color: var(--amber);
    box-shadow: 0 10px 18px rgba(13, 27, 42, 0.12);
}

.ticket-top,
.ticket-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ticket h3 {
    margin: 12px 0 8px;
}

.ticket p,
.ticket-meta {
    color: rgba(19, 32, 47, 0.68);
    font-size: 12px;
    line-height: 1.35;
}

.priority {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(119, 141, 169, 0.2);
    color: var(--navy);
    font-size: 11px;
    font-weight: 800;
}

.priority--high {
    background: rgba(185, 75, 58, 0.16);
    color: var(--danger);
}

.priority--low {
    background: rgba(63, 125, 88, 0.14);
    color: var(--ok);
}

.sla {
    color: var(--danger);
    font-size: 12px;
    font-weight: 800;
}

.quick-panel {
    padding: 16px;
}

.panel-head {
    margin-bottom: 12px;
}

.quick-panel form,
.form-row {
    display: grid;
    gap: 12px;
}

label {
    display: grid;
    gap: 6px;
    color: rgba(19, 32, 47, 0.74);
    font-size: 12px;
    font-weight: 800;
}

.form-row {
    grid-template-columns: 1fr 1fr;
}

.warnings {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.warning-line {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(185, 75, 58, 0.08);
    border-color: rgba(185, 75, 58, 0.28);
    text-align: left;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 16px;
}

.record,
.resource-radar,
.calendar-screen,
.report-screen {
    padding: 18px;
}

.record-head h2 {
    margin: 12px 0 8px;
    font-size: clamp(24px, 3vw, 38px);
    max-width: 780px;
}

.record-head p,
.note {
    color: rgba(19, 32, 47, 0.7);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.detail-grid div {
    min-height: 88px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--cream);
}

.detail-grid span {
    display: block;
    margin-bottom: 10px;
    color: rgba(19, 32, 47, 0.58);
    font-size: 12px;
}

.detail-grid strong {
    overflow-wrap: anywhere;
}

.record-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stock-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 90px 48px;
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.stock-row strong,
.stock-row span {
    display: block;
    overflow-wrap: anywhere;
}

.stock-row span {
    color: rgba(19, 32, 47, 0.62);
    font-size: 12px;
}

.stock-row.is-danger b {
    color: var(--danger);
}

.gauge {
    height: 10px;
    border-radius: 999px;
    background: rgba(13, 27, 42, 0.16);
    overflow: hidden;
}

.gauge i {
    display: block;
    height: 100%;
    background: var(--amber);
}

.calendar-grid {
    display: grid;
    gap: 10px;
}

.slot {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) minmax(60px, 28%);
    gap: 14px;
    align-items: center;
    min-height: 62px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--cream);
}

.slot time {
    font-weight: 900;
}

.slot strong,
.slot span {
    display: block;
    overflow-wrap: anywhere;
}

.slot span {
    color: rgba(19, 32, 47, 0.62);
    font-size: 12px;
}

.slot em {
    height: 12px;
    width: calc(var(--span) * 24%);
    max-width: 100%;
    border-radius: 999px;
    background: var(--steel);
}

.slot--sla em,
.slot--ticket em {
    background: var(--amber);
}

.slot--act em {
    background: var(--ok);
}

.report-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.invoice-line,
.stock-chip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.invoice-line span,
.stock-chip strong {
    overflow-wrap: anywhere;
}

.invoice-line small,
.stock-chip span {
    color: rgba(19, 32, 47, 0.58);
}

.stock-chip {
    grid-template-columns: 90px minmax(0, 1fr) auto;
}

.empty-state {
    grid-column: 1 / -1;
    padding: 28px;
    border-radius: 8px;
    background: var(--paper);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: min(420px, calc(100vw - 36px));
    padding: 12px 14px;
    border-radius: 6px;
    background: var(--amber);
    color: #17130d;
    font-weight: 800;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

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

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

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

    .rail {
        position: sticky;
        top: 0;
        z-index: 5;
        flex-direction: row;
        align-items: center;
        gap: 16px;
        padding: 12px;
        overflow-x: auto;
    }

    .rail-nav {
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        overflow-x: auto;
    }

    .nav-button {
        width: auto;
        white-space: nowrap;
    }

    .rail-status {
        display: none;
    }

    .control-grid,
    .split,
    .report-grid {
        grid-template-columns: 1fr;
    }

    .metrics-spine {
        grid-template-columns: repeat(4, minmax(132px, 1fr));
        overflow-x: auto;
    }
}

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

    .topbar,
    .search,
    .record-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .brand span {
        font-size: 18px;
    }

    .control-grid {
        gap: 12px;
    }

    .metrics-spine {
        grid-template-columns: repeat(2, minmax(130px, 1fr));
    }

    .kanban {
        grid-template-columns: repeat(4, 240px);
    }

    .lane {
        min-height: 420px;
    }

    .form-row,
    .detail-grid,
    .slot,
    .invoice-line,
    .stock-chip {
        grid-template-columns: 1fr;
    }

    .stock-row {
        grid-template-columns: 1fr;
    }
}

