/* referalo v2.0 — Base Components
 * Контракт v2.1, разделы 4–5
 * Только токены из tokens.css. Никаких inline-цветов.
 */

[hidden] {
  display: none !important;
}

/* === 4.1 Page structure === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  line-height: var(--line-height-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--container-padding);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.page-header .user-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
}

.page-header h1 {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.page-header p {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-content {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--space-4) var(--container-padding);
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px) + var(--space-4));
}

/* === 4.2 Bottom navigation === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  min-height: calc(50px + env(safe-area-inset-bottom, 0px));
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-1);
  min-height: 64px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  transition: color 0.15s;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.nav-item .nav-icon {
  font-size: 22px;
  line-height: 1;
}

.nav-item.active {
  color: var(--accent);
}

.nav-item.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.nav-item:active {
  opacity: 0.7;
}

/* === 2.4 Role toggle === */
.role-toggle {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  padding: 2px;
  gap: 2px;
  overflow: hidden;
  max-width: 100%;
}

.role-toggle button {
  flex: 1;
  min-height: 32px;
  min-width: 72px;
  padding: 0 var(--space-2);
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.role-toggle button.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
}

@media (max-width: 360px) {
  .role-toggle button {
    font-size: var(--font-size-xs);
    min-width: 60px;
    padding: 0 var(--space-1);
  }
}

/* === Avatar === */
.avatar {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
}

/* === KPI card === */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.kpi-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

.kpi-grid .kpi-card {
  margin-bottom: 0;
}

.kpi-card-wide {
  grid-column: span 2;
}

.kpi-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

/* === Bar chart (monthly) === */
.month-chart {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  height: 80px;
  padding: var(--space-3);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}

.month-chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  height: 100%;
  justify-content: flex-end;
}

.month-chart-bar {
  width: 100%;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 4px;
}

.month-chart-bar.current {
  background: var(--accent);
}

.month-chart-lbl {
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
}

.kpi-card .kpi-value {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
}

.kpi-card .kpi-value-large {
  font-size: var(--font-size-2xl, 28px);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--accent);
}

.kpi-card .kpi-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.section-header .section-icon {
  font-size: 20px;
}

.section-header .section-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
}

.skeleton-card {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--bg-tertiary) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-wave 1.4s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-kpi {
  height: 80px;
}

/* === Row item (list) === */
.row-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--container-padding);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.row-item:last-child {
  border-bottom: none;
}

.row-item:active {
  background: var(--bg-secondary);
}

.row-item .row-title {
  flex: 1;
  font-size: var(--font-size-md);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-item .row-meta {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

.row-item .row-leading {
  flex-shrink: 0;
}

.row-item .row-content {
  flex: 1;
  min-width: 0;
}

.row-item .row-content .row-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-item .row-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-item .row-trailing {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.row-item .row-trailing .row-balance {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text);
}

.row-item .row-trailing .row-chevron {
  font-size: var(--font-size-xs);
  color: var(--text-disabled);
}

.row-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
}

.row-avatar--square {
  border-radius: var(--radius-sm);
  color: #fff;
}

.row-title--muted {
  color: var(--text-muted);
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--container-padding);
  border-bottom: 1px solid var(--border);
}

.skeleton-row .skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.skeleton-row .skeleton-lines {
  flex: 1;
}

.skeleton-row .skeleton-line {
  height: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  margin-bottom: 6px;
}

.skeleton-row .skeleton-line:last-child {
  width: 60%;
  margin-bottom: 0;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-5);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #1C1F26; /* always dark on yellow */
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-tertiary);
}

.btn-ghost {
  background: transparent;
  color: var(--info);
  border: 1px solid var(--info);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-secondary);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

.btn-danger:hover:not(:disabled) {
  opacity: 0.85;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  min-height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--font-size-sm);
}

.section-header--mt {
  margin-top: var(--space-5);
}

