/* ═══════════════════════════════════════════════════════════════
   Logisoft One — design system
   One Platform. Total Control.

   Подход: дизайн-токени + компонентни класове; fluid мащаби (clamp/rem);
   мобилно чекмедже; адаптивни мрежи.
   Breakpoints: <768 телефон (drawer), 768–1023 таблет (икон-лента),
   ≥1024 пълен sidebar, ≥1920/2560/3840 — по-широк канвас за FHD/QHD/4K.
   ═══════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;

  /* Бранд */
  --brand: #ea580c;
  --brand-soft: #fff7ed;

  /* Акцент (интерактивни елементи) */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-soft: #eff6ff;

  /* Семантични */
  --green: #16a34a;
  --green-dark: #15803d;
  --green-light: #dcfce7;
  --red: #dc2626;
  --red-dark: #b91c1c;
  --red-light: #fee2e2;
  --orange: #ea580c;
  --orange-light: #ffedd5;
  --gray: #64748b;

  /* Неутрални */
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-soft: #eef2f6;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --hover: #f8fafc;
  --active: #f1f5f9;

  /* Сенки — меки и дискретни */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 6px 16px -4px rgba(15, 23, 42, .1), 0 2px 6px -2px rgba(15, 23, 42, .05);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, .22);

  /* Радиуси */
  --radius: 12px;       /* панели, карти */
  --radius-sm: 8px;     /* бутони, полета */
  --radius-lg: 16px;    /* модали */

  /* Оформление */
  --sidebar-w: 16rem;
  --topbar-h: 3.5rem;
  --content-max: 1240px;

  /* Fluid отстояния */
  --pad-page: clamp(1rem, 2.5vw, 2rem);
  --pad-card: clamp(1rem, 1.3vw, 1.375rem);
  --gap: clamp(0.75rem, 1vw, 1rem);

  /* Fluid типография */
  --fs-xs: clamp(0.6875rem, 0.65rem + 0.15vw, 0.75rem);
  --fs-sm: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --fs-base: clamp(0.875rem, 0.84rem + 0.2vw, 0.9375rem);
  --fs-md: clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
  --fs-title: clamp(1.25rem, 1.1rem + 0.8vw, 1.5rem);

  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system,
          "Helvetica Neue", Arial, sans-serif;
  --transition: .15s ease;
}

/* Големи екрани: повече място за съдържанието */
@media (min-width: 1920px) { :root { --content-max: 1480px; } }
@media (min-width: 2560px) { :root { --content-max: 1680px; } body { zoom: 1.2; } }
@media (min-width: 3840px) { body { zoom: 1.7; } }

/* ── Базови стилове ─────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, canvas { max-width: 100%; height: auto; }
svg { display: block; }

button { font-family: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 0.875rem; }
/* iOS Safari увеличава мащаба при фокус върху поле с шрифт < 16px */
@media (pointer: coarse) and (max-width: 767px) {
  input, select, textarea { font-size: 16px; }
}

a { color: var(--primary); }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

::selection { background: var(--primary-light); }

/* Дискретни скролбари */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 99px;
  border: 2px solid transparent; background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; border: 2px solid transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Вход ───────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg);
  padding: clamp(1rem, 4vw, 2rem);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: clamp(1.75rem, 5vw, 2.75rem);
  width: 100%; max-width: 26.5rem;
}
.login-brand {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  margin: 0 0 1.75rem;
  padding: 0.25rem 0.5rem 1.5rem;
  border-bottom: 1px solid var(--border-soft);
}
.login-brand .brand-logo {
  width: auto;
  height: auto;
  max-width: 120px;
  max-height: 60px;
  object-fit: contain;
  display: block;
}
.login-brand .tagline {
  color: var(--text-muted); font-size: 0.8125rem; margin-top: 0.875rem;
  font-weight: 500; letter-spacing: 0.01em;
}
.login-foot {
  margin-top: 1.5rem; color: var(--text-faint); font-size: 0.75rem; text-align: center;
}

/* ── Форми ──────────────────────────────── */
.field { margin-bottom: 1rem; min-width: 0; }
.field label {
  display: block; font-size: 0.8125rem; font-weight: 550;
  margin-bottom: 0.375rem; color: var(--text-secondary);
}
.field input, .field select, .field textarea,
.input, select.input {
  width: 100%; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; background: var(--card); color: var(--text);
  min-height: 2.5rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field textarea { min-height: auto; line-height: 1.5; padding-top: 0.5625rem; resize: vertical; }
.field input:hover, .field select:hover, .field textarea:hover,
.input:hover { border-color: var(--border-strong); }
.field input:focus, .field select:focus, .field textarea:focus,
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.field input:disabled, .field select:disabled, .field textarea:disabled {
  background: var(--bg); color: var(--text-muted); cursor: not-allowed;
}
.field input::placeholder, .field textarea::placeholder, .input::placeholder { color: var(--text-faint); }

/* Селекти: собствена стрелка */
.field select, select.input {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.625rem center;
  padding-right: 2.25rem;
}

input[type="checkbox"], input[type="radio"] {
  accent-color: var(--primary); width: 1rem; height: 1rem; cursor: pointer;
}
.field input[type="checkbox"], .field input[type="radio"] {
  padding: 0; flex-shrink: 0; min-height: auto; width: 1rem; height: 1rem;
}
.field input[type="color"] { width: 2.25rem; height: 2.25rem; padding: 2px; min-height: auto; cursor: pointer; }

.form-row { display: flex; gap: 0.75rem; }
.form-row > * { flex: 1; min-width: 0; }

.check-label {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.8125rem; color: var(--text-secondary); cursor: pointer;
  user-select: none;
}

.form-error { color: var(--red); font-size: 0.8125rem; min-height: 1.125rem; margin-bottom: 0.625rem; }
.field-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.375rem; }

/* Информационна лента във форми */
.form-note {
  display: flex; gap: 0.5rem; align-items: flex-start;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.625rem 0.75rem;
  font-size: 0.75rem; color: var(--text-muted); margin-bottom: 1rem; line-height: 1.45;
}
.form-note svg { flex-shrink: 0; margin-top: 1px; color: var(--text-faint); }

/* ── Бутони ─────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4375rem;
  padding: 0.5rem 1rem; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 550; line-height: 1.2; white-space: nowrap;
  min-height: 2.5rem; text-decoration: none;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), box-shadow var(--transition);
}
.btn svg { flex-shrink: 0; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--green); color: #fff; box-shadow: var(--shadow-xs); }
.btn-success:hover { background: var(--green-dark); }
.btn-danger { background: var(--red); color: #fff; box-shadow: var(--shadow-xs); }
.btn-danger:hover { background: var(--red-dark); }
.btn-ghost {
  background: var(--card); color: var(--text-secondary); border-color: var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-ghost:hover { background: var(--hover); border-color: var(--border-strong); color: var(--text); }
.btn-sm { padding: 0.3125rem 0.6875rem; font-size: 0.8125rem; min-height: 2rem; border-radius: 7px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Икон-бутон (квадратен, дискретен) */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; padding: 0; border: none; border-radius: 7px;
  background: transparent; color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--active); color: var(--text); }
.btn-icon.danger:hover { background: var(--red-light); color: var(--red); }
.btn-icon[disabled] { opacity: .45; cursor: not-allowed; }

.row-actions { display: flex; gap: 0.25rem; align-items: center; }

/* По-големи touch цели на устройства с пръст */
@media (pointer: coarse) {
  .btn-sm { padding: 0.55rem 0.85rem; min-height: 2.5rem; }
  .btn-icon { width: 2.5rem; height: 2.5rem; }
  input[type="checkbox"], input[type="radio"] { width: 1.2rem; height: 1.2rem; }
}

/* ── Горна лента (само телефон) ──────────── */
.topbar { display: none; }
.backdrop { display: none; }

