/* "Industry" Design System
   Blueprint/wireframe visual language — steel-blue accent, square corners,
   Barlow Condensed (headings) + Barlow (body). Token values below are the
   single swap point: every rule in this file references these variables
   (not literal colors/radii), so retargeting the palette/type/radius here
   re-skins the whole app without touching per-page CSS. Corner-cross decor
   (`--corner-mark`, baked into .card/.project-card/.stage-card/.modal/
   .btn-primary/.btn-secondary) and square avatars (`.avatar-square`) are
   now part of the shared component styles below — see the "Blueprint
   corner marks" and "Avatar (square)" sections. */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=Barlow:wght@400;500;600&display=swap');

/* ─── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  /* System Colors — accent is Industry's steel-blue, rest kept for badges/status */
  --blue:       #5980A6;
  --blue-dark:  #3F6483;
  --blue-light: #DDE6EC;
  --green:      #34C759;
  --red:        #FF3B30;
  --orange:     #FF9500;
  --yellow:     #FFCC00;
  --purple:     #AF52DE;
  --teal:       #5AC8FA;
  --indigo:     #5856D6;
  --pink:       #FF2D55;
  --mint:       #00C7BE;

  /* Accent tonal ramp (Industry — approximated from OKLCH ramp as sRGB) */
  --accent-100: #E4EBF0;
  --accent-300: #B7C9D6;
  --accent-500: #5980A6;
  --accent-700: #3F6483;
  --accent-800: #33526C;
  --accent-900: #263D51;

  /* Neutral tonal ramp */
  --neutral-100: #EDEDEE;
  --neutral-600: #6B6E70;
  --neutral-900: #1D1F20;

  /* Backgrounds (light mode) */
  --bg-primary:     #F2F2F3;   /* --color-bg */
  --bg-secondary:   #FFFFFF;   /* card / elevated surface */
  --bg-tertiary:    var(--neutral-100);
  --bg-sidebar:     #F7F7F8;
  --bg-nav:         rgba(247,247,248,0.92);
  --bg-glass:       rgba(255,255,255,0.75);
  --bg-modal:       rgba(29,31,32,0.45);
  --bg-input:       #FFFFFF;
  --bg-hover:       rgba(29,31,32,0.04);
  --bg-active:      var(--accent-100);
  --bg-tag:         var(--accent-100);

  /* Text */
  --tx-primary:     #1D1F20;
  --tx-secondary:   #3C3F41;
  --tx-tertiary:    var(--neutral-600);
  --tx-placeholder: #9B9DA0;
  --tx-on-accent:   #FFFFFF;
  --tx-link:        var(--blue);

  /* Borders — hairline, Industry favors visible thin borders over shadows */
  --brd:            rgba(29,31,32,0.16);
  --brd-strong:     rgba(29,31,32,0.28);
  --brd-focus:      var(--blue);

  /* Shadows — kept subtle; Industry relies mostly on borders, not elevation */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.06);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:  0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg:  0 4px 16px rgba(0,0,0,0.10);
  --shadow-xl:  0 12px 40px rgba(0,0,0,0.14);

  /* Radii — square corners are a deliberate Industry trait, not rounded */
  --r-xs:  2px;
  --r-sm:  2px;
  --r-md:  4px;
  --r-lg:  4px;
  --r-xl:  4px;
  --r-2xl: 4px;
  --r-full: 4px;

  /* Spacing (8pt grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Sidebar */
  --sidebar-w: 232px;
  --nav-h: 52px;

  /* Typography */
  --font: 'Barlow', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Barlow Condensed', var(--font);
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;

  /* Transitions */
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 350ms;

  /* Blueprint corner-cross mark — a small "+" tick, steel-blue, used as a
     repeating background image at all four corners of key surfaces (see
     "Blueprint corner marks" section below). One asset works for all four
     corners since a "+" is rotation-symmetric. */
  --corner-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='7'%3E%3Cpath d='M3.5 0v7M0 3.5h7' stroke='%235980A6' stroke-width='1'/%3E%3C/svg%3E");
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--tx-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
button { cursor: pointer; font-family: var(--font); }
a { color: var(--tx-link); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(0,122,255,0.2); }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ─── Blueprint corner marks (Industry) ──────────────────────────────────── */
/* A small steel-blue "+" tick inset 4px from each corner — the wireframe/
   blueprint accent that identifies key surfaces across the app. Baked
   directly into these shared component selectors (rather than a separate
   opt-in class) so the whole app picks it up consistently. */
.card,
.project-card,
.stage-card,
.modal,
.dialog,
.grouped-list,
.filters-panel,
.form-section,
.btn-primary,
.btn-secondary {
  position: relative;
  background-image: var(--corner-mark), var(--corner-mark), var(--corner-mark), var(--corner-mark);
  background-repeat: no-repeat;
  background-size: 7px 7px;
  background-position:
    4px 4px,
    calc(100% - 11px) 4px,
    4px calc(100% - 11px),
    calc(100% - 11px) calc(100% - 11px);
}

/* ─── Avatar (square) ─────────────────────────────────────────────────────── */
.avatar-square {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--tx-on-accent);
  background: var(--accent-800);
}
.avatar-square.lg { width: 44px; height: 44px; font-size: 16px; }
.avatar-square.md { width: 36px; height: 36px; font-size: 14px; }
.avatar-square.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-square.neutral { background: var(--neutral-600); }

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--brd);
  overflow: hidden;
  z-index: 100;
}

.sidebar-header {
  padding: var(--sp-5) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--brd);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 18px;
  color: var(--tx-primary);
}

.sidebar-logo .logo-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2) 0;
  scrollbar-width: thin;
}

.nav-section { margin-bottom: var(--sp-2); }

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tx-tertiary);
  padding: var(--sp-2) var(--sp-4) var(--sp-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 9px var(--sp-4);
  margin: 1px var(--sp-2);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--tx-secondary);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  user-select: none;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--tx-primary);
  text-decoration: none;
}

.nav-item.active {
  background: var(--bg-active);
  color: var(--blue);
  font-weight: 600;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--blue);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--r-full);
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--brd);
  flex-shrink: 0;
}

/* ─── Main Area ──────────────────────────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Top Nav Bar ────────────────────────────────────────────────────────── */
.topbar {
  height: var(--nav-h);
  min-height: var(--nav-h);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
  background: var(--bg-nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--brd);
  z-index: 90;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--tx-primary);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: 13px;
  color: var(--tx-tertiary);
}

.breadcrumb-item { color: var(--tx-tertiary); cursor: pointer; }
.breadcrumb-item:hover { color: var(--blue); }
.breadcrumb-item.active { color: var(--tx-primary); font-weight: 500; cursor: default; }
.breadcrumb-sep { color: var(--tx-placeholder); }

/* Back-link at the top of the shared project header (projectHeaderHtml) */
.project-back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--tx-tertiary);
  cursor: pointer;
  margin-bottom: var(--sp-3);
  transition: color 150ms ease;
}
.project-back-link:hover { color: var(--blue); text-decoration: underline; }