.team-add-btn-wrap {
  padding: var(--space-4) var(--container-padding);
}

/* === Delta chip (аналитика: +X% / -X%) === */
.delta-chip {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.delta-chip--up {
  background: var(--success-bg, #0d2e1a);
  color: var(--success, #34d399);
}

.delta-chip--down {
  background: var(--danger-bg, #2e0d0d);
  color: var(--danger);
}

/* === Month header row === */
.an-month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

/* === Funnel === */
.funnel-row {
  margin-bottom: var(--space-3);
}

.funnel-row:last-child {
  margin-bottom: 0;
}

.funnel-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-1);
}

.funnel-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.funnel-count {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
}

.funnel-bar-track {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.funnel-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  min-width: 2px;
  transition: width 0.3s ease;
}

.funnel-bar--accrued { background: var(--success, #34d399); }
.funnel-bar--paid    { background: var(--accent); }
.funnel-bar--in_work { background: var(--info, #60a5fa); }
.funnel-bar--applied { background: var(--text-muted); }
.funnel-bar--waiting { background: var(--bg-tertiary); }

/* === 5.1 Skeleton === */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--bg-tertiary) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-wave 1.4s ease-in-out infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card:not(.skeleton-kpi) {
  height: 80px;
  margin-bottom: var(--space-3);
}

.skeleton-row {
  height: 52px;
  border-radius: 0;
  margin-bottom: 1px;
}

.skeleton-text {
  height: 16px;
  width: 60%;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

/* === 5.2 Empty state === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-8) var(--container-padding);
  gap: var(--space-3);
}

.empty-icon {
  font-size: 48px;
  line-height: 1;
}

.empty-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}

.empty-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  max-width: 280px;
}

/* === 5.3 Error state === */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-8) var(--container-padding);
  gap: var(--space-3);
}

.error-icon {
  font-size: 48px;
  line-height: 1;
}

.error-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--danger);
}

.error-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  max-width: 280px;
}

/* === Bell button (header) === */
.bell-btn {
  min-height: 44px;
  min-width: 44px;
  background: none;
  border: none;
  font-size: var(--font-size-lg);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}

.bell-btn:active {
  background: var(--bg-secondary);
}

/* === Update toast === */
.update-toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  left: 16px;
  right: 16px;
  max-width: 448px;
  margin: 0 auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  z-index: 9999;
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.update-toast-text {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--text);
}

.update-toast .update-toast-btn,
.update-toast .update-toast-dismiss {
  min-height: 36px;
  padding: 0 var(--space-3);
  font-size: var(--font-size-sm);
  white-space: nowrap;
}

/* === Login page === */
.login-page {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  margin: 0;
  font-family: var(--font-family);
}

.login-container {
  max-width: 400px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.login-logo {
  text-align: center;
}

.login-logo-emoji {
  font-size: 56px;
  width: 96px;
  height: 96px;
  border-radius: var(--radius-md);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-3);
}

.login-logo h1 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  margin: 0 0 var(--space-2);
}

.login-logo p {
  color: var(--text-muted);
  margin: 0;
  font-size: var(--font-size-md);
}

.login-type-toggle {
  display: flex;
  gap: var(--space-1);
  background: var(--bg-secondary);
  padding: var(--space-1);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.login-type-toggle button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  cursor: pointer;
  min-height: 44px;
  font-weight: var(--font-weight-medium);
}

.login-type-toggle button.active {
  background: var(--bg-tertiary);
  color: var(--text);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.login-form label {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  margin-bottom: calc(-1 * var(--space-2));
  font-weight: var(--font-weight-medium);
}

.login-form input {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  min-height: 48px;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-form .btn {
  width: 100%;
  margin-top: var(--space-2);
}

.login-admin-link {
  display: block;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  text-decoration: none;
  margin-top: var(--space-4);
  padding: var(--space-2);
}

.login-admin-link:hover {
  color: var(--text);
}

/* === Menu === */
.menu-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--container-padding) var(--space-4);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.menu-profile-avatar {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
}

.menu-profile-name {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  margin: 0;
}

.menu-profile-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: center;
}