/* ── Оформление ─────────────────────────── */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
}
.sidebar .brand {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 1.5rem 1.25rem 1.375rem;
  margin: 0 0.75rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-soft);
}
.sidebar .brand .brand-logo {
  width: auto;
  height: auto;
  max-width: 120px;
  max-height: 60px;
  object-fit: contain;
  display: block;
}
.sidebar .brand .tagline {
  color: var(--text-muted); font-size: 0.8125rem; margin-top: 0.875rem;
  font-weight: 500; letter-spacing: 0.01em; line-height: 1.3;
}
.sidebar nav {
  flex: 1; padding: 0.875rem 0.75rem 0.75rem;
  display: flex; flex-direction: column; gap: 1px;
  overflow-y: auto; min-height: 0;
}
.sidebar nav .nav-section {
  font-size: 0.6875rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-faint);
  padding: 1rem 0.625rem 0.375rem;
}
.sidebar nav .nav-section:first-child { padding-top: 0.5rem; }
.sidebar nav a {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  color: var(--text-secondary); text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500; white-space: nowrap;
  min-height: 2.375rem;
  transition: background var(--transition), color var(--transition);
}
.sidebar nav a svg { color: var(--text-faint); flex-shrink: 0; transition: color var(--transition); }
.sidebar nav a:hover { background: var(--active); color: var(--text); }
.sidebar nav a:hover svg { color: var(--text-muted); }
.sidebar nav a.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.sidebar nav a.active svg { color: var(--primary); }
.sidebar nav a .badge {
  margin-left: auto; background: var(--red); color: #fff; border-radius: 99px;
  font-size: 0.6875rem; font-weight: 700; padding: 1px 7px; line-height: 1.5;
}

.sidebar .user-box {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: calc(0.875rem + env(safe-area-inset-bottom, 0px));
}
.sidebar .user-box .avatar { flex-shrink: 0; }
.sidebar .user-box .user-meta { flex: 1; min-width: 0; }
.sidebar .user-box .name {
  color: var(--text); font-weight: 600; font-size: 0.8125rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar .user-box .pos {
  font-size: 0.75rem; color: var(--text-muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Аватар с инициали */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 8px;
  background: var(--primary-light); color: var(--primary-dark);
  font-size: 0.75rem; font-weight: 650; letter-spacing: .01em;
  flex-shrink: 0; user-select: none;
}
.avatar.sm { width: 1.5rem; height: 1.5rem; font-size: 0.625rem; border-radius: 6px; }
.avatar.lg { width: 4rem; height: 4rem; font-size: 1.375rem; border-radius: 14px; }
.avatar.neutral { background: var(--active); color: var(--text-secondary); }

.main {
  flex: 1; margin-left: var(--sidebar-w);
  padding: clamp(1.25rem, 2.5vw, 2rem) var(--pad-page) clamp(2rem, 4vw, 3rem);
  max-width: calc(var(--sidebar-w) + var(--content-max));
  min-width: 0;
  width: 100%;
}

.page-title {
  font-size: var(--fs-title); font-weight: 700; letter-spacing: -0.02em;
  margin-bottom: 0.25rem; line-height: 1.25;
}
.page-sub { color: var(--text-muted); font-size: var(--fs-base); margin-bottom: clamp(1rem, 2vw, 1.5rem); }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--gap); flex-wrap: wrap; margin-bottom: 0.25rem;
}
.page-head .page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ── Таблет: компактна икон-лента ────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  :root { --sidebar-w: 5.25rem; }
  .sidebar .brand {
    justify-content: center;
    padding: 1.25rem 0.5rem 1rem;
    margin: 0 0.35rem;
  }
  .sidebar .brand .tagline { display: none; }
  .sidebar nav { padding: 0.75rem 0.625rem 0.75rem; }
  .sidebar nav .nav-section { padding: 0.75rem 0 0.25rem; text-align: center; overflow: hidden; height: 1.375rem; }
  .sidebar nav .nav-section::before { content: "··"; letter-spacing: .1em; }
  .sidebar nav .nav-section span { display: none; }
  .sidebar nav a { justify-content: center; padding: 0.5625rem 0.5rem; }
  .sidebar nav a span { display: none; }
  .sidebar nav a .badge { display: none; }
  .sidebar .user-box { justify-content: center; padding: 0.75rem 0.5rem; }
  .sidebar .user-box .user-meta { display: none; }
}

/* ── Телефон: чекмедже + горна лента ─────── */
@media (max-width: 767px) {
  .topbar {
    display: flex; position: fixed; top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    z-index: 60; align-items: center; gap: 0.625rem; padding: 0 0.75rem;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .topbar .menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--text-secondary);
    width: 2.5rem; height: 2.5rem; border-radius: var(--radius-sm);
  }
  .topbar .menu-btn:active { background: var(--active); }
  .topbar .brand-logo {
    width: auto; height: auto;
    max-width: 120px; max-height: 36px;
    object-fit: contain;
  }

  .sidebar {
    width: min(80vw, 18rem);
    transform: translateX(-105%);
    transition: transform .25s ease;
    z-index: 80;
    box-shadow: none;
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar .brand {
    padding: 1.5rem 1rem 1.375rem;
    margin: 0 0.75rem;
  }
  .backdrop {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 70;
  }
  body:not(.nav-open) .backdrop { display: none; }
  body.nav-open .backdrop { display: block; }
  body.nav-open { overflow: hidden; }

  .main {
    margin-left: 0;
    padding-top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 1rem);
  }
}

/* ── Карти със статистики ───────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(14.5rem, 100%), 1fr));
  gap: var(--gap); margin-bottom: clamp(1rem, 2vw, 1.5rem);
}
.stat-card {
  position: relative;
  background: var(--card); border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
  box-shadow: var(--shadow-xs); border: 1px solid var(--border);
  min-width: 0;
}
.stat-card .label { font-size: 0.8125rem; color: var(--text-muted); font-weight: 500; }
.stat-card .value {
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 1.75rem); font-weight: 700;
  letter-spacing: -0.02em; margin-top: 0.375rem; line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-card .hint { font-size: 0.75rem; color: var(--text-faint); margin-top: 0.25rem; }
.stat-card .stat-icon {
  position: absolute; top: 1rem; right: 1rem;
  display: flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border-radius: 10px;
}
.stat-card.accent-blue .stat-icon { background: var(--primary-soft); color: var(--primary); }
.stat-card.accent-green .stat-icon { background: var(--green-light); color: var(--green); }
.stat-card.accent-orange .stat-icon { background: var(--orange-light); color: var(--orange); }
.stat-card.accent-red .stat-icon { background: var(--red-light); color: var(--red); }

/* ── Панели ─────────────────────────────── */
.panel {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-xs);
  border: 1px solid var(--border); margin-bottom: clamp(1rem, 2vw, 1.5rem);
  min-width: 0; overflow: clip;
}
.panel .panel-head {
  padding: 0.875rem var(--pad-card); border-bottom: 1px solid var(--border);
  font-weight: 650; font-size: var(--fs-md); letter-spacing: -0.01em;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; flex-wrap: wrap;
}
.panel .panel-body { padding: var(--pad-card); }
.panel .empty { color: var(--text-muted); font-size: var(--fs-base); padding: clamp(1.25rem, 3vw, 2rem); text-align: center; }

/* ── Празни състояния ───────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: clamp(2rem, 5vw, 3rem) 1.25rem;
}
.empty-state .es-icon {
  display: flex; align-items: center; justify-content: center;
  width: 2.75rem; height: 2.75rem; border-radius: 12px;
  background: var(--active); color: var(--text-faint); margin-bottom: 0.875rem;
}
.empty-state .es-title { font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.empty-state .es-hint { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.25rem; max-width: 26rem; }
.empty-state .btn { margin-top: 1rem; }

/* ── Зареждане ──────────────────────────── */
.loading {
  display: flex; align-items: center; justify-content: center; gap: 0.625rem;
  color: var(--text-muted); padding: clamp(2rem, 6vw, 3rem); font-size: var(--fs-base);
}
.spinner, .loading::before {
  content: ""; width: 1.125rem; height: 1.125rem; flex-shrink: 0;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: var(--active); border-radius: var(--radius-sm);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ── Таблици ────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data th {
  text-align: left; padding: 0.625rem 1rem;
  font-size: 0.6875rem; text-transform: uppercase; font-weight: 600;
  letter-spacing: .05em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg); white-space: nowrap;
}
table.data td {
  padding: 0.6875rem 1rem; border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background var(--transition); }
