/* The console of forge.latouf.re: one sidebar, cards and tables, steps and logs. Light and dark follow the system. */
:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --sunken: #f1f3f6;
    --text: #15171a;
    --soft: #3d4450;
    --muted: #5b6370;
    --line: #e4e7ec;
    --line-soft: #f0f2f5;
    --field: #d5dae1;
    --accent: #2f6fde;
    --accent-ink: #173c8f;
    --accent-soft: #e8edfb;
    --ok: #146c3a;
    --ok-soft: #e3f4ea;
    --fail: #a3261d;
    --fail-soft: #fbe7e5;
    --warn: #6b4600;
    --warn-soft: #fff7e6;
    --warn-line: #f1d9a6;
    --log: #111214;
    --log-text: #d8d8dc;
    --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111316;
        --surface: #181b1f;
        --sunken: #20242a;
        --text: #eceef1;
        --soft: #c9cdd4;
        --muted: #9aa1ac;
        --line: #2a2f36;
        --line-soft: #22262c;
        --field: #353b44;
        --accent: #6c9cff;
        --accent-ink: #b9cdff;
        --accent-soft: #1d2a45;
        --ok: #5fd08e;
        --ok-soft: #13301f;
        --fail: #ff8a80;
        --fail-soft: #3a1714;
        --warn: #f3c66b;
        --warn-soft: #2e2410;
        --warn-line: #4d3c18;
        --log: #0b0c0e;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); }

h1 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 16px; }
h3 { margin: 0; font-size: 15px; }

.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.error { margin: 0; color: var(--fail); }
.ok { color: var(--ok); }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { min-height: 40px; padding: 0 12px; border: 1px solid var(--field); border-radius: 10px; background: var(--surface); }
textarea { padding: 10px 12px; font: 13px/1.6 var(--mono); resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Buttons */
.button, button.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 0 16px; border: 0; border-radius: 10px;
    background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.button:hover { color: #fff; filter: brightness(1.06); }
.button.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--field); font-weight: 500; }
.button.ghost:hover { border-color: var(--muted); filter: none; }
.button.danger { background: var(--surface); color: var(--fail); border: 1px solid var(--field); font-weight: 500; }
.button.small { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.button[disabled] { opacity: .5; cursor: default; }
.chip { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border: 1px solid var(--field); border-radius: 999px; background: var(--surface); font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--muted); }
form.inline { display: inline-flex; margin: 0; }

/* Pills and dots */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--sunken); color: var(--soft); }
.pill.succeeded, .pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.failed, .pill.fail { background: var(--fail-soft); color: var(--fail); }
.pill.running, .pill.queued, .pill.run { background: var(--accent-soft); color: var(--accent-ink); }
.pill.running::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
.tag { padding: 2px 8px; border-radius: 999px; background: var(--sunken); color: var(--soft); font-size: 12px; white-space: nowrap; }
.sha { padding: 2px 6px; border-radius: 6px; background: var(--sunken); font: 12.5px var(--mono); color: var(--text); }
.dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--muted); }
.dot.ok, .dot.succeeded { background: var(--ok); }
.dot.fail, .dot.failed { background: var(--fail); }
.dot.run, .dot.running, .dot.queued { background: var(--accent); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .pill.running::before { animation: none; } }