.menu-profile-phone {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.menu-role-chip {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--text);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: 1.6;
}

.menu-profile-edit {
  margin-top: var(--space-1);
  font-size: var(--font-size-sm);
  color: var(--info);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  min-height: 36px;
  min-width: auto;
}

.menu-list {
  background: var(--bg);
  margin-top: var(--space-3);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 56px;
  padding: 0 var(--container-padding);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:active {
  background: var(--bg-secondary);
}

.menu-item-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.menu-item-label {
  flex: 1;
  font-size: var(--font-size-md);
}

.menu-item-arrow {
  font-size: var(--font-size-lg);
  color: var(--text-disabled);
  flex-shrink: 0;
}

.menu-item-danger .menu-item-label {
  color: var(--danger);
}

.menu-item-danger .menu-item-icon {
  color: var(--danger);
}

/* === iOS auto-fill override === */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0px 1000px var(--bg-secondary) inset;
  transition: background-color 5000s ease-in-out 0s;
}

/* === Case-status chips (partner.html) === */
.status-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: 20px;
}
.status-chip--new          { background: rgba(107,114,128,.18); color: #9CA3AF; }
.status-chip--consultation { background: rgba(11,95,255,.18);   color: #60A5FA; }
.status-chip--docs         { background: rgba(217,119,6,.18);   color: #FBBF24; }
.status-chip--court        { background: rgba(124,58,237,.18);  color: #A78BFA; }
.status-chip--done         { background: rgba(16,185,129,.18);  color: #34D399; }

/* === Case steps progress (partner.html) === */
.case-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4) 0;
}
.case-step {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}
.case-step-num {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
}
.case-step-label {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}
.case-step--done .case-step-num {
  background: rgba(16,185,129,.2);
  color: #34D399;
}
.case-step--done .case-step-label { color: var(--text-secondary); }
.case-step--active {
  background: rgba(11,95,255,.08);
  border: 1px solid rgba(11,95,255,.3);
}
.case-step--active .case-step-num {
  background: var(--primary);
  color: #fff;
}
.case-step--active .case-step-label {
  color: var(--text);
  font-weight: var(--font-weight-semibold);
}

/* === Level progress bar (partner.html) === */
.level-bar-wrap {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  overflow: hidden;
  margin-top: var(--space-2);
}
.level-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width .4s ease;
}

/* === Modal / Sheet (feed-author.html и другие) === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.hidden { display: none; }

.modal-sheet {
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-5) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
}

.modal-handle {
  width: 36px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  margin: 0 auto var(--space-4);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-4);
}

/* === Form elements (внутри .modal-sheet) === */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.form-input,
.form-textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-3);
  font-size: var(--font-size-md);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--primary);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

.radio-group {
  display: flex;
  gap: var(--space-2);
}

.radio-btn {
  flex: 1;
  padding: var(--space-2) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.radio-btn.selected {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(11, 95, 255, 0.08);
}

.form-checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  cursor: pointer;
}

.form-checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* === Feed post card === */
.feed-post {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

.feed-post-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.feed-post-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  flex: 1;
}

.feed-post-pin {
  font-size: 16px;
  flex-shrink: 0;
}

.feed-post-meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.feed-post-stats {
  display: flex;
  gap: var(--space-4);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

/* === Feed reader (partner.html) === */
.feed-posts-wrap {
  margin-top: var(--space-2);
}

.feed-post--pinned {
  border-left: 3px solid var(--primary);
  padding-left: calc(var(--space-4) - 3px);
}

.feed-post-img {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  display: block;
}

.feed-post-body {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  line-height: 1.55;
  margin: var(--space-2) 0 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
  word-break: break-word;
}

.feed-post-body--expanded {
  -webkit-line-clamp: unset;
  overflow: visible;
}

.feed-expand-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: var(--font-size-xs);
  padding: var(--space-1) 0;
  cursor: pointer;
  display: block;
  margin-top: var(--space-1);
}