/* In-content project tabs — underline style, shown on desktop too (not just
   .bx-embed/narrow) once a project is open; sidebar keeps the pill-style nav
   for the same routes, the two are intentionally redundant navigation. */
.topbar-tabstrip {
  display: flex;
  gap: var(--sp-5);
  padding: 0 var(--sp-6);
  border-bottom: 1px solid var(--brd);
  overflow-x: auto;
  white-space: nowrap;
  flex-shrink: 0;
}
.topbar-tabstrip.hidden { display: none !important; }
.topbar-tabstrip .nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--sp-3) 0;
  margin: 0;
  border-radius: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--tx-tertiary);
  background: transparent;
  border-bottom: 2px solid transparent;
  flex-shrink: 0;
  transition: color 150ms ease, border-color 150ms ease;
}
.topbar-tabstrip .nav-item:hover { background: transparent; color: var(--tx-primary); }
.topbar-tabstrip .nav-item.active { background: transparent; color: var(--blue); font-weight: 600; border-bottom-color: var(--blue); }

/* ─── Page Content ───────────────────────────────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
  scrollbar-width: thin;
}

.page-header {
  margin-bottom: var(--sp-6);
}

.page-title {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--tx-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 15px;
  color: var(--tx-tertiary);
  margin-top: var(--sp-1);
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: 9px var(--sp-4);
  border-radius: var(--r-sm);
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  user-select: none;
  white-space: nowrap;
  line-height: 1;
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--blue);
  color: white;
  box-shadow: 0 1px 2px rgba(89,128,166,0.3);
}
.btn-primary:hover { background: var(--blue-dark); box-shadow: 0 2px 8px rgba(89,128,166,0.35); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--blue);
  border: 1px solid var(--brd);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--blue); }

.btn-ghost {
  background: transparent;
  color: var(--tx-secondary);
  border: none;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--tx-primary); }

.btn-danger {
  background: var(--red);
  color: white;
}
.btn-danger:hover { background: #CC2E25; }

.btn-success {
  background: var(--green);
  color: white;
}

.btn-sm { padding: 6px var(--sp-3); font-size: 13px; }
.btn-lg { padding: 12px var(--sp-5); font-size: 15px; }
.btn-xl { padding: 14px var(--sp-6); font-size: 16px; border-radius: var(--r-md); }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-sm);
}
.btn-icon.btn-sm { width: 28px; height: 28px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-secondary);
  border-radius: var(--r-lg);
  border: 1px solid var(--brd);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--brd);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--tx-primary);
}

.card-body {
  padding: var(--sp-5);
}

.card-footer {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--brd);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* Project Card — lean by design: no avatar, no stat-chip row. Name, client,
   status/industry tags, updated date. Anything more is the "visual noise"
   this was explicitly trimmed to remove (see ТЗ v6 projects-list rework). */
.project-card {
  background: var(--bg-secondary);
  border-radius: var(--r-lg);
  border: 1px solid var(--brd);
  padding: var(--sp-4);
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.project-card:hover {
  border-color: var(--blue);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.project-card-name {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--tx-primary);
  line-height: 1.3;
}

.project-card-client {
  font-size: 13px;
  color: var(--tx-tertiary);
  margin-top: 2px;
}

.project-card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.project-card-meta {
  font-size: 11px;
  color: var(--tx-placeholder);
  margin-top: 2px;
}

/* ─── Grid ───────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-5); }

/* ─── Generic Table (list view) ──────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; background: var(--bg-secondary); border: 1px solid var(--brd); border-radius: var(--r-lg); overflow: hidden; }
.table th, .table td { padding: var(--sp-3) var(--sp-4); text-align: left; border-bottom: 1px solid var(--brd); font-size: 13px; }
.table th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--tx-secondary); background: var(--bg-tertiary); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr[data-clickable] { cursor: pointer; }
.table tbody tr[data-clickable]:hover { background: var(--bg-hover); }

/* ─── Filters bar (projects list, reusable pattern) ──────────────────────── */
.filters-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.filters-search { position: relative; flex: 1; min-width: 220px; max-width: 320px; }
.filters-panel { display: none; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-3); background: var(--bg-secondary); border: 1px solid var(--brd); border-radius: var(--r-lg); padding: var(--sp-4); margin-bottom: var(--sp-4); }
.filters-panel.open { display: grid; }

/* ─── Projects Kanban (stages synced from Bitrix "Проекты" SP) ───────────── */
.projects-kanban-col-title { display: flex; justify-content: space-between; }

/* ─── Form Elements ──────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--tx-secondary);
  letter-spacing: 0.01em;
}

.form-label .required { color: var(--red); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px var(--sp-3);
  border: 1.5px solid var(--brd);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--tx-primary);
  background: var(--bg-input);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  outline: none;
  line-height: 1.5;
}

.form-control::placeholder { color: var(--tx-placeholder); }

.form-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(89,128,166,0.15);
}

.form-control:disabled { background: var(--bg-tertiary); opacity: 0.6; cursor: not-allowed; }

textarea.form-control { resize: vertical; min-height: 80px; }

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B6B73' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-hint {
  font-size: 12px;
  color: var(--tx-tertiary);
  margin-top: 2px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  cursor: pointer;
  font-size: 15px;
  color: var(--tx-primary);
  border-bottom: 1px solid var(--brd);
  user-select: none;
}
.checkbox-row:last-of-type { border-bottom: none; }
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
  cursor: pointer;
  flex-shrink: 0;
}

.form-error {
  font-size: 12px;
  color: var(--red);
  margin-top: 2px;
}

/* Toggle / Switch (UIKit style) */
.toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

.toggle-label { font-size: 14px; color: var(--tx-primary); }

.toggle {
  position: relative;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: var(--r-full);
  background: #E9E9EA;
  transition: background var(--dur-base) var(--ease);
  cursor: pointer;
}

.toggle input:checked ~ .toggle-track { background: var(--green); }

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.1);
  transition: transform var(--dur-base) var(--ease-spring);
  pointer-events: none;
}

.toggle input:checked ~ .toggle-track .toggle-thumb { transform: translateX(20px); }

/* Segmented Control (iOS style) */
.segmented {
  display: inline-flex;
  background: var(--bg-tertiary);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
}