table.data tbody tr:hover td { background: var(--hover); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data.compact th { padding: 0.5625rem 0.625rem; }
table.data.compact td { padding: 0.5625rem 0.625rem; }
table.data td.actions { text-align: right; white-space: nowrap; padding-top: 0.375rem; padding-bottom: 0.375rem; }
table.data strong { font-weight: 600; }

/* ── Статус значки ──────────────────────── */
.badge-status {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.1875rem 0.625rem; border-radius: 99px;
  font-size: 0.75rem; font-weight: 550; white-space: nowrap;
  border: 1px solid transparent;
}
.badge-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-status.pending  { background: var(--orange-light); color: #c2410c; border-color: #fed7aa; }
.badge-status.approved { background: var(--green-light); color: var(--green-dark); border-color: #bbf7d0; }
.badge-status.rejected { background: var(--red-light); color: var(--red-dark); border-color: #fecaca; }
.badge-status.cancelled { background: var(--active); color: var(--text-muted); border-color: var(--border); }

/* ── Модали ─────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: clamp(0.5rem, 3vw, 1.5rem);
  animation: fade-in .15s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  background: var(--card); border-radius: var(--radius-lg); width: 100%; max-width: 30rem;
  box-shadow: var(--shadow-lg); max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column;
  animation: modal-in .18s ease-out;
}
.modal.modal-lg { max-width: 38rem; }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(.985); }
  to { opacity: 1; transform: none; }
}
.modal .modal-head {
  padding: 1.125rem 1.5rem 1rem; border-bottom: 1px solid var(--border);
  font-weight: 650; font-size: 1rem; letter-spacing: -0.01em;
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  flex-shrink: 0;
}
.modal .modal-body { padding: 1.25rem 1.5rem; overflow-y: auto; min-height: 0; }
.modal .modal-foot {
  padding: 1rem 1.5rem 1.25rem; display: flex; gap: 0.625rem; justify-content: flex-end;
  flex-wrap: wrap; flex-shrink: 0; border-top: 1px solid var(--border-soft);
}

/* Диалог за потвърждение */
.confirm-body { display: flex; gap: 0.875rem; align-items: flex-start; }
.confirm-body .confirm-icon {
  display: flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; border-radius: 12px; flex-shrink: 0;
  background: var(--red-light); color: var(--red);
}
.confirm-body .confirm-icon.neutral { background: var(--primary-soft); color: var(--primary); }
.confirm-body .confirm-title { font-weight: 650; font-size: 0.9375rem; }
.confirm-body .confirm-msg { color: var(--text-muted); font-size: 0.875rem; margin-top: 0.25rem; line-height: 1.5; }

/* Телефон: (почти) цял екран, фиксиран футър с бутоните */
@media (max-width: 639px) {
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal, .modal.modal-lg {
    max-width: none; border-radius: 0; max-height: none;
    height: 100vh; height: 100dvh;
  }
  .modal .modal-head { padding-top: calc(1.125rem + env(safe-area-inset-top, 0px)); }
  .modal .modal-body { flex: 1; }
  .modal .modal-foot {
    border-top: 1px solid var(--border);
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }
  .modal .modal-foot .btn { flex: 1; }
}

/* ── Известия (toast) ───────────────────── */
#toasts {
  position: fixed; top: 1.125rem; right: 1.125rem; z-index: 200;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
  display: flex; align-items: flex-start; gap: 0.625rem;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border);
  padding: 0.6875rem 0.875rem; border-radius: 10px;
  font-size: 0.8125rem; font-weight: 500; line-height: 1.45;
  box-shadow: var(--shadow-md); max-width: 23.75rem;
  animation: toast-in .2s ease;
}
.toast svg { flex-shrink: 0; margin-top: 1px; }
.toast.success svg { color: var(--green); }
.toast.error svg { color: var(--red); }
.toast.info svg { color: var(--primary); }
.toast.leaving { animation: toast-out .18s ease forwards; }
@keyframes toast-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateX(16px); opacity: 0; } }

@media (max-width: 639px) {
  #toasts {
    left: 0.75rem; right: 0.75rem;
    top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 0.5rem);
  }
  .toast { max-width: none; }
}

/* ── Списък отсъстващи / компактни редове ── */
.absent-item {
  display: flex; align-items: center; gap: 0.625rem; padding: 0.5625rem 0;
  border-bottom: 1px solid var(--border-soft); flex-wrap: wrap;
}
.absent-item:last-child { border-bottom: none; }
.absent-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.absent-item .who { font-weight: 600; font-size: 0.875rem; }
.absent-item .what { color: var(--text-muted); font-size: 0.8125rem; margin-left: auto; text-align: right; }
.absent-item.clickable { cursor: pointer; margin: 0 -0.625rem; padding-left: 0.625rem; padding-right: 0.625rem; border-radius: var(--radius-sm); transition: background var(--transition); }
.absent-item.clickable:hover { background: var(--hover); }

/* ── Ленти с инструменти и филтри ───────── */
.toolbar {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin-bottom: 0.875rem;
}
.toolbar .range-label {
  font-weight: 600; font-size: 0.8125rem; margin: 0 0.25rem;
  font-variant-numeric: tabular-nums; color: var(--text-secondary);
}
.toolbar .spacer { margin-left: auto; }
.toolbar .date-input {
  width: auto; padding: 0.3125rem 0.5rem; border: 1px solid var(--border);
  border-radius: 7px; font-size: 0.8125rem; min-height: 2rem;
  background: var(--card); color: var(--text-secondary); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.toolbar .date-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.toolbar .date-input .date-input-field { font-size: 0.8125rem; color: var(--text-secondary); min-width: 8.5rem; }

/* ── Date input + календар (ДД.ММ.ГГГГ г.) ─ */
.date-input {
  display: inline-flex; align-items: center; gap: 0.375rem;
  width: auto; min-width: 9.75rem; max-width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text);
  min-height: 2.5rem; cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-sizing: border-box;
}
.field .date-input { display: flex; width: 100%; }
.date-input:hover { border-color: var(--border-strong); }
.date-input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.date-input.disabled { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }
.date-input .date-input-field {
  flex: 1; min-width: 0; width: auto !important;
  border: none !important; box-shadow: none !important;
  padding: 0 !important; min-height: 0 !important;
  background: transparent !important; color: inherit;
  font: inherit; cursor: pointer; outline: none;
}
.date-input .date-input-field:disabled { cursor: not-allowed; }
.date-input .date-input-field::placeholder { color: var(--text-faint); }
.date-input .date-input-icon { flex-shrink: 0; color: var(--text-muted); pointer-events: none; }

