﻿:root {
  /* Основа: тёмно-синий + перивинкль */
  --color-navy-900: #1A1D42;
  --color-navy-800: #2A2D6E;
  --color-navy-700: #3A3F8C;

  --color-bg: #E6EAF4;
  --color-surface: #FFFFFF;
  --color-text: #1A1D42;
  --color-text-muted: #4E5575;
  --color-border: #C8CEE0;
  --color-row-hover: #EEF1F8;

  /* Акцент: насыщенный синий (читается на белом и на голубом фоне) */
  --color-primary: #2F55C8;
  --color-primary-hover: #2346AD;
  --color-primary-light: #4D74E8;
  --color-primary-subtle: rgba(47, 85, 200, 0.12);
  --color-primary-ring: rgba(47, 85, 200, 0.35);

  /* Дополнительный голубой акцент */
  --color-accent: #3BA8E8;
  --color-accent-subtle: rgba(59, 168, 232, 0.14);

  --color-link: #1F46A8;
  --color-link-hover: #17388C;

  --color-success: #1F9B62;
  --color-success-bg: rgba(31, 155, 98, 0.12);
  --color-warning: #D4820A;
  --color-warning-bg: rgba(212, 130, 10, 0.12);
  --color-danger: #D43B3B;
  --color-danger-bg: rgba(212, 59, 59, 0.1);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-card: 0 1px 3px rgba(26, 29, 66, 0.08);
  --shadow-elevated: 0 4px 16px rgba(26, 29, 66, 0.1);
  --shadow-modal: 0 12px 40px rgba(26, 29, 66, 0.18);
  --transition-fast: 0.15s ease;
  --sidebar-width: 200px;
  --sidebar-bg: #2A2D6E;
  --sidebar-text: #FFFFFF;
  --sidebar-text-muted: rgba(255, 255, 255, 0.68);
  --sidebar-accent: #7EB8FF;
  --main-area-bg: #C4CAE4;
  --header-height: 56px;

  /* Карточка рекламации — размеры модалки */
  --reclamation-modal-width-max: 1320px;
  --reclamation-modal-gap: 20px;
  --reclamation-modal-height-max: 94dvh;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: 'Segoe UI', Inter, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--color-primary-subtle);
  color: var(--color-navy-900);
}

button,
.btn {
  touch-action: manipulation;
}

.hidden { display: none !important; }

.text-muted { color: var(--color-text-muted); }

.empty-state {
  text-align: center;
  padding: 24px;
  color: var(--color-text-muted);
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--main-area-bg) 0%, var(--color-bg) 45%, var(--color-surface) 100%);
}

.login-card {
  background: var(--color-surface);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  border: 1px solid var(--color-border);
  width: 360px;
}

.login-card h1,
.login-logo-product {
  margin: 0 0 24px;
  font-size: 22px;
  text-align: center;
  color: var(--color-navy-900);
}

.login-company {
  margin: -16px 0 24px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  color: var(--color-text-muted);
}

.login-company:not(.hidden) + form,
.login-logo-product:has(+ .login-company:not(.hidden)) {
  margin-top: 0;
}

.login-logo-product:has(+ .login-company:not(.hidden)) {
  margin-bottom: 6px;
}

.login-card form .field:last-of-type {
  margin-bottom: 0;
}

/* App shell */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  padding: 16px 0;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-logo-product {
  font-weight: 700;
  font-size: 18px;
  color: var(--sidebar-text);
}

.sidebar-logo-company {
  font-weight: 500;
  font-size: 12px;
  line-height: 1.3;
  color: var(--sidebar-text-muted);
  letter-spacing: 0.02em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  margin-bottom: 4px;
}

.sidebar-section-label {
  padding: 6px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-text-muted);
  user-select: none;
}

.sidebar-section.is-active .sidebar-section-label {
  color: var(--sidebar-accent);
}

.sidebar-section + .sidebar-section {
  margin-top: 12px;
}

.sidebar-subsection-label {
  padding: 10px 16px 6px 28px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.5);
  user-select: none;
}

.sidebar-subsection-label:first-of-type {
  padding-top: 8px;
}

.sidebar-item {
  display: block;
  padding: 10px 16px;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.sidebar-item.active {
  background: rgba(126, 184, 255, 0.16);
  border-left-color: var(--sidebar-accent);
  color: var(--sidebar-text);
  font-weight: 600;
}

.sidebar-subitem {
  padding-left: 28px;
  font-size: 13px;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--main-area-bg);
}

.app-header {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 0 rgba(26, 29, 66, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}

.app-header-start,
.app-header-end {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-header-end {
  margin-left: auto;
}

.app-header-brand {
  display: none;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-weight: 700;
  font-size: 17px;
  color: var(--color-navy-900);
}

.app-header-product {
  flex-shrink: 0;
}

.app-header-company {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-menu-toggle:hover {
  background: var(--color-row-hover);
}

.btn-menu-icon,
.btn-menu-icon::before,
.btn-menu-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--color-text);
  border-radius: 1px;
}

.btn-menu-icon {
  position: relative;
}

.btn-menu-icon::before,
.btn-menu-icon::after {
  content: '';
  position: absolute;
  left: 0;
}

.btn-menu-icon::before { top: -6px; }
.btn-menu-icon::after { top: 6px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1050;
}

.sidebar-overlay.is-visible {
  display: block;
}

#header-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.app-content {
  padding: 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#view-kanban,
#view-orders-kanban {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#view-kanban .toolbar,
#view-orders-kanban .toolbar {
  flex-shrink: 0;
}

