:root {
  --bg: #ececec;
  --side: #f7f7f7;
  --panel: #ffffff;
  --ink: #222222;
  --ink-2: #4a4a4a;
  --muted: #6f6f6f;
  --line: #e3e3e3;
  --line-2: #eeeeee;
  --accent: #0a6fe0;
  --accent-soft: #e3effc;
  --brand: #56b13b;
  --good: #2e7d32;   --good-bg: #e3f5e1;
  --warn: #9a5b00;   --warn-bg: #fdf0d8;
  --bad: #c62828;    --bad-bg: #fde7e7;
  --info: #0a5cba;   --info-bg: #e3effc;
  --c1: #81d4fa; --c2: #80cbc4; --c3: #a57fd6; --c4: #ffb74d; --c5: #6cc979;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--sans); font-feature-settings: "tnum"; padding: 16px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; font-weight: 500; }
h2 { font-size: 18px; font-weight: 500; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- shell ---------- */
.shell {
  display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - 32px);
  max-width: 1520px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
}
.side {
  border-right: 1px solid var(--line); padding: 28px 12px; position: sticky; top: 16px; height: calc(100vh - 32px);
  display: flex; flex-direction: column; gap: 32px; background: var(--side); border-radius: 4px 0 0 4px;
}
.brand { padding: 0 20px; }
.brand .co { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.brand .name { font-size: 18px; font-weight: 500; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; border-radius: 4px;
  color: var(--ink-2); min-height: 44px; position: relative;
}
.nav a:hover { background: var(--line-2); text-decoration: none; }
.nav a.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.nav a.on::before { content: ""; position: absolute; left: 7px; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--brand); }
.nav .count {
  font: 500 11px var(--sans); background: var(--warn-bg); color: var(--warn); padding: 1px 6px; border-radius: 3px;
}
.nav .live { width: 7px; height: 7px; border-radius: 50%; background: var(--good); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.side .foot { margin-top: auto; padding: 0 20px; font-size: 12px; color: var(--muted); }

main { padding: 0 36px 64px; width: 100%; min-width: 0; }
.head {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin: 0 -36px 32px; padding: 24px 36px; border-bottom: 1px solid var(--line);
}
.head p { margin: 4px 0 0; color: var(--muted); }

section { margin-top: 40px; }
section > .label {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 12px; margin-bottom: 0;
}
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; }
.cols-3-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 36px; }

