:root {
  --bg: #0e1014; --panel: #15181e; --panel2: #1b1f27; --line: #262b35; --ink: #e6e8ee; --mute: #8b92a3; --dim: #5b6272;
  --acc: #7c8cff; --ok: #3fd19a; --err: #ff6b7a; --warn: #f5b84b; --info: #5cc8ff; --run: #7c8cff;
  --r: 12px; --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: var(--acc); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--mute); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; background: linear-gradient(180deg, #12141a, var(--bg)); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 8px 18px; }
.brand img { width: 26px; height: 26px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--mute); padding: 8px 10px; border-radius: 8px; }
.nav a:hover { background: var(--panel2); color: var(--ink); }
.nav a.on { background: var(--panel2); color: var(--ink); box-shadow: inset 2px 0 0 var(--acc); }
.side .foot { margin-top: auto; color: var(--dim); font-size: 12px; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; }
main { padding: 26px 32px 60px; max-width: 1400px; width: 100%; }
.head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.head .sp { flex: 1; }
.sub { color: var(--mute); font-size: 13px; }

/* Bausteine */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.btn { border: 1px solid var(--line); background: var(--panel2); padding: 7px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; }
.btn:hover { border-color: var(--dim); }
.btn.pri { background: var(--acc); border-color: var(--acc); color: #0b0d12; font-weight: 600; }
.btn.pri:hover { filter: brightness(1.1); }
.btn.ghost { background: none; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.danger:hover { border-color: var(--err); color: var(--err); }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 25%, transparent); }
label { display: block; font-size: 12px; color: var(--mute); margin: 12px 0 5px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel2); }
.empty { color: var(--dim); text-align: center; padding: 40px 10px; }

