/* BuildOps — MTL brand theme.
   Brand tokens are carried verbatim from WhereAreYou (see MTL graphics/mtl-brand-guidance-app-theme.md)
   so the two apps look like one estate. What differs below the tokens is the layout: WhereAreYou is a
   phone-first app of big tap targets, and this is an operations dashboard of dense tables read on a
   desk. Hand-built CSS, deliberately — MTL does not use Fluent UI. */
: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: 12px;
    --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;
    --font-mono: "Cascadia Mono", "Consolas", "SF Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--page-bg);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 600; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }

a { color: var(--marine-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--text-muted); }
.small { font-size: .82rem; }

/* Visually hidden, but present for screen readers — used on the links column header, which has no
   visible caption but still needs a name. */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Shell ------------------------------------------------------------------------------------- */

.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }

.app-header {
    display: flex; align-items: center; gap: .6rem;
    padding: .7rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
}
.app-header img { height: 30px; width: 30px; }
.app-header .title { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; }
/* Pushed right, and the first thing to go when the header is tight. */
.app-header .who {
    margin-left: auto; display: inline-flex; align-items: center; gap: .4rem;
    font-size: .82rem; color: var(--text-muted);
}

.app-body { flex: 1; display: flex; min-height: 0; }
.app-content {
    flex: 1; min-width: 0; padding: 1rem;
    /* Wider than WhereAreYou's 900px: the build queue has ten columns and squeezing it into a reading
       measure would put every row into a horizontal scroller on a perfectly large screen. */
    max-width: 1400px; width: 100%; margin: 0 auto; padding-bottom: 5rem;
}

/* Primary nav — fixed bottom bar on mobile, a left rail on desktop (below). */
.app-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    display: flex; background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.app-nav a {
    flex: 1; text-align: center; padding: .55rem 0 .5rem; color: var(--text-muted);
    font-size: .72rem; display: flex; flex-direction: column; align-items: center; gap: .15rem;
    text-decoration: none;
}
.app-nav a:hover { text-decoration: none; }
.app-nav a .ico { font-size: 1.3rem; line-height: 1; }
.app-nav a.active { color: var(--marine-blue); font-weight: 600; }

@media (min-width: 768px) {
    .app-nav {
        position: sticky; top: 53px; align-self: flex-start;
        flex-direction: column; width: 190px; height: calc(100dvh - 53px);
        border-top: none; border-right: 1px solid var(--border); padding: .75rem .5rem;
    }
    .app-nav a {
        flex: 0 0 auto; flex-direction: row; gap: .6rem; justify-content: flex-start;
        text-align: left; font-size: .92rem; padding: .55rem .75rem; border-radius: var(--radius);
    }
    .app-nav a.active { background: rgba(18, 143, 165, .1); }
    .app-content { padding: 1.25rem 1.5rem 2rem; }
}

.app-loading {
    min-height: 100dvh; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 1rem; color: var(--text-muted);
}

/* The MSAL redirect routes (AuthLayout). Header and nothing else: these pages are transient, and the
   shell they must NOT get is the one that loads data — see AuthLayout for why. */
.auth-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.auth-content {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: .75rem; padding: 2rem 1rem; text-align: center; color: var(--text-muted);
}

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: var(--oxidized-orange); color: #fff; padding: .7rem 1rem;
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; }
#blazor-error-ui .reload { color: #fff; text-decoration: underline; }

/* --- Page furniture ---------------------------------------------------------------------------- */

.page-head { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.page-head h1 { margin: 0; }
.as-at { margin-left: auto; font-variant-numeric: tabular-nums; }

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem;
}
.card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .25rem; }
.card-head h2 { margin: 0; }

/* --- Metric grids ------------------------------------------------------------------------------ */

/* auto-fit rather than a fixed column count: the same markup reads as one column on a phone and as five
   across on a desk, without a breakpoint per card. */
