/*
 * DarzaFleet website. The look follows the Darza Wiki on purpose: the same semantic tokens,
 * light theme by default with the wiki's dark theme and accent presets, a left sidebar with game
 * icons, a slim top bar and one boxed content panel, flat tables with hairlines (no cards), the
 * Nope 8 pixel font only on the brand. Logs and config previews keep a dark panel in both themes,
 * like the wiki's in-game tooltip cards.
 */

@font-face {
    font-family: "Nope 8";
    src: url("/fonts/Nope8.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ---------- tokens --------------------------------------------------------------------- */

:root {
    color-scheme: light;
    --bg-page: #f2f3f5;
    --bg-chrome: #f6f7f9;
    --bg-panel: #ffffff;
    --panel-border: #d9dde2;
    --bg-stripe: #f7f9fb;
    --bg-inset: #f4f6f8;
    --bg-hover: #eef2f6;
    --text: #2f3237;
    --text-muted: #6d747c;
    --text-faint: #8f96a0;
    --text-heading: #2b2e33;
    --link: #2d7dc4;
    --link-hover: #1f5a94;
    --border: #d9dde2;
    --border-chrome: #e4e7ec;
    --input-bg: #ffffff;
    --input-border: #c6ccd4;
    --input-text: #2f3237;
    --scrollbar-thumb: #c3c9d1;
    --scrollbar-track: #eef0f4;
    --shadow-panel: 0 1px 2px rgba(0, 0, 0, 0.05);
    --emphasis-bg: rgba(45, 125, 196, 0.10);

    --good: #2e7d32;
    --good-bg: rgba(46, 125, 50, 0.12);
    --busy: #1f6fb2;
    --busy-bg: rgba(31, 111, 178, 0.12);
    --warn: #a16207;
    --warn-bg: rgba(161, 98, 7, 0.13);
    --bad: #c62828;
    --bad-bg: rgba(198, 40, 40, 0.12);
    --off: #6d747c;
    --off-bg: rgba(109, 116, 124, 0.12);

    --card-bg: #101418;
    --card-text: #e8edf2;
    --card-muted: #8c96a0;

    --font-body: "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-display: "Nope 8", sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

    --sidebar-width: 240px;
    --content-max: 1360px;
    --header-h: 56px;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg-page: #0b0b0d;
    --bg-chrome: #131316;
    --bg-panel: #121215;
    --panel-border: #26262c;
    --bg-stripe: #16161a;
    --bg-inset: #101014;
    --bg-hover: rgba(255, 255, 255, 0.06);
    --text: #ededed;
    --text-muted: #9aa4ad;
    --text-faint: #6c757d;
    --text-heading: #f6fbff;
    --link: #77bff4;
    --link-hover: #a9d7f2;
    --border: #33363f;
    --border-chrome: #26262c;
    --input-bg: #0c0c0e;
    --input-border: #3b404c;
    --input-text: #dddddd;
    --scrollbar-thumb: #444444;
    --scrollbar-track: #111111;
    --shadow-panel: none;
    --emphasis-bg: rgba(164, 194, 221, 0.14);

    --good: #78e08f;
    --good-bg: rgba(120, 224, 143, 0.12);
    --busy: #77bff4;
    --busy-bg: rgba(119, 191, 244, 0.13);
    --warn: #ffd166;
    --warn-bg: rgba(255, 209, 102, 0.12);
    --bad: #ff6b6b;
    --bad-bg: rgba(255, 107, 107, 0.13);
    --off: #9aa4ad;
    --off-bg: rgba(154, 164, 173, 0.12);
}

[data-accent="azure"] { --accent: #3d8fd1; }
[data-accent="forest"] { --accent: #75c526; }
[data-accent="royal"] { --accent: #9a3fd5; }
[data-accent="crimson"] { --accent: #d14b4b; }
[data-accent="steel"] { --accent: #6b8cb0; }

[data-accent] {
    --bg-panel: color-mix(in srgb, var(--accent) 8%, #ffffff);
    --bg-stripe: color-mix(in srgb, var(--accent) 13%, #ffffff);
    --bg-inset: color-mix(in srgb, var(--accent) 15%, #ffffff);
    --bg-page: color-mix(in srgb, var(--accent) 20%, #ffffff);
    --bg-hover: color-mix(in srgb, var(--accent) 22%, #ffffff);
    --bg-chrome: color-mix(in srgb, var(--accent) 28%, #ffffff);
    --border-chrome: color-mix(in srgb, var(--accent) 45%, #ffffff);
    --border: color-mix(in srgb, var(--accent) 40%, #ffffff);
    --panel-border: color-mix(in srgb, var(--accent) 65%, #ffffff);
}

[data-theme="dark"][data-accent] {
    --bg-page: color-mix(in srgb, var(--accent) 9%, #0a0a0c);
    --bg-chrome: color-mix(in srgb, var(--accent) 10%, #131316);
    --bg-panel: color-mix(in srgb, var(--accent) 6%, #121215);
    --border-chrome: color-mix(in srgb, var(--accent) 24%, #26262c);
    --border: color-mix(in srgb, var(--accent) 26%, #33363f);
    --panel-border: color-mix(in srgb, var(--accent) 45%, #26262c);
    --bg-hover: color-mix(in srgb, var(--accent) 14%, #1a1a20);
    --bg-inset: color-mix(in srgb, var(--accent) 8%, #101014);
    --bg-stripe: color-mix(in srgb, var(--accent) 6%, #121216);
}

/* ---------- base ------------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg-page);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.45;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }
h1, h2, h3, h4 { color: var(--text-heading); font-weight: 700; }
h1 { font-size: 24px; margin: 8px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 18px; margin: 24px 0 8px; }
h3 { font-size: 15px; margin: 16px 0 6px; }
p { margin: 6px 0 10px; }
code, kbd, pre, .mono { font-family: var(--font-mono); font-size: 12.5px; }
code { background: var(--bg-inset); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1 1 auto; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); }

/* ---------- game icons (wwwroot/img/icons.png, 16px cells, see tools/extract_icons.py) ---- */

.icon {
    --s: 22px;
    display: inline-block;
    width: var(--s);
    height: var(--s);
    flex-shrink: 0;
    background-image: url("/img/icons.png");
    background-repeat: no-repeat;
    background-size: calc(var(--s) * 14) var(--s);
    image-rendering: pixelated;
    filter: drop-shadow(1px 0 0 rgba(0, 0, 0, .55)) drop-shadow(-1px 0 0 rgba(0, 0, 0, .55))
            drop-shadow(0 1px 0 rgba(0, 0, 0, .55)) drop-shadow(0 -1px 0 rgba(0, 0, 0, .55));
}
.icon-brand { background-position: calc(var(--s) * 0) 0; }

/* ---------- shell ----------------------------------------------------------------------- */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--bg-chrome);
    border-right: 1px solid var(--border-chrome);
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 30;
    display: flex;
    flex-direction: column;
    overscroll-behavior: contain;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--header-h);
    padding: 0 16px;
    border-bottom: 1px solid var(--border-chrome);
    position: sticky;
    top: 0;
    background: var(--bg-chrome);
    z-index: 2;
    white-space: nowrap;
}
/* Apex Darza, at exactly twice its 16px art so every art pixel is 2x2, with the wiki's game
   sprite outline: four hard 1px dark stamps that trace the silhouette, and a dark glow. */
.brand .icon {
    --s: 32px;
    filter: drop-shadow(1px 0 0 rgba(0, 0, 0, .85)) drop-shadow(-1px 0 0 rgba(0, 0, 0, .85))
            drop-shadow(0 1px 0 rgba(0, 0, 0, .85)) drop-shadow(0 -1px 0 rgba(0, 0, 0, .85))
            drop-shadow(0 0 2px rgba(0, 0, 0, 1));
}
/* Nope 8 is drawn on a 16 px grid (64 units of a 1024 em), so it is only crisp at 16, 32 or
   48 px, where each font pixel covers whole screen pixels; at 22 px every edge is smeared. */
.brand-name {
    font-family: var(--font-display);
    font-size: 32px;
    line-height: 1;
    color: var(--text-heading);
}
.nav-group-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 14px 16px 4px;
    white-space: nowrap;
    overflow: hidden;
}
.nav a {
    display: block;
    padding: 5px 16px;
    color: var(--link);
    white-space: nowrap;
}
.nav a:hover { color: var(--link-hover); }
.nav a.active { color: var(--text); font-weight: 700; background: var(--bg-hover); }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 700; color: #fff; background: var(--bad); border-radius: 9px; padding: 0 6px; }
.sidebar-foot { margin-top: auto; padding: 14px 16px; font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }


.page {
    padding-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: padding-left .25s ease;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    background: var(--bg-chrome);
    border-bottom: 1px solid var(--border-chrome);
}
.topbar .spacer { flex: 1; }
.env-switch { display: flex; gap: 4px; flex-wrap: nowrap; overflow-x: auto; }
.env-switch a {
    padding: 4px 10px;
    border-radius: 14px;
    color: var(--text-muted);
    border: 1px solid transparent;
    white-space: nowrap;
    font-size: 13px;
}
.env-switch a:hover { color: var(--text); background: var(--bg-hover); }
.env-switch a.active { color: var(--text); background: var(--bg-panel); border-color: var(--border); font-weight: 700; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex-shrink: 0; }
.live-dot.on { background: #3ba55d; box-shadow: 0 0 0 3px rgba(59, 165, 93, .2); }
.live-dot.off { background: var(--bad); }
.round-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-panel);
    color: var(--text);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}
.round-btn:hover { background: var(--bg-hover); }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }
.user-chip form { margin: 0; }
.mobile-nav-toggle { display: none; }

.accent-picker { position: relative; }
.accent-popover {
    display: none;
    position: absolute;
    top: 38px;
    right: 0;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
    gap: 6px;
    z-index: 60;
}
.accent-picker.open .accent-popover { display: flex; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.active { border-color: var(--text); }

.content {
    width: 100%;
    max-width: var(--content-max);
    margin: 16px auto 24px;
    padding: 8px 28px 36px;
    background: var(--bg-panel);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    box-shadow: var(--shadow-panel);
}
.page > .content { width: calc(100% - 32px); }
.breadcrumbs { display: flex; gap: 6px; font-size: 13px; margin: 6px 0 4px; color: var(--text-muted); flex-wrap: wrap; }
.footer { margin-top: auto; padding: 14px 32px 18px; border-top: 1px solid var(--border-chrome); font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ---------- status pills ---------------------------------------------------------------- */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 1px 9px 1px 7px;
    border-radius: 11px;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
    color: var(--off);
    background: var(--off-bg);
    vertical-align: middle;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill.good { color: var(--good); background: var(--good-bg); }
.pill.busy { color: var(--busy); background: var(--busy-bg); }
.pill.busy::before { animation: pulse 1.1s ease-in-out infinite; }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.off { color: var(--off); background: var(--off-bg); }
.pill.big { font-size: 14px; padding: 3px 12px 3px 9px; }
@keyframes pulse { 50% { opacity: .25; } }
.state-detail { color: var(--text-muted); font-size: 12.5px; }

.env-tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 7px; border-radius: 3px; border: 1px solid var(--border); color: var(--text-muted); }
.env-tag.protected { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.tag-chip { display: inline-block; margin: 1px 4px 1px 0; padding: 0 6px; border-radius: 3px; font-size: 12px; line-height: 18px; background: var(--bg-inset); border: 1px solid var(--border); white-space: nowrap; }

/* ---------- tables ---------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin: 8px 0 16px; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: 6px 10px;
    white-space: nowrap;
}
.table td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:nth-child(even) td { background: var(--bg-stripe); }
.table tbody tr:hover td { background: var(--bg-hover); }
.table td.num, .table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .row-title { font-weight: 700; }
.table .sub { display: block; color: var(--text-muted); font-size: 12px; font-weight: normal; }
.table tr.group td { background: transparent !important; padding-top: 18px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.empty { color: var(--text-muted); padding: 18px 4px; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 8px 0 16px; }
dl.facts dt { color: var(--text-muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- meters, stats --------------------------------------------------------------- */

.meter { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.meter .bar { width: 64px; height: 6px; border-radius: 3px; background: var(--bg-inset); border: 1px solid var(--border); overflow: hidden; }
.meter .fill { height: 100%; background: var(--good); }
.meter .fill.warn { background: var(--warn); }
.meter .fill.bad { background: var(--bad); }

.stats { display: flex; gap: 0; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 6px; margin: 8px 0 16px; }
.stat { flex: 1 1 140px; padding: 10px 14px; border-right: 1px solid var(--border); }
.stat:last-child { border-right: none; }
.stat .value { font-size: 22px; font-weight: 700; color: var(--text-heading); font-variant-numeric: tabular-nums; }
.stat .label { font-size: 12px; color: var(--text-muted); }

.env-block { padding: 12px 0 6px; border-bottom: 1px solid var(--border); }
.env-block:last-child { border-bottom: none; }
.env-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.env-head h2 { margin: 0; }
.state-counts { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }

.spark { display: inline-block; vertical-align: middle; }
.spark path { fill: none; stroke: var(--link); stroke-width: 1.5; }
.spark path.mem { stroke: var(--warn); }

/* ---------- buttons, forms -------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--bg-panel);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { background: var(--bg-hover); color: var(--text); }
.btn.primary { background: var(--link); border-color: var(--link); color: #fff; }
.btn.primary:hover { background: var(--link-hover); border-color: var(--link-hover); color: #fff; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, var(--input-border)); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.actions form { margin: 0; display: inline; }
.inline-form { display: inline; margin: 0; }

.form { max-width: 760px; }
.form .field { margin: 0 0 14px; }
.form label, .field > .label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.form .help { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.form .row { display: flex; gap: 12px; flex-wrap: wrap; }
.form .row > .field { flex: 1 1 180px; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=search], select, textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    color: var(--input-text);
    font: inherit;
    padding: 6px 9px;
}
textarea { font-family: var(--font-mono); font-size: 12.5px; min-height: 90px; resize: vertical; }
textarea.tall { min-height: 220px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--link) 45%, transparent); outline-offset: 0; border-color: var(--link); }
input[type=checkbox] { width: 15px; height: 15px; vertical-align: -2px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: normal !important; }
.check input { margin-top: 2px; }

.flash { padding: 8px 12px; border-radius: 4px; margin: 8px 0 12px; border: 1px solid; }
.flash.ok { color: var(--good); background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.flash.error { color: var(--bad); background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.flash.info { color: var(--busy); background: var(--busy-bg); border-color: color-mix(in srgb, var(--busy) 35%, transparent); }
.flash.warn { color: var(--warn); background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.flash pre { white-space: pre-wrap; margin: 6px 0 0; color: var(--text); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 12px 0; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-bottom-color: var(--link); font-weight: 700; }

/* ---------- logs and previews: always dark, like the wiki's tooltip cards ---------------- */

pre.console, .console {
    background: var(--card-bg);
    color: var(--card-text);
    border-radius: 6px;
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.45;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 560px;
    margin: 8px 0 16px;
}
.console.short { max-height: 260px; }
.console .err { color: #ff8a80; }
.console .dim { color: var(--card-muted); }
.log-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.steps { list-style: none; margin: 10px 0; padding: 0; border-left: 2px solid var(--border); }
.steps li { padding: 4px 0 4px 14px; position: relative; }
.steps li::before { content: ""; position: absolute; left: -6px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.steps li.done::before { background: var(--good); }
.steps li.active::before { background: var(--busy); animation: pulse 1.1s ease-in-out infinite; }
.steps li.failed::before { background: var(--bad); }

/* ---------- login ----------------------------------------------------------------------- */

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: 100%; max-width: 380px; background: var(--bg-panel); border: 1px solid var(--panel-border); border-radius: 8px; padding: 24px 26px 18px; box-shadow: var(--shadow-panel); }
.login-box .brand { position: static; border: none; padding: 0 0 12px; height: auto; background: none; }

/* Long paths and names may break anywhere rather than push a table wider than the page. */
.wrap-any { overflow-wrap: anywhere; word-break: break-word; min-width: 12em; }

/* ---------- narrow desktop: drop the columns that only add detail ------------------------- */

@media (max-width: 1180px) {
    .hide-narrow { display: none; }
}

/* ---------- mobile ---------------------------------------------------------------------- */

.nav-backdrop { display: none; }
@media (max-width: 860px) {
    .sidebar { width: min(300px, 85vw); transform: translate3d(-105%, 0, 0); visibility: hidden; transition: transform .25s ease, visibility .25s ease; z-index: 1001; }
    html.mobile-nav-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, .45); }
    .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 1000; opacity: 0; pointer-events: none; transition: opacity .25s; }
    html.mobile-nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
    .page { padding-left: 0; }
    .mobile-nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .topbar { padding: 0 10px; gap: 8px; }
    .user-chip .who { display: none; }
    .page > .content { width: auto; margin: 8px; padding: 8px 14px 24px; }
    .stat { flex-basis: 45%; border-right: none; border-bottom: 1px solid var(--border); }
    .hide-mobile { display: none; }
}
