* { box-sizing: border-box; }
/* no elastic bounce at the page ends: the pinned table header is position: fixed and would detach */
html, body { overscroll-behavior-y: none; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}
/* form controls don't inherit the page font by default; make every control use it */
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 600; }
/* digits line up in tables and metric cards */
table.grid, .kpi-value, .switch-btn-sub, .switch-item-sub { font-variant-numeric: tabular-nums; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  height: 60px; padding: 0 28px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bar-bg); backdrop-filter: saturate(180%) blur(12px); z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 22px; min-width: 0; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; color: var(--text); white-space: nowrap; letter-spacing: -.01em; }
.logo-mark { display: block; width: 30px; height: 30px; flex-shrink: 0; }
.logo:hover { text-decoration: none; }
nav { display: flex; gap: 8px; }
nav a { white-space: nowrap; padding: 7px 13px; border-radius: 9px; color: var(--muted); font-weight: 500; }
nav a.active { background: var(--blue-light); color: var(--accent-strong); }
nav a:hover { text-decoration: none; background: var(--hover); color: var(--text); }
nav a.active:hover { background: var(--blue-light); color: var(--accent-strong); }
.topbar-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
nav { overflow-x: auto; scrollbar-width: none; }
@media (max-width: 1100px) {
  .topbar { padding: 0 18px; gap: 12px; }
  .topbar-left { gap: 12px; }
  .logo-text { display: none; }
  .sync-pill .sync-text { display: none; }
  .sync-pill { padding: 6px; }
  .switch-btn-name { max-width: 140px; }
}
@media (max-width: 760px) {
  main { padding: 18px 14px 110px; }
  .switch-btn-text { display: none; }
  .switch-btn { padding: 4px; border-radius: 50%; }
  .switch-btn .chev { display: none; }
}

/* sync pill */
.sync-pill {
  display: inline-flex; align-items: center; gap: 7px; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 12px; color: var(--muted); padding: 6px 10px; border-radius: 8px; white-space: nowrap;
}
.sync-pill:hover { background: var(--hover); color: var(--text); }
.sync-pill.busy { cursor: default; }
.sync-pill.busy:hover { background: none; color: var(--muted); }
.sync-pill.err { color: var(--red); }
.sync-pill .status-dot { background: var(--green); }
.sync-pill.err .status-dot { background: var(--red); }
.sync-refresh { font-size: 14px; opacity: .55; }
.sync-pill:hover .sync-refresh { opacity: 1; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-dot.active { background: var(--green); }
.status-dot.disabled { background: var(--neutral); }
.status-dot.invalid { background: var(--red); }

/* avatar */
.ava {
  position: relative; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; flex-shrink: 0;
  color: var(--on-accent); font-weight: 600; overflow: hidden; user-select: none; letter-spacing: .02em;
}
.ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ava.has-photo { background: transparent !important; color: transparent; }

/* account switcher */
.account-switch { position: relative; }
.switch-btn {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); background: var(--field); cursor: pointer;
  padding: 5px 10px 5px 5px; border-radius: 12px; font: inherit; text-align: left; max-width: 300px; transition: border-color .12s, box-shadow .12s;
}
.switch-btn:hover, .switch-btn.open { border-color: var(--accent-line); box-shadow: 0 1px 4px rgba(var(--accent-rgb), .12); }
.switch-btn-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.switch-btn-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.switch-btn-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.chev { width: 8px; height: 8px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg) translateY(-2px); margin: 0 4px 0 2px; flex-shrink: 0; }
.switch-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 320px; background: var(--pop); border-radius: 14px; z-index: 40;
  border: 1px solid var(--border); box-shadow: 0 12px 36px rgba(var(--shade-rgb), .14); padding: 6px; animation: pop-in .12s ease-out;
}
.switch-menu-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px 6px; font-weight: 600; }
.switch-item {
  display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none; cursor: pointer; font: inherit; text-align: left;
  padding: 8px 10px; border-radius: 10px;
}
.switch-item:hover { background: var(--hover); }
.switch-item.current { background: var(--blue-light); }
.switch-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.switch-item-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switch-item-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switch-check { color: var(--accent-text); font-weight: 700; }
.switch-menu-footer { display: flex; justify-content: space-between; border-top: 1px solid var(--border-soft); margin-top: 6px; padding: 8px 4px 2px; }
.switch-link { font-size: 13px; font-weight: 500; padding: 4px 6px; border-radius: 6px; }
.switch-link:hover { text-decoration: none; background: var(--blue-light); }

/* user menu */
.user-menu { position: relative; display: flex; align-items: center; gap: 8px; }
.org-tag { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; color: var(--accent-text); background: var(--blue-light); border-radius: 999px; padding: 4px 10px; }
@media (max-width: 700px) { .org-tag { display: none; } }
.user-btn { display: flex; border: none; background: none; padding: 0; cursor: pointer; border-radius: 50%; }
.user-btn:hover .ava, .user-btn.open .ava { box-shadow: 0 0 0 3px var(--blue-light); }
.user-menu .dropdown-menu { right: 0; top: calc(100% + 8px); min-width: 220px; max-height: calc(100dvh - var(--top-h, 64px) - 16px); }  /* the whole menu, scrolls only on a screen too small for it */
.user-menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border-soft); margin-bottom: 4px; line-height: 1.3; }
.user-menu-name { font-weight: 600; font-size: 13px; }
.user-menu-sub { font-size: 12px; color: var(--muted); }

/* ---------- sign-in page ---------- */
.auth-page { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; background: var(--bg); }
.auth-hero {
  position: relative; display: flex; align-items: center; justify-content: center; padding: 40px; overflow: hidden;
  background: linear-gradient(145deg, var(--hero-1) 0%, var(--hero-2) 45%, var(--hero-3) 100%); color: var(--on-accent);
}
.auth-hero-brand { position: absolute; top: 36px; left: 40px; font-weight: 800; font-size: 15px; letter-spacing: .04em; }
.auth-hero-mark { width: min(52%, 340px); height: auto; }
.auth-back { display: flex; gap: 20px; justify-content: center; font-size: 13px; margin: 0; }
.auth-hero-slogan { position: absolute; left: 40px; bottom: 36px; font-size: clamp(30px, 3.6vw, 52px); font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.auth-side { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 400px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.auth-logo { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.auth-logo img { width: 34px; height: 34px; }
.auth-card { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px 26px 22px; text-align: center; }
.auth-card h1 { font-size: 20px; margin: 0 0 6px; }
.auth-sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.auth-btn + .auth-btn { margin-top: 12px; }
.auth-btn { width: 100%; justify-content: center; height: 44px; font-size: 15px; border-radius: 10px; }
.auth-btn .ic { font-size: 17px; opacity: 1; }
#tg-login .ic { color: var(--accent-text); }
.auth-btn.loading { opacity: .7; pointer-events: none; }
.mail-sep { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; color: var(--muted); font-size: 12px; }
.mail-sep::before, .mail-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.mail-form input { height: 44px; border-radius: 10px; font-size: 15px; text-align: left; margin-bottom: 12px; }
.mail-form .auth-btn { margin-top: 0; }
.mail-hint { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.mail-hint b { color: var(--text); word-break: break-all; }
.mail-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; }
.mail-links .btn-link:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.auth-btn-google .ic { font-size: 18px; }
.user-menu .menu-item { text-decoration: none; display: flex; align-items: center; gap: 8px; }
.auth-note { margin: 14px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.auth-error { margin: 0 0 16px; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger-text); font-size: 13px; text-align: left; }
.doc-page { background: var(--bg); }
.doc { max-width: 760px; margin: 0 auto; padding: 40px 20px 80px; display: flex; flex-direction: column; align-items: flex-start; gap: 20px; }
.doc .auth-logo { color: var(--text); text-decoration: none; }
.doc-card { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px 32px; line-height: 1.6; }
.doc-card h1 { margin: 0 0 4px; }
.doc-card h2 { font-size: 16px; margin: 24px 0 8px; }
.doc-card ul { padding-left: 20px; margin: 0; }
@media (max-width: 900px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}

/* ---------- page layout ---------- */
body[data-route=dashboard], body[data-route=campaigns], body[data-route=automations], body[data-route=accounts], body[data-route=create], body[data-route=profile] { background: var(--bg); }
main { padding: 26px 28px 110px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; line-height: 1.2; }
.page-head .btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.camp-head { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.camp-title { cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.camp-title .ic { font-size: 16px; color: var(--muted); }
.camp-title:hover .ic { color: var(--accent-text); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 16px; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--blue); }
table.grid tr.clickable { cursor: pointer; }
.be-body .ui-select, .be-body .dt-input { width: 100%; max-width: 420px; }
.page-sub { display: block; margin-top: 3px; font-size: 13px; color: var(--muted); }
.empty { padding: 48px; text-align: center; color: var(--muted); }
.empty-state { padding: 56px 24px; text-align: center; max-width: 420px; margin: 0 auto; }
.empty-state .empty-icon { font-size: 36px; margin-bottom: 10px; }
.empty-state h3 { margin: 0 0 6px; font-size: 16px; }
.empty-state p { margin: 0 0 18px; line-height: 1.5; }
.foot-note { margin-top: 14px; }
.grow { flex: 1; }

/* ---------- common controls ---------- */
.btn {
  border: 1px solid var(--border); background: var(--btn-bg); color: var(--text);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--btn-hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent-solid); border-color: var(--blue); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--red); border-color: var(--danger-line); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 3px 8px; font-size: 13px; border-radius: 7px; }
.btn-link { border: none; background: none; color: var(--accent-text); cursor: pointer; padding: 0; font-size: 13px; font: inherit; font-size: 13px; }
.btn-link:hover { text-decoration: underline; }
.kebab { font-size: 16px; line-height: 1; padding: 4px 9px; letter-spacing: .05em; }

input[type=text], input[type=password], textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; font: inherit; color: var(--text); background: var(--field);
}
input:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12); }
textarea { resize: vertical; min-height: 70px; }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error-text { color: var(--red); }
.ok-text { color: var(--green); }
.hidden { display: none !important; }