.metrics {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .75rem 1rem; margin: .85rem 0 0;
}
.metrics > div { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.metrics dt { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.metrics dd {
    margin: 0; font-family: var(--font-head); font-size: 1.25rem; font-weight: 600;
    /* Tabular figures so a refreshing number does not shuffle its neighbours sideways. */
    font-variant-numeric: tabular-nums;
    display: flex; flex-direction: column; gap: .05rem;
}
.metrics dd .small { font-family: var(--font-body); font-weight: 400; font-size: .74rem; }

/* --- Tables ------------------------------------------------------------------------------------ */

/* The table scrolls inside its own box; the page never scrolls sideways. */
.table-scroll { overflow-x: auto; margin: .5rem -1rem -1rem; padding: 0 1rem 1rem; }

table.grid { width: 100%; border-collapse: collapse; font-size: .88rem; white-space: nowrap; }
table.grid th, table.grid td {
    text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top;
}
table.grid th {
    font-family: var(--font-head); font-size: .74rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .04em; border-bottom-width: 2px;
    position: sticky; top: 0; background: var(--surface); z-index: 1;
}
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tbody tr:hover { background: rgba(18, 143, 165, .05); }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid td .small { display: block; font-weight: 400; }
table.grid td.links { display: flex; gap: .6rem; white-space: nowrap; }

/* A quota row that cannot satisfy its pools. Tinted rather than only badged, because it is the row you
   are meant to notice without reading the numbers. */
tr.row-bad td { background: rgba(147, 47, 62, .07); }

/* --- State badges ------------------------------------------------------------------------------ */

.badge {
    display: inline-flex; align-items: center; padding: .15rem .55rem;
    border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap;
    border: 1px solid transparent;
}

/* Calm, not green: this is the resting state and it should read as "nothing to see". Painting a
   scaled-to-zero pool amber is exactly the false alarm the correlation exists to prevent. */
.tone-calm { background: var(--water-ballast-white); color: var(--text-muted); border-color: var(--border); }

.tone-good { background: rgba(18, 143, 165, .12); color: var(--marine-blue); border-color: rgba(18, 143, 165, .35); }

/* Its own tone, between "fine" and "wrong": a warm agent with no job is spending money. */
.tone-billing { background: rgba(239, 131, 84, .16); color: #8A4520; border-color: rgba(239, 131, 84, .45); }

.tone-busy { background: rgba(123, 161, 166, .2); color: #3E5E63; border-color: rgba(123, 161, 166, .5); }
.tone-bad { background: rgba(147, 47, 62, .12); color: var(--hull-red); border-color: rgba(147, 47, 62, .4); }
.tone-unknown { background: var(--water-ballast-white); color: var(--text-muted); border-color: var(--border); }

/* --- Alerts ------------------------------------------------------------------------------------ */

.alert {
    margin: .75rem 0 0; padding: .7rem .85rem; border-radius: var(--radius);
    background: rgba(147, 47, 62, .09); border: 1px solid rgba(147, 47, 62, .3);
    color: var(--hull-red); font-size: .88rem; line-height: 1.45;
}

/* --- Buttons ----------------------------------------------------------------------------------- */

.btn {
    font-family: var(--font-body); font-weight: 600; font-size: 1rem;
    border: none; border-radius: var(--radius); padding: .7rem 1rem; cursor: pointer;
    background: var(--marine-blue); color: #fff; transition: background .12s ease;
}
.btn:hover { background: var(--marine-blue-hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { font-size: .85rem; padding: .45rem .8rem; }

/* --- Error state ------------------------------------------------------------------------------- */

.error-state { display: flex; gap: .75rem; align-items: flex-start; }
.error-state.panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem;
}
.error-state.inline { padding: .6rem 0; }
.error-state .error-mark { font-size: 1.3rem; line-height: 1.2; }
.error-state .error-title { margin: 0 0 .2rem; font-family: var(--font-head); font-weight: 600; }
.error-state .error-detail { margin: 0 0 .6rem; color: var(--text-muted); font-size: .9rem; }
.error-state.problem { border-left: 4px solid var(--hull-red); }
/* Benign: a sign-in redirect in flight is a transition, not a fault, and must not be dressed as one. */
.error-state.benign { border-left: 4px solid var(--north-sea-blue); }