.date-picker {
  position: fixed; z-index: 1200; width: 280px;
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 0.625rem; font-size: 0.8125rem;
  overscroll-behavior: contain;
}
.date-picker.is-mobile {
  width: min(300px, calc(100vw - 16px));
  padding: 0.75rem;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(15, 23, 42, 0.04);
}
.date-picker.is-mobile .date-picker-day {
  min-height: 2.25rem;
  border-radius: 8px;
}
.date-picker.is-mobile .date-picker-nav {
  width: 2.25rem; height: 2.25rem;
}
.date-picker-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.25rem; margin-bottom: 0.5rem;
}
.date-picker-title { font-weight: 650; color: var(--text); font-size: 0.875rem; }
.date-picker-nav { width: 1.75rem; height: 1.75rem; }
.date-picker-dow {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
  margin-bottom: 0.25rem; text-align: center;
  color: var(--text-muted); font-size: 0.6875rem; font-weight: 600;
}
.date-picker-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.date-picker-day {
  appearance: none; border: none; background: transparent;
  width: 100%; aspect-ratio: 1; border-radius: 7px;
  font: inherit; font-variant-numeric: tabular-nums;
  color: var(--text); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.date-picker-day:hover:not(.disabled):not(.empty) { background: var(--hover); }
.date-picker-day.today { font-weight: 700; color: var(--primary); }
.date-picker-day.selected {
  background: var(--primary); color: #fff; font-weight: 650;
}
.date-picker-day.selected.today { color: #fff; }
.date-picker-day.in-range {
  background: var(--primary-soft); color: var(--primary);
  border-radius: 0; font-weight: 550;
}
.date-picker-day.range-start { border-radius: 7px 0 0 7px; }
.date-picker-day.range-end { border-radius: 0 7px 7px 0; }
.date-picker-day.range-start.range-end { border-radius: 7px; }
.date-picker-day.range-start.in-range,
.date-picker-day.range-end.in-range { background: var(--primary); color: #fff; }
.date-picker-hint {
  font-size: 0.75rem; color: var(--text-muted);
  align-self: center; padding: 0 0.25rem;
}
.date-picker.is-range { width: 300px; }
.date-picker.is-range.is-mobile { width: min(300px, calc(100vw - 16px)); }

.date-picker-day.disabled { color: var(--text-faint); cursor: not-allowed; }
.date-picker-day.empty { pointer-events: none; visibility: hidden; }
.date-picker-foot {
  display: flex; justify-content: space-between; gap: 0.5rem;
  margin-top: 0.5rem; padding-top: 0.375rem;
  border-top: 1px solid var(--border-soft);
}

.filters {
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
  margin-bottom: 0.875rem;
}
.filters select {
  padding: 0.375rem 2rem 0.375rem 0.625rem; border: 1px solid var(--border);
  border-radius: 7px; font-size: 0.8125rem; min-height: 2rem;
  background-color: var(--card); color: var(--text-secondary); outline: none;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.5rem center;
  transition: border-color var(--transition), box-shadow var(--transition);
  max-width: 100%;
}
.filters select:hover { border-color: var(--border-strong); }
.filters select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* Сегментиран контрол (период 14/28/42 и др.) */
.seg { display: inline-flex; background: var(--active); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button {
  border: none; background: transparent; padding: 0.25rem 0.6875rem;
  border-radius: 6px; font-size: 0.8125rem; font-weight: 500; color: var(--text-muted);
  min-height: 1.625rem; transition: background var(--transition), color var(--transition);
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow-xs); }

/* Легенда */
.legend { display: flex; gap: 0.875rem 1rem; flex-wrap: wrap; margin: 0.25rem 0 0.875rem; }
.legend .legend-item {
  display: inline-flex; align-items: center; gap: 0.375rem;
  font-size: 0.75rem; color: var(--text-muted);
}
.legend .legend-item .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }

/* ── Проекти ────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 0.3125rem;
  padding: 0.125rem 0.5625rem; border-radius: 99px; font-size: 0.75rem; font-weight: 550;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

.progress-track {
  height: 6px; border-radius: 99px; background: var(--active); overflow: hidden; min-width: 70px;
}
.progress-fill { height: 100%; border-radius: 99px; background: var(--primary); transition: width .25s ease; }

.chip {
  display: inline-flex; align-items: center; gap: 0.375rem;
  background: var(--card); border: 1px solid var(--border);
  padding: 0.1875rem 0.625rem; border-radius: 99px; font-size: 0.75rem; font-weight: 500;
  color: var(--text-secondary);
}
.chip.manager { background: var(--primary-soft); border-color: var(--primary-light); color: var(--primary-dark); font-weight: 600; }

.tabs {
  display: flex; flex-wrap: nowrap; align-items: stretch; gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: clamp(0.75rem, 2vw, 1.125rem) 0 1rem;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: none;
  touch-action: pan-x;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  display: inline-flex; align-items: center; gap: 0.4375rem;
  background: none; border: none; padding: 0.5625rem 0.875rem;
  font-size: 0.875rem; font-weight: 500;
  color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap; flex-shrink: 0;
  touch-action: manipulation;
  transition: color var(--transition), border-color var(--transition);
}
.tabs button.active { color: var(--primary-dark); border-bottom-color: var(--primary); font-weight: 600; }
.tabs button:hover { color: var(--text); }

.project-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-xs); padding: 1.125rem 1.25rem;
  cursor: pointer; transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
  min-width: 0;
}
.project-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }
.project-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(18.5rem, 100%), 1fr));
  gap: var(--gap);
}

/* Канбан дъска */
.board { display: flex; gap: var(--gap); align-items: flex-start; overflow-x: auto; padding-bottom: 0.625rem; }
.board-col {
  background: var(--active); border-radius: var(--radius); padding: 0.5rem;
  width: clamp(16rem, 22vw, 19rem); min-width: min(16rem, 82vw); flex-shrink: 0;
}
.board-col .col-head {
  display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.8125rem;
  padding: 0.375rem 0.5rem 0.625rem;
}
.board-col .col-head .count {
  margin-left: auto; background: var(--card); border: 1px solid var(--border);
  border-radius: 99px; padding: 0 0.5rem;
  font-size: 0.6875rem; font-weight: 600; color: var(--text-muted); line-height: 1.5;
}
.board-col.drag-over { outline: 2px dashed var(--primary); outline-offset: -3px; }
.kanban-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.625rem 0.75rem; margin-bottom: 0.5rem; cursor: grab; box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.kanban-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.kanban-card:active { cursor: grabbing; }
.kanban-card .title { font-weight: 600; font-size: 0.8125rem; margin-bottom: 0.4375rem; line-height: 1.4; }
.kanban-card .meta { display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; font-size: 0.6875rem; color: var(--text-muted); }
.kanban-card.dragging { opacity: .45; }

/* Дърво на задачи */
tr.task-row td { font-size: 0.8125rem; }
tr.task-row.done td { color: var(--text-faint); }
tr.task-row.done .task-title { text-decoration: line-through; }
tr.task-row.overdue td:first-child { box-shadow: inset 3px 0 0 var(--red); }
tr.task-row[draggable="true"] { cursor: grab; }
tr.task-row.drop-above td { border-top: 2px solid var(--primary); }
tr.task-row.drop-below td { border-bottom: 2px solid var(--primary); }
/* Списък задачи: колоната „Задача“ = ширината на най-дългото заглавие (без пренос → по-ниски редове) */
table.data.tasks-list {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
}
table.data.tasks-list th.col-task,
table.data.tasks-list td.col-task {
  white-space: nowrap;
  width: 1%; /* shrink-to-fit съдържанието */
  vertical-align: middle;
}
table.data.tasks-list .task-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  max-width: none;
}
table.data.tasks-list .task-title {
  white-space: nowrap;
}
table.data.tasks-list.compact th,
table.data.tasks-list.compact td {
  padding-top: 0.22rem;
  padding-bottom: 0.22rem;
}
.task-title { font-weight: 550; cursor: pointer; color: var(--text); }
.task-title:hover { color: var(--primary); }
.task-title-input {
  width: min(36rem, 70vw);
  min-width: 12rem;
  max-width: 100%;
  font: inherit;
  font-weight: 550;
  font-size: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--primary);
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-light);
}
tr.task-row.is-draft td { background: var(--primary-soft); }
tr.task-row.is-subtask .task-title-input { font-weight: 500; }
.subtask-indent { color: var(--border-strong); margin-right: 0.25rem; font-size: 0.7rem; }

/* По-тесни редове + по-малък шрифт за подзадачи */
tr.task-row.is-subtask td { font-size: 0.72rem; color: var(--text-secondary); }
tr.task-row.is-subtask .task-title { font-weight: 500; font-size: 0.72rem; }
tr.task-row.is-subtask .inline-select,
tr.task-row.is-subtask .inline-cell-btn {
  font-size: 0.7rem;
  min-height: 1.45rem;
  padding-top: 0.1rem;
  padding-bottom: 0.1rem;
}
tr.task-row.is-subtask .pill { font-size: 0.65rem; padding: 0.05rem 0.4rem; }
tr.task-row.is-subtask .task-check { width: 1.35rem; height: 1.35rem; }

