/* Discord CC admin — design system.
   No build step and no CDN on purpose: the image is python:3.11-slim, so the
   whole UI has to work from vendored files with no npm install. */
:root {
    color-scheme: dark;
    --bg: #0e1118;
    --bg-elev: #151a25;
    --bg-sunken: #0a0d13;
    --panel: #1a2030;
    --line: #262d3f;
    --line-strong: #36405a;
    --text: #e9ecf5;
    --muted: #969fba;
    --faint: #6d7793;
    --accent: #5865f2;
    --accent-ink: #ffffff;
    --ok: #3fb950;
    --warn: #e3a008;
    --err: #f0484d;
    --info: #4d9ff0;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .3);
    --mono: ui-monospace, "Cascadia Mono", Consolas, "Segoe UI Mono", monospace;
    --sidebar: 224px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 14px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
    grid-template-rows: 54px 1fr;
    grid-template-areas: "brand bar" "side main";
    min-height: 100vh;
}
@media (max-width: 900px) {
    body { grid-template-columns: 1fr; grid-template-areas: "bar" "main"; }
}
/* Signed-out pages (login, health probe) have no sidebar, so the 224px brand
   column must collapse too - body.no-side is set from base.html. */
body.no-side { grid-template-columns: 1fr; grid-template-areas: "bar" "main"; }
body.no-side .brand { display: none; }

/* ---------- chrome ---------- */
.brand {
    grid-area: brand; display: flex; align-items: center; gap: 10px; padding: 0 14px;
    border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
    background: var(--bg-elev); font-weight: 650; letter-spacing: .2px;
}
.brand .mark {
    width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto; display: grid;
    place-items: center; color: #fff; font-size: 13px;
    background: linear-gradient(140deg, var(--accent), #8b5cf6);
}
.topbar {
    grid-area: bar; display: flex; align-items: center; gap: 12px; padding: 0 18px;
    border-bottom: 1px solid var(--line); background: var(--bg-elev);
    position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 15px; margin: 0; font-weight: 600; }
.spacer { flex: 1; }
.env {
    color: var(--muted); font-size: 11px; font-family: var(--mono);
    border: 1px solid var(--line-strong); background: var(--bg-sunken);
    padding: 2px 8px; border-radius: 999px;
}
.kicker { color: var(--muted); font-size: 12px; }
.sidebar {
    grid-area: side; border-right: 1px solid var(--line); background: var(--bg-elev);
    padding: 14px 10px; overflow-y: auto; position: sticky; top: 54px;
    align-self: start; max-height: calc(100vh - 54px);
}
@media (max-width: 900px) {
    .sidebar { position: static; max-height: none; border-right: none; display: flex;
               gap: 6px; overflow-x: auto; padding: 10px; }
    .sidebar .navgroup { margin-bottom: 0; }
}
.navgroup { margin-bottom: 18px; }
.navgroup h2 {
    font-size: 10px; letter-spacing: .9px; text-transform: uppercase; color: var(--faint);
    margin: 0 8px 6px; font-weight: 650;
}
nav { display: contents; }
nav a {
    display: flex; align-items: center; gap: 9px; padding: 7px 9px; margin: 1px 0;
    color: var(--muted); text-decoration: none; border-radius: var(--radius-sm);
    font-size: 13.5px;
}
nav a:hover { background-color: rgba(88, 101, 242, .1); color: var(--text); }
nav a.active { background: rgba(88, 101, 242, .16); color: var(--text); font-weight: 600; }
nav a .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5; }
main { grid-area: main; padding: 22px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ---------- type ---------- */
h1 { font-size: 21px; margin: 0 0 6px; letter-spacing: -.2px; }
h2 {
    font-size: 12px; color: var(--muted); margin: 26px 0 10px;
    text-transform: uppercase; letter-spacing: .7px;
}
h3 { font-size: 13px; margin: 16px 0 6px; }
p { margin: 10px 0; }
a { color: #9aa5ff; }
code {
    background: var(--bg-sunken); border: 1px solid var(--line); padding: 1px 5px;
    border-radius: 5px; font-size: 12px; font-family: var(--mono);
}
pre { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.small-txt { font-size: 15px !important; }

/* ---------- flash + toast ---------- */
.flash {
    border-radius: var(--radius); padding: 11px 14px; margin-bottom: 14px;
    border: 1px solid var(--warn); background: rgba(227, 160, 8, .11);
}
.flash.error { border-color: var(--err); background: rgba(240, 72, 77, .11); }
.flash.ok { border-color: var(--ok); background: rgba(63, 185, 80, .11); }
.flash.warn { border-color: var(--warn); background: rgba(227, 160, 8, .11); }
.flash a { color: var(--text); }
#toasts {
    position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex;
    flex-direction: column; gap: 8px; max-width: min(430px, 92vw);
}
.toast {
    background: var(--panel); border: 1px solid var(--line-strong);
    border-left: 3px solid var(--info); border-radius: var(--radius); padding: 10px 13px;
    box-shadow: var(--shadow); font-size: 13px; animation: rise .18s ease-out;
}
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important; transition-duration: .01ms !important;
    }
}

