/* Deliberately plain. DevExpress Blazor 24.1.12 is available from the local DevExpress feed and matches the
   WinForms version already in use, but the shell must not depend on a component library before the licence
   position is confirmed in writing - so the foundation is built with ordinary markup and these components
   can be swapped in without restructuring anything. */

:root {
    --ink: #1a1c1e;
    --muted: #5b6169;
    --line: #d8dce1;
    --surface: #ffffff;
    --surface-2: #f5f7f9;
    --accent: #00694e;
    --bad: #a5202b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    color: var(--ink);
    background: var(--surface-2);
}

/* Visually hidden until focused - the first stop for a keyboard user on every page. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--ink);
    color: #fff;
    padding: 10px 14px;
    z-index: 10;
}

.skip-link:focus { left: 0; }

/* Never removed, only made obvious. */
:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.shell-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 14px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-size: 13px; color: var(--muted); }

.shell-body { flex: 1; display: flex; align-items: stretch; }

.shell-nav {
    width: 230px;
    flex: none;
    padding: 18px 12px;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.shell-nav ul { list-style: none; margin: 0 0 18px; padding: 0; }
.shell-nav li { margin-bottom: 2px; }

.shell-nav a {
    display: block;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--ink);
    text-decoration: none;
}

.shell-nav a:hover { background: var(--surface-2); }
.shell-nav a.active { background: var(--surface-2); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }

.nav-heading {
    margin: 0 0 6px;
    padding: 0 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.nav-disabled { display: block; padding: 8px 10px; color: var(--muted); }

.shell-main { flex: 1; padding: 24px 28px; }
.shell-main:focus { outline: none; }

h1 { font-size: 24px; margin: 0 0 10px; letter-spacing: -0.02em; }

.button {
    font: inherit;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
}

.button:hover:not(:disabled) { background: var(--surface-2); }
.button:disabled { color: var(--muted); cursor: default; }

.result { margin-top: 16px; }
.result .ok { color: var(--accent); }
.result .bad { color: var(--bad); }

.result pre {
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    font-size: 13px;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    background: #ffe8a3;
    border-top: 1px solid #d8c26a;
}

/* ---- Stage 2: authentication, client selection, shell ---- */

.shell-account { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.account-name { font-size: 13px; color: var(--muted); }

.client-switch { display: flex; align-items: center; gap: 6px; }
.client-switch-label { font-size: 13px; color: var(--muted); }
.client-switch select { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }

.button-quiet { padding: 5px 10px; font-size: 13px; }

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px 20px;
    margin: 0 0 18px;
    max-width: 520px;
}

.panel h2 { font-size: 16px; margin: 0 0 6px; }

.muted { color: var(--muted); }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; margin-bottom: 4px; }