/* Канбан: без прокрутки страницы, колонки до низа экрана */
.app-shell:has(#view-kanban:not(.hidden)),
.app-shell:has(#view-orders-kanban:not(.hidden)) {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.app-shell:has(#view-kanban:not(.hidden)) .main-area,
.app-shell:has(#view-orders-kanban:not(.hidden)) .main-area {
  overflow: hidden;
  min-height: 0;
}

.app-content:has(#view-kanban:not(.hidden)),
.app-content:has(#view-orders-kanban:not(.hidden)) {
  padding-bottom: 0;
  overflow: hidden;
}

.settings-entity-type-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 16px;
  font-size: 13px;
  color: var(--color-navy-700);
}

.settings-entity-type-select {
  min-width: 140px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
}

.page-title {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 600;
  color: var(--color-navy-900);
}

.page-heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.page-heading-meta {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  background: var(--color-surface);
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
}

.toolbar .page-title {
  margin: 0;
}

.page-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.toolbar-quick-filter {
  flex: 1;
  max-width: 420px;
  min-width: 140px;
}

.quick-filter-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}

.quick-filter-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.quick-filter-input::-webkit-search-cancel-button {
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.25;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.btn-block {
  width: 100%;
}

.btn-block-spaced {
  width: 100%;
  margin-top: 12px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(26, 29, 66, 0.12);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

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

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-link);
  border-color: var(--color-primary-light);
  font-weight: 500;
}

.btn-secondary:hover {
  background: var(--color-primary-subtle);
  border-color: var(--color-primary);
  color: var(--color-primary-hover);
}

.btn-secondary.btn-danger {
  color: var(--color-danger);
  border-color: rgba(212, 59, 59, 0.45);
}

.btn-secondary.btn-danger:hover {
  background: var(--color-danger-bg);
  border-color: var(--color-danger);
  color: #B82E2E;
}

.btn-ghost {
  background: transparent;
  color: var(--color-link);
  border: none;
  padding: 4px 8px;
  font-weight: 500;
}

.btn-ghost:hover {
  background: var(--color-primary-subtle);
  color: var(--color-primary-hover);
}

.btn-danger { color: var(--color-danger); }

.btn-ghost.btn-danger {
  color: var(--color-danger);
}

.btn-ghost.btn-danger:hover {
  background: var(--color-danger-bg);
  color: #B82E2E;
}

.password-input-wrap {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.password-input-wrap input {
  flex: 1;
  min-width: 0;
}

.btn-password-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
}

.btn-password-toggle:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.btn-password-toggle svg.hidden {
  display: none;
}

/* Table */
.card-surface {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.data-table { width: 100%; border-collapse: collapse; }

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-bg);
}

.data-table thead th {
  border-bottom: 1px solid var(--color-border);
}

.data-table--row-open tbody tr[data-id] { cursor: pointer; }

.data-table--row-open tbody tr[data-id]:hover { background: var(--color-row-hover); }

.data-table td.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 24px;
  cursor: default;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

/* Form */
.field { margin-bottom: 12px; }

.field label {
  display: block;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.empty-value { color: var(--color-text-muted); font-style: italic; }

/* Section card */
.section-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  padding: 16px 20px;
}

.section-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 16px;
}

.section-cards-grid .section-card {
  margin-bottom: 0;
  min-width: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

.section-header .section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: 12px 24px;
}

.field-grid .field-full { grid-column: 1 / -1; }

.field-view .field-label {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.field-view .field-value {
  font-size: 15px;
  margin-bottom: 12px;
}

.field-value-editable {
  cursor: pointer;
  border-radius: 4px;
  margin-left: -4px;
  margin-right: -4px;
  padding: 2px 4px;
  transition: background 0.15s;
}

.field-value-editable:hover {
  background: var(--color-bg);
}

.field-value-editable:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

/* Stage required fields settings */
.stage-fields-toolbar {
  padding: 16px 20px;
  margin-bottom: 16px;
}

.stage-fields-hint {
  margin: 0;
  font-size: 13px;
}

.stage-fields-legend {
  margin: 10px 0 0;
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.stage-required-legend-mark {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 2px;
}

.stage-required-legend-origin {
  background: var(--color-primary);
  opacity: 0.85;
}

.stage-required-legend-inherited {
  background: var(--color-border);
  border: 1px dashed var(--color-text-muted);
  opacity: 0.7;
}

.stage-required-table {
  margin: 0;
}

.stage-required-table tbody tr {
  cursor: default;
}

.stage-required-table tbody tr:hover {
  background: transparent;
}

.stage-required-field-col {
  min-width: 200px;
  vertical-align: bottom;
}

.stage-required-stage-col {
  min-width: 130px;
  vertical-align: bottom;
}

.stage-required-col-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

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

.stage-required-col-name {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  max-width: 120px;
}

.stage-required-col-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.stage-required-count {
  font-size: 11px;
  color: var(--color-text-muted);
  min-height: 14px;
}

.stage-required-section-row {
  background: var(--color-bg);
}

.stage-required-section-row td {
  border-top: 2px solid var(--color-border);
  padding-top: 10px;
  padding-bottom: 6px;
}

.stage-required-section-name {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.stage-required-field-name {
  font-weight: 500;
  padding-left: 12px;
}

.stage-required-field-row:hover td {
  background: var(--color-row-hover);
}

.stage-required-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-width: 24px;
  min-height: 24px;
}

.stage-required-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.stage-required-toggle.stage-required-inherited {
  cursor: default;
}

.stage-required-toggle.stage-required-inherited input {
  cursor: not-allowed;
  opacity: 0.55;
  accent-color: var(--color-text-muted);
}

.stage-required-table td:not(.stage-required-section-name):not(.stage-required-field-name) {
  text-align: center;
}

/* Stage change permissions settings */
.stage-permissions-toolbar {
  padding: 16px 20px;
  margin-bottom: 16px;
}

.stage-permissions-hint {
  margin: 0;
  font-size: 13px;
}

.stage-permissions-table tbody tr {
  cursor: default;
}

.stage-permissions-table td:not(.stage-permissions-stage-name) {
  text-align: center;
}

.field-permissions-table tbody tr {
  cursor: default;
}

.field-permissions-table td:not(.field-permissions-section-name) {
  text-align: center;
  vertical-align: middle;
}

.field-permissions-table .access-segment {
  margin: 0 auto;
}

.stage-permissions-stage-name {
  min-width: 180px;
  font-weight: 500;
}

.stage-email-toolbar {
  padding: 16px 20px;
  margin-bottom: 16px;
}

.stage-email-hint {
  margin: 0;
  font-size: 13px;
}

.stage-email-table tbody tr {
  cursor: default;
}

.stage-email-table td:not(.stage-email-stage-name) {
  text-align: center;
}

.stage-email-stage-name {
  min-width: 180px;
  font-weight: 500;
}

.stage-email-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.stage-email-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.mail-account-form {
  padding: 16px 20px;
}

.mail-account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 10px 16px;
}

.field-checkbox {
  display: flex;
  align-items: end;
}

.field-checkbox label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.stage-permission-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.stage-permission-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* Field permissions settings */
#field-permissions-container {
  max-width: 100%;
  min-width: 0;
}

