/*
 * The look of the internal tools hub (hub-site/index.html): the same ground,
 * ink and rules, and cards that lift on hover. DiCon's blue is the accent.
 */
:root {
    --ink: #15201f;
    --muted: #5a6462;
    --rule: #d3d9d7;
    --ground: #f4f6f5;
    --surface: #ffffff;
    --accent: #1a3282;
    --accent-soft: #e7eaf5;
    --danger: #b3261e;
    --ok: #1e7b3a;

    /*
     * Each home card's own hue, with a soft tint for its ground and a line
     * tint for its border, as on the hub.
     */
    --systems: #1a3282;
    --systems-soft: #e7eaf5;
    --systems-line: #bcc4e4;
    --templates: #b8651a;
    --templates-soft: #f2e2d0;
    --templates-line: #e0bd94;
    --accounts: #6b3fa0;
    --accounts-soft: #ece4f5;
    --accounts-line: #cdbbe4;
    --settings: #4a5568;
    --settings-soft: #e6e9ee;
    --settings-line: #c3cad5;

    color-scheme: light;
    color: var(--ink);
    background: var(--ground);
    font-family:
        'IBM Plex Sans',
        system-ui,
        -apple-system,
        'Segoe UI',
        sans-serif;
    line-height: 1.5;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

/* the attribute wins over any display a rule below gives the element */
[hidden] {
    display: none !important;
}

header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--rule);
}

header .brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
    margin-right: auto;
}

header .brand img {
    width: 26px;
    height: 26px;
}

header .who .username {
    color: var(--ink);
    font-weight: 600;
}

header .who .role {
    color: var(--muted);
    font-size: 0.85rem;
}

/* a button that looks like a link: Sign out, Close */
.link {
    color: var(--accent);
    background: none;
    border: 0;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}

main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

h1 {
    font-size: 1.6rem;
    margin: 1.25rem 0 0.5rem;
}

h2 {
    font-size: 1.1rem;
    margin: 0;
}

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

code {
    background: var(--ground);
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 0.88em;
}

.lede {
    color: var(--muted);
    margin: 0 0 1.75rem;
    max-width: 62ch;
}

.crumbs {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.crumbs .back {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 6px;
    color: var(--ink);
    display: inline-flex;
    gap: 0.15rem;
    margin-right: 0.5rem;
    padding: 0.15rem 0.6rem 0.15rem 0.3rem;
    text-decoration: none;
}

.crumbs .back:hover,
.crumbs .back:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
}

.crumbs .back svg {
    height: 16px;
    width: 16px;
}

.crumbs [aria-current='page'] {
    color: var(--ink);
}

.narrow {
    max-width: 26rem;
    margin: 3rem auto;
}

.stack {
    display: grid;
    gap: 0.9rem;
}

.stack label {
    display: grid;
    gap: 0.25rem;
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0.5rem 0;
}

.inline {
    display: inline;
}

input,
select {
    font: inherit;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--rule);
    border-radius: 6px;
    background: var(--surface);
}

input[type='number'] {
    width: 5rem;
}

button,
.button {
    font: inherit;
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--rule);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

button:disabled {
    opacity: 0.5;
    cursor: default;
}

.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.danger {
    color: var(--danger);
    border-color: var(--danger);
}

.meta,
.hint {
    color: var(--muted);
    font-size: 0.92rem;
}

.flash {
    background: #fff7d6;
    border: 1px solid #e6cf73;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
}

.error {
    color: var(--danger);
}

.badge {
    font-size: 0.78rem;
    padding: 0.05rem 0.55rem;
    border-radius: 999px;
    background: var(--ground);
    border: 1px solid var(--rule);
    color: var(--muted);
    white-space: nowrap;
}

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

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

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

/* the home page: one card per thing a site admin does */

.tools {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(3, 1fr);
}

/* one row up to three cards, two rows of two for four */
.tools[data-count='1'] {
    grid-template-columns: 1fr;
}

.tools[data-count='2'],
.tools[data-count='4'] {
    grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 860px) {
    .tools,
    .tools[data-count] {
        grid-template-columns: 1fr;
    }
}

.tool {
    background: var(--tool-soft);
    border: 1px solid var(--tool-line);
    border-radius: 10px;
    color: inherit;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    text-decoration: none;
    transition:
        border-color 0.15s ease,
        transform 0.15s ease;
}

.tool.systems {
    --tool: var(--systems);
    --tool-soft: var(--systems-soft);
    --tool-line: var(--systems-line);
}

.tool.templates {
    --tool: var(--templates);
    --tool-soft: var(--templates-soft);
    --tool-line: var(--templates-line);
}