/* ---------- cards ---------- */
.cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px; margin: 14px 0 22px;
}
.card {
    background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 13px 15px;
}
.card .k {
    display: block; color: var(--faint); font-size: 10.5px; text-transform: uppercase;
    letter-spacing: .7px;
}
.card .v { font-size: 25px; font-weight: 620; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.card.ok { border-color: rgba(63, 185, 80, .45); }
.card.warn { border-color: rgba(227, 160, 8, .5); }
.card-box {
    background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 4px 18px 18px; margin-bottom: 18px;
}
.card-box h2 { margin-top: 16px; }

/* ---------- tables ---------- */
.scroll { overflow-x: auto; max-width: 100%; }
table.t {
    width: 100%; border-collapse: separate; border-spacing: 0; background: var(--bg-elev);
    border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px;
}
table.t th, table.t td {
    text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line);
    vertical-align: top; font-size: 13px;
}
table.t thead th {
    background: #1b2233; color: var(--faint); font-size: 10.5px; text-transform: uppercase;
    letter-spacing: .7px; position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
table.t tbody tr:last-child td { border-bottom: none; }
table.t tbody tr:hover td { background: rgba(88, 101, 242, .055); }
table.t tr.enabled td { background: rgba(63, 185, 80, .07); }
table.t td.num, table.t th.num { font-variant-numeric: tabular-nums; }
table.t th.sortable { cursor: pointer; user-select: none; }
table.t th.sortable:hover { color: var(--text); }
table.t th .arrow { opacity: .6; margin-left: 4px; }
td.ids, td.err, td.notes {
    font-size: 12px; color: var(--muted); max-width: 320px; overflow-wrap: anywhere;
}
td.err { color: var(--err); }
td.notes ul { margin: 0; padding-left: 16px; }
td.actions { white-space: nowrap; text-align: right; }

/* ---------- badges ---------- */
.tag {
    display: inline-flex; align-items: center; font-size: 10.5px; text-transform: uppercase;
    letter-spacing: .5px; padding: 2px 8px; border-radius: 999px;
    border: 1px solid var(--line-strong); color: var(--muted);
    background: var(--bg-sunken); font-weight: 620;
}
.tag.on { border-color: rgba(63, 185, 80, .55); color: #74e08a; }
.tag.off { color: var(--faint); }
.tag.err { border-color: rgba(240, 72, 77, .55); color: #ff8f93; }

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: 11px; }
.row { display: flex; flex-wrap: wrap; gap: 9px; align-items: flex-end; }
.grow { flex: 1; min-width: 190px; }
.inline { display: inline; }
label {
    display: flex; flex-direction: column; gap: 5px; font-size: 11.5px;
    color: var(--muted); font-weight: 550;
}
input, textarea, select, button {
    background: var(--bg-sunken); color: var(--text); border: 1px solid var(--line-strong);
    padding: 8px 11px; border-radius: var(--radius-sm); font-size: 13.5px;
    font-family: inherit; width: 100%;
}
textarea { resize: vertical; min-height: 62px; font-family: var(--mono); font-size: 12.5px; }
input.narrow { width: 96px; flex: 0 0 auto; }
.frow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.frow input, .frow select { width: auto; min-width: 128px; flex: 1 1 auto; font-size: 12.5px; }
.filters { margin-bottom: 12px; }
input:focus, textarea:focus, select:focus, button:focus-visible {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88, 101, 242, .24);
}
input::placeholder, textarea::placeholder { color: #565f7d; }
button, a.btn {
    background: var(--accent); color: var(--accent-ink); border: 1px solid transparent;
    cursor: pointer; font-weight: 600; font-size: 13px; padding: 8px 14px;
    border-radius: var(--radius-sm); display: inline-flex; align-items: center; gap: 7px;
    width: auto; text-decoration: none; white-space: nowrap;
}
button:hover, a.btn:hover { filter: brightness(1.1); }
button:active, a.btn:active { transform: translateY(1px); }
button.ghost, a.ghost {
    background: transparent; border: 1px solid var(--line-strong); color: var(--text);
    font-weight: 500;
}
button.ghost:hover, a.ghost:hover { border-color: var(--accent); background: rgba(88, 101, 242, .1); }
button.danger { background: var(--err); }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }

/* staged progress, driven by real server state */
.progress { min-height: 18px; color: var(--muted); font-size: 12px; margin: 0; }
.progress.ok { color: var(--ok); }
.progress.err { color: var(--err); }
.stages { list-style: none; margin: 8px 0; padding: 0; font-size: 12px; color: var(--faint); }
.stages li { padding: 3px 0 3px 22px; position: relative; }
.stages li::before {
    content: ""; position: absolute; left: 4px; top: 9px; width: 9px; height: 9px;
    border-radius: 50%; border: 2px solid var(--line-strong);
}
.stages li.done { color: var(--text); }
.stages li.done::before { background: var(--ok); border-color: var(--ok); }
.meter { height: 5px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }

/* ---------- dialogs (top layer via showModal) ---------- */
dialog {
    background: var(--panel); color: var(--text); border: 1px solid var(--line-strong);
    border-radius: 14px; padding: 20px; width: min(580px, 92vw); max-height: 86vh;
    overflow: auto; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(4, 6, 12, .74); backdrop-filter: blur(2px); }
dialog h2 { margin-top: 0; text-transform: none; letter-spacing: 0; font-size: 16px; color: var(--text); }
.picker {
    max-height: 46vh; overflow-y: auto; border: 1px solid var(--line);
    border-radius: var(--radius); padding: 6px; background: var(--bg-sunken);
}
.pick {
    display: flex; gap: 9px; align-items: center; flex-direction: row; padding: 6px 7px;
    border-radius: 6px; font-size: 13px; color: var(--text); font-weight: 450;
}
.pick:hover { background: rgba(88, 101, 242, .1); }
.pick input { width: auto; }
.pick code { margin-left: auto; }
dl.explain dt { font-weight: 620; color: var(--text); margin-top: 12px; }
dl.explain dd { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }

/* ---------- diagnostics ---------- */
.logview {
    background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 11px 13px; font-family: var(--mono); font-size: 11.5px; line-height: 1.5;
    max-height: 46vh; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere;
    margin: 10px 0;
}
.pill {
    display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 620;
    padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-strong);
    background: var(--bg-sunken);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.live::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(63, 185, 80, .18); }