/* ---------- ad accounts ---------- */
.acc-empty > .empty-state { margin-top: 8px; }
/* cabinets: one row per cabinet, the whole row opens it (on a phone the rows become cards, mobile.css) */
.acc-table { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
/* no overflow: hidden on the table, or it clips the «⋯» menu: the corner rows round themselves */
.acc-row:first-child { border-radius: 15px 15px 0 0; }
.acc-row:last-child { border-radius: 0 0 15px 15px; }
.acc-row:only-child { border-radius: 15px; }
.acc-row { display: grid; grid-template-columns: minmax(240px, 2.4fr) repeat(3, minmax(110px, 1fr)) minmax(190px, 1.4fr) 150px; align-items: center; gap: 20px; padding: 14px 18px; border-top: 1px solid var(--border-soft); cursor: pointer; transition: background .12s; }
.acc-row:hover { background: var(--hover); }
.acc-row:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.acc-row.current { box-shadow: inset 3px 0 0 var(--blue); }
.acc-head-row { border-top: none; padding-top: 11px; padding-bottom: 11px; background: var(--surface-2); font-size: 12px; color: var(--muted); cursor: default; }
.acc-head-row:hover { background: var(--surface-2); }
.acc-cell { min-width: 0; }
.acc-name { display: flex; align-items: center; gap: 12px; }
.acc-id { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.acc-id .badge { margin-top: 4px; }
.acc-title { max-width: 100%; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.acc-open-tag { margin-left: 8px; font-size: 11px; font-weight: 600; color: var(--accent-text); text-transform: uppercase; letter-spacing: .04em; }
.acc-sub { max-width: 100%; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-num { text-align: right; }
.acc-cell-label { display: none; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.acc-num-value { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.acc-pay-title { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; }
.acc-pay-sub { font-size: 12px; color: var(--muted); margin: 2px 0 0 14px; }
.acc-pay-sub.warn { color: var(--warn-text); }
.acc-pay-sub.danger { color: var(--danger-text); }
.acc-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.acc-dot.ok { background: var(--green); }
.acc-dot.warn { background: var(--warn-stripe); }
.acc-dot.danger { background: var(--red); }
.acc-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.acc-note { font-size: 12px; color: var(--muted); line-height: 1.45; }
.acc-note.err { color: var(--red); }
.menu { padding: 6px; min-width: 220px; }
.menu-item { display: block; width: 100%; text-align: left; border: none; background: none; font: inherit; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text); }
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--red); }
.menu-item.danger:hover { background: var(--danger-soft); }
.spinner-light { border-color: var(--on-accent); border-top-color: transparent; }

/* ---------- dashboard ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px 12px; min-width: 0; }
.kpi-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.kpi-value { font-size: 20px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.35; }
.kpi.accent { background: linear-gradient(135deg, var(--kpi-1), var(--kpi-2)); border-color: transparent; color: var(--on-accent); }
.kpi.accent .kpi-label, .kpi.accent .kpi-sub { color: var(--on-accent-muted); }

/* filter toolbar: every control is 34px tall and shares the same radius */
.toolbar { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.toolbar-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar-row + .toolbar-row { border-top: 1px solid var(--border-soft); padding-top: 10px; }
.toolbar .btn-sm, .toolbar input[type=text] { height: 34px; box-sizing: border-box; }
.toolbar input[type=text] { width: auto; padding: 0 10px; font-size: 13px; border-radius: 9px; }
.toolbar .btn-sm { border-radius: 9px; }
.toolbar input[type=text].search { min-width: 280px; padding-left: 32px; background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23707579' stroke-width='2.2' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>") 11px center no-repeat; } /* theme-icon: the stroke colour of a data: icon cannot be a token, the dark theme repeats this rule */
.pills { display: inline-flex; gap: 2px; background: var(--hover); border-radius: 9px; padding: 3px; height: 34px; box-sizing: border-box; }
.pill { border: none; background: none; font: inherit; font-size: 13px; padding: 0 11px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 500; white-space: nowrap; }
.pill:hover { color: var(--text); }
.pill.active { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 3px rgba(var(--shade-rgb), .1); }
.pill:focus-visible { outline: 2px solid rgba(var(--accent-rgb), .45); outline-offset: 1px; }
.pill:focus:not(:focus-visible) { outline: none; }

/* inline icons */
.ic { width: 1em; height: 1em; flex-shrink: 0; vertical-align: -0.125em; }
.ic-fill { fill: currentColor; stroke-width: 1; }
.btn .ic { font-size: 15px; opacity: .8; }
.btn-icon .ic { font-size: 13px; opacity: 1; }
.badge .ic { font-size: 12px; opacity: .7; }
.badge-type { gap: 5px; }

/* own checkbox / radio: the OS look is switched off, we draw the box ourselves */
input[type=checkbox], input[type=radio] {
  appearance: none; -webkit-appearance: none; margin: 0; flex-shrink: 0; cursor: pointer;
  width: 18px; height: 18px; border: 1.5px solid var(--border-strong); background: var(--field) center / 12px no-repeat;
  border-radius: 5px; vertical-align: middle; transition: background-color .12s, border-color .12s, box-shadow .12s;
}
input[type=radio] { border-radius: 50%; }
input[type=checkbox]:hover, input[type=radio]:hover { border-color: var(--blue); }
input[type=checkbox]:focus-visible, input[type=radio]:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18); }
input[type=checkbox]:checked {
  background-color: var(--accent-solid); border-color: var(--accent-solid);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'><path d='m5 12.5 4.5 4.5L19 7.5'/></svg>");
}
input[type=checkbox]:indeterminate {
  background-color: var(--accent-solid); border-color: var(--accent-solid);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round'><path d='M6 12h12'/></svg>");
}
input[type=radio]:checked { border: 5.5px solid var(--blue); }
input[type=checkbox]:disabled, input[type=radio]:disabled { opacity: .45; cursor: default; border-color: var(--border-strong); }

/* own select (uiSelect): same box as text inputs, menu below */
.ui-select { display: block; width: 100%; min-width: 0; }
.ui-select-btn {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px 9px 12px; background: var(--field); line-height: inherit;
}
.ui-select-btn:hover { background: var(--field-hover); }
.ui-select-btn.open { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12); }
.ui-select-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-select-btn .chev { margin: 0 2px 0 0; }
.dropdown-menu.ui-select-menu { left: 0; right: auto; min-width: 100%; width: max-content; max-width: 360px; max-height: 300px; padding: 6px; }
.ui-select-menu .menu-item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-item.active { color: var(--accent-text); font-weight: 600; background: var(--blue-light); }
.menu-item.menu-accent { color: var(--accent-text); font-weight: 500; }
.dropdown-menu.up { top: auto; bottom: calc(100% + 6px); }
.dropdown-menu.to-left { left: auto !important; right: 0 !important; }
.dropdown-menu.to-right { left: 0 !important; right: auto !important; }

/* own date + time field (dateTimeInput) */
.dt-input { display: block; width: 100%; }
.dt-btn {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px 9px 12px; background: var(--field); line-height: inherit;
}
.dt-btn > span:nth-child(2) { flex: 1; }
.dt-btn .ic { color: var(--muted); font-size: 15px; }
.dt-btn:hover { background: var(--field-hover); }
.dt-btn.open { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12); }
.dt-pop .cal-month { width: 296px; }
.dt-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.dt-foot input.dt-time { width: 72px; padding: 6px 8px; text-align: center; font-variant-numeric: tabular-nums; }

/* date range picker */
.date-btn { gap: 8px; padding: 0 9px 0 10px; font-weight: 500; }
.date-btn .ic { font-size: 14px; }
.date-btn.open { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12); }
.dropdown-menu.calendar { right: auto; left: 0; padding: 14px 16px; min-width: 0; max-height: none; overflow: visible; width: max-content; }
.cal-months { display: flex; gap: 22px; }
.cal-month { width: 238px; }
.cal-fields { display: flex; gap: 8px; margin-bottom: 12px; }
.cal-field { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--field); font: inherit; font-size: 13px; color: var(--text); cursor: pointer; text-align: left; }
.cal-field:hover { border-color: var(--border-strong); }
.cal-field.active { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12); }
.cal-field-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.cal-nav-gap { width: 26px; height: 26px; flex-shrink: 0; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { text-align: center; font-weight: 600; font-size: 13px; flex: 1; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 34px); gap: 2px 0; justify-content: center; }
.cal-wd { font-size: 11px; color: var(--muted); text-align: center; height: 24px; line-height: 24px; font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.cal-day { height: 32px; border: none; background: none; font: inherit; font-size: 13px; cursor: pointer; color: var(--text); position: relative; padding: 0; }
.cal-day.empty { cursor: default; }
.cal-day:not(.empty):not(:disabled):hover { background: var(--blue-light); border-radius: 8px; }
.cal-day.future { color: var(--faint); cursor: default; }
.cal-day.today { font-weight: 700; color: var(--accent-text); }
.cal-day.in { background: var(--blue-light); color: var(--accent-strong); }
.cal-day.picked { background: var(--accent-solid); color: var(--on-accent); font-weight: 600; }
.cal-day.picked.from { border-radius: 8px 0 0 8px; }
.cal-day.picked.to { border-radius: 0 8px 8px 0; }
.cal-day.picked.single { border-radius: 8px; }
.cal-day.picked:hover { background: var(--accent-hover) !important; }
.cal-nav { width: 26px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--btn-bg); cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cal-nav .ic { font-size: 15px; }
.cal-nav:hover { background: var(--btn-hover); color: var(--text); }
.cal-nav:disabled { opacity: .35; cursor: default; background: var(--btn-bg); }

/* badge filters: the button shows the chosen badge, the menu lists the same badges as the table */
.filter-btn { padding: 0 9px 0 10px; gap: 8px; }
.filter-btn .chev { margin: 0 0 0 2px; }
.filter-btn.active { border-color: var(--border-strong); }
.filter-btn.one { padding-left: 6px; }  /* a single value is a badge with its own padding; «Статус 3» is plain text and keeps the usual one */
.filter-btn.active .chev { border-color: var(--muted); }
.filter-btn.open { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12); }
.filter-btn .badge { padding: 3px 10px; }
.dropdown-menu.filter-menu { right: auto; left: 0; min-width: 230px; }
.filter-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 8px; }
.filter-box { width: 16px; height: 16px; border: 1.5px solid var(--border-strong); border-radius: 5px; background: var(--field) center / 11px no-repeat; flex-shrink: 0; box-sizing: border-box; }
.filter-item:hover .filter-box { border-color: var(--blue); }
.filter-item.checked .filter-box {
  background-color: var(--accent-solid); border-color: var(--accent-solid);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'><path d='m5 12.5 4.5 4.5L19 7.5'/></svg>");
}
.filter-reset { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.filter-reset .ic { font-size: 14px; }
.filter-count { font-size: 13px; color: var(--muted); white-space: nowrap; }
.filter-count b, .phone-count b { color: var(--text); font-weight: 600; }
.filter-more { font-size: 12px; font-weight: 600; color: var(--accent-strong); background: var(--blue-light); border-radius: 6px; padding: 2px 6px; }

.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: clip; }
/* The page is the only vertical scroller. The header row and totals are pinned under the top bar
   by JS (see stickHeader in js/dashboard.js): a position:fixed copy of the two rows is shown while the real
   ones are scrolled away, because the horizontal scroll wrapper breaks position: sticky against
   the viewport. */