/* Status */
.st { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; padding: 3px 10px 3px 8px; border-radius: 99px; background: var(--panel2); white-space: nowrap; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--dim)); }
.st.success { --c: var(--ok); color: var(--ok); }
.st.failed { --c: var(--err); color: var(--err); }
.st.running, .st.starting { --c: var(--run); color: var(--run); }
.st.running::before, .st.starting::before { animation: pulse 1.2s infinite; }
.st.queued, .st.pending { --c: var(--mute); color: var(--mute); }
.st.skipped, .st.cancelled { --c: var(--dim); color: var(--dim); }
.st.allowed_failure { --c: var(--warn); color: var(--warn); }
.st.waiting { --c: var(--warn); color: var(--warn); }
.node.waiting .bar { background: var(--warn); }
.wssel { margin: -8px 8px 12px; padding: 6px 8px; background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; }
.wsjobs { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0; }
.wj { color: var(--ink); text-decoration: none; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.wj i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.card.cur { border-color: var(--acc); }
.card.approval { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border-color: var(--warn); margin: 12px 0 16px; }
@keyframes pulse { 50% { opacity: .25; } }

/* Pipeline-Karten */
.pipe { display: flex; flex-direction: column; gap: 12px; cursor: pointer; transition: border-color .15s, transform .15s; }
.pipe:hover { border-color: var(--dim); transform: translateY(-1px); }
.pipe .top { display: flex; align-items: center; gap: 10px; }
.pipe .name { font-weight: 650; font-size: 16px; flex: 1; }
.pipe .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.mon { white-space: nowrap; flex: none; color: var(--dim); font-size: 12px; padding: 2px 8px; }
.btn.mon:not(.on) { filter: grayscale(1); opacity: .45; }
.btn.mon.on { color: var(--info); border-color: color-mix(in srgb, var(--info) 50%, transparent); }
.spark { display: flex; gap: 3px; height: 26px; align-items: flex-end; }
.spark i { flex: 1; max-width: 14px; border-radius: 3px; background: var(--c); opacity: .85; }
.meta { display: flex; gap: 14px; color: var(--mute); font-size: 12.5px; flex-wrap: wrap; }

/* Run-Ansicht */
.runhead { border-radius: var(--r); padding: 20px 22px; margin-bottom: 18px; background: linear-gradient(120deg, color-mix(in srgb, var(--acc) 22%, var(--panel)), var(--panel) 60%); border: 1px solid var(--line); }
.runhead .row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.graph { display: flex; gap: 28px; overflow-x: auto; padding: 6px 2px 14px; }
.col { display: flex; flex-direction: column; gap: 10px; min-width: 170px; }
.node { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; position: relative; }
.node.sel { border-color: var(--acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 20%, transparent); }
.node .n { font-weight: 600; display: flex; justify-content: space-between; gap: 4px 8px; flex-wrap: wrap; }
.node .img { color: var(--dim); font-family: var(--mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .bar { position: absolute; left: 0; bottom: 0; height: 3px; border-radius: 0 0 10px 10px; background: var(--c, transparent); width: 100%; }
.node.success { --c: var(--ok); } .node.failed { --c: var(--err); } .node.running { --c: var(--run); }
.node.allowed_failure { --c: var(--warn); } .node.skipped { opacity: .55; }
.split { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.log { background: #0a0c10; border: 1px solid var(--line); border-radius: var(--r); font-family: var(--mono); font-size: 12.5px; line-height: 1.55; max-height: 62vh; overflow: auto; padding: 10px 0; }
.log .l { display: grid; grid-template-columns: 52px 84px 1fr; padding: 0 14px; white-space: pre-wrap; word-break: break-word; }
.log .l:hover { background: #12151b; }
.log .ln { color: var(--dim); user-select: none; text-align: right; padding-right: 12px; }
.log .sn { color: var(--dim); overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.log .cmd { color: var(--info); }
.log .bad { color: var(--err); }
.log .ev { color: var(--mute); font-style: italic; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs button { background: none; border: 1px solid var(--line); border-radius: 99px; padding: 3px 12px; cursor: pointer; color: var(--mute); font-size: 12.5px; }
.tabs button.on { color: var(--ink); border-color: var(--acc); }

/* Widgets */
.widgets { display: flex; flex-direction: column; gap: 12px; }
.w { --c: var(--info); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; border-left: 3px solid var(--c); }
.w.ok { --c: var(--ok); } .w.err { --c: var(--err); } .w.warn { --c: var(--warn); }
.w .lb { color: var(--mute); font-size: 12px; display: flex; justify-content: space-between; }
.w .val { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.w .val small { font-size: 13px; color: var(--mute); font-weight: 500; }
.w .pb { height: 6px; background: var(--panel2); border-radius: 9px; margin-top: 8px; overflow: hidden; }
.w .pb i { display: block; height: 100%; background: var(--c); border-radius: 9px; }
.w table td, .w table th { padding: 5px 4px; font-size: 12.5px; }
.w .md p { margin: 4px 0; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(800px 400px at 30% 20%, #1d2240, transparent), radial-gradient(600px 400px at 80% 90%, #0f2a22, transparent), var(--bg); }
.login form { width: 340px; }
.login .brand { justify-content: center; font-size: 22px; padding-bottom: 6px; }
.login .err { color: var(--err); font-size: 13px; min-height: 20px; margin-top: 10px; }

/* Drawer & Toast */
.scrim { position: fixed; inset: 0; background: #0008; display: flex; justify-content: flex-end; z-index: 10; }
.drawer { width: min(460px, 100%); height: 100%; background: var(--panel); border-left: 1px solid var(--line); padding: 24px; overflow: auto; }
.drawer .acts { display: flex; gap: 10px; margin-top: 22px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 20; }
pre.code { background: #0a0c10; border: 1px solid var(--line); border-radius: 10px; padding: 14px; overflow: auto; font-family: var(--mono); font-size: 12.5px; margin: 0; }
.secret { background: #0a0c10; border: 1px dashed var(--warn); padding: 10px; border-radius: 8px; word-break: break-all; font-family: var(--mono); }
.sx-k { color: #c792ea; } .sx-s { color: #c3e88d; } .sx-c { color: var(--dim); } .sx-f { color: #82aaff; }

.grid.two { grid-template-columns: 1fr 1fr; }
.grid > *, .split > *, main { min-width: 0; }   /* breite Kinder (Graph, Log, Code) scrollen selbst statt die Seite */
.nav .s { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side { flex-direction: row; overflow-x: auto; padding: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 4px 8px; } .side .foot { display: none; }
  main { padding: 18px 14px 40px; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .grid.two { grid-template-columns: minmax(0, 1fr); }
}

/* Handy (z. B. Nothing Phone 1, 412 px): Kopfzeile oben, Navigation als Tableiste unten */
@media (max-width: 700px) {
  body { font-size: 15px; }
  .side { position: sticky; top: 0; z-index: 5; flex-direction: row; align-items: center; justify-content: space-between; overflow: visible;
          padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--bg); }   /* kein backdrop-filter: würde die fixe Tableiste in die Kopfzeile sperren */
  .brand { padding: 0; font-size: 16px; }
  .side .foot { display: flex; margin: 0; padding: 0; gap: 10px; }
  .side .foot > span { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: color-mix(in srgb, var(--panel) 94%, transparent);
         backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 4px 2px max(4px, env(safe-area-inset-bottom)); }
  .nav a { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; padding: 7px 2px 5px; font-size: 10.5px; text-align: center; }
  .nav a svg { width: 20px; height: 20px; }
  .nav a.on { box-shadow: inset 0 2px 0 var(--acc); background: none; color: var(--acc); }
  .nav .l { display: none; } .nav .s { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  main { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
  .toast { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); text-align: center; }
  h1 { font-size: 20px; }
  .head { gap: 10px; margin-bottom: 16px; }
  .card { padding: 14px; overflow-x: auto; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .btn { padding: 9px 14px; }            /* Fingerziel ≥ 40 px */
  .btn.sm { padding: 7px 11px; }
  .btn.mon { padding: 5px 9px; }
  input, select, textarea { font-size: 16px; }   /* sonst zoomt der Browser beim Fokus */
  td, th { padding: 9px 6px; }
  table.runs tr > :nth-child(3), table.runs tr > :nth-child(4), table.runs tr > :nth-child(5) { display: none; }   /* #, Quelle, Commit */
  .runhead { padding: 14px; }
  .runhead .row { gap: 8px; }
  .runhead .meta { gap: 6px 12px; }
  .graph { gap: 14px; margin: 0 -14px; padding: 6px 14px 12px; scroll-snap-type: x proximity; }
  .col { min-width: 168px; scroll-snap-align: start; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .tabs button { flex: none; padding: 6px 13px; }
  .log { font-size: 11.5px; max-height: 70vh; }
  .log .l { grid-template-columns: 30px 62px 1fr; padding: 0 8px; }
  .log .ln { padding-right: 6px; }
  .login form { width: min(340px, 100% - 32px); }
  .drawer { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  pre.code { font-size: 11.5px; }
}

/* Deployments */
.stack { display: grid; gap: 16px; }
.card.deploy.stale { opacity: .8; }
.tw { overflow-x: auto; margin-top: 10px; }
table.djobs td, table.arts td { vertical-align: top; }
table.djobs tr.other { opacity: .55; }
.ac { font-size: 12px; font-weight: 600; white-space: nowrap; }
.ac.ok { color: var(--ok); } .ac.run { color: var(--run); } .ac.err { color: var(--err); } .ac.mute { color: var(--mute); }
.warn { color: var(--warn); font-size: 12px; }
@media (max-width: 700px) {
  table.djobs tr > :nth-child(4), table.djobs tr > :nth-child(5) { display: none; }   /* Allocations, Image */
  table.arts tr > :nth-child(2), table.arts tr > :nth-child(4) { display: none; }
}
.card.deploy > .row { display: flex; align-items: center; }
.card.deploy .sp { flex: 1; }
.card.deploy .err { color: var(--err); font-size: 13px; }

/* Pipelines: Filter, Gruppen, Tags */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin: -6px 0 18px; }
.filters input[type=search] { width: 200px; max-width: 100%; padding: 6px 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 6px 12px; cursor: pointer; color: var(--mute); font: inherit; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--panel2); color: inherit; font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag { border: 1px solid var(--line); background: none; color: var(--info); border-radius: 99px; padding: 1px 9px; font: inherit; font-size: 12px; cursor: pointer; }
.tag.on { background: color-mix(in srgb, var(--info) 18%, transparent); border-color: var(--info); }
.tag.clr { color: var(--mute); }
.fold { font-size: 12px; color: var(--mute); margin-right: 4px; }
details.grp { margin: 0 0 14px calc(var(--d, 0) * 14px); }
details.grp > summary { list-style: none; cursor: pointer; display: flex; gap: 10px; align-items: center; padding: 6px 2px 10px; user-select: none; }
details.grp > summary::-webkit-details-marker { display: none; }
details.grp > summary::before { content: "▸"; color: var(--dim); transition: transform .15s; }
details.grp[open] > summary::before { transform: rotate(90deg); }
details.grp .gt { font-weight: 650; }
details.grp .dot { font-size: 11.5px; color: var(--c); display: inline-flex; align-items: center; gap: 4px; }
details.grp .dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
details.grp > .grid { margin-bottom: 6px; }
@media (max-width: 600px) { details.grp { margin-left: calc(var(--d, 0) * 8px); } .filters input[type=search] { width: 100%; } }
@media (max-width: 900px) { .wssel { margin: 0 6px; max-width: 150px; } }

/* Rollen: Server prüft, die UI blendet nur aus */
body[data-role="viewer"] [data-act]:not([data-act="logout"]):not([data-act="mypw"]):not([data-act="pickws"]):not([data-act="groupby"]):not([data-act="tagfilter"]) { display: none !important; }
body:not([data-role="admin"]) :is([data-act="newtoken"], [data-act="deltoken"], [data-act="monkey"], [data-act="delmonkey"], [data-act="newsecret"], [data-act="editsecret"], [data-act="delsecret"], [data-act="newws"], [data-act="editws"], [data-act="delws"]) { display: none !important; }
.rolesel { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); color: var(--mute); }
.pill.src-env { color: #f2b45a; } .pill.src-file { color: #7c8cff; }