.field-permissions-toolbar {
  padding: 16px 20px;
  margin-bottom: 16px;
}

.field-permissions-hint {
  margin: 0;
  font-size: 13px;
}

.field-permissions-table {
  margin: 0;
}

.field-permissions-section-name {
  min-width: 180px;
  font-weight: 500;
}

.field-permissions-field-name {
  min-width: 200px;
}

.field-permissions-groups {
  margin-top: 0;
  min-width: 0;
}

.field-permissions-group {
  min-width: 0;
}

.field-permissions-group .table-responsive {
  overflow: visible;
}

.field-permissions-group .field-permissions-table thead {
  display: none;
}

.field-permissions-group .field-permissions-table tbody tr {
  display: block;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.field-permissions-group .field-permissions-table tbody tr:last-child {
  border-bottom: none;
}

.field-permissions-group .field-permissions-table td {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-bottom: none;
  min-width: 0;
  text-align: right;
}

.field-permissions-group .field-permissions-table td::before {
  content: attr(data-label);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  text-align: left;
  flex: 1 1 auto;
  min-width: 0;
}

.field-permissions-group .field-permissions-field-name {
  display: block;
  min-width: 0;
  font-weight: 600;
  font-size: 13px;
  padding: 0 0 8px;
  text-align: left;
}

.field-permissions-group .field-permissions-field-name::before {
  display: none;
}

.field-permissions-group .access-segment {
  flex-shrink: 0;
}

#view-field-permissions .section-card {
  padding: 14px 16px;
}

#view-field-permissions .section-header {
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 10px;
}

#view-field-permissions .section-header .section-title {
  font-size: 12px;
}

#view-field-permissions .field-permissions-group-bulk {
  gap: 6px;
}

#view-field-permissions .field-permissions-group-bulk-role {
  min-width: 72px;
}

#view-field-permissions .field-permissions-table td:not(.field-permissions-section-name) {
  text-align: left;
}

#view-field-permissions .field-permissions-group .field-permissions-table td {
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  text-align: left;
}

#view-field-permissions .field-permissions-group .field-permissions-table td::before {
  flex: 0 0 86px;
}

#view-field-permissions .field-permissions-group .access-segment {
  margin-left: auto;
}

.section-header .field-permissions-group-bulk {
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
}