.task-fold {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.15rem;
  width: auto; min-width: 1.25rem; height: 1.25rem; padding: 0 0.15rem;
  margin-right: 0.15rem; border: none; border-radius: 5px;
  background: transparent; color: var(--text-muted); cursor: pointer;
  flex-shrink: 0; vertical-align: middle;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}
.task-fold svg {
  transition: transform 0.15s ease;
  transform: rotate(90deg);
}
.task-fold.is-collapsed svg { transform: rotate(0deg); }
.task-fold:hover { background: var(--active); color: var(--text); }
.task-fold-count {
  font-size: 0.65rem; font-weight: 650; font-variant-numeric: tabular-nums;
  color: var(--text-muted); line-height: 1;
}
.task-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; border-radius: 6px; cursor: pointer;
  color: var(--text-faint); transition: background var(--transition), color var(--transition);
}
.task-check:hover { background: var(--active); color: var(--green); }
.task-check.checked { color: var(--green); }

/* Inline редакция в списъка със задачи */
td.td-inline { vertical-align: middle; }
.inline-select {
  appearance: none; -webkit-appearance: none;
  max-width: 100%; min-width: 0;
  padding: 0.2rem 1.4rem 0.2rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--pill-color, var(--border)) 45%, var(--border));
  border-radius: 999px;
  background:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%) calc(100% - 12px) / 5px 5px no-repeat,
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%) calc(100% - 7px) / 5px 5px no-repeat,
    color-mix(in srgb, var(--pill-color, var(--primary)) 14%, transparent);
  color: var(--pill-color, var(--text));
  font: inherit; font-size: 0.75rem; font-weight: 600;
  cursor: pointer; outline: none;
}
.inline-select:hover, .inline-select:focus {
  border-color: var(--pill-color, var(--primary));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--pill-color, var(--primary)) 18%, transparent);
}
.inline-cell-btn {
  display: inline-block; max-width: 100%;
  border: 1px dashed transparent; border-radius: 6px;
  background: transparent; color: inherit; font: inherit; font-size: 0.75rem;
  padding: 0.2rem 0.35rem; text-align: left; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.inline-cell-btn:hover:not(:disabled), .inline-cell-btn:focus-visible {
  border-color: var(--border-strong); background: var(--hover);
}
.inline-cell-btn.is-readonly { cursor: default; }
.inline-cell-btn.is-overdue { color: var(--red); font-weight: 600; }
.inline-assignees { position: relative; min-width: 0; }
.inline-assignee-panel {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0;
  min-width: 14rem; max-width: 18rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  padding: 0.35rem;
}
.inline-assignee-list { max-height: 12rem; overflow-y: auto; }
.inline-assignee-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.4rem; border-radius: 6px;
  font-size: 0.8125rem; cursor: pointer; color: var(--text);
}
.inline-assignee-row:hover { background: var(--hover); }
.inline-assignee-row input { margin: 0; accent-color: var(--primary); }
.inline-assignee-foot {
  display: flex; justify-content: flex-end;
  padding: 0.35rem 0.25rem 0.15rem; border-top: 1px solid var(--border-soft);
  margin-top: 0.25rem;
}
.inline-due-picker { min-width: 9.5rem; }

/* ── Хора × дни календар (обзор на екипа) ── */
.pcal {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow-x: auto; overscroll-behavior-x: contain;
}
.pcal-inner { position: relative; }
.pcal-hrow { display: flex; border-bottom: 1px solid var(--border); }
.pcal-corner {
  position: sticky; left: 0; z-index: 4; flex-shrink: 0;
  background: var(--bg); border-right: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 0.75rem;
  font-size: 0.6875rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted);
}
.pcal-hday {
  flex-shrink: 0; text-align: center; background: var(--bg);
  font-size: 0.625rem; line-height: 1.3; color: var(--text-muted);
  padding-top: 0.25rem; position: relative;
}
.pcal-hday .mo { color: var(--brand); font-weight: 700; font-size: 0.5625rem; text-transform: uppercase; letter-spacing: .04em; }
.pcal-hday .dn { font-weight: 600; font-size: 0.6875rem; color: var(--text-secondary); }
.pcal-hday .wd { font-weight: 400; color: var(--text-faint); }
.pcal-hday.rest { background: var(--active); }
.pcal-hday.rest .dn { color: var(--text-faint); }
.pcal-hday.today .dn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.125rem; height: 1.125rem; border-radius: 6px;
  background: var(--primary); color: #fff;
}
.pcal-row { display: flex; border-bottom: 1px solid var(--border-soft); }
.pcal-row:last-child { border-bottom: none; }
.pcal-name {
  position: sticky; left: 0; z-index: 3; flex-shrink: 0;
  background: var(--card); border-right: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.5rem; padding: 0 0.625rem;
  font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary);
}
.pcal-name .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcal-track { position: relative; flex-shrink: 0; }
.pcal-cell { position: absolute; top: 0; bottom: 0; }
.pcal-cell.rest {
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.pcal-cell.rest .hol { font-size: 0.5625rem; font-weight: 600; color: var(--text-faint); }
.pcal-cell.today { background: var(--primary-soft); }
.pcal-extra {
  position: absolute; top: 0; height: 100%; pointer-events: none;
  display: flex; justify-content: flex-end; align-items: flex-start;
  padding: 1px 3px; z-index: 2;
}
.pcal-extra > * { pointer-events: auto; }
.pcal-bday { font-size: 0.625rem; color: #d946ef; line-height: 1; cursor: default; }
.pcal-leave {
  position: absolute; top: 4px; bottom: 4px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.5625rem; font-weight: 700; color: #fff;
}
.pcal-bar {
  position: absolute; border-radius: 5px; overflow: hidden; color: #fff;
  font-size: 0.5625rem; font-weight: 600; line-height: 1;
  display: flex; align-items: center; padding: 0 0.375rem;
  white-space: nowrap; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
  transition: filter var(--transition);
}
.pcal-bar.clickable { cursor: pointer; }
.pcal-bar.clickable:hover { filter: brightness(1.08); }

/* ── Времева линия ──────────────────────── */
.tl-wrap { overflow-x: auto; }
.tl-grid { border-collapse: collapse; table-layout: fixed; }
.tl-grid th, .tl-grid td { padding: 0; border: none; }
.tl-grid thead th { border-bottom: 1px solid var(--border); }
.tl-grid tbody td { border-bottom: 1px solid var(--border-soft); }
.tl-grid tbody tr:last-child td { border-bottom: none; }
.tl-bar { height: 14px; border-radius: 6px; position: relative; }

/* ── Кутии със списъци (екипи, отговорници) ─ */
.scroll-box {
  max-height: 11.25rem; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}
.member-row {
  display: flex; align-items: center; gap: 0.625rem;
  font-size: 0.8125rem; padding: 0.375rem 0.5rem; cursor: pointer;
  color: var(--text-secondary); border-radius: 7px; margin: 0 -0.25rem;
  line-height: 1.25;
}
.member-row:hover { background: var(--hover); color: var(--text); }
.member-row.is-active { background: var(--primary-soft); color: var(--primary-dark); }
.member-row input[type="checkbox"] {
  width: 1rem; height: 1rem; margin: 0; flex-shrink: 0;
  accent-color: var(--primary);
}
.member-row .member-name {
  flex: 1; min-width: 0; display: flex; align-items: center;
  line-height: 1.25;
}
.member-row .tag-pm {
  font-size: 0.6875rem; color: var(--primary); font-weight: 650;
  flex-shrink: 0; line-height: 1;
}

/* Typeahead / екип в модали */
.combo {
  position: relative; width: 100%;
  display: block; overflow: visible;
}
.combo-input {
  width: 100%; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; background: var(--card); color: var(--text);
  min-height: 2.5rem; font: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.combo-input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.combo-clear {
  position: absolute; right: 0.35rem; top: 50%; transform: translateY(-50%);
  width: 1.75rem; height: 1.75rem; z-index: 1;
}
.combo:has(.combo-clear:not([hidden])) .combo-input { padding-right: 2.25rem; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  width: 100%; box-sizing: border-box;
  max-height: 14rem; overflow-y: auto;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  padding: 0.25rem; z-index: 50;
}
.combo-list[hidden] { display: none !important; }
/* Модалът иначе клипва absolute dropdown заради overflow-y:auto */
.modal:has(.combo-list:not([hidden])),
.modal:has(.combo-list:not([hidden])) .modal-body {
  overflow: visible;
}
.combo-option {
  display: block; width: 100%; text-align: left;
  border: none; background: transparent; color: var(--text);
  padding: 0.5rem 0.625rem; border-radius: 6px;
  font: inherit; font-size: 0.8125rem; cursor: pointer;
}
.combo-option:hover, .combo-option.active { background: var(--primary-soft); color: var(--primary-dark); }
.combo-option.selected { font-weight: 600; }
.combo-empty {
  padding: 0.625rem; font-size: 0.8125rem; color: var(--text-muted); text-align: center;
}
.person-chips { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; overflow: visible; }
.chip-row {
  display: flex; flex-wrap: wrap; gap: 0.375rem;
  min-height: 0;
}
.chip-row[hidden] { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 0.25rem;
  max-width: 100%;
  padding: 0.3rem 0.3rem 0.3rem 0.625rem;
  background: var(--primary-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8125rem; color: var(--text); line-height: 1.2;
}
.chip-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 14rem;
}
.chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.375rem; height: 1.375rem; flex-shrink: 0;
  border: none; border-radius: 6px;
  background: transparent; color: var(--text-muted); cursor: pointer;
  padding: 0;
}
.chip-x:hover { background: var(--hover); color: var(--text); }
.project-form { display: flex; flex-direction: column; gap: 0.125rem; overflow: visible; }
.project-form .field { margin-bottom: 0.875rem; overflow: visible; }

/* Коментари и история в задача */
.comment-item { padding: 0.5rem 0; border-bottom: 1px solid var(--border-soft); font-size: 0.8125rem; }
.comment-item:last-child { border-bottom: none; }
.comment-item .c-head { display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; }
.comment-item .c-time { color: var(--text-faint); font-size: 0.6875rem; white-space: nowrap; }
.comment-item .c-msg { margin-top: 2px; white-space: pre-wrap; color: var(--text-secondary); }

/* Редове с баланси (редакция на служител) */
.balance-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.3125rem 0;
}
.balance-row label { font-size: 0.8125rem; color: var(--text-secondary); }

/* ── Мрежа стажанти (месец × дни) ────────── */
table.igrid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.8125rem; }
table.igrid th {
  background: var(--bg); color: var(--text-muted);
  font-size: 0.625rem; font-weight: 600; text-align: center;
  padding: 0.25rem 0; line-height: 1.35; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.igrid th.name-col, table.igrid td.name-col {
  position: sticky; left: 0; z-index: 2; background: var(--card);
  text-align: left; padding: 0.375rem 0.75rem; border-right: 1px solid var(--border);
}
table.igrid th.name-col { background: var(--bg); font-size: 0.6875rem; text-transform: uppercase; letter-spacing: .05em; }
table.igrid th.today { color: var(--primary-dark); }
table.igrid th.today .d { background: var(--primary); color: #fff; border-radius: 6px; padding: 0 4px; }
table.igrid td { border-bottom: 1px solid var(--border-soft); }
table.igrid td.cell {
  height: 2.25rem; text-align: center; font-weight: 600; font-size: 0.6875rem;
  border-right: 1px solid var(--border-soft);
}
table.igrid td.cell.rest { background: var(--bg); }
table.igrid td.cell.today { background: var(--primary-soft); }
table.igrid td.cell.filled-full { background: var(--green-light); color: var(--green-dark); }
table.igrid td.cell.filled-part { background: var(--primary-light); color: var(--primary-dark); }
table.igrid td.cell.editable { cursor: pointer; transition: box-shadow var(--transition); }
table.igrid td.cell.editable:hover { box-shadow: inset 0 0 0 2px var(--primary); }
table.igrid td.total {
  text-align: right; font-weight: 700; color: var(--primary-dark);
  padding: 0.375rem 0.875rem; white-space: nowrap; font-variant-numeric: tabular-nums;
}

/* ═══ Модул „Продажби" (интегриран QuotationTrack) ═══ */

/* Оформление на офертната форма: 3 адаптивни колони */
.offer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(21rem, 100%), 1fr));
  gap: var(--gap);
}

