@import url('mining_opportunity_scanner.css');

.csa-tool {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Stats — 3 equal columns */
.csa-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.csa-stat {
  padding: 10px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  background: var(--bg-canvas);
  min-width: 0;
}

.csa-stat-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-subtle);
  line-height: 1.3;
}

.csa-stat-value {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  font-weight: 700;
  font-family: var(--mono);
  line-height: 1.2;
}

.csa-stat-value.is-switch { color: var(--success); }
.csa-stat-value.is-watch { color: var(--accent-emphasis); }

/* Toolbar */
.csa-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
}

.csa-toolbar-main {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.csa-field-inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  color: var(--fg-subtle);
  min-width: 140px;
  flex: 0 1 200px;
}

.csa-field-inline > span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.2;
  min-height: 12px;
}

.csa-select,
.csa-search {
  width: 100%;
  min-height: 30px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  color: var(--fg-default);
  border-radius: var(--radius);
  font: inherit;
  font-size: 11px;
  padding: 6px 8px;
  box-sizing: border-box;
}

.csa-search {
  min-width: 160px;
  flex: 1 1 180px;
  max-width: 280px;
}

.csa-action-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 30px;
}

.csa-filter {
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  color: var(--fg-muted);
  border-radius: var(--radius);
  font: inherit;
  font-size: 10px;
  padding: 6px 10px;
  cursor: pointer;
  line-height: 1.2;
}

.csa-filter.is-active {
  color: var(--fg-default);
  border-color: var(--accent-emphasis);
  background: var(--bg-muted);
}

.csa-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--fg-muted);
  padding-top: 2px;
  border-top: 1px solid var(--border-muted);
}

.csa-meta strong {
  color: var(--fg-default);
}

.csa-top-pick {
  width: 100%;
}

.csa-top-pick-card {
  padding: 10px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  font-size: 12px;
  line-height: 1.45;
}

/* Main layout */
.csa-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 1fr);
  gap: 10px;
  align-items: start;
}

.csa-panel {
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  padding: 12px;
  min-width: 0;
}

.csa-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  min-height: 20px;
}

.csa-panel-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.csa-count {
  font-size: 10px;
  color: var(--fg-subtle);
  white-space: nowrap;
}

.csa-table-wrap {
  max-height: 520px;
  overflow: auto;
  background: var(--bg-canvas);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  scrollbar-color: var(--bg-emphasis) var(--bg-canvas);
}

.csa-table {
  width: 100%;
  table-layout: fixed;
}

.csa-table th,
.csa-table td {
  vertical-align: middle;
  padding: 6px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csa-table th:nth-child(1),
.csa-table td:nth-child(1) { width: 12%; }
.csa-table th:nth-child(2),
.csa-table td:nth-child(2) { width: 28%; }
.csa-table th:nth-child(3),
.csa-table td:nth-child(3) { width: 12%; }
.csa-table th:nth-child(4),
.csa-table td:nth-child(4) { width: 12%; }
.csa-table th:nth-child(5),
.csa-table td:nth-child(5) { width: 14%; text-align: right; }
.csa-table th:nth-child(6),
.csa-table td:nth-child(6) { width: 22%; text-align: right; }

.csa-table tbody tr {
  cursor: pointer;
}

.csa-table tbody tr.is-selected {
  background: var(--bg-muted);
}

.csa-action-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid var(--border-default);
  white-space: nowrap;
}

.csa-action-badge.is-switch {
  color: var(--success);
  border-color: var(--success-muted);
}

.csa-action-badge.is-hold {
  color: var(--fg-muted);
}

.csa-action-badge.is-watch {
  color: var(--accent-emphasis);
  border-color: var(--accent-emphasis);
}

/* Detail panel */
.csa-detail-body h3,
.csa-detail-headline {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  line-height: 1.4;
}

.csa-detail-body h4 {
  margin: 12px 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--fg-default);
}

.csa-detail-hero {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.csa-detail-kv {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 68px;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  font-size: 11px;
  box-sizing: border-box;
}

.csa-detail-kv .k {
  min-height: 26px;
  display: flex;
  align-items: flex-end;
  color: var(--fg-subtle);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.25;
}

.csa-detail-kv .v {
  margin-top: 6px;
  font-weight: 600;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.csa-detail-body .peps-table {
  font-size: 11px;
}

.csa-detail-body .peps-table th:nth-child(2),
.csa-detail-body .peps-table th:nth-child(3),
.csa-detail-body .peps-table td:nth-child(2),
.csa-detail-body .peps-table td:nth-child(3) {
  text-align: right;
}

.csa-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 8px;
}

.csa-reason {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-muted);
  border: 1px solid var(--border-default);
  color: var(--fg-muted);
}

@media (max-width: 1100px) {
  .csa-stats {
    grid-template-columns: 1fr;
  }

  .csa-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .csa-detail-hero {
    grid-template-columns: 1fr;
  }

  .csa-field-inline {
    flex: 1 1 100%;
  }

  .csa-search {
    max-width: none;
  }
}
