/*
 * Design tokens. Dark "heads-up display" theme: deep navy gradient ground,
 * translucent cards framed by inset hairlines and corner brackets, a teal
 * accent, and green / amber / red status colours. Chakra
 * Petch (light weight, wide tracking) everywhere except code, which uses the
 * system monospace stack.
 */
:root {
    /* Dark theme; renders native controls (inputs, scrollbars) dark too. */
    color-scheme: dark;

    --ground: #0a141e;
    --ground-rgb: 10, 20, 30;
    --header: #0c1a27;
    --header-rgb: 12, 26, 39;
    --panel: #101e2c;
    --panel-rgb: 16, 30, 44;
    --panel-2: #152838;
    --line: rgba(150, 190, 220, 0.14);
    --line-strong: rgba(150, 190, 220, 0.28);
    /* Corner brackets and card frames. */
    --frame: rgba(150, 190, 220, 0.3);
    --corner: rgba(150, 190, 220, 0.75);

    --text: #e4edf5;
    --text-rgb: 228, 237, 245;
    --muted: #7f97ac;
    --faint: #4f667a;

    --accent-rgb: 64, 194, 204;
    --accent: rgb(var(--accent-rgb));
    --accent-soft: rgba(var(--accent-rgb), 0.16);
    /* Text on accent-filled buttons; the teal needs dark text for contrast. */
    --on-accent: #07202b;

    --ok: #2fd58c;
    --ok-soft: rgba(47, 213, 140, 0.14);
    --warn: #f0a83a;
    --warn-soft: rgba(240, 168, 58, 0.16);
    --crit: #f2606b;
    --crit-soft: rgba(242, 96, 107, 0.16);
    /* Pull requests deployed on an ETS server: violet, so it never reads as a verdict. */
    --deployed-rgb: 168, 140, 255;
    --deployed: rgb(var(--deployed-rgb));
    --deployed-soft: rgba(var(--deployed-rgb), 0.12);

    --font-sans: "Chakra Petch", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    --tracking: 0.046875rem;

    --header-height: 3.25rem;
    --sidebar-width: 15rem;
    --radius: 4px;
    --radius-lg: 8px;

    /* Legacy aliases kept for rules that predate the token rename. */
    --bg: var(--ground);
    --surface: var(--panel);
    --border: var(--line);
    --accent-dark: var(--text);
    --accent-contrast: var(--on-accent);
    --error-bg: var(--crit-soft);
    --error-text: var(--crit);
    --info-bg: var(--accent-soft);
    --info-text: var(--accent);
    --radius-sm: var(--radius);
}

* {
    box-sizing: border-box;
}

/* Always reserve the vertical scrollbar's space so the page does not jump
   sideways when content grows past the viewport. Browsers without
   scrollbar-gutter support fall back to a permanently visible scrollbar. */
html {
    min-height: 100%;
    overflow-y: scroll;
    background-color: var(--ground);
    background-image: linear-gradient(180deg, rgba(16, 44, 60, 0.9) 0%, #060d15 100%);
    background-attachment: fixed;
}

@supports (scrollbar-gutter: stable) {
    html {
        overflow-y: auto;
        scrollbar-gutter: stable;
    }
}

body {
    position: relative;
    min-height: 100vh;
    margin: 0;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 300;
    line-height: 1.5;
    letter-spacing: var(--tracking);
    -webkit-font-smoothing: antialiased;
    background: transparent;
    color: var(--text);
}

a {
    color: var(--accent);
}

b,
strong {
    font-weight: 600;
}

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    letter-spacing: 0;
}

button,
input,
select,
textarea {
    letter-spacing: inherit;
}

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

/* Material Symbols ligature glyphs (Google Fonts); the icon is a font, so
   its size and weight are set like text. */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined', sans-serif;
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    direction: ltr;
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
    /* Hide the ligature text until the font has loaded. */
    overflow: hidden;
    max-width: 1em;
}

/* Small bold uppercase caption used for card titles and field labels. */
.eyebrow,
.pr-panel-header h1,
.panel h1,
.bucket-panel h2,
.servers-page h2,
.report-card h2,
.pr-details h2,
.pr-details h3,
.comments h3,
.ai-status-section h2,
.stacked-form label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: var(--tracking);
    text-transform: uppercase;
    color: var(--text);
}

/* ---- Cards ----
   Transparent surfaces framed the HUD way: hairlines inset 15px along each
   edge (the pseudo-elements) and a bracket in each corner (eight gradient
   strokes painted in the background). Children stack above the frame. */
