:root {
  --bg: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #16191d;
  --muted: #687080;
  --primary: #2f5bea;
  --primary-hover: #2449c4;
  --primary-soft: #e9eefe;
  --ok: #157347;
  --ok-soft: #e2f5ea;
  --err: #c42b2b;
  --err-soft: #fdeaea;
  --warn: #9a5800;
  --warn-soft: #fff2db;
  --info: #1f56c9;
  --info-soft: #e7efff;
  --radius: 5px;
  --shadow: none;
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --surface: #191c22;
    --surface-2: #1f232a;
    --border: #2b3039;
    --border-strong: #3a414c;
    --text: #e7e9ed;
    --muted: #98a1b0;
    --primary: #5a80ff;
    --primary-hover: #7593ff;
    --primary-soft: #1d2848;
    --ok: #4cc38a;
    --ok-soft: #13301f;
    --err: #ff6b6b;
    --err-soft: #3a191b;
    --warn: #f0b04a;
    --warn-soft: #382a10;
    --info: #7ea4ff;
    --info-soft: #1a2642;
    --shadow: none;
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 16px; font-weight: 650; }
h2 { font-size: 14px; font-weight: 650; margin-bottom: 6px; }
h3 { font-size: 13px; font-weight: 650; margin: 10px 0 4px; }
p { margin: 0 0 5px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 8px 0; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.strong { font-weight: 600; }
.pre { white-space: pre-wrap; }
.nowrap { white-space: nowrap; }
.err-text { color: var(--err); }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.mr-auto { margin-right: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
tr.row-on td { background: var(--primary-soft); }
.dir-fs { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px 8px; margin: 8px 0; }
.dir-fs legend { padding: 0 4px; font-weight: 600; font-size: 13px; }
.dir-table td { vertical-align: top; }
.acc-access-log { margin: 6px 0 0; padding-left: 18px; }
.acc-access-log li { margin: 2px 0; }
.boot, .loading { padding: 24px; text-align: center; color: var(--muted); }

/* ---------- кнопки і поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 4px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: var(--err); filter: brightness(.92); }
.btn-danger-ghost { color: var(--err); border-color: transparent; background: transparent; }
.btn-danger-ghost:hover { background: var(--err-soft); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-xs { height: 22px; padding: 0 6px; font-size: 11.5px; border-radius: 3px; }
.btn-open { border-color: var(--primary); color: var(--primary); }
.btn-open:hover { background: var(--primary-soft); }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 4px; padding: 3px 7px; outline: none;
}
input, select { height: 28px; }
textarea { resize: vertical; min-height: 44px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
input[type=checkbox], input[type=radio] { width: 14px; height: 14px; padding: 0; margin: 0; accent-color: var(--primary); flex: none; cursor: pointer; }
label { display: block; font-weight: 550; margin-bottom: 7px; }
label > input, label > select, label > textarea { margin-top: 2px; font-weight: 400; }
label.check, label.radio { display: flex; gap: 6px; align-items: flex-start; font-weight: 450; cursor: pointer; }
label.check input, label.radio input { margin-top: 2px; }

/* ---------- каркас ---------- */
.topbar { --top-text: #b4bdcc; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 0 6px; min-height: 32px; padding: 0 8px;
  background: #1d2430; color: var(--top-text); font-size: 12.5px; }
.top-brand { display: flex; align-items: center; gap: 6px; flex: none; height: 32px; }
.top-brand .logo { width: 22px; height: 22px; border-radius: 4px; font-size: 10px; background: #2a3341; border-color: #3a4556; color: #fff; }
.top-brand .brand-ver { background: transparent; border-color: #3a4556; color: var(--top-text); padding: 0 5px; }
.top-brand .brand-ver:hover { color: #fff; border-color: #fff; }
.topnav { flex: 1 1 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0 2px; min-width: 0; }
.top-link { display: flex; align-items: center; gap: 5px; height: 32px; padding: 0 9px; border: 0; border-bottom: 2px solid transparent; border-top: 2px solid transparent;
  background: none; color: var(--top-text); font: inherit; font-weight: 500; white-space: nowrap; cursor: pointer; }
.top-link:hover { background: #2a3341; color: #fff; text-decoration: none; }
.top-link.on { background: #2b3a57; border-bottom-color: #6f93ff; color: #fff; font-weight: 600; }
.top-link .nav-ico { width: 14px; height: 14px; flex-basis: 14px; opacity: .85; }
.top-link .badge { min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; }
.subbar { position: sticky; top: 32px; z-index: 19; display: flex; flex-wrap: wrap; align-items: center; gap: 0 1px; min-height: 28px; padding: 0 8px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.sub-link { display: inline-flex; align-items: center; gap: 5px; height: 27px; padding: 0 8px; border-bottom: 2px solid transparent; border-top: 2px solid transparent;
  color: var(--muted); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.sub-link:hover { color: var(--text); text-decoration: none; }
.sub-link.on { border-bottom-color: var(--primary); color: var(--primary); font-weight: 600; }
.sub-link .nav-ico { width: 13px; height: 13px; flex-basis: 13px; }
.nav-sep { flex: none; width: 1px; height: 14px; margin: 0 5px; background: var(--border-strong); }
.top-foot { display: flex; align-items: center; gap: 6px; height: 32px; flex: none; white-space: nowrap; }
.top-foot .top-link { padding: 0 4px; }
.top-foot .top-bell { height: 22px; padding: 0 3px; color: inherit; }
.top-foot .top-bell:hover { background: #2a3341; }
.top-foot .top-bell.on { background: #2b3a57; }
.top-foot .top-bell .badge { top: -3px; right: -4px; min-width: 14px; height: 14px; padding: 0 3px; font-size: 9px; }
.top-user { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-out { border: 0; padding: 0; background: none; color: #8f9aab; font: inherit; font-size: 11.5px; cursor: pointer; }
.top-out:hover { color: #fff; text-decoration: underline; }
@media (max-width: 900px) { .topbar, .subbar { position: static; } }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.brand.big { font-size: 20px; justify-content: center; margin-bottom: 20px; }
.brand-ver { padding: 0 6px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 600; line-height: 16px; cursor: pointer; }
.brand-ver:hover { color: var(--primary); border-color: var(--primary); }
.login-ver { margin: 10px 0 0; text-align: center; }
.about-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.about-row > span:last-child { text-align: right; overflow-wrap: anywhere; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); color: var(--primary); border: 1px solid var(--border-strong); font-size: 12px; font-weight: 800; letter-spacing: .5px; }
.nav-ico { width: 18px; height: 18px; flex: 0 0 18px; color: inherit; }
.nav-txt { white-space: nowrap; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.user { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.page { padding: 7px 10px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; min-height: 28px; }
.page-head > :first-child { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.page-head > :not(:first-child) { flex: none; }
.page-head > input { width: 260px; }
.page-head h1 { flex: none; white-space: nowrap; }
.page-head p { flex: 1; min-width: 0; margin: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
.page-head p.open { white-space: normal; overflow: visible; }
.ap-filters { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 6px; }
.ap-filters > * { width: 100%; min-width: 0; margin: 0; }
@media (max-width: 1000px) { .ap-filters { grid-template-columns: 1fr 1fr; } .ap-filters > input { grid-column: 1 / -1; } }
@media (max-width: 640px) { .ap-filters { grid-template-columns: 1fr; } }
.cred-box { white-space: pre-wrap; word-break: break-all; margin: 8px 0 0; padding: 12px 14px; border-radius: var(--radius); background: var(--info-soft); font-size: 14px; user-select: all; }
.acc-sync { display: flex; flex-direction: row-reverse; align-items: center; gap: 8px; text-align: right; font-size: 12px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 10px; margin-bottom: 7px; }
.table-card { padding: 0; overflow: hidden; }

.notice { display: block; padding: 5px 9px; border-radius: var(--radius); margin-bottom: 7px; background: var(--info-soft); color: var(--text); border: 1px solid transparent; }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.notice-err { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.notice-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--text); }
a.notice:hover { text-decoration: none; filter: brightness(.98); }

.chip { display: inline-flex; align-items: center; gap: 3px; padding: 0 5px; border-radius: 3px; font-size: 11px; line-height: 16px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.chip-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip-err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.chip-hold { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

/* ---------- таблиці ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); padding: 3px 7px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 2px 7px; height: 26px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.card .table th { background: transparent; }
.card:not(.table-card) .table th:first-child, .card:not(.table-card) .table td:first-child { padding-left: 0; }
.table-hover tbody tr { cursor: pointer; }
.table-hover tbody tr:hover td { background: var(--surface-2); }
.table tr.selected td { background: var(--primary-soft); }
.table tr.dim td { opacity: .55; }
.col-check { width: 26px; }
.col-act { width: 32px; text-align: right; }
.empty-row { text-align: center; color: var(--muted); padding: 14px !important; }
.cell-line > div { display: inline; }
.cell-line > div + div { margin-left: 7px; }

.progress { display: inline-block; width: 44px; height: 6px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; vertical-align: middle; margin-right: 6px; }
.progress .bar { height: 100%; background: var(--primary); }

.filters { display: flex; flex-wrap: wrap; gap: 5px; padding: 5px; }
.filters > input[type=search] { flex: 2 1 190px; min-width: 150px; }
.msd { position: relative; flex: 1 1 115px; min-width: 100px; }
.msd-btn { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; height: 28px; padding: 0 7px;
  border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.msd-btn:hover { border-color: var(--primary); }
.msd.has .msd-btn { border-color: var(--primary); color: var(--primary); font-weight: 600; }
.msd-sum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msd-caret { color: var(--muted); font-size: 11px; flex: 0 0 auto; }
.msd-pop { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 70; display: flex; flex-direction: column;
  min-width: 210px; max-height: 340px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .18); overflow: hidden; }
.msd-search { flex: 0 0 auto; width: auto; margin: 5px 5px 3px; height: 26px; padding: 0 7px; border: 1px solid var(--border-strong); border-radius: 4px;
  background: var(--surface); color: var(--text); font: inherit; }
.msd-list { overflow-y: auto; padding: 2px 6px; }
.msd-opt { display: flex; align-items: center; gap: 6px; margin: 0; padding: 2px 5px; border-radius: 3px; cursor: pointer; font-size: 12.5px; font-weight: 450; }
.msd-opt:hover { background: var(--surface-2); }
.msd-opt input { flex: 0 0 auto; width: 14px; height: 14px; margin: 0; }
.msd-foot { border-top: 1px solid var(--border); padding: 6px; display: flex; justify-content: flex-end; }
.bulk { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 4px 6px; border-color: var(--primary); background: var(--primary-soft); }
.bulk select { width: auto; height: 26px; padding: 0 4px; font-size: 12px; }

/* ---------- огляд ---------- */
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 7px; }
.tile { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; color: var(--text); box-shadow: var(--shadow); }
.tile:hover { text-decoration: none; border-color: var(--border-strong); }
.tile-n { font-size: 19px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-l { color: var(--muted); font-size: 11px; margin-top: 1px; }
.tile-info .tile-n { color: var(--info); }
.tile-warn .tile-n { color: var(--warn); }
.tile-err .tile-n { color: var(--err); }
.tile-ok .tile-n { color: var(--ok); }

/* ---------- задачі працівника ---------- */
.tasks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); gap: 7px; margin-bottom: 8px; }
.task { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: var(--radius); padding: 7px 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 3px; transition: border-color .12s, background .12s; }
.task-done { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok-soft) 55%, var(--surface)); }
.task-error { border-left-color: var(--err); background: color-mix(in srgb, var(--err-soft) 55%, var(--surface)); }
.task-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.task-acc { display: flex; align-items: center; gap: 8px; min-width: 0; }
.task-acc-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-title { font-size: 14px; font-weight: 650; margin-top: 2px; }
.task-desc { white-space: pre-wrap; color: var(--text); margin: 0; }
.task-note { margin: 0; font-size: 13px; white-space: pre-wrap; }
.task-prev { margin: 0; font-size: 13px; color: var(--err); }
.task-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.video-link { font-weight: 600; }
.task-comment { margin-top: 4px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg-btn { height: 26px; padding: 0 9px; border: 0; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border-strong); }
.seg-btn:hover { background: var(--surface-2); }
.seg-done.on { background: var(--ok); color: #fff; }
.seg-err.on { background: var(--err); color: #fff; }

.confirm-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 15;
  display: flex; align-items: center; gap: 16px; padding: 10px 10px 10px 18px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.confirm-bar .btn { height: 30px; padding: 0 14px; font-size: 13px; }

.empty { text-align: center; padding: 20px 12px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); margin-bottom: 20px; }
.empty-title { font-size: 14px; font-weight: 650; margin-bottom: 3px; }
/* зв'язок пропав: пояснення і кнопка «Підключитись» під помилкою */
.offline-hint { max-width: 520px; margin: 8px auto 0; }
.offline-btn { margin-top: 14px; }
.offline-status { margin-top: 8px; min-height: 1em; }

/* ---------- сценарії: щільний адмінський вигляд (список ліворуч, кроки — таблицею) ---------- */
.sc-pagehead { margin-bottom: 6px; }
.sc-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 7px; align-items: start; }
.sc-list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }
.sc-list-head { display: flex; justify-content: space-between; padding: 7px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.sc-item { display: flex; flex-direction: column; gap: 0; min-width: 0; text-align: left; padding: 3px 8px; border: 0; border-left: 2px solid transparent;
  border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.sc-item:last-child { border-bottom: 0; }
.sc-item:hover { background: var(--surface-2); text-decoration: none; }
.sc-item-quests { border-bottom: 2px solid var(--border-strong); }
.sc-layout-narrow { grid-template-columns: 158px minmax(0, 1fr); }
.side-main { min-width: 0; }
.view-tabs { flex: none; display: inline-flex; align-self: center; border: 1px solid var(--border-strong); border-radius: 4px; overflow: hidden; }
.view-tab { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; background: var(--surface); color: var(--muted); font-size: 12px; white-space: nowrap; }
.view-tab + .view-tab { border-left: 1px solid var(--border-strong); }
.view-tab:hover { color: var(--text); text-decoration: none; }
.view-tab.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.view-tab .chip { line-height: 14px; }
.dy-month { width: 140px; }
.dy-rules { margin: 0 0 6px; }
.dy-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 7px; }
.dy-add input[name=name] { width: 260px; }
.dy-add input[name=rating] { width: 110px; }
.dy-add select { width: 180px; }
.dy-add .btn { flex: none; }
.dy-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px 7px; border-bottom: 1px solid var(--border); }
.dy-search { width: 240px; }
.dy-filter { width: 180px; }
.table th.num-cell, .table td.num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.inc-filter { width: 170px; }
.inc-worker td { background: var(--surface-2); font-weight: 600; }
.inc-month td:first-child { padding-left: 22px; }
.tm-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 6px 8px 4px; }
.tm-head h2 { margin: 0; }
.tm-head .btn { margin-left: auto; }
.tm-spent { white-space: nowrap; }
.tm-bar { display: inline-block; width: 120px; height: 8px; margin-right: 8px; border-radius: 0 4px 4px 0; background: var(--surface-2); vertical-align: middle; overflow: hidden; }
.tm-bar i { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--primary); }
.tm-days tbody tr.selected td { box-shadow: inset 0 1px 0 var(--primary), inset 0 -1px 0 var(--primary); }
.tm-total td { border-top: 1px solid var(--border-strong); background: var(--surface-2); font-weight: 600; }
.tiles.tm-tiles { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .tiles.tm-tiles { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .tm-bar { width: 60px; } }
.inc-h { font-size: 13px; margin: 8px 0 3px; }
.inc-h:first-child { margin-top: 0; }
.dy-table .dy-rate { width: 96px; height: 22px; padding: 1px 6px; text-align: right; }
.dy-table .dy-worker { width: 150px; height: 22px; padding: 0 4px; }
.dy-settings { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 6px; }
.dy-settings label { margin: 0; }
.dy-settings input { width: 90px; display: block; }
.dy-settings .btn { flex: none; }
.dy-settings .muted { flex: 1; min-width: 220px; align-self: center; }
.dy-rename { display: flex; gap: 6px; margin-bottom: 7px; }
.dy-rename .btn { flex: none; }
.sc-item.on { background: var(--primary-soft); border-left-color: var(--primary); }
.sc-item-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.sc-item-meta { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; line-height: 1.3; color: var(--muted); }
.sc-item-meta b { color: var(--text); font-weight: 600; }
.sc-list-empty { margin: 0; padding: 10px 12px; }

.sc-editor { --st-cols: 14px 28px minmax(0, 1fr) 62px 300px 104px 76px;
  min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.sc-empty { display: flex; flex-direction: column; gap: 2px; padding: 22px 16px; text-align: center; font-size: 13px; border-bottom: 1px solid var(--border); }
.sce-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.sce-titles { flex: 1; min-width: 0; display: grid; gap: 1px; }
.sc-name, .sc-desc { margin: 0 0 0 -7px; padding: 1px 6px; border-color: transparent; background: transparent; border-radius: 6px; }
.sc-name { height: 30px; font-size: 16px; font-weight: 650; }
.sc-desc { height: 24px; font-size: 12.5px; color: var(--muted); }
.sc-name:hover, .sc-desc:hover { border-color: var(--border); }
.sc-name:focus, .sc-desc:focus { background: var(--surface); color: var(--text); }
.sce-acts { display: flex; gap: 6px; flex: none; padding-top: 1px; }
.sce-icon { width: 32px; padding: 0; font-size: 14px; color: var(--muted); }
.sce-icon:hover { color: var(--text); }
.sce-del:hover { color: var(--err); border-color: var(--err); background: var(--err-soft); }
.sce-bar { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; padding: 5px 12px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 12.5px; }
.sce-tools { display: flex; gap: 6px; align-items: center; }
.sce-tools .btn-xs, .sce-bulk > summary { height: 26px; padding: 0 9px; font-weight: 500; }
.sce-bulk { position: relative; }
.sce-bulk > summary { list-style: none; }
.sce-bulk > summary::-webkit-details-marker { display: none; }
.sce-bulk[open] > summary { border-color: var(--primary); color: var(--primary); }
.sce-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  min-width: 240px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow-lg); }
.dur { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.dur input { width: 52px; height: 28px; padding: 2px 6px; text-align: right; font-size: 13px; }
.dur span { color: var(--muted); font-size: 12px; }

.sce-cols { display: grid; grid-template-columns: var(--st-cols); gap: 8px; align-items: center; padding: 5px 12px; border-bottom: 1px solid var(--border);
  font-size: 10.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.st-row { border-bottom: 1px solid var(--border); background: var(--surface); }
.st-row:hover { background: var(--surface-2); }
.st-row.open { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--primary); }
.st-row.dragging { opacity: .35; }
.st-row.drop-before { box-shadow: inset 0 2px 0 var(--primary); }
.st-row.drop-after { box-shadow: inset 0 -2px 0 var(--primary); }
.st-row.st-invalid .st-title, .st-row.st-bad-video [data-f=video_url] { border-color: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.st-top { display: grid; grid-template-columns: var(--st-cols); gap: 8px; align-items: center; min-height: 28px; padding: 1px 10px; }
.st-price-in, .lib-price-in { width: 100%; height: 22px; padding: 0 4px; font-family: var(--mono); font-size: 12px; text-align: right; border-color: var(--border); border-radius: 3px; -moz-appearance: textfield; }
.st-price-in::-webkit-inner-spin-button, .lib-price-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.st-handle { cursor: grab; color: var(--border-strong); font-size: 12px; font-weight: 700; letter-spacing: -2px; user-select: none; }
.st-row:hover .st-handle { color: var(--muted); }
.st-pos { width: 28px; height: 26px; padding: 0; text-align: center; font-size: 12px; font-weight: 650; color: var(--muted);
  background: transparent; border-color: transparent; border-radius: 5px; -moz-appearance: textfield; }
.st-pos:hover { border-color: var(--border); background: var(--surface); }
.st-pos::-webkit-inner-spin-button, .st-pos::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.st-title { min-width: 0; height: 28px; padding: 2px 8px; font-size: 13.5px; font-weight: 550; background: transparent; border-color: transparent; border-radius: 6px; }
.st-title:hover { border-color: var(--border); background: var(--surface); }
.st-title:focus { background: var(--surface); }
.st-flags { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; min-width: 0; min-height: 26px; padding: 2px 6px; border: 1px solid transparent;
  border-radius: 6px; background: transparent; color: var(--muted); font: inherit; text-align: left; cursor: pointer; }
.st-flags:hover { border-color: var(--border-strong); background: var(--surface); }
.st-flag { padding: 0 5px; font-size: 11px; line-height: 18px; white-space: nowrap; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.st-flags-empty { font-size: 12px; color: var(--muted); }
.st-caret { margin-left: auto; padding-left: 4px; font-size: 10px; color: var(--muted); transition: transform .12s; }
.st-row.open .st-caret { transform: rotate(180deg); color: var(--primary); }
.st-delay { display: inline-flex; align-items: center; gap: 3px; }
.st-delay input { width: 36px; height: 26px; padding: 2px 5px; font-size: 12.5px; text-align: right; border-color: var(--border); border-radius: 5px; -moz-appearance: textfield; }
.st-delay input::-webkit-inner-spin-button, .st-delay input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.st-delay span { font-size: 11px; color: var(--muted); }
.st-acts { display: flex; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
.st-row:hover .st-acts, .st-row:focus-within .st-acts, .st-row.open .st-acts { opacity: 1; }
@media (hover: none) { .st-acts { opacity: 1; } }
.st-act { display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 5px; background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.st-act:hover:not(:disabled) { background: var(--border); color: var(--text); }
.st-act:disabled { opacity: .3; cursor: default; }
.st-act-del:hover:not(:disabled) { background: var(--err-soft); color: var(--err); }
.st-adv { display: none; padding: 2px 12px 10px 62px; }
.st-row.open .st-adv { display: block; }
.st-desc { width: 100%; min-height: 30px; height: auto; max-height: 200px; padding: 5px 8px; font-size: 13px; field-sizing: content; resize: vertical; }
.sce-add, .sce-add-auto { display: block; width: 100%; padding: 8px 12px; border: 0; border-radius: 0 0 8px 8px; background: transparent; color: var(--primary);
  font: inherit; font-size: 13px; font-weight: 550; text-align: left; cursor: pointer; }
.sce-add:hover, .sce-add-auto:hover { background: var(--primary-soft); }
.savebar { position: sticky; bottom: 12px; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center;
  margin: 0 8px 8px; padding: 7px 10px 7px 14px; font-size: 13px; background: var(--surface); border: 1px solid var(--primary); border-radius: 8px; box-shadow: var(--shadow-lg); }

/* ---------- картка акаунта ---------- */
.acc-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.acc-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 12px; }
.acc-grid h3 { margin-top: 0; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: st; }
.steps li { counter-increment: st; display: flex; align-items: center; gap: 7px; padding: 2px 0; border-bottom: 1px solid var(--border); }
.steps li:last-child { border-bottom: 0; }
.steps li::before { content: counter(st); flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.steps li.st-done::before { content: "✓"; background: var(--ok); border-color: var(--ok); color: #fff; }
.steps li.st-skip::before { content: "–"; }
.steps li.st-cur::before { background: var(--info); border-color: var(--info); color: #fff; }
.steps li.st-wait::before { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.steps li.st-err::before { content: "!"; background: var(--err); border-color: var(--err); color: #fff; }
.step-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.step-title { font-weight: 550; }

/* ---------- модальні вікна ---------- */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(10, 14, 22, .45); display: flex; align-items: flex-start; justify-content: center; padding: 3vh 12px 12px; overflow-y: auto; }
.modal { width: 100%; max-width: 520px; background: var(--surface); border-radius: 6px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal-wide { max-width: 980px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-body { padding: 9px 12px; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 6px; padding: 7px 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.imp-list { margin-top: 14px; max-height: 50vh; overflow: auto; }

/* ---------- сповіщення ---------- */
#toasts { position: fixed; top: 64px; right: 10px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: 6px 10px; border-radius: 5px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--ok); box-shadow: var(--shadow-lg); transition: opacity .4s, transform .4s; }
.toast-err { border-left-color: var(--err); }
.toast-warn { border-left-color: var(--warn); }
.toast-info { border-left-color: var(--info); }
.toast.hide { opacity: 0; transform: translateX(20px); }

/* ---------- вхід ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; padding: 28px; }
.login .btn { width: 100%; height: 32px; margin-top: 2px; }

/* ---------- GEO-групи ---------- */
.geo-row { display: grid; grid-template-columns: minmax(140px, 240px) minmax(0, 320px) 40px; gap: 8px; margin-bottom: 8px; }
.geo-head { margin-bottom: 4px; }
.chip-geo { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

/* ---------- банер нової версії програми ---------- */
.update-bar { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; padding: 3px 10px;
  background: var(--warn-soft); border-bottom: 1px solid var(--warn, #e0a528); font-size: 13px; animation: update-pulse 1.8s ease-in-out infinite; }
@keyframes update-pulse { 0%, 100% { filter: none; } 50% { filter: brightness(1.06); } }
@media (prefers-reduced-motion: reduce) { .update-bar { animation: none; } }

/* ---------- головна: завантаження програми ---------- */
.landing { width: 100%; max-width: 600px; }
.dl-card { padding: 28px; }
.dl-card h1 { margin-bottom: 6px; }
.dl-box { margin: 18px 0 4px; }
.dl-box .btn { height: 48px; padding: 0 26px; font-size: 16px; margin-bottom: 8px; }
.dl-box a.btn:hover { text-decoration: none; }
.dl-steps { padding-left: 20px; margin: 16px 0; display: grid; gap: 10px; }
.landing-admin { text-align: center; margin-top: 4px; }
.share-box { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- адаптив ---------- */
@media (max-width: 1000px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .acc-grid, .grid2, .grid3 { grid-template-columns: 1fr; }
  .sc-layout { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .geo-row { grid-template-columns: minmax(0, 1fr) 40px; }
  .geo-row .geo-scenario { grid-column: 1; }
  .geo-head { display: none; }
}
@media (max-width: 760px) {
  .sc-editor { --st-cols: 14px 28px minmax(0, 1fr) auto; }
  .sce-cols { display: none; }
  .st-top { row-gap: 2px; padding: 5px 10px; }
  .st-price-in { grid-column: 3; grid-row: 3; width: 70px; }
  .st-delay { grid-column: 4; grid-row: 1; }
  .st-flags { grid-column: 3; grid-row: 2; }
  .st-acts { grid-column: 4; grid-row: 2; opacity: 1; }
  .st-adv { padding-left: 12px; }
  .st-opts { grid-template-columns: 1fr 1fr; }
  .sce-head { flex-direction: column; }
}
@media (max-width: 640px) {
  .page-head { flex-wrap: wrap; }
  .page-head > :first-child { flex-basis: 100%; }
  .acc-sync { flex-direction: column; align-items: flex-start; text-align: left; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tasks { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: 1fr; }
  .confirm-bar { left: 16px; right: 16px; transform: none; justify-content: space-between; }
  #toasts { top: auto; bottom: 92px; left: 16px; right: 16px; max-width: none; }
  .modal-back { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; }
}

/* ---------- ціна кроку в редакторі сценарію ---------- */
.st-pay { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.st-pay input { width: 110px; height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-family: var(--mono); }

/* ---------- робочий стіл: спільний пул задач ---------- */
.wk { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto;
  gap: 7px; align-items: stretch; height: calc(100vh - 82px); min-height: 440px; margin-bottom: 8px; }
.page:has(> .wk) { padding-bottom: 8px; }
.wk-list { grid-column: 1; grid-row: 1 / span 2; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow-y: auto; min-height: 0; }
.wk-list-head { padding: 4px 6px 4px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1;
  display: flex; align-items: center; gap: 10px; }
.wk-list-title { flex: 1; min-width: 0; }
.wk-swap { flex: 0 0 auto; display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--primary); background: var(--primary-soft); color: var(--primary); }
.wk-swap:hover { background: var(--primary); color: #fff; }
.wk-swap:disabled { cursor: wait; }
.wk-swap svg { width: 14px; height: 14px; }
.wk-swap.busy svg { animation: wk-spin .8s linear infinite; }
@keyframes wk-spin { to { transform: rotate(360deg); } }
.wk-item { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); background: var(--surface);
  padding: 5px 10px; cursor: pointer; font: inherit; color: var(--text); }
.wk-item:last-child { border-bottom: 0; }
.wk-item:hover { background: var(--surface-2); }
.wk-item.on { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.wk-item-top { display: flex; align-items: center; gap: 8px; }
.wk-acc { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wk-price { margin-left: auto; font-family: var(--mono); font-weight: 700; color: var(--ok); background: var(--ok-soft);
  padding: 1px 8px; border-radius: 7px; font-size: 13px; white-space: nowrap; }
.wk-item-bot { display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.wk-item-title { flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-item-meta { display: flex; gap: 4px; margin: 0; flex: none; }
.chip-fin { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.wk-detail { grid-column: 2; grid-row: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px; min-width: 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.wk-detail > * { flex-shrink: 0; }
.wk-report { margin-top: auto; padding-top: 12px; display: flex; flex-wrap: wrap; gap: 6px 22px; }
.wk-report[hidden] { display: none; }
.wk-report-btn { padding: 4px 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 3px; }
.wk-report-btn:hover { color: var(--err); }
.wk-report-btn.wk-postpone-btn:hover { color: var(--warn); }
.wk-after-start { margin: 10px 0 0; padding: 7px 10px; border-radius: 8px; background: var(--info-soft); color: var(--info); }
.wk-empty { text-align: center; color: var(--muted); padding: 24px 12px; }
.wk-empty .empty-title { color: var(--text); margin-bottom: 6px; }
.wk-d-head { display: flex; align-items: flex-start; gap: 14px; }
.wk-d-acc { font-weight: 700; font-size: 15px; }
.wk-d-pay { margin-left: auto; text-align: right; }
.wk-d-pay .k { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.wk-d-pay .v { font-family: var(--mono); font-weight: 700; font-size: 16px; color: var(--ok); }
.wk-d-title { font-size: 16px; margin: 6px 0 0; }
.wk-card { margin-top: 8px; }
.wk-card-h { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.wk-video { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; font-weight: 600; color: var(--primary);
  background: var(--primary-soft); padding: 3px 8px; border-radius: 4px; }
.wk-video:hover { text-decoration: none; filter: brightness(.98); }
.wk-actions { margin-top: 10px; }
.wk-actions .btn-lg { height: 34px; padding: 0 14px; font-size: 13px; font-weight: 650; }
.wk-done-row { display: flex; gap: 10px; }
.wk-done-row .btn { flex: 1; }
.wk-done-row .wk-cancel-btn { flex: 0 0 auto; border-color: var(--err); }
/* тестовий прогін (адмін): зліва — крок і акаунт, справа — картка завдання, як у працівника */
.tr-pick { display: flex; flex-direction: column; gap: 6px; padding: 10px; overflow: hidden; }
.tr-field { display: flex; flex-direction: column; gap: 4px; margin: 0; font-size: 13px; font-weight: 600; }
.tr-field select, .tr-pick input { width: 100%; margin: 0; }
.tr-pick label[for] { flex-direction: row; align-items: baseline; gap: 6px; margin-top: 4px; }
.tr-acc { flex: 1; min-height: 160px; width: 100%; margin: 0; padding: 2px; }
.tr-note { margin: 0 0 8px; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--text); font-size: 12.5px; }
.wk-report-btn.tr-reset-btn:hover { color: var(--primary); }
.tr-pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12.5px; }
.tr-res th { width: 32%; vertical-align: top; text-align: left; color: var(--muted); font-weight: 600; }
.wk-input { margin-bottom: 12px; display: flex; flex-direction: column; gap: 5px; }
.wk-input textarea { width: 100%; min-height: 56px; resize: vertical; border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 9px 11px; font: inherit; background: var(--surface); color: var(--text); }
.wk-input textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.wk-email { margin-bottom: 12px; }
.wk-email-out { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--ok-soft); border-radius: 10px; padding: 10px 14px; font-size: 15px; }
.wk-email-combo { font-family: var(--mono); font-size: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 5px 9px; cursor: pointer; user-select: all; }
.wk-email-combo:hover { border-color: var(--primary); }
.wk-gen { margin-bottom: 12px; }
.wk-geo-pick { display: flex; flex-direction: column; gap: 5px; max-width: 320px; margin-bottom: 8px; font-size: 13px; }
.wk-gen-out { display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); border-radius: 10px; padding: 10px 14px; }
.wk-gen-row { display: flex; align-items: center; gap: 10px; }
.wk-gen-k { min-width: 92px; color: var(--muted); font-size: 13px; }
.wk-gen-v { flex: 1; font-family: var(--mono); font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 5px 9px; cursor: pointer; user-select: all; }
.wk-gen-v:hover { border-color: var(--primary); }
#em-text { padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 13px; resize: vertical; }
#em-text:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: var(--ok); filter: brightness(.95); }
.wk-err textarea { width: 100%; min-height: 64px; resize: vertical; border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 9px 11px; font: inherit; background: var(--surface); color: var(--text); margin-bottom: 10px; }
.wk-foot { grid-column: 2; grid-row: 2; display: flex; gap: 22px; align-items: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 5px 10px; flex-wrap: wrap; }
/* Рейтинг над завданнями: хто більше виконав за період */
.page-head > .wk-board { flex: 0 1 auto; min-width: 0; display: flex; flex-flow: row wrap; justify-content: flex-end; align-items: center; gap: 4px 6px;
  white-space: nowrap; cursor: default; }   /* в один рядок; тісно — спершу коротшає підпис, місця ніколи не обрізаються */
.wk-board-h { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.wk-board-p { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.wk-board-p b { max-width: 130px; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.wk-board-p.me { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 35%, transparent); }
.wk-board-n { font-family: var(--mono); font-weight: 700; color: var(--ok); }
@media (max-width: 1100px) {        /* вузько: рейтинг окремим рядком під заголовком, місця переносяться */
  .page-head:has(> .wk-board) { flex-wrap: wrap; }
  .page-head > .wk-board { order: 3; flex-basis: 100%; justify-content: flex-start; }
}
@media (min-width: 761px) and (max-width: 1100px) {   /* рядок рейтингу забирає місце в списку завдань на висоту екрана */
  .page-head:has(> .wk-board) + .wk { height: calc(100vh - 121px); }
}
.wk-stat { display: flex; flex-direction: column; }
.wk-stat .k { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.wk-stat .v { font-family: var(--mono); font-weight: 700; font-size: 15px; }
.wk-upcoming { margin-top: 8px; }
@media (max-width: 760px) {
  .wk { grid-template-columns: 1fr; grid-template-rows: none; height: auto; }
  .wk-list { grid-column: 1; grid-row: auto; max-height: 50vh; }
  .wk-detail { grid-column: 1; grid-row: auto; }
  .wk-foot { grid-column: 1; grid-row: auto; }
}

/* ---------- кроки з бібліотеки в сценарії ---------- */
.st-name { display: flex; align-items: center; gap: 4px; min-width: 0; }
.st-name .st-title { flex: 1; }
.st-shared { flex: none; padding: 0 5px; font-size: 11px; line-height: 18px; border-radius: 4px; color: var(--info); background: var(--info-soft); white-space: nowrap; }
.st-shared:hover { text-decoration: none; filter: brightness(.95); }
.st-libnote { margin: 0 0 6px; padding: 5px 8px; font-size: 12px; border-radius: 6px; color: var(--text); background: var(--info-soft); }

/* вікно «Додати кроки» */
.pk-search { height: 34px; margin-bottom: 8px; }
.pk-list { max-height: 52vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.pk-row { display: grid; grid-template-columns: 16px 18px minmax(0, 1fr) auto 110px; gap: 8px; align-items: center; margin: 0; padding: 6px 10px;
  border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 450; cursor: pointer; }
.pk-row:last-child { border-bottom: 0; }
.pk-row:hover { background: var(--surface-2); }
.pk-row.on { background: var(--primary-soft); }
.pk-num { font-size: 11px; font-weight: 700; color: var(--primary); text-align: center; }
.pk-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.pk-flags { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.pk-used { text-align: right; white-space: nowrap; }
.pk-new { display: block; width: 100%; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface-2);
  color: var(--primary); font: inherit; font-size: 13px; font-weight: 550; text-align: left; cursor: pointer; }
.pk-new:hover { background: var(--primary-soft); }

/* сторінка «Кроки» (бібліотека) */
.lib-table { --lib-cols: minmax(0, 1.5fr) 62px 300px minmax(0, 1fr) 56px; }
.lib-search { width: 260px; max-width: 100%; height: 28px; padding: 2px 10px; font-size: 13px; }
.lib-cols, .lib-row { display: grid; grid-template-columns: var(--lib-cols); gap: 10px; align-items: center; padding: 2px 10px; }
.lib-cols { padding: 3px 10px; border-bottom: 1px solid var(--border); font-size: 10.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.lib-item { border-bottom: 1px solid var(--border); }
.lib-item:last-child { border-bottom: 0; }
.lib-item.open { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--primary); }
.lib-row { min-height: 26px; cursor: pointer; }
.lib-row:hover { background: var(--surface-2); }
.lib-row:hover .st-acts, .lib-item.open .st-acts { opacity: 1; }
.lib-row-new { cursor: default; }
.lib-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13.5px; }
.lib-text { flex: 1; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.lib-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lib-text > :first-child { flex: 0 1 auto; max-width: 75%; }
.lib-text > .lib-desc { flex: 1 1 0; }
.lib-caret { flex: none; width: 12px; font-size: 11px; color: var(--muted); transition: transform .12s; }
.lib-item.open .lib-caret { transform: rotate(90deg); color: var(--primary); }
.lib-desc { font-size: 12px; color: var(--muted); }
.lib-flags { display: flex; flex-wrap: wrap; gap: 3px; }
.lib-used { display: flex; flex-wrap: wrap; gap: 3px; min-width: 0; }
.lib-sc { max-width: 100%; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: inherit; font-size: 11.5px; line-height: 19px;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
.lib-sc:hover { border-color: var(--primary); color: var(--primary); }
.lib-adv { display: none; padding: 2px 12px 12px 30px; }
.lib-item.open .lib-adv { display: block; }
.lib-adv > .st-opt { margin-bottom: 6px; }
.lib-title-opt input { font-weight: 600; }
.lib-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.lib-foot > .muted { margin-right: auto; }
@media (max-width: 760px) {
  .lib-table { --lib-cols: minmax(0, 1fr) 56px; }
  .lib-cols { display: none; }
  .lib-flags, .lib-used, .lib-price-in { grid-column: 1; }
  .lib-price-in { width: 70px; }
  .lib-acts { grid-column: 2; grid-row: 1; opacity: 1; }
  .lib-adv { padding-left: 12px; }
  .pk-row { grid-template-columns: 16px 18px minmax(0, 1fr); }
  .pk-flags, .pk-used { grid-column: 3; justify-content: flex-start; text-align: left; }
}

/* ---------- склад: ресурси й генератори ---------- */
.stk-table { --stk-cols: minmax(0, 1.6fr) repeat(4, 92px) 92px; }
.stk-table .sce-bar { justify-content: flex-start; gap: 10px; }
.stk-cols, .stk-row { display: grid; grid-template-columns: var(--stk-cols); gap: 10px; align-items: center; padding: 2px 10px; }
.stk-cols { padding: 3px 10px; border-bottom: 1px solid var(--border); font-size: 10.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.stk-cols span:not(:first-child), .stk-n { text-align: right; }
.stk-n { font-variant-numeric: tabular-nums; font-size: 13px; }
.stk-add textarea { width: 100%; margin: 0; font-size: 12.5px; }
.stk-items { margin-top: 10px; max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.stk-items > p { padding: 8px 10px; }
.stk-items-t { font-size: 12.5px; }
.stk-items-t th, .stk-items-t td { padding: 4px 10px; }
.stk-items-t td.mono { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stk-rename { width: 220px; height: 26px; padding: 2px 8px; font-size: 12.5px; }
.gen-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px 150px; gap: 10px; align-items: center; padding: 2px 10px; }
.gen-row > span { text-align: right; }
.gf-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.gf-row { display: grid; grid-template-columns: minmax(0, 1fr) 190px 112px minmax(0, 1.6fr) 24px; gap: 8px; align-items: start; }
.gf-count-l { display: flex; align-items: center; gap: 5px; height: 28px; margin: 0; font-size: 12px; font-weight: 400; color: var(--muted); }
.gf-count-l .gf-count { width: 58px; margin: 0; }
.gf-cfg > .muted { display: block; line-height: 28px; }
.gen-fields { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; margin-bottom: 8px; }
.gen-fields-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.gen-fields-foot .gf-add { margin-right: auto; }
.gf-row input, .gf-row select { height: 28px; margin: 0; padding: 2px 8px; font-size: 12.5px; }
.gf-cfg textarea { width: 100%; margin: 0; min-height: 28px; font-size: 12px; field-sizing: content; max-height: 160px; }
.gf-cfg .dur input { width: 64px; }
.gf-add { border-radius: 6px; padding: 6px 2px; }
.gen-try:not(:empty) { margin-top: 8px; }
.gen-try .notice { margin: 0; }
.gf-invalid { border-color: var(--err) !important; box-shadow: 0 0 0 3px var(--err-soft) !important; }
.st-opts-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 170px; }
/* повідомлення адміну */
.top-bell { position: relative; }
.top-bell .badge { position: absolute; top: -4px; right: -6px; }
.nt-list { padding: 0; overflow: hidden; }
.nt-item { display: flex; align-items: center; gap: 7px; padding: 3px 10px; border-top: 1px solid var(--border); border-left: 3px solid transparent; }
.nt-item:first-child { border-top: 0; }
.nt-item.nt-err { border-left-color: var(--err); }
.nt-item.nt-critical { border-left-color: var(--err); background: var(--err-soft); }
.nt-item.nt-warn { border-left-color: var(--warn); }
.nt-item.nt-info { border-left-color: var(--info); }
.nt-item:not(.nt-read) { background: var(--primary-soft); }
.nt-item.nt-read { opacity: .7; }
.nt-item.nt-resolved { opacity: .55; background: transparent; }
.nt-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.acc-assign { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.nt-ico { font-size: 16px; width: 20px; text-align: center; }
.nt-body { flex: 1; min-width: 0; }
.nt-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.wk-name-input input { width: 100%; }

/* позначки акаунта й періодичні завдання */
.chip-periodic { background: var(--info-soft); color: var(--info); border-color: transparent; }
.chip-mark { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.wk-marks { position: relative; display: inline-block; }
.wk-marks-pop { position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 30; min-width: 280px; max-width: 360px;
  padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-lg); }
.wk-marks-pop[hidden] { display: none; }
.marks-menu-h { margin-bottom: 6px; }
.marks-opt { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 6px 4px; border-radius: 6px; cursor: pointer; font-weight: 450; }
.marks-opt:hover { background: var(--primary-soft); }
.marks-opt input { margin-top: 3px; }
.marks-hint { display: block; font-weight: 400; }
.acc-marks { margin: 14px 0; }
.acc-marks-list { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 8px; }
.acc-marks-list .check { font-weight: 500; }
.mk-list { --lib-cols: minmax(0, 1fr) 140px; }
.mk-row > span { text-align: right; }
.wk-report-btn.wk-marks-btn:hover { color: var(--primary); }

/* ---------- регулярні завдання: редактор ---------- */

.mk-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px; }
.mk-tasks-h { margin: 10px 0 4px; }
.mt-list { display: flex; flex-direction: column; gap: 6px; }
.mt-system .st-act-del { display: none; }
.mt-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mt-row .mt-lib { flex: 1 1 260px; min-width: 0; height: 30px; margin: 0; padding: 2px 8px; font-size: 13px; }
.mt-every { display: inline-flex; align-items: center; gap: 4px; }
.mt-every input { width: 52px; height: 28px; margin: 0; padding: 2px 6px; text-align: right; font-family: var(--mono); font-size: 12.5px; }
.mt-every > span:not(.muted) { font-size: 11px; color: var(--muted); }
@media (max-width: 760px) { .mk-head { grid-template-columns: 1fr; } }
.wk-gender { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; }
.wk-gender.wk-gender-need { border-color: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.wk-gender-opt { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 5px 12px; border: 1px solid var(--border);
  border-radius: 999px; font-weight: 500; cursor: pointer; }
.wk-gender-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.wk-gender-opt input { margin: 0; }
.wk-gen-btn { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wk-gen-geo { width: auto; min-width: 200px; margin: 0; }
.gen-unsaved { margin-left: 6px; font-size: 11px; font-weight: 500; vertical-align: 2px; }
.gen-unsaved[hidden] { display: none; }
.gen-name-row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 8px; }
.gen-name-row .st-opt { flex: 1; max-width: 420px; }
.st-min-in { display: flex; align-items: center; gap: 4px; }
.st-opt .st-min-in input { width: 56px; padding: 2px 6px; text-align: right; font-family: var(--mono); }
.st-min-in > span { font-size: 11px; color: var(--muted); }
.wk-min-note { margin: 8px 0 0; }
p.wk-min-note:not(.muted) { padding: 7px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); }
.btn[data-min-until] { opacity: .75; cursor: not-allowed; font-variant-numeric: tabular-nums; }
.wk-gen-btn { margin: 10px 0 6px; }
@media (max-width: 760px) {
  .stk-table { --stk-cols: minmax(0, 1fr) 56px 56px; }
  .stk-cols span:nth-child(n+4), .stk-row > .stk-n:nth-child(n+4) { display: none; }
  .gen-row { grid-template-columns: minmax(0, 1fr); }
  .gen-row > span { text-align: left; }
  .gf-row { grid-template-columns: minmax(0, 1fr) 24px; }
  .gf-row .gf-type, .gf-row .gf-cfg, .gf-row .gf-count-l { grid-column: 1; }
  .gf-row .st-act { grid-column: 2; grid-row: 1; }
  .st-opts-2 { grid-template-columns: 1fr 1fr; }
}

/* ---------- налаштування кроку сценарію (розгорнутий рядок) ---------- */
.st-opts { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.3fr) minmax(0, 1fr) 84px; gap: 8px; margin-top: 6px; }
.st-opt { display: flex; flex-direction: column; gap: 2px; min-width: 0; margin: 0; font-weight: 450; }
.st-opt > span { font-size: 11px; color: var(--muted); }
.st-opt input, .st-opt select { height: 28px; margin: 0; padding: 2px 8px; font-size: 12.5px; border-radius: 6px; }
.st-opt .st-num { font-family: var(--mono); }
.st-checks { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-top: 8px; }
.st-check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; font-weight: 450; cursor: pointer; }
.st-id { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* ---------- вкладка «Статуси» ---------- */
.st-grid { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 14px; align-items: start; }
.stage-list { margin: 0; }
.stage-opts { display: flex; align-items: center; gap: 4px; min-width: 0; }
.stage-row { display: grid; grid-template-columns: minmax(150px, 1.25fr) minmax(100px, 1fr) minmax(100px, 1fr) 116px 112px 50px; gap: 6px; align-items: center; min-height: 28px; padding: 1px 8px; border-top: 1px solid var(--border); font-size: 12.5px; }
.stage-info { margin-left: 6px; font-weight: 400; font-size: 11px; }
.stage-flags label { display: flex; align-items: center; gap: 4px; margin: 0; font-weight: 400; white-space: nowrap; }
.stage-flags input[type=checkbox] { margin: 0; flex: 0 0 auto; }
.lnk-days { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.lnk-days-in { width: 44px; height: 22px; padding: 0 4px; font-size: 12px; }
.lnk-send { display: flex; gap: 3px; align-items: center; }
.lnk-count { width: 38px; height: 22px; padding: 0 3px; font-size: 12px; }
.lnk-send .btn { padding: 0 5px; }
.stage-cost { text-align: right; font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.stage-cost .muted { font-family: var(--font); font-weight: 400; font-size: 11px; }
.stage-head > span:last-child { text-align: right; }
.stage-add-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 8px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.stage-name { position: relative; }
.stf-acts { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: inline-flex; gap: 1px; padding-left: 4px; background: var(--surface-2); visibility: hidden; }
.stage-row:hover .stf-acts, .stf-acts:focus-within { visibility: visible; }
.stf-act { border: 0; background: transparent; color: var(--muted); padding: 0 3px; font: inherit; font-size: 12px; line-height: 16px; cursor: pointer; border-radius: 4px; }
.stf-act:hover:not(:disabled) { background: var(--surface); color: var(--primary); }
.stf-act:disabled { opacity: .3; cursor: default; }
.stf-del:hover:not(:disabled) { color: var(--err); }
.stage-name { white-space: normal; }
.bk-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.sys-errors { max-height: 240px; overflow: auto; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-family: var(--mono); font-size: 11px; white-space: pre-wrap; }
.stage-head { border-top: 0; min-height: 0; padding-top: 3px; padding-bottom: 3px; background: var(--surface-2); font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .03em; }
.stage-head:hover { background: var(--surface-2); }
.stage-head > .span2 { grid-column: span 2; }
.stage-row:first-child { border-top: 0; border-radius: 9px 9px 0 0; }
.stage-row:last-child { border-radius: 0 0 9px 9px; }
.stage-row:hover { background: var(--surface-2); }
.stage-name { font-weight: 600; white-space: normal; min-width: 0; }
.stage-st { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stage-chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.stage-chip { height: 20px; padding: 0 7px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); font-family: var(--mono); font-size: 11px; font-weight: 600; line-height: 20px; }
.req-paths { margin: 6px 0 0; padding-left: 18px; }
.req-paths li { margin-bottom: 4px; }
.stage-chip-sc { font-family: var(--font); font-weight: 600; background: var(--primary-soft); color: var(--primary); }
.stage-chip-sc::before { content: '✓ '; }
.stage-gear.msd { flex: 0 0 auto; min-width: 0; }
.stage-gear .msd-pop { right: auto; width: 270px; }
.stage-gear .msd-search { height: 30px; font-size: 13px; }
.stage-gear .msd-opt .mono { color: var(--muted); font-size: 12px; }
.stage-gear-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--muted); cursor: pointer; }
.stage-gear-btn:hover { border-color: var(--primary); color: var(--primary); }
.stage-row .strule-role { width: 100%; height: 24px; padding: 0 4px; border-radius: 3px; font-size: 12px; }
.msd-pop.up { top: auto; bottom: calc(100% + 4px); }
.msd-pop.pop-fixed { position: fixed; bottom: auto; }
.btn-dirty { box-shadow: 0 0 0 3px var(--primary-soft); }
@media (max-width: 1100px) { .stage-row { grid-template-columns: 1fr 1fr 1fr; padding-top: 4px; padding-bottom: 4px; } .stage-head { display: none; } }
@media (max-width: 720px) { .stage-row { grid-template-columns: 1fr; } }
@media (max-width: 920px) { .st-grid { grid-template-columns: 1fr; } }
.st-col { margin-bottom: 0; }
.st-chead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.st-chead h2 { margin: 0; display: flex; align-items: center; }
.st-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; margin-left: 8px;
  border-radius: 11px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; }
.empty-hint { padding: 12px 0; }
.stcat-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.stcat-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 28px; gap: 8px; align-items: center; }
.stcat-row input { height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; }
.stcat-code { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.stcat-new { display: flex; gap: 8px; margin: 10px 0 6px; }
.stcat-new input { flex: 1; min-width: 0; height: 34px; }
.stcat-new .btn { flex: 0 0 auto; height: 34px; }
.msd-search-form { display: flex; flex: 0 0 auto; }
.msd-search-form .msd-search { flex: 1; min-width: 0; }
.msd-create { flex: 0 0 auto; margin: 2px 6px 6px; padding: 7px 8px; border: 0; border-radius: 7px; background: var(--primary-soft); color: var(--primary);
  font: inherit; font-size: 13px; font-weight: 600; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.msd-create:hover { background: var(--primary); color: #fff; }
.st-del { width: 28px; height: 28px; display: inline-grid; place-items: center; border: 0; border-radius: 7px;
  background: none; color: var(--muted); font-size: 13px; cursor: pointer; }
.st-del:hover { background: var(--err-soft); color: var(--err); }
.st-folder-search { width: 100%; height: 36px; margin-top: 8px; padding: 0 12px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.st-rules-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.strule-card { position: relative; border: 1px solid var(--border); border-radius: 10px; padding: 12px 38px 12px 12px; background: var(--surface); }
.strule-card > .st-del { position: absolute; top: 8px; right: 8px; }
.strule-folder-main { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; }
.strule-folder-main:focus { background: var(--surface); }
.strule-row2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.strule-lbl { min-width: 50px; font-size: 12px; color: var(--muted); }
.strule-codes { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.st-chip { border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); font-family: var(--mono);
  font-weight: 600; font-size: 12px; padding: 4px 9px; border-radius: 999px; cursor: pointer; }
.st-chip:hover { border-color: var(--primary); }
.st-chip.on { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.strule-geo, .strule-gender { height: 32px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.st-pick { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 12px; }
.st-pick .st-chip { font-family: var(--font); font-weight: 600; }

/* квоти по гео */

.strule-role { height: 26px; padding: 0 5px; border: 1px solid var(--border-strong); border-radius: 4px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }

/* запити */
.req-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; margin-bottom: 3px; }
.req-form label { display: flex; flex-direction: column; gap: 2px; margin: 0; font-size: 11.5px; font-weight: 600; }
.req-form .req-note { flex: 1; min-width: 180px; }
.req-form input, .req-form select { height: 28px; padding: 0 6px; margin: 0; border: 1px solid var(--border-strong); border-radius: 4px;
  background: var(--surface); color: var(--text); font: inherit; }
.req-form input[type=number] { width: 90px; }
.key-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 3px 0; border-bottom: 1px solid var(--border); }
.key-row.off { opacity: 0.6; }
.key-main { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 4px; }
.key-token { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border-radius: 6px; padding: 4px 8px; cursor: pointer; word-break: break-all; }
.api-help { margin-top: 14px; }
.api-help summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.api-example { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-family: var(--mono);
  font-size: 12px; white-space: pre-wrap; word-break: break-all; margin: 10px 0; }

/* доступ до розділів: таблиця галочок і картка користувача */
.am-table th, .am-table td { padding: 6px 8px; }
.am-table .am-c { text-align: center; width: 64px; }
.am-table .am-tab { font-size: 11.5px; font-weight: 600; line-height: 1.25; white-space: normal; vertical-align: bottom; }
.am-table .am-group { text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  border-bottom: 1px solid var(--border); }
.am-table .am-admin { border-right: 1px solid var(--border); }
.am-table .am-who { white-space: nowrap; min-width: 160px; }
.am-table input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.am-table input[type=checkbox]:disabled { cursor: default; }
.am-table tbody tr:hover td { background: var(--primary-soft); }
.um-access { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.um-tabs { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px 14px; }
.um-group { display: flex; flex-direction: column; gap: 2px; }
.um-group .check { font-weight: 500; }

/* перевірка: скарги працівників */
.rv-folder { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.rv-bulk { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.rv-list { display: flex; flex-direction: column; gap: 10px; }
.rv-item { padding: 12px 14px; margin: 0; border-left: 3px solid var(--err); }
.rv-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rv-sts { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.rv-complaint { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--err-soft); }
.rv-flag { color: var(--err); }
.rv-text { margin: 4px 0 0; font-size: 14px; }
.rv-notes { margin-top: 6px; }
.rv-notes summary { cursor: pointer; }
.rv-notes p { margin: 4px 0 0; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; max-height: 160px; overflow: auto; }
.rv-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.rv-st-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rv-st-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 12px; margin: 4px 0 6px; }
.rv-st-grid .check { font-weight: 500; }

/* ---------- доступ до активів, клієнти, автоматизація ---------- */
.acc-access { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.acc-access h3 { display: flex; align-items: center; gap: 8px; }
.acc-access-users { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 6px 0 10px; }
.acc-access-users .check { margin: 0; font-weight: 400; }
.client-form { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.key-once { display: block; margin-top: 8px; padding: 8px 10px; font-size: 14px; word-break: break-all; cursor: copy; }

/* Automation Engine: черга, виконавці, правила, налаштування автоматичного кроку */
.tiles-sm { grid-template-columns: repeat(10, minmax(0, 1fr)); }
.tiles-sm .tile-l { font-size: 12px; }
.tile-on { outline: 2px solid var(--accent, #2563eb); }
.auto-result { margin-top: 3px; padding: 3px 6px; border-left: 2px solid var(--border); white-space: pre-wrap; }
.ex-card h3 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ex-ops { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 10px; margin: 6px 0; }
.ex-edit .check { margin: 4px 0; }
.chips-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-wrap .chip { display: inline-flex; align-items: center; gap: 4px; }
.st-auto { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; padding: 6px 8px; border: 1px dashed var(--border); border-radius: var(--radius); }
.st-auto .st-wide textarea { width: 100%; }
.st-auto .st-opts-3 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.7fr) minmax(0, 1fr); }
@media (max-width: 700px) { .st-auto .st-opts-3 { grid-template-columns: 1fr; } }
/* Бібліотека навичок і реєстр робочих середовищ (4.6) */
.skill-st { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.skill-st.active { background: var(--ok-soft); color: var(--ok); }
.skill-st.ready { background: var(--info-soft); color: var(--info); }
.skill-st.testing { background: var(--warn-soft); color: var(--warn); }
.skill-st.needs_work { background: var(--err-soft); color: var(--err); }
.skill-st.paused { color: var(--muted); }
.ex-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 30px; gap: 6px; margin-bottom: 6px; }
.ex-row.bad { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 0.8fr) 30px; }
.ex-row textarea { min-height: 48px; }
.test-case { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; margin-bottom: 6px; }
.test-case.ok { border-left: 3px solid var(--ok); }
.test-case.fail { border-left: 3px solid var(--err); }
.test-case.wait { border-left: 3px solid var(--warn); }
.task-env { font-size: 12px; color: var(--muted); }
@media (max-width: 900px) { .tiles-sm { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* Конструктор автоматизації: переходи, результати попередніх кроків, схема, симуляція, вибір операції */
.sce-auto-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin: 6px 0 8px; }
.sce-auto-bar .st-opt { min-width: 260px; }
.st-trans { display: flex; flex-direction: column; gap: 4px; padding-top: 4px; border-top: 1px dashed var(--border); }
.tr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tr-row select, .tr-row .tr-val { max-width: 170px; }
.st-prev { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip-btn { cursor: pointer; border: 1px solid var(--border); background: var(--surface); font-family: ui-monospace, monospace; }
.op-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; margin-bottom: 8px; }
.op-card { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.op-card:hover { border-color: var(--accent, #2563eb); }
.scheme { display: flex; flex-direction: column; align-items: stretch; }
.scheme-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; background: var(--surface); }
.scheme-card.auto { border-left: 3px solid var(--accent, #2563eb); }
.scheme-card.combined { border-left: 3px solid var(--warn); }
.scheme-tr { margin-left: 12px; }
.scheme-arrow { text-align: center; color: var(--muted, #888); margin: 2px 0; }
.sim-step { display: grid; grid-template-columns: 1fr 210px; gap: 4px 8px; margin-bottom: 8px; }
.sim-step textarea { grid-column: 1 / -1; }
.sim-path li { margin-bottom: 6px; }
/* 4.8: облік LLM — смуга бюджету й витрат по днях */
.meter { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 4px 0; }
.meter > span { display: block; height: 100%; background: var(--accent, #2563eb); }
/* 4.9: кабінет працівника, звернення */
a.top-user { color: inherit; }
a.top-user:hover { color: var(--primary); text-decoration: none; }
.cab-days { display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 3px; align-items: end; height: 110px; padding-top: 6px; }
.cab-day { display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; }
.cab-bar { display: block; min-height: 2px; background: var(--primary); border-radius: 3px 3px 0 0; opacity: .85; }
.cab-day:hover .cab-bar { opacity: 1; }
.cab-lbl { font-size: 10px; color: var(--muted); text-align: center; margin-top: 2px; font-variant-numeric: tabular-nums; }
.cab-grid { gap: 10px; margin-bottom: 10px; align-items: start; }
.cab-grid .card { margin-bottom: 0; }
.cab-list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.cab-list li { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; border-top: 1px solid var(--border); }
.cab-list li:first-child { border-top: 0; }
.cab-new { background: var(--info-soft); border-radius: var(--radius); padding-left: 6px !important; }
.cab-ico { width: 18px; text-align: center; flex: none; }
.cab-answer { background: var(--ok-soft); border-radius: var(--radius); padding: 4px 8px; margin-top: 4px; }
.cab-inbox .card { margin-bottom: 8px; }
@media (max-width: 900px) { .cab-grid { grid-template-columns: 1fr; } .cab-lbl { font-size: 8px; } }