/* Cupo base + app shell. Tokens only — see cupo-tokens.css. */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--cu-paper);
    color: var(--cu-text);
    font-family: var(--cu-font);
    font-size: var(--cu-fs-body);
    line-height: var(--cu-lh);
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    margin: 0;
    line-height: var(--cu-lh-tight);
    letter-spacing: var(--cu-track-tight);
    font-weight: 800;
}

h1 { font-size: var(--cu-fs-h1); }
h2 { font-size: var(--cu-fs-h2); }
h3 { font-size: var(--cu-fs-h3); }
h4 { font-size: var(--cu-fs-body); }

p {
    margin: 0;
}

/* Inline links stay underlined. Colour alone is not a distinction — axe fails
   link-in-text-block on it, and the sign-in-again link inside the MFA alert is exactly the case
   the rule exists for. Components that happen to be anchors (buttons, nav, cards, tiles) opt out
   individually below; anything in running text keeps the rule. */
a {
    color: var(--cu-accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;
}

a:hover {
    color: var(--cu-accent-strong);
}

code, kbd, samp, pre {
    font-family: var(--cu-font-mono);
    font-size: 0.9em;
}

:focus-visible {
    outline: 2px solid var(--cu-focus);
    outline-offset: 2px;
    border-radius: var(--cu-r-sm);
}

/* Motion is decoration here, never information: nothing below conveys state by moving. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---- Icons -------------------------------------------------------------------------------- */

.cu-icon {
    font-family: 'Cupo Symbols';
    font-weight: normal;
    font-style: normal;
    font-size: 1.125rem;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    flex: none;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    -webkit-font-smoothing: antialiased;
    user-select: none;
}

.cu-icon.is-sm { font-size: 1rem; }
.cu-icon.is-lg { font-size: 1.5rem; }
.cu-icon.is-xl { font-size: 2rem; }
.cu-icon.is-filled { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }

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

/* Viewport-locked shell: the rail and the work area scroll independently. min-height alone lets
   tall pages stretch the frame, which silently disables the rail's own scrollbar. */
.cu-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.cu-topbar {
    position: sticky;
    top: 0;
    z-index: var(--cu-z-topbar);
    display: flex;
    align-items: center;
    gap: var(--cu-s3);
    height: var(--cu-topbar-h);
    padding: 0 var(--cu-s3);
    background: var(--cu-ink-800);
    color: var(--cu-text-on-ink);
    border-bottom: 1px solid var(--cu-ink-900);
    flex: none;
}

.cu-topbar :focus-visible {
    outline-color: var(--cu-focus-on-ink);
}

.cu-brand {
    display: flex;
    align-items: center;
    gap: var(--cu-s2);
    color: inherit;
    text-decoration: none;
    padding: var(--cu-s1) var(--cu-s1);
    border-radius: var(--cu-r);
}

.cu-brand:hover {
    color: inherit;
    text-decoration: none;
    background: var(--cu-ink-700);
}

/* The Hostport lockup is dark artwork on transparent; on the ink chrome it is close to invisible.
   Reversing it to a white silhouette is the standard treatment for this logo on a dark ground —
   do not "fix" it by putting a light chip behind it, which reads as a sticker. */
.cu-brand img,
.cu-auth-head img {
    display: block;
    height: 1.5rem;
    width: auto;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

.cu-brand-name {
    font-size: var(--cu-fs-lead);
    font-weight: 800;
    letter-spacing: var(--cu-track-tight);
}

.cu-brand-sub {
    font-family: var(--cu-font-mono);
    font-size: var(--cu-fs-micro);
    letter-spacing: var(--cu-track-wide);
    text-transform: uppercase;
    color: var(--cu-ink-200);
}

@media (max-width: 640px) {
    .cu-brand-sub { display: none; }
}

.cu-topbar-spacer {
    flex: 1;
}

.cu-topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--cu-s1);
}

.cu-icon-button {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: var(--cu-r);
    background: transparent;
    color: inherit;
    cursor: pointer;
    position: relative;
    transition: background-color var(--cu-dur) var(--cu-ease);
}

.cu-icon-button:hover {
    background: var(--cu-ink-700);
}