.feed-post-link {
  display: inline-block;
  margin-top: var(--space-2);
}

.feed-show-all-btn {
  width: 100%;
  margin-top: var(--space-3);
}

/* ── Карточки интеграций (v2.4.0) ──────────────────────────────────────────── */

.integration-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}

.integration-card--disabled {
  opacity: 0.5;
  pointer-events: none;
}

.integration-card--link {
  cursor: pointer;
  transition: background 0.15s;
}

.integration-card--link:hover {
  background: var(--surface-alt, #f5f7fa);
}

.integration-card-icon {
  font-size: 28px;
  flex-shrink: 0;
  width: 44px;
  text-align: center;
}

.integration-card-body {
  flex: 1;
  min-width: 0;
}

.integration-card-name {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.integration-card-desc {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.integration-card-action {
  flex-shrink: 0;
}

.badge-stub {
  display: inline-block;
  background: var(--border);
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
}

/* === Profile page (v2.5.3) === */
.profile-avatar-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.profile-avatar {
  width: 100px;
  height: 100px;
  min-width: 100px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-display);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  overflow: hidden;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.form-hint {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-hint-inline {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: var(--font-weight-regular);
}

/* === Payout recipient cards (v2.6.1) === */
.recipient-card {
  margin-bottom: var(--space-3);
}

.recipient-card-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.recipient-card-info {
  flex: 1;
  min-width: 0;
}

.recipient-card-name {
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recipient-card-meta {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.recipient-card-badge {
  font-size: var(--font-size-sm);
  color: var(--primary);
  font-weight: var(--font-weight-medium);
  flex-shrink: 0;
  white-space: nowrap;
}

.recipient-card-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  flex-wrap: wrap;
}

.recipients-empty-text {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-4) 0;
  line-height: 1.6;
  margin: 0;
}

/* =====================================================================
   === Knowledge Base — ROPP author (v2.7.1) ===
   ===================================================================== */

.knowledge-toolbar {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.knowledge-toolbar .btn {
  flex: 1;
}

/* Warning banner */
.yadisk-warning {
  background: rgba(216, 124, 0, 0.12);
  border: 1px solid var(--warning);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  text-align: center;
}

.yadisk-warning-icon {
  font-size: 2rem;
  margin-bottom: var(--space-2);
}

.yadisk-warning-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--warning);
  margin-bottom: var(--space-1);
}

.yadisk-warning-text {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

/* Category card */
.knowledge-category {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  overflow: hidden;
}

.knowledge-category-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.knowledge-category-header:active {
  background: var(--bg-tertiary);
}

.drag-handle {
  color: var(--text-disabled);
  font-size: 1.1rem;
  cursor: grab;
  touch-action: none;
  flex-shrink: 0;
  padding: 2px 4px;
}

.drag-handle:active { cursor: grabbing; }

.knowledge-cat-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.knowledge-cat-title {
  flex: 1;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  color: var(--text);
}

.knowledge-cat-count {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  padding: 2px 8px;
}

.knowledge-cat-chevron {
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.knowledge-cat-chevron.open {
  transform: rotate(90deg);
}

.knowledge-cat-menu-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.knowledge-cat-menu-btn:active {
  background: var(--bg-tertiary);
}

/* Articles list inside category */
.knowledge-articles-list {
  border-top: 1px solid var(--border);
  display: none;
}

.knowledge-articles-list.open {
  display: block;
}

/* Article item */
.knowledge-article {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--border);
}

.knowledge-article:last-child {
  border-bottom: none;
}

.knowledge-article-icon {
  font-size: 1rem;
  flex-shrink: 0;
  color: var(--text-muted);
}

.knowledge-article-title {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--text);
  line-height: 1.4;
}

.knowledge-article-badge {
  font-size: var(--font-size-xs);
  color: var(--text-disabled);
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  padding: 1px 6px;
  flex-shrink: 0;
}

.knowledge-article-menu-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Uncategorized section */
.knowledge-section-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-4) 0 var(--space-2);
}

/* Sortable ghost */
.sortable-ghost {
  opacity: 0.4;
  background: var(--bg-tertiary);
}

.sortable-drag {
  opacity: 1;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

/* Quill editor wrapper */
.quill-wrapper {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  overflow: hidden;
}

.quill-wrapper .ql-toolbar {
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}

.quill-wrapper .ql-container {
  border: none;
  min-height: 120px;
  font-size: var(--font-size-md);
  font-family: inherit;
}

.quill-wrapper .ql-editor {
  min-height: 120px;
  color: var(--text);
}

/* File attach preview */
.attach-preview {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
}

.attach-preview-name {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-preview-size {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  flex-shrink: 0;
}

.attach-preview-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px;
  flex-shrink: 0;
}

.upload-progress {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-2);
}

.upload-progress-bar {
  height: 100%;
  background: var(--info);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.3s;
}

/* Context menu dropdown */
.ctx-menu {
  position: fixed;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 300;
  overflow: hidden;
  min-width: 160px;
}

.ctx-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--text);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.ctx-menu-item:hover {
  background: var(--bg-secondary);
}

