/* Prodefence CRM — динамичная чёрно-красная тема */
@import "components/buttons.css";

@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Outfit:wght@400;500;600;700&display=swap");

:root {
  --bg-dark: #030303;
  --bg-card: rgba(12, 12, 12, 0.85);
  --bg-card-solid: #0c0c0c;
  --bg-input: rgba(20, 20, 20, 0.9);
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(220, 38, 50, 0.5);
  --text: #f0f0f0;
  --text-muted: #8a8a8a;
  --accent: #e82e3a;
  --accent-soft: rgba(232, 46, 58, 0.18);
  --accent-glow: rgba(232, 46, 58, 0.4);
  --accent-hover: #ff3d4a;
  --danger: #c41e28;
  --radius: 10px;
  --radius-lg: 14px;
  --font: "Outfit", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-glow: 0 0 40px var(--accent-glow);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Глобальный стиль скроллбаров (единый для всего CRM) */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 46, 58, 0.55) rgba(255, 255, 255, 0.06);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(232, 46, 58, 0.8), rgba(232, 46, 58, 0.45));
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.15);
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(255, 72, 86, 0.9), rgba(232, 46, 58, 0.6));
}

/* Фон приложения (только внутри CRM после входа) */
body.crm-gradient-active::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(42vw 42vw at 14% 20%, rgba(232, 46, 58, 0.11), transparent 68%),
    radial-gradient(40vw 40vw at 86% 22%, rgba(61, 120, 255, 0.11), transparent 67%),
    radial-gradient(34vw 34vw at 50% 78%, rgba(232, 46, 58, 0.06), transparent 64%),
    radial-gradient(
      ellipse 100% 100% at 50% 50%,
      var(--bg-dark) 0%,
      rgba(0, 0, 0, 0.12) 75%,
      rgba(0, 0, 0, 0.25) 100%
    );
  pointer-events: none;
  z-index: 0;
}

body.crm-gradient-active::after {
  content: "";
  position: fixed;
  inset: -12% -8%;
  background:
    radial-gradient(36vw 36vw at 18% 30%, rgba(232, 46, 58, 0.08), transparent 72%),
    radial-gradient(38vw 38vw at 82% 26%, rgba(72, 132, 255, 0.08), transparent 72%),
    radial-gradient(30vw 30vw at 52% 86%, rgba(232, 46, 58, 0.04), transparent 70%);
  filter: blur(12px) saturate(110%);
  animation: crmGradientFloat 22s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes crmGradientFloat {
  0% { transform: translate3d(-1.2%, -1%, 0) scale(1); }
  50% { transform: translate3d(1.1%, 0.8%, 0) scale(1.02); }
  100% { transform: translate3d(-0.6%, 1.2%, 0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  body.crm-gradient-active::after {
    animation: none;
  }
}


/* На экране логина и публичного роудмэпа — общий тёмный фон */
#screen-login::before,
#screen-roadmap-public::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 120% 80% at 50% 50%, rgba(20, 5, 8, 0.97), #050205 60%);
  z-index: -2;
}

/* Динамичный фон: голографический переход синий → красный */
.binary-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: clamp(11px, 1.5vw, 15px);
  font-weight: 600;
  line-height: 1.5;
  white-space: pre;
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-around;
  gap: 0 0.5em;
  padding: 0.25em;
  --hue: 280;
  mask-image: radial-gradient(ellipse 95% 85% at 50% 50%, black 5%, transparent 55%);
  -webkit-mask-image: radial-gradient(ellipse 95% 85% at 50% 50%, black 5%, transparent 55%);
}

.binary-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(80, 120, 255, 0.08) 0%,
    transparent 35%,
    transparent 65%,
    rgba(255, 80, 120, 0.08) 100%
  );
  pointer-events: none;
}

.binary-bg .binary-column {
  flex: 0 0 auto;
  color: hsla(var(--hue), 72%, 85%, 0.55);
  text-shadow:
    0 0 8px hsla(var(--hue), 85%, 78%, 0.6),
    0 0 20px hsla(var(--hue), 75%, 72%, 0.4),
    0 0 2px rgba(255, 255, 255, 0.2);
  animation: binaryScroll 12s linear infinite, binaryPulse 4s ease-in-out infinite;
  animation-fill-mode: both;
}

.binary-bg .binary-column:nth-child(odd) {
  animation-direction: reverse;
  animation-duration: 16s, 5s;
}

.binary-bg .binary-column:nth-child(3n) {
  animation-duration: 20s, 4.5s;
  animation-delay: -3s, -1s;
}

.binary-bg .binary-column:nth-child(5n) {
  animation-duration: 14s, 5.5s;
  animation-delay: -7s, -2s;
}

.binary-bg .binary-column:nth-child(4n) {
  filter: brightness(1.15);
}

@keyframes binaryScroll {
  0% { transform: translateY(-50%); }
  100% { transform: translateY(0); }
}

@keyframes binaryPulse {
  0%, 100% { opacity: 0.38; }
  50% { opacity: 0.52; }
}

#app {
  position: relative;
  z-index: 1;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Login ---------- */
#screen-login,
#screen-roadmap-public {
  position: relative;
}

#screen-login {
  background: transparent;
}

.login-box {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255,255,255,0.03);
  animation: cardIn 0.5s ease-out;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-box .brand-block {
  text-align: center;
  margin-bottom: 1.75rem;
  padding: 1px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.03) 100%);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 24px rgba(232, 46, 58, 0.12);
}

.login-box .brand-inner {
  padding: 1.1rem 1.5rem 1.3rem;
  background: transparent;
  border-radius: calc(var(--radius) - 2px);
}

.login-box .brand-logo {
  display: block;
  max-width: 100%;
  height: auto;
  max-height: 52px;
  margin: 0 auto 0.6rem;
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(232, 46, 58, 0.3));
}

.login-box .brand-crm {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.4em;
  color: rgba(255, 255, 255, 0.9);
  text-transform: uppercase;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.2rem;
}

.form input {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form input:focus {
  outline: none;
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.login-step.hidden {
  display: none !important;
}

.login-step-2fa {
  animation: login2FAIn 0.35s ease-out;
}

@keyframes login2FAIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-2fa-label {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.9);
}

.login-step-2fa #login-2fa-code {
  text-align: center;
  letter-spacing: 0.3em;
  font-size: 1.25rem;
}

.login-step-2fa .btn-back-login {
  width: 100%;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.form button {
  width: 100%;
  margin-top: 0.5rem;
}

/* Кнопка «Войти» — тот же красный, что и полоска под CRM */
.btn-login {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.85rem 1.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-family: var(--font);
  color: #fff !important;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: var(--accent);
  box-shadow:
    0 4px 20px rgba(232, 46, 58, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
}

.btn-login::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 50%);
  pointer-events: none;
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow:
    0 8px 28px rgba(232, 46, 58, 0.55),
    0 0 0 1px rgba(255,255,255,0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-login:active {
  transform: translateY(0);
  box-shadow: 0 2px 12px rgba(232, 46, 58, 0.4);
}

.error-msg {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--accent);
  min-height: 1.25rem;
}

/* Выпадашка напоминания в календаре — в стиле CRM */
.calendar-reminder-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}

.calendar-reminder-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.calendar-reminder-select {
  flex: 1;
  max-width: 220px;
  padding: 0.45rem 2.1rem 0.45rem 0.9rem;
  background: rgba(0, 0, 0, 0.55);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  position: relative;
  background-image: linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.7) 50%), linear-gradient(135deg, rgba(255, 255, 255, 0.7) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.calendar-reminder-select:focus {
  outline: none;
  border-color: var(--border-accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.calendar-reminder-select:hover {
  border-color: var(--border-accent);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition), border-color var(--transition);
}

.btn:active {
  transform: scale(0.98);
}

/* Основная кнопка — приглушённый акцент, без яркого градиента */
.btn-primary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.btn-primary:hover {
  color: #fff;
  border-color: var(--border-accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(232, 46, 58, 0.2);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Вторичная кнопка — прозрачная с красной обводкой */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(232, 46, 58, 0.2);
}

/* Кнопка удаления — приглушённая, при наведении красная */
.btn-danger {
  color: var(--text-muted);
  border-color: transparent;
}

.btn-danger:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(232, 46, 58, 0.12);
}

/* ---------- Dashboard & Header ---------- */
#screen-dashboard {
  display: block;
  min-height: 100vh;
  flex-direction: column;
  align-items: stretch;
}

/* ---------- Layout: левый сайдбар + контент ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.mobile-nav-toggle {
  position: fixed;
  left: 0.9rem;
  top: 0.9rem;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(12, 12, 12, 0.9);
  color: rgba(255, 255, 255, 0.92);
  font-size: 1.1rem;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2600;
}

.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  z-index: 2450;
}

body.mobile-nav-open {
  overflow: hidden;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-card-solid);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.02);
  transition: width 0.2s ease;
}

.sidebar.collapsed {
  width: 72px;
}

.sidebar.collapsed .sidebar-brand {
  padding: 0.75rem 0.5rem;
  justify-content: center;
}

/* Развёрнутая панель: только logo.png + CRM. Свёрнутая: только logo-solo.png */
.sidebar:not(.collapsed) .sidebar-logo-solo {
  display: none !important;
}

.sidebar.collapsed .sidebar-logo-full,
.sidebar.collapsed .sidebar-crm,
.sidebar.collapsed .sidebar-btn-label {
  display: none;
}

.sidebar.collapsed .sidebar-logo-solo {
  display: block;
  height: 32px;
  width: 32px;
  object-fit: contain;
}

.sidebar.collapsed .sidebar-btn {
  justify-content: center;
  padding: 0.6rem;
}

.sidebar.collapsed .sidebar-nav,
.sidebar.collapsed .sidebar-footer {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  align-items: center;
}

.sidebar.collapsed .sidebar-toggle .sidebar-toggle-icon {
  transform: rotate(180deg);
}

.sidebar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--accent) 0%, transparent 70%);
  opacity: 0.25;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.35rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card-solid);
}

/* Чёрный фон в PNG логотипах сливается с фоном CRM */
.sidebar-brand .sidebar-logo {
  height: 26px;
  width: auto;
  object-fit: contain;
  display: block;
  mix-blend-mode: lighten;
}

.sidebar.collapsed .sidebar-brand .sidebar-logo-solo {
  height: 32px;
  width: 32px;
}

.sidebar-crm {
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 0.85rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.6rem 0.85rem;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  transition: color var(--transition), background var(--transition);
}

.sidebar-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-btn.active {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(232, 46, 58, 0.15);
}

.sidebar-btn.active .sidebar-btn-icon {
  color: var(--accent);
}

.sidebar-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: inherit;
  opacity: 0.9;
}

.sidebar-btn-icon svg {
  width: 100%;
  height: 100%;
}

.sidebar-btn-label {
  white-space: nowrap;
}

.sidebar-toggle {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 0.35rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}

.sidebar-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-toggle-icon {
  display: block;
  transition: transform 0.2s;
}

.sidebar.collapsed .sidebar-toggle {
  padding: 0.5rem;
}

.sidebar-footer {
  padding: 0.65rem 0.65rem 0.85rem;
  border-top: 1px solid var(--border);
}

.sidebar-btn-logout {
  color: var(--text-muted);
  border-radius: var(--radius);
}

.sidebar-btn-logout:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-btn-admin.hidden {
  display: none;
}

/* ---------- Main & Toolbar ---------- */
.app-layout > main {
  flex: 1;
  min-width: 0;
}

