/* MWM - Shared Styles — CSS переменные и базовые стили */

:root {
  /* Modern Color Palette */
  --bg: #fafbfc;
  --bg-card: #ffffff;
  --bg-secondary: #f6f8fa;
  --border: #d1d9e0;
  --border-light: #e1e4e8;
  --border-hover: #c7ccd1;
  --text: #24292f;
  --text-muted: #656d76;
  --text-subtle: #8b949e;
  --accent: #0969da;
  --accent-light: #218bff;
  --accent-hover: #0550ae;
  --accent-soft: #f6f8fa;
  --accent-bg: #ddf4ff;
  --success: #238636;
  --success-bg: #dafbe1;
  --danger: #d1242f;
  --danger-bg: #ffebe9;
  --warning: #bf8700;
  --warning-bg: #fff8e5;

  /* Modern Spacing Scale */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */

  /* Modern Border Radius */
  --radius-sm: 0.375rem;  /* 6px */
  --radius: 0.5rem;       /* 8px */
  --radius-lg: 0.75rem;   /* 12px */
  --radius-xl: 1rem;      /* 16px */

  /* Modern Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Modern Typography */
  --font-sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;

  /* Font Sizes */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  --text-4xl: 2.25rem;   /* 36px */

  /* Font Weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modern CSS Reset and Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sr-only.focus:not-sr-only {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ============================================
   TAILWIND UTILITY CLASSES (for React components)
   ============================================ */

/* Layout - Flex */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1 1 0%; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* Spacing - Space between */
.space-y-2 > * + * { margin-top: var(--space-2); }
.space-y-3 > * + * { margin-top: var(--space-3); }
.space-y-4 > * + * { margin-top: var(--space-4); }
.space-y-6 > * + * { margin-top: var(--space-6); }

/* Spacing - Padding */
.p-4 { padding: var(--space-4); }
.px-2 { padding-left: var(--space-2); padding-right: var(--space-2); }
.px-3 { padding-left: var(--space-3); padding-right: var(--space-3); }
.py-1 { padding-top: var(--space-1); padding-bottom: var(--space-1); }
.py-1\.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-8 { padding-top: var(--space-8); padding-bottom: var(--space-8); }
.py-12 { padding-top: var(--space-12); padding-bottom: var(--space-12); }

/* Spacing - Margin */
.mb-4 { margin-bottom: var(--space-4); }
.mx-4 { margin-left: var(--space-4); margin-right: var(--space-4); }
.pt-4 { padding-top: var(--space-4); }

/* Sizing - Min/Max */
.min-w-\[60px\] { min-width: 60px; }
.w-3 { width: 0.75rem; }
.h-3 { height: 0.75rem; }

/* Sizing */
.h-8 { height: 2rem; }
.h-48 { height: 12rem; }
.w-8 { width: 2rem; }

/* Background colors */
.bg-white { background-color: #ffffff; }
.bg-gray-50 { background-color: #f9fafb; }
.bg-gray-100 { background-color: #f3f4f6; }
.bg-gray-200 { background-color: #e5e7eb; }
.bg-red-50 { background-color: #fef2f2; }
.bg-blue-600 { background-color: #2563eb; }

/* Border */
.border { border: 1px solid var(--border); }
.border-gray-200 { border-color: #e5e7eb; }
.border-blue-600 { border-color: #2563eb; }

/* Border radius */
.rounded-md { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: 9999px; }

/* Typography - Size */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }

/* Typography - Weight */
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }

/* Typography - Color */
.text-white { color: #ffffff; }
.text-gray-400 { color: #9ca3af; }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-gray-900 { color: #111827; }
.text-red-600 { color: #dc2626; }
.text-blue-600 { color: #2563eb; }
.text-yellow-500 { color: #eab308; }

/* Effects - Shadow */
.shadow-lg {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Transitions */
.transition-colors {
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

/* Hover states */
.hover\:bg-gray-200:hover { background-color: #e5e7eb; }
.hover\:border-blue-300:hover { border-color: #93c5fd; }

/* Disabled states */
.disabled\:opacity-50:disabled { opacity: 0.5; }
.disabled\:cursor-not-allowed:disabled { cursor: not-allowed; }

/* Border colors */
.border-gray-300 { border-color: #d1d5db; }

/* Focus states for inputs */
.focus\:outline-none:focus { outline: none; }
.focus\:ring-2:focus { box-shadow: 0 0 0 2px #3b82f6; }
.focus\:ring-blue-500:focus { box-shadow: 0 0 0 2px #3b82f6; }

/* Animation - Spin */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.animate-spin {
  animation: spin 1s linear infinite;
}

/* Border styles for spinner */
.border-b-2 { border-bottom-width: 2px; border-bottom-style: solid; }

/* MWM - CRM Styles — Компоненты интерфейса CRM */

/* Modern Header */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-content {
  max-width: none;
  margin: 0 auto;
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.logo:hover {
  color: var(--accent);
}

.logo-text {
  color: var(--accent);
  font-weight: var(--font-bold);
}

.logo-subtitle {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-secondary);
}

.nav-link[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-bg);
}

.nav-divider {
  width: 1px;
  height: 24px;
  background: var(--border-light);
}

.nav-icon {
  flex-shrink: 0;
}

.nav-chevron {
  flex-shrink: 0;
  opacity: 0.6;
  transition: transform var(--transition-fast);
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: var(--font-bold);
  line-height: 1;
  color: white;
  background: var(--danger, #e53e3e);
  border-radius: 999px;
}

/* Nav dropdowns */
.nav-dropdown {
  position: relative;
}

/* Невидимый мост trigger → menu: без него курсор теряет hover в зазоре */
.nav-dropdown::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 12px;
}

.nav-dropdown-trigger,
.nav-account-trigger {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  min-width: 180px;
  margin-top: 2px;
  padding: var(--space-2);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--transition-fast), transform var(--transition-fast), visibility 0s linear 0.15s;
  pointer-events: none;
}

.nav-dropdown--right .nav-dropdown-menu {
  left: auto;
  right: 0;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu,
.nav-dropdown.is-open .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity var(--transition-fast), transform var(--transition-fast), visibility 0s linear 0s;
}

.nav-dropdown:hover .nav-chevron,
.nav-dropdown:focus-within .nav-chevron,
.nav-dropdown.is-open .nav-chevron {
  transform: rotate(180deg);
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.nav-dropdown-item:hover,
.nav-dropdown-item--button:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

.nav-dropdown-item[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-bg);
}

.nav-dropdown-item--button {
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  border: none;
  background: none;
}

.nav-dropdown-logout {
  margin: 0;
}

.nav-dropdown-divider {
  height: 1px;
  margin: var(--space-2) 0;
  background: var(--border-light);
}

.nav-account-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.nav-account-avatar--placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: white;
  background: var(--accent);
  text-transform: uppercase;
}

.nav-account-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-self: center;
}

/* Button Components */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: 1.5;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  height: auto;
  min-height: 28px;
}

/* Logout button in header should stay compact */
.logout-form .btn {
  height: 32px;
  min-height: 32px;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-secondary);
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
  background: var(--accent-bg);
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-secondary);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 90%, black);
  border-color: var(--danger);
}

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
  background: color-mix(in srgb, var(--success) 90%, black);
  border-color: var(--success);
}

/* Main Content */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.main-content {
  width: 100%;
  max-width: 1536px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .main-content {
    padding: var(--space-6) var(--space-4);
  }
}

@media (max-width: 640px) {
  .main-content {
    padding: var(--space-4) var(--space-3);
  }
}

/* Modern Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-header {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text);
  margin: 0;
}

.card-description {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: var(--space-1) 0 0 0;
}

.card-content {
  color: var(--text);
}

.card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg) 0%, var(--accent-soft) 100%);
  padding: var(--space-4);
}

.login-box {
  background: var(--bg-card);
  padding: var(--space-8);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 400px;
}

.login-title {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--text);
  text-align: center;
  margin: 0 0 var(--space-2) 0;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: var(--text-base);
  text-align: center;
  margin: 0 0 var(--space-6) 0;
  line-height: 1.5;
}

.error-msg {
  background: var(--danger-bg);
  color: var(--danger);
  padding: var(--space-3);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  border: 1px solid color-mix(in srgb, var(--danger) 20%, transparent);
}

.login-form .form-group {
  margin-bottom: var(--space-4);
}

.login-form .btn {
  width: 100%;
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  justify-content: center;
}

.login-footer {
  margin-top: var(--space-5);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.login-footer .link {
  color: var(--accent);
  text-decoration: none;
}

.login-footer .link:hover {
  text-decoration: underline;
}

/* Экран второго фактора: код из письма. */
.code-input {
  font-size: var(--text-2xl);
  letter-spacing: 0.35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.info-msg {
  background: var(--accent-bg, rgba(37, 99, 235, 0.08));
  color: var(--text);
  padding: var(--space-3);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

/* Подсказка «почта не подключена, код на экране». Показывается, пока отправка
   писем выключена; при включённой почте блока нет. */
.dev-code-note {
  background: var(--warning-bg, rgba(217, 119, 6, 0.1));
  border: 1px dashed var(--warning, #b45309);
  color: var(--text);
  padding: var(--space-3);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  line-height: 1.5;
  margin-bottom: var(--space-4);
}

.dev-code-note b {
  font-size: var(--text-lg);
  letter-spacing: 0.2em;
}

.login-resend {
  margin-top: var(--space-3);
  text-align: center;
}

.login-resend .btn {
  width: 100%;
}

/* Последние входы на экране входа и экране кода (шаблон
   partials/recent_logins.html). Ранняя тревога: чужой вход видно до того, как
   кто-то сменит пароль. Список спокойный по виду: это не ошибка, а факты. */
.login-journal {
  margin: var(--space-4) 0 0;
  padding: var(--space-3);
  border: 1px solid var(--border-light, #e5e7eb);
  border-radius: var(--radius);
  background: var(--bg-subtle, rgba(0, 0, 0, 0.03));
  font-size: var(--text-sm);
  line-height: 1.5;
}

.login-journal__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.login-journal__zone {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.login-journal__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.login-journal__row {
  display: grid;
  grid-template-columns: minmax(9rem, auto) minmax(0, 1fr);
  gap: 2px var(--space-3);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--border-light, #e5e7eb);
}

.login-journal__row:first-child {
  border-top: none;
}

.login-journal__when {
  color: var(--text-muted);
  white-space: nowrap;
}

.login-journal__what {
  font-weight: var(--font-semibold, 600);
}

.login-journal__where {
  grid-column: 1 / -1;
  color: var(--text-muted);
  word-break: break-word;
}

.login-journal__new {
  display: inline-block;
  margin-left: var(--space-2);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--warning-bg, rgba(217, 119, 6, 0.12));
  color: var(--warning, #b45309);
}

.login-journal__hint {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Плашка в кабинете: почта не подтверждена. Её смысл — чтобы человек не
   пропустил, на какой ящик придут коды входа и восстановление пароля. */
.email-verify-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) auto 0;
  max-width: 52rem;
  padding: var(--space-4);
  border: 1px dashed var(--warning, #b45309);
  border-radius: var(--radius-lg, 12px);
  background: var(--warning-bg, rgba(217, 119, 6, 0.1));
  color: var(--text);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.email-verify-banner__icon {
  flex-shrink: 0;
  color: var(--warning, #b45309);
}

.email-verify-banner__text {
  flex: 1 1 18rem;
  min-width: 0;
}

.email-verify-banner__address {
  font-weight: var(--font-semibold, 600);
  word-break: break-word;
}

.email-verify-banner__action {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: var(--font-semibold, 600);
}

.email-verify-banner__action:hover {
  text-decoration: underline;
}

/* Подсказка про резервный код на экране входа: спокойная, не тревожная рамка.
   Это не ошибка и не предупреждение, а путь для человека без доступа к почте. */
.login-box .backup-code-note {
  background: var(--bg-subtle, rgba(0, 0, 0, 0.03));
  border: 1px solid var(--border-color, #e5e7eb);
  color: var(--text-secondary, #6b7280);
  padding: var(--space-3);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  line-height: 1.5;
  margin: var(--space-3) 0 0;
}

.login-box .backup-code-note b {
  letter-spacing: 0.1em;
  color: var(--text);
}

.password-field {
  position: relative;
}

.password-field .form-control {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  width: 34px;
  height: 34px;
  transform: translateY(-50%);
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
}

.password-toggle svg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.password-toggle .icon-hide {
  display: none;
}

.password-toggle[aria-pressed="true"] .icon-show {
  display: none;
}

.password-toggle[aria-pressed="true"] .icon-hide {
  display: block;
}

.password-toggle:hover {
  color: var(--text);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.optional-label {
  font-weight: normal;
  color: var(--text-muted);
}

.invite-banner {
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #312e81;
  font-size: var(--text-sm);
}

.form-hint.text-success {
  color: #22c55e;
}

.register-ref-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 8px;
  background: #dcfce7;
  color: #166534;
}

.clear-ref {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  padding: 4px 8px;
}

/* React embed shell — full-bleed mount points inside base.html */
body.page-call-embed .main-content {
  max-width: none;
  padding: 0;
}

body.page-ai-chat-embed .main-content {
  max-width: none;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.page-ai-chat-embed #ai-chat-detail-root {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.page-client-detail-embed .main-content {
  max-width: 1280px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.page-client-detail-embed #client-detail-root {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Page Header */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-light);
}

.page-title {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}

.page-description {
  font-size: var(--text-base);
  color: var(--text-muted);
  margin: var(--space-2) 0 0 0;
  line-height: 1.5;
}

.header-actions {
  margin-top: 1rem;
  display: flex;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* Client Details Header */
.client-detail-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-8);
  box-shadow: var(--shadow-sm);
}

.client-info {
  flex: 1;
  min-width: 300px;
}

/* Prominent call button under client name */
#call-button-root {
  margin: var(--space-3) 0;
}

#call-button-root .btn-call-prominent {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  min-height: 44px;
}

#call-button-root .btn-call-prominent .btn-icon {
  width: 20px;
  height: 20px;
}

.client-info h1 {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text);
  margin: 0 0 var(--space-3) 0;
}

/* Modern Forms */
.form-group {
  margin-bottom: var(--space-5);
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.form-label.required::after {
  content: "*";
  color: var(--danger);
  margin-left: var(--space-1);
}

.form-control {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.form-control:invalid:not(:placeholder-shown) {
  border-color: var(--danger);
}

.form-control:invalid:not(:placeholder-shown):focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
  font-family: var(--font-sans);
}

.form-file {
  padding: var(--space-2);
  border-style: dashed;
}

.form-file:focus {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.form-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: var(--space-2) 0 0 0;
  line-height: 1.4;
}

.form-error {
  font-size: var(--text-sm);
  color: var(--danger);
  margin: var(--space-2) 0 0 0;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.form-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
  justify-content: flex-end;
}

/* Form Grid for better layout */
.form-grid {
  display: grid;
  gap: var(--space-5);
}

@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
}

/* Client List */
.client-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-2);
}

.client-list-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
}

.client-list-item:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.client-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5);
  text-decoration: none;
  color: var(--text);
  border-radius: var(--radius-lg);
  transition: background-color var(--transition-fast);
}

.client-link:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

.client-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.client-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
  min-width: 0;
}

.client-name {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text);
  margin: 0;
  line-height: 1.3;
}

.client-meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.4;
}

.unread-badge {
  background: var(--accent);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.unread-badge::before {
  content: "●";
  margin-right: var(--space-1);
  font-size: 8px;
}

/* Action Buttons and Dropdowns */
.feed-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  padding: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.add-entry-dropdown {
  position: relative;
}

.add-entry-summary {
  background: var(--accent) !important;
  color: white !important;
  border: 1px solid var(--accent) !important;
  font: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  transition: all var(--transition-fast);
  list-style: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  outline: none;
}

.add-entry-summary:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.add-entry-summary::after {
  content: "▼";
  font-size: 12px;
  transition: transform var(--transition-fast);
}

.add-entry-dropdown[open] .add-entry-summary::after {
  transform: rotate(180deg);
}

.dropdown-content {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  margin-top: var(--space-2);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  min-width: 200px;
}

.dropdown-content a {
  display: block;
  padding: var(--space-2) var(--space-3);
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.dropdown-content a:hover {
  background: var(--bg-secondary);
}

/* Add Forms */
.add-form {
  margin-bottom: var(--space-8);
  display: none;
}

.add-form.visible {
  display: block;
}

.add-form-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text);
  margin: 0 0 var(--space-4) 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.add-form-title::before {
  content: "📝";
  font-size: var(--text-lg);
}

/* Feed and Entry List */
.feed {
  margin-top: var(--space-8);
}

.feed-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text);
  margin: 0 0 var(--space-6) 0;
}

.entry-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-4);
}

.entry-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--transition-fast);
}

.entry-item:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.entry-item.unread {
  background: var(--accent-bg);
  border-color: var(--accent);
}

.entry-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.entry-info {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.entry-left {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.entry-type {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--accent);
  background: var(--accent-bg);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius);
}

.entry-source {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius);
}

