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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  background: #f0f2f5;
  color: #2c3e50;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* Сайдбар */
.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: #1a2533;
  color: #cdd9e5;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.sidebar-brand {
  padding: 20px 16px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid #2d3e50;
}

.sidebar ul {
  list-style: none;
  padding: 8px 0;
}

.sidebar ul li a {
  display: block;
  padding: 10px 16px;
  color: #aab8c2;
  text-decoration: none;
  border-radius: 4px;
  margin: 2px 6px;
  transition: background 0.15s;
}

.sidebar ul li a:hover { background: #2d3e50; color: #fff; }
.sidebar ul li.active a { background: #2980b9; color: #fff; }

/* Основной контент */
.content {
  flex: 1;
  padding: 24px;
  overflow-x: auto;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #1a2533;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #2c3e50;
}

.subtitle {
  font-size: 13px;
  font-weight: 400;
  color: #7f8c8d;
  margin-left: 8px;
}

/* KPI плашки */
.kpi-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.kpi-card {
  background: #fff;
  border-radius: 8px;
  padding: 16px 20px;
  min-width: 130px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-left: 4px solid #bdc3c7;
}

.kpi-label { font-size: 11px; color: #7f8c8d; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 4px; }

.kpi-alert { border-left-color: #e67e22; }
.kpi-red   { border-left-color: #e74c3c; }
.kpi-orange{ border-left-color: #e67e22; }
.kpi-yellow{ border-left-color: #f1c40f; }
.kpi-ok    { border-left-color: #27ae60; }

/* Графики */
.charts-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.chart-box {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  flex: 1;
  min-width: 300px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

.chart-box-wide {
  width: 100%;
  flex: none;
}

/* Таблицы */
.section {
  margin-bottom: 24px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

th {
  background: #f8f9fa;
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #7f8c8d;
  border-bottom: 1px solid #ecf0f1;
  white-space: nowrap;
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid #f0f2f5;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9fa; }

/* Цвет строк по уровню */
tr.level-3 td:first-child { color: #e74c3c; font-size: 16px; }
tr.level-2 td:first-child { color: #e67e22; font-size: 16px; }
tr.level-1 td:first-child { color: #f1c40f; font-size: 16px; }
tr.level-0 { color: #7f8c8d; }

.table-meta { font-size: 12px; color: #7f8c8d; margin-bottom: 8px; }
.empty-cell { text-align: center; color: #aaa; padding: 20px; }

/* Фильтр */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.filter-bar select, .filter-bar input {
  padding: 6px 10px;
  border: 1px solid #dce1e7;
  border-radius: 4px;
  font-size: 13px;
}

/* Кнопки */
button, .btn-primary, .btn-reset, .btn-danger {
  display: inline-block;
  padding: 7px 14px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
}

.btn-primary, button[type=submit]:not(.btn-danger):not(.btn-sm) {
  background: #2980b9;
  color: #fff;
}

.btn-primary:hover, button[type=submit]:not(.btn-danger):not(.btn-sm):hover {
  background: #2471a3;
}

.btn-reset {
  background: #ecf0f1;
  color: #2c3e50;
}

.btn-reset:hover { background: #dce1e7; }

.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }

.btn-sm { padding: 3px 8px; font-size: 12px; }

/* Конфиг-форма */
.config-table { margin-bottom: 16px; }
.config-table input[type=number] { width: 80px; }

/* Inline-форма */
.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.inline-form input {
  padding: 6px 10px;
  border: 1px solid #dce1e7;
  border-radius: 4px;
  font-size: 13px;
}

/* Алерты */
.alert {
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}

.alert-ok   { background: #eafaf1; border: 1px solid #a9dfbf; color: #196f3d; }
.alert-info { background: #ebf5fb; border: 1px solid #a9cce3; color: #1a5276; }

/* Инфо-блок */
.info-box {
  background: #f8f9fa;
  border-left: 3px solid #2980b9;
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 16px;
  font-size: 13px;
}

.info-box pre {
  margin-top: 4px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Пустое состояние */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #7f8c8d;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.empty-state p { font-size: 15px; margin-bottom: 8px; }

/* Хлебные крошки */
.breadcrumb { margin-bottom: 16px; }
.breadcrumb a { color: #2980b9; text-decoration: none; font-size: 13px; }

/* Ссылки */
a { color: #2980b9; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Компактные графики */
.chart-box canvas { height: 220px !important; }

/* Подпись под графиком */
.chart-caption {
  font-size: 12px;
  color: #7f8c8d;
  text-align: center;
  margin-top: 8px;
  font-style: italic;
}

/* Сортируемые заголовки */
th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover { background: #edf0f2; color: #2c3e50; }
th.sort-active { color: #2980b9; }

/* Кликабельное название сделки */
.deal-name-link {
  cursor: pointer;
  color: #2980b9;
  border-bottom: 1px dotted #2980b9;
}
.deal-name-link:hover { color: #1a5a8a; }

/* Сигналы (список) */
.signal-list {
  margin: 6px 0 0 16px;
  padding: 0;
}
.signal-list li { margin-bottom: 2px; }

/* Модальное окно */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  width: 500px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #ecf0f1;
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #7f8c8d;
  padding: 0 4px;
  line-height: 1;
}
.modal-close:hover { color: #2c3e50; }

.modal-body { padding: 16px 20px; }

.modal-info-table { width: 100%; border: none; box-shadow: none; font-size: 13px; }
.modal-info-table th {
  background: none;
  color: #7f8c8d;
  padding: 5px 8px 5px 0;
  border: none;
  width: 45%;
  font-weight: 500;
  border-bottom: none;
}
.modal-info-table td {
  padding: 5px 0;
  border: none;
  border-bottom: none;
}
.modal-info-table tr:hover td { background: none; }

.modal-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid #ecf0f1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Справка */
.help-toc {
  background: #ebf5fb;
  border: 1px solid #a9cce3;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 13px;
}
.help-toc a { margin: 0 4px; }

.help-section {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.help-section h2 { font-size: 16px; margin-bottom: 10px; color: #1a2533; }
.help-section h3 { font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: #2c3e50; text-transform: uppercase; letter-spacing: 0.4px; }
.help-section p  { font-size: 13px; line-height: 1.6; margin-bottom: 8px; }

.help-table { font-size: 13px; }
.help-table th { font-size: 11px; }

.help-note {
  background: #fef9e7;
  border-left: 3px solid #f39c12;
  padding: 8px 12px;
  border-radius: 0 4px 4px 0;
  font-size: 13px;
  margin-top: 10px;
}
