@import url('sok-tokens.css');

/* === Page layout === */
.crm-page,
.app-body {
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(245, 158, 11, 0.12), transparent),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-mid) 100%);
  min-height: 100vh;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.crm-page .text-gray-800,
.crm-page .text-gray-900,
.app-body .text-gray-800,
.app-body .text-gray-900 { color: var(--text) !important; }

.crm-page .text-gray-600,
.crm-page .text-gray-700,
.crm-page .text-gray-500,
.app-body .text-gray-600,
.app-body .text-gray-700,
.app-body .text-gray-500 { color: var(--text-muted) !important; }

.crm-text { color: var(--text); font-size: 0.875rem; }
.crm-text-muted { color: var(--text-muted); font-size: 0.875rem; }
.crm-text-accent { color: var(--accent); }

/* === Brand === */
.sok-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #0f172a;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 20px var(--accent-glow);
  flex-shrink: 0;
}

.sok-brand-title { font-weight: 700; color: var(--text); }
.sok-brand-accent { color: var(--accent); }

/* === Cards === */
.crm-card,
.app-header {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.app-header {
  position: relative;
  z-index: 30;
}

/* Карточка с фильтрами/меню «Действия» — выше sticky-шапки таблицы */
.crm-card:has(#filters-panel) {
  position: relative;
  z-index: 20;
}

.crm-card:hover,
.app-header:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.crm-section { margin-bottom: 1.5rem; }

.crm-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.crm-stat:hover {
  transform: translateY(-2px);
  border-color: rgba(245, 158, 11, 0.35);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.crm-stat--clickable { cursor: pointer; }
.crm-stat--clickable:active { transform: translateY(0); }

.crm-stat .crm-stat-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.crm-stat .crm-stat-value { font-size: 1.25rem; font-weight: 700; color: var(--text); }

.stat-cards .stat-card,
.stat-cards > div {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-cards .stat-card:hover,
.stat-cards > div:hover {
  transform: translateY(-2px);
  border-color: rgba(245, 158, 11, 0.35);
  box-shadow: 0 4px 20px var(--accent-glow);
}

/* === Controls === */
.crm-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.crm-input-clear-wrap {
  position: relative;
}

.crm-input--clearable {
  padding-right: 2.25rem;
}

.crm-input-clear {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.crm-input-clear:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.crm-input-clear.hidden {
  display: none;
}

.crm-input,
.crm-select,
.crm-page input[type="text"],
.crm-page input[type="tel"],
.crm-page input[type="number"],
.crm-page input[type="date"],
.crm-page input[type="password"],
.crm-page select,
.crm-page textarea,
.app-body input[type="text"],
.app-body input[type="tel"],
.app-body input[type="number"],
.app-body input[type="date"],
.app-body input[type="password"],
.app-body select,
.app-body textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.875rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.crm-input:focus,
.crm-select:focus,
.crm-page input:focus,
.crm-page select:focus,
.crm-page textarea:focus,
.app-body input:focus,
.app-body select:focus,
.app-body textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.crm-page select option,
.app-body select option {
  background: var(--bg-mid);
  color: var(--text);
}

.crm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.crm-btn:active { transform: scale(0.98); }

.crm-btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #0f172a;
  font-weight: 600;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.crm-btn-primary:hover {
  box-shadow: 0 4px 20px var(--accent-glow);
}

.crm-btn-ghost {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
}

.crm-btn-ghost:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.crm-btn-danger {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}

.crm-btn-danger:hover {
  background: rgba(248, 113, 113, 0.25);
}

.crm-btn-secondary {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.35);
  color: #93c5fd;
}

.crm-btn-sm { padding: 0.35rem 0.65rem; font-size: 0.75rem; }

.crm-alert-error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
}

.crm-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.crm-chip--success { background: rgba(52, 211, 153, 0.15); border-color: rgba(52, 211, 153, 0.4); color: var(--success); }
.crm-chip--error { background: rgba(248, 113, 113, 0.15); border-color: rgba(248, 113, 113, 0.4); color: var(--error); }
.crm-chip--muted { background: rgba(148, 163, 184, 0.12); border-color: var(--border); color: var(--text-muted); }

.crm-border-subtle { border-color: var(--border) !important; }

.crm-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--accent);
  cursor: default;
}