.segmented-item {
  padding: 6px var(--sp-3);
  border-radius: calc(var(--r-sm) - 2px);
  font-size: 13px;
  font-weight: 500;
  color: var(--tx-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
}

.segmented-item:hover { color: var(--tx-primary); }

.segmented-item.active {
  background: var(--bg-secondary);
  color: var(--tx-primary);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* ─── Grouped List (iOS Settings style) ──────────────────────────────────── */
.grouped-list {
  background: var(--bg-secondary);
  border-radius: var(--r-lg);
  border: 1px solid var(--brd);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.grouped-list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 12px var(--sp-4);
  border-bottom: 1px solid var(--brd);
  transition: background var(--dur-fast) var(--ease);
  cursor: pointer;
}

.grouped-list-item:last-child { border-bottom: none; }
.grouped-list-item:hover { background: var(--bg-hover); }

.grouped-list-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.grouped-list-label {
  flex: 1;
  font-size: 15px;
  color: var(--tx-primary);
}

.grouped-list-value {
  font-size: 14px;
  color: var(--tx-tertiary);
}

.grouped-list-chevron {
  color: var(--tx-placeholder);
  font-size: 12px;
}

/* ─── Tags / Chips ───────────────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px var(--sp-2);
  border-radius: var(--r-xs);
  font-size: 12px;
  font-weight: 500;
}

.tag-blue   { background: #E3F2FD; color: #1565C0; }
.tag-green  { background: #E8F5E9; color: #2E7D32; }
.tag-orange { background: #FFF3E0; color: #E65100; }
.tag-red    { background: #FFEBEE; color: #C62828; }
.tag-purple { background: #F3E5F5; color: #6A1B9A; }
.tag-gray   { background: var(--bg-tertiary); color: var(--tx-secondary); }

/* Industry-accent tag variants, used for project/document status pills */
.tag-accent  { background: var(--accent-100); color: var(--accent-800); }
.tag-neutral { background: var(--bg-tertiary); color: var(--tx-secondary); }
.tag-outline { background: transparent; color: var(--tx-secondary); border: 1px solid var(--brd-strong); }

/* Status badge */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.active   { background: var(--green); }
.status-dot.draft    { background: var(--orange); }
.status-dot.archived { background: var(--tx-placeholder); }
.status-dot.final    { background: var(--blue); }

/* ─── Modal / Sheet ──────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-modal);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  backdrop-filter: blur(4px);
  animation: fadeIn var(--dur-base) var(--ease);
}

.modal {
  background: var(--bg-secondary);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp var(--dur-slow) var(--ease-spring);
}

.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }
.modal-full { max-width: calc(100vw - 80px); max-height: calc(100dvh - 60px); }

.modal-header {
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--brd);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 19px;
  font-weight: 600;
  color: var(--tx-primary);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
}

.modal-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--brd);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

/* Bottom Sheet */
.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-xl);
  z-index: 1001;
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUpSheet var(--dur-slow) var(--ease-spring);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--brd-strong);
  border-radius: 2px;
  margin: var(--sp-3) auto;
}

/* ─── Tabs ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--brd);
  padding: 0 var(--sp-6);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab-item {
  padding: var(--sp-3) var(--sp-4);
  font-size: 14px;
  font-weight: 500;
  color: var(--tx-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  white-space: nowrap;
  user-select: none;
}

.tab-item:hover { color: var(--tx-primary); }

.tab-item.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 600;
}

/* ─── Section Headers ────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--tx-primary);
  letter-spacing: -0.3px;
}

.section-subtitle {
  font-size: 13px;
  color: var(--tx-tertiary);
  margin-top: 2px;
}

/* ─── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
  gap: var(--sp-3);
}

.empty-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--tx-secondary);
}

.empty-desc {
  font-size: 14px;
  color: var(--tx-tertiary);
  max-width: 300px;
}

/* ─── Loading States ─────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, rgba(200,200,200,0.3) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}

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

.spinner-lg {
  width: 40px;
  height: 40px;
  border: 3px solid var(--brd);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: var(--sp-8) auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Notifications ──────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  background: rgba(30,30,32,0.92);
  backdrop-filter: blur(20px);
  color: white;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn var(--dur-slow) var(--ease-spring);
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  max-width: 360px;
}

.toast.success { background: rgba(52,199,89,0.92); }
.toast.error   { background: rgba(255,59,48,0.92); }
.toast.warning { background: rgba(255,149,0,0.92); }

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

/* ─── Progress Bar ───────────────────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--blue);
  border-radius: var(--r-full);
  transition: width var(--dur-slow) var(--ease);
}

/* ─── Divider ────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--brd);
  margin: var(--sp-4) 0;
}

/* ─── Popover / Dropdown ─────────────────────────────────────────────────── */
.popover {
  position: absolute;
  background: var(--bg-secondary);
  border: 1px solid var(--brd);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  overflow: hidden;
  animation: popIn var(--dur-base) var(--ease-spring);
  min-width: 180px;
}

.popover-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-4);
  font-size: 14px;
  color: var(--tx-primary);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}

.popover-item:hover { background: var(--bg-hover); }
.popover-item.danger { color: var(--red); }

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ─── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ─── Funnel Editor Layout ───────────────────────────────────────────────── */
.funnel-editor-layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 520px;
  border-top: 1px solid var(--brd);
}

.funnel-stage-sidebar {
  border-right: 1px solid var(--brd);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 72vh;
}

.funnel-sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-1) 0 var(--sp-2);
  color: var(--tx-secondary);
}

.funnel-stage-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-2);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
  position: relative;
  user-select: none;
}
.funnel-stage-item:hover {
  background: var(--bg-secondary);
}
.funnel-stage-item.active {
  background: var(--bg-active);
}
.funnel-stage-item.drag-over {
  background: var(--blue-light);
  border: 2px dashed var(--blue);
}
.funnel-stage-item.dragging {
  opacity: 0.4;
}

/* Funnel list drag */
.drag-handle {
  font-size: 14px; color: var(--tx-placeholder); cursor: grab;
  padding: 0 var(--sp-1); flex-shrink: 0; user-select: none;
  opacity: 0; transition: opacity .15s;
}
.grouped-list-item:hover .drag-handle { opacity: 1; }
.grouped-list-item[data-flist-idx].drag-over {
  background: var(--blue-light);
  border: 1px dashed var(--blue);
  border-radius: var(--r-md);
}
.grouped-list-item[data-flist-idx].dragging { opacity: 0.4; }

.funnel-stage-item:hover .funnel-stage-del { opacity: 1; }

.funnel-stage-grip {
  font-size: 14px;
  color: var(--tx-tertiary);
  cursor: grab;
  opacity: 0;
  transition: opacity var(--dur-fast);
}
.funnel-stage-item:hover .funnel-stage-grip { opacity: 1; }

.funnel-stage-bar {
  width: 4px;
  height: 32px;
  border-radius: 2px;
  flex-shrink: 0;
}

.funnel-stage-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--tx-tertiary);
  width: 18px;
  text-align: right;
  flex-shrink: 0;
}

.funnel-stage-info {
  flex: 1;
  min-width: 0;
}

.funnel-stage-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--tx-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.funnel-stage-group {
  font-size: 11px;
  font-weight: 500;
  margin-top: 1px;
}

.funnel-stage-del {
  opacity: 0;
  width: 20px;
  height: 20px;
  font-size: 11px;
  color: var(--tx-tertiary);
  transition: opacity var(--dur-fast);
}