.cu-frame {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* ---- Navigation rail ----------------------------------------------------------------------- */

.cu-rail {
    width: var(--cu-rail-w);
    flex: none;
    display: flex;
    flex-direction: column;
    background: var(--cu-ink-900);
    color: var(--cu-ink-200);
    border-right: 1px solid var(--cu-ink-900);
    overflow: hidden;
}

.cu-rail :focus-visible {
    outline-color: var(--cu-focus-on-ink);
}

.cu-rail-filter {
    flex: none;
    padding: var(--cu-s2);
    border-bottom: 1px solid var(--cu-ink-700);
}

.cu-rail-filter input {
    width: 100%;
    height: 1.875rem;
    padding: 0 var(--cu-s2);
    border: 1px solid var(--cu-ink-600);
    border-radius: var(--cu-r);
    background: var(--cu-ink-800);
    color: var(--cu-text-on-ink);
    font: inherit;
    font-size: var(--cu-fs-data);
}

.cu-rail-filter input::placeholder {
    color: var(--cu-ink-400);
}

.cu-rail-filter input:focus {
    border-color: var(--cu-accent-on-ink);
    outline: none;
}

.cu-rail-scroll {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: var(--cu-s5);
}

.cu-rail-group {
    padding-top: var(--cu-s3);
}

.cu-rail-group-title {
    display: block;
    padding: 0 var(--cu-s3) var(--cu-s1);
    font-family: var(--cu-font-mono);
    font-size: var(--cu-fs-micro);
    letter-spacing: var(--cu-track-wide);
    text-transform: uppercase;
    color: var(--cu-ink-400);
    text-decoration: none;
}

a.cu-rail-group-title:hover {
    color: var(--cu-ink-200);
    text-decoration: none;
}

/* The signature device: a 3px gutter on the left edge whose colour carries meaning. In the rail it
   marks the current page; in tables and cards it carries row state. One rule, one meaning, and a
   screen full of rows reads as a vertical barcode of health. */
.cu-rail-link {
    display: flex;
    align-items: center;
    gap: var(--cu-s2);
    padding: var(--cu-s1) var(--cu-s3);
    padding-left: calc(var(--cu-s3) - var(--cu-gutter));
    border-left: var(--cu-gutter) solid transparent;
    color: var(--cu-ink-200);
    text-decoration: none;
    font-size: var(--cu-fs-data);
    line-height: 1.7;
    transition: background-color var(--cu-dur) var(--cu-ease);
}

.cu-rail-link:hover {
    background: var(--cu-ink-800);
    color: var(--cu-text-on-ink);
    text-decoration: none;
}

.cu-rail-link.is-active {
    background: var(--cu-ink-700);
    border-left-color: var(--cu-accent-on-ink);
    color: #fff;
    font-weight: 600;
}

.cu-rail-link .cu-icon {
    font-size: 1rem;
    color: var(--cu-ink-400);
}

.cu-rail-link.is-active .cu-icon {
    color: var(--cu-accent-on-ink);
}

.cu-rail-empty {
    padding: var(--cu-s4) var(--cu-s3);
    font-size: var(--cu-fs-data);
    color: var(--cu-ink-400);
}

.cu-rail-scrim {
    display: none;
}

/* Below 1100px the rail cannot push content aside, so it becomes an overlay drawer. Presence is
   still driven by the layout's expanded flag; this only changes how it is positioned. */
@media (max-width: 1100px) {
    .cu-rail {
        position: fixed;
        top: var(--cu-topbar-h);
        bottom: 0;
        left: 0;
        z-index: var(--cu-z-rail);
        max-width: 85vw;
        box-shadow: var(--cu-shadow-2);
    }

    .cu-rail-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: calc(var(--cu-z-rail) - 1);
        background: rgba(12, 27, 33, 0.5);
        border: none;
        padding: 0;
        cursor: pointer;
    }
}

/* ---- Work area ----------------------------------------------------------------------------- */

.cu-work {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--cu-s4) var(--cu-s5) var(--cu-s7);
}

@media (max-width: 720px) {
    .cu-work {
        padding: var(--cu-s3) var(--cu-s3) var(--cu-s6);
    }
}

/* Every routed page is a single vertical stack on the 4px grid. Pages set their own rhythm only
   when they genuinely need to; the default is this. */
.cu-stack {
    display: flex;
    flex-direction: column;
    gap: var(--cu-s4);
    max-width: 96rem;
}

.cu-stack.is-tight { gap: var(--cu-s2); }
.cu-stack.is-loose { gap: var(--cu-s5); }