.pr-panel,
.panel,
.ai-status-section,
.card {
    position: relative;
    isolation: isolate;
    padding: 1rem;
    border: none;
    border-radius: 0;
    background-color: rgba(var(--panel-rgb), 0.35);
    background-image: linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner));
    background-size: 10px 2px, 2px 10px,
    10px 2px, 2px 10px,
    10px 2px, 2px 10px,
    10px 2px, 2px 10px;
    background-position: top left, top left,
    top right, top right,
    bottom left, bottom left,
    bottom right, bottom right;
    background-repeat: no-repeat;
}

.pr-panel::before,
.panel::before,
.ai-status-section::before,
.card::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 15px;
    right: 15px;
    z-index: -1;
    pointer-events: none;
    border-top: 1px solid var(--frame);
    border-bottom: 1px solid var(--frame);
}

.pr-panel::after,
.panel::after,
.ai-status-section::after,
.card::after {
    content: "";
    position: absolute;
    top: 15px;
    bottom: 15px;
    left: 0;
    right: 0;
    z-index: -1;
    pointer-events: none;
    border-left: 1px solid var(--frame);
    border-right: 1px solid var(--frame);
}

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

.alert {
    padding: 0.75rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    line-height: 1.45;
}

.alert-error {
    background: var(--crit-soft);
    border-color: rgba(242, 96, 107, 0.5);
    color: var(--crit);
}

.alert-info {
    background: var(--accent-soft);
    border-color: rgba(var(--accent-rgb), 0.4);
    color: var(--accent);
}

.update-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0;
    border-radius: 0;
    border-width: 0 0 1px;
    padding: 0.625rem 2rem;
}

/* ---- App shell: header, sidebar, content ----
   The hidden checkbox carries the sidebar's toggled state so the hamburger
   works without JavaScript (the CSP allows no inline scripts). On desktop
   "checked" collapses the sidebar; on small screens it slides it in. */

.app {
    padding-top: var(--header-height);
}

.sidebar-toggle {
    display: none;
}

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    height: var(--header-height);
    background: rgba(var(--header-rgb), 0.95);
    border-bottom: 1px solid var(--line);
}

.menu-toggler {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
}

.menu-toggler .bar {
    display: block;
    width: 1.625rem;
    height: 1px;
    background: rgba(var(--text-rgb), 0.4);
    transition: background-color 0.2s linear;
}

.menu-toggler .bar + .bar {
    margin-top: 0.25rem;
}

.menu-toggler:hover .bar {
    background: rgba(var(--text-rgb), 0.75);
}

.app-header .brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
    padding: 0 1rem 0 0.25rem;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 400;
    letter-spacing: 2px;
    text-decoration: none;
    text-transform: uppercase;
    white-space: nowrap;
}

/* The boxed initial: a bordered square with bracketed corners. */
.app-header .brand-img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border: 1px solid var(--line-strong);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--accent);
    background-image: linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner)),
    linear-gradient(var(--corner), var(--corner));
    background-size: 6px 2px, 2px 6px,
    6px 2px, 2px 6px,
    6px 2px, 2px 6px,
    6px 2px, 2px 6px;
    background-position: -1px -1px, -1px -1px,
    calc(100% + 1px) -1px, calc(100% + 1px) -1px,
    -1px calc(100% + 1px), -1px calc(100% + 1px),
    calc(100% + 1px) calc(100% + 1px), calc(100% + 1px) calc(100% + 1px);
    background-repeat: no-repeat;
}

.app-header .spacer {
    flex: 1;
}

/* The repository sits at the right as a small tag. */
.app-header .repo {
    padding: 0.1rem 0.4rem;
    border: 1px solid rgba(var(--accent-rgb), 0.4);
    border-radius: 3px;
    font-size: 0.7rem;
    color: var(--accent);
    white-space: nowrap;
}

.app-header .user {
    padding: 0 0.5rem 0 1rem;
    color: var(--text);
    white-space: nowrap;
}

.logout-form {
    height: 100%;
    margin: 0;
}

.header-link {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    color: var(--text);
    font: inherit;
    cursor: pointer;
    transition: color 0.2s linear;
}

.header-link:hover {
    color: var(--accent);
}

.header-link .material-symbols-outlined {
    font-size: 22px;
}

.app-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    z-index: 1010;
    width: var(--sidebar-width);
    overflow-y: auto;
    transition: transform 0.15s ease-in-out;
}

.sidebar-resources {
    margin-top: auto;
    padding-bottom: 1rem;
}

.menu-header {
    padding: 1rem 1rem 0.5rem;
    font-size: 0.65625rem;
    font-weight: 600;
    color: var(--faint);
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 0.3rem 1rem;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

.menu-link:hover {
    color: var(--text);
}

.menu-link .menu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.875rem;
    height: 1.875rem;
    margin: -0.25rem 0.75rem -0.25rem 0;
}