.entry-source.specialist {
  background: var(--success-bg);
  color: var(--success);
}

.entry-source.client {
  background: var(--accent-bg);
  color: var(--accent);
}

.client-icon {
  width: 12px;
  height: 12px;
  background-color: currentColor;
  border-radius: 2px;
}

.entry-dates {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.entry-date {
  font-size: var(--text-sm);
  color: var(--text-muted);
  display: block;
}

.entry-meta {
  font-size: var(--text-xs);
  color: var(--text-subtle);
  flex-shrink: 0;
}

.btn-toggle-read {
  font-size: var(--text-xs);
  opacity: 0.7;
  transition: opacity var(--transition-fast);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}

.btn-toggle-read:hover {
  opacity: 1;
  background: var(--bg-secondary);
  border-color: var(--border-hover);
}

.entry-content {
  color: var(--text);
  line-height: 1.6;
  margin: var(--space-3) 0;
  word-wrap: break-word;
}

.entry-item.file-entry .entry-content {
  margin: var(--space-2) 0;
}

.entry-item.audio-entry .entry-content {
  margin: var(--space-3) 0;
}

/* Eliminate whitespace between inline elements in file entries */
.entry-item.file-entry .entry-content,
.entry-item.file-entry .entry-content *,
.entry-item.file-entry .file-preview *,
.entry-item.file-entry .file-preview-item * {
  font-size: initial;
}

/* Entry Content Truncation */
.entry-item.text-entry .entry-content {
  max-height: 12em;
  overflow: hidden;
  position: relative;
  transition: max-height var(--transition-normal);
}

.entry-item.text-entry .entry-content.expanded {
  max-height: none;
}

.entry-item.text-entry .entry-content.measuring {
  max-height: none !important;
}

.entry-expand {
  margin: var(--space-2) 0;
  text-align: center;
  display: none;
}

.entry-expand.visible {
  display: block;
}

.btn-expand-text {
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-3);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  transition: all var(--transition-fast);
}

