:root {
  --bg: #f4f1ec;
  --card: #fffdf9;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --accent: #0f766e;
  --accent-2: #134e4a;
  --warn: #b45309;
  --err: #b91c1c;
  --ok: #15803d;
  --font: "Segoe UI", system-ui, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 0.9375rem;
  --text-lg: 1rem;
  --text-xl: 1.125rem;
  /* Площадки — как строки профиля в Google Sheets */
  --platform-direct: #f1c232;
  --platform-direct-text: #1c1917;
  --platform-vk: #4a90d9;
  --platform-vk-text: #ffffff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(ellipse at top left, #d9f99d33, transparent 40%),
    linear-gradient(180deg, #faf7f2, var(--bg));
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.92);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: var(--text-sm);
}
.top-left {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  flex: 1;
}
.brand {
  flex-shrink: 0;
  font-weight: 700;
  font-size: var(--text-md);
  color: var(--accent-2);
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; opacity: 0.85; }
.top-nav {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f5f5f4;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.top-nav::-webkit-scrollbar { display: none; }
.top-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 550;
  font-size: var(--text-sm);
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.top-nav-link:hover {
  color: var(--ink);
  text-decoration: none;
  background: #ebeae8;
}
.top-nav-link.is-active {
  color: var(--accent-2);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(15, 118, 110, 0.18);
  font-weight: 650;
}
.top-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}
.top-user-email {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #44403c;
  font-size: var(--text-sm);
  font-weight: 500;
}
.top-logout {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 550;
  font-size: var(--text-sm);
  background: #fff;
}
.top-logout:hover {
  text-decoration: none;
  border-color: #a8a29e;
  background: #fafaf9;
}
@media (max-width: 780px) {
  .top {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
  }
  .top-left {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .top-nav {
    width: 100%;
  }
  .top-nav-link {
    flex: 1;
    padding: 8px 10px;
    font-size: var(--text-xs);
  }
  .top-user {
    justify-content: space-between;
    padding-left: 0;
    border-left: none;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }
  .top-user-email { max-width: none; }
}
.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 16px 48px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; box-shadow: 0 10px 30px #00000008;
}
.login-card { max-width: 400px; margin: 80px auto; }
h1 { margin: 0 0 6px; font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.02em; }
h2 { margin: 0 0 10px; font-size: var(--text-lg); font-weight: 600; }
.muted { color: var(--muted); font-size: var(--text-sm); }
.error { color: var(--err); }
.row { display: flex; gap: 12px; align-items: center; }
.between { justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.settings-form { display: flex; flex-direction: column; gap: 16px; }
.settings-block {
  padding: 14px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafaf9;
}
.settings-title {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.settings-block .form-grid { margin-bottom: 10px; }
.settings-block .form-grid:last-child { margin-bottom: 0; }
.check-card {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.check-card:hover { border-color: #a8a29e; }
.check-card:has(input:checked) {
  border-color: #99f6e4;
  background: #f0fdfa;
}
.check-card input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.check-card span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.check-card strong { font-size: 0.95rem; font-weight: 600; }
.check-card small { font-size: 0.8rem; color: var(--muted); line-height: 1.35; }
.settings-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}
.settings-actions button { min-width: 200px; }
.autosave-hint { font-size: 0.8rem; white-space: nowrap; }
.autosave-status {
  min-height: 0;
  margin: 0 0 12px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity 0.2s;
}
.autosave-status:empty { display: none; }
.autosave-status.pending { color: var(--muted); }
.autosave-status.ok { color: var(--ok); }
.autosave-status.err { color: var(--err); }
.confirm-dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  max-width: 420px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 50px #0003;
}
.confirm-dialog::backdrop { background: #1c191780; }
.confirm-dialog-inner { margin: 0; padding: 20px 22px; }
.confirm-dialog-inner h3 { margin: 0 0 8px; font-size: 1.15rem; }
.confirm-dialog-inner p { margin: 0 0 18px; line-height: 1.45; }
.confirm-dialog-actions {
  display: flex; justify-content: flex-end; gap: 10px;
}
.confirm-dialog-actions button:disabled {
  opacity: 0.45; cursor: not-allowed;
}
input, select, textarea, button {
  font: inherit; font-size: var(--text-sm); border-radius: 8px;
  border: 1px solid var(--line); padding: 7px 10px; background: #fff;
}
textarea { resize: vertical; }
button, .btn {
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  padding: 7px 12px; border-radius: 8px; font-size: var(--text-sm);
  font-weight: 600; display: inline-block;
}
button:hover, .btn:hover { background: var(--accent-2); text-decoration: none; }
.btn.secondary { background: #44403c; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: var(--text-xs); text-transform: none; }
td.name { max-width: 280px; word-break: break-word; }
table.tight input, table.tight select { width: 100%; padding: 6px 8px; }
.badge {
  display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: var(--text-xs);
  background: #e7e5e4; color: #44403c; font-weight: 600;
}
.badge.ok { background: #dcfce7; color: var(--ok); }
a.badge.ok { text-decoration: none; cursor: pointer; }
a.badge.ok:hover { background: #bbf7d0; text-decoration: none; }
.badge.warn { background: #ffedd5; color: var(--warn); }
.badge.direct {
  background: var(--platform-direct);
  color: var(--platform-direct-text);
  border: 1px solid #d4a017;
}
.badge.vk {
  background: var(--platform-vk);
  color: var(--platform-vk-text);
  border: 1px solid #3a7bc8;
}
.tabs {
  display: flex; gap: 4px; margin: 0 0 14px; padding: 4px;
  background: #f5f5f4; border-radius: 12px; border: 1px solid var(--line);
}
.tab {
  flex: 1; background: transparent; color: var(--muted); border: none;
  padding: 7px 10px; border-radius: 8px; font-size: var(--text-sm);
  font-weight: 600; cursor: pointer;
}
.tab:hover { background: #fff; color: var(--ink); }
.tab.active { background: #fff; color: var(--accent-2); box-shadow: 0 1px 3px #0001; }
.tab[data-platform="direct"].active {
  background: var(--platform-direct);
  color: var(--platform-direct-text);
  box-shadow: 0 0 0 1px #d4a017;
}
.tab[data-platform="vk"].active {
  background: var(--platform-vk);
  color: var(--platform-vk-text);
  box-shadow: 0 0 0 1px #3a7bc8;
}
.platform-fields { gap: 10px; }
.vk-auth-switch {
  display: flex; gap: 4px; margin: 0 0 4px; padding: 4px;
  background: #f5f5f4; border-radius: 12px; border: 1px solid var(--line);
}
.vk-auth-opt {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: transparent; color: var(--muted); border: none;
  padding: 8px 10px; border-radius: 8px; font-size: var(--text-sm);
  font-weight: 700; cursor: pointer; text-align: left; line-height: 1.25;
}
.vk-auth-opt small {
  font-size: 11px; font-weight: 500; color: var(--muted); opacity: .9;
}
.vk-auth-opt:hover { background: #fff; color: var(--ink); }
.vk-auth-opt.active {
  background: var(--platform-vk);
  color: var(--platform-vk-text);
  box-shadow: 0 0 0 1px #3a7bc8;
}
.vk-auth-opt.active small { color: inherit; opacity: .85; }
.vk-auth-fields { gap: 10px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }
.log {
  background: #1c1917; color: #d6d3d1; padding: 12px; border-radius: 10px;
  white-space: pre-wrap; font-size: 0.85rem; margin: 12px 0;
}
.hidden { display: none; }
code { background: #f5f5f4; padding: 1px 5px; border-radius: 4px; }
.flash.ok-msg {
  background: #dcfce7; color: var(--ok); padding: 10px 14px; border-radius: 10px;
  margin: 8px 0 16px; font-weight: 600;
}
.campaigns-card { margin-top: 16px; }
.bulk-bar {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px; margin: 12px 0; background: #f5f5f4; border-radius: 12px; border: 1px solid var(--line);
}
.bulk-bar > input[type="search"] { width: 100%; }
.bulk-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bulk-tools input, .bulk-tools select { min-width: 180px; flex: 1; }
.table-scroll { overflow: auto; max-height: 62vh; border: 1px solid var(--line); border-radius: 12px; }
.camp-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.camp-table thead th {
  position: sticky; top: 0; background: #fafaf9; z-index: 1;
  border-bottom: 1px solid var(--line); padding: 10px 8px;
}
.camp-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.camp-table .col-check { width: 42px; text-align: center; }
.camp-table .col-on { width: 52px; text-align: center; }
.camp-table .name { max-width: 320px; word-break: break-word; font-weight: 500; }
.camp-table .goal-input, .camp-table .attr-select { width: 100%; padding: 8px 10px; }
.camp-row:hover { background: #f0fdf4; }
.save-bar {
  position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-top: 12px; padding: 12px 4px 4px; background: linear-gradient(transparent, var(--card) 30%);
}
.save-all { font-size: 1rem; padding: 12px 18px; }
.pager {
  display: flex; justify-content: center; align-items: center; gap: 12px;
  margin-top: 14px; padding-top: 4px;
}
.pager .btn { text-decoration: none; }
.pager .btn.disabled {
  opacity: 0.4; pointer-events: none; cursor: default;
}
.btn.small { padding: 5px 9px; font-size: var(--text-xs); }
.btn:disabled, .btn.disabled {
  opacity: 0.45; cursor: not-allowed;
}
.ws-hint {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 8px;
  font-size: var(--text-sm); line-height: 1.45;
  background: #f0fdfa; border: 1px solid #99f6e4; color: var(--accent-2);
}
.ws-hint.warn-hint {
  background: #fff7ed; border-color: #fdba74; color: #9a3412;
}
.admin-hidden ul { list-style: none; margin: 0; padding: 0; }
.admin-hidden li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.add-section { margin-top: 20px; }

/* —— Workspace: проекты + таблица профилей —— */
.ws-page-head { margin-bottom: 12px; align-items: center; }
.ws-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 400px;
  padding: 0;
  overflow: hidden;
}
.ws-sidebar {
  border-right: 1px solid var(--line);
  background: #fafaf9;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: var(--text-sm);
}
.ws-sidebar-title {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 6px;
}
.ws-project-search { padding: 0 2px; }
.ws-project-search input {
  width: 100%;
  padding: 6px 8px;
  font-size: var(--text-sm);
}
.ws-search-empty {
  margin: 10px 6px;
  font-size: var(--text-xs);
  text-align: center;
}
.ws-nav-item.is-filtered-out { display: none; }
.ws-new-project {
  display: flex;
  gap: 5px;
  padding: 0 2px;
}
.ws-new-project input { flex: 1; min-width: 0; padding: 6px 8px; font-size: var(--text-sm); }
.ws-new-project button {
  width: 32px; padding: 0; flex-shrink: 0;
  font-size: var(--text-md); line-height: 1;
}
.ws-nav { display: flex; flex-direction: column; gap: 1px; flex: 1; overflow: auto; }
.ws-nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; padding: 7px 10px; border: none; border-radius: 7px;
  background: transparent; color: var(--ink); font: inherit; font-size: var(--text-sm);
  font-weight: 500; text-align: left; cursor: pointer;
}
.ws-nav-item:hover { background: #fff; }
.ws-nav-item.active {
  background: #fff;
  color: var(--accent-2);
  box-shadow: 0 1px 3px #0000000d;
  font-weight: 600;
}
.ws-nav-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-nav-count {
  flex-shrink: 0; min-width: 18px; text-align: center;
  font-size: var(--text-xs); font-weight: 600; color: var(--muted);
  background: #e7e5e4; border-radius: 999px; padding: 1px 6px;
}
.ws-nav-item.active .ws-nav-count { background: #ccfbf1; color: var(--accent-2); }
.ws-panel-actions { gap: 8px; flex-wrap: wrap; align-items: center; }
.ws-sheets-btn.ws-sheets-primary {
  background: var(--accent);
  color: #fff;
  font-size: var(--text-sm);
  padding: 7px 12px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: none;
}
.ws-sheets-btn.ws-sheets-primary:hover {
  background: var(--accent-2);
  color: #fff;
  text-decoration: none;
}
.ws-collect-btn.ws-collect-muted,
.btn.ws-collect-muted {
  background: #a8a29e;
  color: #fff;
}
.ws-collect-btn.ws-collect-muted:hover,
.btn.ws-collect-muted:hover {
  background: #78716c;
}
.ws-visibility-form { margin: 0; display: inline-flex; }
.ws-visibility-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.ws-visibility-btn svg {
  width: 14px;
  height: 14px;
}
.ws-visibility-btn:hover {
  background: #fafaf9;
  color: var(--ink);
  border-color: #d6d3d1;
}
.ws-visibility-btn.is-hiding {
  color: var(--muted);
  opacity: 0.7;
}
.ws-visibility-btn .hidden { display: none; }
.ws-sheets-btn.is-updated {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 0 0 3px #0f766e40;
  animation: ws-sheets-glow 1.4s ease-in-out 4;
}
.ws-sheets-btn.is-updated:hover { background: var(--accent-2); color: #fff; text-decoration: none; }
@keyframes ws-sheets-glow {
  0%, 100% { box-shadow: 0 0 0 3px #0f766e40; }
  50% { box-shadow: 0 0 0 7px #0f766e1a; }
}
.ws-main { padding: 14px 16px; min-width: 0; }
.ws-panel { display: none; position: relative; }
.ws-panel.active { display: block; }
.ws-panel-head { margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }
.ws-panel-title.ws-project-name {
  margin: 0 0 2px;
  font-size: var(--text-lg);
  font-weight: 600;
  cursor: text;
  border-radius: 6px;
  padding: 2px 4px;
  margin-left: -4px;
  outline: none;
}
.ws-panel-title.ws-project-name:hover {
  background: #f5f5f4;
}
.ws-rename-input {
  display: block;
  font: inherit;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--ink);
  border: none;
  border-radius: 6px;
  padding: 2px 4px;
  margin: 0 0 2px -4px;
  width: min(320px, 100%);
  background: #fff;
  box-shadow: 0 0 0 2px var(--accent);
  outline: none;
}
.ws-panel-sub { margin: 0; font-size: var(--text-xs); }
.ws-table-wrap { border: 1px solid var(--line); border-radius: 10px; max-height: none; }
.ws-table { font-size: var(--text-sm); }
.ws-table thead th {
  position: sticky; top: 0; background: #fafaf9; z-index: 1;
  border-bottom: 1px solid var(--line); padding: 7px 10px;
}
.ws-table td { padding: 8px 10px; vertical-align: middle; }
.ws-table .name { font-weight: 600; font-size: var(--text-sm); max-width: 220px; }
.ws-table .ws-actions { text-align: right; white-space: nowrap; font-size: var(--text-sm); }
.ws-table code { font-size: var(--text-xs); }
.ws-move-select { width: 100%; min-width: 130px; max-width: 180px; padding: 5px 8px; font-size: var(--text-xs); }
.ws-empty { padding: 24px 12px; text-align: center; font-size: var(--text-sm); }

/* Аналитика проекта */
.ws-analytics-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 28px #0f766e55;
}
.ws-analytics-fab:hover { background: var(--accent-2); }
.ws-panel:not(.active) .ws-analytics-fab,
.ws-analytics-fab.hidden { display: none; }
.ws-panel-analytics .ws-panel-actions { display: none; }
.ws-panel-analytics .ws-panel-sub { display: none; }
.ws-analytics-fab .ws-fab-icon-back.hidden,
.ws-analytics-fab .ws-fab-icon-chart.hidden { display: none; }
.ws-analytics-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 360px;
  padding-bottom: 72px;
}
.ws-analytics-view.hidden { display: none; }
.ws-analytics-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 2px;
}
.ws-analytics-title {
  font-weight: 700;
  font-size: var(--text-md);
  color: var(--accent-2);
}
.ws-analytics-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px;
  background: #fafaf9;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.ws-an-block {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}
.ws-an-block-period label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 600;
  margin: 0;
}
.ws-analytics-controls select {
  min-width: 140px;
  font-weight: 500;
  color: var(--ink);
}
.ws-an-profiles,
.ws-an-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}
.ws-an-profiles-label {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 600;
  margin-right: 4px;
  min-width: 64px;
}
.ws-an-check {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 6px !important;
  font-size: var(--text-xs) !important;
  color: var(--ink) !important;
  font-weight: 500 !important;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}
.ws-an-check:has(input:checked) {
  border-color: #99f6e4;
  background: #f0fdfa;
}
.ws-an-check input { margin: 0; }
.ws-an-check .badge {
  font-size: 10px;
  padding: 1px 6px;
}
.ws-analytics-chart-wrap {
  position: relative;
  height: min(420px, 55vh);
  min-height: 300px;
  padding: 12px 10px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.ws-analytics-status { margin: 0; min-height: 1.2em; font-size: var(--text-xs); }

.ws-dialog {
  border: none; border-radius: 16px; padding: 0;
  max-width: 520px; width: calc(100% - 32px);
  box-shadow: 0 24px 60px #00000026;
}
.ws-dialog::backdrop { background: #1c191766; }
.ws-dialog form { margin: 0; padding: 16px 18px 18px; }
.ws-dialog-head { margin-bottom: 10px; align-items: flex-start; }
.ws-dialog-head h2 { margin: 0; font-size: var(--text-lg); }
.ws-dialog-close {
  background: none; border: none; color: var(--muted);
  font-size: var(--text-xl); line-height: 1; padding: 0 4px; cursor: pointer;
}
.ws-dialog-close:hover { color: var(--ink); background: none; }
@media (max-width: 860px) {
  .ws-layout { grid-template-columns: 1fr; }
  .ws-sidebar {
    border-right: none; border-bottom: 1px solid var(--line);
    max-height: 220px;
  }
  .ws-nav { flex-direction: row; flex-wrap: wrap; }
  .ws-nav-item { width: auto; flex: 1 1 auto; min-width: 120px; }
}
@media (max-width: 700px) {
  .bulk-tools input, .bulk-tools select { min-width: 100%; }
  .save-bar { flex-direction: column; align-items: stretch; }
}

/* —— Назначение проектов —— */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.assign-page { display: flex; flex-direction: column; gap: 14px; }
.assign-head { gap: 12px; }
.assign-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.assign-stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-size: var(--text-sm); color: var(--muted);
}
.assign-stat b { color: var(--ink); font-weight: 700; margin-right: 4px; }
.assign-stat-warn { border-color: #fcd34d; background: #fffbeb; }
.assign-toolbar {
  display: flex; flex-direction: column; gap: 12px;
}
.assign-search input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: var(--text-md); background: #fff;
}
.assign-filters {
  display: flex; flex-wrap: wrap; gap: 8px; max-height: 120px; overflow: auto;
}
.assign-chip {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 10px 6px 12px; cursor: pointer; font-size: var(--text-sm);
  color: var(--ink); max-width: 220px;
}
.assign-chip:hover { border-color: var(--accent); }
.assign-chip.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.assign-chip-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.assign-chip-count {
  font-variant-numeric: tabular-nums; opacity: 0.75; font-size: var(--text-xs);
}
.assign-chip.active .assign-chip-count { opacity: 0.9; }
.assign-bulk {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding-top: 4px; border-top: 1px dashed var(--line);
}
.assign-table-wrap { padding: 0; overflow: visible; }
.assign-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.assign-table th, .assign-table td {
  text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.assign-table th {
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); background: #fafaf9;
}
.assign-check-col { width: 36px; }
.assign-proj-name { font-weight: 600; }
.assign-empty { padding: 16px; margin: 0; }
.assign-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 8px; background: #ecfdf5;
  color: #065f46; font-size: var(--text-xs); font-weight: 600;
}
.assign-badge-none { background: #fff7ed; color: #9a3412; }
.assign-combo { position: relative; display: inline-block; max-width: 100%; }
.assign-assignee-btn, .assign-combo-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 4px 6px; border-radius: 8px; font: inherit;
}
.assign-assignee-btn:hover, .assign-combo-btn:hover {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}
.assign-caret { color: var(--muted); font-size: 0.7rem; }
.assign-combo-panel {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0;
  min-width: 260px; max-width: min(360px, 90vw);
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 16px 40px #00000018; padding: 8px;
}
.assign-combo-search {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 6px; font-size: var(--text-sm);
}
.assign-combo-list {
  max-height: 240px; overflow: auto; display: flex; flex-direction: column; gap: 2px;
}
.assign-combo-empty {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.4;
}
.assign-combo-empty strong {
  color: var(--ink);
  font-weight: 650;
}
.assign-combo-link {
  margin-top: 2px;
  font-weight: 550;
}
.assign-combo-opt {
  display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  width: 100%; text-align: left; border: none;
  background: transparent;
  color: var(--ink);
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font: inherit;
}
.assign-combo-opt:hover,
.assign-combo-opt:focus {
  background: #f0fdf4;
  color: var(--ink);
}
.assign-combo-opt .muted { color: var(--muted); }
.ws-panel-sub .assign-badge { vertical-align: middle; }

/* —— Почта —— */
.mail-page {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.75fr);
  gap: 18px;
  align-items: start;
  max-width: 1080px;
}
.mail-hero {
  grid-column: 1 / -1;
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 14px; flex-wrap: wrap;
}
.mail-hero h1 { margin: 0 0 4px; }
.mail-hero .muted { margin: 0; }
.mail-status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff;
  font-size: var(--text-sm); font-weight: 600;
}
.mail-status-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #a8a29e;
}
.mail-status-pill.is-on {
  background: #ecfdf5; border-color: #99f6e4; color: #065f46;
}
.mail-status-pill.is-on .mail-status-dot { background: #10b981; }
.mail-status-pill.is-off {
  background: #fff7ed; border-color: #fed7aa; color: #9a3412;
}
.mail-status-pill.is-off .mail-status-dot { background: #f97316; }

.mail-card { padding: 0; overflow: hidden; }
.mail-block {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}
.mail-block:last-of-type { border-bottom: none; }
.mail-block-title {
  margin: 0 0 12px;
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: #78716c;
}
.mail-providers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.mail-prov {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 10px !important;
  border: 1px solid var(--line) !important;
  border-radius: 14px !important;
  background: #fff !important;
  color: var(--ink) !important;
  cursor: pointer; font-weight: 600;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.mail-prov:hover { border-color: #a8a29e !important; }
.mail-prov.active {
  border-color: #5eead4 !important;
  background: #f0fdfa !important;
  box-shadow: 0 0 0 3px #ccfbf166;
}
.mail-prov-mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 0.95rem;
}
.mail-prov-gmail { background: #fee2e2; color: #b91c1c; }
.mail-prov-yandex { background: #fef3c7; color: #b45309; }
.mail-prov-mailru { background: #dbeafe; color: #1d4ed8; }
.mail-prov-smtp { background: #f5f5f4; color: #44403c; }
.mail-prov-name { font-size: var(--text-sm); }
.mail-hint { margin: 10px 0 0; font-size: var(--text-sm); line-height: 1.45; }

.mail-toggles { display: flex; flex-direction: column; gap: 8px; }
.mail-toggle {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff;
  cursor: pointer; color: var(--ink);
}
.mail-toggle:has(input:checked) {
  border-color: #99f6e4; background: #f0fdfa;
}
.mail-toggle input {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.mail-toggle-ui {
  width: 42px; height: 24px; border-radius: 999px;
  background: #d6d3d1; position: relative; flex-shrink: 0;
  transition: background 0.15s;
}
.mail-toggle-ui::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px #0002;
  transition: transform 0.15s;
}
.mail-toggle input:checked + .mail-toggle-ui { background: var(--accent); }
.mail-toggle input:checked + .mail-toggle-ui::after { transform: translateX(18px); }
.mail-toggle-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mail-toggle-copy strong { font-size: var(--text-md); font-weight: 600; }
.mail-toggle-copy small { font-size: 0.78rem; color: var(--muted); line-height: 1.35; }

.mail-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 12px;
}
.mail-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mail-field-grow { grid-column: 1 / 2; }
.mail-field-port { grid-column: 2 / 3; }
.mail-field-full { grid-column: 1 / -1; }
.mail-field label, .mail-field-label {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.03em;
  text-transform: uppercase; color: #78716c;
}
.mail-field input {
  padding: 11px 12px; border-radius: 11px; border: 1px solid var(--line);
  background: #fff; font-size: var(--text-md);
}
.mail-field input:focus {
  outline: none; border-color: #5eead4;
  box-shadow: 0 0 0 3px #ccfbf188;
}
.mail-field-hint { margin: 0; font-size: 0.78rem; }
.mail-probe.pending { color: var(--muted); }
.mail-probe.ok { color: var(--ok); font-weight: 600; }
.mail-probe.err { color: var(--err); font-weight: 600; }
.mail-crypto { grid-template-columns: 1fr 1fr 1fr; }
.hidden { display: none !important; }

.mail-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  padding: 16px 22px 18px;
  border-top: 1px solid var(--line);
  background: #fafaf9;
}
.mail-foot-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.mail-foot .btn { min-width: 120px; padding: 10px 16px; border-radius: 10px; }
.mail-msg { margin: 0; font-size: var(--text-sm); min-height: 1.2em; }

.mail-side { display: flex; flex-direction: column; gap: 14px; }
.mail-side-card h2 {
  margin: 0 0 10px; font-size: var(--text-md);
}
.mail-steps {
  margin: 0; padding-left: 18px; color: var(--muted);
  font-size: var(--text-sm); line-height: 1.55;
}
.mail-steps li { margin-bottom: 8px; }
.mail-log { display: flex; flex-direction: column; gap: 0; max-height: 320px; overflow: auto; }
.mail-log-empty { margin: 0; }
.mail-log-row {
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.mail-log-row:last-child { border-bottom: none; }
.mail-log-top {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-bottom: 4px;
}
.mail-log-badge {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em;
  text-transform: uppercase; padding: 2px 8px; border-radius: 999px;
}
.mail-log-badge.ok { background: #ecfdf5; color: #065f46; }
.mail-log-badge.err { background: #fef2f2; color: #b91c1c; }
.mail-log-badge.skip { background: #f5f5f4; color: #57534e; }
.mail-log-main { font-size: var(--text-sm); font-weight: 600; }
.mail-log-msg {
  margin-top: 2px; font-size: 0.75rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (max-width: 900px) {
  .mail-page { grid-template-columns: 1fr; }
  .mail-providers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .mail-fields { grid-template-columns: 1fr; }
  .mail-field-grow, .mail-field-port { grid-column: 1; }
  .mail-crypto { grid-template-columns: 1fr; }
}

.users-table { width: 100%; }
.users-actions {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end;
  white-space: nowrap;
}
.users-actions .btn { padding: 4px 10px; }

/* —— Команда / пользователи —— */
.users-page { display: flex; flex-direction: column; gap: 18px; max-width: 820px; }
.users-hero {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; flex-wrap: wrap;
}
.users-hero h1 { margin: 0 0 4px; }
.users-hero .muted { margin: 0; }
.users-list { padding: 6px 0; overflow: hidden; }
.user-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}
.user-row:last-child { border-bottom: none; }
.user-row:hover { background: #fafaf9; }
.user-avatar, .user-sheet-avatar {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 1rem;
  background: linear-gradient(145deg, #ccfbf1, #99f6e4);
  color: #134e4a;
  flex-shrink: 0;
}
.user-main { min-width: 0; }
.user-title {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-weight: 600; font-size: var(--text-md);
}
.user-you {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--accent); background: #f0fdfa;
  border: 1px solid #99f6e4; border-radius: 999px; padding: 1px 7px;
}
.u-email {
  font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.role-pill {
  display: inline-flex; align-items: center;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.role-admin { background: #ecfdf5; color: #065f46; }
.role-mkt { background: #f5f5f4; color: #57534e; }
.btn-ghost {
  background: transparent !important; color: var(--ink) !important;
  border: 1px solid var(--line) !important;
  padding: 6px 12px !important; border-radius: 9px !important;
  font-weight: 600; cursor: pointer;
}
.btn-ghost:hover { background: #f5f5f4 !important; border-color: #d6d3d1 !important; }
.btn-ghost.danger {
  color: var(--err) !important; border-color: transparent !important;
  padding: 6px 10px !important; font-size: 0.95rem;
}
.btn-ghost.danger:hover { background: #fef2f2 !important; }

.user-sheet {
  border: none; border-radius: 18px; padding: 0;
  width: calc(100% - 32px); max-width: 440px;
  box-shadow: 0 24px 60px #00000033;
  background: #fffdf9;
}
.user-sheet::backdrop {
  background: rgba(28, 25, 23, 0.45);
  backdrop-filter: blur(4px);
}
.user-sheet-inner { margin: 0; display: flex; flex-direction: column; }
.user-sheet-head {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 12px; align-items: center;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.user-sheet-head h3 { margin: 0 0 2px; font-size: 1.15rem; letter-spacing: -0.02em; }
.user-sheet-head .muted { margin: 0; font-size: var(--text-sm); }
.user-sheet-avatar {
  width: 48px; height: 48px; border-radius: 14px; font-size: 1.15rem;
}
.user-sheet-x {
  background: transparent !important; color: var(--muted) !important;
  border: none !important; font-size: 1.5rem; line-height: 1;
  padding: 4px 8px !important; cursor: pointer; border-radius: 8px !important;
}
.user-sheet-x:hover { background: #f5f5f4 !important; color: var(--ink) !important; }
.user-sheet-body {
  display: flex; flex-direction: column; gap: 16px;
  padding: 18px 20px 8px;
}
.user-field { display: flex; flex-direction: column; gap: 6px; }
.user-field label, .user-field-label {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.03em;
  text-transform: uppercase; color: #78716c;
}
.user-field input[type="text"],
.user-field input[type="email"],
.user-field input[type="password"] {
  padding: 11px 12px; border-radius: 11px; border: 1px solid var(--line);
  background: #fff; font-size: var(--text-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.user-field input:focus {
  outline: none; border-color: #5eead4;
  box-shadow: 0 0 0 3px #ccfbf188;
}
.user-field-hint { margin: 2px 0 0; font-size: 0.78rem; line-height: 1.4; }
.role-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  padding: 4px; background: #f5f5f4; border-radius: 12px;
}
.role-opt {
  border: none !important; background: transparent !important;
  color: var(--muted) !important; padding: 10px 12px !important;
  border-radius: 9px !important; font-weight: 600; cursor: pointer;
}
.role-opt:hover { color: var(--ink) !important; }
.role-opt.active {
  background: #fff !important; color: var(--ink) !important;
  box-shadow: 0 1px 3px #00000014;
}
.user-sheet-msg { min-height: 1.2em; margin: 0; font-size: var(--text-sm); }
.user-sheet-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px 18px; border-top: 1px solid var(--line);
  margin-top: 8px;
}
.user-sheet-foot .btn { min-width: 120px; padding: 10px 16px; border-radius: 10px; }

/* —— Wiki —— */
.wiki-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.wiki-nav {
  position: sticky;
  top: 68px;
  padding: 12px;
}
.wiki-nav-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
  padding: 0 8px;
}
.wiki-nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wiki-nav-link {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 550;
  text-decoration: none;
}
.wiki-nav-link:hover {
  background: #f5f5f4;
  text-decoration: none;
}
.wiki-nav-link.is-active {
  background: #ecfdf5;
  color: var(--accent-2);
  box-shadow: inset 0 0 0 1px #99f6e4;
}
.wiki-article { padding: 22px 24px 32px; }
.wiki-body {
  font-size: var(--text-md);
  line-height: 1.55;
  max-width: 920px;
}
.wiki-body h1 {
  margin: 0 0 14px;
  font-size: 1.45rem;
}
.wiki-body h2 {
  margin: 28px 0 10px;
  font-size: 1.15rem;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.wiki-body h2:first-child { border-top: none; padding-top: 0; }
.wiki-body h3 { margin: 18px 0 8px; font-size: 1rem; }
.wiki-body p { margin: 0 0 12px; }
.wiki-body ul, .wiki-body ol { margin: 0 0 14px; padding-left: 1.3em; }
.wiki-body li { margin: 4px 0; }
.wiki-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: var(--text-sm);
}
.wiki-body th, .wiki-body td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.wiki-body th {
  background: #fafaf9;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.wiki-body img {
  display: block;
  max-width: min(100%, 520px);
  height: auto;
  margin: 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 14px #0000000a;
  background: #fff;
}
.wiki-body code {
  font-size: 0.88em;
  background: #f5f5f4;
  padding: 1px 6px;
  border-radius: 5px;
}
.wiki-body pre {
  background: #1c1917;
  color: #fafaf9;
  padding: 12px 14px;
  border-radius: 10px;
  overflow: auto;
  font-size: var(--text-sm);
}
.wiki-body pre code { background: transparent; color: inherit; padding: 0; }
.wiki-body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 22px 0;
}
.wiki-body a { font-weight: 550; }
@media (max-width: 860px) {
  .wiki-layout { grid-template-columns: 1fr; }
  .wiki-nav { position: static; }
  .wiki-nav-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
}

@media (max-width: 640px) {
  .user-row {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "avatar main"
      "avatar role"
      "actions actions";
  }
  .user-avatar { grid-area: avatar; }
  .user-main { grid-area: main; }
  .u-admin { grid-area: role; }
  .users-actions { grid-area: actions; justify-content: flex-start; }
}