.cu-skip-link {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.cu-skip-link:focus {
    position: fixed;
    left: var(--cu-s4);
    top: var(--cu-s2);
    z-index: calc(var(--cu-z-topbar) + 1);
    width: auto;
    height: auto;
    padding: var(--cu-s2) var(--cu-s3);
    background: var(--cu-surface);
    color: var(--cu-text);
    border-radius: var(--cu-r);
    box-shadow: var(--cu-shadow-2);
    font-weight: 600;
}

/* ---- Sign-in layout ------------------------------------------------------------------------
   The one screen that is not the console. Ink fills the viewport and the form sits on a single
   raised panel, so an operator can tell at a glance whether they are signed in. */

.cu-auth {
    min-height: 100vh;
    display: grid;
    grid-template-rows: 1fr auto;
    padding: var(--cu-s5) var(--cu-s4);
    background:
        radial-gradient(circle at 15% 0%, var(--cu-ink-700), transparent 55%),
        var(--cu-ink-900);
    color: var(--cu-text-on-ink);
}

.cu-auth-panel {
    align-self: center;
    justify-self: center;
    width: min(25rem, 100%);
    background: var(--cu-surface);
    border-left: var(--cu-gutter) solid var(--cu-accent);
    color: var(--cu-text);
    border-radius: var(--cu-r-lg);
    box-shadow: var(--cu-shadow-2);
    overflow: hidden;
}

.cu-auth-head {
    display: flex;
    align-items: center;
    gap: var(--cu-s2);
    padding: var(--cu-s4);
    background: var(--cu-ink-800);
    color: var(--cu-text-on-ink);
}

.cu-auth-body {
    display: flex;
    flex-direction: column;
    gap: var(--cu-s4);
    padding: var(--cu-s5) var(--cu-s4) var(--cu-s4);
}

.cu-auth-title {
    font-size: var(--cu-fs-h2);
}

.cu-auth-lede {
    margin-top: var(--cu-s1);
    color: var(--cu-text-muted);
    font-size: var(--cu-fs-body);
}

.cu-auth-foot {
    justify-self: center;
    padding-top: var(--cu-s4);
    font-family: var(--cu-font-mono);
    font-size: var(--cu-fs-micro);
    letter-spacing: var(--cu-track-wide);
    text-transform: uppercase;
    color: var(--cu-ink-400);
}

/* ---- Utilities ------------------------------------------------------------------------------ */

.cu-mono {
    font-family: var(--cu-font-mono);
    font-size: 0.9em;
}

.cu-muted { color: var(--cu-text-muted); }
.cu-numeric { font-variant-numeric: tabular-nums; }
.cu-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cu-break { overflow-wrap: anywhere; }

.cu-eyebrow {
    font-family: var(--cu-font-mono);
    font-size: var(--cu-fs-micro);
    letter-spacing: var(--cu-track-wide);
    text-transform: uppercase;
    color: var(--cu-text-muted);
}

.cu-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;
}

.cu-row {
    display: flex;
    align-items: center;
    gap: var(--cu-s2);
    flex-wrap: wrap;
}

.cu-row.is-end { justify-content: flex-end; }
.cu-row.is-between { justify-content: space-between; }
.cu-row.is-top { align-items: flex-start; }

.cu-grid {
    display: grid;
    gap: var(--cu-s3);
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
}

/* ---- Circuit-death banner -------------------------------------------------------------------
   #blazor-error-ui is toggled to display:block by blazor.web.js. Without it a dead circuit is a
   silent freeze: every control stops responding with no feedback at all. */

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--cu-z-toast);
    padding: var(--cu-s3) var(--cu-s7) var(--cu-s3) var(--cu-s4);
    background: var(--cu-crit);
    color: #fff;
    box-shadow: var(--cu-shadow-2);
}

#blazor-error-ui .reload {
    color: #fff;
    text-decoration: underline;
    font-weight: 600;
    margin-left: var(--cu-s2);
}

#blazor-error-ui .dismiss {
    position: absolute;
    right: var(--cu-s4);
    top: var(--cu-s3);
    cursor: pointer;
}

/* Radzen's own toast stack would otherwise land under the Cu toaster in the same corner. */
.rz-notification {
    inset-block-start: auto;
    inset-block-end: var(--cu-s4);
}
