/* CRM ARENA BUD — стилі */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f1f5f9; --card: #ffffff; --border: #e2e8f0;
  --text: #0f172a; --muted: #64748b;
  --primary: #2563eb; --primary-dark: #1d4ed8;
  --sidebar: #1e293b; --sidebar-text: #e2e8f0;
  --input: #ffffff; --hover: #f8fafc; --row-border: #f1f5f9;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0a1020; --card: #111a2b; --border: #26344a;
  --text: #e6edf7; --muted: #94a3b8;
  --primary: #3b82f6; --primary-dark: #2563eb;
  --sidebar: #050a14; --sidebar-text: #cbd5e1;
  --input: #0d1627; --hover: #162238; --row-border: #1f2b3d;
  color-scheme: dark;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  transition: background-color 0.2s, color 0.2s;
}

/* Каркас */
.layout { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; }
.app-header {
  position: sticky; top: 0; z-index: 20; height: 64px; display: flex;
  align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px;
  border-bottom: 1px solid var(--border); background: var(--card);
}
.app-header-context { display: flex; align-items: center; gap: 9px; color: var(--text); }
.app-header-icon { display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; color: var(--primary); }
.app-header-icon svg { display: block; width: 22px; height: 22px; }
.app-header-context strong { color: var(--text); font-size: 18px; }
.app-header-user { display: flex; align-items: center; gap: 12px; }
.header-user-copy { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.header-user-copy b { color: var(--muted); font-size: 12px; font-weight: 600; }
.header-user-copy span { color: var(--text); font-size: 12px; }
.header-user-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  padding: 0; border: 0; background: transparent; color: #fff;
  font-size: 12px; font-weight: 750; cursor: pointer;
}
.theme-toggle {
  display: inline-flex; align-items: center; gap: 8px; min-width: 102px;
  justify-content: center; padding: 7px 11px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--input); color: var(--text); cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600;
  transition: border-color 0.16s, background 0.16s;
}
.theme-toggle:hover { border-color: var(--primary); background: var(--hover); }
.theme-toggle span { display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; background: var(--hover);
  color: var(--primary); font-size: 15px; }