.funnel-add-btn {
  display: block;
  width: 100%;
  padding: var(--sp-2) 0;
  font-size: 13px;
  color: var(--blue);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  border-radius: var(--r-md);
  transition: background var(--dur-fast);
}
.funnel-add-btn:hover { background: var(--bg-secondary); }

/* ─── Stage form (right panel) ───────────────────────────────────────────── */
.funnel-stage-form-panel {
  overflow-y: auto;
  max-height: 72vh;
}

.stage-form-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  position: sticky;
  top: 0;
  z-index: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.stage-form-body {
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* Color swatches */
.stage-swatches {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.stage-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color var(--dur-fast), transform var(--dur-fast);
}
.stage-swatch:hover   { transform: scale(1.15); }
.stage-swatch.selected { border-color: var(--tx-primary); }

/* Group chips */
.stage-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.stage-group-chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--brd);
  color: var(--tx-secondary);
  background: var(--bg-secondary);
  transition: all var(--dur-fast);
  user-select: none;
}
.stage-group-chip:hover { border-color: var(--blue); color: var(--blue); }
.stage-group-chip.selected {
  background: var(--blue-light);
  border-color: var(--blue);
  color: var(--blue);
}

/* Dynamic list rows */
.sf-list-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.sf-robot-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.sf-del-btn {
  width: 24px;
  height: 24px;
  font-size: 11px;
  color: var(--tx-tertiary);
  flex-shrink: 0;
}
.sf-del-btn:hover { color: var(--red); }

.sf-add-btn {
  display: inline-block;
  font-size: 13px;
  color: var(--blue);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 0;
}
.sf-add-btn:hover { text-decoration: underline; }

/* ─── Funnel switcher (horizontal, replaces the old vertical funnel list) ─── */
.funnel-switcher { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.funnel-switch-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--tx-secondary);
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.funnel-switch-item:hover { background: var(--bg-hover); color: var(--tx-primary); }
.funnel-switch-item.active { background: var(--blue); color: #fff; font-weight: 600; }
.funnel-switch-item.dragging { opacity: .5; }
.funnel-switch-item.drag-over { box-shadow: inset 2px 0 0 var(--blue-dark); }

.funnel-switch-del {
  opacity: .5;
  font-size: 12px;
  line-height: 1;
}
.funnel-switch-item:hover .funnel-switch-del,
.funnel-switch-item.active .funnel-switch-del { opacity: .85; }
.funnel-switch-del:hover { opacity: 1; }

.funnel-switch-add {
  background: transparent;
  border: 1.5px dashed var(--brd-strong);
  color: var(--tx-tertiary);
}
.funnel-switch-add:hover { background: var(--bg-hover); color: var(--tx-primary); }

.funnel-switcher-legend {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--tx-tertiary);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Funnel Demo / Kanban View ──────────────────────────────────────────── */
.demo-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--brd);
}

.demo-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--tx-secondary);
}

.demo-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.demo-scroll-wrap {
  overflow-x: auto;
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
}

.demo-track {
  display: flex;
  align-items: flex-start;
  gap: 0;
  width: max-content;
}

.demo-arrow {
  display: flex;
  align-items: center;
  color: var(--tx-tertiary);
  font-size: 20px;
  padding: 0 4px;
  margin-top: 36px;
  flex-shrink: 0;
}

.demo-col {
  flex: 0 0 auto;
  width: 160px;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--brd);
  cursor: pointer;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  background: var(--bg-tertiary);
}
.demo-col:hover       { box-shadow: var(--shadow-sm); }
.demo-col.open        { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }

.demo-col-header {
  padding: var(--sp-2) var(--sp-3);
  text-align: center;
}

.demo-col-num {
  font-size: 10px;
  font-weight: 600;
  opacity: .8;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.demo-col-name {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-top: 2px;
  line-height: 1.3;
}

.demo-col-count {
  font-size: 11px;
  font-weight: 600;
  background: rgba(255,255,255,.25);
  border-radius: var(--r-full);
  padding: 1px 7px;
  line-height: 1.4;
  flex-shrink: 0;
}

.demo-col-empty {
  border: 1px dashed var(--brd-strong);
  border-radius: var(--r-sm);
  padding: var(--sp-3) var(--sp-2);
  text-align: center;
  font-size: 11px;
  color: var(--tx-placeholder);
}

.demo-col-body {
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.demo-col-who {
  font-size: 12px;
  color: var(--tx-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.demo-card-chip {
  background: var(--bg-secondary);
  border: 1px solid var(--brd);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--tx-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-robot-tag {
  font-size: 11px;
  color: #7e22ce;
  background: #f3e8ff;
  border-radius: var(--r-sm);
  padding: 2px 7px;
  display: inline-block;
}

.demo-col-group {
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  padding: 3px var(--sp-2);
  letter-spacing: .03em;
}

/* Stage detail panel (below kanban) */
.demo-detail {
  margin: 0 var(--sp-5) var(--sp-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--brd);
  background: var(--bg-secondary);
  overflow: hidden;
  animation: slideDown .18s var(--ease);
}

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

.demo-detail-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--brd);
}

.demo-detail-num {
  font-size: 13px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}

.demo-detail-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--tx-primary);
}

.demo-detail-who {
  font-size: 13px;
  color: var(--tx-secondary);
  margin-left: var(--sp-2);
}

.demo-detail-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  padding: var(--sp-4);
}

.demo-detail-col-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--tx-tertiary);
  margin-bottom: var(--sp-2);
}

.demo-detail-action {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-1) 0;
  border-bottom: 1px solid var(--brd);
  font-size: 13px;
  color: var(--tx-primary);
}
.demo-detail-action:last-child { border-bottom: none; }

.demo-detail-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.demo-detail-robot {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-1) 0;
  border-bottom: 1px solid var(--brd);
  font-size: 13px;
}
.demo-detail-robot:last-child { border-bottom: none; }

.demo-robot-when {
  font-weight: 600;
  flex-shrink: 0;
  min-width: 40px;
}

.demo-detail-note {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--brd);
  font-size: 13px;
  color: var(--tx-secondary);
  font-style: italic;
  background: var(--bg-primary);
}

/* ─── Funnel Board (legacy) ───────────────────────────────────────────────── */
.funnel-board {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
  padding-bottom: var(--sp-4);
  scrollbar-width: thin;
  min-height: 300px;
}

.funnel-column {
  min-width: 220px;
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-tertiary);
  border-radius: var(--r-lg);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.funnel-column-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-1) var(--sp-3);
}

.stage-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.funnel-column-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--tx-secondary);
  flex: 1;
}

.stage-card {
  background: var(--bg-secondary);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--brd);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}

.stage-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: rgba(0,122,255,0.25);
}

.stage-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--tx-primary);
  margin-bottom: 4px;
}

.stage-card-meta {
  font-size: 12px;
  color: var(--tx-tertiary);
}