/* Секционни подзаглавия във форми/калкулатори */
.spec-sec-title {
  font-size: 0.6875rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted);
  padding-bottom: 0.375rem; margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-soft);
}

/* Chip-групи (статуси, режими, гаранция) */
.chip-group { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.chip-btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text-secondary);
  border-radius: 999px; padding: 0.375rem 0.75rem; font-size: 0.8125rem; font-weight: 500;
  cursor: pointer; transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.chip-btn:hover { border-color: var(--border-strong); background: var(--hover); }
.chip-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* Редове „етапи" и timeline във формата */
.stage-row {
  display: flex; align-items: center; gap: 0.4375rem; margin-bottom: 0.375rem; flex-wrap: wrap;
}
.stage-row input[type="text"] { flex: 1; min-width: 7rem; }
.timeline-row {
  display: grid; grid-template-columns: 8.5rem 1fr 2rem; align-items: center;
  gap: 0.5rem; margin-bottom: 0.375rem;
}
.timeline-row .tl-label { font-size: 0.75rem; color: var(--text-muted); }
.timeline-row .date-input { width: 100%; display: flex; min-height: 2.25rem; padding: 0.375rem 0.625rem; }

/* ── Редактор на спецификации ── */
.spec-count {
  margin-left: 0.375rem; background: var(--primary-light); color: var(--primary-dark);
  border-radius: 999px; font-size: 0.6875rem; font-weight: 700; padding: 0 0.375rem;
}
.tabs button.active .spec-count { background: var(--primary); color: #fff; }
table.spec-table th, table.spec-table td {
  min-width: 5rem; max-width: 22rem;
}
table.spec-table [contenteditable] {
  outline: none; white-space: pre-wrap; min-height: 1.2em; cursor: text;
}
table.spec-table [contenteditable]:focus {
  box-shadow: inset 0 0 0 2px var(--primary); border-radius: 4px;
}
table.spec-table tr.spec-head-row th { background: var(--bg); font-weight: 650; }
table.spec-table .spec-del-cell { width: 2.25rem; text-align: center; padding: 0.25rem; }
.spec-row-del { opacity: .35; }
table.spec-table tr:hover .spec-row-del { opacity: 1; }
.spec-total {
  display: flex; justify-content: flex-end; gap: 0.5rem; align-items: baseline;
  padding: 0.625rem 0.25rem 0; font-size: 0.875rem;
}
.spec-total strong { color: var(--primary-dark); font-variant-numeric: tabular-nums; }

/* ── Калкулатори ── */
.calc-row {
  display: grid; align-items: center; gap: 0.4375rem; padding: 0.25rem 0;
}
.calc-row.calc-head {
  font-size: 0.6875rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-faint); padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border-soft); margin-bottom: 0.25rem;
}
.calc-row.labor-row { grid-template-columns: minmax(9rem, 2.2fr) minmax(9rem, 1.6fr) 5rem 5rem minmax(6rem, 1fr) 2rem; }
.calc-row.travel-row { grid-template-columns: minmax(8rem, 1.6fr) minmax(8rem, 1.3fr) 4rem 4rem 5rem 5rem minmax(5.5rem, 1fr) 2rem; }
.calc-row.comp-row { grid-template-columns: 1fr 5.5rem 7rem minmax(6rem, 1fr) 2rem; }
.calc-total-cell { text-align: right; font-weight: 600; font-size: 0.8125rem; font-variant-numeric: tabular-nums; color: var(--text); }
.calc-subtotal {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0.75rem; margin-top: 0.5rem;
  background: var(--bg); border-radius: var(--radius-sm);
}
.calc-subtotal strong { color: var(--brand); font-variant-numeric: tabular-nums; }
.rates-grid {
  display: grid; grid-template-columns: 6rem repeat(3, 1fr); gap: 0.375rem 0.5rem; align-items: center;
}
.rates-grid .rates-h { font-size: 0.6875rem; font-weight: 600; color: var(--text-muted); text-align: center; }
.conveyor-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(11rem, 100%), 1fr));
  gap: 0.5rem 0.75rem;
}
.conveyor-grid .cfield { display: flex; flex-direction: column; gap: 0.1875rem; }
.conveyor-grid .cfield label { font-size: 0.6875rem; font-weight: 550; color: var(--text-muted); }
.breakdown { display: flex; flex-direction: column; gap: 0.125rem; }
.breakdown-row {
  display: grid; grid-template-columns: 1fr 6rem 6rem 6rem; gap: 0.375rem;
  font-size: 0.75rem; padding: 0.1875rem 0; border-bottom: 1px solid var(--border-soft);
}
.breakdown-row .b-qty, .breakdown-row .b-price, .breakdown-row .b-total { text-align: right; font-variant-numeric: tabular-nums; }
.breakdown-row .b-total { font-weight: 600; }