.sidebar {
  width: 220px; background: var(--sidebar); color: var(--sidebar-text);
  padding: 20px 10px; display: flex; flex-direction: column; gap: 10px;
  position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.logo { display: flex; flex-direction: column; gap: 10px; }
.logo-login { align-items: center; margin-bottom: 6px; }
.logo-sidebar { padding: 0 10px 18px; border-bottom: 1px solid #334155; }
.logo-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: fit-content; max-width: 100%;
  background: transparent; padding: 0;
}
.logo-image { display: block; width: 112px; max-width: 100%; height: auto; }
.logo-image-login { width: 144px; }
.logo-sidebar .logo-image { filter: brightness(0) invert(1); }
.logo-sub {
  font-size: 12px; font-weight: 600; color: #94a3b8;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.sidebar nav { display: flex; flex-direction: column; flex: 1; overflow-y: auto; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.sidebar-section {
  margin: 14px 5px 4px; color: #94a3b8; font-size: 12px; font-weight: 650;
  letter-spacing: 0.1em; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 15px;
  background: none; border: none; color: var(--sidebar-text); font-size: 12px;
  border-radius: 6px; cursor: pointer; text-align: left; width: 100%;
}
.nav-item:hover { background: rgba(255,255,255,0.07); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; flex: 0 0 20px; color: currentColor; }
.nav-icon svg { display: block; width: 17px; height: 17px; }
.nav-label { flex: 1; }
.sidebar-foot { font-size: 12px; color: #475569; padding: 0 10px; }
.sidebar-user { padding: 10px; border-top: 1px solid #1e293b; color: #e2e8f0; }
.sidebar-profile-button {
  display: flex; align-items: center; gap: 9px; width: 100%; min-width: 0;
  padding: 0; border: 0; background: transparent; color: #e2e8f0;
  font-family: inherit; text-align: left; cursor: pointer;
}
.sidebar-profile-button > span:last-child { min-width: 0; }
.sidebar-profile-button b, .sidebar-profile-button small {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-profile-button b { font-size: 12px; }
.sidebar-profile-button small { margin-top: 2px; color: #94a3b8; font-size: 12px; }
.btn-logout { margin-top: 8px; width: 100%; background: transparent; color: #94a3b8;
  border-color: #334155; }
.btn-logout:hover { background: #1e293b; color: #fff; }

/* Екран входу */
.login-wrap { display: flex; align-items: center; justify-content: center;
  min-height: 100vh; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px; width: 100%; max-width: 360px;
  box-shadow: 0 10px 30px rgba(15,23,42,0.08); }
.login-card input { width: 100%; }
.content { flex: 1; padding: 24px; max-width: 1600px; min-width: 0; }

/* Заголовки, картки */
.page-head { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
h1 { font-size: 22px; }
h3 { font-size: 15px; margin-bottom: 12px; }
h4 { font-size: 13px; margin: 12px 0 8px; color: var(--muted); }
.card {
  background: var(--card); border: 1px solid transparent; border-radius: 12px;
  padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(15,23,42,0.08);
}
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, monospace; font-size: 12px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.pos { color: #16a34a; } .neg { color: #dc2626; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; }
.kpi-value { font-size: 22px; font-weight: 700; }
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-hint { margin-top: 3px; color: #94a3b8; font-size: 12px; }
.period-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.period { border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.period-label { font-size: 12px; color: var(--muted); }
.period-count { font-size: 13px; margin: 4px 0 2px; }
.period-amount { font-size: 17px; font-weight: 700; color: #16a34a; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

/* Drag-and-drop віджети дашборда */
.dashboard-drag-help { margin-top: 4px; }
.dashboard-head-actions { display: flex; align-items: center; justify-content: flex-end;
  gap: 10px; flex-wrap: wrap; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px; align-items: start; }
.dashboard-widget { min-width: 0; overflow: hidden; border: 1px solid var(--border);
  border-radius: 12px; background: var(--card);
  transition: opacity 0.16s, transform 0.16s, border-color 0.16s, box-shadow 0.16s; }
.dashboard-widget-wide { grid-column: 1 / -1; }
.dashboard-widget-head { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-height: 44px; padding: 10px 12px 9px 16px;
  border-bottom: 1px solid var(--row-border); }
.dashboard-widget-head h3 { margin: 0; }
.dashboard-widget-body { padding: 16px; }
.dashboard-widget-body .kpi-grid { margin-bottom: 0; }
.dashboard-widget-body .kpi { background: var(--hover); }
.dashboard-drag-handle { display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 26px; flex-shrink: 0; border: 1px solid transparent;
  border-radius: 7px; color: var(--muted); cursor: grab; font-size: 19px;
  line-height: 1; user-select: none; }
.dashboard-drag-handle:hover { border-color: var(--border); background: var(--hover);
  color: var(--primary); }
.dashboard-drag-handle:active { cursor: grabbing; }
.dashboard-widget.is-dragging { opacity: 0.42; transform: scale(0.99); }
.dashboard-widget.is-drop-target { border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.dashboard-widget.is-drop-before {
  box-shadow: inset 0 3px 0 var(--primary),
    0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.dashboard-widget.is-drop-after {
  box-shadow: inset 0 -3px 0 var(--primary),
    0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
@media (max-width: 760px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-widget-wide { grid-column: auto; }
  .dashboard-head-actions { align-items: flex-start; justify-content: flex-start; }
}

/* Таблиці */
.table-wrap { overflow-x: auto; padding: 12px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); padding: 10px; border-bottom: 2px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--row-border); vertical-align: middle; }
tbody tr:hover { background: var(--hover); cursor: pointer; }
.num { text-align: right; }
th.num { text-align: right; }

/* Фільтри, форми */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
input, select, textarea {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: var(--input); color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #bfdbfe; border-color: var(--primary);
}
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.card select, .card input, .card textarea { width: 100%; }
.filters input, .filters select { width: auto; }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 90px; }
.form-grid label { margin-top: 8px; }

/* Кнопки, бейджі */
.btn {
  padding: 8px 16px; border: 1px solid var(--border); background: var(--input); border-radius: 6px;
  font-size: 12px; font-weight: 500; cursor: pointer; color: var(--text); font-family: inherit;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-danger-soft { border-color: #fecaca; background: #fff7f7; color: #b91c1c; }
.btn-danger-soft:hover { background: #fef2f2; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: #dc2626; border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-close { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--muted); }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; color: #fff;
  font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-outline { background: var(--card); border: 1.5px solid; }
.lead-origin { max-width: 170px; margin-top: 5px; overflow: hidden; color: #047857;
  font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.lead-origin-card { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px;
  align-items: baseline; padding: 10px 11px; margin-bottom: 12px; border: 1px solid #a7f3d0;
  border-radius: 8px; background: #f0fdf4; }
.lead-origin-card span { color: #047857; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.05em; }
.lead-origin-card b { color: #064e3b; font-size: 13px; }
.lead-origin-card small { grid-column: 2; color: var(--muted); }
.pagination { display: flex; align-items: center; gap: 14px; justify-content: center;
  margin: 16px 0; color: var(--muted); }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 9px 15px; border: 0; border-bottom: 2px solid transparent;
  border-radius: 0; color: var(--muted); background: transparent;
  font-size: 12px; cursor: pointer; font-family: inherit; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); background: transparent; }

/* Канбан */
.kanban { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 14px;
  align-items: flex-start; }
.kanban-col { min-width: 210px; width: 210px; background: #e8edf3; border-radius: 10px;
  padding: 8px; flex-shrink: 0; }
.kanban-head { font-size: 12px; font-weight: 700; padding: 8px; border-top: 3px solid;
  background: var(--card); border-radius: 8px; margin-bottom: 8px;
  display: flex; justify-content: space-between; }
.kanban-card { background: var(--card); border-radius: 8px; padding: 10px; margin-bottom: 8px;
  cursor: grab; border: 1px solid var(--border); font-size: 13px; }
.kanban-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.kanban-card.is-moving { opacity: 0.55; cursor: progress; }
.kanban-card-foot { display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; }
.kanban-empty { padding: 12px 8px; color: var(--muted); font-size: 12px;
  text-align: center; }
.kanban-section-head { display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin: 18px 0 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.kanban-section-head > div { display: flex; align-items: baseline; gap: 10px; }
.kanban-special .kanban-col { background: #f1f3f5; }
.kanban-error { margin-bottom: 12px; padding: 10px 12px; border: 1px solid #fecaca;
  border-radius: 8px; background: #fef2f2; color: #b91c1c; font-size: 13px; }

/* Модальні вікна */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px;
  overflow-y: auto; }
.modal { background: var(--bg); border-radius: 14px; width: 100%; max-width: 980px;
  padding: 20px; }
.modal-sm { max-width: 460px; background: var(--card); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 14px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 16px; }
@media (max-width: 800px) { .modal-grid { grid-template-columns: 1fr; } }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.kv > div:nth-child(odd) { color: var(--muted); font-size: 12px; }

/* Історія, задачі */
.add-comment { display: flex; gap: 6px; margin-bottom: 12px; }
.add-comment input { flex: 1; }
.add-comment select { width: auto; }
.add-comment button { white-space: nowrap; }
.timeline { max-height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.timeline-item { display: flex; gap: 10px; padding: 8px; background: var(--card);
  border-radius: 8px; border: 1px solid var(--border); }
.timeline-icon { font-size: 15px; }
.task-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid #f1f5f9; }
.task-row.done { text-decoration: line-through; color: var(--muted); }
.task-list { max-height: 340px; overflow-y: auto; }

.doc-buttons { display: flex; gap: 8px; margin-top: 14px; }
.doc-buttons .btn { flex: 1; }

/* Календар */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px; }
.cal-nav, .cal-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-nav strong { min-width: 150px; text-align: center; font-size: 15px; }
.cal-arrow { width: 36px; padding-left: 0; padding-right: 0; font-size: 18px; }
.cal-filters select { width: auto; min-width: 150px; }
.cal-legend { gap: 7px; }
.cal-legend-item { border: 1px solid var(--border); border-radius: 20px;
  background: var(--input); padding: 5px 9px; cursor: pointer; color: var(--muted);
  font-family: inherit; transition: border-color 0.15s, color 0.15s; }
.cal-legend-item:hover, .cal-legend-item.active { border-color: #94a3b8; color: var(--text); }
.cal-legend-item.active { box-shadow: 0 0 0 2px #e2e8f0; }
.cal-legend-item .legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.cal-scroll { overflow-x: auto; margin-bottom: 16px; padding-bottom: 2px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(96px, 1fr));
  gap: 5px; min-width: 720px; margin-bottom: 0; }
.cal-grid.cal-loading { opacity: 0.58; }
.cal-weekday { font-size: 12px; text-transform: uppercase; color: var(--muted);
  text-align: center; padding: 3px 0 7px; font-weight: 700; letter-spacing: 0.04em; }
.cal-cell { min-height: 116px; border: 1px solid var(--border); border-radius: 9px;
  padding: 6px; cursor: pointer; overflow: hidden; background: var(--card);
  transition: background 0.15s, border-color 0.15s; }
.cal-cell:hover { background: #f8fafc; }
.cal-empty { border: none; cursor: default; }
.cal-empty:hover { background: none; }
.cal-today { border-color: #93c5fd; }
.cal-selected, .cal-selected:hover { background: #eff6ff; border-color: var(--primary); }
.cal-day-head { display: flex; align-items: center; justify-content: space-between;
  min-height: 23px; margin-bottom: 3px; }
.cal-daynum { display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; font-size: 12px; font-weight: 700; border-radius: 50%; }
.cal-today .cal-daynum { background: var(--primary); color: #fff; }
.cal-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #e2e8f0; color: var(--muted); font-size: 12px; line-height: 18px;
  text-align: center; }
.cal-chip { display: flex; align-items: center; gap: 4px; width: 100%; border: none;
  border-left: 3px solid; border-radius: 4px; padding: 3px 5px; margin-bottom: 3px;
  font-family: inherit; font-size: 12px; text-align: left; cursor: pointer;
  white-space: nowrap; overflow: hidden; }
.cal-chip span { overflow: hidden; text-overflow: ellipsis; }
.cal-chip b { flex-shrink: 0; font-size: 12px; }
.cal-chip:hover { filter: saturate(1.35) brightness(0.97); }
.cal-done { opacity: 0.45; text-decoration: line-through; }
.cal-more { padding: 1px 5px; color: var(--muted); font-size: 12px; }
.cal-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  border-radius: 8px; padding: 9px 11px; margin-bottom: 12px; font-size: 12px; }
.cal-day-panel { padding: 18px; }
.cal-day-title { margin-bottom: 4px; }
.cal-day-title h3 { margin: 0 0 3px; text-transform: capitalize; }
.cal-empty-day { width: 100%; border: 1px dashed #cbd5e1; border-radius: 9px;
  background: #f8fafc; color: var(--muted); padding: 18px; cursor: pointer;
  font-family: inherit; }
.cal-empty-day:hover { color: var(--primary); border-color: #93c5fd; }
.cal-event-list { display: flex; flex-direction: column; }
.cal-event { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px;
  align-items: start; padding: 13px 8px 13px 12px; border-bottom: 1px solid #f1f5f9;
  border-left: 3px solid; }
.cal-event.done { opacity: 0.55; }
.cal-event.done strong { text-decoration: line-through; }
.cal-event-time { font-size: 13px; font-weight: 700; padding-top: 3px; }
.cal-event-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cal-event-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.cal-event-description { color: #334155; font-size: 12px; line-height: 1.45;
  white-space: pre-wrap; }
.cal-event-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  justify-content: flex-end; }
.cal-event-actions .btn { padding: 6px 9px; font-size: 12px; }
.modal-calendar { max-width: 720px; background: var(--card); }
.modal-calendar h3 { margin: 0 0 4px; }
.calendar-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 14px; }
.calendar-form-grid label { margin: 0; line-height: 1.4; }
.calendar-form-grid input, .calendar-form-grid select,
.calendar-form-grid textarea { display: block; width: 100%; margin-top: 5px; }
.calendar-form-grid textarea { resize: vertical; min-height: 92px; }
.cal-field-wide { grid-column: 1 / -1; }
@media (max-width: 760px) {
  .cal-toolbar { align-items: stretch; flex-direction: column; }
  .cal-nav { justify-content: space-between; }
  .cal-nav strong { min-width: 120px; }
  .cal-filters select { flex: 1; min-width: 130px; }
  .cal-event { grid-template-columns: 52px minmax(0, 1fr); }
  .cal-event-actions { grid-column: 2; justify-content: flex-start; }
  .calendar-form-grid { grid-template-columns: 1fr; }
  .cal-field-wide { grid-column: auto; }
}

/* Скоринг */
.score-badge { display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 24px; border-radius: 12px; font-size: 12px; font-weight: 700;
  color: #fff; padding: 0 8px; cursor: help; vertical-align: middle; }
.score-hot { background: #16a34a; }
.score-warm { background: #f59e0b; }
.score-cold { background: #94a3b8; }

/* Сповіщення */
.nav-badge { background: #ef4444; color: #fff; font-size: 12px; font-weight: 700;
  border-radius: 10px; padding: 1px 6px; margin-left: auto; }
.notif { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; cursor: pointer;
  border-radius: 8px; }
.notif:hover { background: #f8fafc; }
.notif-unread { background: #eff6ff; border-left: 3px solid var(--primary); }

/* Плани продажів */
.plan-row { margin-bottom: 14px; }
.plan-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 5px;
  flex-wrap: wrap; }
.plan-track { background: #e2e8f0; border-radius: 6px; height: 10px; overflow: hidden; }
.plan-fill { background: var(--primary); height: 100%; border-radius: 6px;
  transition: width 0.4s; }
.plan-done { background: #16a34a; }
.payment-form { display: grid; grid-template-columns: 1.4fr repeat(3, minmax(120px, 1fr));
  gap: 10px; margin: 10px 0; padding: 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--hover); }
.payment-form label { margin: 0; }
.payment-form input { display: block; width: 100%; margin-top: 5px; }
.payment-form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end;
  gap: 8px; }
@media (max-width: 900px) {
  .payment-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .payment-form { grid-template-columns: 1fr; }
  .payment-form-actions { grid-column: auto; }
}

/* Автоматизації */
.rule-row { display: flex; align-items: center; gap: 12px; padding: 9px 0;
  border-bottom: 1px solid #f1f5f9; }
.rule-name { flex: 1; font-size: 13px; }
.rule-hours { display: flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--muted); }
.switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 20px;
  cursor: pointer; transition: 0.2s; }
.slider:before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px;
  top: 2px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(16px); }

/* Шахматка */
.legend { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.legend-dot { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid; display: inline-block; }
.chess-wrap { display: flex; gap: 20px; overflow-x: auto; padding-bottom: 12px;
  align-items: flex-start; }
.chess-section { background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; flex-shrink: 0; }
.chess-section-title { font-size: 12px; font-weight: 700; color: var(--muted);
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.4px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chess-mini-btn { font-size: 12px; padding: 2px 8px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--input); cursor: pointer; color: var(--muted);
  font-family: inherit; text-transform: none; letter-spacing: 0; }
.chess-mini-btn:hover { color: var(--primary); border-color: var(--primary); }
.chess-floor-del { opacity: 0; border: none; background: none; color: #dc2626;
  cursor: pointer; font-size: 12px; padding: 0 2px; transition: opacity 0.15s; }
.chess-floor:hover .chess-floor-del { opacity: 1; }
.chess-floor { display: flex; gap: 4px; margin-bottom: 4px; align-items: center; }
.chess-floor-num { width: 22px; font-size: 12px; color: var(--muted); text-align: right;
  flex-shrink: 0; padding-right: 4px; }
.apt { display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 70px; height: 52px; border: 1.5px solid; border-radius: 6px; cursor: pointer;
  font-size: 12px; line-height: 1.25; padding: 2px; font-family: inherit; color: #0f172a; }
.apt b { font-size: 12px; }
.apt:hover { filter: brightness(0.93); }
.apt-selected { outline: 2px solid #2563eb; }
.apt-timer { display: block; max-width: 66px; margin-top: 2px; padding: 1px 4px;
  overflow: hidden; border-radius: 999px; font-size: 12px; font-weight: 750;
  line-height: 1.2; text-overflow: ellipsis; white-space: nowrap;
  color: #92400e; background: rgba(255,255,255,0.72); }
.apt-timer-urgent, .apt-timer-expired { color: #b91c1c; background: #fee2e2; }
.apt-urgent, .apt-expired { border-color: #dc2626 !important; }
.apt-expired { animation: reservation-pulse 1.5s ease-in-out infinite; }
@keyframes reservation-pulse {
  50% { box-shadow: 0 0 0 4px rgba(220,38,38,0.16); }
}
.apt-panel { position: sticky; bottom: 12px; box-shadow: 0 8px 30px rgba(15,23,42,0.15);
  max-width: 520px; }
.reservation-term-row { display: grid; grid-template-columns: 150px minmax(220px, 1fr);
  gap: 10px; margin: 8px 0 12px; }
.reservation-term-row label, .reservation-create > label { display: grid; gap: 5px;
  color: var(--muted); font-size: 12px; font-weight: 650; }
.reservation-actions { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--row-border); }
.reservation-extend { display: flex; align-items: center; gap: 8px; }
.reservation-extend select { width: 150px; }
.reservation-actions .modal-foot { margin-top: 10px; }
.reservation-deadline { color: #9a6700; }
.reservation-deadline.reservation-urgent,
.reservation-deadline.reservation-expired { color: #dc2626; }
.reservation-deadline.reservation-open { color: var(--muted); }
.lead-option { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  margin-top: 6px; cursor: pointer; font-size: 13px; }
.lead-option:hover { background: #f0f7ff; border-color: #93c5fd; }
.link { color: var(--primary); cursor: pointer; text-decoration: underline; }

/* Графіки */
.hbar-chart { display: flex; flex-direction: column; gap: 7px; }
.hbar-row { display: grid; grid-template-columns: 150px 1fr; gap: 10px; align-items: center; }
.hbar-label { font-size: 12px; text-align: right; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { display: flex; align-items: center; gap: 8px; }
.hbar-fill { border-radius: 4px; min-width: 3px; transition: width 0.4s; }
.hbar-value { font-size: 12px; font-weight: 600; }
.line-chart { width: 100%; height: auto; }
.chart-tick { font-size: 12px; fill: var(--muted); }

/* Хаб інтеграцій */
.integrations-page { --hub-accent: #b7f34a; }
.integrations-hero { position: relative; overflow: hidden; display: flex;
  align-items: flex-end; justify-content: space-between; gap: 20px; padding: 28px;
  margin-bottom: 16px; border-radius: 16px; color: #fff;
  background:
    radial-gradient(circle at 82% 18%, rgba(183,243,74,0.2), transparent 26%),
    linear-gradient(128deg, #0b1325 0%, #102238 62%, #12332f 100%); }
.integrations-hero::after { content: ""; position: absolute; width: 240px; height: 240px;
  right: -80px; bottom: -160px; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%; box-shadow: 0 0 0 34px rgba(255,255,255,0.025),
  0 0 0 68px rgba(255,255,255,0.018); }
.integrations-hero h1 { margin: 3px 0 7px; font-size: 30px; letter-spacing: -0.03em; }
.integrations-hero p { max-width: 620px; color: #b8c6d9; font-size: 14px; }
.integrations-eyebrow { color: var(--hub-accent); font-size: 12px; font-weight: 800;
  letter-spacing: 0.22em; }
.hub-live { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; padding: 8px 11px; border: 1px solid rgba(183,243,74,0.28);
  background: rgba(11,19,37,0.55); border-radius: 20px; color: #dcff9e; font-size: 12px; }
.hub-live span { width: 8px; height: 8px; border-radius: 50%; background: var(--hub-accent);
  box-shadow: 0 0 0 5px rgba(183,243,74,0.12); }
.hub-live.offline { color: #fda4af; border-color: rgba(253,164,175,0.3); }
.hub-live.offline span { background: #fb7185; box-shadow: 0 0 0 5px rgba(251,113,133,0.12); }
.integration-callout { padding: 11px 14px; margin-bottom: 14px; border: 1px solid #fde68a;
  border-left: 4px solid #eab308; border-radius: 9px; background: #fffbeb;
  color: #854d0e; font-size: 12px; line-height: 1.5; }
.integration-callout b { margin-right: 4px; }
.integration-notice { padding: 9px 12px; margin-bottom: 12px; border: 1px solid #bbf7d0;
  border-radius: 8px; background: #f0fdf4; color: #166534; font-size: 12px; }
.delivery-monitor { margin-bottom: 14px; padding: 16px; overflow: hidden;
  border: 1px solid #cbd5e1; border-radius: 13px;
  background: linear-gradient(135deg, #f8fafc 0%, #f0fdf4 100%); }
.delivery-monitor.attention { border-color: #fecaca;
  background: linear-gradient(135deg, #fff 0%, #fff7ed 100%); }
.delivery-monitor-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; }
.delivery-monitor-head h3 { margin: 3px 0 4px; color: var(--text); font-size: 16px; }
.delivery-monitor-head p { margin: 0; color: var(--muted); font-size: 12px; }
.delivery-monitor .integrations-eyebrow { color: #15803d; }
.delivery-health { display: flex; align-items: center; gap: 7px; flex-shrink: 0;
  padding: 6px 9px; border-radius: 999px; background: #dcfce7; color: #166534;
  font-size: 12px; font-weight: 700; }
.delivery-health span { width: 7px; height: 7px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34,197,94,0.13); }
.delivery-monitor.attention .delivery-health { background: #fee2e2; color: #991b1b; }
.delivery-monitor.attention .delivery-health span { background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239,68,68,0.13); }
.delivery-overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px; margin-top: 14px; }
.delivery-overview > div { display: flex; align-items: baseline; gap: 7px; padding: 9px 10px;
  border: 1px solid rgba(148,163,184,0.25); border-radius: 8px;
  background: rgba(255,255,255,0.72); }
.delivery-overview b { color: #0f172a; font-size: 17px; }
.delivery-overview span { color: #64748b; font-size: 12px; }
.delivery-overview .danger b { color: #dc2626; }
.alert-channel-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin-top: 10px; color: var(--muted); font-size: 12px; }
.alert-channel-row > span { margin-right: 3px; font-weight: 700; }
.alert-channel-row i { padding: 3px 7px; border: 1px solid #e2e8f0; border-radius: 999px;
  background: #fff; color: #94a3b8; font-style: normal; }
.alert-channel-row i.ready { border-color: #86efac; background: #dcfce7; color: #166534; }
.delivery-queue-list { display: grid; gap: 6px; margin-top: 12px; padding-top: 11px;
  border-top: 1px solid rgba(148,163,184,0.25); }
.delivery-queue-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center; gap: 9px; padding: 8px; border-radius: 8px; background: rgba(255,255,255,0.78); }
.delivery-direction { display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 7px; background: #dbeafe; color: #1d4ed8;
  font-size: 12px; font-weight: 900; letter-spacing: 0.05em; }
.delivery-direction.outbound { background: #fef3c7; color: #92400e; }
.delivery-queue-item > div { min-width: 0; }
.delivery-queue-item b { display: block; overflow: hidden; color: var(--text); font-size: 12px;
  text-overflow: ellipsis; white-space: nowrap; }
.delivery-queue-item small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.delivery-queue-item em { display: block; margin-top: 3px; overflow: hidden; color: #b91c1c;
  font-size: 12px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.delivery-status.queued, .delivery-status.processing { background: #dbeafe; color: #1d4ed8; }
.delivery-status.retry { background: #fef3c7; color: #92400e; }
.delivery-status.completed, .delivery-status.sent { background: #dcfce7; color: #166534; }
.delivery-status.dead { background: #fee2e2; color: #b91c1c; }
.hub-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 14px; }
.hub-kpis > div { display: flex; align-items: baseline; gap: 8px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.hub-kpis strong { font-size: 19px; }
.hub-kpis span { color: var(--muted); font-size: 12px; }
.hub-kpis .has-errors strong { color: #dc2626; }
.integration-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px; margin-bottom: 16px; transition: opacity 0.2s; }
.integration-grid.is-loading { opacity: 0.55; }
.integration-card { display: flex; flex-direction: column; min-height: 280px; padding: 16px;
  border: 1px solid var(--border); border-radius: 13px; background: #fff;
  transition: transform 0.16s, box-shadow 0.16s, opacity 0.16s; }
.integration-card:hover { transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15,23,42,0.07); }
.integration-card.disabled { opacity: 0.58; filter: saturate(0.6); }
.integration-card-head { display: flex; align-items: center; gap: 10px; }
.channel-mark { display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; flex-shrink: 0; border-radius: 11px;
  font-size: 13px; font-weight: 900; letter-spacing: -0.04em; }
.integration-title { min-width: 0; flex: 1; }
.integration-title h3 { margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--text); font-size: 14px; }
.integration-title > span { color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.06em; }
.hub-switch { width: 38px; height: 22px; padding: 2px; flex-shrink: 0; border: none;
  border-radius: 20px; background: #cbd5e1; cursor: pointer; transition: 0.2s; }
.hub-switch span { display: block; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(15,23,42,0.25); transition: 0.2s; }
.hub-switch.on { background: #16a34a; }
.hub-switch.on span { transform: translateX(16px); }
.hub-switch:disabled { opacity: 0.5; cursor: default; }
.integration-card > p { min-height: 36px; margin: 15px 0 9px; color: #475569;
  font-size: 12px; line-height: 1.5; }
.integration-fields { min-height: 43px; padding: 8px 9px; border-radius: 7px;
  background: #f8fafc; color: var(--muted); font-family: ui-monospace, monospace;
  font-size: 12px; line-height: 1.45; word-break: break-word; }
.source-count { display: inline-flex; align-items: center; gap: 5px; align-self: flex-start;
  margin-top: 9px; padding: 4px 7px; border-radius: 12px; background: #ecfdf5;
  color: #047857; font-size: 12px; }
.source-count span { font-weight: 800; }
.integration-card-stats { display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px; padding: 13px 0; margin-top: auto; }
.integration-card-stats > div { display: flex; flex-direction: column; }
.integration-card-stats b { font-size: 16px; }
.integration-card-stats span { color: var(--muted); font-size: 12px; }
.integration-card-foot { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding-top: 12px; border-top: 1px solid #f1f5f9; }
.connection-state { display: inline-flex; align-items: center; gap: 6px; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.connection-state i { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; }
.connection-state.connected { color: #15803d; }
.connection-state.connected i { background: #22c55e; box-shadow: 0 0 0 4px #dcfce7; }
.integration-log { padding: 16px 4px 4px; }
.integration-log .page-head { padding: 0 12px; margin-bottom: 8px; }
.integration-log .page-head h3 { margin: 0 0 4px; }
.integration-log-empty { padding: 32px; text-align: center; color: var(--muted); }
.delivery-status { display: inline-flex; padding: 3px 7px; border-radius: 12px;
  background: #f1f5f9; color: #475569; font-size: 12px; font-weight: 700; }
.delivery-status.accepted { background: #dcfce7; color: #166534; }
.delivery-status.duplicate { background: #f1f5f9; color: #64748b; }
.delivery-status.error { background: #fee2e2; color: #b91c1c; }
.delivery-status.test { background: #dbeafe; color: #1d4ed8; }
.payload-details { position: relative; }
.payload-details summary { color: var(--primary); font-size: 12px; cursor: pointer; }
.payload-details pre { max-width: 440px; max-height: 240px; margin-top: 7px; padding: 9px;
  overflow: auto; border-radius: 7px; background: #0f172a; color: #dbeafe;
  font-size: 12px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.integration-modal { max-width: 900px; background: #f8fafc; }
.integration-modal-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.integration-modal-title h3 { margin: 0 0 4px; }
.endpoint-box { padding: 12px; margin-bottom: 14px; border: 1px solid #cbd5e1;
  border-radius: 10px; background: #fff; }
.endpoint-label { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 7px; color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.07em; }
.endpoint-value, .input-action { display: flex; align-items: center; gap: 8px; }
.endpoint-value code { flex: 1; min-width: 0; padding: 9px 10px; overflow: hidden;
  border-radius: 7px; background: #eef2f7; color: #0f172a; font-size: 12px;
  text-overflow: ellipsis; white-space: nowrap; }
.endpoint-help { margin-top: 7px; }
.input-action input { flex: 1; min-width: 0; }
.facebook-setup { padding: 14px; margin-bottom: 14px; border: 1px solid #bfdbfe;
  border-radius: 11px; background: #eff6ff; }
.facebook-setup h4 { margin-top: 0; color: #1e40af; }
.facebook-setup > p { margin: -3px 0 12px; line-height: 1.5; }
.facebook-setup .btn-primary { margin-top: 12px; }
.integration-sources { padding: 14px; margin-bottom: 14px; border: 1px solid #a7f3d0;
  border-radius: 11px; background: linear-gradient(145deg, #f0fdf4, #f8fafc 70%); }
.sources-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; }
.sources-head h4 { margin: 0 0 4px; color: #065f46; }
.sources-head p { max-width: 650px; margin: 0; line-height: 1.5; }
.source-total { display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: 16px; background: #064e3b;
  color: #d1fae5; font-size: 13px; font-weight: 800; }
.source-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 9px;
  align-items: end; padding: 11px; border: 1px solid #d1fae5; border-radius: 9px;
  background: rgba(255,255,255,0.88); }
.source-editor label { display: flex; flex-direction: column; gap: 5px; color: #475569;
  font-size: 12px; }
.source-editor input { min-width: 0; }
.source-editor-actions { display: flex; grid-column: 1 / -1; gap: 7px; padding-bottom: 1px; }
.source-empty { padding: 18px; margin-top: 10px; border: 1px dashed #a7f3d0;
  border-radius: 9px; color: #047857; text-align: center; font-size: 12px; }
.source-list { display: grid; gap: 9px; margin-top: 10px; }
.source-item { padding: 11px; border: 1px solid #dbe3ec; border-radius: 9px;
  background: #fff; transition: opacity 0.15s; }
.source-item.disabled { opacity: 0.58; }
.source-item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.source-item-head > div { min-width: 0; }
.source-item-head b { display: block; overflow: hidden; color: #0f172a; font-size: 12px;
  text-overflow: ellipsis; white-space: nowrap; }
.source-item-head span { display: block; margin-top: 2px; color: var(--muted);
  font-family: ui-monospace, monospace; font-size: 12px; }
.source-stats { display: flex; gap: 16px; padding: 8px 0; color: var(--muted);
  font-size: 12px; }
.source-stats b { color: #0f172a; }
.source-endpoint { display: flex; align-items: center; gap: 7px; }
.source-endpoint code { flex: 1; min-width: 0; padding: 8px 9px; overflow: hidden;
  border-radius: 6px; background: #f1f5f9; color: #334155; font-size: 12px;
  text-overflow: ellipsis; white-space: nowrap; }
.source-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.source-actions .btn { padding: 6px 9px; font-size: 12px; }
.integration-modal-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 14px; }
.integration-modal-grid > div { padding: 14px; border: 1px solid var(--border);
  border-radius: 11px; background: #fff; }
.integration-modal-grid h4 { margin-top: 0; }
.integration-code { min-height: 174px; max-height: 240px; margin-bottom: 9px; padding: 12px;
  overflow: auto; border-radius: 8px; background: #0b1325; color: #d7fca2;
  font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.field-cloud { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.field-cloud code { padding: 5px 7px; border: 1px solid #dbe3ec; border-radius: 6px;
  background: #f8fafc; color: #334155; font-size: 12px; }
.modal-actions-stack { display: flex; flex-direction: column; gap: 7px; margin-top: 16px; }
.integration-mini-log { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; }
.integration-mini-log h4 { margin-top: 0; }
.integration-mini-log > div { display: grid; grid-template-columns: auto 1fr auto; gap: 9px;
  align-items: center; padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: 12px; }
.integration-mini-log time { color: var(--muted); font-size: 12px; }
.integration-title .integration-company { display: inline-block; width: fit-content;
  margin-top: 4px; padding: 2px 6px; border-radius: 999px;
  background: #eef7f2; color: #17613c; font-size: 12px; font-weight: 700; }
@media (max-width: 1050px) {
  .integration-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hub-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .integrations-hero { align-items: flex-start; flex-direction: column; padding: 20px; }
  .integrations-hero h1 { font-size: 25px; }
  .hub-live { align-self: flex-start; }
  .integration-grid { grid-template-columns: 1fr; }
  .hub-kpis { grid-template-columns: 1fr 1fr; }
  .hub-kpis > div { align-items: flex-start; flex-direction: column; gap: 2px; }
  .delivery-monitor-head { flex-direction: column; }
  .delivery-overview { grid-template-columns: 1fr 1fr; }
  .delivery-queue-item { grid-template-columns: auto minmax(0, 1fr); }
  .delivery-queue-item .delivery-status, .delivery-queue-item .btn { grid-column: 2; width: fit-content; }
  .integration-modal-grid { grid-template-columns: 1fr; }
  .endpoint-value, .input-action { align-items: stretch; flex-direction: column; }
  .source-editor { grid-template-columns: 1fr; }
  .source-editor-actions { grid-column: auto; padding: 0; }
  .source-endpoint { align-items: stretch; flex-direction: column; }
  .integration-mini-log > div { grid-template-columns: auto 1fr; }
  .integration-mini-log time { grid-column: 2; }
}

/* Компактний каркас CRM для телефонів */
@media (max-width: 760px) {
  .sidebar { width: 68px; padding: 14px 7px; gap: 14px; }
  .logo-sidebar { padding: 0 2px; align-items: center; }
  .logo-sidebar .logo-image { width: 50px; }
  .logo-sub, .sidebar-user > div, .sidebar-foot { display: none; }
  .nav-item { position: relative; justify-content: center; gap: 0; padding: 10px 6px;
    overflow: visible; font-size: 0; }
  .nav-icon svg { width: 18px; height: 18px; }
  .nav-badge { position: absolute; top: 2px; right: 0; min-width: 16px;
    padding: 1px 4px; font-size: 12px; }
  .sidebar-user { padding: 8px 0 0; }
  .sidebar-profile-button { justify-content: center; }
  .sidebar-profile-button > span:last-child { display: none; }
  .btn-logout { height: 38px; padding: 0; font-size: 0; }
  .btn-logout::after { content: "↪"; font-size: 19px; }
  .content { padding: 18px 12px; }
  .page-head { align-items: flex-start; }
  h1 { font-size: 20px; }
}

/* Доступ і безпека */
.login-submit { width: 100%; margin-top: 16px; }
.auth-step h3 { margin: 0 0 6px; }
.auth-step input { width: 100%; margin-top: 10px; }
.invite-company { margin-bottom: 4px; color: #0f172a; font-size: 18px; font-weight: 800; }
.secret-code { margin: 12px 0; padding: 12px; border: 1px dashed #94a3b8;
  border-radius: 9px; background: #f8fafc; color: #0f172a;
  font-family: ui-monospace, monospace; font-size: 15px; letter-spacing: 1px;
  text-align: center; word-break: break-all; }
.break-all { word-break: break-all; }
.recovery-box { margin-top: 12px; padding: 12px; border: 1px solid #f59e0b;
  border-radius: 9px; background: #fffbeb; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px; margin-top: 10px; }
.recovery-codes code { padding: 7px; border-radius: 6px; background: #fff;
  color: #0f172a; text-align: center; }
.forced-security-shell { min-height: 100vh; padding: 32px; background:
  radial-gradient(circle at 0 0, #dff7ec 0, transparent 36%),
  linear-gradient(145deg, #f8fafc, #eef5f1); }
.security-stack { display: grid; gap: 14px; }
.security-card { margin-bottom: 0; }
.security-card h3 { margin-top: 0; }
.section-title-row { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; }
.security-form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.security-form-grid label { display: flex; flex-direction: column; gap: 6px;
  color: #475569; font-size: 12px; }
.security-inline { margin: 14px 0 0; }
.security-inline input { flex: 1; }
.security-message, .security-notice { margin-top: 10px; padding: 10px 12px;
  border-radius: 8px; background: #eef7f2; color: #17613c; word-break: break-word; }
.badge-ok { background: #dcfce7 !important; color: #166534 !important; }
.badge-warn { background: #fef3c7 !important; color: #92400e !important; }
.setup-box { margin-top: 12px; padding: 12px; border-radius: 10px; background: #f8fafc; }
.session-list { display: grid; gap: 8px; }
.session-row { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 0; border-bottom: 1px solid #eef2f7; }
.security-tabs { margin-bottom: 14px; }
.security-tabs button { padding: 9px 13px; border: 0; border-radius: 8px;
  background: transparent; color: #64748b; cursor: pointer; }
.security-tabs button.active { background: #183f32; color: #fff; }
.security-two-col { align-items: start; }
.company-chips, .permission-cloud { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.role-matrix { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.role-card { padding: 14px; border: 1px solid #dbe4df; border-radius: 10px;
  background: linear-gradient(160deg, #fff, #f7faf8); }
.permission-cloud code { padding: 4px 6px; border-radius: 5px; background: #edf3f0;
  color: #335b4d; font-size: 12px; }
.actions-cell { display: flex; flex-wrap: wrap; gap: 5px; }

@media (max-width: 900px) {
  .security-form-grid, .role-matrix { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .forced-security-shell { padding: 16px; }
  .security-form-grid, .role-matrix { grid-template-columns: 1fr; }
  .security-tabs { overflow-x: auto; white-space: nowrap; }
  .recovery-codes { grid-template-columns: 1fr; }
}

/* Темна тема */
:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at 82% -10%, rgba(37,99,235,0.13), transparent 31%),
    var(--bg);
}
:root[data-theme="dark"] .login-card {
  --card: #ffffff; --border: #e2e8f0; --text: #0f172a;
  --muted: #64748b; --input: #ffffff; --hover: #f8fafc;
  background: var(--card); color: var(--text);
}
:root[data-theme="dark"] .kanban-col,
:root[data-theme="dark"] .kanban-special .kanban-col { background: #0d1627; }
:root[data-theme="dark"] .modal { box-shadow: 0 22px 70px rgba(0,0,0,0.42); }
:root[data-theme="dark"] .cal-cell:hover,
:root[data-theme="dark"] .cal-empty-day,
:root[data-theme="dark"] .notif:hover { background: var(--hover); }
:root[data-theme="dark"] .cal-empty:hover { background: none; }
:root[data-theme="dark"] .cal-selected,
:root[data-theme="dark"] .cal-selected:hover,
:root[data-theme="dark"] .notif-unread {
  background: #10284a;
}
:root[data-theme="dark"] .cal-count,
:root[data-theme="dark"] .plan-track,
:root[data-theme="dark"] .slider { background: #26344a; }
:root[data-theme="dark"] .cal-event-description { color: #c4cfdd; }
:root[data-theme="dark"] .lead-option:hover { background: #112b4c; }
:root[data-theme="dark"] .apt-timer { color: #fbbf24; background: rgba(15,23,42,0.78); }
:root[data-theme="dark"] .apt-timer-urgent,
:root[data-theme="dark"] .apt-timer-expired { color: #fecaca; background: #4c1d24; }
:root[data-theme="dark"] .btn-danger-soft {
  border-color: #7f1d1d; background: #2b151b; color: #fca5a5;
}
:root[data-theme="dark"] .btn-danger-soft:hover,
:root[data-theme="dark"] .btn-danger:hover { background: #35171d; }
:root[data-theme="dark"] .integration-callout {
  border-color: #854d0e; border-left-color: #eab308; background: #2a210e; color: #fde68a;
}
:root[data-theme="dark"] .integration-notice {
  border-color: #166534; background: #0d2a20; color: #bbf7d0;
}
:root[data-theme="dark"] .delivery-monitor {
  border-color: #28523f; background: linear-gradient(135deg, #111a2b, #10251e);
}
:root[data-theme="dark"] .delivery-monitor.attention {
  border-color: #7f1d1d; background: linear-gradient(135deg, #111a2b, #2b1818);
}
:root[data-theme="dark"] .delivery-overview > div,
:root[data-theme="dark"] .delivery-queue-item,
:root[data-theme="dark"] .alert-channel-row i { background: rgba(10,20,35,0.72); }
:root[data-theme="dark"] .delivery-overview b { color: var(--text); }
:root[data-theme="dark"] .alert-channel-row i { border-color: var(--border); }
:root[data-theme="dark"] .alert-channel-row i.ready {
  border-color: #17613c; background: #153528; color: #86efac;
}
:root[data-theme="dark"] .hub-kpis > div,
:root[data-theme="dark"] .integration-card,
:root[data-theme="dark"] .endpoint-box,
:root[data-theme="dark"] .source-item,
:root[data-theme="dark"] .integration-modal-grid > div,
:root[data-theme="dark"] .integration-mini-log { background: var(--card); }
:root[data-theme="dark"] .integration-card > p,
:root[data-theme="dark"] .source-editor label { color: var(--muted); }
:root[data-theme="dark"] .integration-fields,
:root[data-theme="dark"] .field-cloud code {
  background: var(--hover); color: #b9c6d8; border-color: var(--border);
}
:root[data-theme="dark"] .integration-card-foot,
:root[data-theme="dark"] .integration-mini-log > div { border-color: var(--row-border); }
:root[data-theme="dark"] .integration-modal { background: var(--bg); }
:root[data-theme="dark"] .endpoint-value code,
:root[data-theme="dark"] .source-endpoint code {
  background: #0b1424; color: #cbd5e1;
}
:root[data-theme="dark"] .facebook-setup {
  border-color: #1e4d82; background: #10284a;
}
:root[data-theme="dark"] .facebook-setup h4 { color: #93c5fd; }
:root[data-theme="dark"] .integration-sources {
  border-color: #17613c; background: linear-gradient(145deg, #0d2a20, #111a2b 70%);
}
:root[data-theme="dark"] .sources-head h4 { color: #6ee7b7; }
:root[data-theme="dark"] .source-editor { border-color: #214c3c; background: rgba(8,20,18,0.72); }
:root[data-theme="dark"] .source-item-head b,
:root[data-theme="dark"] .source-stats b { color: var(--text); }
:root[data-theme="dark"] .source-empty { border-color: #17613c; color: #6ee7b7; }
:root[data-theme="dark"] .delivery-status { background: #26344a; color: #cbd5e1; }
:root[data-theme="dark"] .integration-title .integration-company {
  background: #153528; color: #86efac;
}
:root[data-theme="dark"] .invite-company,
:root[data-theme="dark"] .source-item-head b { color: var(--text); }
:root[data-theme="dark"] .secret-code,
:root[data-theme="dark"] .setup-box { background: var(--hover); color: var(--text); }
:root[data-theme="dark"] .recovery-box { background: #2a210e; }
:root[data-theme="dark"] .recovery-codes code { background: #111827; color: var(--text); }
:root[data-theme="dark"] .forced-security-shell {
  background:
    radial-gradient(circle at 0 0, rgba(24,63,50,0.42), transparent 36%),
    linear-gradient(145deg, #0a1020, #0d1715);
}
:root[data-theme="dark"] .security-form-grid label { color: var(--muted); }
:root[data-theme="dark"] .security-message,
:root[data-theme="dark"] .security-notice { background: #153528; color: #bbf7d0; }
:root[data-theme="dark"] .role-card {
  border-color: var(--border); background: linear-gradient(160deg, #111a2b, #0e1827);
}
:root[data-theme="dark"] .permission-cloud code { background: #1b3029; color: #a7f3d0; }
:root[data-theme="dark"] .session-row { border-color: var(--row-border); }

@media (max-width: 760px) {
  .app-header { height: 52px; padding: 0 12px; }
  .app-header-context b { display: none; }
  .theme-toggle { min-width: 42px; padding: 6px 9px; font-size: 0; }
  .theme-toggle span { font-size: 15px; }
}

/* Клієнти та 360°-картка */
.clients-page { --client-ink: #14251f; --client-accent: #16835f; --client-soft: #e9f7f1; }
.clients-head h1 { letter-spacing: -0.03em; }
.clients-head p { margin-top: 4px; }
.client-kpi-grid {
  display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)) minmax(190px, 1.25fr);
  gap: 10px; margin-bottom: 16px;
}
.client-kpi-grid > div {
  display: flex; align-items: center; gap: 11px; min-height: 82px; padding: 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card);
}
.client-kpi-grid p { display: flex; flex-direction: column; gap: 3px; }
.client-kpi-grid b { color: var(--text); font-size: 21px; line-height: 1; }
.client-kpi-grid small { color: var(--muted); font-size: 12px; }
.client-kpi-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  flex-shrink: 0; border-radius: 11px; font-size: 15px; font-weight: 800;
}
.client-kpi-icon.blue { background: #e7f1ff; color: #2563eb; }
.client-kpi-icon.green { background: #e5f8ef; color: #16835f; }
.client-kpi-icon.amber { background: #fff4d8; color: #b7791f; }
.client-kpi-icon.coral { background: #ffede7; color: #c75b3a; }
.client-kpi-money {
  justify-content: flex-end; color: #fff; border: none !important;
  background:
    radial-gradient(circle at 12% 15%, rgba(255,255,255,0.18), transparent 30%),
    linear-gradient(135deg, #173f34, #16835f) !important;
}
.client-kpi-money p { align-items: flex-end; }
.client-kpi-money b, .client-kpi-money small { color: #fff; }
.client-kpi-money b { font-size: 23px; }
.client-list-card { padding: 0; overflow: hidden; }
.client-filters {
  display: flex; align-items: center; gap: 8px; padding: 13px 14px;
  border-bottom: 1px solid var(--row-border);
}
.client-search {
  position: relative; display: flex; align-items: center; flex: 1; min-width: 230px;
}
.client-search span { position: absolute; left: 11px; color: var(--muted); font-size: 18px; }
.client-search input { width: 100%; padding-left: 35px; }
.client-result-count { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.client-table-wrap { overflow-x: auto; }
.client-table { min-width: 1010px; }
.client-table th { padding-top: 11px; padding-bottom: 11px; }
.client-table td { vertical-align: middle; padding-top: 12px; padding-bottom: 12px; }
.client-table-person { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.client-table-person > span, .client-profile-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  color: #fff; font-weight: 750; background:
    linear-gradient(145deg, #2f6958, #163e34);
}
.client-table-person > span { width: 36px; height: 36px; border-radius: 50%; font-size: 12px; }
.client-table-person > div { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.client-table-person b { font-size: 12px; }
.client-status {
  display: inline-flex; align-items: center; width: fit-content; padding: 3px 7px;
  border-radius: 99px; font-size: 12px; font-weight: 700; line-height: 1;
}
.client-status-active { color: #087454; background: #dcfce7; }
.client-status-vip { color: #8a5700; background: #fef3c7; }
.client-status-inactive { color: #64748b; background: #e2e8f0; }
.client-status-blacklist { color: #b42318; background: #fee4e2; }
.client-table-contact { display: flex; flex-direction: column; gap: 3px; min-width: 140px; }
.client-table-contact b { font-size: 12px; }
.client-table-contact span, .client-subline { display: block; color: var(--muted); font-size: 12px; }
.client-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.client-tags span {
  padding: 4px 7px; border: 1px solid #cceadf; border-radius: 6px;
  color: #146c52; background: #f0faf6; font-size: 12px; font-weight: 650;
}
.client-tags-table { min-width: 110px; max-width: 175px; }
.client-tags i {
  display: inline-flex; align-items: center; color: var(--muted); font-size: 12px; font-style: normal;
}
.client-open-button {
  width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 50%;
  color: var(--muted); background: var(--card); cursor: pointer;
}
.client-table tr:hover .client-open-button {
  color: #fff; border-color: var(--client-accent); background: var(--client-accent);
}
.client-empty { padding: 64px 20px; text-align: center; }
.client-empty > div { font-size: 30px; filter: grayscale(1); opacity: 0.5; }
.client-empty h3 { margin: 10px 0 5px; color: var(--text); }
.client-empty p { color: var(--muted); font-size: 12px; }
.client-error {
  margin: 10px 14px; padding: 10px 12px; border: 1px solid #fecaca;
  border-radius: 8px; color: #b91c1c; background: #fff7f7; font-size: 12px;
}
.client-loading-overlay {
  position: fixed; right: 24px; bottom: 24px; z-index: 40; padding: 11px 16px;
  border-radius: 10px; color: #fff; background: #173f34; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.client-form-modal { max-width: 760px; background: var(--card); }
.client-form-modal h2 { font-size: 19px; }
.client-form-modal .modal-head p { margin-top: 4px; }
.client-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.client-form-grid label { margin-top: 9px; }
.client-form-grid input, .client-form-grid select, .client-form-grid textarea { width: 100%; margin-top: 5px; }
.client-field-wide { grid-column: 1 / -1; }

.client-profile-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px;
}
.client-back {
  padding: 7px 0; border: none; color: var(--muted); background: none;
  font-family: inherit; font-size: 12px; cursor: pointer;
}
.client-back:hover { color: var(--client-accent); }
.client-profile-actions { display: flex; gap: 7px; }
.client-360-grid {
  display: grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  gap: 14px; align-items: start;
}
.client-profile-card, .client-workspace {
  border: 1px solid var(--border); border-radius: 14px; background: var(--card);
}
.client-profile-card {
  position: sticky; top: 74px; padding: 25px 20px 18px; text-align: center; overflow: hidden;
}
.client-profile-card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 76px;
  background:
    linear-gradient(110deg, rgba(22,131,95,0.22), transparent 65%),
    repeating-linear-gradient(135deg, transparent 0 12px, rgba(22,131,95,0.04) 12px 13px);
}
.client-profile-avatar {
  position: relative; width: 72px; height: 72px; margin: 10px auto 12px;
  border: 4px solid var(--card); border-radius: 24px; font-size: 21px;
  box-shadow: 0 7px 18px rgba(18,68,52,0.18);
}
.client-profile-card h1 { position: relative; margin-bottom: 8px; font-size: 19px; }
.client-profile-card > .client-status { position: relative; margin: 0 auto; }
.client-contact-stack {
  display: flex; flex-direction: column; gap: 1px; margin: 20px -6px 14px;
  border-top: 1px solid var(--row-border); border-bottom: 1px solid var(--row-border);
}
.client-contact-stack > a, .client-contact-stack > div {
  display: flex; align-items: center; gap: 10px; padding: 9px 6px;
  color: inherit; text-align: left; text-decoration: none;
}
.client-contact-stack > a:hover { border-radius: 8px; background: var(--hover); }
.client-contact-stack > a > span, .client-contact-stack > div > span {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  flex-shrink: 0; border-radius: 8px; color: var(--client-accent); background: var(--client-soft);
  font-size: 12px;
}
.client-contact-stack div div, .client-contact-stack a div {
  display: flex; flex-direction: column; min-width: 0;
}
.client-contact-stack small, .client-profile-manager small,
.client-profile-dates small { color: var(--muted); font-size: 12px; }
.client-contact-stack b {
  max-width: 200px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap;
}
.client-profile-card > .client-tags { justify-content: center; margin: 10px 0 16px; }
.client-profile-manager {
  display: flex; flex-direction: column; gap: 3px; padding: 11px;
  border-radius: 9px; text-align: left; background: var(--hover);
}
.client-profile-manager b { font-size: 12px; }
.client-profile-dates {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; text-align: left;
}
.client-profile-dates span { display: flex; flex-direction: column; gap: 2px; }
.client-profile-dates b { font-size: 12px; font-weight: 600; }

.client-workspace { min-width: 0; overflow: hidden; }
.client-stat-strip {
  display: grid; grid-template-columns: repeat(4, minmax(80px, 1fr)) minmax(120px, 1.35fr);
  border-bottom: 1px solid var(--row-border);
}
.client-stat-strip > div {
  display: flex; flex-direction: column; gap: 3px; padding: 17px 14px;
  border-right: 1px solid var(--row-border);
}
.client-stat-strip > div:last-child { border-right: 0; }
.client-stat-strip b { font-size: 18px; }
.client-stat-strip span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.client-stat-strip .money { color: #087454; background: #f3fbf7; }
.client-tabs {
  display: flex; gap: 2px; padding: 10px 13px 0; overflow-x: auto;
  border-bottom: 1px solid var(--row-border);
}
.client-tabs button {
  display: inline-flex; align-items: center; gap: 5px; padding: 9px 10px;
  border: none; border-bottom: 2px solid transparent; color: var(--muted);
  background: none; font-family: inherit; font-size: 12px; font-weight: 650;
  white-space: nowrap; cursor: pointer;
}
.client-tabs button.active { color: var(--client-accent); border-bottom-color: var(--client-accent); }
.client-tabs button span {
  min-width: 16px; padding: 2px 5px; border-radius: 9px;
  color: var(--client-accent); background: var(--client-soft); font-size: 12px;
}
.client-tab-content { min-height: 360px; padding: 17px; }
.client-tab-empty {
  display: flex; align-items: center; justify-content: center; min-height: 280px;
  color: var(--muted); font-size: 12px; text-align: center;
}
.client-purchase-list, .client-record-list, .client-timeline, .client-finance-list {
  display: flex; flex-direction: column; gap: 9px;
}
.client-purchase-card {
  display: flex; gap: 13px; padding: 13px; border: 1px solid var(--border);
  border-radius: 11px; background: var(--hover);
}
.client-purchase-mark {
  display: flex; align-items: center; justify-content: center; width: 43px; height: 43px;
  flex-shrink: 0; border-radius: 11px; color: #fff; background: #173f34; font-size: 12px; font-weight: 750;
}
.client-purchase-main { flex: 1; min-width: 0; }
.client-purchase-head, .client-property-meta, .client-payment-caption {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.client-purchase-head > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.client-purchase-head b { font-size: 12px; }
.client-purchase-head span, .client-property-meta span, .client-payment-caption {
  color: var(--muted); font-size: 12px;
}
.client-property-status { padding: 4px 7px; border-radius: 99px; font-size: 12px !important; font-weight: 700; }
.client-property-status.reserved { color: #995b00; background: #fff2cc; }
.client-property-status.sold { color: #087454; background: #dcfce7; }
.client-property-status.available { color: #64748b; background: #e2e8f0; }
.client-property-meta { margin-top: 11px; }
.client-property-meta strong { font-size: 12px; }
.client-payment-line { height: 5px; margin-top: 9px; overflow: hidden; border-radius: 9px; background: #dfe7e3; }
.client-payment-line div { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1c9b70, #61c39f); }
.client-payment-caption { margin-top: 5px; }
.client-payment-caption b { color: var(--client-accent); font-size: 12px; }
.client-record {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center;
  gap: 10px; width: 100%; padding: 11px; border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); text-align: left; background: var(--card);
  font-family: inherit; cursor: pointer;
}
.client-record:hover { background: var(--hover); border-color: color-mix(in srgb, var(--client-accent) 45%, var(--border)); }
.client-record span:nth-child(2) { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.client-record b { font-size: 12px; }
.client-record small { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.client-record strong { font-size: 12px; }
.client-record i { color: var(--client-accent); font-size: 12px; font-style: normal; }
.client-record-dot { width: 8px; height: 8px; border-radius: 50%; }
.client-record-static { cursor: default; }
.client-event-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border-radius: 8px; color: var(--client-accent); background: var(--client-soft);
}
.client-timeline-item { display: flex; gap: 10px; }
.client-timeline-item > span {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  flex-shrink: 0; border-radius: 9px; color: var(--client-accent); background: var(--client-soft);
}
.client-timeline-item > div {
  display: flex; flex-direction: column; gap: 4px; flex: 1; padding: 4px 0 12px;
  border-bottom: 1px solid var(--row-border);
}
.client-timeline-item b { font-size: 12px; font-weight: 600; }
.client-timeline-item small { color: var(--muted); font-size: 12px; }
.client-finance-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(115px, auto);
  align-items: center; gap: 10px; padding: 11px; border-bottom: 1px solid var(--row-border);
}
.client-finance-row > span {
  display: inline-flex; align-items: center; justify-content: center; width: 25px; height: 25px;
  border-radius: 50%; font-size: 12px;
}
.client-finance-row .is-paid { color: #087454; background: #dcfce7; }
.client-finance-row .is-waiting { color: #995b00; background: #fff2cc; }
.client-finance-row div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.client-finance-row b, .client-finance-row strong { font-size: 12px; }
.client-finance-row small, .client-finance-row time { color: var(--muted); font-size: 12px; }
.client-notes { display: flex; flex-direction: column; align-items: flex-end; gap: 9px; }
.client-notes textarea { width: 100%; resize: vertical; line-height: 1.55; }

:root[data-theme="dark"] .clients-page { --client-ink: #e6edf7; --client-accent: #51c99e; --client-soft: #15352a; }
:root[data-theme="dark"] .client-kpi-icon.blue { background: #142d51; color: #93c5fd; }
:root[data-theme="dark"] .client-kpi-icon.green { background: #15352a; color: #6ee7b7; }
:root[data-theme="dark"] .client-kpi-icon.amber { background: #382a10; color: #fcd34d; }
:root[data-theme="dark"] .client-kpi-icon.coral { background: #3a211c; color: #fdba9a; }
:root[data-theme="dark"] .client-kpi-money {
  background:
    radial-gradient(circle at 12% 15%, rgba(255,255,255,0.12), transparent 30%),
    linear-gradient(135deg, #15352a, #12624a) !important;
}
:root[data-theme="dark"] .client-status-active { color: #6ee7b7; background: #15352a; }
:root[data-theme="dark"] .client-status-vip { color: #fcd34d; background: #382a10; }
:root[data-theme="dark"] .client-status-inactive { color: #94a3b8; background: #26344a; }
:root[data-theme="dark"] .client-status-blacklist { color: #fda4af; background: #3a1b24; }
:root[data-theme="dark"] .client-tags span { border-color: #214c3c; color: #86efac; background: #10291f; }
:root[data-theme="dark"] .client-error { border-color: #7f1d1d; color: #fca5a5; background: #2b151b; }
:root[data-theme="dark"] .client-stat-strip .money { color: #6ee7b7; background: #10291f; }
:root[data-theme="dark"] .client-property-status.reserved,
:root[data-theme="dark"] .client-finance-row .is-waiting { color: #fcd34d; background: #382a10; }
:root[data-theme="dark"] .client-property-status.sold,
:root[data-theme="dark"] .client-finance-row .is-paid { color: #6ee7b7; background: #15352a; }
:root[data-theme="dark"] .client-property-status.available { color: #cbd5e1; background: #26344a; }
:root[data-theme="dark"] .client-payment-line { background: #26344a; }

@media (max-width: 1120px) {
  .client-kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .client-kpi-money { justify-content: flex-start; }
  .client-kpi-money p { align-items: flex-start; }
}
@media (max-width: 900px) {
  .client-360-grid { grid-template-columns: 1fr; }
  .client-profile-card { position: static; }
  .client-contact-stack { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .client-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .client-kpi-money { grid-column: 1 / -1; }
  .client-filters { align-items: stretch; flex-direction: column; }
  .client-search { min-width: 0; }
  .client-result-count { margin-left: 0; }
  .client-form-grid { grid-template-columns: 1fr; }
  .client-field-wide { grid-column: auto; }
  .client-stat-strip { grid-template-columns: repeat(2, 1fr); }
  .client-stat-strip .money { grid-column: 1 / -1; }
  .client-contact-stack { grid-template-columns: 1fr; }
  .client-purchase-head, .client-property-meta { align-items: flex-start; flex-direction: column; }
  .client-record { grid-template-columns: auto minmax(0, 1fr) auto; }
  .client-record i { display: none; }
  .client-finance-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .client-finance-row time { grid-column: 2 / -1; }
}

/* Клієнти: вирівнювання з наданим CRM-прототипом */
.clients-page {
  --client-accent: #3b82f6;
  --client-soft: #dbeafe;
}
.btn-outline {
  border: 1px solid var(--border); color: var(--muted); background: transparent;
}
.btn-outline:hover { border-color: #3b82f6; color: #3b82f6; background: transparent; }
.client-prototype-list { padding: 20px; overflow: visible; }
.client-list-titlebar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.client-list-titlebar h1 { margin: 0; color: var(--text); font-size: 15px; letter-spacing: 0; }
.client-list-titlebar p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.client-prototype-list .client-filters {
  padding: 0; margin-bottom: 16px; border: 0; flex-wrap: wrap;
}
.client-prototype-list .client-search { flex: 0 1 270px; min-width: 220px; }
.client-prototype-list .client-search span { left: 10px; font-size: 12px; }
.client-prototype-list .client-search input { padding-left: 32px; }
.client-prototype-list .client-filters input,
.client-prototype-list .client-filters select {
  height: 34px; padding-top: 7px; padding-bottom: 7px; border-radius: 6px;
}
.client-prototype-list .client-table-wrap { margin: 0 -10px -8px; }
.client-prototype-list .client-table { min-width: 970px; font-size: 13px; }
.client-prototype-list .client-table th {
  padding: 10px; border-bottom: 2px solid var(--border); font-size: 12px;
  font-weight: 650; letter-spacing: 0.05em;
}
.client-prototype-list .client-table td { padding: 10px; font-size: 12px; }
.client-table-person > span {
  width: 36px; height: 36px; border-radius: 50%; font-size: 12px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
}
.client-table-person > div { gap: 2px; }
.client-table-person > div small { color: var(--muted); font-size: 12px; }
.client-table-contact b { color: var(--text); font-weight: 500; }
.client-tags span {
  padding: 3px 8px; border: 0; border-radius: 4px;
  color: #1e40af; background: #dbeafe; font-size: 12px; font-weight: 500;
}
.client-tags span:nth-child(3n + 2) { color: #9d174d; background: #fce7f3; }
.client-tags span:nth-child(3n + 3) { color: #065f46; background: #d1fae5; }
.client-tags-table { max-width: 220px; }
.client-card-button { padding: 6px 12px; border-radius: 6px; font-size: 12px; }
.client-result-count { font-size: 12px; }

.client-profile-shell { padding: 20px; }
.client-card-title {
  margin-bottom: 12px; color: var(--text); font-size: 15px; font-weight: 700;
}
.client-360-grid {
  grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start;
}
.client-profile-card {
  position: static; padding: 16px; overflow: visible; border: 0;
  border-radius: 12px; background: var(--hover); text-align: left;
}
.client-profile-card::before { display: none; }
.client-profile-center { margin-bottom: 16px; text-align: center; }
.client-profile-avatar {
  width: 80px; height: 80px; margin: 0 auto; border: 0; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  box-shadow: none; font-size: 24px;
}
.client-profile-center h2 { margin-top: 12px; font-size: 16px; }
.client-profile-center p { margin: 4px 0 8px; color: var(--muted); font-size: 12px; }
.client-profile-center .client-status { margin: 0 auto; }
.client-status {
  padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 500;
}
.client-contact-stack {
  display: flex; flex-direction: column; gap: 0; margin: 0;
  border: 0; font-size: 12px; line-height: 1.9;
}
.client-contact-stack > a, .client-contact-stack > div {
  display: block; padding: 0; color: var(--text); text-align: left; text-decoration: none;
}
.client-contact-stack > a:hover { color: #2563eb; background: transparent; }
.client-profile-tags {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.client-profile-tags > b { display: block; margin-bottom: 6px; font-size: 12px; }
.client-profile-stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; text-align: center;
}
.client-profile-stat-grid > div { padding: 8px; border-radius: 6px; background: var(--bg); }
.client-profile-stat-grid b { display: block; color: var(--text); font-size: 15px; }
.client-profile-stat-grid span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.client-workspace { border: 0; border-radius: 0; background: transparent; overflow: visible; }
.client-tabs {
  display: flex; gap: 0; padding: 0; margin-bottom: 16px;
  overflow-x: auto; border-bottom: 1px solid var(--border);
}
.client-tabs button {
  padding: 10px 14px; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 12px; font-weight: 500;
}
.client-tabs button.active {
  color: #3b82f6; border-bottom-color: #3b82f6; font-weight: 650;
}
.client-tab-content { min-height: 360px; padding: 0; }
.client-section-title { margin: 0 0 12px; color: var(--text); font-size: 12px; }
.client-purchase-list { gap: 12px; }
.client-purchase-card {
  display: block; padding: 16px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--hover);
}
.client-purchase-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.client-purchase-head > div { display: block; }
.client-purchase-head b { display: block; color: var(--text); font-size: 13px; }
.client-purchase-head span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.client-property-status { flex-shrink: 0; padding: 4px 10px; border-radius: 12px; font-size: 12px !important; }
.client-purchase-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
}
.client-purchase-grid > div {
  min-width: 0; padding: 8px; border-radius: 6px; background: var(--card); text-align: center;
}
.client-purchase-grid span {
  display: block; overflow: hidden; color: var(--muted); font-size: 12px;
  text-overflow: ellipsis; white-space: nowrap;
}
.client-purchase-grid b {
  display: block; margin-top: 3px; overflow: hidden; color: var(--text); font-size: 12px;
  text-overflow: ellipsis; white-space: nowrap;
}
.client-payment-history {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.client-payment-title { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.client-payment-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.client-payment-tags span {
  display: inline-block; padding: 4px 8px; border-radius: 4px; font-size: 12px;
}
.client-payment-tags .payment-paid { color: #065f46; background: #d1fae5; }
.client-payment-tags .payment-pending { color: #92400e; background: #fef3c7; }
.client-payment-tags .payment-empty { color: var(--muted); background: var(--bg); }
.client-payment-progress {
  height: 4px; margin-top: 9px; overflow: hidden; border-radius: 9px; background: var(--border);
}
.client-payment-progress div { height: 100%; background: #10b981; }
.client-payment-history > small {
  display: block; margin-top: 5px; color: var(--muted); font-size: 12px; text-align: right;
}
.client-document-list { display: flex; flex-direction: column; gap: 8px; }
.client-document-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center;
  gap: 8px; padding: 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--hover);
}
.client-document-row > div { display: flex; flex-direction: column; gap: 3px; }
.client-document-row b { font-size: 12px; }
.client-document-row span { color: var(--muted); font-size: 12px; }
.client-document-row .btn { padding: 6px 9px; font-size: 12px; }

:root[data-theme="dark"] .client-tags span { color: #93c5fd; background: #142d51; }
:root[data-theme="dark"] .client-tags span:nth-child(3n + 2) { color: #f9a8d4; background: #3b1c36; }
:root[data-theme="dark"] .client-tags span:nth-child(3n + 3) { color: #6ee7b7; background: #15352a; }
:root[data-theme="dark"] .client-profile-card,
:root[data-theme="dark"] .client-purchase-card,
:root[data-theme="dark"] .client-document-row { background: var(--hover); }
:root[data-theme="dark"] .client-profile-stat-grid > div,
:root[data-theme="dark"] .client-purchase-grid > div { background: var(--card); }
:root[data-theme="dark"] .client-payment-tags .payment-paid { color: #6ee7b7; background: #15352a; }
:root[data-theme="dark"] .client-payment-tags .payment-pending { color: #fcd34d; background: #382a10; }

@media (max-width: 960px) {
  .client-360-grid { grid-template-columns: 250px minmax(0, 1fr); }
  .client-purchase-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  .client-360-grid { grid-template-columns: 1fr; }
  .client-list-titlebar { align-items: flex-start; }
  .client-profile-card { max-width: none; }
  .client-contact-stack { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
}
@media (max-width: 600px) {
  .client-prototype-list, .client-profile-shell { padding: 14px; }
  .client-list-titlebar { flex-direction: column; }
  .client-list-titlebar .btn { width: 100%; }
  .client-prototype-list .client-search { flex-basis: 100%; }
  .client-prototype-list .client-filters select { flex: 1; min-width: 135px; }
  .client-contact-stack { grid-template-columns: 1fr; }
  .client-purchase-head { flex-direction: column; }
  .client-purchase-grid { grid-template-columns: 1fr 1fr; }
  .client-document-row { grid-template-columns: 1fr 1fr; }
  .client-document-row > div { grid-column: 1 / -1; }
}

/* Глобальна візуальна система CRM-прототипу */
.page-head { margin-bottom: 16px; }
.page-head h1 { color: var(--text); font-size: 20px; letter-spacing: -0.02em; }
.page-head .muted { font-size: 12px; }
.dashboard-widget {
  border-color: transparent; background: var(--card);
  box-shadow: 0 1px 3px rgba(15,23,42,0.08);
}
.dashboard-widget-head {
  min-height: 46px; padding: 12px 14px; border-bottom-color: var(--row-border);
}
.dashboard-widget-head h3 { color: var(--text); font-size: 13px; }
.dashboard-widget-body { padding: 16px; }
.dashboard-widget-body .kpi {
  border-color: var(--border); border-radius: 10px; background: var(--card);
  box-shadow: none;
}
.kpi-value { font-size: 22px; }
.period { border-radius: 8px; background: var(--hover); }
.modal { border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(15,23,42,0.22); }
.modal-head { padding-bottom: 12px; border-bottom: 1px solid var(--row-border); }
.modal-foot { padding-top: 14px; border-top: 1px solid var(--row-border); }
.kanban-card, .chess-section, .payment-form, .role-card {
  border-radius: 8px;
}
.security-tabs {
  display: flex; border-bottom: 1px solid var(--border);
}
.security-tabs button { border-radius: 0; border-bottom: 2px solid transparent; }
.security-tabs button.active {
  color: var(--primary); border-bottom-color: var(--primary); background: transparent;
}
.permission-cloud code { color: #1e40af; background: #dbeafe; }
.role-card { background: var(--card); border-color: var(--border); }
.integrations-page { --hub-accent: #3b82f6; }
.integrations-hero {
  align-items: center; padding: 20px; border: 1px solid transparent;
  border-radius: 12px; color: var(--text); background: var(--card);
  box-shadow: 0 1px 3px rgba(15,23,42,0.08);
}
.integrations-hero::after { display: none; }
.integrations-hero h1 { margin: 2px 0 5px; font-size: 22px; }
.integrations-hero p { color: var(--muted); font-size: 12px; }
.integrations-eyebrow { color: var(--primary); }
.hub-live {
  color: #166534; border-color: #bbf7d0; background: #f0fdf4;
}
.hub-live span { background: #22c55e; box-shadow: 0 0 0 4px #dcfce7; }
.hub-kpis > div, .integration-card {
  border-radius: 10px; background: var(--card);
  box-shadow: 0 1px 3px rgba(15,23,42,0.06);
}
.integration-card { border-left: 4px solid var(--primary); }
.integration-card:hover { transform: none; border-color: var(--primary); }
.integration-sources {
  border-color: #bfdbfe; background: linear-gradient(145deg, #eff6ff, var(--card) 70%);
}
.sources-head h4 { color: #1e40af; }
.source-total { color: #dbeafe; background: #1d4ed8; }
.source-editor { border-color: #bfdbfe; }
.source-empty { border-color: #93c5fd; color: #1d4ed8; }
.integration-mini-log, .source-item, .endpoint-box { border-radius: 8px; }

:root[data-theme="dark"] .card,
:root[data-theme="dark"] .dashboard-widget,
:root[data-theme="dark"] .integrations-hero {
  border-color: var(--border); box-shadow: none;
}
:root[data-theme="dark"] .hub-live {
  color: #86efac; border-color: #166534; background: #0d2a20;
}
:root[data-theme="dark"] .permission-cloud code { color: #93c5fd; background: #142d51; }
:root[data-theme="dark"] .integration-sources {
  border-color: #1e4d82; background: linear-gradient(145deg, #10284a, var(--card) 70%);
}
:root[data-theme="dark"] .sources-head h4 { color: #93c5fd; }

@media (max-width: 760px) {
  .sidebar-section, .nav-label { display: none; }
  .nav-group { gap: 2px; }
  .app-header-context strong { font-size: 15px; }
  .header-user-copy { display: none; }
  .reservation-term-row { grid-template-columns: 1fr; }
  .reservation-extend { align-items: stretch; flex-direction: column; }
  .reservation-extend select { width: 100%; }
}

/* Єдина типографіка для розділу клієнтів */
.clients-page,
.clients-page button,
.clients-page input,
.clients-page select,
.clients-page textarea { font-family: inherit; }
.client-list-titlebar h1 {
  font-size: 20px; font-weight: 700; letter-spacing: -0.02em;
}
.client-list-titlebar p { font-size: 12px; }
.client-prototype-list .client-table { font-size: 13px; }
.client-prototype-list .client-table th { font-size: 12px; }
.client-prototype-list .client-table td { font-size: 13px; }
.client-table-person b, .client-table-contact b { font-size: 13px; }
.client-table-person > div small, .client-table-contact span { font-size: 12px; }
.client-card-button { font-size: 12px; }
.client-profile-card { font-size: 13px; }
.client-contact-stack { font-size: 13px; }
.client-tabs button { font-size: 12px; }
.client-section-title { font-size: 13px; }
.client-purchase-head b { font-size: 14px; }
.client-purchase-head span { font-size: 12px; }

/* Єдиний центр повідомлень */
.messages-page { min-height: calc(100vh - 112px); }
.messages-titlebar { margin-bottom: 14px; }
.messages-titlebar h1 { margin-bottom: 4px; }
.message-live {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 999px; color: var(--muted);
  background: var(--card); font-size: 12px; font-weight: 650;
}
.message-live i { width: 7px; height: 7px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 4px #dcfce7; }
.message-page-error {
  margin-bottom: 10px; padding: 10px 12px; border: 1px solid #fecaca;
  border-radius: 8px; background: #fef2f2; color: #b91c1c; font-size: 12px;
}
.message-workspace {
  display: grid; grid-template-columns: 320px minmax(420px, 1fr) 250px;
  min-height: 690px; height: calc(100vh - 150px); overflow: hidden;
  border: 1px solid var(--border); border-radius: 14px; background: var(--card);
  box-shadow: 0 8px 25px rgba(15,23,42,0.07);
}
.message-sidebar { display: flex; min-width: 0; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--card); }
.message-filters { padding: 13px; border-bottom: 1px solid var(--border); }
.message-filters input { width: 100%; }
.message-filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 7px; }
.message-filter-row select { width: 100%; font-size: 12px; }
.message-conversation-list { flex: 1; overflow-y: auto; }
.message-conversation {
  position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 9px;
  width: 100%; padding: 13px 12px; border: 0; border-bottom: 1px solid var(--row-border);
  background: transparent; color: var(--text); font-family: inherit; text-align: left;
  cursor: pointer;
}
.message-conversation:hover { background: var(--hover); }
.message-conversation.active { background: color-mix(in srgb, var(--primary) 9%, var(--card)); }
.message-conversation.active::before { content: ""; position: absolute; inset: 0 auto 0 0;
  width: 3px; background: var(--primary); }
.message-contact-avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: 50%; background: linear-gradient(145deg, #dbeafe, #ccfbf1);
  color: #164e63; font-size: 12px; font-weight: 800;
}
.message-contact-avatar.large { width: 66px; height: 66px; font-size: 17px; }
.message-conversation-copy { min-width: 0; }
.message-conversation-copy > div { display: flex; justify-content: space-between; gap: 8px; }
.message-conversation-copy b { overflow: hidden; font-size: 12px; text-overflow: ellipsis;
  white-space: nowrap; }
.message-conversation-copy time { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.message-conversation-copy p { overflow: hidden; margin: 5px 0; color: var(--muted);
  font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.message-conversation-copy > span { display: flex; align-items: center; gap: 5px;
  overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis;
  white-space: nowrap; }
.message-unread-count { position: absolute; right: 11px; bottom: 11px; display: inline-flex;
  align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--primary); color: #fff; font-size: 12px;
  font-style: normal; font-weight: 800; }
.message-channel-mark { display: inline-flex; flex: 0 0 auto; align-items: center;
  justify-content: center; width: 38px; height: 38px; border-radius: 10px;
  color: #fff; background: var(--message-channel); font-size: 12px; font-weight: 850; }
.message-channel-mark.small { width: 18px; height: 18px; border-radius: 5px; font-size: 12px; }
.message-list-empty, .message-thread-empty { display: flex; flex: 1; flex-direction: column;
  align-items: center; justify-content: center; gap: 7px; padding: 30px;
  color: var(--muted); text-align: center; }
.message-list-empty b, .message-thread-empty b { color: var(--text); font-size: 12px; }
.message-list-empty span, .message-thread-empty p { max-width: 250px; font-size: 12px; line-height: 1.5; }
.message-thread-empty > span { font-size: 34px; filter: grayscale(1); opacity: 0.55; }
.message-thread { display: flex; min-width: 0; flex-direction: column; background:
  radial-gradient(circle at 10% 10%, rgba(37,99,235,0.035), transparent 28%),
  var(--hover); }
.message-thread-head { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-height: 67px; padding: 11px 15px; border-bottom: 1px solid var(--border);
  background: var(--card); }
.message-thread-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.message-thread-person h3 { overflow: hidden; margin: 0 0 3px; font-size: 13px;
  text-overflow: ellipsis; white-space: nowrap; }
.message-thread-person span { color: var(--muted); font-size: 12px; }
.message-thread-actions { display: flex; gap: 6px; }
.message-thread-body { flex: 1; overflow-y: auto; padding: 20px clamp(13px, 3vw, 34px); }
.message-thread-date { width: fit-content; margin: 0 auto 18px; padding: 4px 8px;
  border-radius: 999px; background: var(--card); color: var(--muted); font-size: 12px;
  box-shadow: 0 1px 3px rgba(15,23,42,0.06); }
.message-row { display: flex; margin: 8px 0; }
.message-row.outbound { justify-content: flex-end; }
.message-bubble { max-width: min(74%, 560px); padding: 9px 11px 7px; border: 1px solid var(--border);
  border-radius: 4px 13px 13px 13px; background: var(--card);
  box-shadow: 0 1px 2px rgba(15,23,42,0.05); }
.message-row.outbound .message-bubble { border-color: #bfdbfe; border-radius: 13px 4px 13px 13px;
  background: #eff6ff; }
.message-bubble.failed { border-color: #fecaca !important; background: #fef2f2 !important; }
.message-bubble > b { display: block; margin-bottom: 3px; color: var(--primary); font-size: 12px; }
.message-bubble p { font-size: 12px; line-height: 1.48; white-space: pre-wrap; word-break: break-word; }
.message-bubble footer { display: flex; align-items: center; justify-content: flex-end; gap: 7px;
  margin-top: 5px; color: var(--muted); font-size: 12px; }
.message-delivery { display: inline-flex; gap: 3px; }
.message-read { color: #2563eb; }
.message-failed { color: #dc2626; }
.message-error { margin-top: 5px; color: #b91c1c; font-size: 12px; }
.message-media-image { display: block; overflow: hidden; margin-bottom: 7px; border-radius: 9px; }
.message-media-image img { display: block; width: min(360px, 100%); max-height: 320px;
  object-fit: cover; }
.message-media-player { display: block; width: min(330px, 100%); margin: 2px 0 7px; }
.message-media-video { display: block; width: min(380px, 100%); max-height: 360px;
  margin-bottom: 7px; border-radius: 9px; background: #0f172a; }
.message-media-file { display: flex; align-items: center; gap: 9px; min-width: 220px;
  margin-bottom: 7px; padding: 9px; border: 1px solid var(--border); border-radius: 9px;
  background: color-mix(in srgb, var(--primary) 5%, var(--card)); color: var(--text); }
.message-media-file > span { display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 7px; background: var(--primary); color: #fff;
  font-size: 12px; font-weight: 850; }
.message-media-file div { min-width: 0; }
.message-media-file b, .message-media-file small { display: block; }
.message-media-file b { overflow: hidden; max-width: 240px; font-size: 12px;
  text-overflow: ellipsis; white-space: nowrap; }
.message-media-file small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.message-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border);
  background: var(--card); }
.message-compose-input { display: grid; min-width: 0; }
.message-composer textarea { width: 100%; min-height: 55px; max-height: 140px; resize: vertical;
  line-height: 1.45; }
.message-compose-input > span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.message-composer > .btn { min-height: 55px; }
.message-file-input { display: none; }
.message-attach-button { min-width: 102px; }
.message-readonly-note { margin-bottom: 7px !important; padding: 7px 9px; border-radius: 6px;
  background: #fffbeb; color: #92400e; font-size: 12px; }
.message-readonly-note, .message-template-note, .message-attachment-preview {
  grid-column: 1 / -1;
}
.message-template-note { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 9px 10px; border: 1px solid #fde68a; border-radius: 8px;
  background: #fffbeb; color: #78350f; }
.message-template-note b, .message-template-note span { display: block; }
.message-template-note b { font-size: 12px; }
.message-template-note span { margin-top: 2px; font-size: 12px; }
.message-template-note .btn { flex: 0 0 auto; }
.message-attachment-preview { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 8px 10px; border: 1px solid #bfdbfe; border-radius: 8px;
  background: #eff6ff; }
.message-attachment-preview b, .message-attachment-preview span { display: block; }
.message-attachment-preview b { max-width: 430px; overflow: hidden; font-size: 12px;
  text-overflow: ellipsis; white-space: nowrap; }
.message-attachment-preview span { margin-top: 2px; color: #1d4ed8; font-size: 12px; }
.message-attachment-preview button { width: 25px; height: 25px; padding: 0; border: 0;
  border-radius: 50%; background: #dbeafe; color: #1d4ed8; cursor: pointer; }
.message-context { padding: 18px 15px; border-left: 1px solid var(--border); background: var(--card); }
.message-context-person { display: flex; flex-direction: column; align-items: center;
  padding-bottom: 17px; border-bottom: 1px solid var(--row-border); text-align: center; }
.message-context-person h3 { margin: 10px 0 3px; font-size: 13px; }
.message-context-person span { color: var(--muted); font-size: 12px; }
.message-context dl { margin: 12px 0; }
.message-context dl > div { display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--row-border); }
.message-context dt { color: var(--muted); font-size: 12px; }
.message-context dd { max-width: 58%; font-size: 12px; font-weight: 700; text-align: right; }
.message-context > .btn { width: 100%; }
.messenger-connection-row { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 12px; }
:root[data-theme="dark"] .message-row.outbound .message-bubble {
  border-color: #1e4d82; background: #10284a;
}
:root[data-theme="dark"] .message-contact-avatar { color: #bae6fd;
  background: linear-gradient(145deg, #17345d, #12433f); }
:root[data-theme="dark"] .message-readonly-note { background: #30220e; color: #fcd34d; }
:root[data-theme="dark"] .message-template-note { border-color: #78350f;
  background: #30220e; color: #fcd34d; }
:root[data-theme="dark"] .message-attachment-preview { border-color: #1e4d82;
  background: #10284a; }
:root[data-theme="dark"] .message-page-error,
:root[data-theme="dark"] .message-bubble.failed { border-color: #7f1d1d;
  background: #32151b !important; color: #fca5a5; }
@media (max-width: 1180px) {
  .message-workspace { grid-template-columns: 290px minmax(390px, 1fr); }
  .message-context { display: none; }
}
@media (max-width: 760px) {
  .message-workspace { display: block; height: auto; min-height: 620px; overflow: visible; }
  .message-sidebar { height: 310px; border-right: 0; border-bottom: 1px solid var(--border); }
  .message-thread { min-height: 590px; }
  .message-thread-head { align-items: flex-start; flex-direction: column; }
  .message-thread-actions { width: 100%; }
  .message-thread-actions .btn { flex: 1; }
  .message-bubble { max-width: 88%; }
  .message-composer { grid-template-columns: 1fr 1fr; }
  .message-compose-input { grid-column: 1 / -1; }
  .message-composer > .btn { min-height: 40px; }
  .messenger-connection-row { align-items: stretch; flex-direction: column; }
}

/* Профілі користувачів */
.profile-page { display: grid; gap: 18px; }
.profile-avatar {
  display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center;
  width: 36px; height: 36px; overflow: hidden; border-radius: 50%;
  background: linear-gradient(145deg, #2563eb, #0f766e); color: #fff;
  font-size: 12px; font-weight: 750; letter-spacing: 0.02em;
}
.profile-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.header-user-avatar > .profile-avatar { width: 36px; height: 36px; }
.profile-avatar-xl {
  width: 126px; height: 126px; border: 4px solid rgba(255,255,255,0.72);
  box-shadow: 0 12px 30px rgba(3,19,35,0.24); font-size: 31px;
}
.profile-avatar-lg { width: 104px; height: 104px; font-size: 26px; }
.profile-avatar-table { width: 38px; height: 38px; font-size: 12px; }
.profile-avatar-sidebar { width: 31px; height: 31px; font-size: 12px; }
.profile-hero {
  position: relative; display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: 26px; min-height: 210px; margin: 0; padding: 30px;
  overflow: hidden; border: 0; color: #fff;
  background:
    radial-gradient(circle at 84% 10%, rgba(94,234,212,0.19), transparent 28%),
    linear-gradient(125deg, #0f2740 0%, #123d52 54%, #0f665f 100%);
  box-shadow: 0 12px 30px rgba(15,39,64,0.16);
}
.profile-hero::after {
  content: ""; position: absolute; right: -80px; bottom: -130px;
  width: 310px; height: 310px; border: 1px solid rgba(255,255,255,0.14);
  border-radius: 50%; box-shadow: 0 0 0 46px rgba(255,255,255,0.035);
}
.profile-photo-column, .profile-identity, .profile-completeness {
  position: relative; z-index: 1;
}
.profile-photo-column { display: flex; flex-direction: column; align-items: center; gap: 9px; }
.profile-photo-column .muted { color: rgba(255,255,255,0.66); }
.profile-photo-actions { display: flex; gap: 6px; }
.profile-photo-actions .btn {
  padding: 6px 9px; border-color: rgba(255,255,255,0.24);
  background: rgba(255,255,255,0.1); color: #fff;
}
.profile-photo-actions .btn-primary { background: #fff; border-color: #fff; color: #123d52; }
.profile-file-input { display: none !important; }
.profile-eyebrow {
  color: #99f6e4; font-size: 12px; font-weight: 750;
  letter-spacing: 0.14em; text-transform: uppercase;
}
.profile-identity h1 {
  margin: 7px 0 5px; color: #fff; font-size: clamp(25px, 3vw, 38px);
  line-height: 1.08; letter-spacing: -0.035em;
}
.profile-identity p { color: rgba(255,255,255,0.74); font-size: 13px; }
.profile-badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.profile-badges .badge { border: 1px solid rgba(255,255,255,0.16); }
.profile-completeness {
  min-width: 150px; padding: 17px; border: 1px solid rgba(255,255,255,0.16);
  border-radius: 12px; background: rgba(5,24,38,0.23); backdrop-filter: blur(6px);
}
.profile-completeness strong { display: block; font-size: 28px; }
.profile-completeness span { color: rgba(255,255,255,0.7); font-size: 12px; }
.profile-completeness > div {
  height: 5px; margin-top: 12px; overflow: hidden; border-radius: 9px;
  background: rgba(255,255,255,0.16);
}
.profile-completeness i {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, #5eead4, #fff);
}
.profile-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; }
.profile-form-card { margin: 0; }
.profile-form-card h3, .profile-info-card h3 { margin-bottom: 4px; }
.profile-form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; margin-top: 13px;
}
.profile-form-grid label {
  position: relative; display: flex; flex-direction: column; gap: 6px;
  color: var(--muted); font-size: 12px;
}
.profile-form-wide { grid-column: 1 / -1; }
.profile-form-grid textarea { resize: vertical; min-height: 112px; line-height: 1.5; }
.profile-form-grid input:disabled {
  color: var(--muted); background: var(--hover); cursor: not-allowed;
}
.profile-input-prefix {
  display: flex; align-items: center; overflow: hidden; border: 1px solid var(--border);
  border-radius: 6px; background: var(--input);
}
.profile-input-prefix:focus-within { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.profile-input-prefix span { padding-left: 11px; color: var(--muted); }
.profile-input-prefix input { border: 0; outline: 0; padding-left: 3px; }
.profile-char-count { position: absolute; right: 8px; bottom: 7px; font-size: 12px; }
.profile-form-actions { display: flex; justify-content: flex-end; margin-top: 15px; }
.profile-notice {
  margin-top: 12px; padding: 10px 12px; border: 1px solid #bfdbfe;
  border-radius: 8px; background: #eff6ff; color: #1d4ed8; font-size: 12px;
}
.profile-side-stack { display: grid; align-content: start; gap: 14px; }
.profile-info-card { margin: 0; }
.profile-info-card dl { display: grid; gap: 0; margin-top: 10px; }
.profile-info-card dl > div {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--row-border);
}
.profile-info-card dt { color: var(--muted); font-size: 12px; }
.profile-info-card dd { max-width: 58%; font-size: 12px; font-weight: 650; text-align: right; }
.profile-security-button { width: 100%; margin-top: 13px; }
.security-user-cell { display: flex; align-items: center; gap: 9px; min-width: 190px; }
.security-user-cell > span { display: grid; gap: 1px; min-width: 0; }
.security-user-cell small {
  display: block; overflow: hidden; color: var(--muted); font-size: 12px;
  text-overflow: ellipsis; white-space: nowrap;
}
.user-profile-modal { max-width: 820px; background: var(--card); }
.user-profile-editor { display: grid; grid-template-columns: 140px 1fr; gap: 22px; }
.user-profile-photo {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--hover);
}
.user-profile-photo .btn { width: 100%; padding: 7px 8px; }
.user-profile-fields { margin: 0; }
:root[data-theme="dark"] .profile-notice {
  border-color: #1e4d82; background: #10284a; color: #93c5fd;
}
@media (max-width: 900px) {
  .profile-hero { grid-template-columns: auto 1fr; }
  .profile-completeness { grid-column: 1 / -1; width: 100%; }
  .profile-layout { grid-template-columns: 1fr; }
  .profile-side-stack { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 660px) {
  .profile-hero { grid-template-columns: 1fr; padding: 23px 17px; text-align: center; }
  .profile-identity { display: flex; flex-direction: column; align-items: center; }
  .profile-badges { justify-content: center; }
  .profile-form-grid, .profile-side-stack { grid-template-columns: 1fr; }
  .profile-form-wide { grid-column: auto; }
  .user-profile-editor { grid-template-columns: 1fr; }
  .user-profile-photo { max-width: 210px; margin: auto; }
}

/* Audit Log */
.audit-page { --audit-blue: #2563eb; --audit-teal: #0f766e; --audit-red: #b91c1c; }
.audit-summary-grid {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 9px;
}
.audit-stat {
  position: relative; min-height: 92px; margin: 0; padding: 14px;
  overflow: hidden; border-color: var(--border); box-shadow: none;
}
.audit-stat::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--audit-blue);
}
.audit-stat span { display: block; color: var(--muted); font-size: 12px; }
.audit-stat strong { display: block; margin-top: 9px; font-size: 25px; letter-spacing: -0.03em; }
.audit-stat-create::before { background: #16a34a; }
.audit-stat-update::before { background: #2563eb; }
.audit-stat-delete::before, .audit-stat-denied::before { background: #dc2626; }
.audit-stat-export::before { background: #0f766e; }
.audit-toolbar { margin: 0; }
.audit-toolbar .page-head { margin-bottom: 13px; }
.audit-toolbar .page-head h3 { margin-bottom: 3px; }
.audit-filter-grid {
  display: grid; grid-template-columns: minmax(210px, 1.5fr) repeat(3, minmax(130px, 1fr))
    repeat(2, minmax(125px, 0.8fr)) auto auto; gap: 7px;
}
.audit-filter-grid > * { min-width: 0; width: 100%; }
.audit-table-card { margin: 0; padding: 0; overflow: hidden; }
.audit-table { min-width: 1010px; }
.audit-table tr { cursor: pointer; }
.audit-table td { padding-top: 11px; padding-bottom: 11px; }
.audit-table td > small, .audit-table td > b {
  display: block; margin-top: 2px;
}
.audit-table td > small { color: var(--muted); font-size: 12px; }
.audit-table td > b { font-size: 12px; }
.audit-table time { white-space: nowrap; font-size: 12px; }
.audit-action {
  display: inline-flex; align-items: center; width: fit-content; margin-bottom: 4px;
  padding: 3px 7px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--hover); color: var(--muted); font-size: 12px; font-weight: 750;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.audit-create { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }
.audit-update { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }
.audit-delete { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.audit-export { border-color: #99f6e4; background: #f0fdfa; color: #0f766e; }
.audit-security { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.audit-result {
  display: inline-flex; padding: 4px 7px; border-radius: 6px;
  font-size: 12px; font-weight: 700;
}
.audit-result-success { color: #166534; background: #dcfce7; }
.audit-result-denied, .audit-result-failure { color: #991b1b; background: #fee2e2; }
.audit-details-modal { max-width: 930px; background: var(--card); }
.audit-details-modal .modal-head h3 { margin: 6px 0 3px; font-size: 19px; }
.audit-meta-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
}
.audit-meta-grid > div {
  min-width: 0; padding: 11px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--hover);
}
.audit-meta-grid span, .audit-agent span {
  display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px;
  font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}
.audit-meta-grid b { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; }
.audit-detail-note {
  margin-top: 11px; padding: 11px 13px; border-left: 3px solid var(--primary);
  border-radius: 6px; background: var(--hover); font-size: 12px; white-space: pre-wrap;
}
.audit-change-block { margin-top: 16px; }
.audit-change-block h4, .audit-snapshots h4 { margin-top: 0; }
.audit-diff-table { table-layout: fixed; }
.audit-diff-table th:first-child { width: 22%; }
.audit-diff-table pre, .audit-snapshots pre {
  max-height: 220px; overflow: auto; margin: 0; color: var(--text);
  font-family: ui-monospace, monospace; font-size: 12px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.audit-diff-table td:nth-child(2) { background: color-mix(in srgb, #dc2626 4%, var(--card)); }
.audit-diff-table td:nth-child(3) { background: color-mix(in srgb, #16a34a 5%, var(--card)); }
.audit-snapshots {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px;
}
.audit-snapshots > div {
  min-width: 0; padding: 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--hover);
}
.audit-agent {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
}
.audit-agent p { color: var(--muted); font-size: 12px; line-height: 1.5; word-break: break-word; }
:root[data-theme="dark"] .audit-create { border-color: #166534; background: #10291c; color: #86efac; }
:root[data-theme="dark"] .audit-update { border-color: #1e4d82; background: #10284a; color: #93c5fd; }
:root[data-theme="dark"] .audit-delete { border-color: #7f1d1d; background: #32151b; color: #fca5a5; }
:root[data-theme="dark"] .audit-export { border-color: #115e59; background: #0d2b29; color: #5eead4; }
:root[data-theme="dark"] .audit-security { border-color: #78350f; background: #30220e; color: #fcd34d; }
:root[data-theme="dark"] .audit-result-success { color: #86efac; background: #153522; }
:root[data-theme="dark"] .audit-result-denied,
:root[data-theme="dark"] .audit-result-failure { color: #fca5a5; background: #3b171b; }
@media (max-width: 1200px) {
  .audit-summary-grid { grid-template-columns: repeat(3, 1fr); }
  .audit-filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .audit-search { grid-column: span 2; }
}
@media (max-width: 700px) {
  .audit-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .audit-filter-grid { grid-template-columns: 1fr 1fr; }
  .audit-search { grid-column: 1 / -1; }
  .audit-meta-grid, .audit-snapshots { grid-template-columns: 1fr; }
}

/* Backup and production readiness */
.backup-page { --backup-green: #0f766e; --backup-ink: #123047; }
.backup-hero { display: flex; align-items: center; justify-content: space-between; gap: 20px;
  margin: 0; padding: 24px; overflow: hidden; border: 0; color: #f8fafc;
  background: radial-gradient(circle at 88% 20%, rgba(45,212,191,.28), transparent 26%),
    linear-gradient(125deg, #102a43, #0f4c5c 58%, #0f766e); }
.backup-hero h2 { margin: 5px 0 6px; color: #fff; font-size: 24px; }
.backup-hero p { margin: 0; color: #cbd5e1; font-size: 12px; }
.backup-kicker { color: #5eead4; font-size: 12px; font-weight: 850; letter-spacing: .16em;
  text-transform: uppercase; }
.backup-hero .btn-primary { flex: 0 0 auto; border-color: #fff; background: #fff;
  color: #123047; }
.backup-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.backup-stats .card { margin: 0; padding: 16px; box-shadow: none; }
.backup-stats span, .backup-stats strong { display: block; }
.backup-stats span { color: var(--muted); font-size: 12px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; }
.backup-stats strong { margin-top: 7px; font-size: 18px; }
.backup-table-card { margin: 0; padding: 0; overflow: hidden; }
.backup-table-card .section-title-row, .readiness-card .section-title-row { padding: 16px; }
.backup-table { min-width: 760px; }
.backup-table td:first-child b, .backup-table td:first-child small { display: block; }
.backup-table td:first-child small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.backup-kind { display: inline-flex; padding: 4px 7px; border-radius: 999px;
  background: var(--hover); color: var(--muted); font-size: 12px; font-weight: 750; }
.backup-kind-automatic { background: #dcfce7; color: #166534; }
.backup-kind-manual { background: #dbeafe; color: #1d4ed8; }
.backup-kind-pre_restore { background: #fef3c7; color: #92400e; }
.cloud-backup-card { position: relative; margin: 0; padding: 19px; overflow: hidden;
  border-left: 4px solid #d97706; box-shadow: none; }
.cloud-backup-card.configured { border-left-color: var(--backup-green); }
.cloud-backup-card::after { content: ""; position: absolute; top: -62px; right: -62px;
  width: 180px; height: 180px; border: 28px solid color-mix(in srgb, var(--backup-green) 7%, transparent);
  border-radius: 50%; pointer-events: none; }
.cloud-backup-card > * { position: relative; z-index: 1; }
.cloud-backup-card .section-title-row { margin-bottom: 15px; }
.cloud-backup-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px; }
.cloud-backup-summary > div { min-width: 0; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 9px; background: color-mix(in srgb, var(--backup-green) 4%, var(--card)); }
.cloud-backup-summary span, .cloud-backup-summary b { display: block; }
.cloud-backup-summary span { color: var(--muted); font-size: 12px; font-weight: 750;
  letter-spacing: .04em; text-transform: uppercase; }
.cloud-backup-summary b { margin-top: 5px; overflow: hidden; font-size: 12px;
  text-overflow: ellipsis; white-space: nowrap; }
.cloud-setup { margin-top: 12px; padding: 12px; border: 1px dashed #d97706;
  border-radius: 9px; background: #fffbeb; color: #78350f; font-size: 12px; }
.cloud-setup p { margin: 5px 0 9px; line-height: 1.45; }
.cloud-setup code { display: inline-flex; margin: 0 5px 5px 0; padding: 4px 6px;
  border-radius: 5px; background: #fff; color: #92400e; font-size: 12px; }
.cloud-actions { margin-top: 13px; }
.cloud-job-list, .cloud-manifest { margin-top: 14px; border-top: 1px solid var(--border); }
.cloud-job, .cloud-manifest-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--row-border); }
.cloud-job > div, .cloud-manifest-row > div { min-width: 0; }
.cloud-job b, .cloud-job small, .cloud-manifest-row b, .cloud-manifest-row small { display: block; }
.cloud-job b, .cloud-manifest-row b { overflow: hidden; font-size: 12px;
  text-overflow: ellipsis; white-space: nowrap; }
.cloud-job small, .cloud-manifest-row small { margin-top: 4px; overflow: hidden;
  color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.cloud-job-status { display: inline-flex; padding: 5px 7px; border-radius: 999px;
  background: var(--hover); color: var(--muted); font-size: 12px; font-weight: 800; }
.cloud-job-status.status-verified { background: #dcfce7; color: #166534; }
.cloud-job-status.status-processing, .cloud-job-status.status-queued { background: #dbeafe; color: #1d4ed8; }
.cloud-job-status.status-retry, .cloud-job-status.status-uploaded { background: #fef3c7; color: #92400e; }
.cloud-job-status.status-dead { background: #fee2e2; color: #b91c1c; }
.cloud-manifest { padding-top: 12px; }
.cloud-manifest .section-title-row { margin: 0 0 3px; }
.backup-warning.safe { border-left-color: var(--backup-green); background: #ecfdf5; color: #065f46; }
.readiness-card { margin: 0; padding: 0 16px 17px; box-shadow: none; }
.readiness-card .section-title-row { margin: 0 -16px; }
.readiness-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.readiness-item { display: flex; align-items: center; gap: 9px; padding: 11px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--hover); }
.readiness-item i { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center;
  width: 25px; height: 25px; border-radius: 50%; font-size: 12px; font-style: normal;
  font-weight: 850; }
.readiness-item.ready i { background: #dcfce7; color: #166534; }
.readiness-item.pending i { background: #fef3c7; color: #92400e; }
.readiness-item b, .readiness-item span { display: block; }
.readiness-item b { font-size: 12px; }
.readiness-item span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.readiness-card h4 { margin: 17px 0 8px; }
.readiness-messengers { display: flex; flex-wrap: wrap; gap: 6px; }
.readiness-messengers span { padding: 6px 8px; border-radius: 999px; font-size: 12px;
  font-weight: 700; }
.readiness-messengers .ready { background: #dcfce7; color: #166534; }
.readiness-messengers .pending { background: #fef3c7; color: #92400e; }
.backup-restore-modal { max-width: 570px; background: var(--card); }
.backup-danger-label { color: #dc2626; font-size: 12px; font-weight: 850;
  letter-spacing: .1em; text-transform: uppercase; }
.backup-warning { margin: 13px 0; padding: 11px 13px; border-left: 3px solid #dc2626;
  border-radius: 6px; background: #fef2f2; color: #991b1b; font-size: 12px; line-height: 1.5; }
.backup-restore-modal label { display: grid; gap: 5px; margin-top: 10px; font-size: 12px; }
:root[data-theme="dark"] .backup-kind-automatic,
:root[data-theme="dark"] .readiness-item.ready i,
:root[data-theme="dark"] .readiness-messengers .ready { background: #153522; color: #86efac; }
:root[data-theme="dark"] .backup-kind-manual { background: #10284a; color: #93c5fd; }
:root[data-theme="dark"] .backup-kind-pre_restore,
:root[data-theme="dark"] .readiness-item.pending i,
:root[data-theme="dark"] .readiness-messengers .pending { background: #30220e; color: #fcd34d; }
:root[data-theme="dark"] .backup-warning { background: #32151b; color: #fca5a5; }
:root[data-theme="dark"] .cloud-setup { border-color: #854d0e; background: #30220e; color: #fcd34d; }
:root[data-theme="dark"] .cloud-setup code { background: #201b12; color: #fde68a; }
:root[data-theme="dark"] .cloud-job-status.status-verified,
:root[data-theme="dark"] .backup-warning.safe { background: #153522; color: #86efac; }
:root[data-theme="dark"] .cloud-job-status.status-processing,
:root[data-theme="dark"] .cloud-job-status.status-queued { background: #10284a; color: #93c5fd; }
:root[data-theme="dark"] .cloud-job-status.status-retry,
:root[data-theme="dark"] .cloud-job-status.status-uploaded { background: #30220e; color: #fcd34d; }
:root[data-theme="dark"] .cloud-job-status.status-dead { background: #32151b; color: #fca5a5; }
@media (max-width: 760px) {
  .backup-hero { align-items: stretch; flex-direction: column; }
  .backup-stats, .readiness-grid, .cloud-backup-summary { grid-template-columns: 1fr; }
  .cloud-actions .btn { width: 100%; }
  .cloud-job, .cloud-manifest-row { grid-template-columns: minmax(0, 1fr) auto; }
  .cloud-job .btn { grid-column: 1 / -1; }
}

/* SLA першої обробки ліда */
.lead-sla {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 72px; padding: 4px 8px; border: 1px solid transparent;
  border-radius: 12px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.lead-sla.running { color: #1d4ed8; border-color: #bfdbfe; background: #eff6ff; }
.lead-sla.warning { color: #92400e; border-color: #fde68a; background: #fffbeb; }
.lead-sla.overdue { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.sla-empty { color: var(--muted); }
.kanban-sla { margin-top: 8px; }
.lead-modal-sla {
  display: flex; align-items: center; gap: 7px; margin-top: 7px;
  color: var(--muted); font-size: 12px;
}
:root[data-theme="dark"] .lead-sla.running {
  color: #93c5fd; border-color: #1e4d82; background: #10284a;
}
:root[data-theme="dark"] .lead-sla.warning {
  color: #fcd34d; border-color: #854d0e; background: #2a210e;
}
:root[data-theme="dark"] .lead-sla.overdue {
  color: #fca5a5; border-color: #7f1d1d; background: #2b151b;
}

.deals-page, .deal-profile {
  --deal-ink: #17324d; --deal-green: #16745a; --deal-copper: #c46a3b;
  --deal-soft: #eef5f2; display: grid; gap: 13px;
}
.deals-titlebar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 18px;
  padding: 5px 2px 2px;
}
.deals-titlebar h1 { margin: 4px 0 3px; font-size: 27px; letter-spacing: -.035em; }
.deals-titlebar p { margin: 0; color: var(--muted); font-size: 12px; }
.deal-kicker {
  color: var(--deal-green); font-size: 12px; font-weight: 850; letter-spacing: .16em;
  text-transform: uppercase;
}
.deal-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.deal-kpi-grid > div {
  position: relative; min-height: 106px; padding: 17px; overflow: hidden;
  border: 1px solid var(--border); border-radius: 13px; background: var(--card);
}
.deal-kpi-grid > div::after {
  content: ""; position: absolute; right: -19px; bottom: -31px; width: 82px; height: 82px;
  border: 16px solid color-mix(in srgb, var(--deal-green) 8%, transparent); border-radius: 50%;
}
.deal-kpi-grid span, .deal-kpi-grid b, .deal-kpi-grid small { position: relative; z-index: 1; display: block; }
.deal-kpi-grid span { color: var(--muted); font-size: 12px; font-weight: 750;
  letter-spacing: .05em; text-transform: uppercase; }
.deal-kpi-grid b { margin: 10px 0 5px; font-size: 23px; letter-spacing: -.035em; }
.deal-kpi-grid small { color: var(--muted); font-size: 12px; }
.deal-kpi-grid .warning { color: #fff; border-color: transparent;
  background: linear-gradient(135deg, #8b482c, #c46a3b); }
.deal-kpi-grid .warning span, .deal-kpi-grid .warning small { color: #ffe9dc; }
.deal-list-card { margin: 0; padding: 0; overflow: hidden; }
.deal-filters {
  display: flex; align-items: center; gap: 7px; padding: 13px;
  border-bottom: 1px solid var(--row-border);
}
.deal-filters > select { min-width: 135px; }
.deal-filters > span { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.deal-search { position: relative; flex: 1; min-width: 230px; }
.deal-search span { position: absolute; left: 11px; top: 8px; color: var(--muted); font-size: 19px; }
.deal-search input { width: 100%; padding-left: 34px; }
.deal-table-wrap { overflow-x: auto; }
.deal-table { min-width: 1100px; }
.deal-table tr { cursor: pointer; }
.deal-table tbody tr:hover { background: color-mix(in srgb, var(--deal-green) 5%, var(--card)); }
.deal-table td { vertical-align: middle; padding-top: 12px; padding-bottom: 12px; }
.deal-table td > b, .deal-table td > small, .deal-table td > strong { display: block; }
.deal-table td > b, .deal-table td > strong { font-size: 12px; }
.deal-table td > small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.deal-table-title { display: flex; align-items: center; gap: 9px; min-width: 190px; }
.deal-table-title > i {
  display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 38px;
  border-radius: 11px; color: #fff; background: var(--deal-ink); font-size: 12px; font-style: normal;
  font-weight: 800;
}
.deal-table-title div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.deal-table-title b { overflow: hidden; max-width: 190px; font-size: 12px;
  text-overflow: ellipsis; white-space: nowrap; }
.deal-table-title span { color: var(--muted); font-size: 12px; }
.deal-pending-copy { color: #b45309 !important; }
.deal-stage {
  display: inline-flex; align-items: center; gap: 5px; width: fit-content; padding: 4px 7px;
  border-radius: 999px; color: #334155; background: #edf2f7; font-size: 12px; font-weight: 750;
  white-space: nowrap;
}
.deal-stage i { width: 6px; height: 6px; border-radius: 50%; background: #64748b; }
.deal-stage-reservation { color: #92400e; background: #fef3c7; }
.deal-stage-reservation i { background: #f59e0b; }
.deal-stage-contract, .deal-stage-payment { color: #1e40af; background: #dbeafe; }
.deal-stage-contract i, .deal-stage-payment i { background: #2563eb; }
.deal-stage-won { color: #166534; background: #dcfce7; }
.deal-stage-won i { background: #16a34a; }
.deal-stage-lost { color: #991b1b; background: #fee2e2; }
.deal-stage-lost i { background: #dc2626; }
.deal-empty { padding: 68px 20px; color: var(--muted); text-align: center; }
.deal-empty > span { font-size: 39px; color: var(--deal-green); }
.deal-empty h3 { margin: 8px 0 5px; color: var(--text); }
.deal-empty p { margin: 0; font-size: 12px; }
.deal-error {
  margin: 10px 0; padding: 10px 12px; border: 1px solid #fecaca; border-radius: 8px;
  color: #b91c1c; background: #fff7f7; font-size: 12px;
}
.deal-list-card > .deal-error { margin: 10px 13px; }
.deal-create-modal { max-width: 780px; background: var(--card); }
.deal-create-modal h2 { margin: 4px 0; font-size: 21px; }
.deal-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.deal-form-grid label { margin-top: 10px; }
.deal-form-grid input, .deal-form-grid select, .deal-form-grid textarea { width: 100%; margin-top: 5px; }
.deal-field-wide { grid-column: 1 / -1; }
.deal-profile-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.deal-profile-top > div { display: flex; gap: 7px; }
.deal-back {
  padding: 6px 0; border: 0; color: var(--muted); background: none; font-family: inherit;
  font-size: 12px; cursor: pointer;
}
.deal-back:hover { color: var(--deal-green); }
.deal-profile-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 150px;
  padding: 25px 27px; overflow: hidden; border-radius: 16px; color: #fff;
  background:
    radial-gradient(circle at 85% 20%, rgba(255,255,255,.14), transparent 24%),
    repeating-linear-gradient(125deg, transparent 0 18px, rgba(255,255,255,.018) 18px 19px),
    linear-gradient(125deg, #132f49, #174d52 64%, #16745a);
}
.deal-number { color: #84d8bd; font-size: 12px; font-weight: 850; letter-spacing: .13em;
  text-transform: uppercase; }
.deal-profile-hero h1 { max-width: 650px; margin: 7px 0 7px; color: #fff; font-size: 25px; }
.deal-profile-hero p { margin: 0; color: #d5e5e1; font-size: 12px; }
.deal-hero-value { display: flex; flex-direction: column; align-items: flex-end; flex: 0 0 auto; }
.deal-hero-value > span { color: #c4d8d3; font-size: 12px; text-transform: uppercase; }
.deal-hero-value > b { margin: 5px 0 9px; font-size: 25px; letter-spacing: -.04em; }
.deal-stage-rail {
  display: grid; grid-template-columns: repeat(7, minmax(90px, 1fr)); overflow-x: auto;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card);
}
.deal-stage-rail button {
  position: relative; display: flex; align-items: center; gap: 7px; min-width: 100px; padding: 12px 10px;
  border: 0; border-right: 1px solid var(--row-border); color: var(--muted); background: transparent;
  font-family: inherit; font-size: 12px; cursor: pointer;
}
.deal-stage-rail button:last-child { border-right: 0; }
.deal-stage-rail button::after { content: ""; position: absolute; inset: auto 0 0; height: 2px; background: transparent; }
.deal-stage-rail button i {
  display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
  flex: 0 0 auto; border: 1px solid var(--border); border-radius: 50%; background: var(--hover);
  font-size: 12px; font-style: normal;
}
.deal-stage-rail button.done, .deal-stage-rail button.active { color: var(--deal-green); }
.deal-stage-rail button.done i { border-color: #a7dfcd; background: #dcfce7; }
.deal-stage-rail button.active { font-weight: 800; }
.deal-stage-rail button.active::after { background: var(--deal-green); }
.deal-stage-rail button.active i { border-color: var(--deal-green); color: #fff; background: var(--deal-green); }
.deal-stage-rail button:disabled { cursor: default; }
.deal-stat-strip {
  display: grid; grid-template-columns: repeat(4, minmax(100px, 1fr)) minmax(150px, 1.4fr);
  overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--card);
}
.deal-stat-strip > div { min-width: 0; padding: 14px; border-right: 1px solid var(--row-border); }
.deal-stat-strip > div:last-child { border-right: 0; }
.deal-stat-strip span, .deal-stat-strip b { display: block; }
.deal-stat-strip span { color: var(--muted); font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
.deal-stat-strip b { overflow: hidden; margin-top: 6px; font-size: 15px; text-overflow: ellipsis; }
.deal-stat-strip .progress { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; }
.deal-stat-strip .progress b { margin: 0; }
.deal-stat-strip .progress > i { grid-column: 1 / -1; height: 5px; overflow: hidden;
  border-radius: 9px; background: var(--hover); }
.deal-stat-strip .progress em { display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--deal-green), #51b996); }
.deal-tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--border); }
.deal-tabs button {
  padding: 10px 13px; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  background: transparent; font-family: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.deal-tabs button.active { color: var(--deal-green); border-bottom-color: var(--deal-green); }
.deal-overview-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(265px, .7fr);
  gap: 12px; align-items: start; }
.deal-overview-main { display: grid; gap: 12px; }
.deal-overview-main > section, .deal-overview-side > section, .deal-tab-panel,
.deal-work-grid > section {
  padding: 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--card);
}
.deal-overview-side { display: grid; gap: 12px; }
.deal-section-head, .deal-tab-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px;
}
.deal-section-head span { color: var(--deal-green); font-size: 12px; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase; }
.deal-section-head h3, .deal-tab-toolbar h3 { margin: 3px 0 0; font-size: 13px; }
.deal-tab-toolbar p { margin: 3px 0 0; }
.deal-apartment-list { display: grid; gap: 7px; }
.deal-apartment-choice {
  position: relative; display: grid; grid-template-columns: 44px minmax(150px, 1fr) auto auto;
  align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--hover);
}
.deal-apartment-choice.primary { border-color: #a7dfcd; background: #f3fbf8; }
.deal-apartment-mark {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border-radius: 10px; color: #fff; background: var(--deal-ink); font-size: 12px; font-weight: 800;
}
.deal-apartment-choice > div:nth-child(2) { display: flex; flex-direction: column; gap: 4px; }
.deal-apartment-choice b { font-size: 12px; }
.deal-apartment-choice span { color: var(--muted); font-size: 12px; }
.deal-apartment-choice strong { font-size: 12px; white-space: nowrap; }
.deal-apartment-choice > i {
  padding: 4px 7px; border-radius: 99px; color: var(--muted); background: var(--card);
  font-size: 12px; font-style: normal; font-weight: 750; white-space: nowrap;
}
.deal-apartment-choice.primary > i { color: #087454; background: #dcfce7; }
.deal-choice-actions { position: absolute; right: 8px; bottom: -8px; display: flex; gap: 3px; }
.deal-choice-actions button { padding: 3px 6px; border: 1px solid var(--border); border-radius: 5px;
  color: var(--muted); background: var(--card); font-size: 12px; cursor: pointer; }
.deal-add-apartment { display: grid; grid-template-columns: 1fr auto; gap: 7px; margin-top: 10px; }
.deal-empty-inline { padding: 25px; color: var(--muted); text-align: center; font-size: 12px; }
.deal-money-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.deal-money-grid > div { padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--hover); }
.deal-money-grid span, .deal-money-grid b, .deal-money-grid small { display: block; }
.deal-money-grid span { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.deal-money-grid b { margin-top: 7px; font-size: 14px; }
.deal-money-grid small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.deal-money-grid .total { color: #fff; border-color: transparent;
  background: linear-gradient(135deg, #17324d, #16745a); }
.deal-money-grid .total span { color: #cbe7de; }
.deal-discount { padding: 5px 8px; border-radius: 99px; font-size: 12px !important;
  letter-spacing: 0 !important; text-transform: none !important; }
.deal-discount-pending { color: #92400e !important; background: #fef3c7; }
.deal-discount-approved { color: #166534 !important; background: #dcfce7; }
.deal-discount-rejected { color: #991b1b !important; background: #fee2e2; }
.deal-discount-not_requested { color: var(--muted) !important; background: var(--hover); }
.deal-discount-form { display: grid; grid-template-columns: minmax(160px, 1fr) auto; gap: 7px;
  max-width: 420px; margin-top: 10px; }
.deal-approval-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 10px; }
.deal-overview-side dl { margin: 0; }
.deal-overview-side dl > div { display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--row-border); }
.deal-overview-side dt { color: var(--muted); font-size: 12px; }
.deal-overview-side dd { max-width: 60%; font-size: 12px; font-weight: 700; text-align: right; }
.deal-doc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.deal-overview-side textarea { width: 100%; resize: vertical; }
.deal-overview-side textarea + .btn { width: 100%; margin-top: 7px; }
.deal-tab-panel { min-height: 370px; }
.deal-payment-list { display: grid; gap: 6px; }
.deal-payment {
  display: grid; grid-template-columns: auto minmax(150px, 1fr) auto 90px; align-items: center;
  gap: 10px; padding: 11px; border: 1px solid var(--border); border-radius: 9px;
}
.deal-payment > div { display: flex; flex-direction: column; gap: 3px; }
.deal-payment b, .deal-payment strong { font-size: 12px; }
.deal-payment span { color: var(--muted); font-size: 12px; }
.deal-payment i { padding: 4px 6px; border-radius: 99px; color: #92400e; background: #fef3c7;
  font-size: 12px; font-style: normal; font-weight: 750; text-align: center; }
.deal-payment.paid i { color: #166534; background: #dcfce7; }
.deal-payment.overdue { border-color: #fecaca; }
.deal-payment.overdue i { color: #991b1b; background: #fee2e2; }
.deal-tab-empty { padding: 35px; color: var(--muted); font-size: 12px; text-align: center; }
.deal-work-grid { display: grid; grid-template-columns: minmax(320px, .85fr) minmax(0, 1.15fr); gap: 12px; }
.deal-task-form { display: grid; grid-template-columns: 1fr minmax(170px, auto) auto; gap: 6px; margin-bottom: 10px; }
.deal-task-list, .deal-timeline { display: grid; gap: 6px; max-height: 470px; overflow-y: auto; }
.deal-task-list > div, .deal-timeline > div { display: flex; align-items: flex-start; gap: 9px;
  padding: 9px; border: 1px solid var(--row-border); border-radius: 9px; }
.deal-task-list i, .deal-timeline i {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  flex: 0 0 auto; border-radius: 8px; color: var(--deal-green); background: var(--deal-soft);
  font-size: 12px; font-style: normal; font-weight: 800;
}
.deal-task-list span, .deal-timeline span { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.deal-task-list b, .deal-timeline b { font-size: 12px; font-weight: 650; line-height: 1.4; }
.deal-task-list small, .deal-timeline small { color: var(--muted); font-size: 12px; }
.deal-task-list .done { opacity: .65; }
:root[data-theme="dark"] .deal-apartment-choice.primary { border-color: #166534; background: #10291c; }
:root[data-theme="dark"] .deal-apartment-choice.primary > i,
:root[data-theme="dark"] .deal-discount-approved,
:root[data-theme="dark"] .deal-payment.paid i { color: #86efac; background: #153522; }
:root[data-theme="dark"] .deal-discount-pending,
:root[data-theme="dark"] .deal-payment i { color: #fcd34d; background: #30220e; }
:root[data-theme="dark"] .deal-discount-rejected,
:root[data-theme="dark"] .deal-payment.overdue i { color: #fca5a5; background: #32151b; }
:root[data-theme="dark"] .deal-error { border-color: #7f1d1d; color: #fca5a5; background: #32151b; }
:root[data-theme="dark"] .deal-stage-won { color: #86efac; background: #153522; }
:root[data-theme="dark"] .deal-stage-lost { color: #fca5a5; background: #32151b; }
:root[data-theme="dark"] .deal-stage-reservation { color: #fcd34d; background: #30220e; }
:root[data-theme="dark"] .deal-stage-contract,
:root[data-theme="dark"] .deal-stage-payment { color: #93c5fd; background: #10284a; }
@media (max-width: 1050px) {
  .deal-kpi-grid { grid-template-columns: 1fr 1fr; }
  .deal-overview-grid { grid-template-columns: 1fr; }
  .deal-overview-side { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .deal-work-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .deals-titlebar, .deal-profile-top { align-items: stretch; flex-direction: column; }
  .deal-profile-top > div, .deals-titlebar > .btn { width: 100%; }
  .deal-profile-top .btn { flex: 1; }
  .deal-kpi-grid, .deal-form-grid { grid-template-columns: 1fr; }
  .deal-field-wide { grid-column: auto; }
  .deal-filters { align-items: stretch; flex-direction: column; }
  .deal-filters > span { margin-left: 0; }
  .deal-profile-hero { align-items: flex-start; flex-direction: column; padding: 21px 18px; }
  .deal-hero-value { align-items: flex-start; }
  .deal-stat-strip { grid-template-columns: 1fr 1fr; }
  .deal-stat-strip .progress { grid-column: 1 / -1; }
  .deal-overview-side { grid-template-columns: 1fr; }
  .deal-money-grid { grid-template-columns: 1fr 1fr; }
  .deal-apartment-choice { grid-template-columns: 40px minmax(0, 1fr); }
  .deal-apartment-choice > strong, .deal-apartment-choice > i { margin-left: 50px; }
  .deal-payment { grid-template-columns: auto minmax(0, 1fr) auto; }
  .deal-payment > i { grid-column: 2 / -1; width: fit-content; }
  .deal-task-form { grid-template-columns: 1fr; }
}

/* Documents workspace */
.documents-page {
  --document-accent: #9a6b2f;
  --document-soft: #f6efe3;
  display: grid;
  gap: 13px;
}
.documents-titlebar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}
.documents-titlebar h1 { margin: 4px 0 2px; font-size: 28px; letter-spacing: -.04em; }
.documents-titlebar p { margin: 0; color: var(--muted); font-size: 12px; }
.document-kicker {
  color: var(--document-accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.document-kpi-grid {
  display: grid;
  grid-template-columns: .8fr .8fr .8fr 1.35fr;
  gap: 9px;
}
.document-kpi-grid > div {
  position: relative;
  min-height: 99px;
  overflow: hidden;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background:
    radial-gradient(circle at 90% 10%, rgba(154,107,47,.12), transparent 34%),
    var(--card);
}
.document-kpi-grid > div::after {
  content: "§";
  position: absolute;
  right: 12px;
  bottom: -21px;
  color: rgba(154,107,47,.06);
  font-family: Georgia, serif;
  font-size: 74px;
}
.document-kpi-grid .attention {
  color: #fff;
  border-color: transparent;
  background:
    radial-gradient(circle at 88% 28%, rgba(255,255,255,.16), transparent 28%),
    linear-gradient(135deg, #5e3e1f, #a66f2e);
}
.document-kpi-grid span, .document-kpi-grid b, .document-kpi-grid small { display: block; }
.document-kpi-grid span { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.document-kpi-grid b { position: relative; z-index: 1; margin: 9px 0 4px; font-size: 22px; }
.document-kpi-grid small { color: var(--muted); font-size: 12px; }
.document-kpi-grid .attention span, .document-kpi-grid .attention small { color: #f6e7d4; }
.document-list-card { padding: 0; overflow: hidden; }
.document-filters {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.document-filters select { min-width: 180px; }
.document-filters > span { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.document-search { position: relative; flex: 1; min-width: 220px; }
.document-search span { position: absolute; left: 11px; top: 9px; color: var(--muted); }
.document-search input { width: 100%; padding-left: 30px; }
.document-table-wrap { overflow-x: auto; }
.document-table { min-width: 1040px; }
.document-table tbody tr { cursor: pointer; }
.document-table td { vertical-align: middle; }
.document-table td > b, .document-table td > small { display: block; }
.document-table td > small { max-width: 210px; margin-top: 4px; color: var(--muted); font-size: 12px; }
.document-table-title { display: flex; align-items: center; gap: 9px; min-width: 190px; }
.document-table-title > i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid #ddc9ad;
  border-radius: 4px 9px 4px 4px;
  color: var(--document-accent);
  background: var(--document-soft);
  font-family: Georgia, serif;
  font-size: 16px;
  font-style: normal;
}
.document-table-title > div { display: flex; flex-direction: column; gap: 4px; }
.document-table-title b { font-size: 12px; }
.document-table-title span { max-width: 170px; overflow: hidden; color: var(--muted);
  font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.document-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.document-status i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.document-status-draft { color: #475569; background: #e2e8f0; }
.document-status-review { color: #92400e; background: #fef3c7; }
.document-status-approved { color: #075985; background: #e0f2fe; }
.document-status-sent { color: #1e40af; background: #dbeafe; }
.document-status-signed { color: #166534; background: #dcfce7; }
.document-status-cancelled { color: #991b1b; background: #fee2e2; }
.document-version { padding: 4px 7px; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); font-size: 12px; font-weight: 750; }
.document-empty { padding: 70px 20px; color: var(--muted); text-align: center; }
.document-empty > span { display: block; color: var(--document-accent); font: 42px Georgia, serif; }
.document-empty h3 { margin: 8px 0 4px; color: var(--text); font-size: 14px; }
.document-empty p { margin: 0; font-size: 12px; }
.document-error { margin: 10px 12px; padding: 9px 11px; border: 1px solid #fecaca;
  border-radius: 8px; color: #991b1b; background: #fef2f2; font-size: 12px; }
.document-create-modal { width: min(650px, calc(100vw - 28px)); }
.document-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.document-form-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.document-form-grid .wide { grid-column: 1 / -1; }
.document-form-grid textarea { resize: vertical; }
.document-drawer-back {
  position: fixed;
  z-index: 90;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  background: rgba(10,18,30,.56);
  backdrop-filter: blur(3px);
}
.document-drawer {
  width: min(560px, 94vw);
  height: 100%;
  overflow-y: auto;
  padding: 22px;
  border-left: 1px solid var(--border);
  background: var(--bg);
  box-shadow: -22px 0 60px rgba(8,15,26,.18);
  animation: document-drawer-in .2s ease-out;
}
@keyframes document-drawer-in { from { transform: translateX(30px); opacity: .7; } }
.document-drawer > header { display: flex; justify-content: space-between; gap: 15px; }
.document-drawer > header h2 { margin: 5px 0 3px; font: 700 24px Georgia, serif; letter-spacing: -.02em; }
.document-drawer > header p { margin: 0; color: var(--muted); font-size: 12px; }
.document-drawer-status { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 19px 0 12px; }
.document-detail-grid { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.document-detail-grid > div { min-width: 0; padding: 12px; border-right: 1px solid var(--row-border);
  border-bottom: 1px solid var(--row-border); }
.document-detail-grid > div:nth-child(2n) { border-right: 0; }
.document-detail-grid > div:nth-last-child(-n + 2) { border-bottom: 0; }
.document-detail-grid span, .document-detail-grid b { display: block; }
.document-detail-grid span { margin-bottom: 5px; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.document-detail-grid b { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.document-actions-panel, .document-version-panel, .document-history-panel,
.document-signature-panel {
  margin-top: 11px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}
.document-signature-panel { overflow: hidden; }
.signature-request-summary { display: grid; gap: 10px; margin-top: 12px; }
.signature-request-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.signature-request-title small { color: var(--muted); font-size: 12px; }
.signature-request-status { display: inline-flex; align-items: center; padding: 5px 8px;
  border-radius: 99px; color: #475569; background: #e2e8f0; font-size: 12px; font-weight: 800; }
.signature-request-status.pending { color: #92400e; background: #fef3c7; }
.signature-request-status.viewed { color: #1e40af; background: #dbeafe; }
.signature-request-status.signed { color: #166534; background: #dcfce7; }
.signature-request-status.expired, .signature-request-status.revoked,
.signature-request-status.locked { color: #991b1b; background: #fee2e2; }
.signature-request-grid { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden;
  border: 1px solid var(--row-border); border-radius: 9px; }
.signature-request-grid > div { min-width: 0; padding: 9px; border-right: 1px solid var(--row-border);
  border-bottom: 1px solid var(--row-border); }
.signature-request-grid > div:nth-child(2n) { border-right: 0; }
.signature-request-grid > div:nth-last-child(-n + 2) { border-bottom: 0; }
.signature-request-grid span, .signature-request-grid b { display: block; }
.signature-request-grid span { margin-bottom: 4px; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.signature-request-grid b { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.signature-hash { display: grid; gap: 4px; padding: 9px; border-radius: 8px; background: var(--hover); }
.signature-hash span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.signature-hash code { overflow-wrap: anywhere; color: var(--text); font-size: 12px; }
.signature-evidence { display: flex; align-items: center; justify-content: space-between; gap: 9px;
  padding: 10px; border: 1px solid #bbdec8; border-radius: 9px; background: #f0faf4; }
.signature-evidence > div { display: grid; gap: 4px; }
.signature-evidence b { color: #166534; font-size: 12px; }
.signature-evidence span { color: var(--muted); font-size: 12px; }
.signature-revoke { justify-self: start; }
.signature-inline-notice { margin-top: 10px; padding: 7px 9px; border-radius: 7px;
  color: #166534; background: #ecfdf3; font-size: 12px; }
.signature-request-modal { width: min(650px, calc(100vw - 28px)); }
.signature-request-form { margin-top: 14px; }
.signature-request-hint { padding: 10px 12px; border-left: 3px solid var(--document-accent);
  color: var(--muted); background: var(--hover); font-size: 12px; line-height: 1.5; }
.signature-secret-result { display: grid; gap: 10px; text-align: center; }
.signature-success-mark { display: grid; place-items: center; width: 48px; height: 48px; margin: 2px auto;
  border-radius: 50%; color: #fff; background: #166534; font-size: 20px; font-weight: 800; }
.signature-secret-result h3 { margin: 2px 0 0; font-size: 14px; }
.signature-secret-result > p { margin: 0 auto 6px; max-width: 430px; color: var(--muted);
  font-size: 12px; line-height: 1.55; }
.signature-secret-result label { display: grid; gap: 5px; color: var(--muted); font-size: 12px;
  font-weight: 800; text-align: left; text-transform: uppercase; }
.signature-secret-result label > div { display: flex; align-items: stretch; gap: 6px; }
.signature-secret-result input { min-width: 0; flex: 1; font-size: 12px; text-transform: none; }
.signature-secret-result code { display: grid; flex: 1; place-items: center; min-height: 36px;
  border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--hover);
  font-size: 19px; font-weight: 850; letter-spacing: .32em; }
.signature-delivery-result { padding: 9px 11px; border-radius: 8px; color: #166534;
  background: #ecfdf3; font-size: 12px; text-align: left; }
.signature-delivery-result.warn { color: #92400e; background: #fffbeb; }
.document-actions-panel > span { color: var(--document-accent); font-size: 12px; font-weight: 800;
  letter-spacing: .09em; text-transform: uppercase; }
.document-actions-panel > div { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.document-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.document-panel-head span { color: var(--document-accent); font-size: 12px; font-weight: 800;
  letter-spacing: .09em; text-transform: uppercase; }
.document-panel-head h3 { margin: 3px 0 0; font-size: 12px; }
.document-notes { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.document-edit-form { display: grid; gap: 9px; margin-top: 12px; }
.document-edit-form > div { display: flex; gap: 8px; }
.document-edit-form > div > label { flex: 1; }
.document-edit-form label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.document-edit-form textarea { resize: vertical; }
.document-edit-form > div:last-child { justify-content: flex-end; }
.document-version-list { display: grid; gap: 6px; margin-top: 10px; }
.document-version-list > div { display: flex; align-items: center; gap: 9px; padding: 8px;
  border: 1px solid var(--row-border); border-radius: 8px; }
.document-version-list i { display: inline-flex; align-items: center; justify-content: center;
  width: 29px; height: 29px; border-radius: 8px; color: var(--document-accent);
  background: var(--document-soft); font-size: 12px; font-style: normal; font-weight: 850; }
.document-version-list span { display: flex; flex-direction: column; gap: 3px; }
.document-version-list b { font-size: 12px; }
.document-version-list small { color: var(--muted); font-size: 12px; }
.deal-document-list { display: grid; gap: 6px; margin-bottom: 8px; }
.deal-document-list button { display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 8px; width: 100%; padding: 8px; border: 1px solid var(--row-border); border-radius: 8px;
  color: var(--text); background: var(--hover); text-align: left; cursor: pointer; }
.deal-document-list i { display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 31px; border-radius: 4px 7px 4px 4px; color: #9a6b2f;
  background: #f6efe3; font: 13px Georgia, serif; }
.deal-document-list span { display: flex; flex-direction: column; gap: 3px; }
.deal-document-list b { font-size: 12px; }
.deal-document-list small { color: var(--muted); font-size: 12px; }
.deal-document-list em { color: var(--muted); font-size: 12px; font-style: normal; }
.deal-document-empty { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
:root[data-theme="dark"] .document-kpi-grid > div { background:
  radial-gradient(circle at 90% 10%, rgba(191,145,78,.12), transparent 34%), var(--card); }
:root[data-theme="dark"] .document-kpi-grid .attention { background:
  radial-gradient(circle at 88% 28%, rgba(255,255,255,.12), transparent 28%),
  linear-gradient(135deg, #3d2917, #7a4d20); }
:root[data-theme="dark"] .document-table-title > i,
:root[data-theme="dark"] .document-version-list i,
:root[data-theme="dark"] .deal-document-list i { border-color: #64451f; color: #e7bd7a; background: #2c2114; }
:root[data-theme="dark"] .document-status-draft { color: #cbd5e1; background: #293548; }
:root[data-theme="dark"] .document-status-review { color: #fcd34d; background: #30220e; }
:root[data-theme="dark"] .document-status-approved { color: #7dd3fc; background: #123247; }
:root[data-theme="dark"] .document-status-sent { color: #93c5fd; background: #10284a; }
:root[data-theme="dark"] .document-status-signed { color: #86efac; background: #153522; }
:root[data-theme="dark"] .document-status-cancelled { color: #fca5a5; background: #32151b; }
:root[data-theme="dark"] .document-error { border-color: #7f1d1d; color: #fca5a5; background: #32151b; }
:root[data-theme="dark"] .signature-request-status.pending { color: #fcd34d; background: #30220e; }
:root[data-theme="dark"] .signature-request-status.viewed { color: #93c5fd; background: #10284a; }
:root[data-theme="dark"] .signature-request-status.signed { color: #86efac; background: #153522; }
:root[data-theme="dark"] .signature-request-status.expired,
:root[data-theme="dark"] .signature-request-status.revoked,
:root[data-theme="dark"] .signature-request-status.locked { color: #fca5a5; background: #32151b; }
:root[data-theme="dark"] .signature-evidence { border-color: #225b38; background: #132f20; }
:root[data-theme="dark"] .signature-evidence b { color: #86efac; }
:root[data-theme="dark"] .signature-inline-notice { color: #86efac; background: #132f20; }
:root[data-theme="dark"] .signature-delivery-result { color: #86efac; background: #132f20; }
:root[data-theme="dark"] .signature-delivery-result.warn { color: #fcd34d; background: #30220e; }
@media (max-width: 1050px) {
  .document-kpi-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .documents-titlebar { align-items: stretch; flex-direction: column; }
  .documents-titlebar .btn { width: 100%; }
  .document-kpi-grid, .document-form-grid { grid-template-columns: 1fr; }
  .document-form-grid .wide { grid-column: auto; }
  .document-filters { align-items: stretch; flex-direction: column; }
  .document-filters > span { margin-left: 0; }
  .document-search { min-width: 0; }
  .document-drawer { width: 100%; max-width: none; padding: 17px; }
  .document-detail-grid { grid-template-columns: 1fr; }
  .document-detail-grid > div { border-right: 0; }
  .document-detail-grid > div:nth-last-child(2) { border-bottom: 1px solid var(--row-border); }
  .document-edit-form > div { flex-direction: column; }
  .signature-request-grid { grid-template-columns: 1fr; }
  .signature-request-grid > div { border-right: 0; }
  .signature-request-grid > div:nth-last-child(2) { border-bottom: 1px solid var(--row-border); }
  .signature-evidence { align-items: stretch; flex-direction: column; }
  .signature-secret-result label > div { flex-direction: column; }
}

/* Commission workspace */
.commissions-page {
  --commission-green: #087454;
  --commission-soft: #e8f5ef;
  display: grid;
  gap: 13px;
}
.commissions-titlebar { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.commissions-titlebar h1 { margin: 4px 0 2px; font-size: 28px; letter-spacing: -.04em; }
.commissions-titlebar p { margin: 0; color: var(--muted); font-size: 12px; }
.commission-kicker { color: var(--commission-green); font-size: 12px; font-weight: 850;
  letter-spacing: .15em; text-transform: uppercase; }
.commission-kpi-grid { display: grid; grid-template-columns: 1.2fr .75fr 1.2fr 1.2fr; gap: 9px; }
.commission-kpi-grid > div { min-height: 98px; padding: 16px; border: 1px solid var(--border);
  border-radius: 13px; background: radial-gradient(circle at 92% 10%, rgba(8,116,84,.11), transparent 34%), var(--card); }
.commission-kpi-grid span, .commission-kpi-grid b, .commission-kpi-grid small { display: block; }
.commission-kpi-grid span { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.commission-kpi-grid b { margin: 9px 0 4px; font-size: 21px; }
.commission-kpi-grid small { color: var(--muted); font-size: 12px; }
.commission-kpi-grid .attention { color: #fff; border-color: transparent;
  background: radial-gradient(circle at 88% 22%, rgba(255,255,255,.16), transparent 30%),
    linear-gradient(135deg, #73451f, #b97732); }
.commission-kpi-grid .ready { color: #fff; border-color: transparent;
  background: radial-gradient(circle at 88% 22%, rgba(255,255,255,.15), transparent 30%),
    linear-gradient(135deg, #143d34, #0e8665); }
.commission-kpi-grid .attention span, .commission-kpi-grid .attention small,
.commission-kpi-grid .ready span, .commission-kpi-grid .ready small { color: #e7f4ef; }
.commission-list-card { padding: 0; overflow: hidden; }
.commission-filters { display: flex; align-items: center; gap: 7px; padding: 12px;
  border-bottom: 1px solid var(--border); }
.commission-filters select { min-width: 180px; }
.commission-filters > span { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.commission-search { position: relative; flex: 1; min-width: 220px; }
.commission-search span { position: absolute; top: 9px; left: 11px; color: var(--muted); }
.commission-search input { width: 100%; padding-left: 30px; }
.commission-table-wrap { overflow-x: auto; }
.commission-table { min-width: 1050px; }
.commission-table tbody tr { cursor: pointer; }
.commission-table td { vertical-align: middle; }
.commission-table td > b, .commission-table td > small { display: block; }
.commission-table td > small { max-width: 200px; margin-top: 4px; color: var(--muted); font-size: 12px; }
.commission-person { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.commission-person i { display: inline-flex; align-items: center; justify-content: center; width: 30px;
  height: 30px; border-radius: 9px; color: #fff; background: linear-gradient(135deg, #17394a, #0e8665);
  font-size: 12px; font-style: normal; font-weight: 800; }
.commission-person b { font-size: 12px; }
.commission-status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px;
  border-radius: 99px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.commission-status i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.commission-status-accrued { color: #475569; background: #e2e8f0; }
.commission-status-pending { color: #92400e; background: #fef3c7; }
.commission-status-approved { color: #075985; background: #e0f2fe; }
.commission-status-paid { color: #166534; background: #dcfce7; }
.commission-status-cancelled { color: #991b1b; background: #fee2e2; }
.commission-table-progress { min-width: 120px; }
.commission-table-progress span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.commission-table-progress i, .commission-eligibility > i, .deal-commission-progress > i {
  display: block; height: 5px; overflow: hidden; border-radius: 99px; background: var(--hover); }
.commission-table-progress em, .commission-eligibility em, .deal-commission-progress em {
  display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #0e8665, #5dc29f); }
.commission-empty { padding: 70px 20px; color: var(--muted); text-align: center; }
.commission-empty > span { display: block; color: var(--commission-green); font-size: 42px; }
.commission-empty h3 { margin: 8px 0 4px; color: var(--text); font-size: 14px; }
.commission-empty p { margin: 0; font-size: 12px; }
.commission-error { margin: 10px 0; padding: 9px 11px; border: 1px solid #fecaca;
  border-radius: 8px; color: #991b1b; background: #fef2f2; font-size: 12px; }
.commission-list-card > .commission-error { margin: 10px 12px; }
.commission-create-modal { width: min(610px, calc(100vw - 28px)); }
.commission-form { display: grid; gap: 9px; }
.commission-form > div:not(.commission-error):not(.commission-form-actions) { display: grid;
  grid-template-columns: 1fr 1fr; gap: 9px; }
.commission-form label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.commission-form textarea { resize: vertical; }
.commission-form-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 4px; }
.commission-drawer-back { position: fixed; z-index: 90; inset: 0; display: flex; justify-content: flex-end;
  background: rgba(10,18,30,.56); backdrop-filter: blur(3px); }
.commission-drawer { width: min(555px, 94vw); height: 100%; overflow-y: auto; padding: 22px;
  border-left: 1px solid var(--border); background: var(--bg); box-shadow: -22px 0 60px rgba(8,15,26,.18);
  animation: document-drawer-in .2s ease-out; }
.commission-drawer > header { display: flex; justify-content: space-between; gap: 15px; }
.commission-drawer > header h2 { margin: 5px 0 3px; font-size: 22px; letter-spacing: -.03em; }
.commission-drawer > header p { margin: 0; color: var(--muted); font-size: 12px; }
.commission-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 15px;
  margin: 18px 0 11px; padding: 17px; border-radius: 13px; color: #fff;
  background: radial-gradient(circle at 90% 20%, rgba(255,255,255,.14), transparent 28%),
    linear-gradient(135deg, #16384a, #0e795e); }
.commission-hero span, .commission-hero b { display: block; }
.commission-hero span { color: #cce8df; font-size: 12px; text-transform: uppercase; }
.commission-hero b { margin-top: 6px; font-size: 25px; }
.commission-detail-grid { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.commission-detail-grid > div { padding: 12px; border-right: 1px solid var(--row-border);
  border-bottom: 1px solid var(--row-border); }
.commission-detail-grid > div:nth-child(2n) { border-right: 0; }
.commission-detail-grid > div:nth-last-child(-n + 2) { border-bottom: 0; }
.commission-detail-grid span, .commission-detail-grid b { display: block; }
.commission-detail-grid span { margin-bottom: 5px; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.commission-detail-grid b { font-size: 12px; }
.commission-eligibility { margin-top: 11px; padding: 14px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--card); }
.commission-eligibility > div { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.commission-eligibility span { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.commission-eligibility b { font-size: 12px; }
.commission-eligibility small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.commission-eligibility > i { margin-top: 10px; }
.commission-eligibility.ready { border-color: #a7dfcd; background: #f3fbf8; }
.commission-action-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.commission-edit-panel, .commission-meta { margin-top: 11px; padding: 14px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--card); }
.commission-meta h3 { margin: 0 0 8px; font-size: 12px; }
.commission-meta dl { margin: 0; }
.commission-meta dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0;
  border-bottom: 1px solid var(--row-border); }
.commission-meta dt { color: var(--muted); font-size: 12px; }
.commission-meta dd { margin: 0; font-size: 12px; font-weight: 700; text-align: right; }
.commission-meta p { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.deal-commission-status { padding: 5px 8px; border-radius: 99px; font-size: 12px; font-style: normal;
  font-weight: 800; }
.deal-commission-status.accrued { color: #475569; background: #e2e8f0; }
.deal-commission-status.pending { color: #92400e; background: #fef3c7; }
.deal-commission-status.approved { color: #075985; background: #e0f2fe; }
.deal-commission-status.paid { color: #166534; background: #dcfce7; }
.deal-commission-status.cancelled { color: #991b1b; background: #fee2e2; }
.deal-commission-summary { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden;
  border: 1px solid var(--border); border-radius: 9px; }
.deal-commission-summary > div { padding: 11px; border-right: 1px solid var(--row-border); }
.deal-commission-summary > div:last-child { border-right: 0; }
.deal-commission-summary span, .deal-commission-summary b { display: block; }
.deal-commission-summary span { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.deal-commission-summary b { margin-top: 5px; font-size: 12px; }
.deal-commission-summary .total { color: #fff; background: linear-gradient(135deg, #17394a, #0e8665); }
.deal-commission-summary .total span { color: #cce8df; }
.deal-commission-progress { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin-top: 10px; }
.deal-commission-progress span { color: var(--muted); font-size: 12px; }
.deal-commission-progress b { font-size: 12px; }
.deal-commission-progress > i { grid-column: 1 / -1; }
.deal-commission-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 10px; }
.deal-commission-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; align-items: end;
  gap: 7px; margin-top: 10px; }
.deal-commission-form label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
:root[data-theme="dark"] .commission-kpi-grid > div { background:
  radial-gradient(circle at 92% 10%, rgba(32,180,134,.1), transparent 34%), var(--card); }
:root[data-theme="dark"] .commission-status-accrued,
:root[data-theme="dark"] .deal-commission-status.accrued { color: #cbd5e1; background: #293548; }
:root[data-theme="dark"] .commission-status-pending,
:root[data-theme="dark"] .deal-commission-status.pending { color: #fcd34d; background: #30220e; }
:root[data-theme="dark"] .commission-status-approved,
:root[data-theme="dark"] .deal-commission-status.approved { color: #7dd3fc; background: #123247; }
:root[data-theme="dark"] .commission-status-paid,
:root[data-theme="dark"] .deal-commission-status.paid { color: #86efac; background: #153522; }
:root[data-theme="dark"] .commission-status-cancelled,
:root[data-theme="dark"] .deal-commission-status.cancelled { color: #fca5a5; background: #32151b; }
:root[data-theme="dark"] .commission-eligibility.ready { border-color: #166534; background: #10291c; }
:root[data-theme="dark"] .commission-error { border-color: #7f1d1d; color: #fca5a5; background: #32151b; }
@media (max-width: 1050px) {
  .commission-kpi-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .commissions-titlebar { align-items: stretch; flex-direction: column; }
  .commissions-titlebar .btn { width: 100%; }
  .commission-kpi-grid { grid-template-columns: 1fr; }
  .commission-filters { align-items: stretch; flex-direction: column; }
  .commission-filters > span { margin-left: 0; }
  .commission-search { min-width: 0; }
  .commission-drawer { width: 100%; max-width: none; padding: 17px; }
  .commission-detail-grid { grid-template-columns: 1fr; }
  .commission-detail-grid > div { border-right: 0; }
  .commission-detail-grid > div:nth-last-child(2) { border-bottom: 1px solid var(--row-border); }
  .commission-form > div:not(.commission-error):not(.commission-form-actions),
  .deal-commission-summary, .deal-commission-form { grid-template-columns: 1fr; }
  .deal-commission-summary > div { border-right: 0; border-bottom: 1px solid var(--row-border); }
  .deal-commission-summary > div:last-child { border-bottom: 0; }
}

/* ─────────────── Післяпродажний супровід ─────────────── */
.handover-page {
  --care-teal: #087f78;
  --care-navy: #173449;
  --care-orange: #d97831;
  display: grid; gap: 13px;
}
.handover-titlebar { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.handover-titlebar h1 { margin: 4px 0 2px; font-size: 28px; letter-spacing: -.04em; }
.handover-titlebar p { margin: 0; color: var(--muted); font-size: 12px; }
.handover-kicker { color: var(--care-teal); font-size: 12px; font-weight: 850;
  letter-spacing: .15em; text-transform: uppercase; }
.handover-kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.handover-kpi-grid > div { position: relative; min-height: 98px; overflow: hidden; padding: 16px;
  border: 1px solid var(--border); border-radius: 13px; background:
  radial-gradient(circle at 95% 0, rgba(8,127,120,.1), transparent 40%), var(--card); }
.handover-kpi-grid > div::after { content: ""; position: absolute; right: 12px; bottom: 12px;
  width: 22px; height: 3px; border-radius: 99px; background: #b8dcd9; }
.handover-kpi-grid > div.due::after { background: #e6b783; }
.handover-kpi-grid > div.issues::after { background: #8bb1c9; }
.handover-kpi-grid > div.alert::after { background: #ef7d73; }
.handover-kpi-grid span, .handover-kpi-grid b, .handover-kpi-grid small { display: block; }
.handover-kpi-grid span { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.handover-kpi-grid b { margin: 8px 0 4px; color: var(--care-navy); font-size: 24px; }
.handover-kpi-grid small { color: var(--muted); font-size: 12px; }
.handover-workspace { padding: 0; overflow: hidden; }
.handover-filters { display: flex; align-items: center; gap: 7px; padding: 12px;
  border-bottom: 1px solid var(--border); background: var(--card); }
.handover-filters select { min-width: 145px; }
.handover-filters > span { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.handover-search { position: relative; flex: 1; min-width: 230px; }
.handover-search span { position: absolute; top: 9px; left: 11px; color: var(--muted); }
.handover-search input { width: 100%; padding-left: 30px; }
.handover-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
  padding: 12px; background: color-mix(in srgb, var(--bg) 72%, var(--card)); }
.handover-card { position: relative; display: grid; gap: 13px; min-width: 0; padding: 16px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--card); cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.handover-card::before { content: ""; position: absolute; top: 0; left: 18px; right: 18px; height: 3px;
  border-radius: 0 0 5px 5px; background: linear-gradient(90deg, var(--care-teal), #79bdb2); opacity: .85; }
.handover-card.has-overdue::before { background: linear-gradient(90deg, #cf3f36, #ef9f67); }
.handover-card:hover { z-index: 1; transform: translateY(-2px); border-color: #9fcac5;
  box-shadow: 0 12px 32px rgba(22,52,73,.11); }
.handover-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.handover-card-top > div { min-width: 0; }
.handover-card-top > div > span { display: block; overflow: hidden; color: var(--care-teal);
  font-size: 12px; font-weight: 800; letter-spacing: .09em; text-overflow: ellipsis;
  text-transform: uppercase; white-space: nowrap; }
.handover-card h3 { margin: 5px 0 3px; font-size: 15px; letter-spacing: -.02em; }
.handover-card small { color: var(--muted); font-size: 12px; }
.handover-status { display: inline-flex; align-items: center; gap: 5px; max-width: 145px; padding: 5px 8px;
  border-radius: 99px; font-size: 12px; font-weight: 750; line-height: 1.2; text-align: left; }
.handover-status i { flex: 0 0 auto; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.handover-status-waiting_commissioning { color: #475569; background: #e2e8f0; }
.handover-status-ready_for_inspection, .handover-status-inspection { color: #075985; background: #e0f2fe; }
.handover-status-defects { color: #9a3412; background: #ffedd5; }
.handover-status-ready_for_handover { color: #0f766e; background: #ccfbf1; }
.handover-status-keys_handed, .handover-status-closed { color: #166534; background: #dcfce7; }
.handover-status-warranty { color: #6b3c0d; background: #fef3c7; }
.handover-status-cancelled { color: #991b1b; background: #fee2e2; }
.handover-card-client { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--row-border); border-bottom: 1px solid var(--row-border); }
.handover-card-client button { overflow: hidden; padding: 0; border: 0; color: var(--text);
  background: none; font-size: 12px; font-weight: 800; text-align: left; text-overflow: ellipsis;
  white-space: nowrap; cursor: pointer; }
.handover-card-client button:hover { color: var(--care-teal); }
.handover-card-client span { color: var(--muted); font-size: 12px; text-align: right; }
.handover-card-progress > div { display: flex; justify-content: space-between; margin-bottom: 6px; }
.handover-card-progress span, .handover-card-progress b { font-size: 12px; }
.handover-card-progress span { color: var(--muted); }
.handover-card-progress > i { display: block; height: 6px; overflow: hidden; border-radius: 99px; background: #e4ecec; }
.handover-card-progress em { display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--care-teal), #65b6a7); }
.handover-card-deadline { display: grid; gap: 3px; padding: 10px 11px; border-radius: 9px;
  color: #325766; background: #edf6f6; }
.handover-card-deadline span { font-size: 12px; font-weight: 750; text-transform: uppercase; }
.handover-card-deadline b { font-size: 12px; }
.handover-card-deadline.overdue { color: #991b1b; background: #fff0ed; }
.handover-card footer { display: flex; align-items: center; gap: 12px; }
.handover-card footer span { color: var(--muted); font-size: 12px; }
.handover-card footer span i { color: var(--text); font-style: normal; font-weight: 850; }
.handover-card footer span.overdue, .handover-card footer span.overdue i { color: #c24137; }
.handover-card footer strong { margin-left: auto; color: var(--care-teal); font-size: 12px; }
.handover-empty { padding: 70px 20px; color: var(--muted); text-align: center; }
.handover-empty > span { display: block; color: var(--care-teal); font-size: 42px; }
.handover-empty h3 { margin: 8px 0 4px; color: var(--text); font-size: 14px; }
.handover-empty p { margin: 0; font-size: 12px; }
.handover-empty-inline { padding: 20px; border: 1px dashed var(--border); border-radius: 10px;
  color: var(--muted); font-size: 12px; text-align: center; }
.handover-error { margin: 8px 0; padding: 9px 11px; border: 1px solid #fecaca;
  border-radius: 8px; color: #991b1b; background: #fef2f2; font-size: 12px; }
.handover-workspace > .handover-error { margin: 10px 12px; }
.handover-create-modal { width: min(620px, calc(100vw - 28px)); }
.handover-create-fields { display: grid; gap: 10px; }
.handover-create-fields label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }

.handover-drawer-back { position: fixed; z-index: 90; inset: 0; display: flex; justify-content: flex-end;
  background: rgba(7,18,27,.48); backdrop-filter: blur(3px); }
.handover-drawer { width: min(760px, 96vw); height: 100%; overflow-y: auto; padding: 22px;
  border-left: 1px solid var(--border); background: var(--bg); box-shadow: -18px 0 50px rgba(5,21,32,.2);
  animation: document-drawer-in .2s ease-out; }
.handover-drawer > header { display: flex; justify-content: space-between; gap: 15px; }
.handover-drawer > header h2 { margin: 5px 0 3px; font-size: 22px; letter-spacing: -.03em; }
.handover-client-link { padding: 0; border: 0; color: var(--muted); background: none;
  font-size: 12px; cursor: pointer; }
.handover-client-link:hover { color: var(--care-teal); }
.handover-drawer-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  gap: 16px; margin-top: 17px; padding: 17px; border-radius: 15px; color: #fff;
  background: radial-gradient(circle at 82% 15%, rgba(107,206,185,.3), transparent 33%),
  linear-gradient(135deg, #173449, #096f6b); }
.handover-drawer-hero .handover-status { color: #d4faf3; background: rgba(255,255,255,.13); }
.handover-drawer-hero h3 { margin: 8px 0 3px; font-size: 14px; }
.handover-drawer-hero p { margin: 0; color: #cce2e4; font-size: 12px; }
.handover-drawer-hero .btn { color: #fff; border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.08); }
.handover-readiness-ring { display: grid; width: 78px; height: 78px; padding: 7px; border-radius: 50%;
  background: conic-gradient(#75dcc9 var(--ready), rgba(255,255,255,.15) 0); }
.handover-readiness-ring::before { content: ""; grid-area: 1 / 1; border-radius: 50%; background: #16475a; }
.handover-readiness-ring span { z-index: 1; grid-area: 1 / 1; display: grid; place-content: center; text-align: center; }
.handover-readiness-ring b, .handover-readiness-ring small { display: block; }
.handover-readiness-ring b { font-size: 16px; }
.handover-readiness-ring small { margin-top: 2px; color: #cce2e4; font-size: 12px; text-transform: uppercase; }
.handover-workflow { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; margin: 12px 0;
  padding: 13px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.handover-workflow > div { position: relative; display: grid; justify-items: center; gap: 5px; color: var(--muted); }
.handover-workflow > div:not(:last-child)::after { content: ""; position: absolute; top: 9px; left: 60%;
  width: 80%; height: 1px; background: var(--border); }
.handover-workflow i { z-index: 1; display: grid; place-items: center; width: 19px; height: 19px;
  border: 1px solid var(--border); border-radius: 50%; background: var(--card); font-size: 12px;
  font-style: normal; font-weight: 800; }
.handover-workflow span { max-width: 85px; font-size: 12px; line-height: 1.3; text-align: center; }
.handover-workflow .done { color: var(--care-teal); }
.handover-workflow .done i { color: #fff; border-color: var(--care-teal); background: var(--care-teal); }
.handover-workflow .done:not(:last-child)::after { background: #72bcb3; }
.handover-editor-panel { margin-bottom: 12px; padding: 15px; border: 1px solid #afd6d1;
  border-radius: 12px; background: color-mix(in srgb, var(--card) 88%, #d5f3ef); }
.handover-case-editor { display: grid; gap: 11px; }
.handover-editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.handover-editor-grid label, .handover-issue-form-grid label { display: grid; gap: 5px;
  color: var(--muted); font-size: 12px; font-weight: 700; }
.handover-editor-wide { grid-column: 1 / -1; }
.handover-readiness-field > div { display: grid; grid-template-columns: 1fr 35px; align-items: center; gap: 9px; }
.handover-readiness-field input { padding: 0; }
.handover-readiness-field b { color: var(--care-teal); font-size: 12px; text-align: right; }
.handover-form-actions { display: flex; justify-content: flex-end; gap: 7px; }
.handover-facts { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.handover-facts > div { min-width: 0; padding: 12px; border-right: 1px solid var(--row-border);
  border-bottom: 1px solid var(--row-border); }
.handover-facts > div:nth-child(4n) { border-right: 0; }
.handover-facts > div:nth-last-child(-n + 4) { border-bottom: 0; }
.handover-facts span, .handover-facts b { display: block; }
.handover-facts span { margin-bottom: 5px; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.handover-facts b { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.handover-note { margin-top: 10px; padding: 13px; border-left: 3px solid var(--care-teal);
  border-radius: 4px 10px 10px 4px; background: var(--card); }
.handover-note span { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.handover-note p { margin: 5px 0 0; font-size: 12px; line-height: 1.55; white-space: pre-line; }
.handover-issues-section, .handover-history { margin-top: 12px; padding: 15px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.handover-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.handover-section-heading h3 { margin: 3px 0 0; font-size: 13px; }
.handover-section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.handover-issue-composer { display: grid; gap: 10px; margin-top: 12px; padding: 13px;
  border: 1px solid #b8dcd7; border-radius: 10px; background: color-mix(in srgb, var(--bg) 70%, #dff7f3); }
.handover-issue-form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; }
.handover-photo-field { position: relative; align-content: center; min-height: 54px; padding: 9px;
  border: 1px dashed var(--border); border-radius: 8px; cursor: pointer; }
.handover-photo-field input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.handover-photo-field span { color: var(--care-teal); font-size: 12px; }
.handover-photo-preview { position: relative; width: 86px; height: 64px; overflow: hidden; border-radius: 8px; }
.handover-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.handover-photo-preview button { position: absolute; right: 3px; bottom: 3px; padding: 3px 5px; border: 0;
  border-radius: 4px; color: #fff; background: rgba(0,0,0,.65); font-size: 12px; cursor: pointer; }
.handover-issue-list { display: grid; gap: 8px; margin-top: 11px; }
.handover-issue { display: grid; grid-template-columns: auto minmax(0, 1fr); overflow: hidden;
  border: 1px solid var(--border); border-left: 3px solid #94a3b8; border-radius: 10px; background: var(--bg); }
.handover-issue.severity-major { border-left-color: #e28535; }
.handover-issue.severity-critical, .handover-issue.overdue { border-left-color: #dc4d43; }
.handover-issue-photo { display: block; width: 112px; min-height: 125px; background: #dce6e7; }
.handover-issue-photo img { width: 100%; height: 100%; object-fit: cover; }
.handover-issue-main { min-width: 0; padding: 12px; }
.handover-issue-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.handover-issue-top > div > span { color: var(--care-teal); font-size: 12px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; }
.handover-issue h4 { margin: 4px 0 0; font-size: 12px; }
.handover-issue p { margin: 8px 0; color: var(--muted); font-size: 12px; line-height: 1.5; white-space: pre-line; }
.handover-issue-status { flex: 0 0 auto; padding: 4px 7px; border-radius: 99px; color: #475569;
  background: #e2e8f0; font-size: 12px; font-weight: 750; }
.handover-issue-status.status-in_progress { color: #92400e; background: #fef3c7; }
.handover-issue-status.status-resolved, .handover-issue-status.status-accepted {
  color: #166534; background: #dcfce7; }
.handover-issue-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 8px; }
.handover-issue-meta > span { color: var(--muted); font-size: 12px; }
.handover-issue-meta > span.overdue { color: #c24137; font-weight: 800; }
.severity-label { padding: 3px 6px; border-radius: 99px; background: #e2e8f0; }
.severity-label.major { color: #9a3412; background: #ffedd5; }
.severity-label.critical { color: #991b1b; background: #fee2e2; }
.handover-issue-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 10px; }
.handover-issue-edit { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; margin-top: 10px;
  padding-top: 10px; border-top: 1px solid var(--row-border); }
.handover-issue-edit .btn { justify-self: start; }
.handover-clean-state { display: grid; justify-items: center; gap: 4px; padding: 24px;
  border: 1px dashed var(--border); border-radius: 10px; color: var(--muted); text-align: center; }
.handover-clean-state i { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  color: #fff; background: var(--care-teal); font-size: 12px; font-style: normal; }
.handover-clean-state b { color: var(--text); font-size: 12px; }
.handover-clean-state span { font-size: 12px; }
.handover-history > div:last-child { display: grid; gap: 0; margin-top: 10px; }
.handover-history article { display: grid; grid-template-columns: 12px 1fr; gap: 8px; min-height: 38px; }
.handover-history article > i { position: relative; width: 7px; height: 7px; margin-top: 4px; border: 2px solid var(--card);
  border-radius: 50%; background: var(--care-teal); box-shadow: 0 0 0 1px #8dc9c1; }
.handover-history article:not(:last-child) > i::after { content: ""; position: absolute; top: 7px; left: 2px;
  width: 1px; height: 31px; background: var(--border); }
.handover-history article b, .handover-history article span { display: block; }
.handover-history article b { font-size: 12px; }
.handover-history article span { margin-top: 3px; color: var(--muted); font-size: 12px; }

:root[data-theme="dark"] .handover-kpi-grid b { color: #e7f5f3; }
:root[data-theme="dark"] .handover-card { background: linear-gradient(145deg, var(--card), #14212d); }
:root[data-theme="dark"] .handover-card-deadline { color: #b6ddda; background: #122c31; }
:root[data-theme="dark"] .handover-card-deadline.overdue { color: #fca5a5; background: #32191b; }
:root[data-theme="dark"] .handover-card-progress > i { background: #263846; }
:root[data-theme="dark"] .handover-status-waiting_commissioning,
:root[data-theme="dark"] .handover-issue-status { color: #cbd5e1; background: #293548; }
:root[data-theme="dark"] .handover-status-ready_for_inspection,
:root[data-theme="dark"] .handover-status-inspection { color: #7dd3fc; background: #123247; }
:root[data-theme="dark"] .handover-status-defects,
:root[data-theme="dark"] .severity-label.major { color: #fdba74; background: #352111; }
:root[data-theme="dark"] .handover-status-ready_for_handover { color: #75ddce; background: #11342f; }
:root[data-theme="dark"] .handover-status-keys_handed,
:root[data-theme="dark"] .handover-status-closed,
:root[data-theme="dark"] .handover-issue-status.status-resolved,
:root[data-theme="dark"] .handover-issue-status.status-accepted { color: #86efac; background: #153522; }
:root[data-theme="dark"] .handover-status-warranty,
:root[data-theme="dark"] .handover-issue-status.status-in_progress { color: #fcd34d; background: #30220e; }
:root[data-theme="dark"] .handover-status-cancelled,
:root[data-theme="dark"] .severity-label.critical { color: #fca5a5; background: #32151b; }
:root[data-theme="dark"] .handover-error { border-color: #7f1d1d; color: #fca5a5; background: #32151b; }
:root[data-theme="dark"] .handover-editor-panel,
:root[data-theme="dark"] .handover-issue-composer { border-color: #285b58; background: #112a2b; }

@media (max-width: 1120px) {
  .handover-card-grid { grid-template-columns: 1fr 1fr; }
  .handover-kpi-grid { grid-template-columns: 1fr 1fr; }
  .handover-facts { grid-template-columns: 1fr 1fr; }
  .handover-facts > div:nth-child(2n) { border-right: 0; }
  .handover-facts > div:nth-last-child(-n + 4) { border-bottom: 1px solid var(--row-border); }
  .handover-facts > div:nth-last-child(-n + 2) { border-bottom: 0; }
}
@media (max-width: 760px) {
  .handover-titlebar { align-items: stretch; flex-direction: column; }
  .handover-titlebar .btn { width: 100%; }
  .handover-kpi-grid, .handover-card-grid { grid-template-columns: 1fr; }
  .handover-filters { align-items: stretch; flex-direction: column; }
  .handover-filters > span { margin-left: 0; }
  .handover-search { min-width: 0; }
  .handover-drawer { width: 100%; max-width: none; padding: 16px; }
  .handover-drawer-hero { grid-template-columns: auto 1fr; }
  .handover-drawer-hero > .btn { grid-column: 1 / -1; width: 100%; }
  .handover-workflow { grid-template-columns: repeat(3, 1fr); row-gap: 12px; }
  .handover-workflow > div:nth-child(3)::after { display: none; }
  .handover-editor-grid, .handover-issue-form-grid, .handover-issue-edit { grid-template-columns: 1fr; }
  .handover-editor-wide { grid-column: auto; }
  .handover-facts { grid-template-columns: 1fr; }
  .handover-facts > div, .handover-facts > div:nth-child(2n) { border-right: 0; border-bottom: 1px solid var(--row-border); }
  .handover-facts > div:last-child { border-bottom: 0; }
  .handover-issue { grid-template-columns: 1fr; }
  .handover-issue-photo { width: 100%; height: 170px; min-height: 0; }
}

/* Центр дублів */
.duplicates-page { --duplicate-ink: #17324d; --duplicate-teal: #0f766e;
  --duplicate-coral: #e76f51; }
.duplicate-hero { position: relative; display: flex; align-items: center;
  justify-content: space-between; gap: 24px; overflow: hidden; min-height: 148px;
  margin-bottom: 14px; padding: 26px 30px; border-radius: 18px; color: #f8fafc;
  background:
    radial-gradient(circle at 82% 18%, rgba(94,234,212,.24), transparent 29%),
    radial-gradient(circle at 7% 120%, rgba(251,146,60,.2), transparent 36%),
    linear-gradient(125deg, #12283c 0%, #17475a 58%, #11645f 100%);
  box-shadow: 0 14px 34px rgba(15,48,65,.18); }
.duplicate-hero::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 26px 26px; mask-image: linear-gradient(90deg, transparent, #000); }
.duplicate-hero > * { position: relative; z-index: 1; }
.duplicate-eyebrow { display: block; margin-bottom: 7px; color: #99f6e4;
  font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.duplicate-hero h1 { margin: 0; color: #fff; font-size: clamp(24px, 3vw, 34px);
  letter-spacing: -.035em; }
.duplicate-hero p { max-width: 610px; margin: 8px 0 0; color: #d1e8ea;
  font-size: 12px; line-height: 1.55; }
.duplicate-scan-btn { display: inline-flex; align-items: center; gap: 9px; min-width: 178px;
  justify-content: center; border-color: rgba(255,255,255,.28); color: #103b3d;
  background: #f3fffc; box-shadow: 0 8px 20px rgba(7,29,39,.18); }
.duplicate-scan-btn:hover { background: #d9fff5; }
.duplicate-scan-btn > span { position: relative; width: 14px; height: 14px;
  border: 1.8px solid currentColor; border-radius: 50%; }
.duplicate-scan-btn > span::after { content: ""; position: absolute; right: -4px; bottom: -2px;
  width: 6px; height: 2px; border-radius: 2px; background: currentColor; transform: rotate(45deg); }

.duplicate-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px; margin-bottom: 14px; }
.duplicate-kpis > div { position: relative; overflow: hidden; min-height: 92px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 13px; background: var(--card); }
.duplicate-kpis > div::before { content: ""; position: absolute; top: 0; left: 0;
  width: 4px; height: 100%; background: #5fa89f; }
.duplicate-kpis > div:nth-child(2)::before { background: var(--duplicate-coral); }
.duplicate-kpis > div:nth-child(3)::before { background: #4776a8; }
.duplicate-kpis > div:nth-child(4)::before { background: #c49743; }
.duplicate-kpis span, .duplicate-kpis b, .duplicate-kpis small { display: block; }
.duplicate-kpis span { color: var(--muted); font-size: 12px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; }
.duplicate-kpis b { margin: 5px 0 2px; color: var(--text); font-size: 24px; line-height: 1; }
.duplicate-kpis small { color: var(--muted); font-size: 12px; }

.duplicate-toolbar { display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 12px; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--card); }
.duplicate-toolbar > div { display: flex; flex-wrap: wrap; gap: 8px; }
.duplicate-toolbar label { display: grid; gap: 4px; margin: 0; color: var(--muted);
  font-size: 12px; font-weight: 700; text-transform: uppercase; }
.duplicate-toolbar select { min-width: 145px; padding: 7px 30px 7px 10px; font-size: 12px;
  text-transform: none; }
.duplicate-toolbar > span { padding-bottom: 7px; color: var(--muted); font-size: 12px; }
.duplicate-list { display: grid; gap: 12px; }
.duplicate-card { overflow: hidden; border: 1px solid var(--border); border-radius: 15px;
  background: var(--card); box-shadow: 0 2px 7px rgba(15,23,42,.045); }
.duplicate-card-head { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 13px 16px 10px; }
.duplicate-card-head > div { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.duplicate-card-head time { color: var(--muted); font-size: 12px; }
.duplicate-score { display: inline-flex; align-items: baseline; gap: 4px; padding: 5px 9px;
  border-radius: 99px; color: #475569; background: #e2e8f0; font-size: 12px; font-weight: 700; }
.duplicate-score b { font-size: 12px; }
.duplicate-score.high { color: #9a3412; background: #ffedd5; }
.duplicate-score.medium { color: #854d0e; background: #fef9c3; }
.duplicate-score.low { color: #334155; background: #e2e8f0; }
.duplicate-type, .duplicate-resolution { padding: 5px 8px; border-radius: 99px;
  color: #0f5e5a; background: #d8f3ee; font-size: 12px; font-weight: 750; }
.duplicate-resolution.status-dismissed, .duplicate-resolution.status-stale {
  color: #475569; background: #e2e8f0; }
.duplicate-resolution.status-merged { color: #166534; background: #dcfce7; }
.duplicate-reasons { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; }
.duplicate-reasons span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px;
  border: 1px solid #bbdcd7; border-radius: 7px; color: #315d62; background: #f1faf8;
  font-size: 12px; font-weight: 650; }
.duplicate-reasons i { width: 5px; height: 5px; border-radius: 50%; background: #27988d; }
.duplicate-pair { display: grid; grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr);
  align-items: stretch; padding: 0 14px 14px; }
.duplicate-entity { position: relative; display: flex; flex-direction: column; min-width: 0;
  margin: 0; padding: 14px; border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); background: var(--bg); cursor: pointer;
  transition: border-color .16s, box-shadow .16s, transform .16s; }
.duplicate-entity:hover { border-color: #7ebbb4; transform: translateY(-1px); }
.duplicate-entity.selected { border-color: #2b948a;
  box-shadow: inset 0 0 0 1px #2b948a, 0 5px 14px rgba(15,118,110,.08); }
.duplicate-entity > input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.duplicate-select-mark { position: absolute; top: 13px; right: 13px; width: 14px; height: 14px;
  border: 1.5px solid #94a3b8; border-radius: 50%; background: var(--card); }
.duplicate-entity.selected .duplicate-select-mark { border: 4px solid var(--duplicate-teal); }
.duplicate-keep-label { margin-bottom: 8px; color: var(--muted); font-size: 12px;
  font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.duplicate-entity.selected .duplicate-keep-label { color: var(--duplicate-teal); }
.duplicate-entity-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 9px; padding-right: 18px; }
.duplicate-entity-head > span:first-child { min-width: 0; }
.duplicate-entity-head b, .duplicate-entity-head small { display: block; }
.duplicate-entity-head b { overflow: hidden; font-size: 13px; text-overflow: ellipsis;
  white-space: nowrap; }
.duplicate-entity-head small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.duplicate-status { flex: 0 0 auto; padding: 4px 7px; border-radius: 99px;
  color: #334155; background: #e2e8f0; font-size: 12px; font-weight: 700; }
.duplicate-contact-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 13px;
  margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--row-border); }
.duplicate-contact-list > span { min-width: 0; }
.duplicate-contact-list i, .duplicate-contact-list b { display: block; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.duplicate-contact-list i { margin-bottom: 2px; color: var(--muted); font-size: 12px;
  font-style: normal; }
.duplicate-contact-list b { font-size: 12px; font-weight: 650; }
.duplicate-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.duplicate-tags em { padding: 3px 6px; border-radius: 5px; color: #475569;
  background: #e9eef3; font-size: 12px; font-style: normal; }
.duplicate-counts { display: flex; flex-wrap: wrap; gap: 5px 10px; margin-top: auto;
  padding-top: 12px; color: var(--muted); font-size: 12px; }
.duplicate-counts b { color: var(--text); font-size: 12px; }
.duplicate-open-link { align-self: flex-start; margin-top: 10px; padding: 0; border: 0;
  color: var(--duplicate-teal); background: none; font-size: 12px; font-weight: 750; cursor: pointer; }
.duplicate-open-link:hover { text-decoration: underline; }
.duplicate-versus { display: grid; place-items: center; }
.duplicate-versus span { display: grid; place-items: center; width: 26px; height: 26px;
  border: 1px solid var(--border); border-radius: 50%; color: var(--muted);
  background: var(--card); font-size: 12px; font-weight: 750; }
.duplicate-actions { display: flex; align-items: center; justify-content: flex-end;
  gap: 7px; padding: 10px 14px; border-top: 1px solid var(--row-border); background: var(--bg); }
.duplicate-actions .btn { padding: 7px 11px; font-size: 12px; }
.duplicate-resolution-note { margin-right: auto; color: var(--muted); font-size: 12px;
  font-style: italic; }
.duplicate-error, .duplicate-notice { margin-bottom: 12px; padding: 10px 13px;
  border: 1px solid #fecaca; border-radius: 9px; color: #991b1b; background: #fef2f2;
  font-size: 12px; }
.duplicate-notice { border-color: #a7d9d1; color: #115e59; background: #edfafa; }
.duplicate-loading, .duplicate-empty { display: grid; justify-items: center; gap: 5px;
  min-height: 210px; place-content: center; padding: 30px; border: 1px dashed var(--border);
  border-radius: 14px; color: var(--muted); text-align: center; }
.duplicate-empty > span { position: relative; width: 44px; height: 44px; margin-bottom: 6px;
  border: 1.5px solid #71aaa4; border-radius: 50%; }
.duplicate-empty > span::before, .duplicate-empty > span::after { content: ""; position: absolute;
  width: 15px; height: 15px; border: 2px solid #2f8c83; border-radius: 4px; }
.duplicate-empty > span::before { top: 10px; left: 9px; }
.duplicate-empty > span::after { right: 8px; bottom: 9px; }
.duplicate-empty h3 { margin: 0; color: var(--text); }
.duplicate-empty p { margin: 0; font-size: 12px; }

.duplicate-merge-modal { max-width: 560px; }
.duplicate-modal-kicker { color: var(--duplicate-teal); font-size: 12px; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase; }
.duplicate-merge-modal h2 { margin: 5px 0 0; font-size: 20px; }
.duplicate-merge-flow { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 10px; margin: 15px 0; }
.duplicate-merge-flow > div { min-width: 0; padding: 11px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--bg); }
.duplicate-merge-flow span, .duplicate-merge-flow b, .duplicate-merge-flow small { display: block; }
.duplicate-merge-flow span { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.duplicate-merge-flow b { overflow: hidden; margin: 4px 0 2px; font-size: 12px;
  text-overflow: ellipsis; white-space: nowrap; }
.duplicate-merge-flow small { color: var(--muted); font-size: 12px; }
.duplicate-merge-flow > i { color: var(--duplicate-teal); font-size: 20px; font-style: normal; }
.duplicate-warning { padding: 10px 12px; border-left: 3px solid #f59e0b; border-radius: 5px;
  color: #7c4a0a; background: #fffbeb; font-size: 12px; line-height: 1.55; }
.duplicate-merge-modal label { margin-top: 10px; }
.duplicate-merge-modal label input, .duplicate-merge-modal label textarea { width: 100%;
  margin-top: 5px; }
.duplicate-merge-modal code { color: var(--text); font-size: 12px; }

:root[data-theme="dark"] .duplicate-reasons span { border-color: #285b58; color: #9bd8d1;
  background: #112a2b; }
:root[data-theme="dark"] .duplicate-type { color: #80d9cf; background: #163b39; }
:root[data-theme="dark"] .duplicate-score.high { color: #fdba74; background: #3c2616; }
:root[data-theme="dark"] .duplicate-score.medium { color: #fde68a; background: #352c13; }
:root[data-theme="dark"] .duplicate-score.low,
:root[data-theme="dark"] .duplicate-status,
:root[data-theme="dark"] .duplicate-resolution.status-dismissed,
:root[data-theme="dark"] .duplicate-resolution.status-stale { color: #cbd5e1; background: #293548; }
:root[data-theme="dark"] .duplicate-resolution.status-merged { color: #86efac; background: #153522; }
:root[data-theme="dark"] .duplicate-tags em { color: #cbd5e1; background: #293548; }
:root[data-theme="dark"] .duplicate-warning { color: #fcd34d; background: #30220e; }
:root[data-theme="dark"] .duplicate-error { border-color: #7f1d1d; color: #fca5a5; background: #32151b; }
:root[data-theme="dark"] .duplicate-notice { border-color: #285b58; color: #8be0d5; background: #112a2b; }

@media (max-width: 980px) {
  .duplicate-kpis { grid-template-columns: 1fr 1fr; }
  .duplicate-pair { grid-template-columns: 1fr; gap: 8px; }
  .duplicate-versus { height: 18px; }
  .duplicate-versus span { width: 24px; height: 24px; }
}
@media (max-width: 680px) {
  .duplicate-hero { align-items: stretch; flex-direction: column; padding: 22px; }
  .duplicate-scan-btn { width: 100%; }
  .duplicate-kpis { grid-template-columns: 1fr 1fr; }
  .duplicate-toolbar { align-items: stretch; flex-direction: column; }
  .duplicate-toolbar > div { display: grid; grid-template-columns: 1fr; }
  .duplicate-toolbar select { width: 100%; }
  .duplicate-toolbar > span { padding: 0; }
  .duplicate-card-head { align-items: flex-start; flex-direction: column; }
  .duplicate-contact-list { grid-template-columns: 1fr; }
  .duplicate-actions { align-items: stretch; flex-direction: column-reverse; }
  .duplicate-actions .btn { width: 100%; }
  .duplicate-resolution-note { margin: 0; }
  .duplicate-merge-flow { grid-template-columns: 1fr; }
  .duplicate-merge-flow > i { justify-self: center; transform: rotate(90deg); }
}