.stage-card-clickable {
  cursor: pointer;
  user-select: none;
}

.stage-chevron {
  font-size: 13px;
  color: var(--tx-tertiary);
  line-height: 1;
  transition: transform var(--dur-fast) var(--ease);
}

.stage-details {
  margin-top: var(--sp-2);
  border-top: 1px solid var(--brd);
  padding-top: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.stage-detail-section {
  font-size: 12px;
}

.stage-detail-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--tx-tertiary);
  margin-bottom: 3px;
}

.stage-detail-row {
  padding: 2px 0;
  border-bottom: 1px solid var(--brd);
  color: var(--tx-secondary);
  line-height: 1.4;
  word-break: break-word;
}
.stage-detail-row:last-child { border-bottom: none; }

.stage-detail-robot {
  color: #7e22ce;
}

/* ─── KP Editor ──────────────────────────────────────────────────────────── */
.kp-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--sp-4);
  height: 100%;
}

.kp-sidebar {
  position: sticky;
  top: 0;
  height: fit-content;
}

.kp-section-nav {
  background: var(--bg-secondary);
  border-radius: var(--r-lg);
  border: 1px solid var(--brd);
  overflow: hidden;
}

.kp-nav-item {
  padding: 10px var(--sp-4);
  font-size: 13px;
  font-weight: 500;
  color: var(--tx-secondary);
  cursor: pointer;
  border-bottom: 1px solid var(--brd);
  transition: all var(--dur-fast) var(--ease);
}

.kp-nav-item:last-child { border-bottom: none; }
.kp-nav-item:hover { background: var(--bg-hover); color: var(--tx-primary); }
.kp-nav-item.active { background: var(--bg-active); color: var(--blue); font-weight: 600; }

.kp-section {
  background: var(--bg-secondary);
  border-radius: var(--r-lg);
  border: 1px solid var(--brd);
  margin-bottom: var(--sp-4);
  overflow: hidden;
}

.kp-section-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--brd);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.kp-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--tx-primary);
  flex: 1;
}

/* ─── Brief Tabs ─────────────────────────────────────────────────────────── */
.brief-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

.form-section {
  background: var(--bg-secondary);
  border-radius: var(--r-lg);
  border: 1px solid var(--brd);
  overflow: hidden;
  margin-bottom: var(--sp-4);
}

.form-section-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--brd);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.form-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--tx-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 12px;
}

.form-section-body {
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* ─── Action Bar ─────────────────────────────────────────────────────────── */
.action-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-secondary);
  border-radius: var(--r-lg);
  border: 1px solid var(--brd);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}

.action-bar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--tx-secondary);
  flex: 1;
  min-width: 120px;
}

/* ─── Responsive / narrow-width ─────────────────────────────────────────────
   Two independent triggers collapse to the same compact layout:
   - @media (max-width:768px): the app in a genuinely narrow browser window.
   - body.bx-embed: running inside the Bitrix24 widget iframe (app.js sets
     this) — the iframe is often 400-700px wide regardless of the host
     screen's size, so a viewport media query alone would miss it.
   Both need the same thing: hide the full sidebar (#topbarTabstrip is
   already visible on desktop too, see rules above) and collapse two-column
   editor layouts to one column. */
.bx-embed .sidebar { display: none; }
.bx-embed .topbar { padding: var(--sp-2) var(--sp-3); }
.bx-embed .page-content { padding: var(--sp-3); }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .page-content { padding: var(--sp-4); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .kp-layout { grid-template-columns: 1fr; }
  .funnel-editor-layout { grid-template-columns: 1fr; }
  .brief-grid { grid-template-columns: 1fr; }
  .modal { margin: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; align-self: flex-end; max-height: 95dvh; }
}

.bx-embed .kp-layout,
.bx-embed .funnel-editor-layout {
  grid-template-columns: 1fr;
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* ─── Utilities ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.flex-1 { flex: 1; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--tx-tertiary); }
.text-blue { color: var(--blue); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.p-4 { padding: var(--sp-4); }
.p-5 { padding: var(--sp-5); }
.rounded { border-radius: var(--r-md); }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.w-100 { width: 100%; }

/* ─── AI Brief Modal ─────────────────────────────────────────────────────── */
.ai-section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}
.ai-section-btn { justify-content: flex-start; font-size: 13px; }
.ai-section-btn.btn-success-outline {
  border-color: var(--green);
  color: var(--green);
  background: rgba(52,199,89,.08);
}
.ai-modal-status {
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  font-size: 13px;
}
.ai-modal-loading {
  background: var(--bg-secondary);
  color: var(--tx-secondary);
}
.ai-modal-success {
  background: rgba(52,199,89,.12);
  color: var(--green);
}
.ai-modal-error {
  background: rgba(255,59,48,.1);
  color: var(--red);
}

/* ─── KP Typed Sections ──────────────────────────────────────────────────── */
.kp-sec-body { display: flex; flex-direction: column; gap: var(--sp-3); }
.kp-field-label { font-size: 12px; font-weight: 600; color: var(--tx-secondary); text-transform: uppercase; letter-spacing: 0.04em; }

.kp-funnel-block {
  border: 1px solid var(--brd);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--sp-3);
}
.kp-funnel-block-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--brd);
}
.kp-funnel-block-body { padding: var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); }
.kp-funnel-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }

.kp-scope-items { display: flex; flex-direction: column; gap: var(--sp-2); }
.kp-scope-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-secondary);
  border-radius: var(--r-lg);
  border: 1px solid var(--brd);
}
.kp-scope-check {
  width: 24px; height: 24px; min-width: 24px;
  background: var(--green);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  margin-top: 2px;
}
.kp-scope-item-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }

/* ─── Login Page ──────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-container {
  width: 100%;
  max-width: 400px;
  padding: var(--sp-4);
}
.login-card {
  background: var(--bg-secondary);
  border-radius: var(--r-xl);
  border: 1px solid var(--brd);
  box-shadow: var(--shadow-md);
  padding: var(--sp-8);
}
.login-logo {
  text-align: center;
  margin-bottom: var(--sp-6);
}
.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--tx-primary);
  margin-top: var(--sp-2);
}
.login-subtitle {
  font-size: 14px;
  color: var(--tx-tertiary);
  margin-top: 2px;
}
.login-error {
  background: #FFF0F0;
  color: var(--red);
  border: 1px solid rgba(255,59,48,0.3);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
  font-size: 14px;
  margin-bottom: var(--sp-3);
}
.login-error.hidden { display: none; }

/* ─── Client (Public) Brief Page ─────────────────────────────────────────── */
.client-page {
  min-height: 100vh;
  background: var(--bg-primary);
}
.client-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--sp-4);
}
/* Full-width variant — used by the client funnels page, whose kanban boards
   need the whole viewport rather than a centered 900px column. */