.field-permissions-group-bulk,
.field-permissions-global-bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.field-permissions-global-bulk {
  padding: 14px 20px;
  margin-bottom: 16px;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Kanban card fields settings */
.kanban-card-fields-container {
  margin-top: 16px;
}

.kanban-card-fields-hint {
  margin: 0;
  font-size: 13px;
}

.kanban-card-fields-container .section-card {
  padding: 14px 16px;
}

.kanban-card-fields-container .section-header {
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.kanban-fields-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  min-width: 0;
}

.kanban-fields-toggle:hover {
  background: var(--color-row-hover);
  border-color: var(--color-border);
}

.kanban-fields-toggle input {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

.kanban-fields-toggle span {
  font-size: 13px;
  line-height: 1.35;
  color: var(--color-text);
}

.kanban-fields-toggle-section {
  background: var(--color-bg);
  border-color: var(--color-border);
}

.field-permissions-global-label,
.field-permissions-group-bulk-role {
  font-size: 12px;
  color: var(--color-text-muted);
}

.field-permissions-role-col {
  min-width: 160px;
}

.field-permissions-role-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.field-permissions-bulk {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.btn-xs {
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.4;
}

.access-segment {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-surface);
}

.access-segment-option {
  margin: 0;
  cursor: pointer;
}

.access-segment-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.access-segment-option span {
  display: block;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.access-segment-option input:checked + span {
  background: var(--color-primary);
  color: #fff;
}

.access-segment--3 .access-segment-option span {
  padding: 6px 8px;
  font-size: 11px;
}

.access-segment-option:not(:last-child) span {
  border-right: 1px solid var(--color-border);
}

/* Stage bar — карточка рекламации */
.stage-bar {
  margin-bottom: 16px;
  padding: 6px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-row-hover);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.stage-bar::-webkit-scrollbar {
  height: 4px;
}

.stage-bar::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 999px;
}

.stage-bar-inner {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: min(100%, max-content);
}

.stage-bar-work {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.stage-bar-work--full {
  width: 100%;
}

.stage-bar-segment {
  display: flex;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
}

.stage-bar-connector {
  flex: 1 1 20px;
  min-width: 10px;
  max-width: 56px;
  height: 2px;
  margin: 0 2px;
  border-radius: 1px;
  background: var(--color-border);
}

.stage-bar-segment:has(.stage-step--done) .stage-bar-connector {
  background: var(--color-primary-light);
}

.stage-bar-segment:has(.stage-step--current) .stage-bar-connector {
  background: var(--color-primary);
}

.stage-bar-fork {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 6px;
  padding: 0 6px;
  align-self: center;
}

.stage-bar-fork::before,
.stage-bar-fork::after {
  content: '';
  width: 1px;
  height: 18px;
  background: var(--color-border);
  flex-shrink: 0;
}

.stage-fork-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  user-select: none;
  white-space: nowrap;
}

.stage-bar-finals {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.stage-bar-finals .stage-bar-segment {
  flex: 1 1 0;
  min-width: 0;
}

.stage-step {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 4px 10px 4px 6px;
  gap: 7px;
  text-align: left;
  font-size: 12px;
  line-height: 1.25;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  border: 1px solid var(--color-border);
  font-weight: 600;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.stage-step-marker {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.stage-step-marker--pending {
  border: 1.5px solid var(--color-border);
  color: var(--color-text-muted);
  background: var(--color-surface);
}

.stage-step-marker--current {
  background: #fff;
  color: var(--color-navy-900);
}

.stage-step-marker--done {
  background: currentColor;
  color: #fff;
  font-size: 11px;
}

.stage-step-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-step--pending {
  background: var(--color-surface);
  color: var(--color-text-muted);
  border-color: var(--color-border);
  font-weight: 500;
}

.stage-step--pending:hover:not(:disabled) {
  border-color: var(--color-primary-light);
  background: var(--color-primary-subtle);
}

.stage-step--current {
  border-width: 2px;
  font-weight: 700;
  z-index: 1;
}

.stage-step--done {
  font-weight: 600;
}

.stage-step--done:hover:not(:disabled),
.stage-step--current:hover:not(:disabled) {
  filter: brightness(1.02);
}

.stage-step:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* Settings — stage colors */
.stages-settings-board {
  display: flex;
  gap: 8px;
  align-items: stretch;
  padding: 16px;
  overflow-x: auto;
}

.stages-settings-work {
  display: flex;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.stages-settings-finals {
  display: flex;
  gap: 4px;
  align-items: stretch;
  flex-shrink: 0;
}

.stages-settings-board .kanban-column {
  flex: 1;
  min-width: 200px;
  max-width: 280px;
  max-height: none;
}

.stages-settings-board .kanban-column-body {
  min-height: 180px;
  padding: 12px;
}

.stages-settings-group {
  font-size: 12px;
  color: var(--color-text-muted);
  margin: 0 0 12px;
}

.stages-settings-color-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.stages-settings-sample {
  margin-top: 12px;
  cursor: default;
  pointer-events: none;
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-color-input {
  width: 40px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  background: var(--color-surface);
}

.stage-color-text {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

.stage-color-light-swatch {
  display: inline-block;
  width: 40px;
  height: 32px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  vertical-align: middle;
}

.stage-kanban-preview {
  display: inline-block;
  min-width: 120px;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.stage-kanban-preview-card {
  padding: 6px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.success-msg {
  color: var(--color-success);
  font-size: 13px;
  font-weight: 500;
}

.form-feedback {
  margin-top: 12px;
}

.app-toast {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 2200;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  box-shadow: var(--shadow-elevated);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.app-toast--success {
  background: #fff;
  color: var(--color-success);
  border-color: color-mix(in srgb, var(--color-success) 35%, #ffffff);
}

.app-toast--error {
  background: #fff;
  color: var(--color-danger);
  border-color: color-mix(in srgb, var(--color-danger) 35%, #ffffff);
}

/* Files */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.file-thumb {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
}

.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-thumb .file-name {
  font-size: 10px;
  padding: 4px;
  word-break: break-all;
  color: var(--color-text-muted);
}

.file-thumb .btn-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
}

.file-upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

.file-upload-btn {
  position: relative;
  margin: 0;
  cursor: pointer;
}

.file-upload-btn .file-input {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.file-upload-hint {
  flex: 1 1 100%;
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.file-grid--video {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.file-video {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #0f1118;
}

.file-video-preview {
  position: relative;
  aspect-ratio: 16 / 9;
  cursor: pointer;
  background: #000;
}

.file-video-el {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.file-video-play-btn {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 3px;
}

.file-video-duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.file-video-meta {
  padding: 6px 8px;
  background: var(--color-surface);
}

.file-video-meta .file-name {
  font-size: 11px;
  word-break: break-all;
  color: var(--color-text);
}

.file-video-meta .file-size {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.file-video .btn-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
}

.file-upload-progress {
  grid-column: 1 / -1;
  margin-top: 4px;
}

.file-upload-progress-bar {
  height: 4px;
  width: 0;
  border-radius: 2px;
  background: var(--color-primary);
  transition: width 0.15s ease;
}

.file-upload-progress-text {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.video-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.video-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.video-modal-dialog {
  position: relative;
  width: min(96vw, 900px);
  max-height: 90vh;
  z-index: 1;
}

.video-modal-player {
  width: 100%;
  max-height: 90vh;
  border-radius: var(--radius-sm);
  background: #000;
}

.video-modal-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

body.video-modal-open {
  overflow: hidden;
}

.file-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-link);
  text-decoration: none;
  font-weight: 500;
}

.file-link:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 29, 66, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-modal);
  padding: 24px;
  width: min(480px, calc(100vw - 32px));
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-navy-900);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-reclamation,
.modal-entity {
  --reclamation-modal-pad-x: 16px;
  --entity-modal-pad-x: 16px;
  --rc-card-pad-x: 16px;
  --rc-card-pad-y: 14px;
  --rc-gap-sections: 16px;
  --rc-gap-fields: 12px;
  --rc-gap-fields-col: 20px;
  --rc-gap-header: 10px;
  --rc-field-divider-pad: 12px;
  width: min(var(--reclamation-modal-width-max), calc(100vw - 2 * var(--reclamation-modal-gap)));
  max-width: 100%;
  height: min(var(--reclamation-modal-height-max), calc(100dvh - 2 * var(--reclamation-modal-gap)));
  max-height: min(var(--reclamation-modal-height-max), calc(100dvh - 2 * var(--reclamation-modal-gap)));
  min-height: min(600px, calc(100dvh - 2 * var(--reclamation-modal-gap) - 80px));
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

#reclamation-card-modal.modal-overlay {
  padding: var(--reclamation-modal-gap);
  align-items: center;
  justify-content: center;
}

.reclamation-modal-header {
  flex-shrink: 0;
  padding: 14px calc(var(--reclamation-modal-pad-x) + 44px) 12px var(--reclamation-modal-pad-x);
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.reclamation-modal-header .stage-bar {
  margin-top: var(--rc-gap-header);
  margin-bottom: 0;
}

.reclamation-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--rc-gap-sections) var(--reclamation-modal-pad-x) 20px;
  -webkit-overflow-scrolling: touch;
}

.btn-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.btn-modal-close:hover {
  background: var(--color-primary-subtle);
  color: var(--color-navy-900);
  border-color: var(--color-primary-light);
}

.btn-modal-close:focus-visible {
  outline: 2px solid var(--color-primary-ring);
  outline-offset: 2px;
}

body.reclamation-modal-open {
  overflow: hidden;
}

#reclamation-card-modal .card-header-row--reclamation {
  margin-bottom: 0;
  box-shadow: none;
  padding: 10px 12px;
  gap: 12px;
}

#reclamation-card-modal .card-header-row--reclamation .page-title {
  padding-right: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.role-checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 16px;
  font-size: 14px;
  color: var(--color-text);
}

.error-msg {
  color: var(--color-danger);
  font-size: 13px;
  margin-top: 8px;
}

.back-link {
  color: var(--color-link);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
  display: inline-block;
}

.back-link:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

.back-link-prominent {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--color-primary) 45%, #ffffff);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(47, 85, 200, 0.28);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), filter var(--transition-fast);
}

.back-link-prominent:hover {
  color: #fff;
  text-decoration: none;
  filter: brightness(1.03);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(47, 85, 200, 0.32);
}

.back-link-prominent:focus-visible {
  outline: 3px solid var(--color-primary-ring);
  outline-offset: 2px;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  background: var(--color-surface);
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
}

.card-header-row .page-title {
  margin: 0;
}

.reclamation-card-top {
  margin-bottom: 16px;
}

.reclamation-context-banner {
  background: linear-gradient(135deg, rgba(47, 85, 200, 0.16) 0%, rgba(59, 168, 232, 0.2) 100%);
  border: 1px solid rgba(47, 85, 200, 0.28);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.reclamation-context-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.reclamation-context-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.reclamation-context-kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-navy-900);
}

.reclamation-context-hint {
  margin: 0;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
}

.card-header-row--reclamation {
  border-width: 2px;
  border-color: color-mix(in srgb, var(--color-primary) 24%, var(--color-border));
}

.card-header-row--reclamation .page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-navy-900);
}

/* Reclamation card — section panels layout & typography */
#reclamation-card-modal #reclamation-card-container {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--rc-gap-sections);
}

#reclamation-card-modal #reclamation-card-container .section-card {
  padding: var(--rc-card-pad-y) var(--rc-card-pad-x);
  min-width: 0;
  overflow: hidden;
}

#reclamation-card-modal .section-header {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: var(--rc-gap-fields);
  padding-bottom: var(--rc-gap-fields);
}

#reclamation-card-modal .section-header .section-title {
  flex: 1 1 8rem;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

#reclamation-card-modal .section-header > .btn-edit-section {
  flex: 0 0 auto;
  width: auto;
  min-height: 36px;
  white-space: nowrap;
}

#reclamation-card-modal .section-header .section-actions {
  width: 100%;
  flex-basis: 100%;
  gap: 8px;
}

#reclamation-card-modal .section-header .section-actions .btn {
  flex: 1;
  min-width: 0;
  min-height: 40px;
}