.crm-filter-chip button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0 0.15rem;
  line-height: 1;
  opacity: 0.8;
}

.crm-filter-chip button:hover { opacity: 1; }

.crm-call-attempt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  min-width: 5.5rem;
}

.crm-call-attempt--center {
  align-items: center;
}

.crm-call-attempt__controls {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.crm-call-attempt__btn,
.crm-call-attempt__reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.15));
  border-radius: 0.35rem;
  background: var(--surface-2, rgba(255, 255, 255, 0.04));
  color: inherit;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
}

.crm-call-attempt__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.crm-call-attempt__reset {
  width: 1.35rem;
  height: 1.35rem;
  font-size: 0.85rem;
  opacity: 0.75;
}

.crm-call-attempt__count {
  min-width: 1.25rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.crm-call-attempt__time {
  font-size: 0.68rem;
  line-height: 1.1;
  opacity: 0.75;
  white-space: nowrap;
}

#active-filter-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; min-height: 0; }
#active-filter-chips:not(:empty) { margin-top: 0.75rem; }

.crm-filters-panel.collapsed .crm-filters-body { display: none; }
.crm-filters-toggle { cursor: pointer; user-select: none; }
.crm-filters-toggle .fa-chevron-down { transition: transform 0.2s ease; }
.crm-filters-panel.collapsed .crm-filters-toggle .fa-chevron-down { transform: rotate(-90deg); }

.crm-accordion-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0.35rem 0;
  cursor: pointer;
  user-select: none;
  text-align: left;
}

.crm-accordion-body.hidden { display: none; }

.crm-accordion-chevron {
  transition: transform 0.2s ease;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.crm-accordion.collapsed .crm-accordion-chevron,
.crm-accordion-toggle[aria-expanded="false"] .crm-accordion-chevron {
  transform: rotate(-90deg);
}

.crm-ai-remarks-section ul { margin: 0; padding-left: 0; }

.crm-works-filter { position: relative; z-index: 25; }
.crm-works-filter.is-open { z-index: 45; }

.crm-works-filter-trigger {
  cursor: pointer;
  min-height: 2.5rem;
}

.crm-works-filter-trigger .fa-chevron-down {
  transition: transform 0.2s ease;
}

.crm-works-filter.is-open .crm-works-filter-trigger .fa-chevron-down {
  transform: rotate(180deg);
}

.crm-works-filter-dropdown {
  z-index: 50;
  min-width: 100%;
}

.crm-status-filter-dropdown {
  right: auto;
  min-width: 17.5rem;
  width: max-content;
  max-width: min(22rem, calc(100vw - 2rem));
}

.crm-status-filter-dropdown label {
  white-space: nowrap;
}

.crm-panel-light {
  color: #111827 !important;
}

.crm-panel-light .text-gray-900,
.crm-panel-light .text-gray-800,
.crm-panel-light .crm-panel-light-text {
  color: #111827 !important;
}

.crm-panel-light .text-gray-700 {
  color: #374151 !important;
}

.crm-panel-light .text-gray-600,
.crm-panel-light .text-gray-500 {
  color: #4b5563 !important;
}

.crm-panel-light label.text-green-700 {
  color: #15803d !important;
}

.crm-panel-light label.text-red-700 {
  color: #b91c1c !important;
}

.crm-panel-light .crm-input,
.crm-panel-light input[type="text"],
.crm-panel-light textarea {
  background: #fff !important;
  color: #111827 !important;
  border-color: #d1d5db !important;
}

.crm-panel-light .crm-input::placeholder,
.crm-panel-light input::placeholder,
.crm-panel-light textarea::placeholder {
  color: #9ca3af;
}

.crm-approval-panel {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--accent);
  color: var(--text);
}