.client-shell-wide {
  max-width: none;
  margin: 0;
  padding: var(--sp-4) var(--sp-6);
}
.client-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) 0 var(--sp-6);
  border-bottom: 1px solid var(--brd);
  margin-bottom: var(--sp-6);
}
.client-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 700;
  color: var(--tx-primary);
}
.client-logo-text { font-size: 16px; }
.client-project-name {
  font-size: 14px;
  color: var(--tx-tertiary);
}
.client-content {}

/* ─── AI Mode Tabs (inside modal) ───────────────────────────────────────── */
.ai-mode-tabs {
  display: flex;
  gap: var(--sp-2);
  border-bottom: 2px solid var(--brd);
  padding-bottom: var(--sp-2);
}
.ai-mode-tab {
  background: none;
  border: none;
  padding: var(--sp-2) var(--sp-3);
  font-size: 14px;
  font-weight: 500;
  color: var(--tx-tertiary);
  cursor: pointer;
  border-radius: var(--r-md);
  transition: color 0.15s, background 0.15s;
}
.ai-mode-tab:hover { background: var(--bg-hover); color: var(--tx-primary); }
.ai-mode-tab.active {
  color: var(--blue);
  background: var(--blue-light);
}

/* ─── File Drop Zone ─────────────────────────────────────────────────────── */
.file-drop-zone {
  border: 2px dashed var(--brd-strong);
  border-radius: var(--r-lg);
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--bg-tertiary);
  user-select: none;
}
.file-drop-zone:hover, .file-drop-zone.drag-over {
  border-color: var(--blue);
  background: var(--blue-light);
}
.file-drop-label { font-size: 14px; color: var(--tx-secondary); }
.file-drop-hint  { font-size: 12px; color: var(--tx-tertiary); margin-top: var(--sp-1); }
.file-selected-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-tertiary);
  border-radius: var(--r-md);
  border: 1px solid var(--brd);
  margin-top: var(--sp-2);
  font-size: 13px;
}
.file-selected-info.hidden { display: none; }
.file-selected-name { color: var(--tx-primary); font-weight: 500; }
.file-selected-size { color: var(--tx-tertiary); }

/* ─── Extra Channel Rows ─────────────────────────────────────────────────── */
.channel-extra-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.channel-extra-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  max-width: 400px;
}
.channel-extra-item .form-control { flex: 1; }

/* ─── Share Link Box ─────────────────────────────────────────────────────── */
.share-link-box {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}
.share-link-box .form-control {
  flex: 1;
  font-size: 13px;
  background: var(--bg-tertiary);
  cursor: text;
}

.kp-price-input { font-size: 18px !important; font-weight: 700 !important; color: var(--blue) !important; }

/* ─── Checklist Page ─────────────────────────────────────────────────────── */
.cl-dates-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}
.cl-date-block { display: flex; flex-direction: column; gap: 2px; }
.cl-date-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--tx-tertiary); }
.cl-date-val   { font-size: 16px; font-weight: 600; color: var(--tx-primary); }
.cl-date-sub   { font-size: 12px; color: var(--tx-tertiary); }
.cl-date-arrow { font-size: 20px; color: var(--tx-tertiary); margin: 0 var(--sp-1); }

.cl-days-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px; font-size: 13px; font-weight: 500;
}
.cl-days-badge.ok      { background: var(--green-light); color: var(--green); }
.cl-days-badge.urgent  { background: #fff3e0; color: #e65100; }
.cl-days-badge.today   { background: #fce4ec; color: #c62828; }
.cl-days-badge.overdue { background: #fce4ec; color: #c62828; font-weight: 600; }

.cl-progress-stat-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--sp-2);
}
.cl-progress-label { font-size: 13px; color: var(--tx-secondary); }
.cl-progress-pct   { font-size: 13px; font-weight: 600; color: var(--blue); }
.cl-progress-track {
  height: 8px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden;
}
.cl-progress-fill {
  height: 100%; background: var(--blue); border-radius: 4px;
  transition: width .3s ease;
}
.cl-progress-fill.complete { background: var(--green); }

.cl-update-banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  background: #fff8e1; border: 1px solid #ffc107; border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4); font-size: 13px; color: #795548;
}

/* Groups */
.cl-group {
  background: var(--bg-secondary);
  border: 1px solid var(--brd);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-3);
  overflow: hidden;
}
.cl-group-header {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer; user-select: none;
  background: var(--bg-secondary);
}
.cl-group-header:hover { background: var(--bg-tertiary); }
.cl-group-toggle { font-size: 12px; color: var(--tx-tertiary); width: 16px; }
.cl-group-name   { font-size: 14px; font-weight: 600; color: var(--tx-primary); }
.cl-group-stat   { font-size: 12px; color: var(--tx-tertiary); font-weight: 500; }
.cl-group-stat.all-done { color: var(--green); }
.cl-group-bar-wrap {
  width: 80px; height: 4px; background: var(--bg-tertiary);
  border-radius: 2px; overflow: hidden;
}
.cl-group-bar {
  height: 100%; background: var(--blue); border-radius: 2px; transition: width .3s;
}
.cl-group-bar.complete { background: var(--green); }
.cl-group-body { border-top: 1px solid var(--brd); }

/* Items */
.cl-item {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--brd);
  transition: background .15s;
}
.cl-item:last-child { border-bottom: none; }
.cl-item:hover { background: var(--bg-primary); }
.cl-item.done { opacity: .65; }
.cl-item.done .cl-item-title { text-decoration: line-through; color: var(--tx-tertiary); }