.btn-expand-text[data-expanded="true"] svg {
  transform: rotate(180deg);
}

.file-comment {
  margin: var(--space-2) 0 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.5;
  padding: var(--space-3);
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  max-height: 100px;
  overflow: hidden;
  white-space: normal;
}

.version-content {
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 15em;
  overflow: hidden;
  padding: var(--space-3);
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* File Previews */
.file-preview {
  margin: var(--space-2) 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.file-preview a {
  text-decoration: none !important;
}

.file-preview-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition-fast);
  width: 100%;
  min-height: auto;
  box-sizing: border-box;
}

.file-preview-item:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.file-preview-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: opacity var(--transition-fast);
}

.file-preview-link:hover {
  opacity: 0.8;
  text-decoration: none;
}

.file-preview-img {
  max-width: 100%;
  max-height: 200px;
  margin: 0 auto;
  object-fit: contain;
  display: block;
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.file-preview-info {
  padding: var(--space-3) var(--space-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-icon {
  width: 24px;
  height: 24px;
  margin-right: var(--space-2);
  flex-shrink: 0;
}

.file-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text);
  margin: 0;
  word-break: break-word;
}

.file-size {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin: var(--space-1) 0 0 0;
}

.entry-content a {
  color: var(--accent);
  text-decoration: none;
  font-weight: var(--font-medium);
  transition: color var(--transition-fast);
}

.entry-content a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
}

.entry-actions .btn {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
}

.inline-form {
  display: inline;
  margin: 0;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.page-info {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Version history */
.entry-type-label,
.entry-date-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
}

.version-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.version-item {
  margin-bottom: 1rem;
}

.version-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.25rem;
}

.version-type {
  font-size: 0.9rem;
  color: var(--accent);
  display: block;
  margin-bottom: 0.5rem;
}

/* Trash */
.trash-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.trash-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 1rem;
  align-items: start;
}

.trash-item .entry-preview {
  grid-column: 1 / -1;
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 4em;
}

.trash-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
}

.trash-item .file-name {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  margin: var(--space-8) 0;
}

.empty-state-icon {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text);
  margin: 0 0 var(--space-2) 0;
}

.empty-state-description {
  font-size: var(--text-base);
  margin: 0 0 var(--space-4) 0;
  line-height: 1.5;
}

.empty-state a {
  color: var(--accent);
  font-weight: var(--font-medium);
  text-decoration: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}

.empty-state a:hover {
  background: var(--accent-bg);
  text-decoration: underline;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 500px;
  width: 100%;
  margin: var(--space-4);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg-secondary);
}

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-6);
  border-top: 1px solid var(--border-light);
  justify-content: flex-end;
}

.export-info {
  margin-top: var(--space-4);
  padding: var(--space-4);
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

.export-info p {
  margin: 0 0 var(--space-3) 0;
}

.export-rules {
  margin: 0;
  padding-left: var(--space-4);
  list-style: none;
}

.export-rules li {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.export-rules li:before {
  content: "•";
  color: var(--accent);
  font-weight: bold;
  margin-right: var(--space-2);
}

/* Form Styles for Modal */
.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: var(--text-base);
  transition: border-color var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* Select dropdown styles */
.form-select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: var(--space-10);
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.form-select:hover {
  border-color: var(--border-hover);
}

/* Print Styles */
@media print {
  .header,
  .header-actions,
  .entry-actions,
  .btn {
    display: none !important;
  }

  .card {
    border: 1px solid #000 !important;
    box-shadow: none !important;
  }

  body {
    font-size: 12pt !important;
  }
}

/* ============================================
   BALANCE & REFERRAL CARDS
   ============================================ */

/* Balance Card */
.balance-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow);
}

.balance-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-light);
}

.balance-amount {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--text);
  line-height: 1.2;
}

.balance-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

.balance-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.detail-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) 0;
}

.detail-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.detail-value {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text);
}

.balance-link {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--success);
  background: var(--success-bg);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.balance-link:hover {
  opacity: 0.8;
}

.balance-link.negative {
  color: var(--danger);
  background: var(--danger-bg);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  border-radius: var(--radius-xl);
}

.status-trial {
  background: var(--accent-bg);
  color: var(--accent);
}

/* Метка «в работе» / «сейчас». Цвет — тот же --accent, что у выделенного
   этапа карты проекта (`.team-roadmap-step.is-current`): метка и состояние
   читаются одной краской. Цвет плитки счётчика «В работе» — из того же
   токена, поэтому отдельная строка не нужна. */
.status-progress {
  background: var(--accent-bg);
  color: var(--accent);
}