.crm-approval-panel .crm-text,
.crm-approval-panel label,
.crm-approval-panel .crm-text-muted {
  color: var(--text) !important;
}

.crm-approval-panel .crm-text-accent {
  color: var(--accent) !important;
}

.crm-approval-panel .crm-input,
.crm-approval-panel input[type="number"],
.crm-approval-panel select {
  background: var(--bg-elevated) !important;
  color: var(--text) !important;
  border-color: var(--border-strong) !important;
}

.crm-approval-panel .crm-approval-work-select {
  flex: 1 1 8rem;
  min-width: 7rem;
  max-width: 11rem;
  width: auto !important;
}

.crm-approval-panel .crm-approval-qty-input {
  width: 4.25rem !important;
  min-width: 4.25rem !important;
  max-width: 4.25rem !important;
  padding-left: 0.35rem !important;
  padding-right: 0.35rem !important;
  text-align: center;
}

.crm-approval-panel .crm-approval-qty-group {
  flex-shrink: 0;
}

.crm-approval-sum-badge {
  display: inline-block;
  min-width: 5.5rem;
  padding: 0.2rem 0.5rem;
  border-radius: 0.375rem;
  background: rgba(245, 158, 11, 0.18);
  color: var(--accent) !important;
  font-size: 0.8125rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
}

.crm-table tbody tr.row-status-extra td,
.crm-table tbody tr.row-status-agreed td,
.crm-table tbody tr.row-status-work td,
#data-table tbody tr.row-status-extra td,
#data-table tbody tr.row-status-agreed td,
#data-table tbody tr.row-status-work td {
  color: var(--text);
}

.crm-table tbody tr.row-status-extra .crm-text,
#data-table tbody tr.row-status-extra .crm-text {
  color: var(--text) !important;
}

.crm-urgent-photo-thumb {
  position: relative;
  width: 4rem;
  height: 4rem;
  flex-shrink: 0;
}

.crm-urgent-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.375rem;
  border: 1px solid #fecdd3;
  cursor: pointer;
}

.crm-urgent-photo-delete {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.75rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}

.crm-works-filter-dropdown label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.35rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
}

.crm-works-filter-dropdown label:hover {
  background: rgba(255, 255, 255, 0.05);
}

.crm-works-filter-dropdown input[type="checkbox"] {
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* === Table === */
.crm-table-wrap,
.data-table-wrap {
  position: relative;
  z-index: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.crm-table-wrap .overflow-x-auto,
.data-table-wrap .overflow-x-auto {
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 158, 11, 0.3) transparent;
}

#data-table,
.crm-table {
  width: 100%;
  border-collapse: collapse;
}

#data-table thead th,
.crm-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

#data-table tbody tr,
.crm-table tbody tr {
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

#data-table tbody tr:nth-child(even),
.crm-table tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.02);
}

#data-table tbody tr:hover,
.crm-table tbody tr:hover {
  background-color: rgba(245, 158, 11, 0.06) !important;
  box-shadow: inset 3px 0 0 var(--accent);
}

#data-table tbody tr.row-needs-attention,
.crm-table tbody tr.row-needs-attention {
  background-color: var(--attention-bg) !important;
  box-shadow: inset 4px 0 0 var(--attention-border);
}

#data-table tbody tr.row-needs-attention:hover {
  background-color: rgba(245, 158, 11, 0.18) !important;
}

/* === Clickable copy (phone, contract, etc.) === */
.crm-copyable {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: inherit;
}

.crm-copyable:hover {
  text-decoration: underline;
  color: var(--accent, #2563eb);
}

.crm-table tbody tr.row-status-reject td .crm-copyable:hover,
#data-table tbody tr.row-status-reject td .crm-copyable:hover {
  color: var(--row-reject-text);
  filter: brightness(1.12);
}

/* === Row status tints === */
.crm-table tbody tr[class*="row-status-"],
#data-table tbody tr[class*="row-status-"] {
  border-left: 5px solid transparent;
}