.cl-status-btn {
  width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px;
  border-radius: var(--r-xs); border: 1.5px solid var(--brd-strong); background: transparent;
  cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center;
  color: var(--tx-tertiary); transition: all .15s;
}
.cl-status-btn:hover              { border-color: var(--blue); color: var(--blue); }
.cl-status-btn.cl-status-progress { border-color: var(--orange); color: var(--orange); background: #fff3e0; }
.cl-status-btn.cl-status-done     { border-color: var(--blue); color: #fff; background: var(--blue); }

.cl-item-body  { flex: 1; min-width: 0; }
.cl-item-title { font-size: 14px; font-weight: 500; color: var(--tx-primary); line-height: 1.4; }
.cl-item-desc  { font-size: 12px; color: var(--tx-tertiary); margin-top: 2px; line-height: 1.4; }

.cl-item-meta  { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.cl-item-src   { font-size: 11px; color: var(--tx-tertiary); }

.cl-dl {
  font-size: 11px; font-weight: 500; padding: 2px 8px;
  border-radius: 10px; white-space: nowrap;
}
.cl-dl.ok      { background: var(--bg-tertiary); color: var(--tx-tertiary); }
.cl-dl.urgent  { background: #fff3e0; color: #e65100; }
.cl-dl.today   { background: #fce4ec; color: #c62828; }
.cl-dl.overdue { background: #fce4ec; color: #c62828; font-weight: 700; }
.cl-dl.done    { background: var(--green-light); color: var(--green); }

.cl-item-del {
  opacity: 0; flex-shrink: 0;
  transition: opacity .15s;
}
.cl-item:hover .cl-item-del { opacity: 1; }

/* ─── Funnel Approval ─────────────────────────────────────────────────────── */
.funnel-approval-badge {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--green-light); border: 1px solid var(--green);
  border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4);
}
.funnel-approval-badge-sm {
  font-size: 13px; font-weight: 500; color: var(--green);
  background: var(--green-light); padding: 4px 12px; border-radius: 20px;
}
.funnel-approval-icon  { font-size: 24px; }
.funnel-approval-title { font-weight: 600; font-size: 15px; color: var(--green); }
.funnel-approval-meta  { font-size: 12px; color: var(--tx-secondary); margin-top: 2px; }

.funnel-approve-block {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  background: var(--bg-secondary); border: 1px solid var(--brd);
  border-radius: var(--r-lg); padding: var(--sp-4);
}

.funnel-approval-card {
  display: flex; align-items: center; gap: var(--sp-4);
  background: var(--green-light); border: 1.5px solid var(--green);
  border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5);
}

/* ─── Funnel Client Comments ─────────────────────────────────────────────── */
.funnel-client-comments {
  margin-top: var(--sp-4); padding-top: var(--sp-4);
  border-top: 1px solid var(--brd);
}
.funnel-comments-title { font-size: 13px; font-weight: 600; color: var(--tx-secondary); margin-bottom: var(--sp-2); }
.funnel-comment-item {
  background: var(--bg-tertiary); border-radius: var(--r-md);
  padding: var(--sp-3); margin-bottom: var(--sp-2);
}
.funnel-comment-header {
  display: flex; align-items: center; gap: var(--sp-2); margin-bottom: 4px;
}
.funnel-comment-author { font-size: 12px; font-weight: 600; color: var(--tx-primary); display:flex;align-items:center;gap:4px }
.funnel-comment-date   { font-size: 11px; color: var(--tx-tertiary); margin-left: auto; }
.funnel-comment-text   { font-size: 13px; color: var(--tx-primary); line-height: 1.5; }

/* ─── Client Funnels Page ─────────────────────────────────────────────────── */
.cf-cards-tabs {
  display: flex; gap: var(--sp-1); margin-bottom: var(--sp-3);
  border-bottom: 1px solid var(--brd); padding-bottom: 0;
}
.cf-card-tab {
  padding: var(--sp-2) var(--sp-3); font-size: 13px; font-weight: 500;
  color: var(--tx-secondary); background: transparent; border: none;
  border-bottom: 2px solid transparent; cursor: pointer; transition: all .15s;
  margin-bottom: -1px;
}
.cf-card-tab:hover  { color: var(--blue); }
.cf-card-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.cf-field-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-secondary); border: 1px solid var(--brd);
  border-radius: var(--r-sm); padding: 4px 10px; font-size: 12px;
}
.cf-field-type {
  font-size: 10px; color: var(--tx-tertiary); background: var(--bg-tertiary);
  padding: 1px 5px; border-radius: 3px; text-transform: uppercase;
}

.cf-comments-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.cf-comment-form  { display: flex; flex-direction: column; gap: var(--sp-2); }

/* ─── Entity card preview (EntityCardPreview, utils.js) — shared by the admin
   funnels editor and the public client-funnels page ─────────────────────── */
.ecard-section { margin-bottom: var(--sp-4); }
.ecard-section:last-child { margin-bottom: 0; }
.ecard-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--tx-tertiary); margin-bottom: var(--sp-1);
}
.ecard-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: 9px 0; border-bottom: 1px solid var(--brd); font-size: 14px;
}
.ecard-row:last-child { border-bottom: none; }
.ecard-row-label { color: var(--tx-secondary); }
.ecard-row-value { display: flex; align-items: center; gap: 8px; color: var(--tx-primary); }

/* Demo-column "sample deal" trigger — sits alongside the field-label chips,
   opens EntityCardPreview.open() for that funnel. */
.demo-sample-card {
  display: block; width: 100%; text-align: left;
  background: var(--bg-secondary); border: 1px solid var(--brd); border-radius: var(--r-sm);
  padding: 7px 9px; font-family: var(--font); cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.demo-sample-card:hover { border-color: var(--blue); box-shadow: var(--shadow-xs); }
.demo-sample-card-title { font-size: 12px; font-weight: 600; color: var(--tx-primary); }
.demo-sample-card-hint  { font-size: 11px; color: var(--tx-tertiary); margin-top: 1px; }
.form-section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--tx-tertiary); margin-bottom: var(--sp-1);
}

/* ─── KP Done Status ─────────────────────────────────────────────────────── */
.kp-list-card.kp-done { opacity: .7; }
.kp-list-card.kp-done:hover { opacity: 1; }
.kp-done-title { color: var(--tx-tertiary) !important; }
.kp-done-banner {
  font-size: 12px; color: var(--green); font-weight: 500;
  margin-bottom: var(--sp-2);
}
.kp-done-editor-banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  background: var(--green-light); border: 1px solid var(--green);
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4);
  font-size: 13px; color: var(--green); font-weight: 500;
}
.kp-editor-done-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--green-light); color: var(--green);
  font-size: 12px; font-weight: 600; padding: 4px 12px;
  border-radius: 20px; border: 1px solid var(--green);
}

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 3px 8px;
  border-radius: 10px; white-space: nowrap;
}
.badge-blue   { background: var(--blue-light);   color: var(--blue); }
.badge-green  { background: var(--green-light);  color: var(--green); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-red    { background: var(--red-light);    color: var(--red); }
.badge-purple { background: #f3f0ff; color: #7c3aed; }
.badge-gray   { background: var(--bg-tertiary);  color: var(--tx-secondary); }

/* ─── User Management ────────────────────────────────────────────────────── */
.users-table {
  width: 100%; border-collapse: collapse;
}
.users-table th, .users-table td {
  padding: var(--sp-3) var(--sp-4); text-align: left;
  border-bottom: 1px solid var(--brd); font-size: 13px;
}
.users-table th {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--tx-secondary); background: var(--bg-secondary);
}
.users-table tbody tr:hover { background: var(--bg-secondary); }
.users-table tbody tr:last-child td { border-bottom: none; }

.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
}

.perm-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-2);
}
.perm-toggle {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  border: 1px solid var(--brd); cursor: pointer;
  transition: background .15s, border-color .15s;
  font-size: 13px;
}
.perm-toggle:hover { background: var(--bg-secondary); }
.perm-toggle input[type="checkbox"] { accent-color: var(--blue); }
.perm-section { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--brd); }

.btn-danger:hover { background: var(--red-light) !important; color: var(--red) !important; }

.form-error { color: var(--red); font-size: 12px; padding: var(--sp-2) var(--sp-3); background: var(--red-light); border-radius: var(--r-sm); }