.menu-link .menu-text {
    flex: 1;
}

.menu-link.active {
    color: var(--text);
}

.menu-link.active .menu-icon {
    color: var(--accent);
}

.sidebar-backdrop {
    display: none;
}

.app-content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    transition: margin-left 0.15s ease-in-out;
}

@media (min-width: 992px) {
    body:has(.sidebar-toggle:checked) .app-sidebar {
        transform: translateX(-100%);
    }

    body:has(.sidebar-toggle:checked) .app-content {
        margin-left: 0;
    }
}

@media (max-width: 991.98px) {
    .app-sidebar {
        background: rgba(var(--header-rgb), 0.98);
        border-right: 1px solid var(--line);
        transform: translateX(-100%);
    }

    .app-content {
        margin-left: 0;
        padding: 1rem;
    }

    .app-header .user {
        display: none;
    }

    body:has(.sidebar-toggle:checked) .app-sidebar {
        transform: none;
    }

    body:has(.sidebar-toggle:checked) .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: var(--header-height) 0 0 0;
        z-index: 1005;
        background: rgba(0, 0, 0, 0.4);
        cursor: pointer;
    }

    .update-banner {
        padding: 0.625rem 1rem;
    }
}

/* Page title above the cards (Controls). */
.page-header,
.admin-page > h1 {
    margin: 0 0 1rem;
    padding: 0 0 1rem;
    border-bottom: 1px solid var(--line);
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.2;
}

.page-header small,
.admin-page > h1 small {
    font-size: 1rem;
    font-weight: 300;
    color: var(--muted);
}

/* Plain inline links such as "View on GitHub" on the PR page. */
.nav-link {
    color: var(--accent);
    text-decoration: none;
}

.nav-link:hover {
    text-decoration: underline;
}

.link-button {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.link-button:hover {
    text-decoration: underline;
}

.link-button.danger {
    color: var(--crit);
}

/* ---- Card headings ---- */

.pr-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Header buttons of the pull request page, e.g. Merge master next to Refresh. */
.pr-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pr-panel-header h1,
.panel h1,
.bucket-panel h2,
.report-card h2,
.pr-details h2 {
    margin: 0;
}

.panel h1 {
    margin-bottom: 1rem;
}

.pr-panel-header h1 small,
.panel h1 small,
.servers-page h2 small,
.report-card h2 small {
    margin-left: 0.5rem;
    font-size: 0.75rem;
    font-weight: 300;
    text-transform: none;
    color: var(--muted);
}

.panel h2 {
    margin: 1.5rem 0 0.5rem;
    font-size: 1.09375rem;
    font-weight: 600;
}

.panel > h2:first-child {
    margin-top: 0;
}

/* ---- Buttons ----
   HUD buttons are outlines: neutral ones use the hairline colour, primary
   ones the accent, danger ones the critical colour; hovering fills them. */

.refresh,
.action-button,
.bucket-toggle,
.stacked-form button,
.comment-form button,
.login-card button[type="submit"],
.update-banner button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
    border-color 0.15s ease-in-out;
}

.refresh:hover:enabled,
.action-button:hover:enabled,
.bucket-toggle:hover {
    background: rgba(var(--text-rgb), 0.1);
    border-color: var(--text);
}

.refresh:disabled,
.action-button:disabled {
    cursor: default;
    opacity: 0.45;
}

.action-button.danger:hover:enabled {
    background: var(--crit);
    border-color: var(--crit);
    color: #fff;
}

.stacked-form button,
.comment-form button,
.login-card button[type="submit"],
.update-banner button {
    border-color: var(--accent);
    color: var(--accent);
}

.stacked-form button:hover:enabled,
.comment-form button:hover:enabled,
.login-card button[type="submit"]:hover:enabled,
.update-banner button:hover:enabled {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

.stacked-form button:disabled,
.comment-form button:disabled,
.update-banner button:disabled {
    opacity: 0.45;
    cursor: default;
}

.update-banner button:disabled {
    cursor: wait;
}

.stacked-form button.danger-button,
.danger-button {
    border-color: var(--crit);
    color: var(--crit);
}

.stacked-form button.danger-button:hover:enabled,
.danger-button:hover:enabled {
    background: var(--crit);
    border-color: var(--crit);
    color: #fff;
}

.refresh-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 1.375rem;
    padding: 0 0.35rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
}

.refresh-mini:hover:enabled {
    border-color: var(--accent);
    color: var(--accent);
}

.refresh-mini:disabled {
    opacity: 0.45;
    cursor: default;
}

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

.pr-group {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line-strong);
}

