:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f0f2f5; --ink: #16181d; --muted: #5d6470;
  --line: #e2e5ea; --brand: #0f5b52; --brand-soft: #e3f1ee;
  --ok: #1a7f4b; --ok-soft: #e4f4ea; --warn: #a15c00; --warn-soft: #fdf1df;
  --bad: #b42318; --bad-soft: #fde8e6; --busy: #2557d6; --busy-soft: #e6edfd;
  --radius: 14px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --ink: #e8eaee; --muted: #9aa3b0;
    --line: #2a2f38; --brand: #4fc2ae; --brand-soft: #143430;
    --ok: #4cc38a; --ok-soft: #12301f; --warn: #f0a742; --warn-soft: #362611;
    --bad: #f97066; --bad-soft: #3a1714; --busy: #7aa2ff; --busy-soft: #18233f;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.55 "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }
a { color: var(--busy); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 16px 40px; }
header.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
header.top h1 { font-size: 20px; margin: 0; font-weight: 700; }
header.top .sub { color: var(--muted); font-size: 13px; }
header.top .spacer { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); display: inline-block; }
.dot.stale { background: var(--warn); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
button.link { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px;
  padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; }
button.link:hover { color: var(--ink); border-color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .6s ease; }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }

h2 { font-size: 15px; margin: 26px 0 10px; color: var(--muted); font-weight: 600; display: flex; gap: 8px; align-items: center; }
h2 .count { background: var(--surface-2); color: var(--ink); border-radius: 99px; padding: 0 9px; font-size: 12.5px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.card.busy { border-color: color-mix(in srgb, var(--busy) 45%, var(--line)); }
.card .head { display: flex; align-items: center; gap: 8px; }
.card .name { font-weight: 700; font-size: 15.5px; }
.card .repo { color: var(--muted); font-size: 12.5px; }
.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 1px 10px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip.busy { background: var(--busy-soft); color: var(--busy); }
.chip.idle { background: var(--surface-2); color: var(--muted); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.card .push { margin-inline-start: auto; }
.job { margin-top: 10px; font-size: 14px; }
.job b { font-weight: 700; }
.meta { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 12px; overflow-wrap: anywhere; }
.progress { margin-top: 12px; }
.progress .bar { height: 8px; }
.progress .bar > i { background: var(--busy); }
.progress .bar.over > i { background: var(--warn); }
.progress .row { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.card .open { display: inline-block; margin-top: 10px; font-size: 13px; }

.idle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.idle-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.idle-card .name { font-weight: 600; }
.idle-card .meta { margin-top: 2px; }

.table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { text-align: start; padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table .scroll { overflow-x: auto; }

.alert { border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.empty { color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; }
footer { color: var(--muted); font-size: 12.5px; margin-top: 26px; text-align: center; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); }
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.login label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.login input { width: 100%; font: inherit; font-size: 17px; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); direction: ltr; text-align: center; letter-spacing: 3px; }
.login input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.login button { width: 100%; margin-top: 14px; font: inherit; font-weight: 700; padding: 11px; border: 0; border-radius: 10px; background: var(--brand); color: #fff; cursor: pointer; }
.login .err { color: var(--bad); font-size: 13.5px; margin-top: 10px; min-height: 1.4em; }
@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; }
  header.top h1 { font-size: 18px; }
}

/* navigation, ranges, panels, charts */
nav.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
nav.tabs a { padding: 5px 14px; border-radius: 7px; color: var(--muted); font-size: 14px; text-decoration: none; }
nav.tabs a:hover { color: var(--ink); }
nav.tabs a.on { background: var(--brand); color: #fff; }
.range { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }
.range button { font: inherit; font-size: 13px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.range button.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow); min-width: 0; }
.panel h3 { margin: 0 0 4px; font-size: 15px; }
.panel h4 { margin: 14px 0 6px; font-size: 13.5px; color: var(--muted); font-weight: 600; }
.panel .table { border: 0; border-radius: 0; margin: 6px -16px -14px; }
.hint { margin: 0 0 8px; color: var(--muted); font-size: 12.5px; }
.hint-inline { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.two > .panel { margin-bottom: 14px; }
.chartbox { position: relative; direction: ltr; margin-top: 6px; }
.chart { display: block; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; direction: rtl; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend i, .tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }
.tip { position: absolute; top: 0; pointer-events: none; opacity: 0; transition: opacity .12s; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 12.5px; box-shadow: 0 4px 14px rgba(0,0,0,.12); min-width: 140px; direction: rtl; z-index: 2; }
.tip b { display: block; margin-bottom: 2px; }
.empty.small { padding: 10px; font-size: 13px; }
.sharecell { display: flex; align-items: center; gap: 8px; min-width: 160px; }
.sharecell .bar { flex: 1; margin: 0; }
.heat { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; direction: ltr; margin-top: 8px; }
.heat .cell { position: relative; text-align: center; font-size: 11px; color: var(--muted); }
.heat .cell i { display: block; height: 34px; border-radius: 5px; background: var(--busy); }
.heat .cell b { position: absolute; top: 9px; left: 0; right: 0; font-size: 11px; color: var(--ink); font-weight: 600; }
.heat .cell span { display: block; margin-top: 3px; }
.log { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
.logline { font-size: 12.5px; padding: 5px 8px; border-radius: 7px; background: var(--surface-2); overflow-wrap: anywhere; }
.logline.bad { background: var(--bad-soft); color: var(--bad); }
.logline.ok { background: var(--ok-soft); color: var(--ok); }
tr.failrow td { background: color-mix(in srgb, var(--bad-soft) 60%, transparent); }
@media (max-width: 720px) {
  .two { grid-template-columns: 1fr; }
  nav.tabs { order: 5; width: 100%; justify-content: center; }
  .heat { grid-template-columns: repeat(12, 1fr); }
}

/* table cells holding left-to-right text (names, branches, numbers) stay real table cells */
td.ltr, th.ltr { display: table-cell; direction: ltr; text-align: right; unicode-bidi: isolate; }