.status-active {
  background: var(--success-bg);
  color: var(--success);
}

.status-blocked {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-pending {
  background: var(--warning-bg);
  color: var(--warning);
}

.status-confirmed {
  background: var(--success-bg);
  color: var(--success);
}

.status-rejected {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Referral Card */
.referral-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow);
}

.referral-card .card-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text);
  margin: 0 0 var(--space-2) 0;
}

.referral-card .card-description {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0 0 var(--space-4) 0;
  line-height: 1.5;
}

.referral-blocks {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.referral-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
}

.referral-block-label {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  font-weight: var(--font-medium);
}

.referral-block-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.referral-block-content code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--text);
  letter-spacing: 0.02em;
  background: var(--bg-card);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-width: 200px;
  line-height: 1.5;
}

.referral-block-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg-card);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-width: 200px;
  outline: none;
  line-height: 1.5;
}

/* Legacy styles - keep for backward compatibility */
.referral-code-container {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.referral-code {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--text);
  letter-spacing: 0.05em;
}

.referral-link-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
}

.referral-link-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.referral-link {
  flex: 1;
  min-width: 250px;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: all var(--transition-fast);
}

.referral-link:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

/* Button link style */
.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text);
  margin: 0 0 var(--space-1) 0;
}

.stat-value.positive {
  color: var(--success);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
}

/* Compact stats */
.stat-card.compact {
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  text-align: left;
}

.stat-card.compact .stat-value {
  font-size: var(--text-lg);
  margin: 0;
}

.stat-card.compact .stat-label {
  font-size: var(--text-xs);
}

/* Compact grid */
.stats-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
}

/* Entry comment section */
.entry-comment-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.specialist-comment {
  background: var(--bg-secondary);
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}

.specialist-comment-header {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.375rem;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
}

.specialist-comment-text {
  color: var(--text-primary);
  font-size: 0.875rem;
  line-height: 1.4;
}

/* Hidden by default elements */
.hidden {
  display: none;
}

/* Transaction amounts */
.amount-credit {
  color: var(--success);
  font-weight: var(--font-medium);
}

.amount-debit {
  color: var(--danger);
  font-weight: var(--font-medium);
}

/* Transaction badges */
.transaction-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  border-radius: 50%;
}

.transaction-credit {
  background: var(--success-bg);
  color: var(--success);
}

.transaction-debit {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Section title */
.section-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text);
  margin: var(--space-8) 0 var(--space-4) 0;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-light);
}

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
}

.alert-icon {
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid color-mix(in srgb, var(--warning) 20%, transparent);
  color: var(--warning);
}

.alert-danger {
  background: var(--danger-bg);
  border: 1px solid color-mix(in srgb, var(--danger) 20%, transparent);
  color: var(--danger);
}

.alert-success {
  background: var(--success-bg);
  border: 1px solid color-mix(in srgb, var(--success) 20%, transparent);
  color: var(--success);
}

.alert-info {
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--text);
}

.alert-banner {
  margin-bottom: 0;
  border-radius: 0;
  padding: var(--space-3) var(--space-4);
  justify-content: center;
}

.alert-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
}

.alert-banner .alert-icon {
  margin-top: 0;
}

.alert-link {
  font-weight: var(--font-semibold);
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

.alert-link:hover {
  opacity: 0.85;
}

.balance-cta {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-light);
  text-align: center;
}

.balance-pro-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  max-width: 360px;
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
}

.balance-cta-note {
  margin: var(--space-3) 0 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.page-toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: min(420px, calc(100vw - 32px));
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg, 0 12px 32px rgba(0, 0, 0, 0.18));
  animation: pageToastIn 0.35s ease-out;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.page-toast-success {
  background: var(--success-bg);
  border: 1px solid color-mix(in srgb, var(--success) 25%, transparent);
  color: var(--success);
}

.page-toast-hide {
  opacity: 0;
  transform: translateY(-8px);
}

@keyframes pageToastIn {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   TARIFF DETAILS SECTION
   ============================================ */

/* Link to tariff details */
.tariff-info {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
}

.tariff-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--accent);
  text-decoration: none;
  font-weight: var(--font-medium);
  transition: color var(--transition-fast);
}

.tariff-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.tariff-link svg {
  flex-shrink: 0;
}

/* Tariff details section */
.tariff-details-section {
  margin-top: var(--space-8);
}

/* Tariff cards grid */
.tariff-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-6);
  margin-top: var(--space-6);
}

/* Individual tariff card */
.tariff-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  position: relative;
  transition: all var(--transition-fast);
}

.tariff-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Current tariff styling */
.tariff-current {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.tariff-current:hover {
  border-color: var(--accent);
}

/* Tariff badge ("Текущий тариф" / "Активно") */
.tariff-badge {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  background: var(--accent);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-xl);
}

/* Tariff header */
.tariff-header {
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-light);
}

.tariff-name {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text);
  margin: 0 0 var(--space-2) 0;
}

.tariff-price {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--accent);
}

.tariff-period {
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  color: var(--text-muted);
}

/* Пояснение к цене: расчёт за 30 дней, а не календарный месяц. */
.tariff-note {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Tariff features list */
.tariff-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.tariff-features li {
  font-size: var(--text-sm);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.tariff-features li::before {
  content: "✓";
  color: var(--success);
  font-weight: var(--font-bold);
  flex-shrink: 0;
}

/* ============================================
   TOGGLE SWITCH
   ============================================ */

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.toggle-item label {
  font-weight: var(--font-medium);
  margin: 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.12);
  transition: var(--transition-fast);
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 3px;
  background-color: white;
  transition: var(--transition-fast);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent);
  border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

/* ============================================
   TABS STYLES
   ============================================ */

.tabs {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-6);
  padding: var(--space-1);
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

.tab {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
  background: var(--bg-card);
}

.tab-active {
  background: var(--bg-card);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  font-weight: var(--font-semibold);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
  .main-content {
    padding: var(--space-6) var(--space-4);
  }
}

@media (max-width: 768px) {
  .header-content {
    padding: var(--space-4) var(--space-3);
  }

  .logo {
    font-size: var(--text-lg);
  }

  .nav {
    gap: var(--space-3);
  }

  .nav-account-name {
    display: none;
  }

  .nav-dropdown-menu {
    min-width: 160px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
  }

  .page-title {
    font-size: var(--text-2xl);
  }

  .header-actions {
    justify-content: stretch;
    width: 100%;
  }

  .header-actions .btn {
    flex: 1;
  }

  .client-detail-header {
    padding: var(--space-4);
  }

  .client-info h1 {
    font-size: var(--text-xl);
  }

  .entry-item {
    padding: var(--space-4);
  }

  .entry-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .entry-meta {
    align-self: flex-start;
    text-align: left;
  }

  .entry-dates {
    align-items: flex-start;
  }

  .file-preview {
    grid-template-columns: 1fr;
  }

  .feed-actions {
    flex-direction: column;
    gap: var(--space-3);
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .balance-main {
    flex-direction: column;
    align-items: flex-start;
  }

  .balance-status {
    align-items: flex-start;
  }

  .referral-code-container {
    flex-direction: column;
    align-items: stretch;
  }

  .referral-code-container .btn {
    width: 100%;
    justify-content: center;
  }

  .referral-link-wrapper {
    flex-direction: column;
    align-items: stretch;
  }

  .referral-link {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .tariff-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main-content {
    padding: var(--space-4) var(--space-3);
  }

  .card {
    padding: var(--space-4);
    margin-bottom: var(--space-4);
  }

  .client-link {
    padding: var(--space-4);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .unread-badge {
    align-self: flex-end;
  }

  .login-box {
    padding: var(--space-6);
    margin: var(--space-4);
  }

  .login-title {
    font-size: var(--text-2xl);
  }

  .tariff-card {
    padding: var(--space-4);
  }

  .tariff-badge {
    position: static;
    display: inline-block;
    margin-bottom: var(--space-3);
  }

  .tariff-header {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
  }

  .tabs {
    flex-wrap: wrap;
    gap: var(--space-1);
  }

  .tab {
    flex: 1;
    min-width: 120px;
    justify-content: center;
  }
}

/* Admin presets page */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-6);
}

.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.admin-card-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
}

.admin-card-description {
  margin: 0 0 var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.data-table-container {
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  background: var(--bg-secondary);
}
.loading-cell {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-8) !important;
}

.admin-presets-page {
  max-width: 1200px;
}

.admin-presets-section {
  margin-bottom: var(--space-10);
}

.admin-presets-section-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
}