.pr-group h2 {
    margin: 0 0 0.75rem;
    font-size: 0.9375rem;
}

.pr-group h2 small {
    color: var(--muted);
    font-size: inherit;
    font-weight: 400;
}

/* Keeps an over-wide table scrolling inside the card instead of overflowing
   past its frame. */
.pr-table-scroll,
.data-table-scroll {
    overflow-x: auto;
}

.pr-table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    vertical-align: top;
}

/* Every PR section uses the same grid, independent of its titles or row count.
   The title gets the remaining width; narrow screens scroll inside each card. */
.pr-dashboard-table {
    table-layout: fixed;
    min-width: 84rem;
}

.db-change {
    white-space: nowrap;
}

.pr-dashboard-table .pr-col-db-change {
    width: 8rem;
}

.last-commit {
    white-space: nowrap;
}

.pr-dashboard-table .pr-col-last-commit {
    width: 8rem;
}

.pr-dashboard-table .pr-col-author {
    width: 9rem;
}

.pr-dashboard-table .pr-col-check {
    width: 5rem;
}

.pr-dashboard-table .pr-col-functional {
    width: 7rem;
}

.pr-dashboard-table .pr-col-spotbugs {
    width: 6rem;
}

.pr-dashboard-table .pr-col-summary {
    width: 11rem;
}

.pr-dashboard-table td:first-child,
.pr-dashboard-table td:nth-child(2) {
    overflow-wrap: anywhere;
}

.pr-dashboard-table .report-cell {
    max-width: 100%;
    white-space: normal;
}

.pr-dashboard-table .report-link {
    min-width: 0;
    overflow-wrap: anywhere;
}

.pr-dashboard-table .refresh-mini {
    flex-shrink: 0;
}

.pr-table th,
.pr-table td,
.data-table th,
.data-table td {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 1px solid var(--line-strong);
    vertical-align: middle;
}

.pr-table th,
.data-table th {
    font-weight: 600;
    white-space: nowrap;
    color: var(--text);
}

.pr-table tbody tr:hover td,
.data-table tbody tr:hover td {
    background: rgba(var(--text-rgb), 0.075);
}

.data-table td {
    overflow-wrap: anywhere;
}

/* Verdict-mark columns (Claude, User, Unit, Functional) read best centered. */
.pr-table .col-center {
    text-align: center;
}

.pr-table a,
.data-table a {
    color: var(--text);
    text-decoration: none;
}

.pr-table a:hover,
.data-table a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.pr-number {
    color: var(--muted);
    white-space: nowrap;
}

.pr-number a {
    color: var(--muted);
    text-decoration: none;
}

.pr-number a:hover {
    text-decoration: underline;
}

.pr-updated {
    white-space: nowrap;
    color: var(--muted);
}

.pr-report {
    white-space: nowrap;
}

.report-link {
    text-decoration: none;
}

.report-link:hover {
    text-decoration: underline;
}

.pr-table .report-ready {
    color: var(--accent);
}

.pr-table .report-stale {
    color: var(--warn);
}

.pr-table .report-failed,
.report-failed {
    color: var(--crit);
}

.report-pending {
    color: var(--muted);
}

/* Non-existent reports: plain text, not a link. */
.report-none {
    font-size: inherit;
}

/* Verdict marks (User Review, Claude Review, Unit, Functional columns). They sit on
   anchors, so the selectors are scoped to the table to beat `.pr-table a`. */
.pr-table .user-review-pass {
    color: var(--ok);
    font-weight: 600;
}

.pr-table .user-review-fail {
    color: var(--crit);
    font-weight: 600;
}

.pr-table .user-review-none {
    color: var(--faint);
}

/* A report cell: status text/link plus the conditional mini refresh button. */
.report-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* Review / Summary tabs on a PR report page: Bootstrap-style boxed tabs. */
.report-tabs {
    display: flex;
    flex-wrap: wrap;
    margin-top: 1rem;
    border-bottom: 1px solid var(--line-strong);
}

.report-tabs a {
    margin-bottom: -1px;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius) var(--radius) 0 0;
    font-weight: 400;
    text-decoration: none;
    color: var(--muted);
}

.report-tabs a:hover {
    color: var(--text);
    border-color: var(--line) var(--line) var(--line-strong);
}

.report-tabs a.active {
    color: var(--text);
    font-weight: 600;
    border-color: var(--line-strong) var(--line-strong) transparent;
    background: rgba(var(--ground-rgb), 0.9);
}

.pr-branches {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0;
    color: var(--muted);
}

.pr-branches .arrow {
    color: var(--text);
}

/* ---- Badges ---- */

.badge,
.bucket-count {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.35em 0.65em;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: transparent;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
    vertical-align: middle;
}

