/* Work Management — MTL brand colours, as WhereAreYou. Plain on purpose: Cost Control's house style, no component library (D9). */
:root {
    --cargo-tank-black: #262626;
    --water-ballast-white: #EBEBEB;
    --marine-blue: #128FA5;
    --marine-blue-hover: #0F7F93;
    --hull-red: #932F3E;
    --north-sea-blue: #7BA1A6;
    --oxidized-orange: #EF8354;

    --page-bg: var(--water-ballast-white);
    --surface: #FFFFFF;
    --text: var(--cargo-tank-black);
    --text-muted: #5F6B6D;
    --border: #D6D6D6;

    --radius: 8px;
    --shadow: 0 1px 3px rgba(38, 38, 38, .12), 0 1px 2px rgba(38, 38, 38, .08);
    --font-head: "Montserrat", "Segoe UI", Arial, sans-serif;
    --font-body: "Source Sans 3", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--page-bg);
    color: var(--text);
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 600; margin: 0 0 .5rem; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; margin-top: 1.2rem; }

a { color: var(--marine-blue); text-decoration: none; }

/* Shell */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.app-header img { height: 28px; width: 28px; }
.app-header .title { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; margin-right: 1rem; }
.app-nav { display: flex; flex-wrap: wrap; gap: .2rem; min-width: 0; }
.app-nav a { padding: .35rem .7rem; border-radius: var(--radius); color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.app-nav a.active { color: var(--marine-blue); background: #e8f4f6; }
.app-content { flex: 1; padding: 1rem; max-width: 1280px; width: 100%; margin: 0 auto; }

.page-head, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.page-head h1, .section-head h2 { margin: 0; }

/* Cards */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem;
}
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.notice { background: #fff8f0; border: 1px solid var(--oxidized-orange); border-radius: var(--radius); padding: .6rem .8rem; }
.saved-note { color: var(--marine-blue); font-weight: 600; }
.spinner { color: var(--text-muted); padding: .5rem 0; }

/* Buttons */
.btn {
    display: inline-block; font-family: var(--font-body); font-weight: 600; font-size: .95rem;
    border: none; border-radius: var(--radius); padding: .55rem 1rem; cursor: pointer;
    background: var(--marine-blue); color: #fff;
}
.btn:hover { background: var(--marine-blue-hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--marine-blue); border: 1px solid var(--marine-blue); }
.btn.small { font-size: .85rem; padding: .35rem .7rem; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }

/* Forms */
label { display: block; font-weight: 600; font-size: .85rem; margin: .8rem 0 .25rem; }
select, input[type="text"], input[type="number"] {
    width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: var(--radius);
    font-family: var(--font-body); font-size: 1rem; background: #fff; color: var(--text);
}
.search-row { display: flex; gap: .5rem; margin-bottom: .6rem; }
.search-row select { width: auto; flex: 0 0 auto; min-width: 10rem; }
/* In a table cell, 100% of a narrow column clipped the Kind choices to two letters. */
.grid select { width: auto; min-width: 7.5rem; padding: .3rem .4rem; font-size: .9rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid th, table.grid td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.grid th { font-weight: 600; color: var(--text-muted); font-size: .8rem; }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid .detail { min-width: 16rem; }

/* Status chips */
.chip { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.chip.good { background: #e3f2ec; color: #1d6b4a; }
.chip.wait { background: #eef1f2; color: var(--text-muted); }
.chip.bad { background: #fbe9ec; color: var(--hull-red); }
.chip.warn { background: #fff1e8; color: #a14e22; }
/* Category types (core.CategoryType): outlined, so they never read as a status. */
.chip.type { background: transparent; border: 1px solid currentColor; font-weight: 600; }
.chip.type-part { color: var(--marine-blue); }
.chip.type-service { color: #6a4c93; }
.chip.type-rental { color: #a14e22; }
.chip.type-none { color: var(--text-muted); }

/* Facts list */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 1rem; }
.facts dt { font-weight: 600; color: var(--text-muted); }
.facts dd { margin: 0; }

/* Pick lists */
.pick-list { list-style: none; padding: 0; margin: 0; max-height: 18rem; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.pick-list li + li { border-top: 1px solid var(--border); }
.pick { display: flex; align-items: center; gap: .5rem; margin: 0; padding: .45rem .6rem; font-weight: 400; font-size: .95rem; cursor: pointer; }
.pick.inactive { color: var(--text-muted); cursor: default; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(38, 38, 38, .45); z-index: 40; }
.modal {
    position: fixed; z-index: 50; top: 8vh; left: 50%; transform: translateX(-50%);
    width: min(640px, calc(100vw - 2rem)); max-height: 84vh; overflow-y: auto;
    background: var(--surface); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0, 0, 0, .25); padding: 1rem 1.2rem;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.modal-head h2 { margin: 0; }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text-muted); }

/* Failed API calls (ErrorState.razor): a `panel` that replaces a section whose load failed, an `inline`
   strip beside a refused action. `benign` is the signing-in transition, which is not a fault. */
.error-state {
    display: flex; gap: .7rem; align-items: flex-start;
    border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: 1rem;
    background: var(--surface); border: 1px solid var(--border);
}
.error-state.problem { background: #fdf5f6; border-color: var(--hull-red); }
.error-state.benign { background: var(--surface); border-color: var(--border); }
.error-state.inline { padding: .5rem .7rem; font-size: .9rem; }
.error-mark { font-size: 1.1rem; line-height: 1.4; flex: none; }
.error-body { min-width: 0; }
.error-title { font-family: var(--font-head); font-weight: 600; margin: 0; }
.error-detail { color: var(--text-muted); margin: .2rem 0 0; }
.error-state .btn.small { margin-top: .6rem; }

.app-loading { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; }

#blazor-error-ui {
    background: var(--hull-red); color: #fff; bottom: 0; display: none; left: 0; right: 0;
    padding: .8rem 1rem; position: fixed; z-index: 1000;
}
#blazor-error-ui .reload { color: #fff; text-decoration: underline; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: .8rem; }

a.btn { display: inline-block; }

/* Blazor focuses the page heading after navigation (FocusOnNavigate) for screen readers; no ring is needed on a heading. */
h1:focus { outline: none; }

/* A chip that follows text in the same cell. */
.chip.beside { margin-left: .4rem; }

/* Danger buttons: destructive confirmations. */
.btn.danger { background: var(--hull-red); }
.btn.danger:hover { background: #7a2633; }

/* Contract picker (Pages/Contracts.razor) */
.contract-list { list-style: none; padding: 0; margin: 0 0 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.contract-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: .55rem .8rem; flex-wrap: wrap; }
.contract-list li + li { border-top: 1px solid var(--border); }
.contract-list a { display: flex; gap: .7rem; min-width: 0; font-weight: 600; }
.contract-list .contract-id { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.other-contracts > summary { cursor: pointer; font-family: var(--font-head); font-weight: 600; padding: .3rem 0 .6rem; }
.other-contracts .contract-list { opacity: .85; }

/* The contract board (Pages/Board.razor) */
.board-head { flex-wrap: wrap; }
.board-tools { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.segmented { display: inline-flex; border: 1px solid var(--marine-blue); border-radius: var(--radius); overflow: hidden; }
.segmented button { border: none; background: var(--surface); color: var(--marine-blue); font: inherit; font-size: .85rem; font-weight: 600; padding: .35rem .7rem; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--marine-blue); }
.segmented button.on { background: var(--marine-blue); color: #fff; }
.inline-check { display: inline-flex; align-items: center; gap: .35rem; margin: 0; font-weight: 600; font-size: .85rem; }

.board-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.board { min-width: 56rem; }
.board-row { display: grid; grid-template-columns: minmax(18rem, 24rem) 1fr; border-bottom: 1px solid var(--border); }
.board-row:last-child { border-bottom: none; }
.row-label { display: flex; align-items: flex-start; gap: .4rem; padding: .4rem .6rem; min-width: 0; border-right: 1px solid var(--border); }
.label-text { min-width: 0; }
.label-main { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.label-sub { margin-top: .1rem; }
.row-label .ref { font-variant-numeric: tabular-nums; color: var(--text-muted); font-weight: 600; }
.row-label .name { font-weight: 600; }
.board-row.phase .row-label { padding-left: 2.2rem; }
.board-row.phase .row-label .name { font-weight: 400; }
.row-label .seq { color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 1.2rem; }
.row-label .objective { color: var(--text); }
.row-label .toggle { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 0 .1rem; font-size: .9rem; line-height: 1.4; }
.board-row.workscope { background: #f6f9fa; }
.board-row.other .row-label { padding-left: 2.2rem; }
.board-row.attention > .row-label { box-shadow: inset 3px 0 0 var(--hull-red); }
.board-row.attention.phase { background: #fdf5f6; }
.attention-mark { font-size: .72rem; }

.row-track { position: relative; min-height: 2.2rem;
    background-image: linear-gradient(to right, var(--border) 1px, transparent 1px);
    background-size: calc(100% / var(--cols)) 100%; }
.row-track.scale { display: grid; grid-template-columns: repeat(var(--cols), 1fr); align-items: end; min-height: 0; }
.row-track.scale span { font-size: .75rem; line-height: 1.15; color: var(--text-muted); padding: .35rem .2rem; text-align: center; overflow: hidden; }
.row-track.scale span.today { color: var(--marine-blue); font-weight: 700; }
.row-track .finer { position: absolute; top: 0; bottom: 0; left: 0; background: rgba(123, 161, 166, .12); pointer-events: none; }
.row-track .today-line { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--oxidized-orange); opacity: .7; pointer-events: none; }

.bar { position: absolute; top: 50%; height: .8rem; margin-top: -.4rem; border-radius: 4px; min-width: 4px; }
.bar.runs-before { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bar.runs-after { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.bar-workscope { height: .35rem; margin-top: -.175rem; background: var(--north-sea-blue); opacity: .55; }
.bar-phase.active { background: var(--marine-blue); }
.bar-phase.planned { background: #fff; border: 2px solid var(--marine-blue); }
.bar-phase.on-hold { background: repeating-linear-gradient(45deg, #c9d3d5, #c9d3d5 4px, #eef1f2 4px, #eef1f2 8px); }
.bar-phase.overrunning { background: var(--hull-red); }
.overrun-tail { background: repeating-linear-gradient(45deg, rgba(147, 47, 62, .55), rgba(147, 47, 62, .55) 3px, rgba(147, 47, 62, .15) 3px, rgba(147, 47, 62, .15) 6px); }