.table-wrap { overflow-x: auto; }
.sticky-head { position: fixed; z-index: 15; overflow: hidden; background: var(--surface); box-shadow: 0 2px 6px rgba(var(--shadow-rgb), .08); }
.sticky-head table.grid { table-layout: fixed; }
.sticky-head table.grid th, .sticky-head table.grid td { box-sizing: border-box; overflow: hidden; }
.sticky-head table.grid tr.summary td { border-bottom-color: var(--border-strong); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.grid th, table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; text-align: right; }
table.grid th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--muted); user-select: none; letter-spacing: .02em; z-index: 1; }
table.grid th.sortable { cursor: pointer; }
table.grid th.sortable:hover, table.grid th.sorted { color: var(--text); }
table.grid .sort-mark { display: inline-block; width: 10px; margin-left: 2px; color: var(--accent-text); }
/* column filter: the funnel shows on header hover, stays visible (blue) while a filter is set */
table.grid .th-filter { display: inline-flex; vertical-align: -3px; margin-left: 2px; padding: 3px; border-radius: 6px; color: var(--muted); opacity: 0; transition: opacity .12s; }
table.grid th:hover .th-filter, table.grid .th-filter.on { opacity: 1; }
table.grid .th-filter:hover { background: var(--track); color: var(--text); }
table.grid .th-filter.on { color: var(--accent-text); }
table.grid .th-filter.on:hover { background: var(--blue-light); color: var(--accent-strong); }
.range-pop { position: fixed; right: auto; width: 300px; padding: 14px; font-weight: 400; }
.range-pop-title { font-weight: 600; margin-bottom: 10px; }
.range-pop-row { display: flex; align-items: center; gap: 8px; }
.range-pop-row > .input-prefix, .range-pop-row > input { flex: 1; min-width: 0; }
.range-pop input { width: 100%; box-sizing: border-box; }
.range-pop-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.input-prefix.suffix > span { left: auto; right: 12px; color: var(--muted); }
.input-prefix.suffix > input { padding-left: 12px; padding-right: 30px; }
.range-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.range-chip { display: inline-flex; align-items: center; background: var(--blue-light); color: var(--accent-strong); border: 1px solid var(--accent-line); border-radius: 999px; font-size: 13px; }
.range-chip button { border: none; background: none; color: inherit; font: inherit; cursor: pointer; }
.range-chip-main { display: inline-flex; align-items: center; gap: 6px; padding: 5px 2px 5px 11px; }
.range-chip-main b { font-weight: 600; }
.range-chip-x { padding: 3px 10px 3px 6px; font-size: 16px; line-height: 1; }
.range-chip-main:hover, .range-chip-x:hover { color: var(--accent-text); }
table.grid .left { text-align: left; }
table.grid tr.summary td { background: var(--surface-2); font-weight: 600; border-bottom: 1px solid var(--border-soft); }
table.grid tbody tr:hover td { background: var(--row-hover); }
table.grid tbody tr.selected td { background: var(--row-selected); }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid td.title-cell { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
/* first two columns stay visible while scrolling horizontally */
table.grid .check-col, table.grid .title-cell, table.grid .title-col { position: sticky; background: var(--surface); }
/* exactly 42px: .title-cell is pinned at left: 42px */
table.grid .check-col { left: 0; z-index: 2; width: 42px; min-width: 42px; max-width: 42px; box-sizing: border-box; text-align: center; padding-left: 0; padding-right: 0; }
table.grid .title-cell, table.grid .title-col { left: 42px; z-index: 2; box-shadow: 1px 0 0 var(--border-soft); }
table.grid th.check-col, table.grid th.title-col { z-index: 3; background: var(--surface-2); }
table.grid tr.summary .check-col, table.grid tr.summary .title-cell { background: var(--surface-2); }
table.grid tbody tr:hover .check-col, table.grid tbody tr:hover .title-cell { background: var(--row-hover); }
table.grid tbody tr.selected .check-col, table.grid tbody tr.selected .title-cell { background: var(--row-selected); }
table.grid td.target-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
table.grid input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--blue); cursor: pointer; vertical-align: middle; }
.item-title { font-weight: 600; color: var(--text); cursor: pointer; overflow: hidden; text-overflow: ellipsis; }
.item-title:hover { color: var(--accent-text); }
.item-id { font-size: 12px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; }
.row-actions { display: inline-flex; gap: 4px; opacity: .6; transition: opacity .12s; }
tr:hover .row-actions { opacity: 1; }
.actions-cell { width: 1%; }
/* data columns hug their content with equal gaps; the actions column takes the leftover width */
table.items-grid th, table.items-grid td { text-align: left; padding-left: 14px; padding-right: 14px; }
table.items-grid .actions-cell { width: 100%; text-align: right; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-active { background: var(--st-active-bg); color: var(--st-active-fg); }
.badge-on_hold { background: var(--st-on_hold-bg); color: var(--st-on_hold-fg); }
.badge-in_review { background: var(--st-in_review-bg); color: var(--st-in_review-fg); }
.badge-ready_for_review { background: var(--st-ready_for_review-bg); color: var(--st-ready_for_review-fg); }
.badge-declined { background: var(--st-declined-bg); color: var(--st-declined-fg); }
.badge-stopped { background: var(--st-stopped-bg); color: var(--st-stopped-fg); }
.badge-type { background: var(--st-type-bg); color: var(--st-type-fg); }
.badge-type::before { display: none; }
button.badge { border: none; font-family: inherit; }
.badge-btn { cursor: pointer; transition: filter .12s; }
.badge-btn:hover { filter: brightness(.95); }
.badge-btn:disabled { opacity: .6; cursor: default; }
.camp-id { margin-top: 2px; }
.camp-status-line { display: flex; align-items: center; gap: 10px; }
.camp-choice-note { margin: 10px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); }

