/* RunDesk – Stylesheet (Grundlage aus MailDesk). */
:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #eef2f1; --text: #17201e; --muted: #5b6764; --line: #d7dfdc;
  --brand: #3b4fa8; --brand-2: #2f3f8a; --brand-soft: #e5e9fa; --focus: #2563eb;
  --ok: #157a3d; --ok-soft: #e3f4ea; --warn: #9a6200; --warn-soft: #fff4dc; --err: #b42318; --err-soft: #fdecea; --info-soft: #e8f0fe;
  --radius: 10px; --row: 32px; --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101514; --surface: #182120; --surface-2: #1f2a28; --text: #e7eeec; --muted: #9db0ab; --line: #2f3d3a;
    --brand: #8da0f0; --brand-2: #a9b8f5; --brand-soft: #1e2645; --focus: #7aa7ff;
    --ok: #4cc27a; --ok-soft: #173426; --warn: #e3a93b; --warn-soft: #3a2e14; --err: #ff7b6b; --err-soft: #3d1d19; --info-soft: #1b2840;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 var(--font); background: var(--bg); color: var(--text); }
a { color: var(--brand); }
h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.boot { padding: 2rem; color: var(--muted); }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5rem; z-index: 99; }
.skip:focus { left: .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

/* ---------- Kopf und Navigation ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; padding-top: max(.5rem, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand-ver { font-weight: 500; font-size: .72rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: .05rem .45rem; font-variant-numeric: tabular-nums; }
.nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.nav a { display: flex; align-items: center; gap: .35rem; padding: .45rem .7rem; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-short { display: none; }
.user { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.user-name { color: var(--muted); max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .top { padding-left: .75rem; padding-right: .75rem; }
  .user-name { display: none; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line);
    justify-content: space-around; padding: .25rem .25rem max(.25rem, env(safe-area-inset-bottom)); gap: 0; }
  .nav a { flex-direction: column; gap: 0; font-size: .7rem; padding: .3rem .4rem; min-width: 56px; }
  .nav-ic { font-size: 1.2rem; }
  .nav-long { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .nav-short { display: block; white-space: nowrap; }
  .nav a { min-width: 0; flex: 1; }
  main { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
}

/* ---------- Seiten ---------- */
main { outline: none; }
.page { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page.narrow { max-width: 760px; }
.page.wide { max-width: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty.err h2 { color: var(--err); }
.banner { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid transparent; }
.banner.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.err { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.banner.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.banner.info { background: var(--info-soft); }

/* ---------- Schaltflächen und Eingaben ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 40px; padding: .45rem .9rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; touch-action: manipulation; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 32px; padding: .25rem .6rem; font-size: .9rem; }
.btn.icon { min-width: 40px; padding: .3rem; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.in { width: 100%; min-height: 40px; padding: .45rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
  font-size: 16px; /* verhindert Zoom auf dem iPhone */ }
.in:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.in[readonly], .in:disabled { background: var(--surface-2); }
.in.sm { min-height: 32px; padding: .2rem .4rem; font-size: 14px; width: auto; }
textarea.in { resize: vertical; min-height: 80px; }
select.in { appearance: auto; }
.in.num { text-align: right; font-variant-numeric: tabular-nums; }
.in.calc { display: flex; align-items: center; justify-content: flex-end; font-weight: 600; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.in-group { display: flex; align-items: stretch; }
.in-group > .in { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1; min-width: 0; }
.in-group > .btn, .in-group > .in-unit { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.in-unit { display: flex; align-items: center; padding: 0 .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--muted); }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; }
.field > .hint { font-size: .8rem; color: var(--muted); }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 180px; }
.check { display: flex; gap: .5rem; align-items: flex-start; cursor: pointer; padding: .3rem 0; }
.check input { width: 20px; height: 20px; margin: .1rem 0 0; flex: none; accent-color: var(--brand); }
.protect-opts { border: 1px solid var(--line, #ccc); border-radius: 8px; padding: .4rem .8rem .6rem; margin: .8rem 0 0; }
.protect-opts legend { padding: 0 .3rem; }
.choice { display: flex; flex-wrap: wrap; gap: .25rem 1rem; padding: .3rem 0; }
.choice-item { display: flex; gap: .4rem; align-items: center; cursor: pointer; min-height: 32px; }
.choice-item input { width: 18px; height: 18px; accent-color: var(--brand); }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.st-submitted { background: var(--info-soft); color: var(--focus); }
.st-approved { background: var(--ok-soft); color: var(--ok); }
.st-rejected { background: var(--err-soft); color: var(--err); }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .3rem .8rem; cursor: pointer; font: inherit; color: var(--text); min-height: 34px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Listen ---------- */
.list { display: flex; flex-direction: column; gap: .5rem; }
.item { display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; align-items: center; padding: .8rem 1rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.item:hover { border-color: var(--brand); }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { color: var(--muted); font-size: .85rem; }
.item-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; }
table.grid { width: 100%; border-collapse: collapse; background: var(--surface); }
table.grid th, table.grid td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: .9rem; }
table.grid th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; }
.scroll-x { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- Dialoge, Meldungen ---------- */
dialog.modal { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
dialog.modal.wide { width: min(1100px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgb(0 0 0 / .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 1rem; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem 1rem; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
.toasts { position: fixed; z-index: 1000; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; max-width: calc(100vw - 2rem); }
.toast { padding: .7rem 1rem; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); transition: opacity .3s, transform .3s; }
.toast-err { background: var(--err); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
@media (max-width: 760px) { .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); left: 1rem; } }

/* ---------- Allgemein ---------- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.muted td { color: var(--muted); }
.nowrap { white-space: nowrap; }
.section-h { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
.small-h { font-size: .95rem; margin: .75rem 0 .35rem; }
.st-ok { background: var(--ok-soft); color: var(--ok); }
.st-failed, .st-error { background: var(--err-soft); color: var(--err); }
.st-running, .st-queued { background: var(--info-soft); color: var(--focus); }
.st-waiting, .st-paused { background: var(--warn-soft); color: var(--warn); }
.st-skipped, .st-canceled { background: var(--surface-2); color: var(--muted); }

/* ---------- Ziele (Etappe 2) ---------- */
.shot { display: block; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; margin-top: .75rem; background: #fff; }
.probe .msg-head { margin: .75rem 0; }
.msg-head { border-collapse: collapse; font-size: .9rem; }
.msg-head th { text-align: left; color: var(--muted); font-weight: 500; padding: .15rem 1rem .15rem 0; vertical-align: top; white-space: nowrap; }
.msg-head td { padding: .15rem 0; overflow-wrap: anywhere; }
.msg-nav { margin: 0 0 .5rem; }
ul.plain { list-style: none; padding: 0; margin: .25rem 0 .75rem; }
ul.plain li { display: flex; align-items: center; gap: .5rem; padding: .15rem 0; }

/* ---------- Runbooks und Läufe (Etappe 3) ---------- */
.item-link { color: var(--text); text-decoration: none; min-width: 0; }
.item-link:hover .item-title { color: var(--brand); }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .25rem; }
.search-bar { display: flex; gap: .5rem; margin-bottom: 1rem; max-width: 640px; }
.results-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.err-text { color: var(--err); }
.warn-text { color: var(--warn); }
.danger-text { color: var(--err) !important; }
table.grid tr.clickable { cursor: pointer; }
table.grid tr.clickable:hover td { background: var(--surface-2); }
ol.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
li.step { border-radius: 8px; }
li.step.dragging { opacity: .4; }
li.step.drop > .step-row { box-shadow: inset 0 3px 0 var(--brand); }
.step-row { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-height: 40px; }
.step-row:hover { border-color: var(--brand); }
.step-row.disabled { opacity: .5; }
.step-row.disabled .step-desc { text-decoration: line-through; }
.step-row.hl, .step-row.current { border-color: var(--brand); background: var(--brand-soft); }
.drag { cursor: grab; color: var(--muted); user-select: none; padding: 0 .1rem; }
.step-no { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .8rem; min-width: 2.2rem; text-align: right; }
.step-ic { width: 1.4rem; text-align: center; flex: none; }
.step-text { flex: 1 1 9rem; min-width: 9rem; display: flex; flex-direction: column; } /* schmale Spalten (Live-Browser): Aktionen rutschen in die nächste Zeile, Text bleibt sichtbar */
.step-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-comment { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.step-badges { display: flex; gap: .25rem; align-items: center; flex: none; }
.step-acts { display: flex; gap: 0; flex: none; margin-left: auto; }
.step-acts .btn.sm { min-height: 28px; padding: .1rem .35rem; }
.step-nested { margin: 2px 0 4px 2.6rem; padding-left: .6rem; border-left: 2px solid var(--line); }
.nested-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: .2rem 0; }
.step-tools { display: flex; gap: .25rem; padding: .2rem 0; }
.sels { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .4rem; }
.sel-row { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.sel-row .in.sm:nth-child(2) { flex: 1 1 14rem; }
.sel-row .num { width: 4.5rem; }
.check.sm { font-size: .85rem; padding: 0; align-items: center; }
.check.sm input { width: 16px; height: 16px; margin: 0; }
table.grid.vars td { vertical-align: middle; }
table.grid.vars .in.sm { width: 100%; }
ol.run-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .35rem; }
.run-step { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: .4rem .6rem; }
.run-step.st-row-failed { border-color: var(--err); }
.run-step-head { display: flex; align-items: center; gap: .5rem; }
.run-shot summary { cursor: pointer; padding: .2rem 0 0 3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-shot .shot { max-height: 60vh; cursor: zoom-in; margin-left: 3rem; max-width: calc(100% - 3rem); }
.shot.big { margin: 0; max-height: none; }
@media (max-width: 760px) {
  .step-acts { flex-wrap: wrap; }
  .step-nested { margin-left: 1rem; }
  .run-shot .shot, .run-shot summary { margin-left: 0; padding-left: 0; max-width: 100%; }
}

/* ---------- Anmeldung (Etappe 4) ---------- */
.banner.waiting { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* ---------- Live-Browser (Etappe 5) ---------- */
.live-page { max-width: 1700px; }
.live-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.live-layout > .live:only-child { grid-column: 1 / -1; }
.live { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.live-bar { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; }
.live-addr { flex: 1 1 18rem; width: auto; }
.live-status { margin-left: .5rem; }
.live-screen { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; aspect-ratio: 1366 / 900; outline: none; }
.live-screen:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 40%, transparent); }
.live-screen.ro { cursor: default; }
.live-img { display: block; width: 100%; height: 100%; object-fit: contain; cursor: default; user-select: none; }
.live-side { position: sticky; top: 4rem; max-height: calc(100dvh - 6rem); overflow: auto; display: flex; flex-direction: column; gap: .5rem; }
.live-side .run-shot { display: none; }
@media (max-width: 1100px) { .live-layout { grid-template-columns: 1fr; } .live-side { position: static; max-height: none; } }

/* ---------- Freigaben, Fassungen, Protokoll (Etappe 9) ---------- */
pre.diff { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 0; overflow-x: auto; }
pre.diff > div { padding: 0 .75rem; white-space: pre; }
pre.diff .add { background: var(--ok-soft); color: var(--ok); }
pre.diff .del { background: var(--err-soft); color: var(--err); }
.audit-filter { margin-bottom: .75rem; align-items: center; }
.audit-filter > * { flex: 0 1 auto; }