.tool.accounts {
    --tool: var(--accounts);
    --tool-soft: var(--accounts-soft);
    --tool-line: var(--accounts-line);
}

.tool.settings {
    --tool: var(--settings);
    --tool-soft: var(--settings-soft);
    --tool-line: var(--settings-line);
}

.tool:hover,
.tool:focus-visible {
    border-color: var(--tool, var(--accent));
    transform: translateY(-2px);
}

.tool:focus-visible {
    outline: 2px solid var(--tool, var(--accent));
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .tool {
        transition: none;
    }

    .tool:hover,
    .tool:focus-visible {
        transform: none;
    }
}

.tool .text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 8px;
    padding: 0 17px 17px;
}

/* straddles the seam between the preview and the card body */
.icon {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--tool-line, var(--rule));
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(21, 32, 31, 0.13);
    color: var(--tool, var(--accent));
    display: flex;
    flex: none;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.tool .icon {
    margin: -21px 0 4px;
    position: relative;
}

.tool p {
    color: #4a5453;
    margin: 0;
}

.tool .footer {
    color: var(--tool);
    font-size: 0.85rem;
    margin-top: auto;
    padding-top: 6px;
}

/*
 * A miniature of the page each card opens, drawn in blocks. Nothing here is
 * text; what tells the cards apart is the shape of what they open.
 */
/* the bottom padding keeps the drawing clear of the icon over the seam */
.preview {
    background: var(--surface);
    border-bottom: 1px solid var(--tool-line);
    height: 84px;
    overflow: hidden;
    padding: 10px 14px 28px 76px;
}

.preview span {
    display: block;
}

.mini-cards {
    display: flex;
    gap: 8px;
    height: 100%;
}

.mini-card {
    border: 1px solid var(--rule);
    border-radius: 4px;
    flex: 1;
    padding: 6px;
}

.mini-card .dot {
    border-radius: 50%;
    height: 7px;
    margin-bottom: 6px;
    width: 7px;
}

.mini-card .dot.up {
    background: var(--ok);
}

.mini-card .dot.down {
    background: var(--rule);
}

.mini-card .bar,
.mini-row .bar {
    background: #dde1e0;
    height: 5px;
}

.mini-stack {
    position: relative;
    height: 100%;
}

.mini-stack span {
    background: var(--surface);
    border: 1px solid var(--templates-line);
    border-radius: 4px;
    height: 30px;
    position: absolute;
    width: 56%;
}

.mini-stack span:nth-child(1) {
    left: 4%;
    top: 0;
}

.mini-stack span:nth-child(2) {
    left: 10%;
    top: 7px;
}

.mini-stack span:nth-child(3) {
    border-top: 4px solid var(--templates);
    left: 16%;
    top: 14px;
}

.mini-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mini-row {
    align-items: center;
    display: flex !important;
    gap: 7px;
}

.mini-row .avatar {
    background: var(--accounts-line);
    border-radius: 50%;
    height: 11px;
    width: 11px;
}

.mini-row .bar {
    width: 48%;
}

.mini-settings {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
}

.mini-settings .track {
    background: #dde1e0;
    height: 3px;
    position: relative;
    width: 70%;
}

.mini-settings .knob {
    background: var(--settings);
    border-radius: 50%;
    height: 9px;
    position: absolute;
    top: -3px;
    width: 9px;
}

.mini-settings .knob.low {
    left: 30%;
}

.mini-settings .knob.high {
    left: 65%;
}

.mini-settings .log {
    background: #dde1e0;
    height: 3px;
    width: 85%;
}

.mini-settings .log.short {
    width: 55%;
}

/* the system list and a system's page */

.title-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
}

.title-row h1 {
    margin-right: auto;
}

/*
 * A system's or an account's name with its state beside it, in the heading.
 * vertical-align: middle centers the badge on half the x-height above the
 * baseline, where the eye reads the middle of a lowercase name, measured from
 * whichever font the browser picked.
 */
h1.with-badge .badge {
    font-weight: 400;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0 1.25rem;
}

.panels {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
}