#reclamation-card-modal .field-grid {
  gap: var(--rc-gap-fields) var(--rc-gap-fields-col);
  min-width: 0;
  max-width: 100%;
}

#reclamation-card-modal .field-grid .field,
#reclamation-card-modal .field-grid .field-view {
  margin-bottom: 0;
  min-width: 0;
}

#reclamation-card-modal .section-fields-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#reclamation-card-modal .section-fields-stack > .field-view:not(:last-child),
#reclamation-card-modal .section-fields-stack > .field-row:not(:last-child),
#reclamation-card-modal .section-fields-stack > .field:not(:last-child) {
  margin-bottom: var(--rc-field-divider-pad);
  padding-bottom: var(--rc-field-divider-pad);
  border-bottom: 1px solid var(--color-border);
}

#reclamation-card-modal .section-fields-stack > .field {
  margin-bottom: 0;
}

#reclamation-card-modal .field-view {
  min-width: 0;
}

#reclamation-card-modal .field-view .field-label,
#reclamation-card-modal .field label {
  overflow-wrap: anywhere;
  line-height: 1.35;
  margin-bottom: 4px;
}

#reclamation-card-modal .field-view .field-value {
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
  margin-bottom: 0;
  min-width: 0;
}

#reclamation-card-modal .field-value-editable {
  margin-left: 0;
  margin-right: 0;
  padding: 4px 0;
  max-width: 100%;
}

#reclamation-card-modal .field-value .file-grid,
#reclamation-card-modal .field-view > .file-grid {
  margin-top: 4px;
}

#reclamation-card-modal .file-grid,
#reclamation-card-modal .field-grid {
  min-width: 0;
  max-width: 100%;
}

#reclamation-card-modal .field input,
#reclamation-card-modal .field select,
#reclamation-card-modal .field textarea {
  max-width: 100%;
}

#reclamation-card-modal .field-row {
  gap: var(--rc-gap-fields);
  min-width: 0;
}

#reclamation-card-modal .field-row .field {
  margin-bottom: 0;
  min-width: 0;
}

#reclamation-card-modal .address-input-wrap {
  max-width: 100%;
}

#reclamation-card-modal .card-header-row--reclamation .page-title {
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.25;
}

#reclamation-card-modal .reclamation-robot-runs {
  margin-top: var(--rc-gap-sections);
  padding: var(--rc-card-pad-y) var(--rc-card-pad-x);
  min-width: 0;
  overflow: hidden;
}

#reclamation-card-modal .reclamation-robot-runs .section-title {
  margin: 0 0 var(--rc-gap-fields);
}

#reclamation-card-modal .reclamation-context-hint {
  overflow-wrap: anywhere;
  line-height: 1.45;
}

@media (min-width: 1400px) {
  :root {
    --reclamation-modal-width-max: 1440px;
    --reclamation-modal-gap: 28px;
  }
}

@media (max-width: 1100px) {
  #reclamation-card-modal #reclamation-card-container {
    grid-template-columns: 1fr;
    gap: var(--rc-gap-fields);
  }
}

@media (min-width: 769px) and (max-width: 1100px) {
  #reclamation-card-modal .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--rc-gap-fields) var(--rc-gap-fields-col);
  }

  #reclamation-card-modal .field-grid .field-full {
    grid-column: 1 / -1;
  }
}

/* Address picker */
.address-input-wrap {
  position: relative;
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.address-input-wrap input {
  flex: 1;
  min-width: 0;
}

.btn-address-map {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-link);
  cursor: pointer;
}