main {
  padding: 2rem 1.75rem;
  max-width: 1200px;
  margin: 0 auto;
  animation: fadeIn 0.4s ease-out;
}

@media (max-width: 900px) {
  .mobile-nav-toggle {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(82vw, 300px);
    z-index: 2500;
    transform: translateX(-102%);
    transition: transform 0.24s ease;
    border-right: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.45);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: min(82vw, 300px);
  }

  .sidebar.collapsed .sidebar-logo-full,
  .sidebar.collapsed .sidebar-crm,
  .sidebar.collapsed .sidebar-btn-label {
    display: unset;
  }

  .sidebar.collapsed .sidebar-logo-solo {
    display: none;
  }

  .sidebar.collapsed .sidebar-btn {
    justify-content: flex-start;
    padding: 0.6rem 0.85rem;
  }

  .sidebar.collapsed .sidebar-nav,
  .sidebar.collapsed .sidebar-footer {
    align-items: stretch;
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  .sidebar-toggle {
    display: none;
  }

  main {
    max-width: 100%;
    width: 100%;
    padding: 4rem 0.9rem 1rem;
  }

  .toolbar {
    margin-bottom: 0.9rem;
    gap: 0.6rem;
  }

  .toolbar h2 {
    font-size: 1.3rem;
  }

  .toolbar-actions {
    width: 100%;
    display: flex;
    gap: 0.5rem;
  }

  .toolbar-actions .btn {
    flex: 1;
    min-height: 42px;
  }

  .filters-panel {
    padding: 0.8rem;
  }

  .filters-row {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.55rem;
  }

  .filter-group,
  .filter-group-search,
  .filter-group-date {
    width: 100%;
  }

  .filter-group-search .input-search,
  .filters-row .input-select,
  .date-range .input-date,
  .input-date-wrap,
  .input-date-display {
    min-width: 0;
    width: 100%;
    max-width: none;
  }

  .date-range {
    width: 100%;
    gap: 0.35rem;
  }

  .date-range-sep {
    display: none;
  }

  .filter-actions {
    width: 100%;
    margin-left: 0;
    gap: 0.5rem;
  }

  .filter-actions .btn {
    flex: 1;
    min-height: 42px;
  }

  .cases-grid {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  #page-case .toolbar {
    align-items: flex-start;
  }

  #page-case .toolbar .btn {
    min-height: 40px;
  }

  #page-case .toolbar h2 {
    width: 100%;
    font-size: 1.02rem;
    line-height: 1.25;
  }

  .case-page-title-wrap {
    width: 100%;
    flex: 1 1 100%;
  }

  .case-title-heading-text {
    font-size: 1.02rem;
    line-height: 1.25;
  }

  .case-detail-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    gap: 0.45rem;
  }

  .case-detail-tab {
    white-space: nowrap;
    font-size: 0.88rem;
    padding: 0.48rem 0.8rem;
  }

  .case-detail-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .case-detail-sidebar {
    position: static;
    top: auto;
    gap: 0.85rem;
  }

  .case-panel-head {
    padding: 0.85rem 0.9rem 0.65rem;
  }

  .case-panel-body {
    padding: 0.9rem;
  }

  .case-docs-kp-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem;
  }

  .case-docs-kp-items {
    margin-top: 0;
    gap: 0.55rem;
  }

  .kp-catalog-head {
    margin-top: 0;
  }

  .kp-catalog-search {
    height: 34px;
    font-size: 0.88rem;
  }

  .kp-catalog-list {
    max-height: 46vh;
    padding-right: 2px;
    gap: 6px;
  }

  .kp-catalog-item {
    padding: 8px 9px;
    gap: 8px;
  }

  .case-docs-kp-items-foot {
    justify-content: stretch;
  }

  #kp-add-item-btn {
    width: 100%;
    min-height: 40px;
  }

  .case-file-uploader {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 8px;
  }

  .case-file-uploader-pick {
    height: 36px;
  }

  .case-kp-generate-controls {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .case-kp-generate-controls .btn,
  .case-kp-generate-controls select {
    width: 100%;
    min-height: 42px;
  }

  .case-tab-pane-documents .case-panel-body {
    padding: 0.8rem;
  }

  .case-tab-pane-documents .case-docs-kp-title {
    font-size: 0.95rem;
  }
}

/* ---------- Стек тостов (всплывающие уведомления) ---------- */
.toast-stack {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 10000;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 2rem));
}

.toast-item {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.05);
  animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 100%;
}

.toast-item.info {
  border-left: 3px solid #7eb8ff;
}

.toast-item.success {
  border-left: 3px solid #2ecc71;
}

.toast-item.warning {
  border-left: 3px solid #f1c40f;
}

.toast-item.error {
  border-left: 3px solid var(--accent);
}

.toast-item.reminder {
  border-left: 3px solid var(--accent);
  background: linear-gradient(135deg, var(--bg-card-solid) 0%, rgba(232, 46, 58, 0.06) 100%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.05), 0 0 20px var(--accent-glow);
}

.toast-item-icon {
  flex-shrink: 0;
  font-size: 1.2rem;
}

.toast-item-body {
  flex: 1;
  min-width: 0;
}

.toast-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.toast-item-message {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.toolbar h2 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff;
}

#page-dashboard .toolbar .btn-primary {
  padding: 0.6rem 1.25rem;
  font-weight: 600;
  border-radius: var(--radius);
}

#page-dashboard .toolbar .btn-primary:hover {
  box-shadow: 0 0 0 1px rgba(232, 46, 58, 0.25);
}

#page-case .toolbar {
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
}

#page-case .toolbar h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.case-page-title-wrap {
  flex: 1;
  min-width: 0;
}

.case-page-title-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.case-title-heading-text {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.case-title-edit-icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(232, 46, 58, 0.34);
  background:
    linear-gradient(145deg, rgba(232, 46, 58, 0.16), rgba(61, 120, 255, 0.12)),
    rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.96);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.case-title-edit-icon:hover {
  border-color: rgba(232, 46, 58, 0.58);
  background:
    linear-gradient(145deg, rgba(232, 46, 58, 0.24), rgba(61, 120, 255, 0.18)),
    rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(232, 46, 58, 0.15);
}

.case-title-edit-icon:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(232, 46, 58, 0.35);
}

.case-title-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.case-title-editor-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ---------- Empty state ---------- */
.cases-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  animation: emptyPulse 3s ease-in-out infinite;
}

@keyframes emptyPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.cases-empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.9;
  display: block;
}

.cases-empty-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.cases-empty-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}

/* ---------- Cases filters ---------- */
.cases-filters {
  margin-bottom: 1.5rem;
}

.filters-panel {
  background: linear-gradient(145deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.35rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.filters-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.7rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-group-search .input-search {
  width: 100%;
  min-width: 190px;
  max-width: 260px;
}

.filters-row .input-search,
.filters-row .input-select,
.filters-row .input-date {
  padding: 0.55rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.filters-row .input-search:focus,
.filters-row .input-select:focus,
.filters-row .input-date:focus {
  outline: none;
  border-color: rgba(232, 46, 58, 0.4);
  box-shadow: 0 0 0 2px rgba(232, 46, 58, 0.12);
}

.filters-row .input-select {
  min-width: 150px;
  cursor: pointer;
}

.filter-group-date {
  flex-wrap: wrap;
}

.filter-group-date .filter-date-label {
  width: 100%;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-range .input-date {
  min-width: 122px;
}

.input-date-wrap {
  position: relative;
  min-width: 124px;
}

.input-date-display {
  width: 100%;
  min-width: 124px;
  padding-right: 2.1rem !important;
  cursor: pointer;
  font-size: 0.84rem !important;
}

.input-date-trigger {
  position: absolute;
  top: 50%;
  right: 0.45rem;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 1.5rem;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 0.45rem;
}

.input-date-trigger:hover {
  color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.08);
}

.input-date-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(232, 46, 58, 0.25);
}

.date-range-sep {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex-shrink: 0;
}

.filter-date-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.cases-date-picker {
  position: absolute;
  z-index: 2100;
  width: 236px;
  padding: 0.58rem;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    linear-gradient(165deg, rgba(20, 20, 20, 0.98), rgba(10, 10, 10, 0.98)),
    radial-gradient(circle at top right, rgba(61, 120, 255, 0.1), transparent 55%),
    radial-gradient(circle at top left, rgba(232, 46, 58, 0.12), transparent 50%);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(10px);
}

.cases-date-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.cases-date-picker-month {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  text-transform: capitalize;
}

.cases-date-picker-nav {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
}

.cases-date-picker-nav:hover {
  border-color: rgba(232, 46, 58, 0.45);
  background: rgba(232, 46, 58, 0.16);
}

.cases-date-picker-weekdays,
.cases-date-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cases-date-picker-weekdays {
  margin-bottom: 0.2rem;
}

.cases-date-picker-weekdays span {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  text-transform: uppercase;
}

.cases-date-cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 0.48rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  cursor: pointer;
  font-size: 0.74rem;
}

.cases-date-cell:hover {
  background: rgba(255, 255, 255, 0.1);
}

.cases-date-cell.is-today {
  box-shadow: inset 0 0 0 1px rgba(61, 120, 255, 0.65);
}

.cases-date-cell.is-selected {
  background: linear-gradient(145deg, rgba(232, 46, 58, 0.82), rgba(61, 120, 255, 0.75));
  color: #fff;
  font-weight: 700;
}

.cases-date-cell.is-empty {
  visibility: hidden;
  pointer-events: none;
}

.cases-date-picker-foot {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
}

.cases-date-picker-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0.44rem;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.72rem;
  padding: 0.22rem 0.5rem;
  line-height: 1.15;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.cases-date-picker-btn:hover {
  border-color: rgba(232, 46, 58, 0.5);
  background: rgba(232, 46, 58, 0.17);
  color: #fff;
}

.cases-date-picker-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(232, 46, 58, 0.28);
}

@media (max-width: 1200px) {
  .filters-row {
    flex-wrap: wrap;
    align-items: flex-end;
  }
  .filter-actions {
    margin-left: 0;
  }
}

/* ---------- Cases grid & cards ---------- */
.cases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.35rem;
}

.case-card {
  padding: 1.35rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, rgba(18,18,18,0.95) 0%, rgba(12,12,12,0.98) 100%);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  animation: cardAppear 0.4s ease-out backwards;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.cases-grid .case-card:nth-child(1) { animation-delay: 0.05s; }
.cases-grid .case-card:nth-child(2) { animation-delay: 0.1s; }
.cases-grid .case-card:nth-child(3) { animation-delay: 0.15s; }
.cases-grid .case-card:nth-child(4) { animation-delay: 0.2s; }
.cases-grid .case-card:nth-child(5) { animation-delay: 0.25s; }
.cases-grid .case-card:nth-child(n+6) { animation-delay: 0.3s; }

@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.case-card:hover {
  border-left-color: var(--accent-hover);
  border-color: rgba(232, 46, 58, 0.25);
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(232, 46, 58, 0.15);
}

.case-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.08rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.case-card .meta {
  font-size: 0.84rem;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--font-mono);
}

.toolbar-cases-actions,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Модалка настройки колонок доски сделок */
.modal-deal-board-settings.modal-box {
  max-width: 420px;
}

.modal-case-status-settings.modal-box {
  max-width: 520px;
}

.modal-deal-board-settings .deal-board-settings-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
  line-height: 1.4;
}

.deal-board-status-list {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
}

.deal-board-status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card-solid);
  transition: background 0.15s;
}

.deal-board-status-row:last-child {
  border-bottom: none;
}