.ctx-menu-item.danger {
  color: var(--danger);
}

.ctx-menu-divider {
  height: 1px;
  background: var(--border);
}

/* =====================================================================
   === Knowledge Base — Agent reader (v2.7.2) ===
   ===================================================================== */

/* Chip filter bar */
.chip-filter-bar {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-3);
  scrollbar-width: none;
}

.chip-filter-bar::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.chip--active {
  border-color: var(--info);
  color: var(--info);
  background: rgba(14, 111, 227, 0.1);
}

.chip--sm {
  padding: 2px var(--space-2);
  font-size: var(--font-size-xs);
}

/* Knowledge article card (agent view) */
.knowledge-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}

.knowledge-card:active {
  background: var(--bg-tertiary);
}

.knowledge-card-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.knowledge-card-body {
  flex: 1;
  min-width: 0;
}

.knowledge-card-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-card-sub {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.knowledge-card-chevron {
  color: var(--text-disabled);
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* Article view fullscreen modal */
.kb-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 250;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.kb-modal-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.kb-modal-body {
  padding: var(--space-4);
  padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  flex: 1;
}

/* Article meta (category chip + date) */
.kb-article-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.kb-article-date {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* Article HTML content */
.kb-article-content {
  font-size: var(--font-size-md);
  line-height: 1.65;
  color: var(--text);
  word-break: break-word;
}

.kb-article-content h1,
.kb-article-content h2,
.kb-article-content h3 {
  font-weight: var(--font-weight-semibold);
  margin: var(--space-4) 0 var(--space-2);
  line-height: 1.3;
}

.kb-article-content h1 { font-size: 1.4rem; }
.kb-article-content h2 { font-size: 1.2rem; }
.kb-article-content h3 { font-size: 1.05rem; }

.kb-article-content p {
  margin: 0 0 var(--space-3);
}

.kb-article-content ul,
.kb-article-content ol {
  padding-left: var(--space-5);
  margin-bottom: var(--space-3);
}

.kb-article-content li { margin-bottom: var(--space-1); }

.kb-article-content a {
  color: var(--info);
  text-decoration: underline;
}

.kb-article-content strong { font-weight: var(--font-weight-semibold); }
.kb-article-content em { font-style: italic; }

.kb-article-content blockquote {
  border-left: 3px solid var(--border);
  padding-left: var(--space-3);
  color: var(--text-muted);
  margin: var(--space-3) 0;
}

/* Attachment area */
.kb-article-attach {
  margin-top: var(--space-4);
}

/* =====================================================================
   === MOPP Management — ROPP (v2.8.1) ===
   ===================================================================== */

/* MOPP card */
.mopp-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

.mopp-card-body {
  flex: 1;
  min-width: 0;
}

.mopp-card-name {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  margin-bottom: 2px;
}

.mopp-card-phone {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.mopp-card-sub {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.mopp-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.mopp-card-agents {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.mopp-card-menu-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  margin-top: -4px;
}

.mopp-card-menu-btn:active {
  background: var(--bg-tertiary);
}

/* Status chip variant */
.chip--fired {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(208, 46, 46, 0.1);
}

/* Radio group for modals */
.mopp-radio-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.mopp-radio-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s;
}

.mopp-radio-item:has(input:checked) {
  border-color: var(--info);
  background: rgba(14, 111, 227, 0.06);
}

.mopp-radio-item input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--info);
  flex-shrink: 0;
}

/* Distribute table */
.mopp-agents-table {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.distribute-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.distribute-agent {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.distribute-select {
  flex: 1;
  min-width: 0;
  font-size: var(--font-size-sm);
  padding: var(--space-2);
}

/* Invite link box */
.invite-link-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

.invite-link-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.invite-link-url {
  font-size: var(--font-size-sm);
  color: var(--text);
  word-break: break-all;
  line-height: 1.5;
}

.invite-hint {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: var(--space-4);
}

/* Toast */
.toast-msg {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  z-index: 500;
  white-space: nowrap;
  pointer-events: none;
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* =====================================================================
   === MOPP Invite page (v2.8.2) ===
   ===================================================================== */

/* Error state */
.invite-error-card {
  text-align: center;
  padding: var(--space-6) var(--space-4);
}

.invite-error-icon {
  font-size: 3rem;
  margin-bottom: var(--space-3);
}

.invite-error-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.invite-error-sub {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  line-height: 1.6;
}

/* Welcome block */
.invite-welcome {
  text-align: center;
  margin-bottom: var(--space-5);
}

.invite-welcome-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  margin-bottom: var(--space-1);
}

.invite-welcome-sub {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  line-height: 1.5;
}

/* Pre-filled info card */
.invite-info-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}

.invite-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.invite-info-row:last-child {
  border-bottom: none;
}

.invite-info-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  flex-shrink: 0;
}

.invite-info-val {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text);
  text-align: right;
}

/* Field error */
.invite-field-error {
  background: rgba(208, 46, 46, 0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  color: var(--danger);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-3);
}

/* =====================================================================
   === Branding Settings page (v2.9.1) ===
   ===================================================================== */

/* Back button in page-header */
.back-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
  flex-shrink: 0;
}
.back-btn:active {
  background: var(--bg-secondary);
}