.btn-address-map:hover {
  background: var(--color-primary-subtle);
  border-color: var(--color-primary-light);
  color: var(--color-primary-hover);
}

.address-suggest {
  position: absolute;
  left: 0;
  right: 44px;
  top: calc(100% + 2px);
  z-index: 50;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  max-height: 220px;
  overflow-y: auto;
}

.address-suggest-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
  cursor: pointer;
}

.address-suggest-item:hover,
.address-suggest-item.active {
  background: var(--color-row-hover);
}

.modal-map {
  width: min(720px, 92vw);
}

.map-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.map-search-row {
  position: relative;
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.map-search-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
}

.map-search-row input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.address-map-suggest {
  left: 0;
  right: 0;
  top: calc(100% + 2px);
}

.address-map {
  height: 380px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  z-index: 0;
}

.address-map-label {
  margin-top: 10px;
  font-size: 13px;
  color: var(--color-text);
  min-height: 1.4em;
}

.kanban-board,
.kanban-column-body,
.table-responsive {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.kanban-board::-webkit-scrollbar,
.kanban-column-body::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.kanban-board::-webkit-scrollbar-thumb,
.kanban-column-body::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

.kanban-board::-webkit-scrollbar-thumb:hover,
.kanban-column-body::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

.kanban-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.kanban-column {
  flex: 0 0 240px;
  background: var(--color-surface);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--color-border);
  border-bottom: none;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  min-height: 0;
  align-self: stretch;
  overflow: hidden;
}

.kanban-column-header {
  padding: 12px 14px;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  border-radius: var(--radius) var(--radius) 0 0;
}

.kanban-column-header-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}

.kanban-column-cost {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  opacity: 0.9;
}

.kanban-column-title {
  line-height: 1.3;
}