.field input {
    font: inherit;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.error { color: var(--bad); max-width: 520px; }

.client-list { list-style: none; margin: 14px 0 0; padding: 0; max-width: 420px; }
.client-list li { margin-bottom: 8px; }
.client-choice { width: 100%; text-align: left; }

.risk-preview { list-style: none; margin: 14px 0 0; padding: 0; max-width: 720px; }

.risk-preview li {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    margin-bottom: 6px;
}

.risk-name { font-weight: 500; }

/* ---- Stage 3: shell, breadcrumb, ratings, states, reflow ---- */

.breadcrumb { margin: 0 0 10px; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; font-size: 13px; }
.breadcrumb li + li::before { content: "/"; margin-right: 6px; color: var(--muted); }
.breadcrumb a { color: var(--accent); }
.breadcrumb [aria-current="page"] { color: var(--muted); }

/* The colour is a swatch beside the name, never behind it - see RatingChip.razor for why. */
.rating { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

.rating-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    /* A border so a pale or white rating colour is still a visible shape rather than nothing. */
    border: 1px solid rgba(0, 0, 0, 0.35);
    flex: none;
}

.rating-score { color: var(--muted); font-variant-numeric: tabular-nums; }
.rating-none { color: var(--muted); font-style: italic; }

.state-loading { color: var(--muted); }

/* Reflow (WCAG 1.4.10): at narrow widths the navigation becomes a bar above the content rather than a
   drawer. No JavaScript, no focus trap, nothing hidden behind a control - the links stay in the tab order
   and in the same reading order they were in. */
@media (max-width: 720px) {
    .shell-body { flex-direction: column; }

    .shell-nav {
        width: auto;
        border-right: none;
        border-bottom: 1px solid var(--line);
        padding: 10px 12px;
    }

    .shell-nav ul { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
    .shell-nav li { margin-bottom: 0; }
    .shell-nav a.active { box-shadow: inset 0 -3px 0 var(--accent); }

    .shell-header { flex-wrap: wrap; gap: 8px 12px; }
    .shell-account { margin-left: 0; width: 100%; }
    .shell-main { padding: 16px 14px; }
}

/* Respect a stated preference for less motion rather than assuming everyone wants transitions. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---- Stage 4: the register ---- */

.register-controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin: 12px 0 6px; }

.field-inline { display: flex; align-items: center; gap: 8px; }
.field-inline span { font-size: 13px; color: var(--muted); }

.field-inline input {
    font: inherit;
    padding: 7px 10px;
    min-width: 260px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.field-checkbox { display: flex; align-items: center; gap: 7px; font-size: 14px; }

/* Wide tables scroll inside their own box rather than pushing the page sideways, which is what keeps
   reflow at 320px honest. tabindex makes the scroll region reachable by keyboard, otherwise a keyboard
   user cannot scroll it at all. */
.table-scroll { overflow-x: auto; margin-top: 10px; }

.register {
    border-collapse: collapse;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
}

.register th, .register td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.register thead th { padding: 0; background: var(--surface-2); white-space: nowrap; }
.register tbody tr:last-child th, .register tbody tr:last-child td { border-bottom: none; }
.register tbody tr:hover { background: var(--surface-2); }

.register th[scope="row"] { font-weight: 500; }
.cell-risk { min-width: 260px; }

.sort-header {
    font: inherit;
    font-weight: 600;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
}

.sort-header:hover { background: rgba(0, 0, 0, 0.04); }
.sort-arrow { color: var(--accent); }

.flag {
    display: inline-block;
    padding: 1px 7px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px;
}

/* Available to assistive technology, absent from the visual design. */
.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;
}

/* ---- Stage 5: risk detail ---- */

.panel-wide {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 0 0 16px;
}

.panel-wide h2 { font-size: 16px; margin: 0 0 12px; }
.panel-wide h3 { font-size: 14px; margin: 0 0 8px; }

.banner {
    background: #fff6dd;
    border: 1px solid #e0c675;
    border-radius: 6px;
    padding: 10px 12px;
    margin: 0 0 14px;
}

.positions { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 14px; }

.position {
    flex: 1 1 190px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 14px;
}

.position-rating { margin: 0 0 8px; font-size: 15px; }
.position-levels { margin: 0; font-size: 13px; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.facts-inline { margin-bottom: 16px; }

.position-levels { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; }
.position-levels dt { color: var(--muted); }
.position-levels dd { margin: 0; }

.assessment { padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 10px; }

/* The current assessment is distinguished by a heading, a badge and a heavier border - three signals, so
   it does not depend on the border colour alone. */
.assessment-current { border-color: var(--accent); border-left-width: 4px; }

.badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    vertical-align: middle;
}

.history-heading { margin-top: 18px; }
.assessment-history { list-style: none; margin: 0; padding: 0; }
.rationale { margin: 8px 0 0; font-size: 14px; }

.history { list-style: none; margin: 0; padding: 0; }
.history-entry { padding: 8px 0; border-bottom: 1px solid var(--line); }
.history-entry:last-child { border-bottom: none; }
.history-line { margin: 0; font-size: 14px; }
.history-reason { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

.cell-risk a { color: var(--accent); }
