@import url('https://fonts.googleapis.com/css2?family=Schibsted+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bench: #e6eaee;
  --panel: #ffffff;
  --panel-2: #f3f5f8;
  --ink: #1d2833;
  --ink-2: #566472;
  --ink-3: #8a96a3;
  --rule: #d5dbe2;
  --cobalt: #2f4fd8;
  --cobalt-ink: #ffffff;
  --go: #1e8e5a;
  --go-soft: #dcf1e6;
  --wait: #b97b0c;
  --wait-soft: #fbefd5;
  --stop: #c8372d;
  --stop-soft: #f9e0de;
  --idle: #9aa6b2;
  --shadow: 0 1px 0 rgba(29, 40, 51, .06), 0 6px 18px -10px rgba(29, 40, 51, .25);
  --sans: 'Schibsted Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bench: #12181f; --panel: #1a222b; --panel-2: #212b36; --ink: #e2e8ee; --ink-2: #a3afbb; --ink-3: #6f7c89;
    --rule: #2c3945; --cobalt: #7d93ff; --cobalt-ink: #0e1630; --go: #4cc78b; --go-soft: #173327; --wait: #e6b04a;
    --wait-soft: #3a2e14; --stop: #f07167; --stop-soft: #3d1d1b; --idle: #5d6a77;
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 8px 20px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bench: #12181f; --panel: #1a222b; --panel-2: #212b36; --ink: #e2e8ee; --ink-2: #a3afbb; --ink-3: #6f7c89;
  --rule: #2c3945; --cobalt: #7d93ff; --cobalt-ink: #0e1630; --go: #4cc78b; --go-soft: #173327; --wait: #e6b04a;
  --wait-soft: #3a2e14; --stop: #f07167; --stop-soft: #3d1d1b; --idle: #5d6a77;
  --shadow: 0 1px 0 rgba(0,0,0,.3), 0 8px 20px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bench); color: var(--ink); font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--cobalt); text-decoration-thickness: 1px; text-underline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }

/* ---------- top bar */
.top {
  display: flex; align-items: center; gap: 16px; padding: 14px 28px;
  border-bottom: 1px solid var(--rule); background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand svg { width: 26px; height: 26px; }
.top .spacer { flex: 1; }
.top .who { color: var(--ink-2); font-size: 14px; }
.btn {
  border: 1px solid var(--rule); background: var(--panel); border-radius: 8px; padding: 7px 13px;
  cursor: pointer; font-weight: 500; font-size: 14px; line-height: 1.2;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--cobalt); border-color: var(--cobalt); color: var(--cobalt-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.quiet:hover { color: var(--ink); background: var(--panel-2); }
.btn:disabled { opacity: .5; cursor: default; }

main { max-width: 1320px; margin: 0 auto; padding: 26px 28px 60px; }
h2 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 12px; letter-spacing: .01em; }
section + section { margin-top: 34px; }

/* ---------- environments: the signal board */
.project-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.project-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.envs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 16px; }
.env {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 20px 22px 18px;
  display: grid; gap: 14px; position: relative; overflow: hidden;
}
.env::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--lamp, var(--idle)); }
.env-head { display: flex; align-items: center; gap: 14px; }
.lamp {
  width: 16px; height: 16px; border-radius: 50%; background: var(--lamp, var(--idle)); flex: none;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--lamp, var(--idle)) 18%, transparent);
}
.lamp.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--lamp) 4%, transparent); } }
.env-name { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.env-state { font-weight: 500; color: var(--ink-2); }
.env-head .actions { margin-left: auto; display: flex; gap: 8px; }
.env-url { font-size: 14px; word-break: break-all; }
.env-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 14px; margin: 0; }
.env-facts dt { color: var(--ink-3); }
.env-facts dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.go { --lamp: var(--go); } .wait { --lamp: var(--wait); } .stop { --lamp: var(--stop); } .idle { --lamp: var(--idle); }

/* pipeline track: stations of the latest build */
.track { display: flex; align-items: center; padding: 6px 0 0; }
.station { display: grid; justify-items: center; gap: 4px; flex: none; min-width: 54px; font-size: 12px; color: var(--ink-3); }
.station i {
  width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--rule); background: var(--panel); display: block;
}
.station.done i { background: var(--go); border-color: var(--go); }
.station.done { color: var(--ink-2); }
.station.now i { background: var(--wait); border-color: var(--wait); animation: pulse 1.6s infinite; --lamp: var(--wait); }
.station.now { color: var(--ink); font-weight: 600; }
.station.fail i { background: var(--stop); border-color: var(--stop); }
.station.fail { color: var(--stop); font-weight: 600; }
.rail { flex: 1; height: 2px; background: var(--rule); margin: 0 -14px 18px; min-width: 12px; }
.rail.done { background: var(--go); }