/* ── Brand preview card ── */
.bs-preview-section {
  margin-bottom: var(--space-5);
}

.bs-preview-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: border-color 0.2s;
}

.bs-preview-logo-wrap {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bs-preview-emoji {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.bs-preview-img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.bs-preview-text {
  flex: 1;
  min-width: 0;
}

.bs-preview-name {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bs-preview-legal {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Sections ── */
.bs-section {
  margin-bottom: var(--space-5);
}

.bs-section-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-3);
}

/* ── Labels & inputs ── */
.bs-label {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--text);
  margin-bottom: var(--space-1);
}

.bs-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: var(--space-3);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--text);
  font-family: var(--font-family);
}
.bs-input:focus {
  outline: none;
  border-color: var(--accent);
}

.bs-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
  line-height: 1.5;
}

/* ── Logo drop zone ── */
.bs-logo-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: var(--space-3);
}
.bs-logo-drop:hover,
.bs-logo-drop--over {
  border-color: var(--accent);
  background: rgba(0,0,0,0.03);
}
.bs-logo-drop-icon {
  font-size: 2rem;
  margin-bottom: var(--space-2);
}
.bs-logo-drop-hint {
  font-size: var(--font-size-sm);
  color: var(--text);
  margin-bottom: 2px;
}
.bs-logo-drop-sub {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* =====================================================================
   === Agent Promo Cards (v3.1.8) ===
   =================================================================== */

.promo-agent-card {
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  cursor: pointer;
  transition: opacity 0.15s;
  position: relative;
  overflow: hidden;
}

.promo-agent-card:active { opacity: 0.85; }

/* Состояния по прогрессу */
.promo-agent-card--gray   { background: var(--bg-secondary); }
.promo-agent-card--blue   { background: rgba(11, 95, 255, 0.07); border: 1px solid rgba(11,95,255,0.18); }
.promo-agent-card--green  { background: rgba(22, 163, 74, 0.07); border: 1px solid rgba(22,163,74,0.2); }
.promo-agent-card--gold   { background: rgba(245, 158, 11, 0.1);  border: 1px solid rgba(245,158,11,0.25); }

.promo-agent-card-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  margin-bottom: var(--space-1);
  padding-right: var(--space-6); /* room for completed badge */
}

