:root {
    color-scheme: light;
    --ink: #0d1b2a;
    --paper: #f5ebe0;
    --steel: #778da9;
    --signal: #e0a458;
    --line: rgba(13, 27, 42, 0.16);
    --muted: #657386;
    --ok: #297a56;
    --bad: #b44135;
    --white: #fffaf4;
    --shadow: 0 22px 50px rgba(13, 27, 42, 0.16);
}

* {
    box-sizing: border-box;
}

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

body {
    min-height: 100%;
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        var(--ink);
    background-size: 28px 28px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

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

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

.primary {
    background: var(--signal);
    border-color: #a66f23;
    color: var(--ink);
    font-weight: 800;
}

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

.nav-rail {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px;
    color: var(--paper);
    border-right: 1px solid rgba(245, 235, 224, 0.16);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.brand img {
    flex: 0 0 auto;
    filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.32));
}

.brand strong,
h1,
h2,
h3 {
    letter-spacing: 0;
}

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

.brand em {
    display: block;
    margin-top: 4px;
    color: rgba(245, 235, 224, 0.64);
    font-size: 12px;
    font-style: normal;
}

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

.tab {
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border-color: rgba(245, 235, 224, 0.16);
    background: rgba(245, 235, 224, 0.06);
    color: var(--paper);
}

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

.rail-meter {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(245, 235, 224, 0.16);
}

.label,
.eyebrow,
.mono {
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0;
    color: var(--muted);
}

.rail-meter .label {
    color: rgba(245, 235, 224, 0.68);
}

.rail-meter strong {
    display: block;
    margin: 8px 0;
    font-size: 34px;
    color: var(--signal);
}

.meter,
.progress {
    height: 8px;
    overflow: hidden;
    background: rgba(13, 27, 42, 0.12);
}

.rail-meter .meter {
    background: rgba(245, 235, 224, 0.16);
}

.meter span,
.progress span {
    display: block;
    height: 100%;
    background: var(--signal);
}

.workspace {
    min-width: 0;
    padding: 24px;
    background: var(--paper);
}

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

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

h1 {
    margin-bottom: 0;
    font-size: 32px;
    line-height: 1.05;
}

h2 {
    margin-bottom: 0;
    font-size: 22px;
}

h3 {
    margin-bottom: 10px;
    font-size: 16px;
}

.toolbelt {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.toolbelt input,
.toolbelt select,
.quick-panel input,
.quick-panel select,
#bookingSelect {
    min-height: 40px;
    border: 1px solid var(--line);
    background: var(--white);
    color: var(--ink);
    padding: 0 12px;
    outline: none;
}

.toolbelt input {
    width: 250px;
}

.status-line {
    min-height: 38px;
    display: flex;
    align-items: center;
    padding: 9px 12px;
    margin-bottom: 16px;
    background: rgba(119, 141, 169, 0.14);
    border-left: 4px solid var(--steel);
    color: #304053;
}

.status-line.is-error {
    background: rgba(180, 65, 53, 0.12);
    border-left-color: var(--bad);
}

.screen {
    display: none;
}

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

.hub-grid {
    display: grid;
    grid-template-columns: 148px minmax(0, 1fr) 300px;
    gap: 16px;
    align-items: start;
}

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

.metric {
    min-height: 92px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px;
    background: var(--white);
    border: 1px solid var(--line);
    box-shadow: inset 0 -4px 0 rgba(119, 141, 169, 0.18);
}