/* ---------- layout below */
.split { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
.split > div, .env { min-width: 0; }
.board-wrap { overflow-x: auto; }
.panel { background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px 10px; }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.panel-head .aside { margin-left: auto; font-size: 13px; color: var(--ink-3); }
.panel-body { padding: 0 18px 16px; }

/* builds board */
.board { width: 100%; border-collapse: collapse; font-size: 14px; }
.board th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12.5px; padding: 6px 10px; border-bottom: 1px solid var(--rule); }
.board td { padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.board tr:last-child td { border-bottom: 0; }
.board tbody tr { cursor: pointer; }
.board tbody tr:hover td { background: var(--panel-2); }
.board .msg { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .when, .board .dur { white-space: nowrap; color: var(--ink-2); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 9px 2px 7px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--panel-2); color: var(--ink-2);
}
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.success { background: var(--go-soft); color: var(--go); }
.pill.running { background: var(--wait-soft); color: var(--wait); }
.pill.queued { color: var(--ink-2); }
.pill.failed { background: var(--stop-soft); color: var(--stop); }
.pill.cancelled { color: var(--ink-3); }
.tag { display: inline-block; font-size: 12.5px; padding: 1px 7px; border-radius: 5px; background: var(--panel-2); color: var(--ink-2); white-space: nowrap; }
.tag.production { background: color-mix(in srgb, var(--cobalt) 14%, transparent); color: var(--cobalt); font-weight: 600; }
.tag.staging { background: var(--wait-soft); color: var(--wait); font-weight: 600; }

/* lists */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-top: 1px solid var(--rule); font-size: 14px; min-width: 0; }
.rows li:first-child { border-top: 0; }
.rows .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--idle); transform: translateY(-1px); }
.dot.go { background: var(--go); } .dot.wait { background: var(--wait); } .dot.stop { background: var(--stop); }
.group-label { font-size: 12.5px; color: var(--ink-3); margin: 12px 0 2px; }
.group-label:first-child { margin-top: 0; }

.wip-branch { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.wip-meta { font-size: 13.5px; color: var(--ink-2); margin: 2px 0 10px; }

.meter { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; margin: 4px 0 10px; }
.meter b { display: block; height: 100%; background: var(--cobalt); border-radius: 3px; }
.meter b.hot { background: var(--wait); }
.stat-row { display: flex; justify-content: space-between; font-size: 13.5px; }

.empty { color: var(--ink-2); font-size: 14px; padding: 6px 0 4px; }

/* drawer for logs */
dialog {
  border: 0; padding: 0; border-radius: 14px; width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--panel); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0,0,0,.5);
}
dialog::backdrop { background: rgba(18, 24, 31, .45); }
.dlg-head { display: flex; gap: 12px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--rule); }
.dlg-head h3 { margin: 0; font-size: 17px; }
.dlg-head .spacer { flex: 1; }
.dlg-body { padding: 16px 20px 20px; display: grid; gap: 12px; }
pre.log {
  margin: 0; background: #0f151b; color: #cfd8e1; font: 12.5px/1.55 var(--mono); padding: 14px 16px;
  border-radius: 10px; max-height: 60vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 14px; font-weight: 500; }
.form input, .form select {
  border: 1px solid var(--rule); border-radius: 8px; padding: 9px 11px; background: var(--panel); font-weight: 400;
}
.form .err { color: var(--stop); font-size: 14px; min-height: 1.2em; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--panel);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); z-index: 10;
}

@media (max-width: 920px) {
  .split { grid-template-columns: 1fr; }
  .envs { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .top { padding: 12px 16px; flex-wrap: wrap; }
  main { padding: 18px 16px 48px; }
  .board .hide-sm { display: none; }
  .board .msg { max-width: 160px; }
  .env-head { flex-wrap: wrap; }
  .env-head .actions { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .lamp.pulse, .station.now i { animation: none; } }

/* ---------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login {
  width: min(400px, 100%); background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); padding: 30px 28px 26px;
}
.login .brand { margin-bottom: 20px; }
.login h1 { font-size: 24px; letter-spacing: -.02em; margin: 0 0 4px; }
.login p { margin: 0 0 20px; color: var(--ink-2); font-size: 14.5px; }
.login .btn.primary { width: 100%; padding: 11px; font-size: 15px; }
.signal-strip { display: flex; gap: 6px; margin-top: 22px; }
.signal-strip i { flex: 1; height: 4px; border-radius: 2px; background: var(--rule); }
.signal-strip i:nth-child(1) { background: var(--go); }
.signal-strip i:nth-child(2) { background: var(--wait); }
.signal-strip i:nth-child(3) { background: var(--cobalt); }