/* ── Настройки продажби / статистика ── */
.settings-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr));
  gap: var(--gap); margin-bottom: clamp(1rem, 2vw, 1.5rem);
}
.stack-bar {
  display: flex; height: 1.25rem; border-radius: 999px; overflow: hidden;
  background: var(--active);
}
.stack-bar > div { height: 100%; }

/* Продажби: калкулаторите на телефон скролират таблиците хоризонтално */
@media (max-width: 767px) {
  .calc-row.labor-row, .calc-row.travel-row, .calc-row.comp-row { grid-template-columns: 1fr; gap: 0.25rem; }
  .calc-row.calc-head { display: none; }
  .timeline-row { grid-template-columns: 7rem 1fr 2rem; }
}

/* ── Помощни ────────────────────────────── */
.muted { color: var(--text-muted); }
.text-sm { font-size: 0.8125rem; }
.link {
  display: inline-flex; align-items: center; gap: 0.25rem;
  color: var(--primary); text-decoration: none; font-weight: 550; font-size: 0.8125rem;
}
.link:hover { color: var(--primary-dark); text-decoration: underline; }

/* ── CRM: pipeline, сделки, времева линия ── */
.crm-page { min-width: 0; }
.main:has(.crm-page) {
  max-width: none;
}
.crm-board {
  display: flex; gap: var(--gap); align-items: stretch;
  overflow-x: auto; overflow-y: hidden;
  overscroll-behavior-x: contain;
  padding-bottom: 0.75rem;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}
.crm-board::-webkit-scrollbar { height: 10px; }
.crm-board::-webkit-scrollbar-track {
  background: var(--active); border-radius: 99px;
}
.crm-board::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 99px;
}
.crm-board::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
.crm-board .board-col {
  display: flex; flex-direction: column;
  width: 17.5rem; min-width: 17.5rem; max-width: 17.5rem;
  flex-shrink: 0;
  max-height: calc(100dvh - 13.5rem);
}
.crm-board .crm-col-cards {
  flex: 1; min-height: 4rem;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  padding-right: 0.125rem;
  scrollbar-gutter: stable;
}
.crm-board .crm-col-cards.drag-over {
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
  border-radius: 8px;
}
.crm-card.drop-before {
  box-shadow: 0 -3px 0 0 var(--primary);
}
.crm-card.drop-after {
  box-shadow: 0 3px 0 0 var(--primary);
}
.crm-board .crm-col-cards::-webkit-scrollbar { width: 8px; }
.crm-board .crm-col-cards::-webkit-scrollbar-track {
  background: transparent;
}
.crm-board .crm-col-cards::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 99px;
}
.crm-board .crm-endzones {
  align-self: stretch;
  max-height: calc(100dvh - 13.5rem);
}

.crm-kpis {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(11.5rem, 100%), 1fr));
  margin-bottom: 0.875rem;
}
.crm-search {
  flex: 1; min-width: min(14rem, 100%);
  padding: 0.375rem 0.625rem; border: 1px solid var(--border);
  border-radius: 7px; font-size: 0.8125rem; min-height: 2rem;
  background: var(--card); color: var(--text); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.crm-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.crm-col-value {
  font-size: 0.6875rem; font-weight: 600; color: var(--text-faint);
  padding: 0 0.5rem 0.5rem; font-variant-numeric: tabular-nums;
}
.crm-card-company {
  display: flex; align-items: center; gap: 0.3125rem;
  font-size: 0.75rem; color: var(--text-secondary); margin: -0.25rem 0 0.4375rem;
}
.crm-card-value { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.crm-ind {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 0.6875rem; font-weight: 600; color: var(--text-muted);
}
.crm-ind.red { color: var(--red); }
.crm-owner .avatar { width: 1.375rem; height: 1.375rem; font-size: 0.5625rem; }

.crm-endzones {
  display: flex; flex-direction: column; gap: 0.5rem; flex-shrink: 0;
  width: 8.5rem;
}
.crm-endzone {
  display: flex; align-items: center; justify-content: center; gap: 0.375rem;
  border: 2px dashed color-mix(in srgb, var(--zone-color) 45%, transparent);
  color: var(--zone-color); border-radius: var(--radius);
  padding: 1.125rem 0.625rem; font-size: 0.8125rem; font-weight: 650;
  background: color-mix(in srgb, var(--zone-color) 6%, transparent);
  transition: background var(--transition), border-color var(--transition);
}
.crm-endzone.drag-over {
  background: color-mix(in srgb, var(--zone-color) 16%, transparent);
  border-color: var(--zone-color); outline: none;
}

/* Детайл на сделка */
.crm-banner {
  display: flex; align-items: center; gap: 0.5rem;
  border-radius: var(--radius-sm); padding: 0.625rem 0.875rem;
  font-size: 0.875rem; font-weight: 600; margin-bottom: 0.875rem;
}
.crm-banner.won { background: var(--green-light); color: var(--green-dark); }
.crm-banner.lost { background: var(--red-light); color: var(--red-dark); }
.crm-deal-info {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
  gap: 0.25rem 1.5rem; padding: var(--pad-card);
}
.crm-info-row { display: flex; gap: 0.75rem; font-size: 0.875rem; padding: 0.25rem 0; min-width: 0; }
.crm-info-row a { color: var(--primary); text-decoration: none; }
.crm-info-row a:hover { text-decoration: underline; }
.crm-info-label { color: var(--text-muted); width: 7.5rem; flex-shrink: 0; }
.crm-info-notes {
  grid-column: 1 / -1; font-size: 0.875rem; color: var(--text-secondary);
  white-space: pre-wrap; border-top: 1px solid var(--border-soft);
  padding-top: 0.625rem; margin-top: 0.375rem;
}

/* Детайл на сделка */
.crm-deal-page { display: flex; flex-direction: column; gap: 0.875rem; }
.crm-back-link {
  font-size: 0.8125rem; display: inline-flex; align-items: center; gap: 4px;
  text-decoration: none; color: var(--text-muted);
}
.crm-back-link:hover { color: var(--primary); }
.crm-deal-title { margin-top: 0.25rem; letter-spacing: -0.02em; line-height: 1.25; }
.crm-deal-meta { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.5rem; flex-wrap: wrap; }
.crm-owner-chip { display: inline-flex; align-items: center; gap: 0.375rem; }
.crm-metrics {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.625rem;
}
.crm-metric {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.75rem 0.875rem;
}
.crm-metric-label { font-size: 0.6875rem; font-weight: 600; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 0.25rem; }
.crm-metric-value { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; color: var(--text); }
.crm-metric-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem; }
.crm-deal-grid {
  display: grid; grid-template-columns: minmax(15rem, 18.5rem) minmax(0, 1fr);
  gap: 0.875rem; align-items: start;
}
.crm-deal-aside { padding: 1rem 1.125rem; position: sticky; top: 0.75rem; }
.crm-aside-title {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); margin: 0 0 0.75rem;
}
.crm-side-list { display: flex; flex-direction: column; gap: 0.75rem; }
.crm-side-row { min-width: 0; }
.crm-side-label { font-size: 0.6875rem; font-weight: 600; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 0.2rem; }
.crm-side-value { font-size: 0.875rem; color: var(--text); word-break: break-word; }
.crm-side-value a { color: var(--primary); text-decoration: none; }
.crm-side-value a:hover { text-decoration: underline; }
.crm-tag-list { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.crm-aside-notes {
  margin-top: 1rem; padding-top: 0.875rem; border-top: 1px solid var(--border-soft);
}
.crm-aside-notes .tl-details { margin-top: 0.25rem; font-size: 0.8125rem; }
.crm-deal-content { min-width: 0; display: flex; flex-direction: column; gap: 0.75rem; }

.crm-composer {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.875rem; margin-bottom: 0.75rem;
}
.crm-composer-top { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.625rem; }
.crm-composer-input {
  width: 100%; min-height: 4.5rem; resize: vertical; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.625rem 0.75rem; font: inherit;
  background: var(--bg); color: var(--text);
}
.crm-composer-input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.crm-composer-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  margin-top: 0.625rem; flex-wrap: wrap;
}
.crm-filter-bar { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-bottom: 0.625rem; }
.crm-filter-chip {
  border: 1px solid var(--border); background: var(--card); color: var(--text-secondary);
  border-radius: 999px; padding: 0.25rem 0.7rem; font-size: 0.75rem; font-weight: 550;
  cursor: pointer;
}
.crm-filter-chip:hover { background: var(--active); color: var(--text); }
.crm-filter-chip.active {
  background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  color: var(--primary-dark);
}