.admin-presets-section-hint {
  margin: 0 0 var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.admin-presets-loading {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  padding: var(--space-4);
}

.admin-preset-desc {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.admin-preset-flags-inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.admin-preset-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.admin-preset-badge--active {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
}

.admin-preset-badge--inactive {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.admin-preset-badge--muted {
  background: var(--bg-secondary);
  color: var(--text-muted);
}

.admin-preset-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-4);
}

.admin-preset-modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.admin-preset-view-modal {
  max-width: 720px;
}

.admin-preset-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.admin-preset-modal-title-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.admin-preset-modal-title-row h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

.admin-preset-modal-title-row p {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.admin-preset-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
}

.admin-preset-modal-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.admin-preset-modal-body {
  flex: 1;
  overflow: auto;
  padding: var(--space-6);
}

.admin-preset-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
}

.admin-preset-flags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.admin-preset-flag {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  cursor: pointer;
}

.admin-preset-sort-input {
  max-width: 120px;
}

.admin-preset-code {
  margin: 0;
  padding: var(--space-3);
  background: var(--bg-secondary);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow: auto;
}

.admin-preset-code--large {
  max-height: 480px;
}

.admin-preset-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 800px;
}

.admin-preset-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.admin-preset-form-actions-left {
  flex: 1;
}

.admin-preset-form-actions-right {
  display: flex;
  gap: var(--space-3);
}

.admin-preset-delete-confirm {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--danger);
}

.spin-icon {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Нагрузка на сервер звонков (/admin/calls) ──────────────────────────────
   Столбик — пик одновременных звонков за день. Высота приходит с сервера
   в процентах от потолка сервера, поэтому шкала у всех дней одна и столбик
   «на потолке» виден сразу. */

.capacity-block {
  margin-bottom: var(--space-8);
  padding: var(--space-6);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.capacity-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.capacity-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text);
}

.capacity-note {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.capacity-note-alert {
  color: var(--danger);
  font-weight: var(--font-medium);
}

.capacity-periods {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}

.capacity-period {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.capacity-period:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.capacity-period-active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: var(--font-medium);
}

.capacity-peak-day {
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.capacity-chart-wrap {
  margin-top: var(--space-4);
}

.capacity-chart {
  display: grid;
  gap: 2px;
  height: 160px;
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--border);
}

.capacity-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 0;
}

.capacity-col-track {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
}

.capacity-bar {
  position: relative;
  width: 100%;
  min-height: 3px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  transition: var(--transition-fast);
}

.capacity-col:hover .capacity-bar {
  background: var(--accent-hover);
}

.capacity-bar-over {
  background: var(--danger);
}

.capacity-col:hover .capacity-bar-over {
  opacity: 0.85;
}

.capacity-bar-value {
  position: absolute;
  top: -1.1em;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  line-height: 1;
  color: var(--text-muted);
}

.capacity-col-label {
  margin-top: var(--space-1);
  font-size: 10px;
  text-align: center;
  color: var(--text-subtle);
  white-space: nowrap;
  overflow: hidden;
}

/* На девяноста днях подпись каждого дня не помещается: CSS не умеет
   пропускать элементы по счёту, поэтому прячем подписи вовсе, а точную
   дату оставляем в подсказке столбика. */
.capacity-chart[style*="repeat(90,"] .capacity-col-label {
  visibility: hidden;
}

.capacity-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.capacity-legend-alert {
  color: var(--danger);
}

.capacity-table-details {
  margin-top: var(--space-4);
}

.capacity-table-details summary {
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--accent);
}

.capacity-table-details .table-container {
  margin-top: var(--space-3);
}

.capacity-footnote {
  margin: var(--space-4) 0 0;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--text-subtle);
}

.capacity-footnote code {
  font-family: var(--font-mono);
  font-size: inherit;
}

@media (max-width: 640px) {
  .capacity-block {
    padding: var(--space-4);
  }

  .capacity-chart {
    height: 120px;
  }

  .capacity-col-label,
  .capacity-bar-value {
    display: none;
  }
}

/* === Новые специалисты (сквозная аналитика) ===
   Отдельный блок: страница внутренняя, оформление простое — цифры и списки,
   без графиков. Цвета берутся из общих переменных, чтобы тут не появилась
   вторая палитра. */

.admin-filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.filter-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.filter-chip {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: var(--text-sm);
  color: var(--text);
  text-decoration: none;
  background: var(--bg-card);
}

.filter-chip:hover {
  border-color: var(--accent);
}

.filter-chip-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.analytics-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.analytics-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
}

.analytics-card-value {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
}

.analytics-card-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.analytics-bar {
  position: relative;
  min-width: 120px;
  height: 18px;
  border-radius: 999px;
  background: var(--bg-secondary);
  overflow: hidden;
}

.analytics-bar-fill {
  height: 100%;
  background: var(--accent);
  opacity: 0.35;
}

.analytics-bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding-left: var(--space-2);
  font-size: var(--text-xs);
}

.row-subtitle {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: 2px;
}