/* Layout: the sidebar beside the page, stacked on a phone */
.console { min-height: 100vh; display: flex; flex-wrap: wrap; align-items: stretch; }
.sidebar { flex: 1 1 220px; display: flex; flex-direction: column; gap: 2px; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; color: var(--text); }
.sidebar .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.sidebar .brand strong { display: block; font-size: 15px; }
.sidebar .brand small { color: var(--muted); font-size: 12px; }
.sidebar .heading { margin: 14px 10px 4px; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.sidebar a.item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: 9px; color: var(--soft); font-weight: 500; }
.sidebar a.item:hover { background: var(--sunken); color: var(--text); }
.sidebar a.item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.sidebar a.item span.grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar svg { width: 18px; height: 18px; flex: none; }
.sidebar .account { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 10px 0; border-top: 1px solid var(--line); }
.sidebar .account .who { flex: 1; min-width: 0; }
.sidebar .account .who strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.sidebar .account .who small { color: var(--muted); font-size: 12px; }
.icon-button { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; }
.page { flex: 999 1 560px; min-width: 0; padding: 24px 32px 56px; display: flex; flex-direction: column; gap: 20px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.page-head .title { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.page-head .title-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.crumbs { color: var(--muted); font-size: 13px; }
.crumbs a { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Cards and grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.card.padded { padding: 16px 18px; }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split > .main { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.split > .side { flex: 1 1 290px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.section-title { display: flex; align-items: center; gap: 12px; }
.section-title h2 { flex: 1; }

.project-card { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; padding: 18px 20px; }
.project-card .who { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.project-card .who a.name { color: var(--text); font-weight: 650; font-size: 16px; }
.project-card .what { flex: 2 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.line.wrap { flex-wrap: wrap; row-gap: 2px; }
.line .cut { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.feed { padding: 4px 0; }
.feed .event { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line-soft); color: inherit; }
.feed .event:last-child { border-bottom: 0; }
.feed a.event:hover { background: var(--sunken); }
.feed .event .dot { margin-top: 6px; }
.feed .event .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.feed .event .body strong { font-weight: 500; overflow-wrap: anywhere; }
.feed .event .body span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.feed .event time { color: var(--muted); font-size: 12px; white-space: nowrap; }

.strip { display: flex; flex-wrap: wrap; overflow: hidden; }
.strip > div { flex: 1 1 170px; padding: 16px 20px; display: flex; flex-direction: column; gap: 6px; border-right: 1px solid var(--line-soft); min-width: 0; }
.strip > div:first-child { flex: 2 1 320px; }
.strip > div:last-child { border-right: 0; }
.label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }

/* Tables */
.table-box { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 10px; color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; }
td { padding: 13px 10px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.when { color: var(--muted); white-space: nowrap; }
td .cut { display: block; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.clickable:hover td { background: var(--sunken); }

/* A kept release, a fact list */
.releases { display: flex; flex-direction: column; gap: 12px; }
.release { display: flex; align-items: center; gap: 10px; }
.release .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* A kept database backup: when and how big, then what to do with it */
.files { display: flex; flex-direction: column; gap: 14px; }
.file { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.file .body { flex: 1 1 100%; display: flex; justify-content: space-between; gap: 8px; }
/* Beside the deployments the column is narrow: the action goes under the release */
.side .release { flex-wrap: wrap; gap: 6px 10px; }
.side .release .body { flex-basis: 100%; }
.stack { display: flex; flex-direction: column; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 20px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
code.copy { font: 12.5px/1.5 var(--mono); overflow-wrap: anywhere; user-select: all; }
.switch { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.switch .body { flex: 1; display: flex; flex-direction: column; gap: 2px; }

/* Steps of a deployment */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.steps li.current { border-color: var(--accent); background: var(--accent-soft); }
.steps .mark { width: 24px; height: 24px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--sunken); color: var(--muted); font-size: 12px; font-weight: 700; }
.steps li.done .mark { background: var(--ok-soft); color: var(--ok); }
.steps li.current .mark { background: var(--accent); color: #fff; }
.steps li.failed .mark { background: var(--fail-soft); color: var(--fail); }
.steps .name { display: block; font-weight: 600; font-size: 13.5px; }
.steps .time { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* The log, one block per command */
.log-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.log-head h2 { flex: 1; }
.block { border-bottom: 1px solid var(--line-soft); }
.block:last-child { border-bottom: 0; }
.block summary { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 16px; cursor: pointer; list-style: none; }
.block summary::-webkit-details-marker { display: none; }
.block summary .state { width: 18px; text-align: center; font-weight: 700; color: var(--muted); }
.block.ok summary .state { color: var(--ok); }
.block.fail summary .state { color: var(--fail); }
.block.run summary { background: var(--accent-soft); }
.block.run summary .state { color: var(--accent); }
.block summary .cmd { flex: 1; min-width: 0; font: 12.5px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block summary .took { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.block summary .chev { color: var(--muted); transition: transform .15s; }
.block[open] summary .chev { transform: rotate(90deg); }
.block pre { margin: 0; padding: 12px 16px 14px 46px; background: var(--log); color: var(--log-text); font: 12px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 520px; overflow-y: auto; }
.block.note summary .cmd { font-family: var(--font); color: var(--soft); }

/* Commands */
.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.notice.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.notice .body { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.command-bar { display: flex; align-items: stretch; min-height: 48px; border: 2px solid var(--accent); border-radius: 12px; overflow: hidden; background: var(--surface); }
.command-bar .prefix { display: inline-flex; align-items: center; padding: 0 12px; background: var(--sunken); color: var(--muted); font: 13px var(--mono); white-space: nowrap; }
.command-bar input { flex: 1; min-width: 0; min-height: 44px; border: 0; border-radius: 0; font: 14px var(--mono); }
.command-bar input:focus-visible { outline: none; }
.command-bar button { border-radius: 0; }
.suggestions { list-style: none; margin: 0; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 8px 24px rgba(21, 23, 26, .08); max-height: 280px; overflow-y: auto; }
.suggestions li { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 10px; border-radius: 8px; cursor: pointer; }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--accent-soft); }
.suggestions .name { font: 13px var(--mono); min-width: 160px; }
.suggestions .text { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: 0 16px 40px rgba(21, 23, 26, .18); }
dialog::backdrop { background: rgba(17, 19, 22, .45); }
dialog form { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
dialog .danger-line { padding: 8px 10px; border-radius: 8px; background: var(--fail-soft); color: var(--fail); font: 12.5px var(--mono); overflow-wrap: anywhere; }

/* Forms */
.fields { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.fields label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13.5px; }
.fields label.check { flex-direction: row; align-items: center; color: var(--text); }
.fields label.check input { min-height: 0; width: 18px; height: 18px; }
.fields input, .fields select, .fields textarea { color: var(--text); font-size: 14.5px; }
.fields .row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

/* Signing in */
.lone { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 0; }
.login { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin-bottom: 8px; }

@media (max-width: 720px) {
    .page { padding: 20px 16px 48px; }
    /* The sidebar becomes a bar of links that scrolls sideways */
    .sidebar { position: sticky; top: 0; z-index: 5; flex-direction: row; align-items: center; gap: 4px; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
    .sidebar .brand { padding: 0 6px 0 0; }
    .sidebar .brand > span:not(.logo), .sidebar .heading, .sidebar .account .logo, .sidebar .account .who { display: none; }
    .sidebar a.item { flex: none; min-height: 38px; }
    .sidebar a.item span.grow { overflow: visible; }
    .sidebar .account { margin: 0 0 0 4px; padding: 0; border-top: 0; }
    .facts { grid-template-columns: 1fr; gap: 2px; }
    .facts dd { margin-bottom: 10px; }
    .fields .row { grid-template-columns: 1fr; }
    .command-bar .prefix { display: none; }
    .tabs { flex-wrap: nowrap; overflow-x: auto; }
    .tabs a { flex: none; }
    th.wide, td.wide { display: none; }
    td .cut { max-width: 44vw; }
}