.deal-board-status-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.deal-board-status-name,
.deal-board-status-name-input {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--text);
}

.deal-board-status-name-input {
  display: block;
  width: 100%;
  padding: 0.35rem 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  color: var(--text);
}

.deal-board-status-name-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.deal-board-add-column {
  margin-bottom: 1rem;
}

.deal-board-status-remove {
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.35rem 0.5rem !important;
  min-width: 28px !important;
}

.deal-board-status-remove:hover {
  color: var(--danger);
}

/* Переключатель «показать на доске» — компактный свитч справа */
.deal-board-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.deal-board-toggle:hover {
  background: rgba(255, 255, 255, 0.16);
}

.deal-board-status-check {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.deal-board-toggle-slider {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s ease;
}

.deal-board-status-check:checked + .deal-board-toggle-slider {
  transform: translateX(18px);
  background: var(--accent);
}

.deal-board-toggle:has(.deal-board-status-check:checked) {
  background: rgba(232, 46, 58, 0.15);
  border-color: rgba(232, 46, 58, 0.4);
}

.deal-board-status-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.deal-board-status-actions .btn {
  min-width: 32px;
  padding: 0.4rem 0.5rem;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.deal-board-status-actions .btn:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-accent);
}

.deal-board-status-actions .btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.cases-view-toggle {
  display: flex;
  gap: 0.15rem;
}

.cases-view-toggle .btn-sm.active {
  color: var(--accent);
  background: var(--accent-soft);
}

#cases-list-wrap {
  position: relative;
  min-height: 120px;
}

#cases-list.hidden,
#cases-kanban.hidden {
  display: none !important;
}

/* ---------- Доска сделок (Kanban) ---------- */
.cases-kanban {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 1rem 0 0.25rem;
  min-height: 400px;
  align-items: flex-start;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.05);
}

.cases-kanban::-webkit-scrollbar {
  height: 10px;
}

.cases-kanban::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 5px;
  margin: 0 0.5rem;
}

.cases-kanban::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 5px;
}

.cases-kanban::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

.cases-kanban .cases-empty {
  flex: 1;
  min-width: 280px;
}

.kanban-column {
  flex: 0 0 200px;
  min-width: 200px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 280px);
}

.kanban-column-head {
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.kanban-column-title {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: 0.2rem;
  line-height: 1.25;
}

.kanban-column-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.kanban-column-cards {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.kanban-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.kanban-card:hover {
  background: var(--accent-soft);
  border-color: var(--border-accent);
}

.kanban-card-title {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.2rem;
  line-height: 1.25;
}

.kanban-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.kanban-card-amount {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
}

.case-personal-note-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

#case-personal-note-body {
  width: 100%;
  min-height: 80px;
  margin-bottom: 0.5rem;
  padding: 0.65rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  resize: vertical;
}

#case-personal-note-save {
  margin-top: 0.25rem;
}

.tasks-placeholder {
  padding: 3rem 2rem;
  text-align: center;
}

.tasks-placeholder-text {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0;
}

/* ---------- Case detail: layout ---------- */
#case-detail {
  margin-top: 0.75rem;
}

.case-detail-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
}

.case-detail-tab {
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.case-detail-tab:hover {
  color: var(--text);
}

.case-detail-tab.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
}

.case-tab-pane {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.case-tab-pane.hidden {
  display: none !important;
}

.case-panel-roadmap-standalone .case-panel-body,
.case-panel-chat-standalone .case-panel-body {
  min-height: 120px;
}

.case-detail-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
  max-width: 1180px;
}

@media (max-width: 920px) {
  .case-detail-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .case-contact-view-grid {
    grid-template-columns: 1fr;
  }
  .case-contact-main {
    grid-template-columns: 1fr;
  }
}

.case-detail-main {
  min-width: 0;
}

.case-detail-sidebar {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

/* ---------- Main column: panels — чёрный фон, белый текст ---------- */
.case-panel {
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
}

.case-panel-head {
  padding: 1rem 1.35rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.case-panel-heading {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.case-panel-body {
  padding: 1.25rem 1.35rem 1.35rem;
}

.case-summary-editor {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.case-summary-editor .case-input {
  min-height: 110px;
  resize: vertical;
}

.case-summary-editor-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.case-contacts-hint {
  margin: 0 0 0.85rem;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.85rem;
}

.case-contacts-list {
  display: grid;
  gap: 0.8rem;
}

.case-contacts-empty {
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 0.9rem;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
}

.case-contact-card {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(20, 20, 20, 0.96), rgba(12, 12, 12, 0.98));
  padding: 0.85rem;
  display: grid;
  gap: 0.7rem;
}

.case-contact-view {
  display: grid;
  gap: 0.6rem;
}

.case-contact-view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.case-contact-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  background: linear-gradient(145deg, rgba(232, 46, 58, 0.32), rgba(61, 120, 255, 0.26));
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.case-contact-view-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.case-contact-action-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(232, 46, 58, 0.35);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.95);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.02rem;
  line-height: 1;
}

.case-contact-action-icon svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
  display: block;
}

.case-contact-action-icon:hover {
  background: rgba(232, 46, 58, 0.14);
  border-color: rgba(232, 46, 58, 0.58);
}

.case-contact-delete-icon {
  border-color: rgba(255, 107, 120, 0.4);
  color: rgba(255, 145, 156, 0.95);
}

.case-contact-delete-icon:hover {
  background: rgba(255, 107, 120, 0.17);
  border-color: rgba(255, 107, 120, 0.62);
  color: rgba(255, 173, 182, 0.98);
}

.case-contact-view-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.case-contact-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.case-contact-label {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.case-contact-value {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.88rem;
  word-break: break-word;
}

.case-contact-comment-view {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.55rem;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.86rem;
  white-space: pre-wrap;
}

.case-contact-main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 0.55rem;
}

.case-contact-comment {
  grid-column: 1 / -1;
  min-height: 64px;
  resize: vertical;
}

.case-contact-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.case-docs-kp {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.case-docs-kp-title {
  font-size: 1rem;
  font-weight: 600;
}
.case-docs-kp-grid {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: 20px;
  align-items: flex-start;
}
.case-docs-kp-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.case-docs-kp-signature {
  margin-top: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}
.case-docs-kp-signature-field .case-input-label {
  min-height: 34px;
  display: flex;
  align-items: flex-end;
}
.case-file-input-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.case-file-uploader {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  min-height: 48px;
}
.case-file-uploader-pick {
  height: 40px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.05s ease;
}
.case-file-uploader-pick:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.26);
}
.case-file-uploader-pick:active {
  transform: translateY(1px);
}
.case-file-uploader.has-file .case-file-uploader-pick {
  display: none;
}
.case-file-uploader-plus {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  line-height: 1;
}
.case-file-uploader-pick-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.case-file-uploader-meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  min-width: 0;
}
.case-file-uploader-status {
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
}
.case-file-uploader-name {
  margin-left: 2px;
}
.case-file-uploader.has-file .case-file-uploader-status {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}
.case-file-uploader-name {
  min-width: 0;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.82);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
}
.case-file-uploader-clear {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
}
.case-file-uploader-clear:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}
.case-file-uploader:not(.has-file) .case-file-uploader-clear {
  opacity: 0.35;
  pointer-events: none;
}
.case-file-uploader:not(.has-file) .case-file-uploader-name {
  display: none;
}
.case-file-uploader.has-file .case-file-uploader-name {
  display: block;
}
.case-file-uploader:not(.has-file) .case-file-uploader-clear {
  display: none;
}
.case-docs-kp-signature-field input[type="file"] {
  width: 100%;
}
.case-docs-kp-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: -12px;
}
.case-docs-kp-items-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}
.case-input.case-input-sm {
  height: 28px;
  padding: 2px 8px;
  font-size: 0.82rem;
}
.case-docs-kp-items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.case-docs-kp-items-list:empty {
  display: none;
}

.kp-catalog {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 2px;
}
.kp-catalog-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  margin-top: -8px;
}
.kp-catalog-title {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.kp-catalog-search {
  width: 100%;
  max-width: none;
  height: 28px;
  font-size: 0.82rem;
}
.kp-catalog-list {
  max-height: calc(100vh - 295px);
  overflow: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kp-catalog-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
}
.kp-catalog-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
}
.kp-catalog-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}
.kp-catalog-checkbox:checked {
  background: linear-gradient(135deg, var(--accent-soft), var(--accent));
  border-color: transparent;
}
.kp-catalog-checkmark {
  width: 0;
  height: 0;
}
.kp-catalog-body {
  min-width: 0;
}
.kp-catalog-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.kp-catalog-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.kp-catalog-edit {
  min-width: 34px;
}