/* Bitrix24 linkage panel */
.bx-link-rows .row { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 8px 0; border-bottom: 1px solid var(--brd); font-size: 14px; }
.bx-link-rows .row:last-child { border-bottom: none; }
.bx-link-rows .row b { color: var(--tx-secondary); font-weight: 500; }
.bx-link-rows .row a { color: var(--blue); text-decoration: none; }
.bx-link-rows .row a:hover { text-decoration: underline; }

/* KP/TZ per-section "include in file" toggle */
.kp-include-toggle { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--tx-secondary); cursor: pointer; user-select: none; white-space: nowrap; }
.kp-include-toggle input { margin: 0; cursor: pointer; }

/* Architecture funnels sub-header with its own include toggle */
.kp-funnels-head { display: flex; align-items: center; justify-content: space-between; margin: var(--sp-2) 0 var(--sp-1); }

/* Lightweight rich-text editor for KP/TZ prose fields */
.rich { border: 1px solid var(--brd); border-radius: var(--r-md); overflow: hidden; background: var(--bg-primary); }
.rich-toolbar { display: flex; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--brd); background: var(--bg-secondary); }
.rich-toolbar button { min-width: 28px; height: 26px; padding: 0 6px; border: none; background: transparent; border-radius: var(--r-sm); cursor: pointer; font-size: 13px; color: var(--tx-secondary); }
.rich-toolbar button:hover { background: var(--bg-tertiary); color: var(--tx-primary); }
.rich-edit { min-height: 84px; padding: 10px 12px; font-size: 14px; line-height: 1.6; outline: none; }
.rich-edit:focus { box-shadow: inset 0 0 0 2px var(--blue-light); }
.rich-edit[data-rich-edit]:empty:before { content: attr(data-ph); color: var(--tx-tertiary); pointer-events: none; }
.rich-edit ul, .rich-edit ol { margin: 4px 0 4px 20px; }
.rich-edit h3 { font-size: 15px; font-weight: 700; margin: 6px 0 2px; }

/* Add-section type picker */
.kp-addsec-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.kp-addsec-btn { justify-content: flex-start; text-align: left; }

/* Multiple checklists: selector bar + current head */
.cl-bar { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.cl-bar-chip { display: inline-flex; align-items: center; gap: var(--sp-2); padding: 6px 12px; border: 1px solid var(--brd); border-radius: var(--r-pill, 20px); background: var(--bg-secondary); cursor: pointer; font-size: 13px; color: var(--tx-secondary); }
.cl-bar-chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.cl-bar-chip .cl-bar-prog { font-size: 11px; opacity: .8; }
.cl-bar-add { padding: 6px 12px; border: 1px dashed var(--brd); border-radius: var(--r-pill, 20px); background: transparent; cursor: pointer; font-size: 13px; color: var(--blue); }
.cl-bar-add:hover { background: var(--blue-light); }
.cl-current-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.cl-current-name { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.cl-bind-tag { font-size: 12px; font-weight: 500; color: var(--blue); background: var(--blue-light); padding: 2px 8px; border-radius: var(--r-sm); }

/* Checklist control panel (автоконтроль ключевых точек) */
.cl-control-panel { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; padding: 10px 14px; background: var(--bg-secondary); border: 1px solid var(--brd); border-radius: var(--r-md); }
.cl-cp-label { font-size: 13px; font-weight: 600; color: var(--tx-secondary); }
.cl-cp-chip { font-size: 13px; padding: 3px 10px; border-radius: var(--r-pill, 20px); font-weight: 500; }
.cl-cp-chip.overdue { background: var(--red-light); color: var(--red); }
.cl-cp-chip.urgent  { background: #fff3e0; color: #e8770a; }
.cl-cp-chip.ok      { background: var(--blue-light); color: var(--blue); }

/* Overview page — folder tree (КП → ТЗ → чек-листы) */
.ov-folder { border: 1px solid var(--brd); border-radius: var(--r-md); margin-bottom: var(--sp-3); overflow: hidden; background: var(--bg-primary); }
.ov-folder-loose { background: var(--bg-secondary); }
.ov-folder-head { display: flex; align-items: center; gap: var(--sp-2); padding: 12px 14px; cursor: pointer; user-select: none; }
.ov-folder-head:hover { background: var(--bg-secondary); }
.ov-fold-caret { color: var(--tx-tertiary); font-size: 12px; width: 14px; transition: transform .15s; }
.ov-folder.collapsed .ov-fold-caret { transform: rotate(-90deg); }
.ov-folder.collapsed .ov-folder-body { display: none; }
.ov-fold-title { font-weight: 600; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.ov-fold-title:hover { color: var(--blue); }
.ov-fold-badges { display: flex; gap: 6px; }
.ov-badge { font-size: 12px; padding: 2px 8px; border-radius: var(--r-pill, 20px); background: var(--bg-tertiary); color: var(--tx-secondary); }
.ov-badge-empty { background: transparent; color: var(--tx-tertiary); }
.ov-folder-body { padding: 4px 14px 12px 30px; }
.ov-item { display: flex; align-items: center; gap: var(--sp-2); padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; font-size: 14px; }
.ov-item:hover { background: var(--bg-secondary); }
.ov-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-meta { font-size: 12px; color: var(--tx-tertiary); flex-shrink: 0; }
.ov-tz { margin: 4px 0; }
.ov-tzhead { font-weight: 500; }
.ov-children { margin-left: 22px; border-left: 2px solid var(--brd); padding-left: 8px; }
.ov-hint { font-size: 13px; color: var(--tx-tertiary); padding: 4px 10px; }

/* Funnel ↔ ТЗ link row in the funnel card header */
.funnel-tz-row { display: flex; align-items: center; gap: var(--sp-2); padding: 6px 20px 10px; font-size: 13px; color: var(--tx-secondary); border-bottom: 1px solid var(--brd); }

/* ТЗ generation modal: attached files list */
.tz-file-list { display: flex; flex-direction: column; gap: 4px; margin-top: var(--sp-2); }
.tz-file-item { display: flex; align-items: center; gap: var(--sp-2); padding: 6px 10px; background: var(--bg-secondary); border: 1px solid var(--brd); border-radius: var(--r-sm); font-size: 13px; }
.tz-file-item span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* SP field mapping screen */
.spmap-group-title { font-size: 13px; font-weight: 600; color: var(--tx-secondary); text-transform: uppercase; letter-spacing: .03em; margin-bottom: var(--sp-2); }
.spmap-row { display: grid; grid-template-columns: 1fr 24px 1.3fr; align-items: center; gap: var(--sp-2); padding: 6px 0; }
.spmap-src { display: flex; align-items: center; gap: var(--sp-2); font-size: 14px; }
.spmap-type { font-size: 11px; color: var(--tx-tertiary); background: var(--bg-tertiary); padding: 1px 6px; border-radius: var(--r-sm); }
.spmap-arrow { text-align: center; color: var(--tx-tertiary); }