/* ---------- figures ---------- */
.figures { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.figure { padding: 14px 16px 16px 0; }
.figure + .figure { padding-left: 16px; border-left: 1px solid var(--line); }
.figure .k { font-size: 12px; color: var(--muted); }
.figure .v { font: 500 30px/1.15 var(--sans); margin-top: 6px; letter-spacing: -0.02em; }
.figure .s { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.figure.alert .v { color: var(--warn); }

/* ---------- phases ---------- */
.phases { display: grid; grid-template-columns: repeat(4, 1fr); }
.phase { padding: 14px 16px 14px 0; border-bottom: 1px solid var(--line); }
.phase + .phase { padding-left: 16px; border-left: 1px solid var(--line); }
.phase .n { font: 500 11px var(--sans); color: var(--muted); }
.phase h3 { margin-top: 2px; }
.phase p { font-size: 12px; color: var(--muted); margin: 2px 0 10px; }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state.live { color: var(--good); }
.state.ready { color: var(--info); }
.state.blocked { color: var(--bad); }
.state.waiting { color: var(--muted); }

/* ---------- bars ---------- */
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: 190px 1fr 64px; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.bars .track { height: 6px; background: var(--line-2); border-radius: 1px; overflow: hidden; }
.bars .fill { display: block; height: 100%; background: var(--accent); }
.bars .v { text-align: right; font-family: var(--sans); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 12px; font-weight: 400; color: var(--muted); background: var(--side);
  padding: 12px 16px; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); white-space: nowrap;
}
td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: #fafafa; }
.table-wrap { overflow-x: auto; }
.co-name { font-weight: 500; color: var(--ink); }
a.co-name { color: var(--accent); font-weight: 400; }
.sub { display: block; font-size: 12px; color: var(--muted); }

.fit { display: inline-flex; align-items: center; gap: 8px; font-family: var(--sans); }
.fit i { display: block; width: 44px; height: 4px; background: var(--line); border-radius: 1px; position: relative; }
.fit i b { position: absolute; inset: 0 auto 0 0; background: var(--ink-2); border-radius: 1px; }
.fit.high i b { background: var(--good); }

.pill {
  display: inline-block; font-size: 12px; font-weight: 500; padding: 1px 7px; border-radius: 3px;
  background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.muted { background: transparent; color: var(--muted); padding-left: 0; }

/* ---------- checks ---------- */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.checks .mark { font-family: var(--sans); font-weight: 600; }
.checks .ok .mark { color: var(--good); }
.checks .no .mark { color: var(--bad); }
.checks .sub { margin-top: 1px; }

/* ---------- forms ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input[type=text], input[type=search], input[type=number], select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  padding: 7px 9px; min-height: 34px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=search] { width: 260px; }
input[type=number] { width: 84px; }
textarea { width: 100%; resize: vertical; line-height: 1.55; }
.btn {
  font: 400 14px var(--sans); border-radius: 4px; padding: 8px 14px; min-height: 38px; cursor: pointer;
  border: 1px solid #c9c9c9; background: var(--side); color: var(--ink);
}
.btn:hover { border-color: var(--ink-2); background: #f0f0f0; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }
.btn.primary:hover { background: #4a9b32; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- lead page ---------- */
.crumbs { font-size: 13px; color: var(--muted); padding-top: 20px; }
.crumbs + .head { padding-top: 6px; }
.facts { display: grid; grid-template-columns: 120px 1fr; border-top: 1px solid var(--line); }
.facts dt, .facts dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.facts dt { color: var(--muted); font-size: 13px; }
.prose { max-width: 68ch; }
.quote { border-left: 2px solid var(--accent); padding: 4px 0 4px 14px; color: var(--ink); margin: 8px 0 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { font-size: 12px; border: 1px solid var(--line); border-radius: 3px; padding: 1px 7px; color: var(--ink-2); background: var(--panel); }
.draft-step { margin-top: 14px; }
.draft-step .step-h { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.panel + .panel { margin-top: 16px; }
.notice { border: 1px solid var(--line); background: var(--panel); border-left: 3px solid var(--warn); padding: 10px 14px; border-radius: 4px; margin-bottom: 16px; }
.notice.bad { border-left-color: var(--bad); }

/* ---------- lead page, Gmail-style ---------- */
.mailbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; position: sticky; top: 0; z-index: 2;
  margin: 0 -36px 24px; padding: 14px 36px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.mailbar .back { color: var(--ink-2); font-weight: 500; padding: 8px 0; }
.grow { flex: 1; }
.mail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; }
.mail { border: 1px solid var(--line); border-radius: 8px; padding: 20px 24px; background: var(--panel); max-width: 760px; }
.mail + .mail { margin-top: 10px; }
.mail-subject, .mail input.mail-subject {
  display: block; width: 100%; font: 400 22px/1.3 var(--sans); color: var(--ink); margin: 0 0 16px;
  border: 0; padding: 4px 0; min-height: 0; background: transparent;
}
input.mail-subject:focus, .mail-body:focus { outline: none; box-shadow: 0 2px 0 var(--accent-soft); }
.mail-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--c1); color: #0d3c55;
  display: grid; place-items: center; font-weight: 600; font-size: 16px;
}
.mail-body {
  display: block; width: 100%; border: 0; padding: 0; resize: vertical; background: transparent;
  font: 15px/1.6 var(--sans); color: var(--ink); field-sizing: content; min-height: 6lh;
}
.mail.follow { padding: 0; }
.mail.follow summary { cursor: pointer; padding: 14px 24px; list-style: none; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; min-height: 48px; }
.mail.follow summary::-webkit-details-marker { display: none; }
.mail.follow summary .preview { flex-basis: 100%; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail.follow[open] summary .preview { display: none; }
.mail.follow .mail-body { padding: 0 24px 20px; }
.about { position: sticky; top: 90px; }
.about h2 { font-size: 16px; }
.about p { font-size: 13px; color: var(--ink-2); margin: 10px 0; }
.about .fitline { margin-top: 12px; }
.about details { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }
.about summary { cursor: pointer; color: var(--accent); min-height: 32px; }
.about .links { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ---------- runs ---------- */
.actions { list-style: none; margin: 0; padding: 0; }
.actions li { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.actions .desc { font-size: 12px; color: var(--muted); }
.actions .need { font-size: 12px; color: var(--bad); }
.actions form { display: flex; gap: 6px; align-items: center; }
pre.log {
  background: #17171a; color: #d9d8d2; font: 12px/1.6 var(--mono); padding: 14px 16px; border-radius: 6px;
  overflow: auto; max-height: 460px; margin: 0; white-space: pre-wrap; word-break: break-word;
}

.empty { padding: 28px 0; color: var(--muted); }

@media (max-width: 1000px) {
  .figures { grid-template-columns: repeat(2, 1fr); }
  .figure:nth-child(odd) { padding-left: 0; border-left: 0; }
  .phases { grid-template-columns: repeat(2, 1fr); }
  .phase:nth-child(odd) { padding-left: 0; border-left: 0; }
  .cols, .cols-3-2, .mail-grid { grid-template-columns: minmax(0, 1fr); }
  .about { position: static; }
}
@media (max-width: 760px) {
  .figures, .phases { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  body { padding: 0; }
  .shell { grid-template-columns: minmax(0, 1fr); border: 0; border-radius: 0; min-height: 100vh; }
  .head, .mailbar { margin: 0 -16px 24px; padding: 14px 16px; }
  .mail { padding: 16px; }
  .nav a { padding: 8px 14px; }
  .nav a.on::before { left: 4px; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .side .foot { display: none; }
  main { padding: 0 16px 48px; }
  .bars li { grid-template-columns: 120px 1fr 52px; }
  input[type=search] { width: 100%; }
}

/* ---------- overview: to-do and pipeline ---------- */
.todo { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.todo li {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--muted);
  border-radius: 4px; padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.todo li.good { border-left-color: var(--good); }
.todo li.warn { border-left-color: var(--warn); }
.todo li.info { border-left-color: var(--info); }
.todo li.bad { border-left-color: var(--bad); }
.todo .t { font-size: 16px; font-weight: 500; }
.todo .d { font-size: 13px; color: var(--ink-2); }
.todo .btn { white-space: nowrap; display: inline-flex; align-items: center; min-height: 40px; }
.todo .btn:hover { text-decoration: none; }

/* Ecomail-style funnel: a column per step, hatched slopes between them showing the drop. */
.funnel { display: flex; margin-top: 8px; }
.funnel .col { flex: 1 1 0; min-width: 0; }
.funnel .gap { flex: 0.6 1 0; position: relative; height: 200px; }
.funnel .box { position: relative; height: 200px; background: var(--side); }
.funnel .fill { position: absolute; left: 0; right: 0; bottom: 0; }
.funnel .v { position: absolute; top: 12px; left: 0; right: 0; text-align: center; font-size: 30px; font-weight: 500; line-height: 1.1; }
.funnel .slope {
  position: absolute; inset: 0; opacity: .45;
  background: repeating-linear-gradient(135deg, var(--c) 0 2px, transparent 2px 7px);
  clip-path: polygon(0 calc(100% - var(--a)), 100% calc(100% - var(--b)), 100% 100%, 0 100%);
}
.funnel .pct { position: absolute; left: 50%; transform: translateX(-50%); z-index: 1; }
.funnel .pct span { background: var(--panel); padding: 2px 4px; white-space: nowrap; font-size: 14px; }
.funnel .pct small { font-size: 12px; color: var(--muted); }
.funnel-legend .name { background: var(--side); border-top: 1px solid var(--line); padding: 10px 8px; text-align: center; height: 100%; }
.funnel-legend .name .t { font-weight: 500; font-size: 13px; }
.funnel-legend .name .d { font-size: 12px; color: var(--muted); }
.funnel-legend { display: flex; }
.funnel-legend .col { flex: 1 1 0; min-width: 0; }
.funnel-legend .gap { flex: 0.6 1 0; background: var(--side); border-top: 1px solid var(--line); }

details.more { margin-top: 36px; }
details.more > summary { cursor: pointer; color: var(--accent); font-weight: 500; padding: 10px 0; min-height: 44px; }

@media (max-width: 760px) {
  .todo li { flex-direction: column; align-items: stretch; }
  .funnel .gap, .funnel-legend .gap, .funnel-legend .name .d { display: none; }
  .funnel .col ~ .col, .funnel-legend .col ~ .col { margin-left: 4px; }
  .funnel .v { font-size: 18px; }
  .funnel-legend .name { font-size: 12px; padding: 8px 2px; }
}

/* ---------- sign in ---------- */
body.signin { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.signin-card {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 32px; display: flex; flex-direction: column; gap: 8px;
}
.signin-card .brand { padding: 0; margin-bottom: 20px; }
.signin-card label { font-size: 13px; color: var(--ink-2); }
.signin-card input { width: 100%; min-height: 44px; }
.signin-card .err { color: var(--bad); font-size: 13px; margin: 0; }
.signin-card .btn { min-height: 44px; margin-top: 8px; }
