/*
 * Sentinel server dashboard.
 *
 * Built for two audiences: a wall-mounted screen read from a distance, and a
 * laptop or phone opened ad hoc. The root font size scales with the viewport
 * and everything else is expressed in rem, so one layout covers both.
 */

:root {
    --bg: #0f1319;
    --surface: #171d26;
    --surface-2: #1e2632;
    --line: #2a3441;

    --text: #e7edf5;
    --text-dim: #8c9bad;
    --text-mute: #5f6d7e;

    --ok: #3fb950;
    --warn: #d6a020;
    --crit: #f2564d;

    /*
     * Deliberately not the Yggdrasil gold (#e0a83a): it sits too close to
     * --warn, so a gold marker beside the title reads as an alert.
     */
    --accent: #5b7f9e;

    --fill: linear-gradient(90deg, #3d5a75, #6087a8);

    --radius: 5px;      /* cards, panels, the data strip */
    --radius-sm: 3px;   /* chips and rows inside them */
    --gap: 9px;
}

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

html {
    font-size: clamp(12.5px, 0.86vw, 17px);
}

body {
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.3;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-variant-numeric: tabular-nums;
}

h1,
h2 {
    margin: 0;
    font-weight: 600;
}

/* --- top bar ---------------------------------------------------------- */

.bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.4rem;
    padding: 0.55rem 1rem;
    background-color: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}

.bar__id {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-right: auto;
}

.bar__mark {
    width: 0.5rem;
    height: 1.4rem;
    border-radius: 99px;
    background-color: var(--accent);
}

.bar h1 {
    font-size: 1.1rem;
    letter-spacing: -0.01em;
}

.bar__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.74rem;
    color: var(--text-dim);
}

.build {
    color: var(--text-mute);
    font-size: 0.69rem;
}

.kpis {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.kpi {
    display: flex;
    flex-direction: column;
    min-width: 5.2rem;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--line);
    border-left: 3px solid var(--text-mute);
    border-radius: var(--radius);
    background-color: var(--surface-2);
}

.kpi--ok {
    border-left-color: var(--ok);
}

.kpi--warn {
    border-left-color: var(--warn);
}

.kpi--crit {
    border-left-color: var(--crit);
}

.kpi__value {
    font-size: 1.45rem;
    font-weight: 650;
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.kpi__label {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* --- panels ----------------------------------------------------------- */

main {
    padding: 8px 10px;
}

.panel {
    margin-bottom: 0.8rem;
}

.panel__title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0 0 0.45rem 0.1rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
}

.panel__title--alert {
    color: var(--warn);
}

.panel__count {
    padding: 0 0.42rem;
    border: 1px solid var(--line);
    border-radius: 99px;
    background-color: var(--surface-2);
    color: var(--text-dim);
    font-size: 0.68rem;
    letter-spacing: 0;
}

.panel__count--alert {
    border-color: var(--warn);
    color: var(--warn);
}

/* --- attention list --------------------------------------------------- */

.alerts {
    display: grid;
    gap: 3px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.alert {
    display: grid;
    grid-template-columns: 3.2rem minmax(10rem, 1fr) minmax(5rem, 2fr) 6.5rem;
    align-items: center;
    gap: 0.7rem;
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius);
    border-left: 3px solid var(--warn);
    background-color: var(--surface);
}

.alert--crit {
    border-left-color: var(--crit);
    background-color: color-mix(in srgb, var(--crit) 9%, var(--surface));
}

.alert__value {
    font-size: 1.1rem;
    font-weight: 650;
    color: var(--warn);
}

.alert--crit .alert__value {
    color: var(--crit);
}

.alert__who b {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.76rem;
    text-transform: uppercase;
}

.alert__track {
    height: 5px;
    border-radius: 99px;
    background-color: var(--surface-2);
    overflow: hidden;
}

.alert__track i {
    display: block;
    height: 100%;
    background-color: var(--warn);
}

.alert--crit .alert__track i {
    background-color: var(--crit);
}

.alert__free {
    font-size: 0.76rem;
    color: var(--text-dim);
    text-align: right;
}

/* --- server cards ----------------------------------------------------- */

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

.card {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.5rem 0.6rem 0.58rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background-color: var(--surface);
}

.card--warn {
    border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
}

.card--crit {
    border-color: var(--crit);
    background-color: color-mix(in srgb, var(--crit) 7%, var(--surface));
}

.card__title {
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

/* --- one node (ws / db) within a card --------------------------------- */

.node {
    display: flex;
    flex-direction: column;
    gap: 0.26rem;
}

.node + .node {
    padding-top: 0.36rem;
    border-top: 1px dashed var(--line);
}

.node__header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.role {
    padding: 0.02rem 0.36rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    color: var(--text-dim);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.dot {
    display: inline-block;
    flex: none;
    width: 0.48rem;
    height: 0.48rem;
    border-radius: 99px;
}

.dot--up {
    background-color: var(--ok);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 22%, transparent);
}

.dot--down {
    background-color: var(--crit);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--crit) 30%, transparent);
}

.node__down {
    color: var(--crit);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/*
 * Neither CPU load nor memory is shown: the collector refreshes both only
 * every fifteen minutes, so they say little about the current state. Both
 * fields stay in the payload and the database -- they are simply not drawn.
 *
 * Installations served by this node is the number people actually look for.
 */
.node__sites {
    margin-left: auto;
    color: var(--text-mute);
    font-size: 0.72rem;
}

.node__sites b {
    color: var(--text);
    font-weight: 650;
    font-size: 0.82rem;
}

/* --- disk meters ------------------------------------------------------ */

.disks {
    display: flex;
    flex-direction: column;
    gap: 0.26rem;
}

.meter__top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.72rem;
}

.meter__label {
    color: var(--text-dim);
}

.meter__value {
    font-size: 0.84rem;
    font-weight: 650;
}

.meter__track {
    height: 6px;
    margin: 0.1rem 0 0.05rem;
    border-radius: 99px;
    background-color: var(--surface-2);
    overflow: hidden;
}

.meter__track i {
    display: block;
    height: 100%;
    background: var(--fill);
}

.meter__sub {
    font-size: 0.67rem;
    color: var(--text-mute);
}

.meter--warn .meter__track i {
    background: var(--warn);
}

.meter--warn .meter__value {
    color: var(--warn);
}

.meter--crit .meter__track i {
    background: var(--crit);
}

.meter--crit .meter__value {
    color: var(--crit);
}

/* --- data nodes ------------------------------------------------------- */

.data-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.28rem;
    padding: 0.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background-color: var(--surface);
}

.data-node {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    padding: 0.18rem 0.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    color: var(--text-dim);
    font-size: 0.75rem;
}

.data-node--down {
    border-color: var(--crit);
    color: var(--crit);
}

/* --- narrow screens --------------------------------------------------- */

@media (max-width: 640px) {
    .bar {
        gap: 0.6rem;
        padding: 0.55rem 0.7rem;
    }

    .bar__id {
        margin-right: 0;
        width: 100%;
    }

    .bar__meta {
        align-items: flex-start;
    }

    .alert {
        grid-template-columns: 3rem 1fr;
        row-gap: 0.25rem;
    }

    .alert__track,
    .alert__free {
        grid-column: 1 / -1;
    }

    .alert__free {
        text-align: left;
    }
}
