/* Aspendora Client Portal.

   The palette, type and radii come from ~/code/aspendora-branding (tokens/tokens.css), copied
   into brand/tokens.css rather than re-typed, so an upstream palette change is a re-copy rather
   than a hunt through this file. Everything below maps the portal's own semantic names onto
   those tokens — reference the variables, never a raw hex.

   One brand rule is load-bearing: crimson is logo artwork only and is never a UI colour. The
   action colour is brand blue. */

:root {
    /* Portal semantics, expressed in brand tokens. */
    --bg:         var(--asp-bg-alt);
    --surface:    var(--asp-white);
    --ink:        var(--asp-text);
    --ink-muted:  var(--asp-text-muted);
    --line:       var(--asp-border);
    --accent:     var(--asp-action);
    --accent-hover: var(--asp-action-hover);
    --danger:     var(--asp-danger);
    --radius:     var(--asp-r-md);
    --font:       var(--asp-font);

    /* Reserved status colour for a threshold being crossed — never a series colour. */
    --attention:      var(--asp-warning);
    --attention-bg:   #fffaf2;
    --attention-line: #f0dcc0;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.page { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--asp-sh-header);
}

/* The logo is the mark; no wordmark beside it, per the brand's clear-space rule. */
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand img { height: 26px; width: auto; display: block; }

.org {
    padding: 0.15rem 0.6rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--ink-muted);
}

.spacer { flex: 1; }
.who { color: var(--ink-muted); font-size: 0.9rem; }
.signout { color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.signout:hover { text-decoration: underline; }

main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 2rem 1.25rem; }

h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.022em; margin: 0 0 0.35rem; }
h2 { font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 0.4rem; }
h3 { font-size: 0.92rem; font-weight: 650; margin: 0.8rem 0 0.3rem; }

.lede { color: var(--ink); margin: 0 0 1.25rem; }
.muted { color: var(--ink-muted); margin: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
    box-shadow: var(--asp-sh-card);
}

.button {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    background: var(--accent);
    color: var(--asp-white);
    border-radius: var(--asp-r-sm);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
    transition: background var(--asp-t-fast);
}
.button:hover { background: var(--accent-hover); }

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* --- Digest views ------------------------------------------------------------------- */

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.page-head h1 { margin-bottom: 0.15rem; }
.page-head p { margin: 0; }

.daynav { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.daynav-current { font-size: 0.9rem; color: var(--ink-muted); }

.button-quiet {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    font-size: 0.9rem;
}
.button-quiet:hover { border-color: var(--ink-muted); }
.button-quiet.is-disabled { opacity: 0.4; pointer-events: none; }

.stack { display: flex; flex-direction: column; gap: 0.85rem; }
.stack .card, main > .card { margin-bottom: 0; }
main > .card { margin-bottom: 0.85rem; }

.card-link { display: block; color: inherit; text-decoration: none; transition: border-color .12s; }
.card-link:hover { border-color: var(--accent); }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }

.headline { margin: 0.35rem 0 0.65rem; }
.headline-lg { font-size: 1.05rem; line-height: 1.45; margin-top: 0; }

.stats { display: flex; flex-wrap: wrap; gap: 0.35rem 1.25rem; font-size: 0.9rem; color: var(--ink-muted); }
.stats strong { color: var(--ink); font-weight: 600; }
.stats-lg { font-size: 0.95rem; gap: 0.5rem 1.75rem; }

.chip {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--line);
    font-size: 0.78rem;
    color: var(--ink-muted);
    white-space: nowrap;
}
.chip-flag { background: var(--attention-bg); border-color: var(--attention-line); color: var(--attention); }

.card-flag { border-color: var(--attention-line); background: var(--attention-bg); }
.card-meta { background: transparent; border-style: dashed; }

.note {
    margin: 0.75rem 0 0;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border-left: 3px solid var(--line);
    border-radius: 0 4px 4px 0;
    font-size: 0.88rem;
    color: var(--ink-muted);
}

