/* === Bitrix24 Design System === */

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  background: #eef2f4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Header */
.header {
  background: #fff;
  border-radius: 4px;
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  border-left: 4px solid #2067b0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.header-content {
  flex: 1;
}

.title {
  font-size: 20px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.subtitle {
  font-size: 13px;
  color: #666;
}

/* Help button (circle with ?) */
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #c6cdd3;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
  margin-top: 2px;
}

.help-btn:hover {
  background: #2067b0;
}

/* Form sections */
.form-section {
  background: #fff;
  border-radius: 4px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 20px;
  color: #1a1a1a;
  padding-bottom: 10px;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-row {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}

.form-input,
.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #c6cdd3;
  border-radius: 2px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: #333;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: #2067b0;
  box-shadow: 0 0 0 2px rgba(32, 103, 176, 0.15);
}

.form-select[multiple] {
  min-height: 100px;
}

.form-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #7f7f7f;
}

.form-checkbox {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  cursor: pointer;
  accent-color: #2067b0;
}

.dates-row {
  display: flex;
  gap: 12px;
}

.date-field {
  flex: 1;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: #2067b0;
  color: #fff;
}

.btn-primary:hover {
  background: #1a5a9e;
  box-shadow: 0 1px 3px rgba(32, 103, 176, 0.3);
}

.btn-secondary {
  background: #bbed21;
  color: #333;
}

.btn-secondary:hover {
  background: #a8d91a;
  box-shadow: 0 1px 3px rgba(187, 237, 33, 0.3);
}

/* Checkbox label */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  margin-right: 16px;
  font-weight: 500;
}

.checkbox-label span {
  user-select: none;
}

/* Export controls */
.export-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e5e5;
  flex-wrap: wrap;
}

/* Alert */
.alert {
  padding: 16px 20px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.alert-warning {
  background: #fef9e6;
  border: 1px solid #f5a623;
  color: #8a6d3b;
}

.alert a {
  color: #2067b0;
  font-weight: 600;
  text-decoration: underline;
}

/* Result section */
.result-section {
  background: #fff;
  border-radius: 4px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.result-section.hidden {
  display: none;
}

.result-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #1a1a1a;
}

/* Table */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid #c6cdd3;
  border-radius: 2px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #e5e5e5;
}

.data-table th {
  background: #f5f5f5;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  border-bottom: 2px solid #c6cdd3;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable:hover {
  background: #ebebeb;
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:hover {
  background: #f5f9fc;
}

.data-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.data-table tbody tr:nth-child(even):hover {
  background: #f5f9fc;
}

.data-table a {
  color: #2067b0;
  text-decoration: none;
}

.data-table a:hover {
  text-decoration: underline;
}

.data-table tfoot .total-row {
  font-weight: 600;
  background: #f5f5f5;
}

.data-table tfoot td {
  border-top: 2px solid #c6cdd3;
  border-bottom: none;
}

/* Footer */
.footer {
  margin-top: 24px;
  padding-top: 16px;
  text-align: center;
}

.copyright {
  font-size: 12px;
  color: #999;
}

/* Settings page */
.settings-form {
  max-width: 720px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e5e5e5;
}

.save-message {
  font-size: 14px;
  font-weight: 500;
}

.save-message.success {
  color: #1eaa1e;
}

.save-message.error {
  color: #d9534f;
}

.required {
  color: #d9534f;
}

/* Loading */
.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
}

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

/* === Help Sidebar === */
.help-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.help-overlay.active {
  opacity: 1;
  visibility: visible;
}

.help-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 90vw;
  height: 100%;
  background: #fff;
  z-index: 999;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
}

.help-sidebar.active {
  transform: translateX(0);
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e5e5;
  background: #f5f5f5;
  flex-shrink: 0;
}

.help-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.help-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  transition: background 0.2s, color 0.2s;
}

.help-close:hover {
  background: #e5e5e5;
  color: #333;
}

.help-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.help-nav {
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  border-bottom: 1px solid #e5e5e5;
  background: #fafafa;
  flex-shrink: 0;
}

.help-nav-link {
  padding: 8px 20px;
  font-size: 13px;
  color: #2067b0;
  text-decoration: none;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

.help-nav-link:hover {
  background: #eef2f4;
  border-left-color: #2067b0;
}

.help-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.help-section {
  margin-bottom: 28px;
}

.help-section h4 {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e5e5;
}

.help-section h5 {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-top: 16px;
  margin-bottom: 8px;
}

.help-section p {
  font-size: 13px;
  color: #555;
  margin-bottom: 10px;
  line-height: 1.6;
}

.help-section ul {
  margin-left: 18px;
  margin-bottom: 12px;
}

.help-section ul li {
  font-size: 13px;
  color: #555;
  margin-bottom: 6px;
  line-height: 1.5;
}

.help-section code {
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 2px;
  font-size: 12px;
  color: #d9534f;
}

.help-section a {
  color: #2067b0;
  text-decoration: none;
  cursor: pointer;
}

.help-section a:hover {
  text-decoration: underline;
}

.help-section em {
  color: #7f7f7f;
  font-style: italic;
}

.help-section strong {
  color: #333;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 12px;
  }
  
  .dates-row {
    flex-direction: column;
    gap: 8px;
  }
  
  .data-table th,
  .data-table td {
    padding: 8px;
    font-size: 12px;
  }
  
  .export-controls {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .help-sidebar {
    width: 100%;
    max-width: 100%;
  }
}
