/* PatternLab v15 — light theme */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: #f6f8fc; color: #1e2230; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }

/* ---------- TOPBAR ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: #ffffff;
  border-bottom: 1px solid #e7eaf2;
}
.topbar-actions { display: flex; gap: 8px; }
.brand { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.brand .ver { color: #2e6bff; font-weight: 600; margin-left: 4px; }
.settings-btn { display: inline-flex; align-items: center; gap: 6px; }
#btnOpenSaved { display: inline-flex; align-items: center; gap: 6px; }
.badge[hidden] { display: none; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: #2e6bff; color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px; min-width: 18px; margin-left: 2px;
}

/* ---------- CONFIG ROW ---------- */
.config-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 14px 18px;
  background: #fff;
  border-bottom: 1px solid #e7eaf2;
}
@media (max-width: 1400px) { .config-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px)  { .config-row { grid-template-columns: 1fr; } }

.config-card { padding: 12px 14px; }
.config-card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; letter-spacing: .2px; color: #1e2230; }
.config-card .field + .field { margin-top: 8px; }
.config-card .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.config-card .row2 + .row2, .config-card .row2 + .field { margin-top: 8px; }
.config-card .btn { margin-top: 10px; width: 100%; }

.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-head h3 { margin: 0; }

/* ---------- FIELDS ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.field > span { color: #6b7280; font-size: 12px; letter-spacing: .2px; }
.field > span small { color: #9aa0b4; font-size: 10px; font-weight: 400; letter-spacing: 0; margin-left: 4px; }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid #d9dde8; border-radius: 8px; background: #fff;
  font: inherit; color: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 60px; font-family: inherit; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #2e6bff; box-shadow: 0 0 0 3px rgba(46,107,255,.12); }

/* ---------- METRICS CHECKBOX LIST ---------- */
.metrics-list {
  display: flex; flex-direction: column; gap: 4px;
  padding: 6px 8px; border: 1px solid #d9dde8; border-radius: 8px; background: #fff;
}
.metric-check {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px; border-radius: 5px;
  cursor: pointer; user-select: none;
  transition: background .1s;
}
.metric-check:hover { background: #f4f6fb; }
.metric-check input[type=checkbox] { accent-color: #2e6bff; width: 14px; height: 14px; margin: 0; }
.metric-check .metric-name { flex: 1; font-size: 12.5px; color: #4a5264; font-weight: 400; }
.metric-check.primary .metric-name { font-weight: 700; color: #1e2230; }
.metric-check .metric-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%;
  background: #eef3ff; color: #1d4ed8; font-weight: 700; font-size: 10px;
  cursor: help; border: 0; user-select: none;
  transition: background .15s, color .15s;
}
.metric-check .metric-info:hover { background: #1d4ed8; color: #fff; }

/* ---------- TOOLTIP ---------- */
.tooltip {
  position: fixed; z-index: 200; max-width: 380px;
  background: #1e2230; color: #e7eaf2;
  padding: 10px 12px; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15,20,40,.24);
  font-size: 12.5px; line-height: 1.5; pointer-events: none;
}
.tooltip[hidden] { display: none; }
.tooltip b { color: #fff; }

/* ---------- BUTTONS ---------- */
.btn {
  padding: 9px 14px; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  font: inherit; font-weight: 500;
  transition: background .15s, border-color .15s, color .15s;
}
.btn.primary { background: #2e6bff; color: #fff; }
.btn.primary:hover:not(:disabled) { background: #1f5de6; }
.btn.ghost { background: #fff; border-color: #d9dde8; color: #1e2230; }
.btn.ghost:hover:not(:disabled) { background: #f1f4fb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- TZ TOGGLE ---------- */
.tz-toggle {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px; background: #f3f5fb; border-radius: 7px; border: 1px solid #e3e7f0;
}
.tz-btn {
  background: transparent; border: 0; padding: 3px 8px; border-radius: 5px;
  cursor: pointer; font: inherit; font-size: 11px; color: #6b7280;
}
.tz-btn.active { background: #fff; color: #1d4ed8; box-shadow: 0 1px 2px rgba(20,40,100,.08); }

/* ---------- CARDS ---------- */
.card {
  background: #fff; border: 1px solid #e7eaf2; border-radius: 10px;
  padding: 14px; box-shadow: 0 1px 2px rgba(20,40,100,.04);
}
.card h3 { margin: 0 0 10px; font-size: 14px; color: #1e2230; letter-spacing: .3px; font-weight: 600; }
.meta { color: #6b7280; font-size: 12px; margin-top: 2px; }

/* ---------- MODAL ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(15, 20, 40, .45); backdrop-filter: blur(2px);
}
.modal-dialog {
  position: relative; z-index: 1;
  width: min(960px, 92vw); max-height: 90vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(15,20,40,.25);
  overflow: hidden;
}
.saved-dialog { width: min(1200px, 95vw); max-height: 92vh; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid #e7eaf2;
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-close {
  background: transparent; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: #6b7280;
  width: 32px; height: 32px; border-radius: 8px;
}
.modal-close:hover { background: #f1f4fb; color: #1e2230; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 18px; border-top: 1px solid #e7eaf2; background: #fafbfe;
}

/* ---------- SETTINGS ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 14px; }
@media (max-width: 800px) { .settings-grid { grid-template-columns: 1fr; } }
.inst-list { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 12px; }
.inst-row { display: grid; grid-template-columns: 80px 1fr 1.5fr 28px; gap: 8px; align-items: center; }
.inst-row input { padding: 7px 9px; border: 1px solid #d9dde8; border-radius: 7px; font: inherit; }
.inst-row .rm { background: transparent; border: 0; color: #b91c1c; cursor: pointer; font-size: 18px; }

/* ---------- VIEW ---------- */
.view { padding: 16px 18px; }
.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.chip {
  background: #eef3ff; color: #1d4ed8; padding: 8px 12px;
  border-radius: 20px; font-size: 13px; font-weight: 500; border: 1px solid #dbe7ff;
}
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.switch { display: inline-flex; align-items: center; gap: 6px; user-select: none; cursor: pointer; color: #4a5264; font-size: 13px; }
.switch input { accent-color: #2e6bff; }

.pattern-row { display: grid; grid-template-columns: 1fr 2.2fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 1100px) { .pattern-row { grid-template-columns: 1fr; } }
.chart-box { height: 240px; position: relative; }
.stats-card .chart-box { height: 220px; }
.stats-summary { font-size: 12.5px; line-height: 1.55; color: #4a5264; }

/* Stats card: header with direction toggle + two panes */
.stats-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; gap: 12px; flex-wrap: wrap;
}
.stats-header h3 { margin: 0; font-size: 14px; color: #1e2230; letter-spacing: .3px; font-weight: 600; }

.direction-toggle {
  display: inline-flex; gap: 4px; padding: 3px; background: #f3f5fb;
  border-radius: 7px; border: 1px solid #e3e7f0;
}
.dir-opt {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 5px;
  cursor: pointer; font-size: 12px; color: #6b7280; user-select: none;
  transition: background .12s, color .12s;
}
.dir-opt input[type=checkbox] { accent-color: #2e6bff; width: 12px; height: 12px; margin: 0; }
.dir-opt.active { background: #fff; color: #1d4ed8; box-shadow: 0 1px 2px rgba(20,40,100,.08); font-weight: 600; }

.stats-panes {
  display: grid; grid-template-columns: minmax(220px, 1fr) 1.55fr;
  gap: 14px; align-items: start;
}
@media (max-width: 900px) { .stats-panes { grid-template-columns: 1fr; } }

/* Stats table */
.stats-table {
  border-collapse: collapse; width: 100%; font-size: 12.5px;
}
.stats-table td {
  padding: 4px 6px; border: 0;
  vertical-align: middle;
}
.stats-table td:first-child { color: #6b7280; white-space: nowrap; }
.stats-table td:last-child { color: #1e2230; font-weight: 600; text-align: right; white-space: nowrap; }
.stats-table tr.sep td { padding: 4px 0; border-top: 1px dashed #e3e7f0; height: 1px; }
.stats-table td.pos { color: #16a34a; }
.stats-table td.neg { color: #dc2626; }

/* ---------- MOSAIC ---------- */
.mosaic { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tile {
  background: #fff; border: 1px solid #e7eaf2; border-radius: 10px; padding: 10px;
  cursor: pointer; position: relative;
  transition: transform .1s, box-shadow .15s, opacity .15s;
}
.tile:hover { box-shadow: 0 2px 10px rgba(20,40,100,.07); transform: translateY(-1px); }
.tile.excluded { opacity: .33; filter: grayscale(.6); }
.tile-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tile-head .score { font-weight: 700; color: #1d4ed8; font-size: 14px; }
.tile-head .ts { color: #6b7280; font-size: 12px; }
.tile .badges-row {
  display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0;
}
.tile .sub { color: #6b7280; font-size: 11px; margin: 2px 0 6px; }
.mini-chart { height: 120px; position: relative; }
.mini-volume-chart { height: 40px; position: relative; margin-top: 4px; }
.metric-badge {
  display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .3px;
  padding: 1px 6px; border-radius: 4px;
  background: #eef3ff; color: #1d4ed8;
}
.metric-badge.m-pearson { background: #dbeafe; color: #1e40af; }
.metric-badge.m-pearson_returns { background: #dcfce7; color: #166534; }
.metric-badge.m-dtw { background: #fef3c7; color: #92400e; }
.metric-badge.m-spearman { background: #ecfdf5; color: #047857; }
.metric-badge.m-cosine_returns { background: #fce7f3; color: #9d174d; }
.metric-badge.m-directional { background: #ede9fe; color: #5b21b6; }
.metric-badge.m-ddtw { background: #ffedd5; color: #9a3412; }
.metric-badge.m-volume { background: #e0f2fe; color: #075985; }
.volume-field { margin-top: 4px; }
.volume-field .hint { display: block; color: #6b7280; font-size: 11px; margin-top: 2px; }
.volume-weight-field input[type=range] { width: 100%; }
.volume-weight-field small { color: #6b7280; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ---------- SAVED RESULTS ---------- */
.saved-body { padding: 0; }
.saved-list-wrap { padding: 16px 18px; }
.saved-list { display: flex; flex-direction: column; gap: 10px; }
.saved-empty { padding: 40px 16px; text-align: center; color: #6b7280; }
.saved-item {
  background: #fff; border: 1px solid #e7eaf2; border-radius: 10px; padding: 12px 14px;
  cursor: pointer; transition: background .12s, border-color .12s, transform .1s;
}
.saved-item:hover { background: #f8faff; border-color: #bdd3ff; transform: translateY(-1px); }
.saved-item-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.saved-item-title { font-size: 13px; color: #1e2230; }
.saved-item-date { font-size: 11px; color: #6b7280; white-space: nowrap; }
.saved-item-sub { font-size: 12px; color: #6b7280; margin-top: 3px; }
.saved-item-stats {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.saved-item-stats .si-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; font-size: 11.5px; line-height: 1.3;
  background: #f5f7fc; border: 1px solid #e3e7f0; border-radius: 6px;
  color: #4a5264;
}
.saved-item-stats .si-chip b { color: #1e2230; font-weight: 600; }
.saved-item-stats .si-chip b.pos { color: #16a34a; }
.saved-item-stats .si-chip b.neg { color: #dc2626; }
.saved-item-stats .si-chip.dir-long { background: #eef5ff; border-color: #cfe0ff; color: #1d4ed8; font-weight: 600; }
.saved-item-stats .si-chip.dir-short { background: #fff1f2; border-color: #fecdd3; color: #be123c; font-weight: 600; }
.saved-item-comment {
  margin-top: 6px; padding: 6px 8px; background: #f3f5fb; border-radius: 6px;
  font-size: 12px; color: #4a5264; white-space: pre-wrap;
}

.saved-detail { padding: 16px 18px; }
.saved-detail-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.saved-detail-meta { font-size: 12.5px; color: #4a5264; background: #f8faff; padding: 10px 12px; border-radius: 8px; line-height: 1.7; }
.saved-detail-meta b { color: #1e2230; }
.saved-detail-pattern { display: grid; grid-template-columns: 1fr 1.3fr; gap: 12px; margin-top: 14px; }
@media (max-width: 900px) { .saved-detail-pattern { grid-template-columns: 1fr; } }
.saved-mosaic-title { margin: 18px 0 10px; font-size: 14px; }
#btnSavedDelete { color: #b91c1c; border-color: #fecaca; }
#btnSavedDelete:hover { background: #fef2f2; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(30px);
  background: #1e2230; color: #fff; padding: 10px 16px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  box-shadow: 0 6px 20px rgba(20,40,100,.18); font-size: 13px; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- LOADER ---------- */
.loader {
  display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -2px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .8s linear infinite;
}
.btn.ghost .loader { border-color: rgba(30,34,48,.25); border-top-color: #1e2230; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================ */
/* ================  PatternScout v16 — стили  ==================== */
/* ================================================================ */

#btnOpenScout { display: inline-flex; align-items: center; gap: 6px; }

/* Большая модалка с табами */
.scout-modal .scout-dialog {
  width: min(1280px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.scout-modal .modal-head h2 .ver {
  font-size: 12px; font-weight: 500; color: #2e6bff; margin-left: 6px;
  padding: 2px 7px; background: rgba(46,107,255,.08); border-radius: 6px;
}

.scout-tabs { display: flex; gap: 4px; margin-left: auto; margin-right: 16px; }
.scout-tab {
  background: transparent; border: 1px solid transparent; padding: 6px 12px;
  border-radius: 8px; font: inherit; color: #6b7280; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.scout-tab:hover:not(:disabled) { background: #f0f2f7; color: #1e2230; }
.scout-tab.active { background: #eef3ff; color: #2e6bff; border-color: #d5e1ff; }
.scout-tab:disabled { opacity: .45; cursor: not-allowed; }

.scout-body { overflow-y: auto; padding: 16px 18px 20px; flex: 1; }
.scout-pane { display: block; }
.scout-pane[hidden] { display: none !important; }

/* Config */
.scout-config-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 1100px) { .scout-config-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px)  { .scout-config-grid { grid-template-columns: 1fr; } }

.scout-pane .card { padding: 12px 14px; }
.scout-pane .card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; }
.scout-pane .field + .field { margin-top: 8px; }
.scout-pane .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.scout-pane .hint { color: #9aa0b4; font-size: 11px; margin-top: 3px; }
.check-inline {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  cursor: pointer; user-select: none;
}

.scout-run-bar {
  margin-top: 16px; display: flex; justify-content: space-between;
  align-items: center; gap: 12px; padding: 12px 14px;
  background: #f6f8fc; border: 1px solid #e7eaf2; border-radius: 10px;
}
.scout-info { color: #4a5264; font-size: 13px; flex: 1; }
.scout-info.error { color: #dc2626; }
.scout-info.ok { color: #16a34a; }

/* Jobs */
.scout-jobs-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.scout-jobs-list { display: flex; flex-direction: column; gap: 8px; }
.scout-job-item {
  padding: 12px 14px; background: #fff; border: 1px solid #e7eaf2;
  border-radius: 10px; cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.scout-job-item:hover { border-color: #2e6bff; box-shadow: 0 0 0 3px rgba(46,107,255,.08); }
.scout-job-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.scout-job-title { font-weight: 600; }
.scout-job-status {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
  text-transform: uppercase;
}
.scout-job-status.queued   { background: #f0f2f7; color: #6b7280; }
.scout-job-status.running  { background: #eef6ff; color: #2e6bff; }
.scout-job-status.done     { background: #ecfdf5; color: #16a34a; }
.scout-job-status.error    { background: #fef2f2; color: #dc2626; }
.scout-job-status.cancelled{ background: #f0f2f7; color: #6b7280; }
.scout-job-meta { color: #6b7280; font-size: 12px; margin-top: 4px; }
.scout-progress {
  height: 6px; border-radius: 4px; background: #e7eaf2; margin-top: 8px;
  overflow: hidden;
}
.scout-progress-bar {
  height: 100%; background: linear-gradient(90deg, #2e6bff, #4f8bff);
  transition: width .2s;
}
.scout-job-actions {
  margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap;
}
.scout-job-actions .btn {
  padding: 4px 10px; font-size: 12px;
}

/* Results */
.scout-results-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
.scout-filters {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
}
.scout-filters .inline-mini {
  flex-direction: row; align-items: center; gap: 4px;
}
.scout-filters .inline-mini > span { white-space: nowrap; font-size: 11px; }
.scout-filters .inline-mini input { width: 70px; padding: 4px 6px; }

.scout-results-layout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px;
}
@media (max-width: 900px) { .scout-results-layout { grid-template-columns: 1fr; } }

.scout-summary {
  padding: 12px 14px; background: #fff; border: 1px solid #e7eaf2; border-radius: 10px;
  font-size: 13px; line-height: 1.6;
}
.scout-summary b { color: #1e2230; }
.scout-summary .kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; }
.scout-summary .kv span:first-child { color: #6b7280; }

.scout-heatmap-wrap {
  padding: 12px 14px; background: #fff; border: 1px solid #e7eaf2; border-radius: 10px;
}
.scout-heatmap-wrap h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
#scoutHeatmap { display: block; width: 100%; height: auto; }
.scout-heatmap-legend {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
  font-size: 11px; color: #6b7280;
}
.scout-heatmap-legend .grad {
  flex: 1; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #eef3ff, #2e6bff);
}

/* Table */
.scout-table-wrap {
  background: #fff; border: 1px solid #e7eaf2; border-radius: 10px;
  overflow-x: auto;
}
.scout-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.scout-table th, .scout-table td {
  padding: 8px 10px; text-align: right; border-bottom: 1px solid #f0f2f7;
  white-space: nowrap;
}
.scout-table th:first-child, .scout-table td:first-child,
.scout-table th:nth-child(2), .scout-table td:nth-child(2) {
  text-align: left;
}
.scout-table th {
  position: sticky; top: 0; background: #f6f8fc; z-index: 2;
  font-weight: 600; color: #4a5264; cursor: pointer; user-select: none;
}
.scout-table th:hover { background: #eef3ff; }
.scout-table th.sorted { color: #2e6bff; }
.scout-table tbody tr:hover { background: #f9fafc; }
.scout-table .pos { color: #16a34a; font-weight: 600; }
.scout-table .neg { color: #dc2626; font-weight: 600; }
.scout-table .muted { color: #9aa0b4; }
.scout-table .edge {
  font-weight: 700; padding: 2px 6px; border-radius: 4px;
  background: rgba(46,107,255,.08); color: #2e6bff; display: inline-block;
  min-width: 40px; text-align: center;
}
.scout-table .dir {
  font-weight: 700; padding: 1px 6px; border-radius: 4px; font-size: 10px;
  text-transform: uppercase;
}
.scout-table .dir.long  { background: #ecfdf5; color: #16a34a; }
.scout-table .dir.short { background: #fef2f2; color: #dc2626; }
.scout-table .flag-chip {
  display: inline-block; font-size: 10px; padding: 1px 5px; border-radius: 3px;
  margin-right: 2px;
}
.scout-table .flag-fdr     { background: #ecfdf5; color: #16a34a; }
.scout-table .flag-stable  { background: #eef3ff; color: #2e6bff; }
.scout-table .flag-time    { background: #fff7ed; color: #ea580c; }
.scout-table .flag-oos     { background: #f3e8ff; color: #7c3aed; }
.scout-table tr.fdr-pass { background: rgba(22,163,74,.04); }
.scout-table tr.excluded { opacity: .4; }

.scout-table .btn-open {
  padding: 3px 8px; font-size: 11px; background: #2e6bff; color: #fff;
  border: none; border-radius: 5px; cursor: pointer;
}
.scout-table .btn-open:hover { background: #1b55e0; }

/* ===== INTERACTIVE PATTERN PICKER ===== */
.picker-card { margin-top: 12px; padding: 12px; }
.picker-card[hidden] { display: none !important; }
.picker-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.picker-head h3 { margin: 0; font-size: 15px; }
.picker-head .picker-hint { color: #6b7280; font-size: 12px; flex: 1; }
.picker-head .modal-close {
  background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer;
  color: #6b7280; padding: 0 6px;
}
.picker-head .modal-close:hover { color: #111827; }

.picker-toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 8px; padding: 6px 8px; background: #f8fafc; border-radius: 8px;
}
.picker-toolbar > div { display: flex; gap: 4px; align-items: center; }
.picker-toolbar .btn.sm { padding: 2px 9px; font-size: 12px; min-width: 28px; }
.picker-toolbar input[type="datetime-local"] {
  font-size: 12px; padding: 3px 6px; border: 1px solid #d1d5db; border-radius: 5px;
}
.picker-toolbar .picker-span { font-size: 12px; color: #6b7280; min-width: 90px; text-align: center; font-variant-numeric: tabular-nums; }
.picker-toolbar #pickerSelLabel { font-size: 12px; color: #374151; font-variant-numeric: tabular-nums; }

.picker-chart-wrap {
  position: relative; height: 360px; width: 100%;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px;
}
.picker-chart-wrap canvas { width: 100% !important; height: 100% !important; cursor: crosshair; touch-action: none; }
.picker-status {
  position: absolute; top: 10px; left: 14px;
  font-size: 11px; color: #9ca3af; pointer-events: none;
}

/* подсветка активного эталона внутри полей */
#patternStart.picker-active, #patternEnd.picker-active {
  outline: 2px solid #2e6bff; outline-offset: 1px;
}