.pill.dead::before { background: var(--err); }
.pill.warn::before { background: var(--warn); }

/* ---------- dashboard ---------- */
.banner {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 11px 14px;
    border-radius: var(--radius); border: 1px solid var(--line-strong);
    background: var(--bg-elev); margin-bottom: 4px;
}
.banner.running { border-color: rgba(63, 185, 80, .45); }
.banner.no-account, .banner.stale { border-color: rgba(227, 160, 8, .55); }
.banner.never-started, .banner.stopped { border-color: rgba(240, 72, 77, .5); }
.banner #verdict-why { flex: 1; min-width: 220px; color: var(--muted); }
.chart {
    display: flex; align-items: flex-end; gap: 4px; height: 130px; padding: 12px 12px 4px;
    background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
}
.chart .bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.chart .bar i { display: block; width: 100%; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--accent); }
.chart .bar i.zero { background: var(--line-strong); }
.chart .bar span { font-size: 9.5px; color: var(--faint); margin-top: 4px; height: 14px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 18px; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }

/* ---------- data tables ---------- */
td.clip { max-width: 420px; overflow-wrap: anywhere; }
tr.clickable { cursor: pointer; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 0 24px; }

/* ---------- proxies ---------- */
.two-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
@media (max-width: 900px) { .two-even { grid-template-columns: 1fr; } }
.err-text { color: var(--err); }
#job-out ul { margin: 4px 0; padding-left: 18px; }
#job-out dl.explain { margin: 0; }
#job-out dl.explain dl.explain { margin-left: 10px; padding-left: 10px; border-left: 1px solid var(--line); }

/* ---------- guilds ---------- */
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; border: 1px solid var(--line-strong); }