/* three columns of equal width, so the page numbers sit in the exact centre of the card */
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 10px 14px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border-soft); background: var(--surface-2); }
/* stays at the bottom of the screen while the table is longer than the viewport */
.table-card > .pager { position: sticky; bottom: 0; z-index: 3; box-shadow: 0 -8px 16px -12px rgba(var(--shadow-rgb), .18); }
.pager-center { display: flex; justify-content: center; }
.pager-sizes { justify-self: end; }
@media (max-width: 760px) { .pager { grid-template-columns: 1fr 1fr; } .pager-center { grid-column: 1 / -1; order: -1; } }
.pager button { border: none; background: none; padding: 4px 9px; border-radius: 6px; cursor: pointer; color: var(--muted); font: inherit; font-size: 13px; }
.pager button:hover { color: var(--text); }
.pager button.active { background: var(--seg-on); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(var(--shade-rgb), .1); }
.pager-sizes { display: inline-flex; align-items: center; gap: 2px; }
.pager-sizes > span { margin-right: 6px; }
.pager-nav { display: inline-flex; align-items: center; gap: 2px; }
.pager-nav .pager-num, .pager-nav .pager-arrow { min-width: 30px; height: 30px; padding: 0 6px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.pager-nav .pager-num.active { background: var(--accent-solid); color: var(--on-accent); box-shadow: none; }
.pager-nav .pager-arrow { font-size: 18px; line-height: 1; }
.pager-nav .pager-arrow:disabled { opacity: .35; cursor: default; color: var(--muted); }
.pager-gap { padding: 0 4px; color: var(--muted); }

/* floating "bulk edit" button, shown while ads are selected */
.bulk-fab {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 35;
  display: flex; align-items: center; background: var(--accent-solid); border-radius: 999px;
  box-shadow: 0 10px 30px rgba(var(--accent-rgb), .4), 0 2px 6px rgba(var(--shadow-rgb), .15); animation: rise-in .16s ease-out;
}
@keyframes rise-in { from { opacity: 0; transform: translate(-50%, 10px); } }
.bulk-main {
  display: inline-flex; align-items: center; gap: 9px; height: 46px; padding: 0 10px 0 20px; border: none;
  background: none; color: var(--on-accent); font-weight: 600; font-size: 15px; cursor: pointer; border-radius: 999px 0 0 999px; white-space: nowrap;
}
.bulk-main .ic { font-size: 16px; }
.bulk-main:hover, .bulk-clear:hover { background: var(--on-accent-hover); }
.bulk-count { background: var(--on-accent); color: var(--on-accent-fg); font-weight: 700; font-size: 13px; min-width: 24px; height: 24px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; padding: 0 7px; }
.bulk-clear {
  height: 46px; width: 44px; border: none; border-left: 1px solid var(--on-accent-line); background: none;
  color: var(--on-accent); font-size: 20px; line-height: 1; cursor: pointer; border-radius: 0 999px 999px 0;
}

/* bulk edit modal */
.seg-sm { display: inline-flex; background: var(--hover); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg-sm button { border: none; background: none; padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; }
.seg-sm button:hover { color: var(--text); }
.seg-sm button.active { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 3px rgba(var(--shadow-rgb), .15); }
.be-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 13px; }
.be-chip { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.be-list { padding-top: 14px !important; }
.be-block { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; background: var(--surface); transition: border-color .12s, box-shadow .12s, background .12s; }
.be-block.on { border-color: var(--accent-line); background: var(--row-hover); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .08); }
.be-block.on .be-title { color: var(--accent-strong); }
.be-block.err { border-color: var(--danger-line); box-shadow: 0 0 0 3px rgba(var(--danger-rgb), .06); background: var(--surface); }
.be-block.disabled { opacity: .5; }
.be-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; user-select: none; border-radius: 12px; min-width: 0; }
.be-head:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18); }
.be-block.disabled .be-head { cursor: default; }
.be-title { font-weight: 600; flex: none; }
.be-note { font-size: 12px; color: var(--muted); flex: none; }
.be-change { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--accent-strong); }
.be-block.err .be-change { color: var(--red); }
.be-reset { flex: none; font-size: 12px; color: var(--muted); }
.be-reset:hover { color: var(--red); text-decoration: none; }
.be-block:not(.on) .be-reset { display: none; }
.be-chev { flex: none; transition: transform .15s; }
.be-block.open .be-chev { transform: rotate(-135deg) translateY(-2px); }
.be-body { display: none; padding: 0 14px 14px; flex-direction: column; gap: 10px; align-items: flex-start; }
.be-block.open .be-body { display: flex; }
.be-body > input, .be-body > textarea, .be-body > .input-prefix, .be-row > input { width: 100%; max-width: 420px; box-sizing: border-box; }
.be-body > textarea { max-width: none; }
.be-body .hint { margin: 0; font-size: 12px; color: var(--muted); }
.be-body .hint.error-text { color: var(--red); }
.be-row { display: flex; gap: 8px; width: 100%; flex-wrap: wrap; align-items: center; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check-row input { accent-color: var(--blue); }
.modal-scroll .modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0;
  padding: 14px 24px; border-top: 1px solid var(--border-soft);
}
.be-summary { font-size: 13px; }
.be-foot-left { display: flex; align-items: center; gap: 14px; min-width: 0; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); background: var(--pop); z-index: 30;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(var(--shade-rgb), .14);
  padding: 8px; min-width: 220px; max-height: 420px; overflow: auto; animation: pop-in .12s ease-out;
}
.kebab + .dropdown-menu .menu-item { white-space: nowrap; }
.dropdown-menu label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.dropdown-menu label:hover { background: var(--hover); }
.dropdown-menu input[type=checkbox] { accent-color: var(--blue); }