.kanban-column-count {
  flex-shrink: 0;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: color-mix(in srgb, currentColor 14%, transparent);
  color: inherit;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.kanban-board .kanban-column-body {
  display: flex;
  flex-direction: column;
  padding: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  transition: background 0.15s;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* «Бесконечная» область: заполняет пустую колонку; при переполнении — уходит ниже последней карточки */
.kanban-board .kanban-column-body::after {
  content: '';
  display: block;
  flex: 1 0 auto;
  min-height: 0;
}

.kanban-board .kanban-column-body--overflow::after {
  min-height: 100vh;
}

.kanban-column-body.drag-over {
  outline: 2px dashed var(--color-primary-light);
  outline-offset: -2px;
  border-radius: 0 0 var(--radius) var(--radius);
}

.kanban-column-body.drag-forbidden {
  outline: 2px dashed var(--color-danger, #c0392b);
  outline-offset: -2px;
  border-radius: 0 0 var(--radius) var(--radius);
  opacity: 0.6;
}

.kanban-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: grab;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.kanban-card:hover {
  border-color: var(--color-primary-light);
  box-shadow: 0 2px 8px rgba(47, 85, 200, 0.12);
}

.kanban-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.kanban-card-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  line-height: 1.3;
  word-break: break-word;
}

.kanban-card-head {
  font-size: 12px;
  color: var(--color-text-muted);
}

.kanban-card-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  line-height: 1.35;
}

.kanban-card-head-row + .kanban-card-head-row {
  margin-top: 3px;
}

.kanban-card-id {
  font-weight: 600;
  color: var(--color-text);
  flex-shrink: 0;
}

.kanban-card-head-sep {
  color: var(--color-border);
  flex-shrink: 0;
}

.kanban-card-head-item {
  min-width: 0;
}

.kanban-card-field {
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
  word-break: break-word;
}

.kanban-card-field-label {
  color: var(--color-text);
  font-weight: 600;
}

.kanban-card-divider {
  height: 1px;
  margin: 6px 0 2px;
  background: color-mix(in srgb, var(--color-border) 55%, var(--color-primary-subtle));
  border: none;
}

.kanban-file-preview-list {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.kanban-file-thumb-link {
  display: inline-flex;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.kanban-file-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.kanban-file-doc-link {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  text-decoration: none;
  font-size: 18px;
}

.kanban-file-video-link {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #0f1118;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
}

.kanban-file-empty {
  margin-top: 4px;
  color: var(--color-text-muted);
  font-style: italic;
}

.kanban-card-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 6px 12px;
}

/* ── Responsive ── */

@media (max-width: 1024px) {
  .app-content { padding: 16px; }

  .kanban-column {
    flex: 0 0 220px;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 52px;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .btn-menu-toggle {
    display: inline-flex;
  }

  .app-header-brand {
    display: flex;
  }

  .app-header {
    padding: 0 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  #header-user-name {
    max-width: 120px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1100;
    width: min(var(--sidebar-width), 85vw);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

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

  .login-page {
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .login-card {
    width: 100%;
    max-width: 360px;
    padding: 24px 20px;
  }

  .app-content:has(#view-kanban:not(.hidden)),
  .app-content:has(#view-orders-kanban:not(.hidden)) {
    padding-bottom: 0;
  }

  .app-content {
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .page-title {
    font-size: 20px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
  }

  .toolbar-quick-filter {
    max-width: none;
    width: 100%;
  }

  .toolbar .btn {
    width: 100%;
  }

  .card-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .card-header-row .btn {
    width: 100%;
  }

  .reclamation-context-main {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .back-link-prominent {
    width: 100%;
  }

  #reclamation-card-modal #reclamation-card-container .section-card {
    padding: var(--rc-card-pad-y) var(--rc-card-pad-x);
  }

  #reclamation-card-modal .card-header-row--reclamation .page-title {
    font-size: 20px;
  }

  #reclamation-card-modal .reclamation-context-banner {
    padding: 12px 14px;
  }

  #reclamation-card-modal .section-header > .btn-edit-section {
    flex: 0 0 auto;
    width: auto;
  }

  .section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .section-header > div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .section-header .btn {
    flex: 1;
    min-width: 0;
  }

  .section-header .field-permissions-group-bulk {
    width: 100%;
    justify-content: flex-start;
  }

  #view-field-permissions .field-permissions-group .field-permissions-table td::before {
    flex-basis: 72px;
  }

  .field-permissions-global-bulk {
    padding: 12px 16px;
  }

  .kanban-card-fields-container .section-card {
    padding: 12px;
  }

  .kanban-card-fields-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .mail-account-grid {
    grid-template-columns: 1fr;
  }

  .field-row,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .stage-bar {
    padding: 5px 6px;
    margin-bottom: 10px;
  }

  .stage-bar-inner {
    min-width: max-content;
  }

  .stage-bar-segment {
    flex: 0 1 auto;
    min-width: 88px;
  }

  .stage-step {
    min-height: 32px;
    padding: 3px 8px 3px 5px;
    font-size: 11px;
    gap: 6px;
  }

  .stage-step-marker {
    width: 16px;
    height: 16px;
    font-size: 9px;
  }

  .stage-step-marker--done {
    font-size: 10px;
  }

  .stages-settings-board {
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  .stages-settings-work {
    flex-wrap: wrap;
  }

  .stages-settings-finals {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .stages-settings-board .kanban-column {
    flex: 1 1 100%;
    max-width: none;
  }

  .modal-overlay {
    padding: 16px;
    align-items: flex-end;
  }

  #reclamation-card-modal.modal-overlay {
    --reclamation-modal-gap: 0px;
    --reclamation-modal-pad-x: 14px;
    --rc-card-pad-x: 14px;
    --rc-card-pad-y: 12px;
    --rc-gap-sections: 12px;
    --rc-gap-fields: 10px;
    --rc-gap-fields-col: 14px;
    --rc-field-divider-pad: 10px;
    padding: max(6px, env(safe-area-inset-top, 0px)) 0 0;
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-height: 85vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  #reclamation-card-modal .modal-reclamation {
    width: 100%;
    height: calc(100dvh - max(6px, env(safe-area-inset-top, 0px)));
    max-height: calc(100dvh - max(6px, env(safe-area-inset-top, 0px)));
    min-height: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
  }

  .reclamation-modal-header {
    padding: 12px 44px 10px var(--reclamation-modal-pad-x);
  }

  .reclamation-modal-body {
    padding: var(--rc-gap-sections) var(--reclamation-modal-pad-x) max(16px, env(safe-area-inset-bottom, 0px));
  }

  #reclamation-card-modal .card-header-row--reclamation {
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 10px;
  }

  #reclamation-card-modal .card-header-row--reclamation .btn {
    flex: 1 1 auto;
    min-width: 120px;
  }

  #reclamation-card-modal .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
  }

  #reclamation-card-modal .file-grid--video {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  #reclamation-card-modal .section-fields-stack > .field-row {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .color-picker-row {
    flex-wrap: wrap;
  }

  .kanban-column {
    flex: 0 0 260px;
  }

  /* Таблицы → карточки */
  .table-responsive {
    overflow: visible;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody tr {
    display: block;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
  }

  .data-table tbody tr:last-child {
    border-bottom: none;
  }

  .data-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: none;
    text-align: right;
  }

  .data-table td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    text-align: left;
    flex-shrink: 0;
    max-width: 45%;
  }

  .data-table td[data-label=""]::before,
  .data-table td:not([data-label])::before {
    display: none;
  }

  .data-table td.cell-actions {
    justify-content: flex-end;
    padding-top: 10px;
  }

  .data-table td.cell-actions::before {
    display: none;
  }

  .data-table td.cell-actions .btn {
    min-height: 36px;
  }

  .address-map {
    height: 280px;
  }

  .data-table td .color-picker-row {
    flex: 1;
    justify-content: flex-end;
  }

  .data-table td[data-label="Цвет"] {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .app-header-end .btn-secondary {
    padding: 8px 12px;
    font-size: 13px;
  }

  #header-user-name {
    display: none;
  }

  #reclamation-card-modal.modal-overlay {
    --reclamation-modal-pad-x: 12px;
    --rc-card-pad-x: 12px;
    --rc-card-pad-y: 10px;
    --rc-gap-sections: 10px;
    --rc-gap-fields: 8px;
    --rc-gap-fields-col: 12px;
    --rc-field-divider-pad: 8px;
  }

  #reclamation-card-modal #reclamation-card-container .section-card {
    padding: var(--rc-card-pad-y) var(--rc-card-pad-x);
  }

  #reclamation-card-modal .section-header {
    gap: 8px;
    margin-bottom: var(--rc-gap-fields);
    padding-bottom: var(--rc-gap-fields);
  }

  #reclamation-card-modal .section-header > .btn-edit-section {
    min-height: 44px;
    padding-left: 14px;
    padding-right: 14px;
  }

  #reclamation-card-modal .section-header .section-actions .btn {
    min-height: 44px;
  }

  #reclamation-card-modal .card-header-row--reclamation {
    padding: 8px;
  }

  #reclamation-card-modal .card-header-row--reclamation .page-title {
    font-size: 18px;
  }

  #reclamation-card-modal .field-grid {
    gap: var(--rc-gap-fields) var(--rc-gap-fields-col);
  }

  #reclamation-card-modal .file-upload-actions {
    flex-direction: column;
  }

  #reclamation-card-modal .file-upload-btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  #reclamation-card-modal .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
  }

  #reclamation-card-modal .file-grid--video {
    grid-template-columns: 1fr;
  }

  #reclamation-card-modal .reclamation-modal-header .stage-bar {
    margin-top: 8px;
  }

  #reclamation-card-modal .section-fields-stack > .field-row {
    grid-template-columns: 1fr;
  }

  .file-upload-actions--video {
    flex-direction: column;
  }

  .file-upload-btn--video {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .video-modal-dialog {
    width: 100vw;
    max-height: 100vh;
    padding: 0 8px;
  }

  .video-modal-player {
    max-height: 80vh;
  }

  .video-modal-close {
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.5);
  }

  .stage-bar-segment {
    min-width: 72px;
  }

  .stage-step {
    min-height: 30px;
  }

  .kanban-column {
    flex: 0 0 calc(100vw - 48px);
  }

  .role-checkboxes label {
    display: flex;
    margin-right: 0;
    margin-bottom: 8px;
  }
}