/* Времева линия */
.tl-list { display: flex; flex-direction: column; padding: 0.25rem 0.875rem; }
.tl-item { display: flex; gap: 0.75rem; padding: 0.75rem 0; position: relative; }
.tl-item + .tl-item { border-top: 1px solid var(--border-soft); }
.tl-item.tl-comment { padding: 0.875rem 0; }
.tl-icon {
  width: 1.75rem; height: 1.75rem; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--tl-color) 13%, transparent);
  color: var(--tl-color); margin-top: 2px;
}
.tl-avatar { flex-shrink: 0; margin-top: 2px; }
.tl-avatar .avatar { width: 1.75rem; height: 1.75rem; font-size: 0.625rem; }
.tl-body { min-width: 0; flex: 1; }
.tl-head {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  font-size: 0.8125rem;
}
.tl-time { margin-left: auto; font-size: 0.6875rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.tl-delete { opacity: 0.45; margin-left: 0.125rem; }
.tl-item:hover .tl-delete { opacity: 1; }
.tl-title { font-size: 0.8125rem; font-weight: 600; margin-top: 2px; }
.tl-details {
  font-size: 0.875rem; color: var(--text-secondary); white-space: pre-wrap; margin-top: 0.35rem;
  line-height: 1.45;
}
.tl-details a { color: var(--primary); word-break: break-all; }
.tl-comment .tl-details {
  background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem; color: var(--text);
}

@media (max-width: 1023px) {
  .crm-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-deal-grid { grid-template-columns: 1fr; }
  .crm-deal-aside { position: static; }
}
@media (max-width: 560px) {
  .crm-metrics { grid-template-columns: 1fr 1fr; }
  .crm-metric-value { font-size: 1rem; }
}

/* Задачи по сделка */
.crm-task {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.4375rem 0; font-size: 0.875rem; flex-wrap: wrap;
}
.crm-task + .crm-task { border-top: 1px solid var(--border-soft); }
.crm-task.done .crm-task-title { text-decoration: line-through; color: var(--text-faint); }
.crm-task.overdue .crm-task-title { color: var(--red); }
.crm-task-title { font-weight: 550; }

/* Прикачени файлове по сделка */
.crm-file-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.625rem 0.5rem; border-bottom: 1px solid var(--border-soft);
}
.crm-file-row:last-child { border-bottom: none; }
.crm-file-icon {
  display: flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; flex-shrink: 0;
  border-radius: 8px; background: var(--primary-soft); color: var(--primary);
}
.crm-file-meta { flex: 1; min-width: 0; }
.crm-file-name {
  font-weight: 600; font-size: 0.875rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crm-file-actions { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }

/* Ghost бутон в червено (Загубена и др.) */
.btn-danger-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--red);
}
.btn-danger-ghost:hover { background: var(--red-light); border-color: var(--red); }

/* Анализи */
.crm-stats-grid {
  display: grid; gap: var(--gap); margin-bottom: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(24rem, 100%), 1fr));
}
.crm-hbar { margin-bottom: 0.5rem; }
.crm-hbar-head {
  display: flex; justify-content: space-between; gap: 0.75rem;
  font-size: 0.8125rem; margin-bottom: 3px; font-weight: 550;
}
.crm-hbar-track { height: 8px; border-radius: 99px; background: var(--active); overflow: hidden; }
.crm-hbar-fill { height: 100%; border-radius: 99px; transition: width .25s ease; }
.crm-vbars {
  display: flex; gap: 0.5rem; align-items: stretch;
  min-height: 9rem; padding-top: 0.25rem; overflow-x: auto;
}
.crm-vbar { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; min-width: 2.75rem; }
.crm-vbar-value { font-size: 0.625rem; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.crm-vbar-col { flex: 1; width: 100%; max-width: 2.5rem; display: flex; align-items: flex-end; background: var(--active); border-radius: 6px; overflow: hidden; }
.crm-vbar-fill { width: 100%; border-radius: 6px 6px 0 0; }
.crm-vbar-label { font-size: 0.6875rem; color: var(--text-muted); }

/* ── Превключвател на езика ── */
.lang-box { padding: 0.375rem 0.875rem 0.625rem; }
.lang-box .seg { width: 100%; display: flex; }
.lang-box .seg button { flex: 1; }

/* ── Оферти: лепкав header с живо резюме ── */
.offer-head {
  position: sticky; top: 0; z-index: 30;
  background: var(--bg);
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border-soft);
}
@media (max-width: 1023px) {
  .offer-head { top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); }
}
.offer-live {
  display: flex; gap: 0.875rem; align-items: center; flex-wrap: wrap;
  margin-top: 4px; font-size: 0.8125rem; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.offer-live strong { font-weight: 700; color: var(--text); }

/* Обобщение на спецификациите (суми по табове + общо) */
.spec-summary {
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
  margin-bottom: 0.625rem;
}
.spec-summary:empty { display: none; }
.spec-sum-chip { cursor: pointer; gap: 0.5rem; transition: border-color var(--transition), background var(--transition); }
.spec-sum-chip:hover { border-color: var(--primary); }
.spec-sum-chip.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.spec-sum-chip strong { font-variant-numeric: tabular-nums; }
.spec-sum-grand { font-size: 0.8125rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.spec-sum-grand strong { color: var(--text); }

/* Спецификации: разширени операции под таблицата */
.spec-advanced {
  margin-top: 0.75rem; padding-top: 0.5rem;
  border-top: 1px dashed var(--border-soft);
}
.spec-advanced .link { background: none; border: none; padding: 0; }
/* Вграденият калкулатор в таба: header-ът му не е лепкав */
.spec-editor .page-head { position: static; border-bottom: none; padding: 0; }

/* ── Плавна поява на изгледите при навигация ── */
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } }
.main > * { animation: view-in .16s ease-out; }

/* ── Skeleton loader (утилита за поетапно зареждане) ── */
.skeleton {
  background: linear-gradient(90deg, var(--active) 25%, var(--border-soft) 50%, var(--active) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  border-radius: var(--radius-sm);
  color: transparent; user-select: none;
}
@keyframes skeleton-shimmer { to { background-position: -200% 0; } }