.crm-table tbody tr.row-status-reject,
#data-table tbody tr.row-status-reject {
  background-color: var(--row-reject) !important;
  box-shadow: inset 5px 0 0 var(--row-reject-accent);
  border-left-color: var(--row-reject-accent);
}

.crm-table tbody tr.row-status-reject:hover,
#data-table tbody tr.row-status-reject:hover {
  background-color: var(--row-reject-hover) !important;
  box-shadow: inset 5px 0 0 var(--row-reject-accent);
}

.crm-table tbody tr.row-status-reject td,
#data-table tbody tr.row-status-reject td {
  color: var(--row-reject-text);
}

.crm-table tbody tr.row-status-reject td .crm-text-muted,
.crm-table tbody tr.row-status-reject td .status-pill,
#data-table tbody tr.row-status-reject td .crm-text-muted,
#data-table tbody tr.row-status-reject td .status-pill {
  opacity: 0.92;
}

.crm-table tbody tr.row-status-reject td select,
.crm-table tbody tr.row-status-reject td input,
#data-table tbody tr.row-status-reject td select,
#data-table tbody tr.row-status-reject td input {
  color: var(--row-reject-text);
}

.crm-table tbody tr.row-status-reject td a,
.crm-table tbody tr.row-status-reject td button,
#data-table tbody tr.row-status-reject td a,
#data-table tbody tr.row-status-reject td button {
  color: #b0bac9;
}

.crm-table tbody tr.row-status-call,
#data-table tbody tr.row-status-call {
  background-color: var(--row-call) !important;
  box-shadow: inset 5px 0 0 var(--row-call-accent);
  border-left-color: var(--row-call-accent);
}

.crm-table tbody tr.row-status-call:hover,
#data-table tbody tr.row-status-call:hover {
  background-color: var(--row-call-hover) !important;
  box-shadow: inset 5px 0 0 var(--row-call-accent);
}

.crm-table tbody tr.row-status-agreed,
#data-table tbody tr.row-status-agreed {
  background-color: var(--row-agreed) !important;
  box-shadow: inset 5px 0 0 var(--row-agreed-accent);
  border-left-color: var(--row-agreed-accent);
}

.crm-table tbody tr.row-status-agreed:hover,
#data-table tbody tr.row-status-agreed:hover {
  background-color: var(--row-agreed-hover) !important;
  box-shadow: inset 5px 0 0 var(--row-agreed-accent);
}

.crm-table tbody tr.row-status-extra,
#data-table tbody tr.row-status-extra {
  background-color: var(--row-extra) !important;
  box-shadow: inset 5px 0 0 var(--row-extra-accent);
  border-left-color: var(--row-extra-accent);
}

.crm-table tbody tr.row-status-extra:hover,
#data-table tbody tr.row-status-extra:hover {
  background-color: var(--row-extra-hover) !important;
  box-shadow: inset 5px 0 0 var(--row-extra-accent);
}

.crm-table tbody tr.row-status-transit,
#data-table tbody tr.row-status-transit {
  background-color: var(--row-transit) !important;
  box-shadow: inset 5px 0 0 var(--row-transit-accent);
  border-left-color: var(--row-transit-accent);
}

.crm-table tbody tr.row-status-transit:hover,
#data-table tbody tr.row-status-transit:hover {
  background-color: var(--row-transit-hover) !important;
  box-shadow: inset 5px 0 0 var(--row-transit-accent);
}

.crm-table tbody tr.row-status-work,
#data-table tbody tr.row-status-work {
  background-color: var(--row-work) !important;
  box-shadow: inset 5px 0 0 var(--row-work-accent);
  border-left-color: var(--row-work-accent);
}

.crm-table tbody tr.row-status-work:hover,
#data-table tbody tr.row-status-work:hover {
  background-color: var(--row-work-hover) !important;
  box-shadow: inset 5px 0 0 var(--row-work-accent);
}