@media (min-width: 769px) {
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.automation-robots-toolbar {
  padding: 16px 20px;
  margin-bottom: 16px;
}

.automation-robots-hint {
  margin: 0 0 16px;
  font-size: 13px;
}

#automation-robots-list {
  overflow: hidden;
  padding: 12px;
}

.automation-robots-table {
  margin: 0;
}

.automation-robots-table .btn-sm,
.automation-robot-card .btn-sm {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
}

.automation-robots-order {
  white-space: nowrap;
}

.automation-robots-actions {
  white-space: nowrap;
}

.automation-role-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.automation-role-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.automation-recipient-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.automation-recipient-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.automation-recipient-option:hover {
  border-color: var(--color-primary-light);
  background: var(--color-surface-alt, #f8f9fc);
}

.automation-recipient-option:has(input:checked) {
  border-color: var(--color-primary);
  background: rgba(47, 85, 200, 0.06);
}

.automation-recipient-option input {
  margin-top: 2px;
  flex: 0 0 auto;
}

.automation-recipient-option-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.automation-recipient-option-label {
  font-weight: 500;
  line-height: 1.3;
}

.automation-recipient-option-meta {
  font-size: 12px;
}

.automation-recipients-hint {
  margin: 0 0 16px;
  font-size: 13px;
}

.automation-recipients-subhint {
  margin: 4px 0 10px;
  font-size: 12px;
}

.automation-recipient-group + .automation-recipient-group {
  margin-top: 12px;
}

.automation-recipient-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.automation-field-type-tag {
  font-size: 11px;
}

.automation-recipients-empty {
  margin: 0;
  font-size: 13px;
}

.automation-robot-toggle input {
  width: auto;
}

.automation-robots-table td[data-label="Вкл"] {
  text-align: center;
}

.automation-robots-table td[data-label="Вкл"]::before {
  text-align: left;
}

.automation-robots-board {
  min-height: 280px;
}

.automation-robot-card {
  cursor: grab;
}

.kanban-card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.kanban-card-title-row .kanban-card-title {
  margin-bottom: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.automation-robot-status-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.2;
  white-space: nowrap;
}

.automation-robot-status-badge--on {
  color: var(--color-success);
  background: var(--color-success-bg);
  border: 1px solid rgba(31, 155, 98, 0.35);
}

.automation-robot-status-badge--off {
  color: var(--color-danger);
  background: var(--color-danger-bg);
  border: 1px solid rgba(212, 59, 59, 0.45);
}

.automation-robot-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.automation-robot-card-actions .btn {
  flex: 0 0 auto;
}

.reclamation-robot-runs .section-title {
  margin: 0 0 12px;
}

.robot-run-status--success {
  color: var(--color-success, #1a7f37);
}

.robot-run-status--error {
  color: var(--color-danger, #c62828);
}

.robot-run-status--skipped {
  color: var(--text-muted, #6b7280);
}

.modal-wide {
  max-width: 560px;
}

@media (max-width: 768px) {
  .automation-robots-toolbar {
    padding: 12px 16px;
  }

  .automation-robots-table td[data-label="Порядок"],
  .automation-robots-table td[data-label="Действия"] {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
  }

  .automation-robots-table td[data-label="Порядок"] .btn,
  .automation-robots-table td[data-label="Действия"] .btn {
    min-width: 96px;
  }

  .automation-robots-table td[data-label="Вкл"] {
    justify-content: space-between;
  }

  #automation-robots-list {
    padding: 8px;
  }

  .automation-robot-card-actions .btn {
    min-width: 110px;
  }
}

/* Entity list: stage folder tree */
.entity-list-layout {
  display: flex;
  align-items: stretch;
  gap: 16px;
  min-height: 0;
}

.entity-list-sidebar {
  flex: 0 0 280px;
  max-width: 320px;
  padding: 12px 10px;
  overflow: auto;
  align-self: flex-start;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 180px);
}

.entity-list-main {
  flex: 1 1 auto;
  min-width: 0;
}

.entity-list-sidebar-head {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 4px 10px;
}

.entity-list-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.entity-list-tree-node {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 2px 4px 2px calc(8px + var(--tree-depth, 0) * 14px);
  border-radius: 8px;
  transition: background 0.12s ease;
}

.entity-list-tree-node.is-selected {
  background: var(--color-row-hover);
}

.entity-list-tree-node.drag-over {
  outline: 2px dashed var(--color-primary);
  outline-offset: -2px;
  background: rgba(78, 85, 117, 0.08);
}

.entity-list-tree-node.drag-forbidden {
  outline: 2px dashed var(--color-danger);
  outline-offset: -2px;
  opacity: 0.75;
}

.entity-list-tree-toggle,
.entity-list-tree-toggle-spacer {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
}

.entity-list-tree-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  padding: 0;
}

.entity-list-tree-toggle::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 3px;
  border: 5px solid transparent;
  border-left-color: var(--text-muted);
  transform: rotate(0deg);
  transition: transform 0.12s ease;
}

.entity-list-tree-toggle.is-expanded::before {
  transform: rotate(90deg);
  top: 5px;
  left: 3px;
}

.entity-list-tree-label {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  padding: 4px 2px;
  font: inherit;
  color: inherit;
}

.entity-list-tree-stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--stage-color, #4E5575);
  flex-shrink: 0;
}

.entity-list-tree-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-list-tree-count {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 1.5em;
  text-align: right;
}

.entity-list-tree-actions {
  display: none;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.entity-list-tree-node:hover .entity-list-tree-actions,
.entity-list-tree-node.is-selected .entity-list-tree-actions {
  display: inline-flex;
}

.entity-list-tree-action {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0;
}

.entity-list-tree-action:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

.entity-list-tree-action--danger:hover {
  color: var(--color-danger);
}

.entity-list-tree-children {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.entity-list-row.dragging {
  opacity: 0.45;
}

@media (max-width: 900px) {
  .entity-list-layout {
    flex-direction: column;
  }

  .entity-list-sidebar {
    flex: none;
    width: 100%;
    max-width: none;
    position: static;
    max-height: none;
  }
}