.row-chip {
  padding: 0 var(--space-2);
  border-radius: 999px;
  background: var(--bg-secondary);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.row-chip-ok {
  background: var(--accent);
  color: #fff;
}

.row-muted {
  color: var(--text-muted);
}

/* Ответы на вопросы в карточке специалиста: подпись ответа идёт первой,
   чтобы строку можно было прочитать, не вспоминая файл вопросов. */
.row-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.row-list .row-subtitle {
  display: inline;
  margin: 0 4px 0 0;
  color: var(--text-muted);
}

.page-hint {
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  max-width: 760px;
}

.data-table-container + .data-table-container,
.analytics-cards + .data-table-container,
.data-table-container + .analytics-cards,
.admin-card + .data-table-container,
.data-table-container + .admin-card {
  margin-top: var(--space-4);
}

/* Отступ между блоками карточки специалиста. */
.analytics-section {
  margin-bottom: var(--space-4);
}

.call-cost-breakdown {
  margin-top: var(--space-1);
}

.call-cost-breakdown summary {
  font-size: var(--text-xs);
  cursor: pointer;
  list-style: none;
}

.call-cost-breakdown summary::-webkit-details-marker {
  display: none;
}

.call-cost-lines {
  margin: var(--space-1) 0 0;
  padding-left: var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.call-cost-lines li {
  margin-bottom: 2px;
}

/* --- Маркетинг: лиды психологов -------------------------------------------
   Шаблоны marketing_my_leads.html, marketing_lead.html и admin/marketing.html
   были написаны с этими классами, а правил под них не было вовсе: карточки,
   плитки счётчиков, фильтры и поиск выстраивались в общий поток страницы и
   лепились друг к другу. Держим их здесь, рядом с остальным CRM. */

.text-muted {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Плитки счётчиков: «Свободных лидов», «Выдан», «Написали»… */
.marketing-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.marketing-stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.marketing-stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  line-height: 1.1;
}

.marketing-stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Счётчик со смыслом статуса — краска как у метки статуса. Сейчас это
   «В работе» на странице команды: число окрашено --accent, тем же токеном,
   что метка «в работе» и выделенный этап карты проекта. */
.marketing-stat.status-progress .marketing-stat-value {
  color: var(--accent);
}

/* Карточка раздела: «Команда», «Последние выдачи», карточка лида. */
.marketing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.marketing-card + .marketing-card,
.admin-grid + .marketing-card,
.marketing-card + .admin-grid {
  margin-top: var(--space-6);
}

.marketing-card .data-table-container {
  margin-top: var(--space-4);
}

.marketing-card p:first-child {
  margin-top: 0;
}

.marketing-card p:last-child {
  margin-bottom: 0;
}

/* Полоса фильтров и поиска над таблицей лидов. */
.marketing-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.marketing-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.marketing-search {
  display: flex;
  gap: var(--space-2);
  flex: 1 1 320px;
  max-width: 420px;
}

.marketing-search .form-control {
  flex: 1 1 auto;
  min-width: 0;
}

.marketing-pager {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* Строка лида. */
.marketing-person {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  min-width: 190px;
}

.marketing-person a {
  white-space: nowrap;
}

/* Таблица лидов: «Отметку» и «Статус» не рвём по словам, «О нём» — самый
   широкий текст, ему отдаём остаток. */
.marketing-leads-table th:nth-child(1),
.marketing-leads-table td:nth-child(1) {
  width: 1%;
  white-space: nowrap;
}

.marketing-leads-table th:nth-child(2),
.marketing-leads-table td:nth-child(2) {
  min-width: 220px;
}

.marketing-leads-table th:nth-child(3),
.marketing-leads-table td:nth-child(3) {
  width: 1%;
  white-space: nowrap;
}

.marketing-bio {
  font-size: var(--text-sm);
  line-height: 1.5;
}

.marketing-samples {
  margin-top: var(--space-1);
  font-style: italic;
}

.marketing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.marketing-card .marketing-actions {
  margin-bottom: var(--space-4);
}

/* История событий в карточке лида. */
.marketing-events {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.marketing-events li {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-light);
}

.marketing-events li:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

/* Формы панели админа: поля друг под другом, кнопка — отдельной строкой. */
.admin-form {
  display: flex;
  flex-direction: column;
}

.admin-form .form-group {
  margin-bottom: var(--space-4);
}

.admin-form .btn {
  align-self: flex-start;
}

.admin-form .text-muted {
  margin: var(--space-2) 0 0;
}

/* Пометка под кнопкой «Закрыть истёкшие» лежит вне формы. */
.admin-card > .text-muted:last-child {
  margin-bottom: 0;
}

/* === Команда: недельный отчёт и доска задач ===
   Внутренний раздел для команды, но открывается и с телефона на встрече:
   всё разложено в одну колонку и не зависит от скриптов. Цвета — из общих
   переменных, чтобы здесь не появилась вторая палитра.
   Страница только читает: счётчики — общие плитки .marketing-stats, метки
   статуса — общие .status-*, своих палитр здесь нет. */

.team-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.team-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.team-toolbar .marketing-search {
  align-items: flex-end;
}

.team-week-caption {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Карта проекта: направление — заголовок, этапы — пронумерованный ряд. */
.team-roadmap-direction + .team-roadmap-direction {
  margin-top: var(--space-4);
}

.team-roadmap {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.team-roadmap-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
}

.team-roadmap-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  counter-reset: team-step;
}

.team-roadmap-step {
  counter-increment: team-step;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  font-size: var(--text-sm);
}

.team-roadmap-step::before {
  content: counter(team-step);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.team-roadmap-step.is-current {
  border-color: var(--accent);
  background: var(--accent-bg);
  font-weight: var(--font-semibold);
}

/* --- Отчёт по людям: карточка на человека --------------------------------
   Только чтение. Порядок сверху вниз: имя, за что отвечает, задачи на
   неделю, что получилось. Карточки идут в ряд на широком экране и
   столбиком на телефоне: на встрече страницу открывают с телефона. */

.team-summary {
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

.team-summary-label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.team-summary-text {
  font-size: var(--text-sm);
  line-height: 1.6;
}

.team-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
}

.team-person-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
}

.team-person-head {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-light);
}

.team-person-name {
  margin: 0 0 var(--space-1);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

.team-person-role {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.team-person-key {
  color: var(--text-subtle);
}

.team-person-section {
  margin-top: var(--space-3);
}

.team-person-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.team-person-tasks,
.team-result-lines {
  list-style: none;
  margin: 0;
  padding: 0;
}

.team-person-task {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
}

.team-person-task-title {
  flex: 1 1 160px;
  min-width: 0;
}

.team-person-task .status-badge {
  font-size: var(--text-xs);
}

.team-result {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: var(--bg-secondary);
}

.team-person-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.team-result + .team-result {
  margin-top: var(--space-2);
}

.team-result-lines {
  margin-top: var(--space-1);
  padding-left: var(--space-3);
  list-style: disc;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.team-result-badge {
  font-size: var(--text-xs);
}

/* Ссылка на доску по номеру задачи: номер и в карточке, и в доске
   одинаковый, поэтому цвет ссылки как у текста, подчёркивание — при наведении. */
.team-person-card a.team-task-number {
  color: var(--text);
  text-decoration: none;
}

.team-person-card a.team-task-number:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Доска задач. */
.team-board-group + .team-board-group {
  margin-top: var(--space-4);
}

/* Строка доски: таблица во всю ширину карточки группы. */
.team-tasks-table {
  width: 100%;
}

.team-task-number {
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  vertical-align: top;
}

.team-task-tags,
.team-task-note {
  font-size: var(--text-xs);
  margin-top: var(--space-1);
}

.team-task-due {
  white-space: nowrap;
  vertical-align: top;
}

@media (max-width: 720px) {
  .team-cards {
    grid-template-columns: 1fr;
  }
}

/* Договоры психолога (PSY-042): список, версии, текст, подписи клиентов. */
.contracts-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 0;
}

.contracts-form .input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--studio-border-light, #e5e7eb);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}

.contracts-form .btn {
  align-self: flex-start;
}

.contract-text {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
  padding: 12px 16px;
  background: var(--studio-bg-subtle, #fbfbfa);
  border: 1px solid var(--studio-border-light, #e5e7eb);
  border-radius: 10px;
  max-height: 60vh;
  overflow: auto;
}

.contract-diff {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.contract-diff__line {
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}

.contract-diff__line p {
  margin: 0;
  white-space: pre-wrap;
}

.contract-diff__label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--studio-text-subtle, #9ca3af);
  margin-bottom: 4px;
}

.contract-diff__line--added {
  background: rgba(74, 107, 82, 0.08);
}

.contract-diff__line--removed {
  background: rgba(180, 64, 44, 0.08);
}

.contract-diff__line--changed {
  background: rgba(138, 97, 0, 0.08);
}

.contract-diff__before {
  color: var(--studio-text-muted, #6b7280);
  text-decoration: line-through;
}

.contract-diff__line--skip {
  background: transparent;
  padding: 4px 12px;
}
/* MWM - Notifications Styles — Стили уведомлений CRM */

/* ============================================
   NOTIFICATIONS STYLES
   ============================================ */

/* Notification Container in Header */
.notification-container {
  position: relative;
  display: flex;
  align-items: center;
}

/* Bell Button */
.notification-bell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}

.notification-bell:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

.notification-bell svg {
  width: 20px;
  height: 20px;
}

/* Badge */
.notification-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: var(--font-semibold);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Dropdown */
.notification-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-height: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  overflow: hidden;
  display: none;
}

/* Dropdown Header */
.notification-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.notification-dropdown-header h3 {
  margin: 0;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text);
}

.notification-dropdown-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Notification List */
.notification-list {
  max-height: 320px;
  overflow-y: auto;
  padding: var(--space-2);
}

/* Notification Item */
.notification-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.notification-item:hover {
  background: var(--bg-secondary);
}

.notification-item.is-unread {
  background: var(--accent-bg);
}

.notification-item.is-unread:hover {
  background: #cce5ff;
}

.notification-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

.notification-content {
  flex: 1;
  min-width: 0;
}

.notification-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.notification-title {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notification-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}

.notification-message {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.notification-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-2);
}

.notification-time {
  font-size: 12px;
  color: var(--text-subtle);
}

.notification-link {
  font-size: 12px;
  color: var(--accent);
}

/* Empty State */
.notification-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  color: var(--text-muted);
  text-align: center;
}

.notification-empty p {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
}

.notification-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  color: var(--text-muted);
}

/* Dropdown Footer */
.notification-dropdown-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
  text-align: center;
}