.crm-table tbody tr.row-status-ready,
#data-table tbody tr.row-status-ready {
  background-color: var(--row-ready) !important;
  box-shadow: inset 5px 0 0 var(--row-ready-accent);
  border-left-color: var(--row-ready-accent);
}

.crm-table tbody tr.row-status-ready:hover,
#data-table tbody tr.row-status-ready:hover {
  background-color: var(--row-ready-hover) !important;
  box-shadow: inset 5px 0 0 var(--row-ready-accent);
}

.crm-table tbody tr.row-status-order-placed,
#data-table tbody tr.row-status-order-placed {
  background-color: var(--row-order-placed) !important;
  box-shadow: inset 5px 0 0 var(--row-order-placed-accent);
  border-left-color: var(--row-order-placed-accent);
}

.crm-table tbody tr.row-status-order-placed:hover,
#data-table tbody tr.row-status-order-placed:hover {
  background-color: var(--row-order-placed-hover) !important;
  box-shadow: inset 5px 0 0 var(--row-order-placed-accent);
}

.crm-table tbody tr.row-status-overdue,
#data-table tbody tr.row-status-overdue {
  background-color: var(--row-overdue) !important;
  box-shadow: inset 5px 0 0 var(--row-overdue-accent);
  border-left-color: var(--row-overdue-accent);
}

.crm-table tbody tr.row-status-overdue:hover,
#data-table tbody tr.row-status-overdue:hover {
  background-color: var(--row-overdue-hover) !important;
  box-shadow: inset 5px 0 0 var(--row-overdue-accent);
}

.crm-table tbody tr.row-status-queue,
#data-table tbody tr.row-status-queue {
  background-color: var(--row-queue) !important;
  box-shadow: inset 5px 0 0 var(--row-queue-accent);
  border-left-color: var(--row-queue-accent);
}

.crm-table tbody tr.row-status-queue:hover,
#data-table tbody tr.row-status-queue:hover {
  background-color: var(--row-queue-hover) !important;
  box-shadow: inset 5px 0 0 var(--row-queue-accent);
}

.crm-table tbody tr.row-status-neutral,
#data-table tbody tr.row-status-neutral {
  background-color: var(--row-neutral) !important;
  box-shadow: inset 5px 0 0 var(--row-neutral-accent);
  border-left-color: var(--row-neutral-accent);
}

.crm-table tbody tr.row-status-neutral:hover,
#data-table tbody tr.row-status-neutral:hover {
  background-color: var(--row-neutral-hover) !important;
  box-shadow: inset 5px 0 0 var(--row-neutral-accent);
}

#data-table tbody td,
.crm-table tbody td {
  color: var(--text);
}

.table-loading #table-body tr td {
  padding: 0.75rem 1.5rem;
}

.table-skeleton-cell {
  height: 1rem;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.works-cell-trigger {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
}

.works-cell-trigger:hover {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.08);
}

.works-cell-editor,
.crm-popover {
  z-index: 200;
  background: var(--bg-elevated);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  color: var(--text);
}

/* === Status pills (dark) === */
.status-pill {
  border-radius: 9999px;
  border-width: 1px;
  border-style: solid;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
  transition: box-shadow 0.15s ease, transform 0.15s ease, filter 0.15s ease;
}