.badge-stale {
    background: var(--warn);
    border-color: var(--warn);
    color: #1a1204;
}

/* Run outcome badge (functional, unit, SpotBugs); its text color comes from .report-*. */
.badge-status {
    border-color: var(--line-strong);
}

/* ---- Deployed pull requests ----
   A pull request whose branch an ETS server runs: a violet bar and tint on
   its row (pull request, ticket and Servers tables), and a violet badge that
   names the servers. */

.pr-table tbody tr.pr-deployed td {
    background: var(--deployed-soft);
}

.pr-table tbody tr.pr-deployed td:first-child {
    box-shadow: inset 3px 0 0 var(--deployed);
}

.pr-table tbody tr.pr-deployed:hover td {
    background: rgba(var(--deployed-rgb), 0.2);
}

.badge-deployed {
    border-color: var(--deployed);
    color: var(--deployed);
}

/* The review page's line naming the servers. */
.pr-deployed-line {
    color: var(--deployed);
}

.loading,
.empty {
    margin: 0.75rem 0 0.25rem;
    color: var(--muted);
}

.pr-panel-header .loading {
    margin: 0;
    font-size: 0.8rem;
}

.empty {
    padding: 1.75rem;
    text-align: center;
}

/* ---- Admin pages ---- */

.admin-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 48rem;
}

/* The Controls page runs full width like the pull-request page, while
   focused admin forms, such as Edit User, keep the narrower default above. */
.admin-page.controls-page {
    max-width: none;
}

.stacked-form {
    max-width: 24rem;
}

.stacked-form label {
    display: block;
    margin: 1rem 0 0.5rem;
    color: var(--text);
}

.stacked-form input[type="text"],
.stacked-form input[type="password"],
.stacked-form input[type="email"],
.stacked-form select,
.diff-filter,
.comment-form textarea,
.action-select {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    background: transparent;
    color: var(--text);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.stacked-form select,
.action-select {
    background-color: rgba(var(--ground-rgb), 0.9);
}

.stacked-form input:focus,
.stacked-form select:focus,
.diff-filter:focus,
.comment-form textarea:focus,
.action-select:focus,
.login-card input:focus {
    outline: none;
    border-color: rgba(var(--text-rgb), 0.5);
    box-shadow: 0 0 0 0.25rem rgba(var(--text-rgb), 0.15);
}

.stacked-form input::placeholder,
.diff-filter::placeholder,
.comment-form textarea::placeholder,
.login-card input::placeholder {
    color: var(--faint);
}

.stacked-form button {
    margin-top: 1rem;
}

.danger-button {
    margin-top: 0.5rem;
}

.auto-review .state-on {
    color: var(--ok);
    font-weight: 600;
}

.auto-review .state-off {
    color: var(--muted);
    font-weight: 600;
}

.panel-divider {
    border: none;
    border-top: 1px solid var(--line);
    margin: 1.25rem 0;
}

.stacked-form .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.9rem;
    font-size: 0.875rem;
    font-weight: 300;
    text-transform: none;
    color: var(--text);
}

.field-error {
    color: var(--crit);
    font-size: 0.8rem;
    margin: 0.25rem 0 0;
}

.hint {
    color: var(--muted);
}

/* ---- ETS releases ---- */

.releases-page {
    max-width: none;
}

.release-layout {
    display: grid;
    grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
    gap: 1rem;
}

.release-list-panel,
.release-detail {
    align-self: start;
}

.release-list-panel h1,
.release-detail h1 {
    margin-top: 0;
}

.release-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 1rem;
}

.release-filters {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

.release-year-filter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.release-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    border: none;
}

.release-filter-group legend {
    width: 100%;
    margin-bottom: 0.25rem;
    color: var(--muted);
    font-size: 0.75rem;
}

.release-filter-button {
    padding: 0.3rem 0.55rem;
    border: 1px solid var(--line-strong);
    background: transparent;
    color: var(--muted);
    font-size: 0.75rem;
}

.release-filter-button:hover,
.release-filter-button.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.release-count {
    margin: 0.75rem 0 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.release-list-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    text-align: left;
}

.release-list-item:hover {
    border-color: var(--line-strong);
    background: rgba(var(--text-rgb), 0.075);
}

.release-list-item.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.release-list-title {
    font-weight: 600;
}

.release-list-meta,
.release-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.release-list-item .badge {
    margin-left: 0;
}

.release-list-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.release-placeholder {
    min-height: 12rem;
    color: var(--muted);
}

.release-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.release-meta {
    margin: 0.5rem 0 0;
}

.release-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.release-section h2 {
    margin-top: 0;
}