.metric.is-hot {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

.metric span {
    color: inherit;
    opacity: 0.66;
    font-size: 12px;
}

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

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

.kanban {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 10px;
}

.kanban-column {
    min-width: 0;
    background: rgba(255, 250, 244, 0.58);
    border: 1px solid var(--line);
}

.kanban-column header {
    min-height: 58px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(13, 27, 42, 0.04);
}

.kanban-column header strong,
.kanban-column header span {
    display: block;
}

.kanban-column header span {
    margin-top: 3px;
    font-size: 12px;
    color: var(--muted);
}

.kanban-column header b {
    display: grid;
    place-items: center;
    min-width: 28px;
    height: 28px;
    background: var(--ink);
    color: var(--paper);
}

.column-stack {
    display: grid;
    gap: 10px;
    padding: 10px;
}

.booking-card {
    padding: 12px;
    background: var(--white);
    border: 1px solid rgba(13, 27, 42, 0.2);
    box-shadow: var(--shadow);
    animation: rise 240ms ease both;
}

.card-top,
.slot-line,
.card-actions,
.passport-head,
.detail-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.booking-card h3 {
    margin: 10px 0 6px;
    line-height: 1.2;
}

.booking-card p,
.booking-card small {
    color: var(--muted);
}

.booking-card p {
    margin-bottom: 12px;
    line-height: 1.35;
}

.slot-line {
    margin-bottom: 10px;
    font-size: 12px;
}

.card-actions {
    margin-top: 10px;
}

.card-actions button,
.detail-actions button {
    flex: 1 1 auto;
    min-height: 34px;
    padding: 0 10px;
}

.conflict {
    padding: 4px 7px;
    font-size: 11px;
    text-transform: uppercase;
    background: rgba(224, 164, 88, 0.24);
    color: #68400c;
}

.conflict.hard,
.calendar-item.hard {
    background: rgba(180, 65, 53, 0.12);
    color: var(--bad);
}

.quick-panel,
.detail-main,
.event-log,
.report-table,
.invoice-panel,
.calendar-lane {
    background: var(--white);
    border: 1px solid var(--line);
}

.quick-panel {
    padding: 14px;
}

.quick-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.switch-light {
    width: 16px;
    height: 16px;
    border: 3px solid var(--ink);
    background: var(--signal);
    box-shadow: 0 0 0 3px rgba(224, 164, 88, 0.22);
}

.quick-panel form {
    display: grid;
    gap: 11px;
}

.quick-panel label {
    display: grid;
    gap: 5px;
    font-size: 12px;
    color: var(--muted);
}

.quick-panel input,
.quick-panel select,
.quick-panel button {
    width: 100%;
}

.details-layout,
.report-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
}

.detail-main,
.event-log,
.report-table,
.invoice-panel {
    padding: 16px;
}

.detail-main h3 {
    font-size: 24px;
    line-height: 1.15;
}

.passport-head strong {
    padding: 6px 10px;
    background: var(--signal);
}

.detail-gridline {
    display: grid;
    grid-template-columns: 128px minmax(0, 1fr);
    gap: 14px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.detail-gridline span {
    color: var(--muted);
}

.detail-gridline b {
    min-width: 0;
    overflow-wrap: anywhere;
}

.detail-actions {
    margin-top: 16px;
}

.event {
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.event span {
    display: inline-block;
    margin-bottom: 6px;
    color: var(--steel);
    font-size: 12px;
    text-transform: uppercase;
}

.event p {
    margin-bottom: 5px;
    line-height: 1.35;
}

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

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 12px;
}

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

.calendar-item {
    width: calc(100% - 20px);
    display: grid;
    gap: 4px;
    margin: 10px;
    padding: 12px;
    text-align: left;
    background: rgba(119, 141, 169, 0.12);
}

.calendar-item b,
.calendar-item em,
.calendar-item span {
    display: block;
}

.calendar-item em {
    color: var(--muted);
    font-style: normal;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.invoice-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.invoice-strip div {
    padding: 12px;
    background: rgba(224, 164, 88, 0.16);
}

.invoice-strip span,
.invoice-strip small,
.load-list span {
    display: block;
    color: var(--muted);
}

.load-list {
    margin-top: 16px;
}

.load-list p {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.empty-state {
    min-height: 92px;
    display: grid;
    place-items: center;
    color: var(--muted);
    background: rgba(13, 27, 42, 0.04);
}

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

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

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

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

    .rail-meter {
        margin-top: 0;
        min-width: 180px;
    }

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

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

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

    .topline,
    .section-title,
    .details-layout,
    .report-layout {
        display: grid;
        grid-template-columns: 1fr;
    }

    .toolbelt,
    .toolbelt input,
    .toolbelt select,
    .toolbelt button,
    #bookingSelect {
        width: 100%;
    }

    .metrics-spine,
    .kanban,
    .calendar-grid {
        grid-template-columns: 1fr;
    }

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

    .detail-gridline {
        grid-template-columns: 1fr;
        gap: 4px;
    }

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

@media (max-width: 480px) {
    h1 {
        font-size: 26px;
    }

    .brand {
        width: 100%;
    }

    .card-actions,
    .detail-actions {
        display: grid;
        grid-template-columns: 1fr;
    }
}
