/* Commercial Toolbox — MTL brand colours, as WhereAreYou. Plain on purpose: a desk tool for Accounts. */
: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; gap: .2rem; }
.app-nav a { padding: .35rem .7rem; border-radius: var(--radius); color: var(--text-muted); font-weight: 600; }
.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; }
.never-invoiced { margin-top: 1.2rem; }
.never-invoiced summary { cursor: pointer; font-weight: 600; color: var(--marine-blue); }

/* 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 (QBO status) */
.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 (vendor matching) */
.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; }

/* Nominal mapping: tabs over one panel, and the gaps list above them. */
.tabs { display: flex; gap: .2rem; flex-wrap: wrap; margin: 1rem 0 0; }
.tab { background: transparent; border: 1px solid transparent; border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; padding: .45rem .9rem; font: inherit; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.tab.active { background: var(--surface); border-color: var(--border); color: var(--marine-blue); }
.tab-panel { border-top-left-radius: 0; margin-top: 0; }
.gap-list { margin: 0; padding-left: 1.2rem; }
.gap-list li { margin: .35rem 0; }
.gap-list .btn.small { margin-left: .5rem; }
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; }

/* Help: cards grouped by the category SharePoint sends. */
.help-group { margin-top: 1.2rem; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1rem; }
.help-card { margin: 0; display: flex; flex-direction: column; gap: .4rem; }
.help-card h3 { margin: 0; }
.help-video { width: 100%; border-radius: var(--radius); background: #0d1b2a; aspect-ratio: 16 / 10; }
.help-meta { margin: auto 0 0; display: flex; gap: .5rem; align-items: center; }
/* 7 = Mapping.razor GapsShown + 1: change them together. */
.gap-list.collapsed li:nth-child(n+7) { display: none; }

/* Client invoices. One colour per ERP status, used by the tiles, the chips and the dialog alike. */
.st-forecast { --st: #7a8a8c; --st-bg: #eef1f2; }
.st-draft { --st: #5f6b6d; --st-bg: #e9ecec; }
.st-review { --st: #6a4c93; --st-bg: #efe9f6; }
.st-issued { --st: #0f6f80; --st-bg: #e3f2f5; }
.st-rejected { --st: var(--hull-red); --st-bg: #fbe9ec; }
.st-part-paid { --st: #a14e22; --st-bg: #fff1e8; }
.st-paid { --st: #1d6b4a; --st-bg: #e3f2ec; }
.chip.status { background: var(--st-bg); color: var(--st); }
.chip.status.big { font-size: .9rem; padding: .25rem .7rem; }
.chip.lock-chip { background: #fbe9ec; color: var(--hull-red); }
.lock { margin-left: .3rem; font-size: .8rem; }
.overdue { color: var(--hull-red); font-weight: 600; }

.status-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .5rem; margin: .8rem 0; }
.status-tile {
    display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; text-align: left; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--st); border-radius: var(--radius);
    padding: .5rem .7rem; font: inherit; color: var(--text);
}
.status-tile.off { opacity: .45; border-left-color: var(--border); }
.status-tile.on { box-shadow: var(--shadow); }
.status-tile .tile-label { font-weight: 600; font-size: .8rem; color: var(--st); }
.status-tile .tile-count { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; }
.status-tile .tile-value { font-size: .8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: .4rem; }
.toolbar input[type="text"] { flex: 1 1 18rem; width: auto; }
label.check { display: inline-flex; align-items: center; gap: .35rem; margin: 0; font-weight: 400; font-size: .9rem; white-space: nowrap; }
.segmented { display: inline-flex; border: 1px solid var(--marine-blue); border-radius: var(--radius); overflow: hidden; }
.segmented button { background: transparent; border: none; padding: .35rem .7rem; font: inherit; font-size: .85rem; font-weight: 600; color: var(--marine-blue); cursor: pointer; }
.segmented button.on { background: var(--marine-blue); color: #fff; }

.po-card { padding: 0; overflow: hidden; }
.po-head {
    display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; width: 100%; text-align: left;
    background: #f6f8f8; border: none; border-bottom: 1px solid var(--border); padding: .7rem 1rem; font: inherit; color: var(--text); cursor: pointer;
}
.po-caret { color: var(--text-muted); width: 1rem; display: inline-block; }
.po-title { display: flex; flex-wrap: wrap; gap: .2rem .6rem; align-items: baseline; flex: 1 1 24rem; }
.po-number { font-weight: 600; color: var(--marine-blue); }
.po-figures { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; font-size: .85rem; font-variant-numeric: tabular-nums; }
.po-bar { display: block; width: 10rem; height: .4rem; background: #e3e7e8; border-radius: 999px; overflow: hidden; }
.po-bar span { display: block; height: 100%; background: var(--marine-blue); }
.po-card .table-wrap { padding: 0 1rem .6rem; }
.invoice-table tr.clickable:hover, tr.clickable:hover { background: #f2f8f9; cursor: pointer; }
tr.unused td { color: var(--text-muted); }

.back-link { margin: 0 0 .6rem; }
.invoice-head { align-items: flex-start; flex-wrap: wrap; }
.invoice-sub { margin: .2rem 0 0; color: var(--text-muted); }
.invoice-sub strong { color: var(--text); }
.invoice-state { display: flex; gap: .4rem; align-items: center; }
.action-card.locked { border-left: 4px solid var(--hull-red); }
.action-card p { margin: 0; }
.action-card .btn-row { margin-top: .6rem; }
.totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.total { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; display: flex; flex-direction: column; }
.total span { font-size: .8rem; color: var(--text-muted); font-weight: 600; }
.total strong { font-family: var(--font-head); font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.total.gross { border-color: var(--marine-blue); }
.notes { white-space: pre-wrap; margin: 0; }
.inv-line + .inv-line { margin-top: 1rem; }
.inv-line-head { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 2px solid var(--border); }
.inv-line-head .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.items-row > td { background: #fafbfb; padding-left: 1.6rem; }
table.grid.items { font-size: .85rem; }
table.grid tfoot th { color: var(--text); border-top: 2px solid var(--border); }

.status-choices { border: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .35rem; }
.status-choices legend { font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.status-choice { display: flex; gap: .6rem; align-items: flex-start; margin: 0; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: var(--radius); font-weight: 400; cursor: pointer; }
.status-choice.on { border-color: var(--marine-blue); background: #f2f8f9; }
.status-choice .explain { display: block; margin-top: .15rem; }
.suggested { margin-left: .4rem; font-size: .78rem; font-weight: 600; color: var(--marine-blue); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
textarea, input[type="date"] {
    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);
}
@media (max-width: 640px) {
    .po-figures { align-items: flex-start; }
    .field-row { grid-template-columns: 1fr; }
}

/* Invoice files panel on /invoices (docs/invoice-files.md) */
.files-panel { margin-bottom: 1rem; }
.prompt-list { list-style: none; padding: 0; margin: .4rem 0; display: grid; gap: .35rem; }
.prompt-list li { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }

