:root {
  --bg: #07090e;
  --bg-2: #0b0f17;
  --panel: rgba(17, 22, 32, .78);
  --panel-solid: #111620;
  --panel-2: #171d2a;
  --border: #1f2735;
  --border-hi: #2c3850;
  --text: #d5dde8;
  --muted: #6b778a;
  --green: #4ade80;
  --green-d: #16a34a;
  --cyan: #22d3ee;
  --blue: #60a5fa;
  --magenta: #e879f9;
  --red: #fb7185;
  --yellow: #fbbf24;
  --term-bg: #05070b;
  --glow: 0 0 24px rgba(74, 222, 128, .18);
  /* ANSI palette */
  --a0: #4b5563; --a1: #fb7185; --a2: #4ade80; --a3: #fbbf24;
  --a4: #60a5fa; --a5: #e879f9; --a6: #22d3ee; --a7: #cbd5e1;
  --a8: #6b7280; --a9: #fda4af; --a10: #86efac; --a11: #fde68a;
  --a12: #93c5fd; --a13: #f0abfc; --a14: #67e8f9; --a15: #f8fafc;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; color: var(--text); }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(74, 222, 128, .09), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 211, 238, .07), transparent 60%),
    radial-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--bg);
  background-attachment: fixed;
}
body, input, textarea, button, select { font: 14px/1.5 "JetBrains Mono", ui-monospace, monospace; }
::selection { background: rgba(74, 222, 128, .3); }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; color: var(--cyan); }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.3px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--red); }
.grow { flex: 1; }
.prompt { color: var(--green); font-weight: 700; text-shadow: 0 0 10px rgba(74, 222, 128, .5); }
.cursor { display: inline-block; width: .6em; height: 1.1em; background: var(--green); vertical-align: text-bottom; margin-left: 2px; animation: blink 1.1s steps(1) infinite; box-shadow: 0 0 10px rgba(74, 222, 128, .6); }
@keyframes blink { 50% { opacity: 0; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #232b3b; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------ header */
header.top {
  display: flex; align-items: center; gap: 22px; padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 9, 14, .75); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 5;
}
.brand { color: var(--text); font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand .logo {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, rgba(74, 222, 128, .2), rgba(34, 211, 238, .15));
  border: 1px solid rgba(74, 222, 128, .4); color: var(--green); font-size: 13px; box-shadow: var(--glow);
}
#nav { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; }
#nav .sep { color: #3a4458; }
#nav a { color: var(--muted); }
#nav a:hover { color: var(--text); text-decoration: none; }
#nav .crumb { color: var(--green); overflow: hidden; text-overflow: ellipsis; }
#nav #logout { margin-left: auto; }

main { padding: 26px 28px 60px; max-width: 1440px; margin: 0 auto; }

/* ------------------------------------------------------------ primitives */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  backdrop-filter: blur(6px);
}
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.eyebrow { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 4px; }
.cmdline {
  margin-top: 10px; font-size: 13px; display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--term-bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px;
}
.chip { color: var(--muted); font-size: 12px; border-left: 1px solid var(--border); padding-left: 8px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

input, textarea, select {
  background: var(--term-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; outline: none; width: 100%; transition: border-color .15s, box-shadow .15s;
}
.toolbar input { width: auto; }
.toolbar input.grow { min-width: 180px; }
input:focus, textarea:focus { border-color: rgba(74, 222, 128, .6); box-shadow: 0 0 0 3px rgba(74, 222, 128, .12); }
input[type=checkbox] { width: auto; accent-color: var(--green); }
input[type=file] { padding: 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border-hi); border-radius: 8px; padding: 7px 14px; cursor: pointer; white-space: nowrap;
  transition: transform .1s, border-color .15s, background .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { border-color: #45536e; text-decoration: none; background: #1c2333; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.primary {
  background: linear-gradient(180deg, #22c55e, #15803d); border-color: #22c55e; color: #03140a; font-weight: 700;
  box-shadow: 0 0 0 1px rgba(74, 222, 128, .2), 0 6px 20px -6px rgba(74, 222, 128, .55);
}
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #4ade80, #16a34a); border-color: #4ade80; }
.btn.danger { color: var(--red); }
.btn.danger:hover:not(:disabled) { border-color: var(--red); background: rgba(251, 113, 133, .08); }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; }
button.link:hover { color: var(--red); }
button.icon {
  background: none; border: 1px solid transparent; color: var(--muted); cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px; display: inline-grid; place-items: center;
}
button.icon:hover { color: var(--green); border-color: var(--border-hi); background: var(--panel-2); }
button.icon.danger:hover { color: var(--red); }

/* status badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px;
  font-size: 12px; border: 1px solid; white-space: nowrap; vertical-align: middle; font-weight: 500;
}
.badge i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.s-success { color: var(--green); border-color: rgba(74, 222, 128, .35); background: rgba(74, 222, 128, .08); }
.s-failed, .s-error, .s-timeout { color: var(--red); border-color: rgba(251, 113, 133, .35); background: rgba(251, 113, 133, .08); }
.s-running { color: var(--cyan); border-color: rgba(34, 211, 238, .4); background: rgba(34, 211, 238, .08); }
.s-running i { animation: ping 1s ease-in-out infinite; }
.s-queued { color: var(--yellow); border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .06); }
.s-cancelled, .s-none { color: var(--muted); border-color: var(--border-hi); }
.s-none i { box-shadow: none; opacity: .5; }
@keyframes ping { 50% { transform: scale(1.6); opacity: .4; } }

/* score */
.score { font-weight: 700; color: var(--yellow); }
.scorecell { display: flex; align-items: center; gap: 10px; min-width: 130px; }
.meter { flex: 1; height: 6px; border-radius: 6px; background: #1a2130; overflow: hidden; min-width: 50px; }
.meter b { display: block; height: 100%; border-radius: 6px; background: currentColor; box-shadow: 0 0 10px currentColor; }
.lvl-hi { color: var(--green); } .lvl-mid { color: var(--yellow); } .lvl-lo { color: var(--red); }

/* avatar */
.who { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none;
  font-size: 11px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 70% 45%), hsl(calc(var(--h) + 40) 70% 35%));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}

/* stacked progress */
.stack { display: flex; height: 8px; border-radius: 8px; overflow: hidden; background: #161c28; }
.stack span { transition: width .4s; }
.stack .ok { background: var(--green); box-shadow: 0 0 12px rgba(74, 222, 128, .5); }
.stack .ko { background: var(--red); }
.stack .run { background: var(--cyan); }

/* ------------------------------------------------------------ login */
.login { max-width: 560px; margin: 9vh auto 0; display: flex; flex-direction: column; gap: 18px; padding: 28px; box-shadow: var(--glow); }
.ascii {
  margin: 0; font-size: 11px; line-height: 1.15; color: var(--green); white-space: pre; overflow: hidden;
  text-shadow: 0 0 14px rgba(74, 222, 128, .45);
  background: linear-gradient(180deg, var(--green), var(--cyan)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.login label { display: flex; flex-direction: column; gap: 8px; color: var(--muted); }
.term-line { color: var(--muted); }

/* ------------------------------------------------------------ jobs */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card.job {
  color: var(--text); display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.card.job::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--green), var(--cyan), transparent); opacity: .6;
}
.card.job:hover { border-color: rgba(74, 222, 128, .45); text-decoration: none; transform: translateY(-2px); box-shadow: var(--glow); }
.job-name { font-weight: 700; font-size: 16px; }
.job-name::before { content: "❯ "; color: var(--green); }
.job-meta { display: flex; gap: 12px; align-items: center; font-size: 12px; color: var(--muted); }
.job-meta .ok { color: var(--green); } .job-meta .ko { color: var(--red); }
.new-job { width: min(460px, 100%); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }

/* ------------------------------------------------------------ job */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px; }
.stat { padding: 14px 16px; }
.stat .v { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px; margin-top: 4px; }
.stat.ok .v { color: var(--green); text-shadow: 0 0 18px rgba(74, 222, 128, .35); }
.stat.ko .v { color: var(--red); }
.stat.run .v { color: var(--cyan); }
.stat.avg .v { color: var(--yellow); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0 14px; overflow-x: auto; }
.tabs a { padding: 9px 16px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs a.on { color: var(--text); border-bottom-color: var(--green); text-shadow: 0 0 12px rgba(74, 222, 128, .3); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs .n { font-size: 11px; background: var(--panel-2); border-radius: 999px; padding: 1px 7px; margin-left: 4px; color: var(--muted); }

.tablewrap { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--panel); }
table.repos { width: 100%; border-collapse: collapse; }
table.repos th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  padding: 10px 12px; border-bottom: 1px solid var(--border); background: rgba(23, 29, 42, .7);
}
table.repos td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.repos tr:last-child td { border-bottom: 0; }
table.repos tbody tr { transition: background .12s; }
table.repos tr.clickable { cursor: pointer; }
table.repos tr.clickable:hover td { background: rgba(74, 222, 128, .04); }
table.repos tr.clickable:hover td:first-child { box-shadow: inset 2px 0 0 var(--green); }
td.name { font-weight: 500; }
td.actions { text-align: right; white-space: nowrap; }
.repo-url { font-size: 12px; color: var(--muted); }
.sha { font-size: 12px; color: var(--magenta); opacity: .85; }
.add { margin-top: 16px; }
.add summary { cursor: pointer; color: var(--green); list-style: none; }
.add summary::-webkit-details-marker { display: none; }
.add[open] summary { margin-bottom: 10px; }
.add form { display: flex; flex-direction: column; gap: 10px; }

/* files */
.files { display: grid; grid-template-columns: 290px 1fr; gap: 14px; }
.files aside { display: flex; flex-direction: column; gap: 12px; align-self: start; }
.files ul { list-style: none; margin: 0; padding: 0; }
.files li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 6px; }
.files li:hover { background: var(--panel-2); }
.files li a { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.files li a::before { content: "▸ "; color: var(--muted); }
.files li a.on { color: var(--green); font-weight: 700; }
.files li a.on::before { color: var(--green); }
.upload { justify-content: center; }
.editor { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.editor .toolbar { margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--border); background: rgba(23, 29, 42, .6); }
.editor textarea {
  flex: 1; min-height: 64vh; resize: vertical; tab-size: 4; white-space: pre; background: var(--term-bg);
  font-size: 13px; border: 0; border-radius: 0; padding: 14px 16px; box-shadow: none;
}

.settings { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.settings label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); }

/* ------------------------------------------------------------ build */
.banner {
  display: flex; gap: 14px; align-items: center; padding: 16px 18px; margin-bottom: 14px;
  border-left: 3px solid var(--muted);
}
.banner.st-success { border-left-color: var(--green); background: linear-gradient(90deg, rgba(74, 222, 128, .1), var(--panel) 45%); }
.banner.st-failed, .banner.st-error, .banner.st-timeout { border-left-color: var(--red); background: linear-gradient(90deg, rgba(251, 113, 133, .1), var(--panel) 45%); }
.banner.st-running, .banner.st-queued { border-left-color: var(--cyan); background: linear-gradient(90deg, rgba(34, 211, 238, .1), var(--panel) 45%); }
.banner h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ring {
  --p: 0; width: 64px; height: 64px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(currentColor calc(var(--p) * 1%), #1a2130 0);
  box-shadow: 0 0 22px -6px currentColor;
}
.ring span { width: 52px; height: 52px; border-radius: 50%; background: var(--panel-solid); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--text); }
.ring.none { color: #2a3345; box-shadow: none; }

.build { display: grid; grid-template-columns: 1fr 260px; gap: 14px; }
.terminal {
  border: 1px solid var(--border-hi); border-radius: 12px; overflow: hidden; background: var(--term-bg); min-width: 0;
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, .8), 0 0 0 1px rgba(74, 222, 128, .05), 0 0 40px -10px rgba(74, 222, 128, .12);
}
.term-bar {
  display: flex; align-items: center; gap: 7px; padding: 9px 14px; background: linear-gradient(180deg, #161c28, #11161f);
  border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px;
}
.term-bar i { width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; }
.term-bar i:nth-child(2) { background: #febc2e; }
.term-bar i:nth-child(3) { background: #28c840; margin-right: 10px; }
.term-bar span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.term-bar label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
pre.term {
  margin: 0; padding: 16px 18px; height: calc(100vh - 290px); min-height: 360px; overflow: auto;
  white-space: pre-wrap; word-break: break-all; font-size: 13px; line-height: 1.5; color: var(--a7);
  background:
    linear-gradient(rgba(255, 255, 255, .012) 50%, transparent 50%) 0 0 / 100% 4px,
    var(--term-bg);
}
.history { align-self: start; padding: 14px 10px 10px 14px; }
.history .eyebrow { margin: 0 0 8px 4px; }
.history ul { list-style: none; margin: 0; padding: 0 4px 0 0; max-height: calc(100vh - 320px); overflow: auto; }
.history li { position: relative; padding: 8px 8px 8px 22px; border-radius: 8px; }
.history li::before { content: ""; position: absolute; left: 8px; top: 0; bottom: 0; width: 1px; background: var(--border-hi); }
.history li::after {
  content: ""; position: absolute; left: 4px; top: 15px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 3px var(--panel-solid);
}
.history li.h-success::after { background: var(--green); }
.history li.h-failed::after, .history li.h-error::after, .history li.h-timeout::after { background: var(--red); }
.history li.h-running::after, .history li.h-queued::after { background: var(--cyan); }
.history li.on { background: var(--panel-2); }
.history li a { color: var(--text); font-weight: 700; }
.history li a:hover { color: var(--green); text-decoration: none; }
.kbd { border: 1px solid var(--border-hi); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 11px; color: var(--muted); }

/* ------------------------------------------------------------ ANSI */
.f0 { color: var(--a0); } .f1 { color: var(--a1); } .f2 { color: var(--a2); } .f3 { color: var(--a3); }
.f4 { color: var(--a4); } .f5 { color: var(--a5); } .f6 { color: var(--a6); } .f7 { color: var(--a7); }
.f8 { color: var(--a8); } .f9 { color: var(--a9); } .f10 { color: var(--a10); } .f11 { color: var(--a11); }
.f12 { color: var(--a12); } .f13 { color: var(--a13); } .f14 { color: var(--a14); } .f15 { color: var(--a15); }
.b0 { background: var(--a0); } .b1 { background: var(--a1); } .b2 { background: var(--a2); } .b3 { background: var(--a3); }
.b4 { background: var(--a4); } .b5 { background: var(--a5); } .b6 { background: var(--a6); } .b7 { background: var(--a7); }
.b8 { background: var(--a8); } .b9 { background: var(--a9); } .b10 { background: var(--a10); } .b11 { background: var(--a11); }
.b12 { background: var(--a12); } .b13 { background: var(--a13); } .b14 { background: var(--a14); } .b15 { background: var(--a15); }
.ffg { color: var(--a7); } .fbg { color: var(--term-bg); } .bfg { background: var(--a7); } .bbg { background: var(--term-bg); }
.ab { font-weight: 700; } .ad { opacity: .55; } .ai { font-style: italic; } .au { text-decoration: underline; }
.term .f2.ab, .term .f10 { text-shadow: 0 0 8px rgba(74, 222, 128, .35); }
.term .f1.ab, .term .f9 { text-shadow: 0 0 8px rgba(251, 113, 133, .3); }

/* ------------------------------------------------------------ toast */
#toast {
  position: fixed; bottom: 22px; right: 22px; background: var(--panel-solid); border: 1px solid var(--border-hi);
  padding: 11px 18px; border-radius: 10px; opacity: 0; transform: translateY(10px); transition: .2s;
  pointer-events: none; z-index: 10; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
#toast::before { content: "› "; color: var(--muted); }
#toast.show { opacity: 1; transform: none; }
#toast.ok { border-color: rgba(74, 222, 128, .6); }
#toast.ok::before { content: "✔ "; color: var(--green); }
#toast.ko { border-color: rgba(251, 113, 133, .6); color: var(--red); }
#toast.ko::before { content: "✘ "; }

@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .build { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  main { padding: 18px 16px 40px; }
  header.top { padding: 10px 16px; gap: 12px; }
  .files { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .tablewrap { overflow-x: auto; }
  table.repos { min-width: 760px; }
  .banner { flex-wrap: wrap; }
  .ascii { font-size: 7px; }
  pre.term { height: 65vh; }
}
