@font-face {
    font-family: "Atkinson Hyperlegible Next";
    src: url("../fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Atkinson Hyperlegible Next";
    src: url("../fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* tokens */
:root {
    color-scheme: light dark;

    --font-body: "Atkinson Hyperlegible Next", system-ui, sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", Menlo, monospace;

    --radius: 4px;
    --control-height: 34px;
    --row-height: 36px;

    --color-bg: light-dark(#eef0f3, #0b0d10);
    --color-surface: light-dark(#ffffff, #14171c);
    --color-surface-alt: light-dark(#f6f7f9, #1b1f26);
    --color-text: light-dark(#0f172a, #f3f5f8);
    --color-text-muted: light-dark(#475569, #a9b1bc);
    --color-border: light-dark(#cbd2db, #2b313a);
    --color-border-strong: light-dark(#94a0b0, #47505c);
    --color-row-line: light-dark(#e2e6eb, #222830);
    --color-row-hover: light-dark(#f3f6fb, #1a1e25);
    --color-accent: light-dark(#1d4ed8, #5b9cff);
    --color-accent-hover: light-dark(#1e3fae, #82b4ff);
    --color-on-accent: light-dark(#ffffff, #03070d);
    --color-link: light-dark(#1d4ed8, #8fbcff);
    --color-focus: light-dark(#1d4ed8, #82b4ff);

    --color-topbar: light-dark(#102a54, #14171c);
    --color-topbar-text: light-dark(#ffffff, #f3f5f8);
    --color-topbar-muted: light-dark(#c3cee3, #a9b1bc);
    --color-topbar-line: light-dark(#5b74a0, #47505c);
    --color-topbar-border: light-dark(#102a54, #2b313a);
    --color-topbar-indicator: light-dark(#ffffff, #5b9cff);

    --color-success: light-dark(#14532d, #d6f5e5);
    --color-success-bg: light-dark(#dcfce7, #0f2a1c);
    --color-success-line: light-dark(#15803d, #3ccf86);
    --color-warning: light-dark(#713f12, #fbecc4);
    --color-warning-bg: light-dark(#fef3c7, #3a2a08);
    --color-warning-line: light-dark(#b45309, #f2b824);
    --color-danger: light-dark(#b91c1c, #ff7b7b);
    --color-danger-text: light-dark(#7f1d1d, #ffd9da);
    --color-danger-bg: light-dark(#fee2e2, #3a1214);
    --color-danger-line: light-dark(#b91c1c, #ff5c63);

    /* risk severity, by likelihood x impact */
    --color-critical: light-dark(#7f1d1d, #140203);
    --color-critical-bg: light-dark(#fee2e2, #ff5c63);
    --color-critical-line: light-dark(#f5a3a3, #ff5c63);
    --color-high: light-dark(#7c2d12, #140802);
    --color-high-bg: light-dark(#ffedd5, #ff9a3c);
    --color-high-line: light-dark(#f8b57a, #ff9a3c);
    --color-medium: light-dark(#713f12, #141002);
    --color-medium-bg: light-dark(#fef9c3, #f2d024);
    --color-medium-line: light-dark(#e9cf4f, #f2d024);
    --color-low: light-dark(#14532d, #02140b);
    --color-low-bg: light-dark(#dcfce7, #3ccf86);
    --color-low-line: light-dark(#86d9a0, #3ccf86);
}

/* reset */
*, *::before, *::after {
    box-sizing: border-box;
}
* {
    margin: 0;
}
body {
    min-height: 100vh;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.4;
    background: var(--color-bg);
    color: var(--color-text);
}
h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    text-wrap: balance;
}
h1 {
    font-size: 22px;
}
h2 {
    font-size: 15px;
}
p {
    text-wrap: pretty;
}
p, h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
}
img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
}
input, button, textarea, select {
    font: inherit;
    color: inherit;
}
table {
    border-collapse: collapse;
}
a {
    color: var(--color-link);
}
:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 1px;
}
code, kbd, samp, .mono {
    font-family: var(--font-mono);
    font-size: 0.92em;
}
.muted {
    color: var(--color-text-muted);
}
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* top bar */
.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 24px;
    min-height: 48px;
    padding: 0 20px;
    background: var(--color-topbar);
    color: var(--color-topbar-text);
    border-bottom: 1px solid var(--color-topbar-border);
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: inherit;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
}
.brand-mark {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: var(--radius);
    background: light-dark(#ffffff, #5b9cff);
    color: light-dark(#102a54, #03070d);
    font-size: 13px;
}
.topnav {
    align-self: stretch;
}
.topnav ul {
    display: flex;
    gap: 2px;
    height: 100%;
    padding: 0;
    list-style: none;
}
.topnav a {
    display: flex;
    align-items: center;
    height: 100%;
    min-height: 48px;
    padding: 0 12px;
    color: var(--color-topbar-muted);
    text-decoration: none;
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
}
.topnav a:hover {
    color: var(--color-topbar-text);
}
.topnav a[aria-current] {
    color: var(--color-topbar-text);
    font-weight: 700;
    border-bottom-color: var(--color-topbar-indicator);
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}
.topbar-user a {
    color: inherit;
    font-weight: 700;
    text-decoration: none;
}
.topbar-user a:hover {
    text-decoration: underline;
}
.topbar-role {
    color: var(--color-topbar-muted);
}
.topbar-button {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
    cursor: pointer;
    background: transparent;
    color: var(--color-topbar-text);
    border: 1px solid var(--color-topbar-line);
    border-radius: var(--radius);
}
.topbar-button:hover {
    border-color: var(--color-topbar-text);
}

/* page layout */
.main {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 1440px;
    padding: 16px 20px 24px;
}
.page-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
}
.page-actions {
    display: flex;
    gap: 8px;
}
.columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
    gap: 12px;
    align-items: start;
}

/* panels */
.panel {
    min-width: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border);
}
.panel-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
}

/* key/value list */
.details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 16px;
}
.details dt {
    color: var(--color-text-muted);
}
.details dd {
    font-weight: 700;
}

/* notices */
#flashes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
#flashes:empty {
    display: none;
}
.notice {
    padding: 8px 12px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-accent);
    border-radius: var(--radius);
}
.notice--success {
    color: var(--color-success);
    background: var(--color-success-bg);
    border-color: var(--color-success-line);
}
.notice--warning {
    color: var(--color-warning);
    background: var(--color-warning-bg);
    border-color: var(--color-warning-line);
}
.notice--error {
    color: var(--color-danger-text);
    background: var(--color-danger-bg);
    border-color: var(--color-danger-line);
}

/* forms */
.stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
}
.stack > .button:not(.button--block) {
    align-self: flex-start;
}
.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.field > label:first-child {
    font-size: 13px;
    font-weight: 700;
}
.field-hint {
    font-size: 12px;
    color: var(--color-text-muted);
}
input:where([type="text"], [type="password"], [type="search"], [type="email"], [type="number"], [type="date"]),
select,
textarea {
    width: 100%;
    min-height: var(--control-height);
    padding: 0 10px;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
}
textarea {
    padding: 6px 10px;
}
input[aria-invalid="true"] {
    border-color: var(--color-danger);
}
input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--color-accent);
}
.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--control-height);
    padding: 0 14px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    background: var(--color-accent);
    color: var(--color-on-accent);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius);
}
.button:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
}
.button--secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border-strong);
}
.button--secondary:hover {
    background: var(--color-surface-alt);
    border-color: var(--color-border-strong);
}
.button--danger {
    background: var(--color-danger-line);
    border-color: var(--color-danger-line);
    color: light-dark(#ffffff, #140203);
}
.button--small {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
}
.button--block {
    width: 100%;
}
.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* tables */
.table-wrap {
    overflow-x: auto;
}
.table {
    width: 100%;
    font-variant-numeric: tabular-nums;
}
.table th,
.table td {
    height: var(--row-height);
    padding: 0 10px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--color-row-line);
}
.table th {
    font-size: 12px;
    color: var(--color-text-muted);
    background: var(--color-surface-alt);
    border-bottom-color: var(--color-border);
}
.table tbody tr:hover {
    background: var(--color-row-hover);
}
.table .num {
    text-align: right;
}
.table .wrap {
    white-space: normal;
}

/* severity badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 1px 7px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.badge--critical {
    color: var(--color-critical);
    background: var(--color-critical-bg);
    border-color: var(--color-critical-line);
}
.badge--high {
    color: var(--color-high);
    background: var(--color-high-bg);
    border-color: var(--color-high-line);
}
.badge--medium {
    color: var(--color-medium);
    background: var(--color-medium-bg);
    border-color: var(--color-medium-line);
}
.badge--low {
    color: var(--color-low);
    background: var(--color-low-bg);
    border-color: var(--color-low-line);
}

.badge--none {
    color: var(--color-text-muted);
    background: var(--color-surface-alt);
}
a.badge {
    text-decoration: none;
}
.badge b {
    font-variant-numeric: tabular-nums;
}
.tag {
    display: inline-block;
    margin-left: 6px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 700;
    color: var(--color-danger);
    border: 1px solid currentColor;
    border-radius: var(--radius);
}
.overdue {
    color: var(--color-danger);
    font-weight: 700;
}

/* page heading extras */
.crumbs {
    margin-bottom: 2px;
    font-size: 12px;
    color: var(--color-text-muted);
}
.crumbs a {
    color: inherit;
}
.page-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
    color: var(--color-text-muted);
}
.button-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.inline {
    display: inline;
}

/* summary numbers */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1px;
    background: var(--color-border);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.stat {
    display: block;
    padding: 10px 14px;
    color: inherit;
    text-decoration: none;
    background: var(--color-surface);
}
a.stat:hover {
    background: var(--color-row-hover);
}
.stat-label {
    font-size: 12px;
    color: var(--color-text-muted);
}
.stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}
.stat-value--danger {
    color: var(--color-danger);
}
.stat-sub {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* filters */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.toolbar input[type="search"],
.toolbar input[type="text"] {
    width: 260px;
}
.toolbar select {
    width: auto;
}
.toolbar-end {
    margin-left: auto;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* two column page body */
.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 12px;
    align-items: start;
}
.split--wide {
    grid-template-columns: minmax(0, 1fr) 380px;
}
.stack-gap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

/* table extras */
.table th .sort-link {
    color: inherit;
    text-decoration: none;
}
.table th[aria-sort] {
    color: var(--color-text);
}
.table .id {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-text-muted);
}
.table .title {
    min-width: 260px;
    white-space: normal;
}
.table .title a {
    font-weight: 700;
    text-decoration: none;
}
.table .title a:hover {
    text-decoration: underline;
}
.table tfoot th {
    color: var(--color-text);
    font-size: 14px;
    border-top: 1px solid var(--color-border);
    border-bottom: 0;
}
.table .empty td {
    height: 56px;
    text-align: center;
    color: var(--color-text-muted);
}
.table tbody tr:last-child td {
    border-bottom: 0;
}
.table select {
    width: auto;
    min-height: 28px;
}
.pager {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
}
.panel-head .meta {
    font-size: 12px;
    color: var(--color-text-muted);
}
.panel-head a {
    font-size: 12px;
}
.panel-foot {
    padding: 8px 12px;
    border-top: 1px solid var(--color-border);
}

/* risk matrix */
.matrix {
    padding: 10px 12px 12px;
}
.matrix-grid {
    display: grid;
    grid-template-columns: 18px repeat(5, 1fr);
    gap: 2px;
}
.matrix-axis {
    display: grid;
    place-items: center;
    font-size: 11px;
    color: var(--color-text-muted);
}
.matrix-cell {
    display: grid;
    place-items: center;
    height: 38px;
    font-weight: 700;
    text-decoration: none;
    border-radius: var(--radius);
    font-variant-numeric: tabular-nums;
}
.matrix-cell:hover {
    outline: 2px solid var(--color-text);
    outline-offset: -2px;
}
.matrix-cell--critical {
    background: light-dark(#c62828, #ff5c63);
    color: light-dark(#ffffff, #140203);
}
.matrix-cell--high {
    background: light-dark(#ea7a1a, #ff9a3c);
    color: #111111;
}
.matrix-cell--medium {
    background: light-dark(#f2c94c, #f2d024);
    color: #111111;
}
.matrix-cell--low {
    background: light-dark(#a3dcae, #2f8f60);
    color: light-dark(#111111, #ffffff);
}
.matrix-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11px;
    color: var(--color-text-muted);
}
.legend {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 8px;
    align-items: center;
    justify-items: start;
    margin-top: 10px;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* compact list */
.list {
    padding: 0;
    list-style: none;
}
.list li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: baseline;
    padding: 6px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--color-row-line);
}
.list li:last-child {
    border-bottom: 0;
}
.list .id {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-text-muted);
}
.list .text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.list .end {
    font-variant-numeric: tabular-nums;
}
.list .empty {
    display: block;
    color: var(--color-text-muted);
}

/* forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    max-width: 720px;
}
.form-grid .field--full {
    grid-column: 1 / -1;
}
textarea {
    min-height: 96px;
    resize: vertical;
}
.error-list {
    margin: 0;
    padding-left: 18px;
}
.prose {
    white-space: pre-wrap;
    max-width: 80ch;
}

/* sign in */
.auth {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
    padding: 64px 16px 24px;
}
.auth .brand {
    color: var(--color-text);
    font-size: 20px;
}
.auth .brand-mark {
    width: 28px;
    height: 28px;
    font-size: 16px;
    background: light-dark(#102a54, #5b9cff);
    color: light-dark(#ffffff, #03070d);
}
.auth .panel-body {
    gap: 16px;
    padding: 20px;
}
.auth .stack {
    max-width: none;
}
.auth-help {
    font-size: 13px;
    color: var(--color-text-muted);
}

/* errors */
.error-page {
    max-width: 640px;
}
.error-code {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-text-muted);
}

@media print {
    :root {
        color-scheme: light;
    }
    .topbar,
    .page-actions,
    .toolbar,
    .panel-foot,
    #flashes {
        display: none;
    }
    body {
        background: #ffffff;
        color: #000000;
    }
    .main {
        padding: 0;
    }
    .panel {
        break-inside: avoid;
    }
}

@media (max-width: 1100px) {
    .split,
    .split--wide {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 720px) {
    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .toolbar input[type="search"] {
        width: 100%;
    }
    .topnav {
        order: 3;
        width: 100%;
        overflow-x: auto;
    }
    .topnav a {
        min-height: 40px;
    }
    .topbar {
        padding: 0 16px;
    }
    .topbar-role {
        display: none;
    }
    .main {
        padding: 12px 16px 20px;
    }
}
