/* Zafar dashboard. Colors are roles, defined once per mode; status colors always travel with a label. */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --sunk: #f1f0ec;
  --ink: #0b0b0b; --ink2: #52514e; --muted: #77756f;
  --line: #e1e0d9; --border: rgba(11, 11, 11, .10);
  --accent: #2a78d6; --button: #256abf; --button-ink: #ffffff;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b;
  --on-good: #ffffff; --on-warn: #0b0b0b; --on-crit: #ffffff;
  --shadow: 0 1px 2px rgba(11, 11, 11, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --sunk: #232322;
    --ink: #ffffff; --ink2: #c3c2b7; --muted: #9a988f;
    --line: #2c2c2a; --border: rgba(255, 255, 255, .10);
    --accent: #3987e5; --button: #256abf; --button-ink: #ffffff;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink);
       font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
h1, h2, h3, h4, h5, h6, p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.noscript { padding: 24px 16px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px calc(40px + env(safe-area-inset-bottom)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.ink2 { color: var(--ink2); }
.small { font-size: 13px; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.wraprow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
[hidden] { display: none !important; }

/* buttons and fields */
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 7px 13px;
       cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--sunk); }
a.btn { text-decoration: none; color: inherit; display: inline-block; }
.linklike { border: 0; background: none; padding: 0; cursor: pointer; color: var(--accent); text-decoration: underline;
            text-underline-offset: 2px; font-size: 13px; }
details.more { border: 1px solid var(--border); border-radius: 12px; padding: 9px 14px; }
details.more summary { cursor: pointer; font-size: 14px; color: var(--ink2); }
details.more[open] summary { margin-bottom: 4px; }
.btn.primary { background: var(--button); border-color: transparent; color: var(--button-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: color-mix(in oklab, var(--crit) 55%, transparent); }
.btn.quiet { border-color: transparent; background: none; color: var(--ink2); }
.btn:disabled { opacity: .5; cursor: default; }
.field { width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
         padding: 10px 12px; }
textarea.field { resize: vertical; min-height: 46px; display: block; }
.field::placeholder { color: var(--muted); }

/* header */
header.top { display: flex; align-items: center; gap: 12px; padding: 18px 0 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.brand img { width: 26px; height: 26px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink2);
        border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; background: var(--surface); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.good { background: var(--good); } .dot.warn { background: var(--warn); }
.dot.serious { background: var(--serious); } .dot.crit { background: var(--crit); }
.dot.accent { background: var(--accent); } .dot.off { background: none; border: 1.5px solid var(--muted); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot.pulse, .step.current.working .mark { animation: none; } }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: 14px;
          border-radius: 12px; border: 1px solid color-mix(in oklab, var(--crit) 45%, transparent);
          background: color-mix(in oklab, var(--crit) 9%, var(--surface)); }
.banner .dot { margin-top: 7px; }
.banner ul { margin: 4px 0 0; padding-left: 18px; }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { padding: 12px 14px; min-width: 0; }
.stat .value { font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; margin-top: 2px; }
.stat .sub { font-size: 13px; color: var(--ink2); }
.meter { height: 8px; border-radius: 4px; margin-top: 8px; overflow: hidden;
         background: color-mix(in oklab, var(--fill, var(--accent)) 20%, var(--surface)); }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--fill, var(--accent)); min-width: 2px; }
.meter.warn { --fill: var(--warn); } .meter.crit { --fill: var(--crit); }

/* composer */
.composer { padding: 14px; margin-bottom: 14px; }
.composer form { display: flex; gap: 10px; align-items: flex-end; }
.composer .hint { margin-top: 8px; }

/* layout */
.main { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; align-items: start; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list h2, .section-title { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
                           color: var(--muted); padding: 4px 2px; }
.run { display: block; width: 100%; text-align: left; padding: 12px 14px; cursor: pointer; }
.run:hover { border-color: color-mix(in oklab, var(--accent) 45%, transparent); }
.run.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.run .title { font-weight: 600; }
.run .meta { font-size: 13px; color: var(--ink2); margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; border-radius: 999px;
        padding: 2px 9px; background: var(--sunk); white-space: nowrap; flex: none; }
.bars { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; margin-top: 9px; }
.bars i { height: 5px; border-radius: 2px; background: var(--line); }
.bars i.done { background: var(--accent); }
.bars i.current { background: var(--accent); opacity: .55; }
.bars i.paused { background: var(--warn); } .bars i.stopped { background: var(--crit); }
.empty { padding: 28px 18px; text-align: center; color: var(--ink2); }

/* run detail */
.detail { padding: 18px; min-width: 0; }
.detail > * + * { margin-top: 16px; }
.detail h2 { font-size: 21px; letter-spacing: -.015em; line-height: 1.25; overflow-wrap: anywhere; }
.back { display: none; align-self: flex-start; margin-left: -8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack:empty, .detail > div:empty { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.note { padding: 10px 12px; border-radius: 10px; background: var(--sunk); font-size: 14px; overflow-wrap: anywhere; }
.steps { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.step { text-align: center; min-width: 0; position: relative; }
.step::before { content: ""; position: absolute; top: 13px; left: -50%; right: 50%; height: 2px; background: var(--line); }
.step:first-child::before { display: none; }
.step.done::before, .step.current::before, .step.paused::before, .step.stopped::before { background: var(--good); }
.step .mark { position: relative; width: 28px; height: 28px; border-radius: 50%; margin: 0 auto; display: grid;
              place-items: center; font-size: 13px; font-weight: 700; background: var(--surface);
              border: 2px solid var(--line); color: var(--muted); }
.step.done .mark { background: var(--good); border-color: var(--good); color: var(--on-good); }
.step.current .mark { border-color: var(--accent); color: var(--accent); }
.step.current.working .mark { animation: ring 1.8s ease-out infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 45%, transparent); }
                  100% { box-shadow: 0 0 0 9px transparent; } }
.step.paused .mark { background: var(--warn); border-color: var(--warn); color: var(--on-warn); }
.step.stopped .mark { background: var(--crit); border-color: var(--crit); color: var(--on-crit); }
.step .name { font-size: 12.5px; margin-top: 6px; font-weight: 500; overflow-wrap: anywhere; }
.step.pending .name { color: var(--muted); font-weight: 400; }
.step .sub { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fact { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.fact .value { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.needs { border: 1px solid color-mix(in oklab, var(--warn) 60%, transparent); border-radius: 12px; padding: 12px 14px;
         background: color-mix(in oklab, var(--warn) 8%, var(--surface)); }
.needs h3 { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.needs ul, .plain-list { margin: 6px 0 0; padding-left: 20px; }
.needs li, .plain-list li { margin: 3px 0; overflow-wrap: anywhere; }
.needs .group + .group { margin-top: 10px; }
.milestones { list-style: none; margin: 6px 0 0; padding: 0; }
.milestones li { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; font-size: 14px; }
.milestones .state { width: 62px; flex: none; font-size: 12px; color: var(--muted); }
.keys code { background: var(--sunk); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 8px 12px; cursor: pointer; font-size: 14px; color: var(--ink2);
       border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.pane { margin-top: 12px !important; min-height: 120px; }
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: grid; grid-template-columns: 76px 14px minmax(0, 1fr); gap: 8px; padding: 7px 0;
             border-top: 1px solid var(--line); font-size: 14px; }
.events li:first-child { border-top: 0; }
.events time { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.events .dot { margin-top: 7px; }
.events .text { overflow-wrap: anywhere; white-space: pre-wrap; }
.log { background: var(--sunk); border-radius: 10px; padding: 10px 12px; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
       max-height: 460px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 13px; color: var(--ink2); }

/* documents (rendered markdown) */
.doc { overflow-wrap: anywhere; }
.doc > * + * { margin-top: 10px; }
.doc h3 { font-size: 19px; letter-spacing: -.01em; margin-top: 18px; }
.doc h4 { font-size: 16px; margin-top: 18px; }
.doc h5, .doc h6 { font-size: 14.5px; margin-top: 14px; }
.doc > :first-child { margin-top: 0; }
.doc ul, .doc ol { margin: 0; padding-left: 22px; }
.doc li { margin: 3px 0; }
.doc li.l1 { margin-left: 18px; } .doc li.l2 { margin-left: 36px; }
.doc code { background: var(--sunk); padding: 1px 5px; border-radius: 5px; font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
.doc pre { background: var(--sunk); border-radius: 10px; padding: 10px 12px; overflow: auto; white-space: pre-wrap;
           font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; position: relative; }
.doc pre code { background: none; padding: 0; }
.doc blockquote { margin: 0; padding: 2px 12px; border-left: 3px solid var(--line); color: var(--ink2); }
.doc hr { border: 0; border-top: 1px solid var(--line); }
.doc .table { overflow-x: auto; }
.doc table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
.doc th, .doc td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top; }
.doc th { background: var(--sunk); font-weight: 600; }
.copy { position: absolute; top: 6px; right: 6px; font-size: 12px; padding: 2px 8px; border-radius: 7px;
        border: 1px solid var(--border); background: var(--surface); cursor: pointer; }

/* dialog and toast */
dialog { border: 1px solid var(--border); border-radius: 16px; padding: 18px; width: min(460px, calc(100vw - 32px));
         background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h3 { font-size: 17px; }
dialog form > * + * { margin-top: 12px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
dialog label { display: block; font-size: 13px; color: var(--ink2); margin-bottom: 4px; }
#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
         background: var(--ink); color: var(--page); padding: 9px 14px; border-radius: 10px; font-size: 14px;
         max-width: calc(100vw - 32px); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; }
#toast.on { opacity: 1; }

/* public page */
.public { max-width: 720px; margin: 0 auto; padding: 0 16px 48px; }
.hero { padding: 36px 0 8px; }
.hero h1 { font-size: clamp(28px, 6vw, 40px); line-height: 1.12; letter-spacing: -.03em; }
.hero p { margin-top: 14px; font-size: 17px; color: var(--ink2); max-width: 60ch; }
.how { list-style: none; margin: 26px 0; padding: 0; display: grid; gap: 10px; counter-reset: how; }
.how li { counter-increment: how; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 12px 14px; }
.how li::before { content: counter(how); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
                  background: var(--sunk); font-weight: 700; font-size: 13px; color: var(--ink2); }
.how b { display: block; }
.signin { padding: 18px; }
.signin form { display: flex; gap: 10px; margin-top: 12px; }
.signin .err { margin-top: 10px; color: var(--ink); display: flex; gap: 8px; align-items: center; font-size: 14px; }
.foot { margin-top: 26px; font-size: 13px; color: var(--muted); }

@media (max-width: 880px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { grid-template-columns: minmax(0, 1fr); }
  .main.has-sel .list { display: none; }
  .main:not(.has-sel) .detail-col { display: none; }
  .back { display: inline-flex; }
  .steps { grid-template-columns: repeat(5, minmax(0, 1fr)); row-gap: 14px; }
  .step:nth-child(6)::before { display: none; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail { padding: 14px; }
  .composer form, .signin form { flex-direction: column; align-items: stretch; }
  .events li { grid-template-columns: 62px 14px minmax(0, 1fr); }
}