.promo-agent-card-desc {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Progress bar */
.promo-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.promo-progress-bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.4s ease;
}

.promo-progress-fill--gray  { background: var(--text-muted); }
.promo-progress-fill--blue  { background: var(--primary); }
.promo-progress-fill--green { background: #16a34a; }
.promo-progress-fill--gold  { background: #f59e0b; }

.promo-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.promo-agent-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-xs);
  gap: var(--space-2);
}

.promo-reward-label {
  font-weight: var(--font-weight-medium);
  color: var(--primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.promo-deadline-label {
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Completed badge */
.promo-completed {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.promo-reward-photo-sm {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  float: right;
  margin-left: var(--space-3);
  margin-bottom: var(--space-2);
}

/* ── Logo preview row ── */
.bs-logo-preview-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
}
.bs-logo-thumb {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.bs-logo-info {
  flex: 1;
  min-width: 0;
}
.bs-logo-filename {
  font-size: var(--font-size-sm);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: var(--space-1);
}

/* ── Upload progress ── */
.bs-upload-progress {
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: var(--space-1);
}
.bs-upload-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0;
  transition: width 0.3s ease;
}
.bs-upload-status {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  min-height: 16px;
}

/* ── Color palette ── */
.bs-palette {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}
.bs-color-swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, border-color 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.bs-color-swatch:active {
  transform: scale(0.92);
}
.bs-color-swatch--active {
  border-color: var(--text);
  transform: scale(1.08);
}
.bs-color-check {
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  line-height: 1;
}

/* ── Error ── */
.bs-error {
  background: rgba(208, 46, 46, 0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  color: var(--danger);
  font-size: var(--font-size-sm);
  margin-top: var(--space-3);
}

/* ── Subdomain field ── */
.bs-subdomain-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.bs-subdomain-input {
  flex: 1;
  padding-right: 96px; /* leave room for suffix */
}
.bs-subdomain-suffix {
  position: absolute;
  right: var(--space-3);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  pointer-events: none;
  white-space: nowrap;
}
.bs-subdomain-error {
  color: var(--danger);
  font-size: var(--font-size-sm);
  margin-top: var(--space-2);
}

/* ── Audit-log page (v2.12.1) ─────────────────────────────────────────────── */

.audit-filter-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) 0;
}

.audit-filter-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.audit-filter-row .form-input {
  flex: 1;
  min-width: 0;
  font-size: var(--font-size-sm);
  padding: var(--space-2) var(--space-3);
}

.audit-filter-select {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--text);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-7);
  cursor: pointer;
}

.audit-filter-select:focus {
  border-color: var(--primary);
}