/* ---------- create form ---------- */
.create-wrap { max-width: 1120px; margin: 0 auto; }
.create-target { display: flex; align-items: center; gap: 10px; }
.create-wrap .page-head { margin-bottom: 16px; }
.create-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 16px; align-items: start; }
.create-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
/* one vertical rhythm inside a panel: the gap between visible children, so hidden ones leave no extra space */
.create-col > .panel { display: flex; flex-direction: column; gap: 16px; }
.create-col > .panel > .panel-title { margin-bottom: 0; }
.create-col > .panel > .field, .create-col > .panel > .notes { margin: 0; }
.create-col > .panel > .panel-sub { margin: 4px 0 0; }
@media (max-width: 900px) { .create-grid { grid-template-columns: minmax(0, 1fr); } .page-head:has(.create-target) { flex-direction: column; } }
.field { margin-bottom: 16px; }
.field > .field-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 600; margin-bottom: 6px; }
.field > .field-label > :last-child:not(:first-child) { font-weight: 400; white-space: nowrap; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .hint.error-text { color: var(--red); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg button { border: 1px solid var(--border); background: var(--btn-bg); border-radius: 8px; padding: 8px; cursor: pointer; font-size: 14px; }
.seg button.active { background: var(--accent-solid); border-color: var(--blue); color: var(--on-accent); }
.radio-list { display: flex; flex-direction: column; gap: 8px; }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--accent-text); }
.input-prefix > input { padding-left: 32px; }
.cpm-wrap { position: relative; }
.cpm-wrap input { padding-right: 70px; }
.cpm-badge {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: var(--orange-soft); color: var(--orange-text); border: 1px solid var(--orange-line);
  font-size: 12px; font-weight: 600; border-radius: 6px; padding: 2px 7px; cursor: help;
}
.cpm-breakdown { margin-top: 8px; color: var(--text-2) !important; }
.cpm-breakdown-title { color: var(--accent-text); font-weight: 600; }
.cpm-breakdown ul { margin: 2px 0 0; padding-left: 18px; }
.cpm-breakdown li { margin: 1px 0; }
.cpm-breakdown li::marker { color: var(--accent-text); }
.cpm-breakdown li b { color: var(--accent-text); }
input.input-error { border-color: var(--red); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.notes { margin: 4px 0 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.note { display: flex; gap: 8px; align-items: flex-start; }
.note .dot { width: 16px; height: 16px; border-radius: 50%; color: var(--on-signal); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; margin-top: 1px; }
.dot.red { background: var(--red); } .dot.green { background: var(--green); } .dot.orange { background: var(--orange); }

.create-footer {
  position: sticky; bottom: 16px; z-index: 5; margin-top: 16px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  box-shadow: 0 6px 24px rgba(var(--shadow-rgb), .08);
}
.create-footer .summary { font-size: 13px; color: var(--muted); }
.create-footer .actions { display: flex; gap: 12px; align-items: center; }
.btn-create { padding: 10px 36px; font-size: 15px; }

/* preview */
.preview { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 18px; }
.preview-chat { background: linear-gradient(135deg, var(--tg-bg-1), var(--tg-bg-2)); padding: 18px; min-height: 150px; }
.preview-msg { background: var(--tg-msg); border-radius: 12px; padding: 10px 12px; max-width: 320px; box-shadow: 0 1px 2px rgba(var(--shade-rgb), .15); }
.preview .item-label { font-size: 12px; color: var(--tg-green); font-weight: 600; }
.preview .item-label span { background: var(--tg-tag); border-radius: 6px; padding: 0 5px; margin-left: 4px; font-weight: 400; }
.preview-bot .item-label { color: var(--accent-text); }
.preview-bot .item-label span { background: var(--blue-light); }
.preview .name { font-weight: 600; margin: 2px 0; }
.preview .text { white-space: pre-wrap; word-break: break-word; }
.custom-emoji { display: inline-block; width: 1.25em; height: 1.25em; line-height: 1.25em; text-align: center; vertical-align: -0.25em; cursor: help; }
.custom-emoji img, .custom-emoji video, .custom-emoji .lottie-box { width: 100%; height: 100%; display: block; object-fit: contain; }
.custom-emoji .lottie-box svg { display: block; }
.preview-msg .media { margin: 6px 0; max-width: 100%; border-radius: 8px; display: block; }
.preview-msg .btn-line { border-top: 1px solid var(--tg-line); margin-top: 8px; padding-top: 6px; text-align: center; color: var(--tg-green); font-weight: 600; font-size: 13px; }
.preview-bot { background: var(--tg-bot); border-radius: 12px; padding: 10px 12px; max-width: 360px; box-shadow: 0 1px 3px rgba(var(--shade-rgb), .15); }
.preview-search .search-box { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--muted); }
.preview-search .section { background: var(--hover); padding: 4px 14px; font-size: 12px; color: var(--muted); }
.preview-search .row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--avatar-bg); flex-shrink: 0; object-fit: cover; }
.preview-search .tag { margin-left: auto; background: var(--blue-light); color: var(--accent-text); font-size: 12px; border-radius: 6px; padding: 1px 6px; }

/* multiselect */
.ms { position: relative; }
.ms-box { border: 1px solid var(--border); border-radius: 8px; padding: 4px 6px; display: flex; flex-wrap: wrap; gap: 4px; min-height: 40px; align-items: center; cursor: text; }
.ms-box:focus-within { border-color: var(--blue); }
.ms-box input { border: none !important; flex: 1; min-width: 120px; padding: 5px 4px !important; }
.warn-text { color: var(--warn-text); }
.token-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.token-chip { border: 1px solid var(--border); background: var(--btn-bg); border-radius: 8px; padding: 2px 8px; font: inherit; font-size: 12px; color: var(--accent-strong); cursor: pointer; }
.token-chip:hover { border-color: var(--blue); background: var(--blue-light); }
.field input[type=text]:disabled { background: var(--hover); color: var(--muted); cursor: not-allowed; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-solid); color: var(--on-accent); border-radius: 6px; padding: 3px 4px 3px 8px; font-size: 13px; }
.chip img { width: 18px; height: 18px; border-radius: 50%; }
.chip button { border: none; background: none; color: var(--on-accent); cursor: pointer; font-size: 14px; padding: 0 3px; line-height: 1; }
.chip.bad { background: var(--danger-soft); color: var(--red); }
.chip.bad button { color: var(--red); }
.ms-dd { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--pop); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(var(--shade-rgb), .12); max-height: 260px; overflow: auto; z-index: 25; }
.ms-dd div { padding: 7px 12px; cursor: pointer; }
.ms-dd div:hover, .ms-dd div.hl { background: var(--blue-light); }
.ms-dd .ms-empty { color: var(--muted); cursor: default; }

