:root {
  --bg: #f5f6f8;
  --surface: #fff;
  --ink: #1b2430;
  --muted: #667380;
  --line: #d9dee5;
  --accent: #1f6f8b;
  --ok: #2e7d4f;
  --ok-bg: #ddf0e4;
  --warn: #b7791f;
  --warn-bg: #f7ebd3;
  --bad: #b4392f;
  --bad-bg: #f6dedb;
  --info-bg: #ddedf3;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: #eef1f4; padding: 1px 4px; border-radius: 3px; }
code.secret { user-select: all; }
h2 { font-size: 20px; margin: 28px 0 12px; }
h2 small, h3 small { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 8px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
.lede { color: var(--muted); margin: -6px 0 16px; }
h4 { margin: 0 0 8px; font-size: 14px; }
small { color: var(--muted); }
main { max-width: 1280px; margin: 0 auto; padding: 8px 20px 40px; }
.top { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.top .brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); text-decoration: none; }
.top .brand svg { color: var(--accent); flex: none; }
.top nav { display: flex; gap: 4px; }
.top nav a { color: var(--ink); text-decoration: none; padding: 6px 10px; border-radius: 4px; white-space: nowrap; }
.top nav a.on, .top nav a:hover { background: var(--bg); }
.top .browser { margin-left: auto; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); white-space: nowrap; }
.top .browser.bad { background: var(--bad-bg); color: var(--bad); }
.foot { max-width: 1280px; margin: 0 auto; padding: 0 20px 24px; color: var(--muted); font-size: 12px; }