.release-ticket-list,
.release-pr-list {
    margin: 0;
    padding-left: 1.25rem;
}

.release-ticket-list li,
.release-pr-list li {
    margin: 0.35rem 0;
}

.release-pr-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
}

.release-pr-merged {
    color: var(--ok);
    font-size: 0.75rem;
}

.release-pr-closed {
    color: var(--muted);
    font-size: 0.75rem;
}

.release-notes {
    max-width: none;
}

@media (max-width: 64rem) {
    .release-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---- Login page ----
   No card: the form floats centered on the page, HUD style. */

.login-page {
    display: flex;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 3rem 1rem;
}

.login-card {
    position: relative;
    flex: 1;
    width: 100%;
    max-width: 22.5rem;
    margin: 0 auto;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
}

.login-card h1 {
    margin: 0 0 0.5rem;
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
}

.login-title {
    margin: 0 0 1.5rem;
    text-align: center;
    color: var(--muted);
}

.login-card label {
    display: block;
    margin: 1rem 0 0.5rem;
    font-weight: 400;
}

.login-card input {
    display: block;
    width: 100%;
    min-height: calc(1.5em + 1rem + 2px);
    padding: 0.5rem 1rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    font: inherit;
    font-size: 1rem;
    line-height: 1.5;
    background: rgba(var(--text-rgb), 0.05);
    color: var(--text);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Password input with the show/hide eye button overlaid on its right edge;
   the input's right padding keeps typed text clear of the button. */
.password-field {
    position: relative;
}

.login-card .password-field input {
    padding-right: 3rem;
}

/* Edge draws its own reveal button in password inputs; hide it so only the
   eye toggle shows. */
.password-field input::-ms-reveal {
    display: none;
}

.password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    padding: 0;
    border: none;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s ease-in-out;
}

.password-toggle:hover,
.password-toggle:focus-visible {
    color: var(--text);
}

.login-card button[type="submit"] {
    display: block;
    width: 100%;
    margin-top: 1.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 500;
}

.login-card .alert {
    margin: 0 0 1rem;
}

/* ---- PR detail page ---- */

.ai-banner {
    margin: 0 0 1rem;
}

/* AI status section at the top of a PR report page. */
.ai-status-section {
    margin-bottom: 1rem;
}

.ai-status-section h2 {
    margin: 0 0 0.5rem;
}

.ai-status-section .ai-banner {
    margin: 0;
}

.ai-idle {
    color: var(--muted);
    margin: 0;
}

.queue-note {
    color: var(--muted);
}

.pr-meta-line {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin: 0.5rem 0 0;
    font-size: 0.8125rem;
    color: var(--muted);
}

.pr-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.pr-details h2 {
    margin-bottom: 0.75rem;
}

.pr-details h3 {
    margin: 0 0 0.25rem;
    color: var(--muted);
}

.jira-description {
    margin: 0;
    white-space: pre-wrap;
}

.jira-summary {
    margin: 0 0 1rem;
}

.report-card {
    margin-top: 1.5rem;
}

.report-card h2 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 0.75rem;
}

.report-card h2 small {
    margin-left: 0;
}

/* The PR page's list of SpotBugs findings new to the branch. */
.bug-table {
    margin: 0.75rem 0 1rem;
}

.bug-table td {
    vertical-align: top;
}

.bug-table code {
    white-space: nowrap;
}

.bug-table .bug-rank {
    text-align: right;
    color: var(--muted);
}

.bug-table .bug-location {
    font-family: var(--font-mono);
    font-size: 0.85em;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.bug-table .bug-message {
    min-width: 16rem;
    overflow-wrap: anywhere;
}

/* ---- View Changes tab (branch diff) ---- */

.diff-totals code,
.report-card h2 code,
.diff-view-path {
    font-family: var(--font-mono);
    font-size: 0.9em;
    letter-spacing: 0;
}

.diff-plus {
    color: var(--ok);
}

.diff-minus {
    color: var(--crit);
}

/* File list beside the diff; stacks above it on narrow screens. */
.diff-layout {
    display: grid;
    grid-template-columns: 19rem minmax(0, 1fr);
    gap: 1rem;
    margin-top: 0.75rem;
}

@media (max-width: 60rem) {
    .diff-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

.diff-files {
    align-self: start;
    position: sticky;
    top: calc(var(--header-height) + 1rem);
    max-height: calc(100vh - var(--header-height) - 2rem);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.diff-file-list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    overflow-y: auto;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: rgba(var(--ground-rgb), 0.6);
}

.diff-file {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: none;
    border-bottom: 1px solid var(--line);
    background: none;
    color: var(--text);
    font: inherit;
    font-size: 0.8125rem;
    text-align: left;
    cursor: pointer;
}

.diff-file-list li:last-child .diff-file {
    border-bottom: none;
}

.diff-file:hover {
    background: rgba(var(--text-rgb), 0.075);
}

.diff-file.active {
    background: var(--accent-soft);
    color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
}

.diff-mark {
    flex: none;
    width: 1.2rem;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.3;
}

.diff-mark-add {
    color: var(--ok);
}

.diff-mark-del {
    color: var(--crit);
}

.diff-mark-mod {
    color: var(--accent);
}

.diff-mark-ren {
    color: var(--warn);
}

.diff-file-path {
    flex: 1;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0;
    /* Paths are read right-to-left: keep the file name, elide the folders. */
    direction: rtl;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.diff-file-counts {
    flex: none;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0;
    color: var(--muted);
}

.diff-view {
    min-width: 0;
}

.diff-view-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line-strong);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    background: rgba(var(--panel-rgb), 0.8);
}

.diff-view-path {
    overflow-wrap: anywhere;
}

.diff-old-path {
    color: var(--muted);
}

.diff-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    color: var(--muted);
    white-space: nowrap;
    cursor: pointer;
}