.kp-catalog-edit.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.kp-catalog-name {
  min-width: 0;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.kp-catalog-desc {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.35;
  white-space: pre-wrap;
}

.kp-catalog-editor {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kp-catalog-editor-title {
  height: 30px;
  line-height: 30px;
  padding: 2px 8px;
  font-size: 0.88rem;
}

.kp-catalog-editor-desc {
  resize: none;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  padding: 6px 8px;
  font-size: 0.85rem;
  overflow: auto;
}
.kp-item-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: start;
  padding: 6px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
}
.kp-item-enabled-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kp-item-enabled-label input {
  width: 16px;
  height: 16px;
}
.kp-item-texts {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kp-item-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.kp-item-title {
  height: 26px;
  line-height: 26px;
  padding: 2px 8px !important;
  font-size: 0.86rem;
  box-sizing: border-box;
  min-width: 0;
}

.kp-item-toggle {
  flex: 0 0 auto;
  padding: 0 0.25rem !important;
  min-width: 26px;
}

.kp-item-desc-preview {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kp-item-desc {
  resize: none;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  overflow: auto;
  padding: 0.35rem 0.5rem !important;
  box-sizing: border-box !important;
  font-size: 0.85rem;
}
.case-docs-kp-totals {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  margin-top: 4px;
  font-size: 0.9rem;
}
.case-docs-kp-total-label {
  color: var(--text-muted);
  margin-right: 4px;
}
.case-docs-kp-total-value {
  font-weight: 600;
}
.case-docs-kp-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.case-kp-generate-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.kp-generate-format {
  width: 120px;
}

.case-docs-kp-totals-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-top: 8px;
  align-items: stretch;
}

.case-docs-kp-total-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.case-docs-kp-total-field .case-input-label {
  min-height: 34px;
  display: flex;
  align-items: flex-end;
}

/* Чекбоксы КП в стиле CRM */
.kp-item-enabled {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.kp-item-enabled:focus-visible {
  outline: none;
  box-shadow: 0 0 0 1px var(--accent-soft), 0 0 0 2px rgba(0, 0, 0, 0.9);
}
.kp-item-enabled:hover {
  border-color: var(--accent-soft);
}
.kp-item-enabled:checked {
  background: linear-gradient(135deg, var(--accent-soft), var(--accent));
  border-color: transparent;
}

@media (min-width: 900px) {
  .case-docs-kp-totals-inputs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.case-panel-head-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.case-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.case-summary-head-actions {
  margin-top: 0;
  margin-left: auto;
}

.case-summary-edit-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(232, 46, 58, 0.34);
  background:
    linear-gradient(145deg, rgba(232, 46, 58, 0.16), rgba(61, 120, 255, 0.12)),
    rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.96);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.case-summary-edit-icon:hover {
  border-color: rgba(232, 46, 58, 0.58);
  background:
    linear-gradient(145deg, rgba(232, 46, 58, 0.24), rgba(61, 120, 255, 0.18)),
    rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(232, 46, 58, 0.15);
}

.case-summary-edit-icon:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(232, 46, 58, 0.35);
}

/* Роудмэп в кейсе */
.roadmap-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.roadmap-step-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

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

.roadmap-step-num {
  font-weight: 700;
  color: var(--accent);
  min-width: 1.5rem;
}

.roadmap-step-title {
  flex: 1;
  color: var(--text);
}

.roadmap-step-status {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
}

.roadmap-status-done { background: rgba(76, 175, 80, 0.2); color: #81c784; }
.roadmap-status-progress { background: var(--accent-soft); color: var(--accent); }
.roadmap-status-paused { background: rgba(255, 193, 7, 0.15); color: #ffca28; }
.roadmap-status-cancelled { color: var(--text-muted); opacity: 0.8; }

.roadmap-step-due {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Чат Telegram в кейсе */
.case-chat-hint {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.case-chat-link-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
}

.case-chat-link-controls .case-input {
  max-width: 280px;
}

.case-chat-linked {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.case-chat-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.case-chat-topline .case-chat-linked {
  margin: 0;
}

.case-chat-meta-toggle {
  min-width: 34px;
  padding: 0.2rem 0.45rem;
}

.case-chat-meta {
  margin-bottom: 0.4rem;
}

.case-chat-id-hint {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.case-chat-id-hint code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.85em;
}

.case-chat-id-hint .btn-link {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.case-chat-id-hint .btn-link:hover {
  color: var(--text);
}

.case-chat-toolbar {
  margin-bottom: 0.75rem;
}

.case-chat-messages {
  max-height: 420px;
  overflow-y: auto;
  margin-bottom: 1rem;
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.case-chat-empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.case-chat-msg {
  padding: 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius);
  border-left: 3px solid transparent;
}

.case-chat-msg-from-crm {
  border-left-color: var(--accent);
  background: rgba(232, 46, 58, 0.06);
}

.case-chat-msg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.case-chat-msg-author {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
}

.case-chat-msg-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.case-chat-msg-head .case-chat-msg-delete {
  margin-left: auto;
  margin-top: 0;
}

.case-chat-msg-text {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.case-chat-msg-text:empty {
  display: none;
}

.case-chat-msg-delete {
  margin-top: 0.4rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  color: var(--accent);
  background: rgba(232, 46, 58, 0.1);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
}

.case-chat-msg-delete:hover {
  background: rgba(232, 46, 58, 0.2);
  color: var(--text);
}

.case-chat-msg-delete:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.case-chat-msg-media {
  margin: 0.35rem 0;
}

.case-chat-msg-img {
  max-width: 100%;
  max-height: 240px;
  border-radius: var(--radius);
  display: block;
}

.case-chat-msg-video {
  max-width: 100%;
  max-height: 240px;
  border-radius: var(--radius);
}

.case-chat-msg-video-note-wrap {
  display: inline-block;
}

.case-chat-msg-video-note {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: var(--bg-input, #2a2a2a);
}

.case-chat-msg-voice-wrap {
  max-width: 280px;
}

.case-chat-msg-voice {
  width: 100%;
  height: 40px;
  margin: 0;
  vertical-align: middle;
}

.case-chat-msg-voice::-webkit-media-controls-panel {
  background: var(--bg-input, #2a2a2a);
}

.case-chat-msg-download {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--accent);
}

.case-chat-msg-edit {
  margin-top: 0.35rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.case-chat-msg-edit:hover {
  color: var(--text);
  border-color: var(--border-accent);
}

.case-chat-msg-edit-wrap {
  margin-top: 0.25rem;
}

.case-chat-msg-edit-input {
  width: 100%;
  min-height: 60px;
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.35rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  resize: vertical;
  box-sizing: border-box;
}

.case-chat-msg-edit-wrap .btn {
  margin-right: 0.5rem;
}

.case-chat-send {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.case-chat-send-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.case-chat-send textarea {
  flex: 1;
  min-height: 60px;
  padding: 0.6rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  resize: vertical;
}

.case-chat-send textarea:focus {
  outline: none;
  border-color: var(--border-accent);
}

.case-chat-send-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.case-chat-send-filename {
  font-size: 0.85rem;
  color: var(--text-muted, #888);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Модалка редактирования роудмэпа */
.modal-roadmap-edit .roadmap-steps-list {
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}

.roadmap-edit-step {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.roadmap-edit-step .roadmap-step-input-title {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 0.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.roadmap-edit-step .roadmap-step-input-desc {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 0.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  resize: vertical;
}

.roadmap-step-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.roadmap-step-row .roadmap-step-select-status {
  padding: 0.4rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.roadmap-step-row .roadmap-step-input-due {
  padding: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

/* Модалка доступа клиенту */
.modal-roadmap-access .roadmap-access-intro {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.roadmap-access-step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.roadmap-access-step-num {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 50%;
}

.roadmap-access-step-body {
  flex: 1;
  min-width: 0;
}

.roadmap-access-step-body label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.roadmap-access-step-body .meta {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
}

.roadmap-access-step-body input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

.roadmap-access-step-body .btn-primary {
  margin-bottom: 0;
}

.roadmap-access-step-body #roadmap-access-regenerate {
  margin-bottom: 0;
  width: 100%;
  display: block;
}

.roadmap-access-url-wrap {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: stretch;
}

.roadmap-access-url {
  flex: 1;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  margin-bottom: 0 !important;
  height: 54px;
  line-height: 1.2;
}

#roadmap-access-copy {
  min-width: 124px;
  height: 54px;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  margin: 0;
  padding: 0 1rem;
}

/* Публичная страница роудмэпа — центрирование карточки как на логине */
#screen-roadmap-public {
  background: transparent;
  position: relative;
}

.roadmap-public-auth {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
}

.roadmap-public-auth .roadmap-public-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.roadmap-public-auth .roadmap-public-hint {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.roadmap-public-content.hidden {
  display: none !important;
}

#screen-roadmap-public .roadmap-public-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 2rem 2rem 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.roadmap-public-heading {
  margin: 0 0 1.75rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

/* Центр кружка с номером от левого края шага: padding 0.5rem + половина ширины кружка 2.25rem */
.roadmap-public-timeline {
  --timeline-x: calc(0.5rem + 2.25rem / 2);
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

/* Вертикальная линия таймлайна — ровно по центру всех кружков */
.roadmap-public-timeline::before {
  content: "";
  position: absolute;
  left: calc(var(--timeline-x) - 1px);
  top: calc(1.25rem + 2.25rem / 2);
  bottom: calc(1.25rem + 2.25rem / 2);
  width: 2px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 1px;
}

.roadmap-pub-step {
  position: relative;
  padding: 1.25rem 0 1.25rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  transition: background 0.2s ease;
}

.roadmap-pub-step:last-child {
  border-bottom: none;
}

.roadmap-pub-step-num {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

.roadmap-pub-step-body {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.roadmap-pub-step-title {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.roadmap-pub-step-desc {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.roadmap-pub-step-status {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.roadmap-pub-step-due {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  opacity: 0.9;
}

/* Запланировано — приглушённо */
.roadmap-pub-step:not(.roadmap-pub-step-done):not(.roadmap-pub-step-progress) .roadmap-pub-step-title {
  color: var(--text-muted);
}

/* Сделано — зелёный акцент */
.roadmap-pub-step-done .roadmap-pub-step-num {
  background: rgba(76, 175, 80, 0.28);
  color: #81c784;
  border-color: rgba(76, 175, 80, 0.4);
}

.roadmap-pub-step-done .roadmap-pub-step-status {
  color: #81c784;
}

/* Активный шаг (В работе) — вертикальная полоска ровно по линии таймлайна */
.roadmap-pub-step-progress {
  background: linear-gradient(90deg, rgba(232, 46, 58, 0.08) 0%, transparent 100%);
  border-radius: var(--radius);
}

.roadmap-pub-step-progress::before {
  content: "";
  position: absolute;
  left: calc(var(--timeline-x) - 2px);
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
  border-radius: 2px;
  z-index: 0;
}

.roadmap-pub-step-progress .roadmap-pub-step-num {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 46, 58, 0.35);
}

.roadmap-pub-step-progress .roadmap-pub-step-title {
  color: var(--text);
}

.roadmap-pub-step-progress .roadmap-pub-step-status {
  color: var(--accent);
  font-weight: 700;
}

.case-summary-text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  color: #fff;
  white-space: pre-wrap;
}

.case-new-note {
  margin-bottom: 1.25rem;
}

.case-new-note textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #080808;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  font-family: var(--font);
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.2s ease;
}

.case-new-note textarea::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.case-new-note textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-add-note {
  min-width: 120px;
}

/* ---------- Вложения: кастомный выбор файла ---------- */
.case-upload-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.case-file-input-hidden {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.case-file-drop {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  min-width: 200px;
  background: #080808;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.case-file-drop:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background: #0c0c0c;
  color: #fff;
}

.case-file-drop-icon {
  font-size: 1.1rem;
  opacity: 0.9;
}

.case-file-drop-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Sidebar: blocks — чёрный фон, белый текст ---------- */
.case-sidebar-block {
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1.2rem 1.3rem;
}

.case-sidebar-block-title {
  margin: 0 0 0.9rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.case-sidebar-block-participants .case-sidebar-block-title {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.72rem;
}

.case-sidebar-hint {
  font-weight: 400;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.9em;
}

/* Meta list (О кейсе) */
.case-meta-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.case-meta-item {
  margin: 0;
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 0.5rem;
  align-items: center;
}

.case-meta-item dt {
  margin: 0;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
}

.case-meta-item dd {
  margin: 0;
  font-size: 0.92rem;
  color: #fff;
}

.case-meta-status dd {
  padding: 0;
}

.case-status-select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  background: #080808;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
}

.case-participants-wrap {
  margin-bottom: 0.75rem;
}

.case-participants-ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.case-participant-item {
  padding: 0.4rem 0;
  font-size: 0.9rem;
  color: #fff;
  line-height: 1.4;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

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

.case-participant-role {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.85em;
  font-weight: 500;
}

.case-participants-empty {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.5);
}

.case-participants-list {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.9);
  margin: 0 0 0.75rem;
  line-height: 1.5;
}

.case-alias-controls {
  display: flex;
  gap: 0.5rem;
}

.case-alias-controls .case-input {
  flex: 1;
  min-width: 0;
}

/* Finance block */
.case-finance-row {
  margin-bottom: 0.9rem;
}

.case-finance-row:last-of-type {
  margin-bottom: 1rem;
}

.case-finance-row label {
  display: block;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 0.35rem;
}

.case-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: #080808;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  transition: border-color 0.2s ease;
}

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

.case-sidebar-actions {
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 0.25rem;
}

.btn-block {
  display: block;
  width: 100%;
  text-align: center;
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(185, 28, 44, 0.4);
}

.btn-outline-danger:hover {
  background: rgba(185, 28, 44, 0.12);
  border-color: var(--danger);
}

/* ---------- Заметки: карточки ---------- */
.notes-list {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.note-item {
  list-style: none;
  margin: 0;
  padding: 0;
}

.note-card {
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  transition: border-color 0.2s ease;
}

.note-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.note-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.note-card-meta {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
}

.note-card-body {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #fff;
  white-space: pre-wrap;
  word-break: break-word;
}

.note-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.note-card-edit {
  flex-shrink: 0;
}

.note-card-delete {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem;
}

.note-card-delete:hover {
  color: var(--accent);
}

.note-edit-form {
  width: 100%;
}

.note-edit-form textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
  resize: vertical;
  min-height: 80px;
}

.note-edit-actions {
  display: flex;
  gap: 0.5rem;
}

.hidden {
  display: none !important;
}

/* Вложения: строка с именем файла и кнопкой удаления */
.attachments-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.attachment-item .attachment-download {
  flex: 1;
  text-align: left;
  min-width: 0;
}

.attachment-item .attachment-delete {
  flex-shrink: 0;
  padding: 0.25rem 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.attachment-item .attachment-delete:hover {
  color: var(--accent);
}

.case-panel input:focus,
.case-panel textarea:focus,
.case-sidebar-block input:focus {
  outline: none;
  border-color: var(--border-accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ---------- Profile page ---------- */
.profile-page {
  max-width: 560px;
  margin: 0 auto;
}

.profile-page-title {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.profile-content {
  animation: fadeIn 0.35s ease-out;
}

.profile-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.profile-section {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.profile-section:last-child {
  border-bottom: none;
}

.profile-section-title {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.profile-form input {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-bottom: 0.85rem;
  padding: 0.7rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
}

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

.profile-form label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.profile-form button {
  margin-top: 0.5rem;
}

.profile-security {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.profile-password-block label,
.profile-2fa-block label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.password-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 320px;
}

.password-fields input {
  padding: 0.55rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
}

.profile-hint {
  font-size: 0.85rem;
  color: var(--text-muted, #888);
  margin: 0.35rem 0 0.75rem;
  line-height: 1.4;
}

.profile-msg {
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
  min-height: 1.25em;
}

.profile-2fa-status {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.profile-2fa-disable {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.profile-2fa-disable input {
  padding: 0.55rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  min-width: 180px;
}

.profile-2fa-setup-box {
  margin-top: 0.75rem;
}

.profile-2fa-setup-box p {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.profile-2fa-setup-box #profile-2fa-qr {
  margin: 0.5rem 0;
}

.profile-2fa-setup-box code {
  font-size: 0.85rem;
  background: rgba(0,0,0,0.3);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.profile-2fa-setup-box input {
  display: block;
  margin: 0.5rem 0;
  padding: 0.55rem 0.85rem;
  max-width: 160px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
}

/* ---------- Employees (admin) ---------- */
.employees-list {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.employee-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.95fr);
  gap: 0.95rem;
  align-items: start;
}

.employee-panel {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  box-shadow:
    0 12px 28px rgba(0,0,0,0.2),
    0 0 0 1px rgba(212,31,55,0.1),
    0 0 28px rgba(212,31,55,0.12);
  overflow: hidden;
}

.employee-panel::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 12px;
  pointer-events: none;
  background: linear-gradient(
    135deg,
    rgba(212,31,55,0.22) 0%,
    rgba(212,31,55,0.05) 30%,
    rgba(212,31,55,0.03) 65%,
    rgba(212,31,55,0.16) 100%
  );
  opacity: 0.22;
}

.employee-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.7rem;
  margin-bottom: 0.75rem;
}

.employee-list-search-wrap {
  width: 100%;
  margin-bottom: 0.55rem;
}

.employee-panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.employee-panel-subtitle {
  margin-top: 0.15rem;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.employee-create-card,
.employee-positions-admin,
.employee-list-panel {
  padding: 0.9rem 1rem;
  min-height: 420px;
  display: flex;
  flex-direction: column;
}

.employee-list-panel {
  margin-top: 0.05rem;
  min-height: 0;
}

.employee-create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.employee-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.employee-field > span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.employee-field-wide {
  grid-column: 1 / -1;
}

.employee-create-actions {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
}

.employee-positions-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.employee-positions-admin-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.employee-position-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 0.4rem;
  align-items: center;
}

.employee-cards-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: calc(100vh - 330px);
  overflow-y: auto;
  padding-right: 4px;
}

.employee-card {
  display: grid;
  grid-template-columns: minmax(220px, 0.95fr) minmax(0, 1.25fr);
  gap: 0.8rem;
  align-items: start;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
}

.employee-card-main {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.employee-card-topline {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  flex-wrap: wrap;
}

.employee-name {
  font-weight: 600;
  color: var(--text);
}

.employee-login {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.employee-role {
  font-size: 0.69rem;
  padding: 0.14rem 0.42rem;
  border-radius: 999px;
  border: 1px solid rgba(212,31,55,0.35);
  background: rgba(212,31,55,0.16);
  color: #f0c3ca;
}

.employee-position-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.employee-position-badge {
  font-size: 0.68rem;
  padding: 0.12rem 0.36rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.045);
  color: var(--text-muted);
}

.employee-position-empty {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.8;
}

.employee-position-line {
  font-size: 0.76rem;
  color: #cfd3da;
  margin-top: 0.1rem;
}

.employee-position-line strong {
  color: #e8ecf4;
  font-weight: 600;
}

.employee-card-controls {
  display: grid;
  grid-template-columns: 1fr;
  justify-content: stretch;
  align-items: center;
  gap: 0.38rem;
  min-width: 0;
  width: 100%;
}

.employee-card-positions {
  grid-column: 1 / -1;
  width: 100%;
}

.employee-role-select {
  grid-column: 1 / -1;
  min-width: 0;
  width: 100%;
  height: 30px;
  font-size: 0.8rem;
}

.employee-card-actions-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.3rem;
  width: 100%;
}

.employee-positions-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.employee-position-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  padding: 0.16rem 0.44rem;
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  font-size: 0.73rem;
  cursor: pointer;
  user-select: none;
}

.employee-position-chip input[type="checkbox"],
.employee-active-toggle input[type="checkbox"] {
  appearance: none;
  margin: 0;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255,255,255,0.46);
  border-radius: 4px;
  background: rgba(0,0,0,0.4);
  position: relative;
}

.employee-position-chip input[type="checkbox"]:checked,
.employee-active-toggle input[type="checkbox"]:checked {
  background: linear-gradient(180deg, #f04a61, #d41f37);
  border-color: rgba(212,31,55,0.96);
}

.employee-position-chip input[type="checkbox"]:checked::after,
.employee-active-toggle input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 7px;
  height: 7px;
  background: #fff;
  border-radius: 2px;
}

.employee-active-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
  background: rgba(255,255,255,0.02);
  width: 100%;
  justify-content: center;
  min-height: 28px;
  font-size: 0.72rem;
}

.btn-save-employee,
.btn-reset-pwd,
.btn-delete-employee {
  width: 100%;
  justify-content: center;
  min-height: 28px;
  padding: 0.22rem 0.45rem;
  font-size: 0.75rem;
}

.employee-list-empty {
  margin-top: 0.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media (max-width: 1100px) {
  .employee-top-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .employee-create-grid {
    grid-template-columns: 1fr;
  }
  .employee-position-row {
    grid-template-columns: 1fr;
  }
  .employee-card {
    grid-template-columns: 1fr;
  }
  .employee-card-controls {
    min-width: 0;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: flex-start;
  }
  .employee-active-toggle,
  .btn-save-employee,
  .btn-reset-pwd,
  .btn-delete-employee {
    width: 100%;
    justify-content: center;
  }
}

/* ---------- Шаблоны услуг КП (admin) ---------- */
.kp-templates-page {
  padding: 1rem 0.15rem 1.2rem;
}
.kp-templates-add {
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.kp-templates-add h3 {
  margin: 0 0 0.75rem;
}
.kp-templates-form-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}
.kp-templates-form-row label {
  min-width: 120px;
  color: var(--text-muted);
}
.kp-template-title-input,
.kp-template-desc-input {
  flex: 1 1 360px;
}
.kp-templates-checkbox input {
  margin-right: 0.4rem;
}
.kp-templates-list-wrap {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.kp-templates-list-wrap h3 {
  margin: 0 0 0.75rem;
}
.kp-templates-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  padding-right: 6px;
}
.kp-templates-list::-webkit-scrollbar {
  width: 8px;
}
.kp-templates-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
}
.kp-template-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  align-items: start;
}
.kp-template-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.kp-template-drag {
  cursor: grab;
  color: rgba(255, 255, 255, 0.65);
  user-select: none;
}
.kp-template-order-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.kp-template-fields {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 0;
}
.kp-template-fields .case-input {
  width: 100%;
}
.kp-template-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
  justify-content: flex-start;
}

.kp-template-action-buttons {
  display: flex;
  flex-direction: row;
  gap: 0.45rem;
  align-items: center;
  justify-content: flex-end;
}
.kp-template-actions .btn {
  white-space: nowrap;
  padding: 0.22rem 0.35rem;
}
.kp-template-active {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.05rem 0.1rem;
}

.kp-template-active input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

/* уменьшаем “высоту” описания, чтобы карточки не были огромными */
.kp-template-desc-input {
  width: 100%;
  height: 56px !important;
  min-height: 56px !important;
  max-height: 56px !important;
  overflow: auto;
  resize: none;
  padding: 0.25rem 0.45rem;
  box-sizing: border-box !important;
  font-size: 0.85rem;
  flex: 0 0 56px !important;
  min-width: 0;
}

.kp-template-title-input {
  height: 30px !important;
  padding: 0 0.45rem;
  font-size: 0.88rem;
  line-height: 30px;
  box-sizing: border-box !important;
  flex: 0 0 30px !important;
  min-height: 30px !important;
}

.kp-template-title-input,
.kp-template-desc-input {
  flex: 0 0 auto !important;
  align-self: stretch;
  min-width: 0;
}

.kp-template-order-buttons .btn {
  padding: 0.2rem 0.35rem;
  min-height: 26px;
  min-width: 26px;
}

.kp-template-actions .btn {
  padding: 0.35rem 0.7rem;
}

/* ---------- Доска задач (по сделкам) ---------- */
.tasks-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tasks-board-root {
  min-height: 200px;
  margin-top: 0.5rem;
}

.tasks-board-loading,
.tasks-board-error {
  color: var(--text-muted);
  padding: 1rem;
}

.tasks-board-error {
  color: var(--accent);
}

.tasks-board {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.tasks-col {
  flex: 1 1 200px;
  min-width: 200px;
  max-width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}

.tasks-col-overdue .tasks-col-head {
  border-bottom-color: rgba(232, 46, 58, 0.45);
}

.tasks-col-overdue .tasks-col-title {
  color: var(--accent);
}

.tasks-col-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.tasks-col-title {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tasks-col-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.tasks-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tasks-col-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  padding: 8px 0;
}

.tasks-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  font: inherit;
  color: var(--text);
}

.tasks-card:hover {
  border-color: var(--border-accent, var(--accent));
  background: rgba(232, 46, 58, 0.1);
}

.tasks-col-overdue .tasks-card {
  border-left: 3px solid var(--accent);
}

.tasks-card-deal {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tasks-card-title {
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tasks-card-due {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ---------- Календарь (личные события) ---------- */
.calendar-toolbar {
  flex-wrap: wrap;
  gap: 0.75rem;
}

.calendar-toolbar-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.calendar-view-switch .btn-sm.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.calendar-view-switch .btn-sm.active:hover {
  background: rgba(232, 46, 58, 0.28);
}

.calendar-nav-month,
.calendar-nav-week {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calendar-week-range {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  min-width: 160px;
  text-align: center;
}

.calendar-wrap {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
  align-items: start;
}

/* Неделя/день: вся ширина под сетку, события сбоку строкой ниже — без горизонтального скролла */
.calendar-wrap.calendar-wrap-wide {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
}

.calendar-wrap.calendar-wrap-wide .calendar-sidebar {
  max-width: 100%;
}

@media (max-width: 900px) {
  .calendar-wrap {
    grid-template-columns: 1fr;
  }
}

.calendar-month-wrap.hidden,
.calendar-week-wrap.hidden,
.calendar-day-wrap.hidden {
  display: none !important;
}

.calendar-header {
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Неделя: временная шкала */
.calendar-week-wrap {
  grid-column: 1;
  min-width: 0;
  width: 100%;
  overflow-x: hidden;
}

.calendar-timeline {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  width: 100%;
}

.calendar-timeline-time-col {
  display: flex;
  flex-direction: column;
  background: var(--bg-card-solid);
  border-right: 1px solid var(--border);
}

.calendar-timeline-slot {
  height: 24px;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0 0.35rem;
  display: flex;
  align-items: flex-end;
  font-family: var(--font-mono);
}

.calendar-timeline-slot:empty {
  height: 24px;
}

.calendar-timeline-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-width: 0;
  width: 100%;
}

.calendar-day-wrap {
  grid-column: 1;
  min-width: 0;
}

.calendar-timeline-day.calendar-timeline {
  grid-template-columns: 52px 1fr;
}

.calendar-timeline-day-single {
  grid-template-columns: minmax(0, 1fr);
}

.calendar-timeline-day-col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
  width: 100%;
}

.calendar-timeline-day-col:last-child {
  border-right: none;
}

.calendar-timeline-spacer {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card-solid);
}

.calendar-timeline-day-header {
  height: 32px;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card-solid);
}

/* Целый день — одна строка на событие, без скролла; длинный текст — превью + … */
.calendar-day-allday-strip {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px 4px;
  min-height: 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  box-sizing: border-box;
}

.calendar-day-allday-strip--empty {
  padding: 0;
  min-height: 28px;
  background: var(--bg-card-solid);
}

.calendar-allday-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
  min-height: 28px;
  max-height: 28px;
  padding: 4px 8px;
  font-size: 0.7rem;
  line-height: 1.2;
  text-align: left;
  border: 1px solid var(--border-accent, var(--border));
  border-radius: 6px;
  background: rgba(232, 46, 58, 0.14);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition);
  overflow: hidden;
}

.calendar-allday-chip:hover {
  background: rgba(232, 46, 58, 0.28);
}

.calendar-allday-chip-icon {
  flex-shrink: 0;
  font-size: 0.85rem;
  opacity: 0.9;
  line-height: 1.2;
  margin-top: 1px;
}

.calendar-allday-chip-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-timeline-day-body {
  position: relative;
  height: 672px;
  min-height: 672px;
}

.calendar-event-block {
  position: absolute;
  left: 3px;
  right: 3px;
  margin-top: 1px;
  padding: 6px 8px 8px 8px;
  font-size: 0.7rem;
  line-height: 1.35;
  text-align: left;
  overflow: hidden;
  border: none;
  border-left: 3px solid var(--accent);
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  font-family: var(--font);
  box-sizing: border-box;
  z-index: 1;
  /* Короткие слоты (30 мин) иначе режут нижнюю часть букв (хвосты у р, ч, н…) */
  min-height: 52px;
}

.calendar-event-block .calendar-event-meta {
  display: block;
  font-size: 0.64rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 4px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-event-block .calendar-event-title {
  display: block;
  font-weight: 500;
  line-height: 1.35;
  padding-bottom: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-event-block:hover {
  z-index: 4;
  background: rgba(232, 46, 58, 0.35);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--border-accent);
}

/* Попап события (в стиле CRM) */
.calendar-event-popup {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem;
  background: rgba(0, 0, 0, 0.6);
  animation: fadeIn 0.2s ease-out;
}

.calendar-event-popup.hidden {
  display: none;
}

.calendar-event-popup-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.05);
  overflow: hidden;
}

.calendar-event-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: rgba(232, 46, 58, 0.12);
  border-bottom: 1px solid var(--border);
}

.calendar-event-popup-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.calendar-event-popup-actions {
  display: flex;
  gap: 0.25rem;
}

.calendar-event-popup-body {
  padding: 1.25rem;
}

.calendar-event-popup-meta {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.calendar-event-popup-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.45;
}

.calendar-event-popup-desc-empty {
  color: var(--text-muted);
  font-style: italic;
}

.calendar-month-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  min-width: 200px;
  text-align: center;
}

.btn-icon {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

.calendar-grid {
  grid-column: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  gap: 2px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 2px;
}

.calendar-weekdays {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.calendar-weekday {
  padding: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  background: var(--bg-card-solid);
}

.calendar-day {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  min-height: 100px;
  padding: 0.4rem;
  background: var(--bg-card);
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-align: left;
}

.calendar-day:hover {
  background: var(--bg-input);
}

.calendar-day-other {
  color: var(--text-muted);
  opacity: 0.7;
}

.calendar-day-selected {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.calendar-day-selected:hover {
  background: rgba(232, 46, 58, 0.28);
}

.calendar-day-num {
  display: block;
  font-weight: 600;
  flex-shrink: 0;
  margin-bottom: 0.25rem;
}

.calendar-day-events-inner {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.calendar-day-event-line {
  font-size: 0.7rem;
  line-height: 1.25;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-day-event-time {
  color: var(--accent);
  font-weight: 600;
  margin-right: 0.2rem;
}

.calendar-day-other .calendar-day-event-time {
  color: var(--text-muted);
}

.calendar-day-more {
  font-size: 0.65rem;
  color: var(--accent);
  font-weight: 600;
  margin-top: 0.1rem;
}

.calendar-sidebar {
  grid-column: 2;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

@media (max-width: 900px) {
  .calendar-sidebar {
    grid-column: 1;
  }
}

.calendar-day-title {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.calendar-day-events {
  list-style: none;
  padding: 0;
  margin: 0;
}

.calendar-no-events {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 0.5rem 0;
}

.calendar-event-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

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

.calendar-event-time {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 48px;
}

.calendar-event-title {
  flex: 1;
  font-size: 0.95rem;
  color: var(--text);
}

.calendar-event-actions {
  display: flex;
  gap: 0.35rem;
}

.calendar-event-actions .btn-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}

#modal-calendar-event .modal-actions {
  flex-wrap: wrap;
}

#modal-calendar-event .modal-actions .btn-danger {
  margin-right: auto;
}

/* ---------- Notes & attachments ---------- */
.attachments-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.attachments-list li {
  margin-bottom: 0.35rem;
}

.attachments-list .btn {
  color: var(--accent);
}

.attachments-list .btn:hover {
  color: var(--accent-hover);
}

/* ---------- Status badges ---------- */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: transform var(--transition);
}

.status-badge.in_work {
  background: rgba(33, 150, 243, 0.25);
  color: #64b5f6;
}

.status-badge.open {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-badge.in_progress {
  background: rgba(232, 46, 58, 0.28);
  color: #ff8a95;
}

.status-badge.closed {
  background: var(--border);
  color: var(--text-muted);
}

.status-badge.analytics { background: rgba(100, 149, 237, 0.25); color: #7eb8ff; }
.status-badge.sent_kp { background: rgba(255, 193, 7, 0.25); color: #ffd54f; }
.status-badge.report_dev { background: rgba(156, 39, 176, 0.25); color: #e1bee7; }
.status-badge.police_claim { background: rgba(232, 46, 58, 0.28); color: #ff8a95; }
.status-badge.worked { background: rgba(76, 175, 80, 0.25); color: #81c784; }
.status-badge.cut { background: rgba(96, 125, 139, 0.25); color: #b0bec5; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: overlayIn 0.25s ease-out;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-overlay.hidden {
  display: none;
}

/* Тост — краткое сообщение без кнопки */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  background: var(--surface-elevated, #2a2a2e);
  color: var(--text);
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  max-width: 90vw;
}
.toast.hidden {
  display: none !important;
}

.modal-notify {
  max-width: 360px;
}

.modal-notify-message {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
}

.modal-notify .modal-actions {
  justify-content: flex-end;
}

.modal-confirm {
  max-width: 380px;
}

.modal-confirm-message {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
}

.modal-confirm .modal-actions {
  justify-content: flex-end;
  gap: 0.75rem;
}

.modal-reset-password {
  max-width: 420px;
}

.modal-reset-password-message {
  margin: 0 0 0.85rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.modal-box {
  width: 100%;
  max-width: 440px;
  padding: 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card-solid);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.05);
  animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-box h3 {
  margin: 0 0 1.25rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

.modal-box label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.modal-box input,
.modal-box textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
}

.modal-box input:focus,
.modal-box textarea:focus {
  outline: none;
  border-color: var(--border-accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ---------- Предпросмотр КП ---------- */
.modal-kp-preview {
  max-width: 720px;
}

.kp-preview-content {
  max-height: 62vh;
  overflow: auto;
  padding-right: 6px;
}

.kp-preview-frame {
  width: 100%;
  height: min(72vh, 820px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #111;
}

.kp-preview-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 14px;
}

.kp-preview-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.kp-preview-key {
  color: var(--text-muted);
  font-size: 0.9rem;
  min-width: 150px;
}

.kp-preview-val {
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
}

.kp-preview-services-title {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 10px;
}

.kp-preview-item {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.kp-preview-item-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.kp-preview-item-desc {
  color: var(--text-muted);
  line-height: 1.4;
}

.kp-preview-muted {
  color: rgba(255, 255, 255, 0.45);
}

.new-case-participants-search {
  width: 100%;
  margin-bottom: 0.5rem;
  box-sizing: border-box;
}

.participants-checkboxes {
  max-height: 180px;
  overflow-y: auto;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
}

.participant-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
  transition: background var(--transition);
}

.participant-option:hover {
  background: rgba(255, 255, 255, 0.04);
}

.participant-option input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.modal-actions .btn {
  min-width: 110px;
  padding: 0.7rem 1.25rem;
}

/* Модалка «Новая сделка»: два столбца — основное + примечание */
.modal-new-deal.modal-box {
  max-width: 640px;
}

.deal-form-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
}

.deal-form-main label,
.deal-form-side label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.deal-form-main input,
.deal-form-side textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  box-sizing: border-box;
}

.deal-contact-block input {
  margin-bottom: 0.5rem;
}

.deal-contact-block input:last-of-type {
  margin-bottom: 1rem;
}

@media (max-width: 640px) {
  .deal-form-layout {
    grid-template-columns: 1fr;
  }
}

/* Карточка сделки: левая панель 20%, правая 80% — одно общее поле «Примечание / Задача» как в amoCRM */
.deal-detail-layout {
  display: grid;
  grid-template-columns: 1fr 4fr;
  gap: 1.5rem;
  align-items: stretch;
  min-height: 0;
  height: calc(100vh - 160px);
  min-height: 520px;
}

.deal-detail-layout .deal-input {
  width: 100%;
  max-width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  box-sizing: border-box;
}

.deal-detail-layout .deal-input:last-child,
.deal-contact-fields .deal-input:last-child {
  margin-bottom: 0;
}

.deal-contact-fields .deal-input {
  margin-bottom: 0.5rem;
}

.deal-detail-layout .input-select {
  width: 100%;
  max-width: 100%;
  padding: 0.55rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
}

.deal-detail-main {
  min-width: 0;
}

.deal-detail-main .case-panel-body {
  padding: 0.85rem 1rem 1rem;
}

.deal-detail-main .case-panel-head {
  padding: 0.75rem 1rem 0.5rem;
}

.deal-detail-actions {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.deal-detail-actions .btn {
  width: 100%;
  margin-top: 0 !important;
}

.btn-delete-deal-main {
  color: #ff6b78;
  border-color: rgba(232, 46, 58, 0.42);
  background: rgba(232, 46, 58, 0.09);
}

.btn-delete-deal-main:hover {
  color: #ff8892;
  border-color: rgba(232, 46, 58, 0.58);
  background: rgba(232, 46, 58, 0.14);
}

/* Правая панель (80%): одна лента активностей (примечания + задачи), внизу одно поле ввода */
.deal-detail-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.deal-activity-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  background: var(--bg-card-solid, #0a0a0a);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: visible;
  position: relative;
  z-index: 0;
}

.deal-activity-feed {
  list-style: none;
  margin: 0;
  padding: 1rem 1.25rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.deal-activity-item {
  padding: 0.85rem 1rem;
  margin-bottom: 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem 1rem;
}

.deal-activity-note {
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0;
  padding-left: 1rem;
}

.deal-note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  margin-bottom: 0.35rem;
}

.deal-note-head-left {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  min-width: 0;
}

.deal-note-del {
  flex-shrink: 0;
  margin-top: 0;
  padding: 0.45rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, transform 0.12s;
  line-height: 0;
}

.deal-note-del:hover {
  color: #e07070;
  background: rgba(220, 80, 80, 0.1);
}

.deal-note-del:active {
  transform: scale(0.94);
}

.deal-note-del-icon {
  display: block;
  opacity: 0.65;
}

.deal-note-del:hover .deal-note-del-icon {
  opacity: 1;
}

.deal-note-content {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.deal-note-content .deal-activity-body {
  width: 100%;
}

.deal-activity-type {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.deal-activity-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.deal-activity-body {
  width: 100%;
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.deal-activity-body br {
  content: "";
  display: block;
  margin-bottom: 0.35em;
}

.deal-activity-task.deal-task-card {
  padding: 0;
  background: transparent;
  border: none;
  margin-bottom: 0.75rem;
}

.deal-task-card-inner {
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(255, 90, 90, 0.07) 0%, rgba(30, 28, 32, 0.98) 38%);
  border: 1px solid rgba(255, 120, 120, 0.22);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.deal-task-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  padding: 0.55rem 0.85rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.25);
}

.deal-task-card-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ff8a8a;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgba(255, 100, 100, 0.12);
  border: 1px solid rgba(255, 130, 130, 0.25);
}

.deal-task-card-done-pill {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8fd4a8;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(100, 200, 130, 0.12);
  border: 1px solid rgba(120, 200, 150, 0.3);
}

.deal-task-card-done .deal-task-card-inner {
  background: linear-gradient(145deg, rgba(100, 180, 120, 0.06) 0%, rgba(28, 30, 32, 0.96) 40%);
  border-color: rgba(120, 200, 150, 0.18);
}

.deal-task-card-done .deal-task-card-badge {
  opacity: 0.85;
}

.deal-task-card-added {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.deal-task-card-due {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text);
  font-weight: 500;
}

.deal-task-card-due-icon {
  font-size: 0.85rem;
  opacity: 0.85;
}

.deal-task-card-time-chip {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.deal-task-card-main {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem 0.5rem;
}

.deal-task-card-check {
  flex: 1;
  min-width: 0;
  margin: 0 !important;
  cursor: pointer;
  display: flex !important;
  align-items: flex-start;
  gap: 0.65rem;
}

.deal-task-card-check input {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--accent, #c45c5c);
  cursor: pointer;
}

.deal-task-card .deal-task-title {
  font-size: 0.98rem;
  line-height: 1.4;
  color: var(--text);
  font-weight: 500;
}

.deal-task-card .deal-task-delete {
  margin: 0;
  flex-shrink: 0;
  opacity: 0.7;
}

.deal-task-card-hint {
  margin: 0;
  padding: 0 0.85rem 0.65rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
  opacity: 0.9;
}

.deal-activity-task .deal-task-row {
  flex: 1;
  min-width: 0;
  margin: 0.35rem 0 0;
}

.deal-activity-task:not(.deal-task-card) .deal-task-delete {
  margin-left: auto;
}

/* Подсказка «нет задач» над полем ввода (как в Bitrix) */
.deal-no-tasks-hint {
  flex-shrink: 0;
  padding: 0.5rem 1.25rem 0;
  position: relative;
}

.deal-no-tasks-hint.hidden {
  display: none;
}

.deal-no-tasks-hint-bubble {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  max-width: 100%;
  padding: 0.65rem 0.85rem 0.7rem;
  background: linear-gradient(180deg, #fff9e6 0%, #fff3cc 100%);
  border: 1px solid #e6d08a;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  color: #3d3d3d;
}

.deal-no-tasks-hint-bubble::after {
  content: "";
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 7px solid #e6d08a;
  filter: drop-shadow(0 1px 0 rgba(255, 249, 230, 0.9));
}

.deal-no-tasks-hint-bubble::before {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #fff3cc;
  z-index: 1;
}

.deal-no-tasks-hint-icon {
  flex-shrink: 0;
  color: #b8a050;
  margin-top: 0.05rem;
}

.deal-no-tasks-hint-icon svg {
  display: block;
  opacity: 0.95;
}

.deal-no-tasks-hint-copy {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: #333;
}

.deal-no-tasks-hint-add {
  display: inline;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: inherit;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: none;
  cursor: pointer;
  color: #1a5f9e;
}

.deal-no-tasks-hint-add:hover {
  color: #0d4a7a;
}

/* Тёмная тема: мягкий янтарный блок, читаемый на тёмном фоне */
@media (prefers-color-scheme: dark) {
  .deal-no-tasks-hint-bubble {
    background: linear-gradient(180deg, rgba(255, 236, 179, 0.22) 0%, rgba(255, 220, 140, 0.14) 100%);
    border-color: rgba(230, 208, 138, 0.55);
    color: var(--text, #e8e8e8);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  }

  .deal-no-tasks-hint-bubble::after {
    border-top-color: rgba(230, 208, 138, 0.55);
  }

  .deal-no-tasks-hint-bubble::before {
    border-top-color: rgba(45, 42, 36, 0.95);
  }

  .deal-no-tasks-hint-copy {
    color: var(--text-muted, #ccc);
  }

  .deal-no-tasks-hint-add {
    color: var(--accent, #8eb4ff);
  }

  .deal-no-tasks-hint-icon {
    color: #d4c47a;
  }
}

/* Одна строка: Примечание▾ или Задача▾ · Сегодня · дата ▾ (время/целый день) */
.deal-activity-type-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.35rem;
  padding: 0.45rem 0.65rem;
  margin-bottom: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
  font-size: 0.9rem;
  line-height: 1.4;
  min-height: 2.5rem;
}

/* Блок даты в той же строке, что и «Задача» — без второй «полосы» */
.deal-task-when-bar {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.1rem 0.25rem;
  padding: 0;
  margin: 0;
  margin-left: 0.1rem;
  background: none;
  border: none;
  font-size: inherit;
  line-height: inherit;
  flex: 1 1 auto;
  min-width: 0;
}

.deal-task-when-bar.hidden {
  display: none;
}

.deal-activity-type-row:has(.deal-task-when-bar:not(.hidden)) {
  gap: 0.2rem 0.4rem;
}

.deal-task-when-prefix {
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.deal-task-when-sep {
  color: var(--text-muted);
  opacity: 0.45;
  margin: 0 0.05rem;
  user-select: none;
  font-weight: 300;
}

.deal-task-when-sep-lead {
  margin-left: 0;
  margin-right: 0.15rem;
  font-size: 1.1rem;
  line-height: 1;
}

.deal-task-when-picker-wrap {
  position: relative;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  z-index: 100;
  min-width: 0;
}

/* Компактная «текстовая» кнопка даты — не отдельное тяжёлое поле */
.deal-task-when-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0.15rem 0.1rem 0;
  margin: 0;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--accent);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: none;
}

.deal-task-when-btn:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.deal-task-when-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.deal-task-when-caret {
  opacity: 0.85;
  font-size: 0.75em;
  margin-left: 0.05rem;
}

.deal-task-when-btn-dot.hidden {
  display: none;
}

.deal-task-when-paren {
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.deal-task-when-popover {
  position: fixed;
  z-index: 9999;
  min-width: 280px;
  max-width: calc(100vw - 24px);
  max-height: min(70vh, 380px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0.85rem;
  background: var(--bg-card-solid, #111);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}

.deal-task-when-popover.hidden {
  display: none;
}

.deal-task-when-pop-hint {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.deal-task-when-quick {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.deal-task-when-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.deal-task-when-input {
  padding: 0.4rem 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
}

.deal-task-when-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  position: relative;
  user-select: none;
}

.deal-task-when-check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.deal-task-when-check::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.deal-task-when-check span {
  padding-left: 0.2rem;
}

.deal-task-when-check input[type="checkbox"]:checked + span::before {
  /* nothing here; kept for compatibility if markup changes */
}

.deal-task-when-check input[type="checkbox"]:checked ~ * ,
.deal-task-when-check input[type="checkbox"]:focus-visible ~ * {
  /* highlight label text when checked/focused */
  color: #fff;
}

.deal-task-when-check input[type="checkbox"]:checked ~ ._dummy {
  /* placeholder, no-op */
}

.deal-task-when-check input[type="checkbox"]:checked ~ span,
.deal-task-when-check input[type="checkbox"]:focus-visible ~ span {
  text-shadow: 0 0 6px rgba(232, 46, 58, 0.6);
}

.deal-task-when-check input[type="checkbox"]:checked + span,
.deal-task-when-check input[type="checkbox"]:checked ~ span {
  /* keep text brighter when checked */
  color: #fff;
}

.deal-task-when-check input[type="checkbox"]:checked ~ .deal-task-when-check-icon,
.deal-task-when-check input[type="checkbox"]:focus-visible ~ .deal-task-when-check-icon {
  outline: none;
}

.deal-task-when-check input[type="checkbox"]:checked ~ * ._inner {
  /* no-op safeguard */
}

.deal-task-when-check input[type="checkbox"]:checked + span,
.deal-task-when-check input[type="checkbox"]:focus-visible + span {
  color: #fff;
}

.deal-task-when-check:hover::before {
  border-color: var(--border-accent);
}

.deal-task-when-check input[type="checkbox"]:checked ~ .deal-task-when-check-tick,
.deal-task-when-check input[type="checkbox"]:checked ~ span::after {
  /* draw tick using ::after on label box */
}

.deal-task-when-check input[type="checkbox"]:checked ~ * ,
.deal-task-when-check input[type="checkbox"]:focus-visible ~ * {
  /* keep selectors, visual handled by ::before / ::after below */
}

.deal-task-when-check input[type="checkbox"]:checked ~ ._ignored {
}

.deal-task-when-check input[type="checkbox"]:checked ~ ._ignored2 {
}

.deal-task-when-check input[type="checkbox"]:checked ~ ._ignored3 {
}

.deal-task-when-check input[type="checkbox"]:checked ~ ._ignored4 {
}

.deal-task-when-check input[type="checkbox"]:checked ~ ._ignored5 {
}

.deal-task-when-check input[type="checkbox"]:checked ~ ._ignored6 {
}

.deal-task-when-check:has(input[type="checkbox"]:checked)::before {
  background: var(--accent-soft);
  border-color: var(--border-accent);
  box-shadow: 0 0 0 1px rgba(232, 46, 58, 0.55);
}

.deal-task-when-check:has(input[type="checkbox"]:checked)::after {
  content: "✓";
  position: absolute;
  left: 3px;
  top: 0;
  font-size: 0.8rem;
  color: #fff;
  pointer-events: none;
}

.deal-task-when-cal-hint {
  margin: 0.5rem 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.deal-task-when-time-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.deal-task-when-time-wrap.deal-task-when-time-muted {
  opacity: 0.72;
}

.deal-task-when-time-wrap.deal-task-when-time-muted .deal-task-when-time-label::after {
  content: " (не используется при «целый день»)";
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.deal-task-when-done {
  width: 100%;
  margin-top: 0.25rem;
}

.deal-activity-textarea-task {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-top: 0;
  min-height: 72px;
}

.deal-task-meta-line {
  width: 100%;
  flex-basis: 100%;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  padding: 0.35rem 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  line-height: 1.4;
}

.deal-task-meta-strong {
  font-weight: 600;
  color: var(--accent);
}

.deal-task-meta-sep {
  margin: 0 0.25rem;
  opacity: 0.7;
}

.deal-task-meta-when,
.deal-task-meta-tail {
  color: var(--text);
}

.deal-activity-input-wrap {
  flex-shrink: 0;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  position: relative;
}

/* Редактор как в CRM: одно поле, сверху слева плейсхолдер «Примечание: введите текст» */
.deal-activity-editor-box {
  position: relative;
  margin-bottom: 0.75rem;
}

.deal-activity-ph-line {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0;
  pointer-events: none;
  z-index: 2;
  line-height: 1.45;
  user-select: none;
}

.deal-activity-ph-line.hidden {
  display: none;
}

.deal-activity-ph-suffix {
  font-size: 0.95rem;
  color: var(--text-muted);
  pointer-events: none;
}

.deal-activity-type-select {
  position: relative;
  display: inline-block;
  pointer-events: auto;
  margin-right: 0;
  vertical-align: baseline;
}

.deal-activity-type-on-line {
  position: relative;
  z-index: 3;
}

.deal-activity-type-current {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent, #6b9fff);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

/* Подчёркивание только у слова, не у стрелки ▾ */
.deal-activity-ph-type-btn {
  text-decoration: none;
}

.deal-activity-ph-type-btn #deal-activity-type-current-label {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.deal-activity-type-caret {
  font-size: 1.15rem;
  line-height: 1;
  opacity: 0.95;
  text-decoration: none !important;
  display: inline-block;
  vertical-align: -0.12em;
  margin-left: 0.08rem;
}

.deal-activity-type-menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  min-width: 140px;
  padding: 0.25rem 0;
  background: var(--bg-card-solid, #0a0a0a);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.deal-activity-send-type {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.deal-activity-send-type:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.deal-activity-send-type.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.deal-activity-textarea {
  width: 100%;
  min-height: 72px;
  padding: 1rem 1rem 1rem;
  margin-bottom: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.45;
  resize: vertical;
  box-sizing: border-box;
  text-align: left;
  vertical-align: top;
  display: block;
}

/* Компактная высота по умолчанию; ширина на всю колонку */
.deal-activity-editor-box .deal-activity-textarea {
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
  min-height: 72px;
}

.deal-activity-textarea:focus {
  outline: none;
  border-color: var(--border-accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.deal-activity-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.9;
}

.deal-notes-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  background: var(--bg-card-solid, #0a0a0a);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.deal-notes-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.deal-notes-tab {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.deal-notes-tab:hover {
  color: var(--text);
}

.deal-notes-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.deal-notes-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1.25rem 1.5rem;
  overflow: hidden;
}

.deal-tab-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.deal-tab-pane.hidden {
  display: none;
}

.deal-notes-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

/* Большое поле: примечание и задачи в одном объёмном блоке, как на скрине */
.deal-notes-textarea {
  width: 100%;
  flex: 1;
  min-height: 320px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
}

.deal-notes-textarea:focus {
  outline: none;
  border-color: var(--border-accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.deal-tab-note .btn {
  align-self: flex-start;
}

.deal-task-input {
  flex: 0 0 auto;
  min-height: 120px;
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  font-size: 0.95rem;
}

#deal-task-submit {
  margin-bottom: 1.25rem;
}

.deal-tasks-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 180px;
}

.deal-task-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.35rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.deal-task-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.deal-task-check {
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.deal-task-title {
  font-size: 0.9rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.deal-task-title.completed {
  text-decoration: line-through;
  color: var(--text-muted);
}

.deal-task-due {
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.deal-task-delete {
  flex-shrink: 0;
  padding: 0.25rem 0.4rem;
  color: var(--text-muted);
}

.deal-task-delete:hover {
  color: var(--text);
}

@media (max-width: 768px) {
  .deal-detail-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 400px;
  }

  .deal-detail-side {
    min-height: 380px;
  }
}

/* ---------- Mobile pass: deals, tasks, calendar, employees ---------- */
@media (max-width: 900px) {
  #page-deals .toolbar-actions,
  #page-tasks .toolbar-actions,
  #page-calendar .toolbar-actions,
  #page-employees .toolbar-actions {
    width: 100%;
  }

  #page-deals .toolbar-actions .btn,
  #page-tasks .toolbar-actions .btn,
  #page-calendar .toolbar-actions .btn,
  #page-employees .toolbar-actions .btn {
    min-height: 42px;
  }

  .cases-kanban {
    padding-top: 0.55rem;
    gap: 0.55rem;
    scroll-snap-type: x mandatory;
    min-height: 320px;
  }

  .kanban-column {
    flex: 0 0 min(86vw, 320px);
    min-width: min(86vw, 320px);
    max-height: none;
    scroll-snap-align: start;
  }

  .kanban-column-cards {
    max-height: 58vh;
  }

  .tasks-toolbar {
    gap: 0.55rem;
  }

  .tasks-board {
    gap: 0.55rem;
    scroll-snap-type: x mandatory;
    padding-bottom: 6px;
  }

  .tasks-col {
    flex: 0 0 min(86vw, 320px);
    min-width: min(86vw, 320px);
    max-width: min(86vw, 320px);
    max-height: none;
    scroll-snap-align: start;
  }

  .tasks-col-body {
    max-height: 58vh;
  }

  .calendar-toolbar-left {
    width: 100%;
    gap: 0.45rem;
  }

  .calendar-nav-month,
  .calendar-nav-week,
  .calendar-nav-day {
    width: 100%;
    justify-content: space-between;
  }

  .calendar-view-switch {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .calendar-view-switch .btn {
    width: 100%;
    min-height: 40px;
  }

  .calendar-wrap {
    gap: 0.85rem;
  }

  .calendar-sidebar {
    padding: 0.85rem;
  }

  .calendar-event-item {
    padding: 0.65rem 0;
    gap: 0.35rem;
  }

  .calendar-event-actions {
    width: 100%;
  }

  .calendar-event-actions .btn {
    flex: 1;
    min-height: 38px;
  }

  .employee-create-card,
  .employee-positions-admin,
  .employee-list-panel {
    min-height: 0;
  }

  .employee-cards-list {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .calendar-timeline {
    grid-template-columns: 44px 1fr;
  }

  .calendar-timeline-day.calendar-timeline {
    grid-template-columns: 44px 1fr;
  }

  .calendar-timeline-days {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }

  .calendar-timeline-day-col:not(:first-child) {
    display: none;
  }

  .calendar-timeline-day-header {
    font-size: 0.72rem;
    height: 30px;
  }

  .calendar-event-popup {
    padding: 0.75rem;
    align-items: flex-end;
  }

  .calendar-event-popup-card {
    max-width: 100%;
    border-radius: 14px;
  }
}

@media (max-width: 420px) {
  .cases-kanban {
    gap: 0.45rem;
    padding-top: 0.45rem;
  }

  .kanban-column {
    flex: 0 0 calc(100vw - 1.4rem);
    min-width: calc(100vw - 1.4rem);
    padding: 0.55rem;
    border-radius: 11px;
  }

  .kanban-column-head {
    margin-bottom: 0.5rem;
    padding-bottom: 0.45rem;
  }

  .kanban-column-title {
    font-size: 0.8rem;
  }

  .kanban-column-stats {
    font-size: 0.68rem;
  }

  .kanban-card {
    padding: 0.62rem;
  }

  .kanban-card-title {
    font-size: 0.8rem;
  }

  .kanban-card-meta,
  .kanban-card-amount {
    font-size: 0.72rem;
  }

  .tasks-col {
    flex: 0 0 calc(100vw - 1.4rem);
    min-width: calc(100vw - 1.4rem);
    max-width: calc(100vw - 1.4rem);
  }

  .tasks-col-head {
    padding: 10px 11px;
  }

  .tasks-col-title {
    font-size: 0.68rem;
  }

  .tasks-card {
    padding: 10px;
    gap: 5px;
  }

  .tasks-card-title {
    font-size: 0.82rem;
  }

  .tasks-card-deal,
  .tasks-card-due {
    font-size: 0.69rem;
  }

  .calendar-toolbar-left {
    gap: 0.35rem;
  }

  .calendar-week-range {
    min-width: 0;
    font-size: 0.9rem;
    text-align: center;
    width: 100%;
  }

  .calendar-nav-month .btn,
  .calendar-nav-week .btn,
  .calendar-nav-day .btn {
    min-width: 34px;
    min-height: 34px;
    padding: 0.35rem 0.5rem;
  }

  .calendar-timeline {
    grid-template-columns: 38px 1fr;
  }

  .calendar-timeline-day.calendar-timeline {
    grid-template-columns: 38px 1fr;
  }

  .calendar-timeline-slot {
    padding: 0 0.2rem;
    font-size: 0.62rem;
  }

  .calendar-day-allday-strip {
    padding: 4px 2px;
    gap: 3px;
  }

  .calendar-allday-chip {
    min-height: 24px;
    max-height: 24px;
    font-size: 0.64rem;
    padding: 3px 6px;
  }

  .calendar-timeline-day-body {
    height: 620px;
    min-height: 620px;
  }

  .calendar-event-block {
    left: 2px;
    right: 2px;
    min-height: 44px;
    padding: 5px 6px 6px;
    border-left-width: 2px;
  }

  .calendar-event-block .calendar-event-meta {
    font-size: 0.58rem;
    margin-bottom: 2px;
  }

  .calendar-event-block .calendar-event-title {
    font-size: 0.66rem;
  }

  .calendar-sidebar {
    padding: 0.72rem;
  }

  .calendar-day-title {
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
  }
}

/* Модалка «Добавить участников»: поиск + список с чекбоксами */
.modal-add-participants .input-search {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
}

.modal-add-participants .input-search::placeholder {
  color: var(--text-muted);
}

.modal-add-participants .input-search:focus {
  outline: none;
  border-color: var(--border-accent);
}

.participants-list-wrap {
  max-height: 280px;
  overflow-y: auto;
  margin: 0.75rem 0;
  padding: 0.25rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
}

.participants-list-wrap::-webkit-scrollbar {
  width: 8px;
}

.participants-list-wrap::-webkit-scrollbar-track {
  background: var(--bg-input);
  border-radius: 4px;
}

.participants-list-wrap::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.participants-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
}

.participants-list .participant-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  transition: background 0.15s ease;
  border-radius: 4px;
  min-height: 2.5rem;
  box-sizing: border-box;
}

.participants-list .participant-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.participants-list .participant-item.hidden-by-search {
  display: none !important;
}

.participants-list .participant-item input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.participants-list .participant-item .label-text {
  flex: 1;
  font-size: 0.95rem;
  color: var(--text);
  min-width: 0;
}

.participants-list .participant-item .label-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.modal-actions .selected-count {
  margin-right: auto;
  font-size: 0.9rem;
  color: var(--text-muted);
  align-self: center;
}
