:root {
  --primary-color: #0b66c3;
  --primary-hover: #09529d;
  --accent-color: #2fc6f6;
  --bg-color: #eef2f5;
  --card-bg: #ffffff;
  --text-main: #333333;
  --text-muted: #535c69;
  --border-color: #dbe2e6;
  --border-radius: 8px;
  --danger-color: #d9534f;
  --danger-hover: #c9302c;
  --warning-color: #f0ad4e;
  --warning-hover: #ec971f;
  --success-color: #5cb85c;
  --success-hover: #449d44;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  padding: 0 0 30px 0;
  font-size: 14px;
  line-height: 1.5;
}

/* --- Corporate Header (ПРО-КОНВЕРСИЯ) --- */
.main-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #0f172a;
  color: #f1f5f9;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.header-left {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 0;
  background: linear-gradient(135deg, #ffffff 0%, #8bb9e7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.partner-badge {
  font-size: 11px;
  color: #8bb9e7;
  letter-spacing: 0.8px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.9;
  margin-top: 2px;
}

.partner-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  background: #8bb9e7;
  border-radius: 50%;
  box-shadow: 0 0 8px #8bb9e7;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.contact-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.contact-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f1f5f9;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
  opacity: 0.8;
}

.contact-link:hover {
  color: #8bb9e7;
  opacity: 1;
}

.contact-link svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.icon-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.icon-btn img {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  object-fit: cover;
}

.max-btn {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.max-btn:hover {
  background: #ffffff;
  color: #0b0f19;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 255, 255, 0.15);
}

.b24-btn {
  background: rgba(139, 185, 231, 0.08);
  color: #8bb9e7;
  border-color: rgba(139, 185, 231, 0.25);
}

.b24-btn:hover {
  background: #8bb9e7;
  color: #0b0f19;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(139, 185, 231, 0.25);
}

.container {
  max-width: 1100px;
  margin: 20px auto 0;
  padding: 0 16px;
}

/* App Hero / Header */
.app-hero,
.app-header {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 18px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
}

.app-title h1 {
  font-size: 20px;
  font-weight: 600;
  color: #202428;
}

.app-title p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.portal-badge {
  display: inline-flex;
  align-items: center;
  background: #eef4fc;
  color: #1967d2;
  border: 1px solid #d2e3fc;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid #f0f3f5;
  padding-bottom: 12px;
}

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #202428;
}

.badge-step {
  background: #eef2f5;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
}

/* Forms & Grids */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-size: 13px;
}

.form-control {
  height: 38px;
  padding: 6px 12px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: #fff;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

.form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(11, 102, 195, 0.2);
}

.form-control:disabled {
  background-color: #eef2f5 !important;
  color: #7b8895 !important;
  cursor: not-allowed !important;
  border-color: #d0d7de !important;
  user-select: none;
}

.form-group.is-disabled label {
  color: #8b95a5 !important;
}

/* --- Custom Interactive Employee Select Component --- */
.custom-select-container {
  position: relative;
  width: 100%;
}

.select-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 10px;
  min-height: 38px;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.select-box:hover {
  border-color: #b0bec5;
}

.select-box:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(11, 102, 195, 0.2);
}

.selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  flex: 1;
  min-height: 28px;
  pointer-events: none;
}

.tag {
  background: #eef4fc;
  color: #1967d2;
  border: 1px solid #d2e3fc;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  animation: tagScaleIn 0.15s ease;
  white-space: nowrap;
  pointer-events: auto;
}

.tag-fired {
  background: #f1f3f5;
  color: #6c757d;
  border-color: #dee2e6;
}

@keyframes tagScaleIn {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.tag-remove {
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  opacity: 0.6;
  font-weight: bold;
  transition: opacity 0.15s, color 0.15s;
}

.tag-remove:hover {
  opacity: 1;
  color: var(--danger-color);
}

.select-search {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  flex: 1;
  min-width: 130px;
  outline: none;
  height: 28px;
  pointer-events: auto;
}

.placeholder {
  color: #8c9ba5;
  font-size: 13px;
  pointer-events: none;
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  transition: opacity 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 20px);
}

.select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  max-height: 280px;
  background: #ffffff;
  border: 1px solid #cfd7df;
  border-radius: 8px;
  overflow-y: auto;
  z-index: 1001;
  display: none;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

.select-dropdown.active {
  display: block;
}

.select-option {
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-main);
}

.select-option:hover {
  background: #f0f4f9;
  color: var(--primary-color);
}

.select-option.selected {
  background: #e8f0fe;
  font-weight: 600;
  color: #1967d2;
}

.select-option.fired {
  color: #8c9ba5;
}

.select-option .status {
  font-size: 10px;
  padding: 2px 6px;
  background: #f1f3f5;
  border-radius: 4px;
  color: #6c757d;
  font-weight: 500;
  margin-left: 8px;
  text-transform: uppercase;
}

.select-option .check-mark {
  font-weight: bold;
  color: #1967d2;
  font-size: 14px;
}

/* Dynamic Conditions Builder */
.dynamic-filter-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
}

.dynamic-filter-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

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