.status-pill:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.status-pill:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.status-not-work { background: var(--status-not-work); color: #e2e8f0; border-color: rgba(148, 163, 184, 0.55); }
.status-sent { background: var(--status-sent); color: #ede9fe; border-color: rgba(167, 139, 250, 0.65); }
.status-call1 { background: var(--status-call1); color: #ccfbf1; border-color: rgba(45, 212, 191, 0.75); }
.status-call2 { background: var(--status-call2); color: #99f6e4; border-color: rgba(20, 184, 166, 0.8); }
.status-call3 { background: var(--status-call3); color: #5eead4; border-color: rgba(13, 148, 136, 0.85); }
.status-extra { background: var(--status-extra); color: #ffedd5; border-color: rgba(251, 146, 60, 0.7); }
.status-agreed { background: var(--status-agreed); color: #dcfce7; border-color: rgba(74, 222, 128, 0.7); }
.status-transit { background: var(--status-transit); color: #f3e8ff; border-color: rgba(192, 132, 252, 0.7); }
.status-reject { background: var(--status-reject); color: #fee2e2; border-color: rgba(248, 113, 113, 0.75); }
.status-work { background: var(--status-work); color: #fef9c3; border-color: rgba(250, 204, 21, 0.75); }
.status-ready { background: var(--status-ready); color: #d1fae5; border-color: rgba(52, 211, 153, 0.75); }
.status-order-placed { background: var(--status-order-placed); color: #ecfdf5; border-color: rgba(16, 185, 129, 0.8); }
.status-overdue { background: var(--status-overdue); color: #fecaca; border-color: rgba(239, 68, 68, 0.8); box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.25); }
.status-queue { background: var(--status-queue); color: #e0e7ff; border-color: rgba(129, 140, 248, 0.75); }
.status-no-decision { background: var(--status-no-decision); color: #fce7f3; border-color: rgba(244, 114, 182, 0.75); }
.status-default { background: rgba(148, 163, 184, 0.24); color: #e2e8f0; border-color: rgba(148, 163, 184, 0.55); }

.crm-badge-yes { background: rgba(52, 211, 153, 0.15); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.35); }
.crm-badge-no { background: rgba(148, 163, 184, 0.12); color: var(--text-muted); border: 1px solid var(--border); }

/* === Modals & toasts === */
.crm-modal-overlay.hidden {
  display: none !important;
}

.crm-modal-overlay,
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(7, 11, 20, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
  isolation: isolate;
}

body.crm-modal-open {
  overflow: hidden;
}

.crm-modal,
.modal-content {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
  color: #f8fafc;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  animation: scaleIn 0.2s ease;
}

.crm-modal .crm-card {
  background: #1a2332;
  border-color: rgba(255, 255, 255, 0.12);
}

.crm-modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0f172a;
  flex-shrink: 0;
}

.crm-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  background: #0f172a;
}

.crm-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  background: #0c1220;
  flex-shrink: 0;
}

.crm-modal .crm-table thead th {
  background: #1e293b;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.crm-modal .crm-table tbody tr {
  background-color: #0f172a;
}

.crm-modal .crm-table tbody tr:nth-child(even) {
  background-color: #131c31;
}

.crm-modal .crm-table tbody tr:hover {
  background-color: rgba(245, 158, 11, 0.12) !important;
  box-shadow: inset 3px 0 0 var(--accent);
}

.crm-modal .crm-table tbody td {
  background: inherit;
  color: #f8fafc;
}

.crm-toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: slideUp 0.25s ease;
  color: var(--text);
}

.crm-toast--success { background: rgba(52, 211, 153, 0.15); border-color: rgba(52, 211, 153, 0.4); }
.crm-toast--error { background: rgba(248, 113, 113, 0.15); border-color: rgba(248, 113, 113, 0.4); }
.crm-toast--info { background: var(--bg-elevated); border-color: var(--border-strong); }

.crm-dropdown {
  z-index: 50;
  background: var(--bg-elevated);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.crm-notification-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.5rem;
  width: min(24rem, calc(100vw - 2rem));
  z-index: 50;
}

.crm-notification-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease;
}

.crm-notification-item:last-child {
  border-bottom: none;
}

.crm-notification-item:hover {
  background: var(--bg-card-hover);
}

.crm-notification-item__title {
  font-weight: 600;
  color: var(--text);
}

.crm-notification-item__subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.crm-notification-item__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.crm-notification-badge {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.crm-notification-badge--call {
  background: rgba(52, 211, 153, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.crm-notification-badge--agreement {
  background: rgba(96, 165, 250, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.35);
}

.photo-section-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.photo-wheel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.photo-wheel-tab {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.photo-wheel-tab:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.photo-wheel-tab.is-active {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.45);
  color: var(--accent);
  font-weight: 600;
}

.photo-wheel-panel {
  display: none;
}

.photo-wheel-panel.is-active {
  display: block;
}

.crm-bulk-panel {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
}

.crm-pagination-bar {
  background: var(--bg-elevated) !important;
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border) !important;
  color: var(--text-muted);
}

.crm-pagination-bar .font-semibold { color: var(--text) !important; }

/* === Analytics deadline block === */
.crm-deadline-card {
  background: var(--bg-card);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius);
}

/* === Animations === */
.toast-enter { animation: slideUp 0.25s ease; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bellPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

#pending-calls-count:not(.hidden),
#pending-agreements-count:not(.hidden) {
  animation: bellPulse 2s ease-in-out infinite;
  background: var(--accent) !important;
  color: #0f172a !important;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field-warning-yellow { color: var(--accent); }
.field-warning-red { color: var(--error); }

.cell-warning-yellow {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  background: rgba(245, 158, 11, 0.12);
}

.cell-warning-red {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  background: rgba(248, 113, 113, 0.12);
}

#filter-order-fields-row:not(.hidden) { animation: fadeIn 0.2s ease; }

/* Override light Tailwind surfaces inside CRM */
.crm-page .bg-white,
.app-body .bg-white { background: var(--bg-card) !important; }

.crm-page .bg-gray-50,
.crm-page .bg-gray-100,
.app-body .bg-gray-50,
.app-body .bg-gray-100 { background: var(--bg-card) !important; }

.crm-page .bg-blue-50,
.crm-page .bg-green-50,
.crm-page .bg-amber-50,
.crm-page .bg-orange-50,
.crm-page .bg-red-50,
.crm-page .bg-purple-50,
.app-body .bg-blue-50,
.app-body .bg-green-50,
.app-body .bg-amber-50,
.app-body .bg-orange-50,
.app-body .bg-red-50,
.app-body .bg-purple-50 {
  background: rgba(255, 255, 255, 0.04) !important;
}

.crm-page .border-gray-200,
.crm-page .border-gray-300,
.app-body .border-gray-200,
.app-body .border-gray-300 { border-color: var(--border) !important; }

.crm-page .shadow,
.crm-page .shadow-lg,
.crm-page .shadow-xl,
.app-body .shadow,
.app-body .shadow-lg,
.app-body .shadow-xl { box-shadow: var(--shadow-sm) !important; }

.crm-page a.text-blue-600,
.app-body a.text-blue-600 { color: var(--accent) !important; }

/* === Photo carousel (dark) === */
.photo-carousel-wrap { display: flex; align-items: center; gap: 0.5rem; }

.photo-carousel {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  flex: 1;
  padding: 0.25rem 0;
  scrollbar-width: thin;
}

.photo-carousel-slide {
  flex: 0 0 auto;
  width: 200px;
  scroll-snap-align: start;
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-muted);
}

.photo-carousel-img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.photo-carousel-caption {
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted, #6b7280);
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

.photo-carousel-actions {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.35rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border);
}

.photo-action-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.photo-action-btn:hover {
  background: var(--bg-card-hover);
  color: var(--accent);
}

.photo-action-danger:hover { color: var(--error); }

.photo-carousel-nav {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-carousel-nav:hover {
  background: var(--bg-card-hover);
  color: var(--accent);
}

.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(7, 11, 20, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.photo-lightbox img {
  max-width: min(92vw, 1200px);
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.photo-lightbox-close,
.photo-lightbox-nav {
  border: none;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
}

.photo-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.1rem;
}

.photo-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.1rem;
}

.photo-lightbox-prev { left: 1rem; }
.photo-lightbox-next { right: 1rem; }

.photo-lightbox-counter {
  position: absolute;
  bottom: 4.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.photo-lightbox-download {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #0f172a;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
}

.login-card { animation: scaleIn 0.25s ease; max-width: 28rem; width: 100%; }