.diff-view .pr-table-scroll {
    border: 1px solid var(--line-strong);
    border-radius: 0 0 var(--radius) var(--radius);
    background: rgba(var(--ground-rgb), 0.8);
}

.diff-view .hint,
.diff-view .alert {
    margin: 0.75rem 0;
}

.diff-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0;
    line-height: 1.5;
}

.diff-table td {
    padding: 0 0.5rem;
    vertical-align: top;
}

.diff-ln {
    width: 3.5rem;
    min-width: 3.5rem;
    text-align: right;
    color: var(--faint);
    user-select: none;
    border-right: 1px solid var(--line);
}

.diff-code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    tab-size: 4;
}

.diff-sign {
    display: inline-block;
    width: 1ch;
    margin-right: 0.5ch;
    user-select: none;
    color: var(--muted);
}

.diff-hunk .diff-code {
    color: var(--accent);
    background: var(--accent-soft);
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
}

.diff-add {
    background: rgba(47, 213, 140, 0.12);
}

.diff-add .diff-sign {
    color: var(--ok);
}

.diff-delete {
    background: rgba(242, 96, 107, 0.12);
}

.diff-delete .diff-sign {
    color: var(--crit);
}

/* ---- Branches page ---- */

.branch-sha {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0;
    color: var(--muted);
    white-space: nowrap;
}

.branch-tests {
    white-space: nowrap;
}

.branch-last-error {
    color: var(--crit);
}

/* Rendered Markdown of the AI reports. */
.md-report {
    max-width: 64rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.md-report h1 {
    font-size: 1.3125rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
}

.md-report h2 {
    font-size: 1.09375rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
}

.md-report h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 1.25rem 0 0.4rem;
}

.md-report ul,
.md-report ol {
    padding-left: 1.4rem;
}

.md-report li {
    margin: 0.25rem 0;
}

.md-report code {
    background: rgba(var(--text-rgb), 0.08);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

.md-report pre {
    background: rgba(var(--ground-rgb), 0.8);
    border: 1px solid var(--line);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
}

.md-report pre code {
    background: none;
    padding: 0;
}

.md-report blockquote {
    border-left: 3px solid var(--line-strong);
    margin: 0.5rem 0;
    padding-left: 0.75rem;
    color: var(--muted);
}

.md-report table {
    border-collapse: collapse;
    margin: 0.5rem 0;
}

.md-report th,
.md-report td {
    border: 1px solid var(--line-strong);
    padding: 0.35rem 0.6rem;
    text-align: left;
}

.md-report th {
    font-weight: 600;
}

.md-report hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 1rem 0;
}

/* ---- Errors page ---- */

/* A whole row of the Errors table opens the error, not just its file name. */
.errors-table .error-row {
    cursor: pointer;
}

/* The Info tab: the labels column. */
.error-info th {
    width: 14rem;
}