.dynamic-conditions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.condition-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.condition-row select, .condition-row input {
  height: 34px;
}

.condition-field {
  flex: 2;
  min-width: 180px;
}

.condition-op {
  flex: 1;
  min-width: 140px;
}

.condition-val-wrapper {
  flex: 2;
  min-width: 220px;
  display: flex;
  align-items: center;
}

.condition-val {
  width: 100%;
}

.condition-date-range {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.condition-date-range .date-sublabel {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  user-select: none;
}

.condition-date-from,
.condition-date-to {
  flex: 1;
  min-width: 120px;
}

.condition-date-single {
  width: 100%;
}

.condition-remove-btn {
  background: transparent;
  border: none;
  color: var(--danger-color);
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
  margin-left: auto;
}

/* Actions Bar */
.filter-actions-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
}

.fetch-status-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-pill {
  background: #e8f4fd;
  color: #0b66c3;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid #c8e1fb;
}

/* Preview Box */
.preview-box {
  margin-top: 14px;
  background: #fdfdfd;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px 16px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.preview-ids-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.id-tag {
  background: #eef2f5;
  color: #333;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}

/* Workflow Parameters Box */
.workflow-params-box {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
}

.params-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.workflow-params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  outline: none;
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
  white-space: nowrap;
}

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

.btn-primary {
  background-color: var(--primary-color);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.btn-success {
  background-color: var(--success-color);
  color: #fff;
}
.btn-success:hover:not(:disabled) {
  background-color: var(--success-hover);
}

.btn-warning {
  background-color: var(--warning-color);
  color: #fff;
}
.btn-warning:hover:not(:disabled) {
  background-color: var(--warning-hover);
}

.btn-danger {
  background-color: var(--danger-color);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background-color: var(--danger-hover);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-muted);
}
.btn-outline:hover:not(:disabled) {
  background-color: #f1f4f6;
  color: var(--text-main);
}

.btn-outline-danger {
  background: transparent;
  border-color: var(--danger-color);
  color: var(--danger-color);
}
.btn-outline-danger:hover:not(:disabled) {
  background-color: #fff1f0;
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--primary-color);
  text-decoration: underline;
  cursor: pointer;
}

.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-lg {
  height: 44px;
  padding: 0 26px;
  font-size: 15px;
  font-weight: 600;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
}

/* Controls Toolbar */
.controls-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

/* Progress Bar */
.progress-section {
  margin: 16px 0;
}

.progress-bar-container {
  width: 100%;
  height: 14px;
  background-color: #e6ebf0;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #2fc6f6, #0b66c3);
  transition: width 0.3s ease;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.stat-badge {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
}

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

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: #202428;
}

.stat-success .stat-value { color: var(--success-color); }
.stat-failed .stat-value { color: var(--danger-color); }
.stat-pending .stat-value { color: var(--primary-color); }

/* Table & Log */
.log-header {
  margin-bottom: 12px;
}

.log-filter-pills {
  display: flex;
  gap: 6px;
}

.pill-filter {
  background: #f1f4f6;
  border: 1px solid transparent;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.pill-filter.active {
  background: #fff;
  border-color: var(--primary-color);
  color: var(--primary-color);
  font-weight: 600;
}

.table-responsive {
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.log-table th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 2;
}

.log-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f3f5;
  color: var(--text-main);
  vertical-align: middle;
}

.log-table tr:hover {
  background-color: #fafbfc;
}

.status-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-tag.success {
  background: #eafaf1;
  color: #27ae60;
  border: 1px solid #a9dfbf;
}

.status-tag.error {
  background: #fdedec;
  color: #e74c3c;
  border: 1px solid #f5b7b1;
}

.status-tag.pending {
  background: #f4f6f7;
  color: #7f8c8d;
}

/* Alerts */
.alert {
  padding: 14px 18px;
  border-radius: 6px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.alert-warning {
  background-color: #fff9e6;
  border: 1px solid #ffe58f;
  color: #874d00;
}

.alert-danger {
  background-color: #fff1f0;
  border: 1px solid #ffa39e;
  color: #cf1322;
}

.btn-warning-sm {
  background: #fa8c16;
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary-sm {
  background: #e6ebf0;
  color: #333;
  border: none;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

/* Install View */
.install-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
}

.install-card {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 40px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 460px;
  width: 100%;
}

.install-icon {
  width: 64px;
  height: 64px;
  background-color: #eafaf1;
  color: #27ae60;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 16px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(11, 102, 195, 0.2);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 0.8s linear infinite;
}

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

/* Footer */
.footer {
  text-align: center;
  padding: 24px 0 10px;
  font-size: 12px;
  color: #64748b;
  border-top: 1px solid var(--border-color);
  margin-top: 30px;
}

@media (max-width: 900px) {
  .main-header {
    padding: 12px 16px;
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  .header-left {
    align-items: center;
  }
  .header-right {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }
  .contact-group {
    align-items: center;
  }
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .filter-grid, .settings-grid {
    grid-template-columns: 1fr;
  }
  .condition-row {
    flex-direction: column;
    align-items: stretch;
  }
}