/* list field */
.list-field textarea { min-height: 90px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.list-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); gap: 8px; flex-wrap: wrap; }
.btn-wide { width: 100%; justify-content: center; padding: 10px 16px; font-size: 15px; } /* same height and font as .btn-create */
.list-chips .btn-wide { flex: 1 0 100%; margin-top: 8px; }
.list-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.bulk-box { border: 1px dashed var(--accent-line); background: var(--row-hover); border-radius: 8px; padding: 10px; margin-top: 8px; }
.bulk-box .field { margin: 8px 0 0; }

/* schedule */
.schedule { margin-top: 10px; user-select: none; }
.schedule table { border-collapse: collapse; }
.schedule td { width: 16px; height: 18px; border: 1px solid var(--surface); background: var(--track); cursor: pointer; }
.schedule td.on { background: var(--blue); }
.schedule th { font-size: 10px; color: var(--muted); font-weight: 400; padding: 0 2px; }
.schedule .day { text-align: right; padding-right: 6px; font-size: 12px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 50px 20px; overflow: auto; }
.modal { background: var(--pop); border-radius: 14px; width: 100%; max-width: 760px; padding: 22px 24px; box-shadow: 0 20px 50px rgba(var(--shade-rgb), .25); }
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.modal-backdrop.modal-center { align-items: center; z-index: 60; animation: fade-in .12s ease-out; }
.modal-sm { max-width: 420px; padding: 24px; animation: pop-in .14s ease-out; }
.modal-sm h2 { margin-bottom: 12px; }
.modal-sm input[type=text] { width: 100%; margin-bottom: 14px; }
.modal-md { max-width: 560px; animation: pop-in .14s ease-out; }
.modal-md .result-list { max-height: 50vh; }
/* ad card: fixed-height window, header stays, the body scrolls inside */
.modal-backdrop:has(> .modal-scroll) { align-items: center; padding: 24px 20px; overflow: hidden; }
.modal-scroll { padding: 0; max-height: calc(100vh - 48px); display: flex; flex-direction: column; overflow: hidden; animation: pop-in .14s ease-out; }
.modal-scroll .modal-frame { display: flex; flex-direction: column; min-height: 0; }
.modal-scroll .modal-head { margin: 0; padding: 20px 24px 14px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0; }
/* no top padding: a sticky header sticks below the padding and rows would show through the strip */
.modal-scroll .modal-body { overflow-y: auto; min-height: 0; padding: 0 24px 24px; overscroll-behavior: contain; }
/* inside the modal the body is the scroll container, so the stats header sticks to its top */
.modal-scroll .modal-body .table-wrap { overflow: visible; max-height: none; }
.modal-scroll .modal-body table.grid th { top: 0; }
.confirm-body { font-size: 14px; color: var(--text-2); line-height: 1.5; }
.confirm-kv { grid-template-columns: 1fr auto; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.confirm-kv > div:nth-child(even) { text-align: right; font-weight: 600; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.confirm-actions .btn { min-width: 110px; justify-content: center; }
.btn-danger-solid { background: var(--danger-solid); border-color: var(--danger-solid); color: var(--on-accent); }
.btn-danger-solid:hover { background: var(--danger-strong); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96); } }
.modal-close { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal section { border-top: 1px solid var(--border-soft); padding-top: 14px; margin-top: 14px; }
.modal section h3 { font-size: 14px; margin: 0 0 10px; }
.modal .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.modal .btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.head-meta { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 2px; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }
.decline { background: var(--danger-soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.progress { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; margin: 12px 0; }
.progress > div { height: 100%; background: var(--blue); transition: width .3s; }
.result-list { max-height: 360px; overflow: auto; font-size: 13px; }
.result-list div { padding: 4px 0; border-bottom: 1px solid var(--border-soft); }

/* toasts */
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--pop); color: var(--text); border: 1px solid var(--border); padding: 10px 14px 10px 10px; border-radius: 12px; font-size: 13px; font-weight: 500; max-width: 420px; box-shadow: 0 10px 30px rgba(var(--shade-rgb), .14); cursor: pointer; animation: toast-in .18s ease-out; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
.toast-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; line-height: 1; background: var(--blue-light); color: var(--accent-strong); }
.toast.ok .toast-icon { background: var(--success-soft); color: var(--success-text); }
.toast.error .toast-icon { background: var(--danger-soft); color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.spinner { width: 14px; height: 14px; border: 2px solid var(--blue); border-top-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ad card ---------- */
.modal-item { max-width: 980px; height: calc(100vh - 48px); }
.modal-item .modal-frame { flex: 1; }
.modal-item .modal-body { flex: 1; }
.modal-scroll .modal-head.item-head { flex-direction: column; align-items: stretch; gap: 12px; padding-bottom: 0; }
.item-head-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-tabs { display: flex; gap: 4px; margin: 0 -4px; }
.modal-tabs button { border: none; background: none; padding: 10px 12px; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.modal-tabs button:hover { color: var(--text); }
.modal-tabs button.active { color: var(--text); border-bottom-color: var(--blue); }
.modal-item .modal-body { background: var(--bg); padding: 18px 24px 24px; }
/* sticky stops below the scroller's top padding; pull the header up over it so no rows peek above */
.modal-item .modal-body table.grid th { top: -18px; }
.item-tab { display: flex; flex-direction: column; gap: 14px; }
.item-tab-note { margin-bottom: -4px; }
.item-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 0; }
.item-kpis .kpi-value { font-size: 18px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; min-width: 0; }
.panel-title { font-weight: 700; font-size: 16px; letter-spacing: -.01em; margin-bottom: 14px; }
.panel-sub { font-weight: 500; font-size: 13px; color: var(--text-2); margin: 16px 0 8px; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.panel .field > .field-label { font-weight: 500; font-size: 13px; color: var(--text-2); }
.panel .preview { margin-bottom: 0; }
.panel .field:last-child { margin-bottom: 0; }
.panel .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.item-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }
.item-kv { display: flex; flex-direction: column; }
.item-kv-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-top: 1px solid var(--border-soft); font-size: 13px; }
.item-kv-row:first-child { border-top: none; padding-top: 0; }
.item-kv-row .k { color: var(--muted); }
.item-kv-row .v { min-width: 0; overflow-wrap: anywhere; }
.item-budget-row { display: flex; gap: 8px; align-items: center; }
.item-budget-row .input-prefix { flex: 1; min-width: 100px; }
.modal-item .table-card table.grid { font-size: 13px; }
.modal-item .auto-journal-compact { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
tr.total-row td { font-weight: 600; background: var(--surface-2); }
.modal-item .modal-foot .btn-row { flex-wrap: nowrap; }
.modal-item .modal-foot > .muted { min-width: 0; }
@media (max-width: 820px) {
  .item-pair { grid-template-columns: 1fr; }
  .item-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- automations ---------- */
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.nowrap { white-space: nowrap; }
.auto-toolbar { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 12px; }
.auto-group { margin-bottom: 22px; }
.auto-group-title { font-weight: 600; margin: 0 0 8px; }
.auto-group-title a { color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.auto-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 10px; }
.auto-card.off { background: var(--surface-2); }
.auto-card.off .auto-phrase, .auto-card.off .auto-name { opacity: .6; }
.auto-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.auto-name { font-weight: 600; font-size: 15px; color: var(--text); text-decoration: none; }
.auto-name:hover { color: var(--accent-text); }
.auto-card-camps { display: flex; flex-wrap: wrap; gap: 6px; }
.auto-card-camps a.badge { text-decoration: none; }
.auto-card-camps a.badge:hover { background: var(--track); }
.attach-menu { min-width: 280px; max-width: 360px; max-height: 320px; overflow: auto; }
.attach-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; white-space: normal; }
.attach-item .small { overflow-wrap: anywhere; }
.menu-note { padding: 8px 10px; }
.auto-order { display: flex; }
.auto-phrase { line-height: 2; }
.auto-kw { color: var(--muted); font-weight: 600; }
.auto-chip { display: inline; background: var(--hover); border-radius: 7px; padding: 3px 8px; white-space: nowrap; }
.auto-chip-action { background: var(--blue-light); color: var(--accent-strong); }

.tgl { position: relative; display: inline-flex; width: 36px; height: 20px; flex: none; cursor: pointer; }
.tgl input { opacity: 0; width: 0; height: 0; position: absolute; }
.tgl span { position: absolute; inset: 0; background: var(--track-strong); border-radius: 20px; transition: background .15s; }
.tgl span::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; background: var(--knob); border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(var(--shade-rgb), .2); }
.tgl input:checked + span { background: var(--green); }
.tgl input:checked + span::after { transform: translateX(16px); }

.auto-editor .auto-section { margin: 14px 0; }
.auto-row { display: flex; align-items: center; gap: 8px; }
.auto-limit { display: inline-flex; align-items: center; gap: 8px; flex-wrap: nowrap; white-space: nowrap; }
.auto-fields { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.auto-row .ui-select { width: auto; }
.auto-kw-cell { width: 76px; flex: none; font-weight: 600; color: var(--muted); }
.auto-editor .hint { font-size: 12px; color: var(--muted); line-height: 1.45; }
.auto-cond-group { border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.auto-or { font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: 12px; letter-spacing: .06em; margin: 8px 0 8px 10px; }
.auto-add { align-self: flex-start; margin-top: 8px; }
.auto-cond-group .auto-add { margin: 0 0 0 84px; }
.auto-now { width: 90px; }
.auto-op { width: 64px !important; }
.auto-val { width: 130px; }
.auto-row input.auto-num { width: 110px; }
.auto-row .auto-val input.auto-num { width: 100%; }
.auto-act { margin-bottom: 8px; }
.auto-note { margin: 4px 0 0 84px; }
.auto-acts { display: flex; flex-direction: column; }
.auto-preview { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.auto-preview-list { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow: auto; }
.auto-preview-row { display: flex; flex-direction: column; padding: 6px 10px; background: var(--surface-2); border-radius: 8px; }
.auto-preview-title { font-weight: 500; }
.auto-more { display: flex; justify-content: center; margin: 12px 0; }
.auto-journal-compact table.grid { font-size: 13px; }

/* ---------- profile ---------- */
.profile-wrap { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.profile-wrap .page-head { margin-bottom: 6px; }
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-head-text { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.profile-name-row { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.profile-name { font-size: 20px; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.profile-name-form { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.profile-name-form input { flex: 1; min-width: 160px; width: auto; }
.profile-lead { margin: -8px 0 6px; font-size: 13px; line-height: 1.5; }
p.profile-lead { margin: 0 0 14px; }
.profile-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.profile-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border-soft); }
.profile-row:first-of-type { border-top: none; }
.profile-row-icon { flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--hover); display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.profile-row-icon .ic { width: 18px; height: 18px; }
.profile-row-icon.tg { color: var(--accent-text); }
.profile-row-text { flex: 1; min-width: 0; }
.profile-row-title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-row-text .small { overflow-wrap: anywhere; }
.profile-row .btn { flex: none; }
.profile-row .role-select { flex: none; width: 170px; }
.profile-row .btn:disabled { opacity: .5; cursor: default; }
.panel.danger-zone { border-color: var(--danger-line); }
.panel.danger-zone .panel-title { color: var(--red); }
@media (max-width: 760px) {
  .profile-head { align-items: flex-start; }
  .profile-row { flex-wrap: wrap; }
  .profile-row .btn { margin-left: 48px; }
}

/* ---------- automation rule page ---------- */
.rule-wrap { max-width: 1180px; margin: 0 auto; }
.rule-lead { margin: -6px 0 18px; }
.rule-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.rule-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.rule-summary { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; }
.rule-summary .panel-title { margin-bottom: 0; }
.rule-summary-body { display: flex; flex-direction: column; gap: 10px; }
.rule-sum-block .auto-phrase { line-height: 1.9; }
.rule-impact { background: var(--blue-light); color: var(--accent-strong); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.rule-summary .auto-preview { border-top: 1px solid var(--border-soft); margin-top: 0; padding-top: 12px; }
.rule-summary-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.rule-step .panel-title { display: flex; align-items: center; gap: 10px; }
.rule-step-num { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--blue-light); color: var(--accent-strong); font-size: 13px; font-weight: 700; }
.rule-step .hint { font-size: 12px; color: var(--muted); line-height: 1.45; margin-top: 10px; }
.rule-step .hint.error-text { color: var(--red); }
.rule-name-row { display: flex; align-items: center; gap: 10px; }
.rule-name-row input { flex: 1; min-width: 0; font-weight: 600; }
.rule-or-block { margin: 0; }
.rule-camp-all { display: flex; align-items: center; gap: 10px; padding: 4px 0 10px; cursor: pointer; }
.rule-camp-list { display: flex; flex-direction: column; max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.rule-camp { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.rule-camp:hover { background: var(--hover); }
.rule-camp .ic { color: var(--muted); }
.rule-journal h2 { font-size: 16px; margin: 6px 0 10px; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.template-card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; color: var(--text); text-decoration: none; transition: border-color .12s, box-shadow .12s; }
.template-card:hover { border-color: var(--blue); box-shadow: 0 2px 10px rgba(var(--accent-rgb), .12); }
.template-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: var(--blue-light); color: var(--accent-strong); margin-bottom: 4px; }
@media (max-width: 1000px) {
  .rule-layout { grid-template-columns: minmax(0, 1fr); }
  .rule-summary { position: static; }
}
@media (max-width: 760px) {
  .auto-kw-cell { width: 52px; }
  .auto-cond-group .auto-add, .auto-note { margin-left: 60px; }
}

/* ---------- background jobs: top-bar line, chip, job window ---------- */
.job-line { position: absolute; left: 0; right: 0; top: 0; height: 3px; overflow: hidden; opacity: 0; transition: opacity .25s; pointer-events: none; }
.job-line > div { height: 100%; width: 0; background: var(--blue); border-radius: 0 3px 3px 0; transition: width .6s ease; }
.job-line.on { opacity: 1; }
.job-line.finished > div { background: var(--green); }
.job-line.warn > div { background: var(--orange); }
.job-line.throttled > div { background: repeating-linear-gradient(135deg, var(--orange) 0 8px, var(--warn-stripe) 8px 16px); background-size: 22px 22px; animation: job-stripes 1.2s linear infinite; }
@keyframes job-stripes { to { background-position: 22px 0; } }
.job-chip-box { display: flex; }
.job-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--accent-line); background: var(--blue-light); color: var(--accent-strong); border-radius: 999px; padding: 4px 12px 4px 8px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.job-chip:hover { border-color: var(--blue); }
.job-chip.throttled { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-text); }
.job-ring { width: 18px; height: 18px; transform: rotate(-90deg); flex: none; }
.job-ring circle { fill: none; stroke-width: 2.5; }
.job-ring-bg { stroke: rgba(var(--accent-rgb), .2); }
.job-ring-arc { stroke: currentColor; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.job-stage { color: var(--muted); font-size: 13px; margin: 4px 0 12px; line-height: 1.45; }
.job-throttle { background: var(--warn-soft); color: var(--warn-text); border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-bottom: 12px; line-height: 1.45; }
.job-bar { display: flex; height: 10px; background: var(--track); border-radius: 5px; overflow: hidden; }
.job-seg { height: 100%; transition: width .4s ease; }
.job-seg.ok { background: var(--green); }
.job-seg.same { background: var(--neutral); }
.job-seg.bad { background: var(--red); }
.job-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 12px; font-size: 13px; color: var(--text-2); }
.job-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: var(--green); } .dot.same { background: var(--neutral); } .dot.bad { background: var(--red); } .dot.left { background: var(--track); border: 1px solid var(--border-strong); }
.job-filter-row { margin: 0 0 8px; }
.modal.job-window { height: min(80vh, 720px); display: flex; flex-direction: column; }
.job-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.job-body .result-list { flex: 1; min-height: 0; max-height: none; }
.job-body .job-footer { margin-top: 12px; flex: none; }
.job-empty { color: var(--muted); padding: 12px 0; text-align: center; }
.job-list { display: flex; flex-direction: column; gap: 6px; }
.job-list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--btn-bg); font: inherit; cursor: pointer; }
.job-list-row:hover { border-color: var(--blue); }
@media (max-width: 760px) { .job-chip-text { display: none; } .job-chip { padding: 4px 6px; } }

/* teams */
.menu-section { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.menu-sep { height: 1px; background: var(--track); margin: 4px 0; }
.menu-org { display: flex; align-items: center; gap: 8px; }
.menu-org .ic { width: 16px; height: 16px; flex: none; }
.menu-org-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-org-role { font-size: 11px; color: var(--muted); }
.menu-org.active .menu-org-role { color: var(--accent-text); }
.role-badge { display: inline-block; font-size: 12px; font-weight: 500; color: var(--muted); background: var(--hover); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.invite-link { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 10px 0 14px; user-select: all; }
.profile-wrap .btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* billing */
.billing-note { display: flex; width: fit-content; max-width: 100%; align-items: center; gap: 8px 14px; margin-bottom: 14px; padding: 8px 8px 8px 14px; border-radius: 10px; font-size: 13px; line-height: 1.45; background: var(--blue-light); color: var(--accent-ink); }
.billing-note .btn { flex: none; }
.billing-note-close { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin-left: -6px; border: none; border-radius: 7px; background: none; color: inherit; opacity: .6; cursor: pointer; }
.billing-note-close:hover { opacity: 1; background: var(--hover); }
.billing-note-close .ic { width: 16px; height: 16px; }
.billing-note.grace { background: var(--warn-soft); color: var(--warn-text); }
.billing-note.frozen { background: var(--danger-soft); color: var(--danger-text); }
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 12px 0 0; }
.price-step { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: border-color .12s, background .12s; }
.price-step:hover { border-color: var(--border-strong); }
.price-step.active { border-color: var(--accent-solid); background: var(--blue-light); box-shadow: 0 0 0 1px var(--accent-solid); }
.price-months { font-size: 12px; color: var(--muted); }
.price-total { font-size: 18px; font-weight: 600; margin: 2px 0; }
.pay-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pay-title .btn-link { font-weight: 500; }
.pay-accounts { display: flex; flex-direction: column; margin: 4px 0 0; }
.pay-account { padding: 10px 0; gap: 12px; border-top: 1px solid var(--border-soft); font-size: 14px; }
.pay-account:first-child { border-top: none; }
.pay-account-text { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pay-account-title { font-weight: 600; overflow-wrap: anywhere; }
.pay-account .badge { flex: none; }
.pay-summary { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.pay-sum { display: flex; flex-direction: column; gap: 2px; }
.pay-sum-total { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pay-total { font-size: 26px; font-weight: 600; }
.pay-methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }
.pay-method { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: border-color .12s, background .12s; }
.pay-method:hover { border-color: var(--border-strong); }
.pay-method:disabled { opacity: .5; cursor: not-allowed; }
.pay-method.active { border-color: var(--accent-solid); background: var(--blue-light); box-shadow: 0 0 0 1px var(--accent-solid); }
.pay-method .ic { flex: none; width: 22px; height: 22px; color: var(--accent-text); }
.pay-method-name { font-weight: 600; }
.pay-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 4px; }
.pay-rules { margin: 4px 2px 0; line-height: 1.5; }
.tariff-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; margin-bottom: 14px; }
.tariff-steps { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.tariff-step { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tariff-step input { width: 64px; }
.tariff-save { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.pay-return { border-color: var(--accent-line); }

/* ---------- admin section ---------- */
.admin-wrap { max-width: 1240px; margin: 0 auto; }
.admin-body { display: flex; flex-direction: column; gap: 16px; }
.admin-list { display: flex; flex-direction: column; gap: 16px; }
.admin-list > .table-card, .admin-list > .kpi-grid { margin: 0; }
.admin-wrap .btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.admin-wrap .panel > .muted.small + .btn-row, .admin-wrap .panel > .btn-row { margin-top: 12px; }
.admin-pay-actions { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.admin-invoice-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.admin-test { padding: 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; }
.admin-test-note { flex: 1 1 100%; margin: 0; }
.admin-wrap .panel > .hint { margin: 0 0 12px; }
.admin-wrap .panel > .table-card { margin-top: 4px; }
.stack { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.admin-tabs { overflow-x: auto; scrollbar-width: none; margin-bottom: 18px; }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tabs a { flex: none; }
.admin-h { margin: 8px 0 -4px; font-size: 15px; }
.admin-kpis { margin-bottom: 0; }
a.kpi-link { color: inherit; text-decoration: none; display: block; transition: border-color .12s; }
a.kpi-link:hover { border-color: var(--accent-line); text-decoration: none; }
.admin-kpis .kpi-value { white-space: normal; overflow-wrap: anywhere; font-size: 18px; }
.abars { position: relative; display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 6px; }
.acol { flex: 1; min-width: 3px; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.abar { width: 100%; background: var(--chart-bar-soft); border-radius: 3px 3px 0 0; transition: background .1s; }
.acol:hover .abar { background: var(--blue); }
.abars-tip { position: absolute; bottom: calc(100% + 4px); transform: translateX(-50%); display: none; flex-direction: column; align-items: center; gap: 1px; padding: 6px 10px; background: var(--tip-bg); color: var(--tip-fg); border-radius: 8px; font-size: 12px; white-space: nowrap; pointer-events: none; z-index: 5; }
.abars-tip b { font-size: 13px; }
.abars-tip.on { display: flex; }
.admin-toolbar { display: flex; flex-direction: column; gap: 8px; }
.admin-toolbar .toolbar-row { flex-wrap: wrap; align-items: center; gap: 8px; }
.admin-seg { max-width: 100%; }
.ucell { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; min-width: 0; }
.ucell:hover .ucell-name { text-decoration: underline; }
.ucell-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.ucell-name { font-weight: 600; }
.ucell .badge { margin-left: 4px; }
.admin-grid td .badge { margin: 2px 0 0 6px; }
.admin-grid td { white-space: nowrap; }
.admin-grid td.left { white-space: normal; min-width: 140px; }
.admin-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 4px 0; }
.admin-count { text-align: right; margin: 2px 0; }
.admin-head { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.admin-head h2 { margin: 0 0 2px; font-size: 20px; }
.admin-head-main { display: flex; gap: 16px; align-items: center; min-width: 0; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-text); cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.admin-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.admin-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.admin-back { font-size: 13px; margin-bottom: -4px; }
.admin-sub { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 6px; }
.admin-wrap .panel > .profile-row { flex-wrap: wrap; gap: 8px 12px; }
.admin-wrap .panel > .btn { margin-top: 10px; }
.picker { display: flex; flex-direction: column; gap: 8px; }
.picker-list { max-height: 190px; overflow: auto; display: flex; flex-direction: column; }
.picker-list .menu-item { text-align: left; }
.imp-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; padding: 8px 16px; background: var(--amber); color: var(--on-accent); font-size: 13px; font-weight: 500; position: relative; z-index: 60; }
.imp-bar .btn { background: var(--on-accent); border-color: transparent; color: var(--amber-ink); }
body.impersonating::after { content: ''; position: fixed; inset: 0; border: 3px solid var(--amber); pointer-events: none; z-index: 9999; }
.menu-theme { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 10px; }
.profile-row-theme { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