@media (max-width: 480px) {
    .panels {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 10px;
    margin-top: 14px;
    padding: 16px;
}

.panels .panel {
    margin-top: 0;
}

.panel.wide {
    grid-column: 1 / -1;
}

.panel h2 {
    margin-bottom: 0.5rem;
}

/* a form field whose label holds more than text, such as a "?" */
.field {
    display: grid;
    gap: 0.25rem;
}

/* an input with a button beside it */
.input-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.field-label {
    align-items: center;
    display: inline-flex;
    gap: 0.4rem;
}

/* the "?" beside a field, and the guide it opens */
.help {
    border-radius: 50%;
    color: var(--accent);
    font-size: 0.95rem;
    font-weight: 600;
    height: 1.8rem;
    line-height: 1;
    padding: 0;
    vertical-align: middle;
    width: 1.8rem;
}

.guide {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(21, 32, 31, 0.25);
    color: var(--ink);
    max-height: calc(100vh - 32px);
    max-width: min(64rem, calc(100vw - 32px));
    overflow: auto;
    padding: 16px 18px;
}

/* wide enough for the first action on one line, on a laptop's screen */
.guide td:first-child {
    min-width: min(27rem, 45vw);
}

.guide::backdrop {
    background: rgba(21, 32, 31, 0.35);
}

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

.guide td:not(:first-child),
.guide th:not(:first-child) {
    text-align: center;
    white-space: nowrap;
}

/*
 * Tabs over their panel. The shown one drops its bottom border and overlaps
 * the panel's top border, so the two read as one shape.
 */
.tab-group {
    margin: 0.75rem 0 0;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tab-group .tab {
    border-radius: 6px 6px 0 0;
    margin-bottom: -1px;
}

.tab[aria-selected='true'] {
    border-bottom-color: var(--surface);
    color: var(--accent);
    position: relative;
    z-index: 1;
}

.tab-panel {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 0 10px 10px;
    padding: 4px 18px 16px;
}

.tab-panel h2 {
    margin: 1rem 0 0.5rem;
}

/* steps for the reader to follow, set apart from what the site reports */
.steps {
    background: #fff7d6;
    border: 1px solid #e6cf73;
    border-radius: 8px;
    margin-top: 1rem;
    padding: 12px 14px;
}

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

.steps > :last-child {
    margin-bottom: 0;
}

.steps table {
    background: transparent;
}

/* an edit button, and the modal with the form it opens */
button.small {
    font-size: 0.88rem;
    padding: 0.2rem 0.65rem;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(21, 32, 31, 0.25);
    color: var(--ink);
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 18px 20px;
    width: min(28rem, calc(100vw - 32px));
}

.modal::backdrop {
    background: rgba(21, 32, 31, 0.35);
}

.modal .stack > h2,
.modal .stack > p {
    margin: 0;
}

/*
 * A modal of reference rather than a form. Its size is fixed, so switching
 * its tabs does not resize it; longer contents scroll.
 */
.modal.wide {
    height: min(56rem, calc(100vh - 32px));
    width: min(60rem, calc(100vw - 32px));
}

.modal .actions {
    margin: 0.25rem 0 0;
}

/* a record's values, each with the button that changes it */
dl.details {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 10px;
    display: grid;
    grid-template-columns: minmax(7rem, max-content) 1fr;
    margin: 0 0 1.25rem;
    max-width: 44rem;
}

/* rows with and without a button are the same height */
dl.details dt,
dl.details dd {
    align-items: center;
    border-bottom: 1px solid var(--rule);
    box-sizing: border-box;
    display: flex;
    margin: 0;
    min-height: 3rem;
    padding: 0.4rem 0.9rem;
}

dl.details > :nth-last-child(-n + 2) {
    border-bottom: 0;
}

dl.details dt {
    color: var(--muted);
}

dl.details dd {
    gap: 0.75rem;
    justify-content: space-between;
    min-width: 0;
}

dl.details dd > button {
    flex: none;
}

/* who the port gate lets in */
.access {
    background: var(--accent-soft);
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
}

/* the create page's choice of template or release */

.create-form {
    max-width: 40rem;
}

fieldset {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 10px;
    display: grid;
    gap: 6px;
    padding: 10px 14px 14px;
}

legend {
    color: var(--muted);
    padding: 0 4px;
}

.choice {
    align-items: flex-start;
    border: 1px solid var(--rule);
    border-radius: 6px;
    cursor: pointer;
    display: flex !important;
    gap: 0.6rem;
    padding: 0.5rem 0.65rem;
}

.choice:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.choice > span {
    display: flex;
    flex-direction: column;
}

.check,
.stack label.check {
    display: inline-flex;
    gap: 0.35rem;
    align-items: center;
    margin-right: 1rem;
}

/* tables */

table {
    border-collapse: collapse;
    width: 100%;
    background: var(--surface);
}

th,
td {
    text-align: left;
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
}

table.ports {
    margin: 0.5rem 0;
}

.scroll {
    overflow-x: auto;
}

/* a list of records, one line each; what to change is on each one's page */
table.list td {
    white-space: nowrap;
}

/* a row that opens its record from anywhere in it (site.js) */
tr[data-href] {
    cursor: pointer;
}

tr[data-href]:hover td {
    background: var(--accent-soft);
}

table.settings td:first-child,
table.settings td:nth-child(2) {
    white-space: nowrap;
}

td code {
    overflow-wrap: anywhere;
}