.audit-event-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.audit-event-date {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.audit-event-actor {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.audit-details-toggle {
  background: none;
  border: none;
  color: var(--primary);
  font-size: var(--font-size-xs);
  padding: var(--space-1) 0;
  cursor: pointer;
  text-align: left;
}

.audit-details-body {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
  font-size: var(--font-size-xs);
  font-family: monospace;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  overflow: hidden;
}

.audit-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
}

.audit-pagination-info {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* ── v3.3.2: wallet-row, btn-add-client, client-list, efficiency-grid ── */

.wallet-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.btn-add-client {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  background: var(--primary, #0b5fff);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.btn-add-client:active { opacity: 0.8; }

.client-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.client-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}
.client-item:last-child { border-bottom: none; }

.client-item-name {
  font-size: var(--font-size-sm);
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-link {
  display: inline-block;
  font-size: var(--font-size-sm);
  color: var(--primary, #0b5fff);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
}
.btn-link:hover { text-decoration: underline; }

/* Efficiency grid (МОПП дашборд) */
.efficiency-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-2);
  text-align: center;
}

.metric-num {
  font-size: var(--font-size-xl, 24px);
  font-weight: var(--font-weight-bold, 700);
  color: var(--primary, #0b5fff);
  line-height: 1.1;
}

.metric-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
  line-height: 1.3;
}

/* ── v3.5.0: Embed widget (widget-card.html) ── */

.widget-body {
  max-width: 400px;
  min-height: 100vh;
  margin: 0 auto;
  padding: var(--space-4);
  background: var(--bg);
  color: var(--text);
}

.widget-section {
  margin-bottom: var(--space-4);
}

.widget-agent-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: var(--space-3);
}

.widget-agent-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.widget-agent-info {
  flex: 1;
  min-width: 0;
}

.widget-agent-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.widget-agent-meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.widget-agent-level {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #1C1F26;
  flex-shrink: 0;
}

.widget-reward-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: var(--space-3);
}

.widget-reward-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.widget-reward-amount {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--text);
}

.widget-status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.widget-status-badge--not-paid   { background: var(--bg-secondary); color: var(--text-muted); border: 1px solid var(--border); }
.widget-status-badge--pending    { background: rgba(217,119,6,.15); color: #d97706; }
.widget-status-badge--completed  { background: rgba(16,185,129,.15); color: #10b981; }

.widget-offset-info {
  padding: var(--space-3) var(--space-4);
  background: rgba(11,95,255,.08);
  border: 1px solid rgba(11,95,255,.2);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}

.widget-offset-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-2);
}

.widget-offset-row:last-child { margin-bottom: 0; }

.widget-offset-label { color: var(--text-muted); }
.widget-offset-value { font-weight: var(--font-weight-semibold); color: var(--text); }

.widget-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-8) var(--space-4);
  gap: var(--space-3);
}

.widget-empty-icon {
  font-size: 40px;
  line-height: 1;
}

.widget-empty-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
}

.widget-empty-desc {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  line-height: 1.5;
}

.widget-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.widget-error {
  padding: var(--space-4);
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: var(--radius-md);
  color: #ef4444;
  font-size: var(--font-size-sm);
  text-align: center;
}

/* === embed-mode: скрываем chrome-элементы внутри iframe === */

body.embed-mode {
  overflow-x: hidden;
}

/* Скрываем: логотип, колокольчик, кнопку профиля, бренд */
.embed-mode .top-header__logo,
.embed-mode .top-header__bell,
.embed-mode .top-header__profile,
.embed-mode .top-header__brand {
  display: none !important;
}

/* Компактная шапка */
.embed-mode .top-header,
.embed-mode .page-header {
  padding: 8px 12px;
  min-height: 40px;
}

/* Имя пользователя — чуть компактнее */
.embed-mode .user-name,
.embed-mode #user-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
}

/* bottom-nav и role-toggle остаются видимыми */
.embed-mode .bottom-nav { /* inherits */ }
.embed-mode .role-toggle { /* inherits */ }