.item { padding: 0.6rem 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; padding-top: 0.25rem; }
.item-head { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.evidence { margin: 0.3rem 0 0; font-size: 0.86rem; color: var(--ink-muted); }

.timeline { display: flex; flex-direction: column; }
.tl-row {
    display: grid;
    grid-template-columns: 7.5rem 7rem 1fr;
    gap: 0.6rem;
    padding: 0.4rem 0;
    border-top: 1px solid var(--line);
    font-size: 0.9rem;
}
.tl-row:first-child { border-top: 0; }
.tl-time { color: var(--ink-muted); font-variant-numeric: tabular-nums; }

.cat { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 4px; font-size: 0.78rem; }
.cat-work           { background: #e8f5ec; color: #14532d; }
.cat-work_adjacent  { background: #e8f0fd; color: #1e3a8a; }
.cat-non_work       { background: #fdecec; color: #991b1b; }
.cat-idle_or_locked { background: var(--asp-slate-100); color: var(--asp-slate-600); }
.cat-unclear        { background: var(--attention-bg); color: var(--attention); }

.bars {
    display: flex;
    align-items: flex-end;
    /* 2px of surface between adjacent bars, per mark spec */
    gap: 2px;
    height: 132px;
    margin: 0.5rem 0 0.25rem;
    /* Recessive baseline — the only axis line the chart needs */
    border-bottom: 1px solid var(--line);
}
.bar-col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; text-decoration: none; min-width: 0; }
.bar-track { position: relative; display: flex; align-items: flex-end; width: 100%; height: 105px; }
.bar {
    display: block;
    width: 100%;
    /* Categorical slot 1. Validated against the light surface: lightness band, chroma floor,
       CVD separation and contrast all pass. */
    background: var(--accent);
    /* Rounded data-end only; the bar stays anchored to the baseline */
    border-radius: 4px 4px 0 0;
    transition: background .12s;
}
.bar-col:hover .bar { background: var(--accent-hover); }
.bar-value {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 3px;
    font-size: 0.68rem;
    /* Text wears a text token, never the series colour */
    color: var(--ink-muted);
    white-space: nowrap;
}
.bar-label { font-size: 0.65rem; color: var(--ink-muted); margin-top: 4px; white-space: nowrap; overflow: hidden; }

.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 0.2rem 0 0.6rem; }
.swatch-active { background: var(--accent); }
.swatch-idle { background: #d8dade; }

.small { font-size: 0.82rem; }

.topnav { display: flex; gap: 0.9rem; margin-left: 0.5rem; }
.topnav a { color: var(--ink-muted); text-decoration: none; font-size: 0.9rem; }
.topnav a:hover { color: var(--ink); }

@media (max-width: 620px) {
    .tl-row { grid-template-columns: 1fr; gap: 0.15rem; }
    .page-head { flex-direction: column; }
}

.orgswitch { display: inline-flex; align-items: center; margin-left: 0.35rem; }
.orgswitch select {
    font: inherit;
    font-size: 0.82rem;
    color: var(--ink-muted);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.12rem 0.5rem;
    max-width: 15rem;
}
.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px;
    padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Summary tiles ------------------------------------------------------------------- */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.tile-value { font-size: 1.5rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.tile-label { font-size: 0.78rem; color: var(--ink-muted); }
/* Status colour, reserved and used only for a threshold — never as a series colour. */
.tile-alert { border-color: var(--attention-line); background: var(--attention-bg); }
.tile-alert .tile-value { color: var(--attention); }

.stat-alert strong { color: var(--attention); }

/* --- Comparison table ---------------------------------------------------------------- */

.grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.grid th {
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ink-muted);
    padding: 0.4rem 0.6rem 0.4rem 0;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.grid td { padding: 0.5rem 0.6rem 0.5rem 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tr:last-child td { border-bottom: 0; }
.grid td a { color: var(--ink); text-decoration: none; font-weight: 550; }
.grid td a:hover { color: var(--accent); text-decoration: underline; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.per-day { color: var(--ink-muted); font-size: 0.78rem; margin-left: 0.25rem; }

/* One measure, one hue — a bar against the row maximum, not a second category. */
.meter {
    display: block;
    width: 100%;
    min-width: 90px;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}
.meter-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.meter-value { font-size: 0.78rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }

.button-quiet.is-current { border-color: var(--accent); color: var(--accent); }


/* --- Forms (operator settings) ------------------------------------------------------- */
.field { display: block; margin: 0 0 1.25rem; max-width: 34rem; }
.field-label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.35rem; }
.field-hint { display: block; color: var(--ink-muted); font-size: 0.85rem; margin-top: 0.4rem; line-height: 1.45; }

.input {
    display: block;
    width: 100%;
    padding: 0.55rem 0.7rem;
    font: inherit;
    font-size: 0.95rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 1.5rem; }
.saved { color: var(--asp-success, #2e7d32); font-size: 0.9rem; }

.validation-message { display: block; color: var(--danger); font-size: 0.85rem; margin-top: 0.35rem; }
.validation-errors { color: var(--danger); font-size: 0.9rem; margin: 0 0 1rem; padding-left: 1.1rem; }

/* --- Plain data table ----------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.9rem; }
.table th {
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-muted);
    border-bottom: 1px solid var(--line);
    padding: 0 0.75rem 0.5rem 0;
}
.table td { padding: 0.55rem 0.75rem 0.55rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.is-muted td { color: var(--ink-muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; color: var(--ink-muted); }

@media (max-width: 700px) {
    .grid thead { display: none; }
    .grid tr { display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
    .grid td { border: 0; padding: 0; }
    .grid .num { text-align: left; }
}

@media (max-width: 640px) {
    .table thead { display: none; }
    .table tr { display: block; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
    .table td { display: block; border: 0; padding: 0.1rem 0; }
    .table td:first-child { font-weight: 600; }
}

/* --- Roster notices and the operator device picker ------------------------------------- */
.card.notice { border-left: 4px solid var(--attention); background: var(--attention-bg); }
.card.is-error { border-left: 4px solid var(--danger); }
.card.is-ok { border-left: 4px solid var(--accent); }

.pick-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.pick-list li { border-bottom: 1px solid var(--line); }
/* Deliberately large touch targets: this page is opened from a ticket, on a phone. */
.pick { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.9rem 0.25rem; cursor: pointer; }
.pick input[type="checkbox"] { width: 1.35rem; height: 1.35rem; margin-top: 0.15rem; flex: none; }
.pick-body { display: flex; flex-direction: column; gap: 0.15rem; }
.pick-name { font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pick-meta { color: var(--ink-muted); font-size: 0.85rem; }

/* --- Consent --------------------------------------------------------------------------- */
.consent-state { display: block; font-size: 0.85rem; }
.link-quiet { font-size: 0.8rem; color: var(--accent); text-decoration: none; }
.link-quiet:hover { text-decoration: underline; }
.choice { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; margin-bottom: 0.75rem; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--bg); }
.choice input { margin-right: 0.6rem; }
.choice-title { font-weight: 600; }
.choice-detail { display: block; color: var(--ink-muted); font-size: 0.85rem; margin: 0.25rem 0 0 1.6rem; }

/* A tile that wants attention — a non-zero count of billing differences. */
.tile.is-attention { border-color: var(--attention-line); background: var(--attention-bg); }

/* --- Request catalog ------------------------------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.cards .card { margin: 0; }
.cards .card h2 { font-size: 1rem; margin: 0 0 0.3rem; }
h3.muted { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; margin: 1rem 0 0.5rem; }
textarea.input { resize: vertical; }
