:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #17202b;
  --muted: #6b7684;
  --line: #e2e5ea;
  --accent: #1f3a5f;
  --accent-ink: #ffffff;
  --accent-soft: #e8eef6;
  --ok: #1d7a46;
  --ok-soft: #e4f4ea;
  --warn: #9a6100;
  --warn-soft: #fdf3e1;
  --bad: #b3261e;
  --bad-soft: #fbe9e8;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* header */
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); }
.brand:hover { text-decoration: none; }
.logo { display: inline-block; width: 36px; height: 36px; flex: none; }
.logo.big { width: 64px; height: 64px; }
.logo svg { display: block; width: 100%; height: 100%; }
.organ .crank { transform-box: view-box; transform-origin: 24px 17px; animation: crank 1.6s linear infinite; }
.organ .note { opacity: 0; animation: note 3.2s ease-out infinite; }
.organ .n2 { animation-delay: 1.6s; }
@keyframes crank { to { transform: rotate(360deg); } }
@keyframes note {
  0% { opacity: 0; transform: translate(0, 3px); }
  20% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(1.5px, -3px); }
}
.nav { display: flex; gap: 18px; flex: 1; }
.nav a { color: var(--ink); }
.me { display: flex; gap: 14px; font-size: 14px; }

/* cards & forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card.narrow { max-width: 420px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; margin-top: 22px; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #cfd5dd; border-radius: 8px;
  padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.45; }
label.check input { width: auto; }
.hint { font-size: 12px; color: var(--muted); }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-form.four { grid-template-columns: repeat(4, 1fr); }
.grid-form .span2 { grid-column: span 2; }
.grid-form .span4 { grid-column: span 4; }
.pair { display: flex; gap: 8px; }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 16px; border-radius: 8px; border: 1px solid #cfd5dd; background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f7f8fa; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--bad); border-color: #ecc5c2; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
form.inline { display: flex; gap: 6px; }
form.inline input { padding: 5px 8px; font-size: 13px; max-width: 150px; }

/* messages */
.flash { background: var(--ok-soft); color: var(--ok); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.error { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }

/* tables */
.section-title { margin-top: 8px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list:not(.static) tbody tr { cursor: pointer; }
table.list:not(.static) tbody tr:hover { background: #fafbfc; }
table.list tr.off td { color: var(--muted); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--accent-soft); color: var(--accent); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.done.partial { background: var(--warn-soft); color: var(--warn); }
.badge.failed { background: var(--bad-soft); color: var(--bad); }
.badge.cancelled { background: #eef0f3; color: var(--muted); }

/* login */
.login { max-width: 380px; margin: 8vh auto 0; }
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand h1 { margin: 12px 0 2px; }
.login-brand p { margin: 0; }

/* job page */
.page-head, .job-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.job-head h1 { margin: 6px 0 4px; }
.job-head p { margin: 0; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; display: flex; flex-direction: column; }
.metric .label { font-size: 12px; color: var(--muted); }
.metric .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.progress { display: flex; align-items: center; gap: 16px; }
.stage { font-weight: 600; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.result-bar h2 { margin: 0; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.article { max-width: 760px; font-size: 16px; line-height: 1.65; }
.article h2 { font-size: 20px; margin: 28px 0 10px; }
.article p { margin: 0 0 12px; }
.article ul { margin: 0 0 12px; padding-left: 22px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.span-all { grid-column: 1 / -1; }
.h2list { margin: 0; padding-left: 22px; }
.h2list li { margin-bottom: 6px; }
.log { list-style: none; margin: 0; padding: 0; font-size: 13px; max-height: 420px; overflow-y: auto; }
.log li { padding: 5px 0; border-bottom: 1px dashed var(--line); white-space: pre-wrap; }
.log .t { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 10px; }
.error-box h2 { color: var(--bad); }
pre { white-space: pre-wrap; font-size: 12px; background: #f6f7f9; padding: 10px; border-radius: 8px; overflow-x: auto; }

@media (max-width: 760px) {
  .top-inner { height: auto; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; gap: 10px 18px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .me { margin-left: auto; }
  .grid-form, .grid-form.four { grid-template-columns: 1fr; }
  .grid-form .span2, .grid-form .span4 { grid-column: auto; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .job-head, .page-head { flex-direction: column; }
  h1 { font-size: 21px; }
}