/* The raw exception file on the Error tab. */
.error-file {
    background: rgba(var(--ground-rgb), 0.8);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0;
    line-height: 1.5;
    margin: 0;
    max-height: 70vh;
    overflow: auto;
    padding: 0.75rem 1rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Per-report user instructions (chatbox). */
.comments {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.comments h3 {
    margin: 0 0 0.5rem;
}

.comment-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border-bottom: 1px dashed var(--line-strong);
}

.comment-text {
    flex: 1;
    overflow-wrap: anywhere;
}

.comment-date {
    color: var(--muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.comment-form textarea {
    min-height: 4.5rem;
    resize: vertical;
}

.comment-form button {
    align-self: flex-end;
}

/* A form that sits inline in a table cell, e.g. a per-row action button. */
.inline-form {
    display: inline;
    margin: 0;
}

/* ---- Tickets board ---- */


/* Ticket workflow tabs share the report tabs' palette and boxed shape. */
.ticket-tabs {
    border-bottom: 1px solid var(--line-strong);
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.ticket-tabs button {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius) var(--radius) 0 0;
    color: var(--muted);
    margin-bottom: -1px;
    padding: 0.5rem 1rem;
}

.ticket-tabs button:hover {
    border-color: var(--line);
    color: var(--text);
}

.ticket-tabs button.active {
    background: rgba(var(--ground-rgb), 0.9);
    border-color: var(--line-strong) var(--line-strong) transparent;
    color: var(--text);
    font-weight: 600;
}

.ticket-tab-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ticket-tab-panel[hidden] {
    display: none;
}

/* One card per bucket, stacked. */
.tickets-page,
.servers-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel-tools {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.updated-at {
    color: var(--muted);
    font-size: 0.8rem;
}

.bucket-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.bucket-toggle {
    width: 2rem;
    height: 2rem;
    padding: 0;
    color: var(--muted);
}

.bucket-toggle:hover {
    color: var(--text);
}

.bucket-toggle .material-symbols-outlined {
    font-size: 22px;
}

/* A collapsed bucket keeps only its header line and description. */
.bucket-panel.collapsed .bucket-description {
    margin-bottom: 0;
}

.bucket-panel h2 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.bucket-count {
    margin-left: 0;
}

.bucket-description {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.8125rem;
}

.bucket-panel .pr-table-scroll {
    margin-top: 0.75rem;
}

.ticket-key {
    white-space: nowrap;
}

.ticket-summary {
    max-width: 34rem;
}

.pr-table code {
    font-size: 0.85em;
}

/* The action column sits last and hugs the right edge. */
.pr-table .col-action {
    text-align: right;
    white-space: nowrap;
}

.pr-table .col-action .action-button + .action-button,
.pr-table .col-action .action-select + .action-button {
    margin-left: 0.4rem;
}

.action-button {
    padding: 0.25rem 0.6rem;
    font-size: 0.8125rem;
}

.action-select {
    display: inline-block;
    width: auto;
    padding: 0.25rem 0.6rem;
    font-size: 0.8125rem;
}

.action-select:disabled {
    color: var(--muted);
    opacity: 0.6;
}

/* ---- Servers page ---- */

.servers-page h2 {
    margin: 1rem 0 0.75rem;
}

.servers-page .pr-panel-header h2 {
    margin: 0;
}

.server-state {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--muted);
}

.server-state-online {
    border-color: var(--ok);
    color: var(--ok);
}

.server-state-unreachable {
    border-color: var(--crit);
    color: var(--crit);
}

.server-reason {
    margin-left: 0.5rem;
    color: var(--crit);
}

.server-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.25rem;
    margin: 0 0 0.75rem;
    font-size: 0.8125rem;
    color: var(--muted);
}

.server-url {
    font-family: var(--font-mono);
    letter-spacing: 0;
}

.server-subject {
    margin-left: 0.5rem;
    color: var(--muted);
}

.component-running {
    color: var(--ok);
    font-weight: 600;
}

.component-stopped,
.component-unknown {
    color: var(--muted);
}

/* A jar built before the deployed commit, and uncommitted changes on a server. */
.jar-stale,
.local-changes {
    color: var(--warn);
}

.local-changes {
    margin-left: 0.5rem;
}

.server-problems {
    margin: 0.75rem 0 0;
    padding-left: 1.25rem;
    font-size: 0.8125rem;
    color: var(--warn);
}

/* ---- Easter egg: runner game ----
   Full-viewport overlay opened by shorcan-dino.js. The html class locks
   scrolling while it is open (the root is the scroll container and
   scrollbar-gutter keeps the layout from shifting). The overlay repeats the
   page background so the game feels like part of the app. */
html.dino-playing {
    overflow: hidden;
}

.dino-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background-color: var(--ground);
    background-image: linear-gradient(180deg, rgba(16, 44, 60, 0.9) 0%, #060d15 100%);
    color: var(--text);
    overscroll-behavior: contain;
    cursor: default;
    outline: none;
}

.dino-card {
    padding: 1rem;
    max-width: 100%;
}

.dino-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    touch-action: none;
    image-rendering: auto;
}

.dino-hint {
    margin: 0.75rem 0 0;
    font-size: 0.75rem;
    color: var(--muted);
    letter-spacing: var(--tracking);
    text-transform: uppercase;
}