/* Button Text */
.btn-text {
  padding: var(--space-2) var(--space-3);
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition-fast);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.btn-text:hover {
  background: var(--accent-bg);
  color: var(--accent-hover);
}

/* Icon Button (for notification actions) */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

/* ============================================
   NOTIFICATIONS PAGE STYLES
   ============================================ */

.notifications-page {
  max-width: 800px;
  margin: 0 auto;
}

.notifications-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-light);
}

.notifications-header h1 {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
}

.notifications-filters {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.filter-btn {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: var(--text-sm);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.notifications-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.notifications-list .notification-item {
  padding: var(--space-4);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
}

.notifications-list .notification-item:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.notifications-list .notification-message {
  -webkit-line-clamp: 3;
}

.load-more-btn {
  width: 100%;
  padding: var(--space-4);
  margin-top: var(--space-4);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: var(--text-sm);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.load-more-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--bg-secondary);
}

.load-more-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==========================================================================
   Лента «Что нового» — страница /updates (templates/updates.html)
   Собирается на сервере и открывается даже без скриптов: модального окна
   поверх страницы больше нет, поэтому и стилей панели (backdrop, крестик,
   фиксированная высота) здесь быть не должно.
   ========================================================================== */

.updates-page-release {
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-light);
}

.updates-page-release:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.updates-page-release-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.updates-page-release-title {
  margin: 0;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text);
}

.updates-page-release-meta {
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--text-secondary, var(--text));
  opacity: 0.7;
}

.updates-page-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.updates-page-item {
  padding: var(--space-2) 0;
}

.updates-page-item-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.updates-page-item-title {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text);
}

.updates-tag {
  display: inline-block;
  padding: 1px var(--space-2);
  font-size: var(--text-xs);
  color: var(--accent);
  background: var(--accent-bg);
  border-radius: var(--radius-sm);
}

.updates-page-item-text {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  color: var(--text-secondary, var(--text));
  opacity: 0.85;
}

.updates-page-item-link {
  display: inline-block;
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--accent);
  text-decoration: none;
}

.updates-page-item-link:hover {
  text-decoration: underline;
}

.updates-page-empty {
  padding: var(--space-4) 0;
  font-size: var(--text-sm);
  color: var(--text-secondary, var(--text));
  text-align: center;
}

/* Метка непрочитанного без текста: бейдж рассчитан на цифру, точке нужен
   собственный размер, иначе она схлопывается в ноль. */
.nav-badge--dot {
  min-width: 8px;
  width: 8px;
  height: 8px;
  padding: 0;
}

/* Кабинет специалиста — дизайн-токены --studio-* (не пересекаются с shadcn/Tailwind в style.css). */

:root {
  --studio-bg: #f0ebe3;
  --studio-bg-card: #fffcfa;
  --studio-bg-subtle: #f4f3f1;
  --studio-bg-secondary: #e8e2d9;
  --studio-bg-elevated: #ffffff;
  --studio-border: #ddd6cb;
  --studio-border-light: #e8e2da;
  --studio-border-hover: #cfc6b8;
  --studio-text: #2a2620;
  --studio-text-muted: #6a635a;
  --studio-text-subtle: #8c847a;
  --studio-accent: #4a6b52;
  --studio-accent-on: #fff;
  --studio-accent-hover: #3d5846;
  --studio-accent-warm: #a67c65;
  --studio-accent-soft: #e4ece5;
  --studio-accent-bg: #dce8de;
  --studio-accent-gradient: linear-gradient(135deg, #4a6b52 0%, #5a7d62 48%, #4d6356 100%);
  --studio-warm-gradient: linear-gradient(135deg, rgba(166, 124, 101, 0.14) 0%, rgba(74, 107, 82, 0.1) 100%);
  --studio-shadow-sm: 0 1px 2px rgba(42, 38, 32, 0.05);
  --studio-shadow: 0 2px 8px rgba(42, 38, 32, 0.06), 0 1px 2px rgba(42, 38, 32, 0.04);
  --studio-shadow-md: 0 8px 24px -8px rgba(42, 38, 32, 0.12), 0 2px 6px rgba(42, 38, 32, 0.04);
  --studio-shadow-lg: 0 16px 40px -16px rgba(42, 38, 32, 0.14);
  --studio-radius-sm: 0.375rem;
  --studio-radius: 0.5rem;
  --studio-radius-lg: 0.75rem;
  --studio-radius-xl: 1rem;
  --studio-font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --studio-font-serif: "Literata", Georgia, "Times New Roman", serif;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100%;
  background-color: var(--studio-bg);
}

body {
  letter-spacing: normal;
  line-height: 1.6;
  font-size: 15px;
  color: var(--studio-text);
  background: transparent;
  position: relative;
  min-height: 100vh;
  /* Сброс утечки call-report-visual.css (align-items:flex-start сжимал кабинет) */
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  padding: 0 !important;
}

.site-paths-background {
  display: none !important;
}

.main {
  position: relative;
  z-index: 2;
  background: transparent !important;
  overflow: visible;
}

.main-content {
  position: relative;
  z-index: 1;
  background: transparent !important;
}

::selection {
  background: rgba(74, 107, 82, 0.22);
  color: var(--studio-text);
}

h1, h2, h3, .login-title, .page-title {
  font-family: var(--studio-font-serif);
  font-weight: 500;
  letter-spacing: normal;
  line-height: 1.35;
}

.header {
  position: relative;
  z-index: 3;
  background: rgba(255, 252, 250, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--studio-border-light);
  box-shadow: var(--studio-shadow-sm);
}

.header-content {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.logo-text {
  letter-spacing: normal;
  font-weight: 500;
  color: var(--studio-text);
}

.nav {
  gap: 0.25rem;
}

.nav-link {
  padding: 0.5rem 0.75rem;
  border-radius: var(--studio-radius-lg);
  font-weight: 400;
  color: var(--studio-text-muted);
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
  color: var(--studio-text);
  background: rgba(74, 107, 82, 0.06);
}

.nav-link[aria-current="page"] {
  font-weight: 500;
  color: var(--studio-accent);
  background: var(--studio-accent-soft);
}

.btn {
  letter-spacing: normal;
  border-radius: var(--studio-radius);
  font-weight: 500;
}

.btn-primary {
  background: var(--studio-accent-gradient);
  color: #fff;
  border: 1px solid transparent;
  box-shadow: var(--studio-shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #3d5846 0%, #4a6b52 100%);
  color: #fff;
  box-shadow: var(--studio-shadow);
}

.btn-secondary {
  background: var(--studio-bg-card);
  color: var(--studio-text-muted);
  border: 1px solid var(--studio-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--studio-bg-secondary);
  color: var(--studio-text);
}

.login-page {
  background: transparent;
  min-height: 100vh;
}

.login-box {
  padding: 2rem 1.75rem;
  background: var(--studio-bg-card);
  border: 1px solid var(--studio-border-light);
  border-radius: var(--studio-radius-xl);
  box-shadow: var(--studio-shadow-md);
}

.login-title {
  font-size: 1.5rem;
  font-weight: 500;
}

.form-control:focus {
  border-color: var(--studio-accent);
  box-shadow: 0 0 0 3px rgba(74, 107, 82, 0.16);
}

/* React-острова */
#clients-page-root,
#client-detail-root,
#calls-list-root,
#calls-calendar-root,
#artifacts-list-root,
#ai-chat-detail-root,
#artifact-detail-root,
#user-presets-root,
#pay-page-root,
#ai-templates-settings-root,
#report-blocks-settings-root {
  font-family: var(--studio-font-sans);
  font-size: 15px;
  line-height: 1.6;
  width: 100%;
}

#clients-page-root,
#calls-list-root,
#artifacts-list-root,
#client-detail-root {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

#clients-page-root h1,
#client-detail-root h1,
#calls-list-root h1,
#artifacts-list-root h1,
#report-blocks-settings-root h1 {
  font-family: var(--studio-font-serif);
  font-weight: 500;
  letter-spacing: normal;
}

/* Страница: воздух + панель */
.studio-page {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0 1.5rem;
  min-height: calc(100vh - 4rem);
}

@media (min-width: 768px) {
  .studio-page {
    padding: 0.75rem 0 2rem;
  }
}

/* Список: по центру, как блок настроек профиля */
.studio-panel {
  display: block;
  width: 100%;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  background: var(--studio-bg-card);
  border: 1px solid var(--studio-border-light);
  border-radius: var(--studio-radius-xl);
  box-shadow: var(--studio-shadow-md);
  overflow: hidden;
}

/* Карточка клиента / календарь — чуть шире списков */
#client-detail-root .studio-panel,
#calls-calendar-root .studio-panel {
  max-width: 1400px;
}