.counters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.counters div { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; display: flex; flex-direction: column; }
.counters .n { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.counters .n.warn { color: var(--bad); }
.counters .l { color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #f0f2f5; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.muted td { color: var(--muted); }
tr.rejected td { background: #fdf6f5; }
tr.current td { background: var(--info-bg); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
td.url { max-width: 520px; overflow-wrap: anywhere; }

.chip { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; white-space: nowrap; background: #eef1f4; color: var(--muted); }
.chip.done { background: var(--ok-bg); color: var(--ok); }
.chip.queued { background: var(--info-bg); color: var(--accent); }
.chip.running { background: var(--warn-bg); color: var(--warn); }
.chip.failed, .chip.challenged { background: var(--bad-bg); color: var(--bad); }
.chip.skipped, .chip.cancelled { background: #eef1f4; color: var(--muted); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.filters { display: flex; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
select, input[type=url], input[type=text], input[type=password] { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
button { font: inherit; padding: 7px 14px; border-radius: 4px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
button.secondary { background: var(--surface); color: var(--accent); }
button[disabled] { opacity: .5; cursor: default; }
form.stack { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px; }
form.stack label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
form.inline { display: inline-block; margin-top: 10px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0; }
.crumbs { color: var(--muted); margin: 12px 0 0; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }
dl.facts dt { color: var(--muted); font-size: 12px; padding-top: 2px; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

ol.steps { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px 12px 36px; margin: 0; }
ol.steps li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
ol.steps li:last-child { border-bottom: 0; }
img.shot { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; }

.site-card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; margin-bottom: 16px; }
.site-card.muted { opacity: .7; }
.site-card header { display: flex; align-items: center; justify-content: space-between; }
.site-card header h3 { margin: 0; }
.site-card .two-col { margin-top: 10px; }
.site-card dl.facts { border: 0; padding: 0; }
.webhook { background: #f7f9fb; border-radius: 6px; padding: 12px 14px; }
.site-card h3 .chip { margin-left: 6px; vertical-align: middle; }

/* pager */
.pager { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 12px 0; }
.pager-total { color: var(--muted); font-size: 12.5px; }
.pager-links { display: flex; gap: 4px; }
.pager-links a, .pager-links span { min-width: 32px; padding: 5px 9px; text-align: center; border-radius: 4px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; font-variant-numeric: tabular-nums; }
.pager-links .cur { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager-links .off { color: var(--line); }
.pager-links .gap { border-color: transparent; background: none; color: var(--muted); }
.pager-jump { display: flex; gap: 6px; margin-left: auto; }
.pager-jump input { width: 72px; font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; }
.pager-jump button { padding: 5px 12px; }

/* settings */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 16px; }
.tabs a { padding: 8px 14px; color: var(--ink); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.flash { padding: 9px 14px; border-radius: 6px; margin: 0 0 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.bad { background: var(--bad-bg); color: var(--bad); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px 18px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: start; }
.settings-layout aside dl.facts code { word-break: break-all; }
@media (max-width: 1000px) { .settings-layout { grid-template-columns: 1fr; } }
.settings-form.narrow { max-width: 760px; }
.field { display: grid; grid-template-columns: 260px minmax(0, 1fr); align-items: center; gap: 4px 16px; padding: 7px 0; border-bottom: 1px solid #eef1f4; }
.field:last-of-type { border-bottom: 0; }
.field > label { color: var(--muted); font-size: 13px; }
.field .control { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field .control input[type=text], .field .control input[type=password], .field .control select { min-width: 280px; }
.field .control input[type=number] { width: 110px; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; }
.field input[type=password] { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; }
.field input[readonly] { background: #f0f2f5; color: var(--muted); }
.field .unit { color: var(--muted); font-size: 12.5px; }
.field label.check { grid-column: 1 / -1; color: var(--ink); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.field .error { grid-column: 2; color: var(--bad); font-size: 12px; }
.field.has-error input, .field.has-error select { border-color: var(--bad); }
label.check.small { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 700px) { .field { grid-template-columns: 1fr; } .field .error { grid-column: 1; } .field .control input[type=text], .field .control input[type=password], .field .control select { min-width: 0; width: auto; flex: 1 1 200px; } }
.section-actions { display: flex; gap: 8px; margin-top: 12px; }
.form-actions { position: sticky; bottom: 0; z-index: 2; padding: 12px 0; background: var(--bg); border-top: 1px solid var(--line); }
.confirm-form { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.row-actions { width: 1%; }
.row-actions > div { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.row-actions form { margin: 0; }
a.button { display: inline-block; font: inherit; padding: 7px 14px; border-radius: 4px; border: 1px solid var(--accent); text-decoration: none; }
a.button.secondary { background: var(--surface); color: var(--accent); }
button.danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.add-site { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.add-site label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

/* accounts */
.top .whoami { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.top .whoami form { margin: 0; }
button.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
button.linkish:hover { text-decoration: underline; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.row-actions .confirm-form { margin-top: 0; flex-wrap: nowrap; }
.row-actions input[type=password] { width: 150px; }
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 28px 32px; width: 100%; max-width: 360px; margin: 16px; }
.login-box h2 { margin: 12px 0 16px; }
.login-box form { display: flex; flex-direction: column; gap: 12px; }
.login-box label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.login-box input { width: 100%; }
.login-box button { margin-top: 4px; padding: 9px 14px; }

/* "?" help popovers */
.title-row { position: relative; display: flex; align-items: center; gap: 10px; margin: 28px 0 12px; }
.title-row h2 { margin: 0; }
details.help { display: inline-block; font-size: 14px; font-weight: 400; }
details.help > summary { list-style: none; cursor: pointer; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--accent); color: var(--accent); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; user-select: none; }
details.help > summary::-webkit-details-marker { display: none; }
details.help[open] > summary { background: var(--accent); color: #fff; }
details.help .help-body { position: absolute; z-index: 20; top: calc(100% + 8px); left: 0; width: min(560px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 24px rgba(27, 36, 48, .14); padding: 12px 16px; line-height: 1.5; color: var(--ink); }
details.help .help-body p { margin: 0 0 8px; }
details.help .help-body ul { margin: 0 0 8px; padding-left: 18px; }
details.help .help-body li { margin-bottom: 4px; }
details.help .help-body .muted { color: var(--muted); font-size: 12.5px; margin-bottom: 0; }

/* ---------------------------------------------------------------- narrow screens */
.menu-toggle { display: none; }
.top .browser .short { display: none; }
.exp-cards { display: none; }

/* laptops: the full browser line no longer fits next to the menu */
@media (max-width: 1280px) {
  .top { gap: 16px; }
  .top .browser .long { display: none; }
  .top .browser .short { display: inline; }
}

/* tablets and phones: the menu folds behind a button */
@media (max-width: 1180px) {
  .top { flex-wrap: wrap; gap: 8px 12px; padding: 8px 14px; }
  .top nav { flex-wrap: wrap; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; width: 42px; height: 42px; padding: 0; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; }
  .top.open .menu-toggle { background: var(--bg); }
  html.js .top nav, html.js .top .browser, html.js .top .whoami { display: none; }
  html.js .top.open nav { display: flex; flex-direction: column; gap: 2px; width: 100%; order: 3; padding: 6px 0; border-top: 1px solid var(--line); }
  .top.open nav a { padding: 11px 10px; font-size: 15px; }
  html.js .top.open .whoami { display: inline-flex; order: 4; flex: 1; font-size: 14px; padding: 4px 10px 8px; }
  html.js .top.open .browser { display: inline-block; order: 5; margin: 0 10px 8px 0; }
  .top .browser { margin-left: 0; }
}

@media (max-width: 720px) {
  main { padding: 4px 12px 32px; }
  .foot { padding: 0 12px 20px; }
  h2 { font-size: 18px; margin: 20px 0 10px; }
  .title-row { margin: 20px 0 10px; }
  .lede { margin: -4px 0 14px; }
  .counters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .counters .n { font-size: 22px; }

  /* a table row becomes a card: column name on the left, value on the right */
  .table-wrap.has-cards { background: none; border: 0; border-radius: 0; overflow: visible; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards thead { display: none; }
  table.cards tr { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 2px 12px; margin-bottom: 10px; }
  table.cards tr.muted { opacity: .75; }
  table.cards td { position: relative; padding: 8px 0 8px 38%; min-height: 34px; border-bottom: 1px solid #eef1f4; text-align: left; white-space: normal; max-width: none; overflow-wrap: anywhere; }
  table.cards td::before { content: attr(data-label); position: absolute; left: 0; top: 9px; width: 34%; color: var(--muted); font-size: 11px; line-height: 1.35; text-transform: uppercase; letter-spacing: .04em; overflow-wrap: normal; }
  table.cards tr > td:first-child { padding: 10px 0 8px; font-size: 15px; }
  table.cards tr > td:first-child::before, table.cards td[colspan]::before, table.cards td[data-label=""]::before { content: none; }
  table.cards td[colspan], table.cards td[data-label=""] { padding-left: 0; }
  table.cards tr > td:last-child { border-bottom: 0; }
  table.cards td.num { text-align: left; }
  table.cards td.row-actions { width: 100%; }
  table.cards .row-actions > div { justify-content: flex-start; flex-wrap: wrap; }
  table.cards form.inline { display: flex; flex-wrap: wrap; }
  table.cards .confirm-form { flex-wrap: wrap; }
  table.cards .row-actions input[type=password] { flex: 1 1 160px; width: auto; }

  /* Эксперимент: one card per period instead of the wide table */
  .exp-desktop { display: none; }
  .exp-cards { display: grid; gap: 10px; }
  .exp-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
  .exp-card.muted { opacity: .75; }
  .exp-card__head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-bottom: 6px; }
  .exp-card table th, .exp-card table td { padding: 6px 4px; font-size: 13px; }
  .exp-card table th { background: none; font-size: 10.5px; white-space: normal; }
  .exp-card table td:first-child { color: var(--muted); font-size: 12px; }
  .exp-card table tbody tr:last-child td { border-bottom: 0; }

  /* forms: full width controls, and 16px text so iOS does not zoom in on focus */
  input, select, textarea { font-size: 16px; }
  .filters > select, .filters > input { flex: 1 1 140px; min-width: 0; }
  .add-site label { flex: 1 1 100%; }
  .add-site input, .add-site select { width: 100%; }
  form.stack input, form.stack select { width: 100%; }
  .pager { gap: 10px; }
  .pager-jump { margin-left: 0; }
  /* wrap rather than scroll: a sideways-scrolling tab strip hides its last tab */
  .tabs { flex-wrap: wrap; }
  .tabs a { white-space: nowrap; padding: 8px 10px; }
  dl.facts { grid-template-columns: minmax(90px, 34%) minmax(0, 1fr); }
  .site-card header { flex-wrap: wrap; gap: 8px; }
  .panel { padding: 12px 14px; }
  .login-box { padding: 22px 20px; }
}

/* «Десятка дня»: the undo sits next to the "запрошено" note */
form.inline-undo { display: inline; margin-left: 6px; }
.daily-action small { color: var(--muted); }