.notifications-page .studio-panel {
  max-width: 800px;
  margin: 0 auto;
}

.studio-hero {
  padding: 1.25rem 1.25rem 1.5rem;
  background: var(--studio-warm-gradient);
  border-bottom: 1px solid var(--studio-border-light);
}

@media (min-width: 768px) {
  .studio-hero {
    padding: 1.5rem 1.75rem 1.75rem;
  }
}

.studio-section {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--studio-border-light);
}

@media (min-width: 768px) {
  .studio-section {
    padding: 1rem 1.75rem;
  }
}

.studio-section:last-child {
  border-bottom: none;
}

.studio-list {
  border: 1px solid var(--studio-border-light);
  border-radius: var(--studio-radius-lg);
  overflow: hidden;
  background: var(--studio-bg-elevated);
  box-shadow: var(--studio-shadow-sm);
}

.studio-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--studio-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  background: var(--studio-accent-gradient);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), var(--studio-shadow-sm);
  flex-shrink: 0;
}

.studio-avatar-lg {
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.125rem;
  border-radius: var(--studio-radius-xl);
}

@media (min-width: 768px) {
  .studio-avatar-lg {
    width: 4rem;
    height: 4rem;
    font-size: 1.25rem;
  }
}

.cabinet-card {
  background: var(--studio-bg-card);
  border: 1px solid var(--studio-border-light);
  border-radius: var(--studio-radius-xl);
  box-shadow: var(--studio-shadow-md);
}

.cabinet-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.625rem 1.125rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  background: var(--studio-accent-gradient);
  border: 1px solid transparent;
  border-radius: var(--studio-radius-lg);
  box-shadow: var(--studio-shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}

.cabinet-btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
  box-shadow: var(--studio-shadow);
  transform: translateY(-1px);
}

.cabinet-btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.cabinet-btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.cabinet-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--studio-text-muted);
  background: var(--studio-bg-elevated);
  border: 1px solid var(--studio-border);
  border-radius: var(--studio-radius-lg);
  box-shadow: var(--studio-shadow-sm);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.cabinet-btn-secondary:hover:not(:disabled) {
  background: var(--studio-accent-soft);
  color: var(--studio-accent-hover);
  border-color: rgba(74, 107, 82, 0.25);
}

.cabinet-tab {
  flex-shrink: 0;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--studio-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  border-radius: var(--studio-radius-sm) var(--studio-radius-sm) 0 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.cabinet-tab:hover {
  color: var(--studio-text);
  background: rgba(74, 107, 82, 0.05);
}

.cabinet-tab-active {
  font-weight: 500;
  color: var(--studio-accent);
  border-bottom-color: var(--studio-accent);
  background: rgba(74, 107, 82, 0.08);
}

.cabinet-tab-muted {
  opacity: 0.75;
}

.cabinet-input {
  width: 100%;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  background: var(--studio-bg-elevated);
  border: 1px solid var(--studio-border);
  border-radius: var(--studio-radius-lg);
  box-shadow: inset 0 1px 2px rgba(42, 38, 32, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cabinet-input:focus {
  outline: none;
  border-color: var(--studio-accent);
  box-shadow: 0 0 0 3px rgba(74, 107, 82, 0.14);
}

/* Своя стрелка у select: системная прижата к самому краю и даёт прямоугольный ховер. */
.cabinet-select-arrow {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378756f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8125rem center;
  background-size: 1rem 1rem;
  cursor: pointer;
}

.cabinet-link {
  color: var(--studio-accent);
  text-decoration: none;
  font-weight: 500;
}

.cabinet-link:hover {
  color: var(--studio-accent-hover);
  text-decoration: underline;
}

.cabinet-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--studio-text-muted);
  font-size: 0.875rem;
  background: var(--studio-warm-gradient);
  border-radius: var(--studio-radius-lg);
}

.studio-list-row {
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
}

.studio-list-row:hover {
  background: rgba(74, 107, 82, 0.05);
  transform: translateX(2px);
}

.morphic-tab-nav {
  background: rgba(232, 226, 217, 0.55);
  border: 1px solid rgba(221, 214, 203, 0.6);
}

.studio-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--studio-accent-on);
  background: var(--studio-accent);
  border-radius: 999px;
}

#client-detail-root table.data-table th {
  font-weight: 500;
  color: var(--studio-text-muted);
}

#client-detail-root table.data-table td,
#client-detail-root table.data-table th {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.notifications-page.studio-page {
  padding-top: 0.5rem;
}

.notifications-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.notifications-toolbar-row .page-title {
  margin: 0;
  font-size: 1.5rem;
  color: var(--studio-text);
}

.notifications-page .notifications-tab-nav {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.125rem;
  padding: 0.25rem;
  margin: 0;
  border-radius: var(--studio-radius-xl);
}

.notifications-page .notifications-tab-nav .filter-btn {
  padding: 0.375rem 0.875rem;
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--studio-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--studio-radius-lg);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.notifications-page .notifications-tab-nav .filter-btn:hover {
  color: var(--studio-text);
  background: rgba(255, 252, 250, 0.45);
}

.notifications-page .notifications-tab-nav .filter-btn.active {
  background: var(--studio-accent);
  border: none;
  color: #fff;
  box-shadow: 0 2px 8px rgba(74, 107, 82, 0.22);
}

.notifications-page .notifications-body {
  padding-bottom: 1.25rem;
}

.notifications-page .notifications-list .notification-item {
  background: var(--studio-bg-elevated);
  border-color: var(--studio-border-light);
  border-radius: var(--studio-radius-lg);
}

.notifications-page .notification-empty,
.notifications-page .notification-loading {
  background: transparent;
  color: var(--studio-text-muted);
}

.page-call-detail-embed #call-detail-root {
  background: transparent;
}

.page-call-detail-embed #call-detail-root .min-h-screen {
  background: transparent !important;
}

#artifact-detail-root [data-testid='artifact-detail-form'] {
  background: transparent !important;
}

/* Единая палитра: legacy --accent/--bg → studio (shared.css остаётся для совместимости имён) */
:root {
  --accent: var(--studio-accent);
  --accent-hover: var(--studio-accent-hover);
  --accent-light: #5a7d62;
  --accent-soft: var(--studio-accent-soft);
  --accent-bg: var(--studio-accent-bg);
  --bg: var(--studio-bg);
  --bg-card: var(--studio-bg-card);
  --bg-secondary: var(--studio-bg-secondary);
  --border: var(--studio-border);
  --border-light: var(--studio-border-light);
  --border-hover: var(--studio-border-hover);
  --text: var(--studio-text);
  --text-muted: var(--studio-text-muted);
  --text-subtle: var(--studio-text-subtle);
  --font-sans: var(--studio-font-sans);
}
