/* Textmine (last30days-skill + 8-emotion topic-first dashboard) */
.tm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 18px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
}
.tm-bar-left, .tm-bar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.tm-bar-label {
  font-size: 13px;
  font-weight: 700;
  color: #475569;
}
.tm-search {
  display: flex;
  gap: 6px;
  flex: 1 1 220px;
  max-width: 100%;
}
.tm-search input {
  flex: 1 1 160px;
  min-width: 0;
  padding: 7px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  background: #f8fafc;
  color: #0f172a;
}
.tm-search input:focus {
  outline: 2px solid #2563eb;
  background: #fff;
}
.tm-search button, .tm-refresh {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
}
.tm-search button {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}
.tm-search button:hover { background: #1e293b; }
.tm-refresh:hover { background: #f1f5f9; }
.tm-search button:disabled, .tm-refresh:disabled { opacity: 0.55; cursor: wait; }

.tm-banner {
  margin: -8px 0 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 13px;
  font-weight: 600;
}

.tm-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 22px;
}
.tm-kpi {
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 14px 16px;
}
.tm-kpi-k { font-size: 12px; color: #64748b; font-weight: 600; }
.tm-kpi-v { font-size: 24px; font-weight: 800; color: #0f172a; margin-top: 4px; letter-spacing: -0.02em; }
.tm-kpi-s { font-size: 12px; color: #475569; margin-top: 4px; line-height: 1.4; }
.tm-kpi-v.good { color: #0f766e; }
.tm-kpi-v.bad { color: #be123c; }

.tm-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.tm-chart-wrap {
  width: 100%;
  overflow: hidden;
}
.tm-chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

.tm-discover-h {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  margin: 12px 0 8px;
}
.tm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tm-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-size: 12px;
  color: #1e293b;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tm-chip b { font-weight: 700; color: #0f172a; }

.tm-legend, .tm-legend-sm {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12px;
  color: #334155;
  margin-bottom: 12px;
}
.tm-legend span, .tm-legend-sm span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.sw {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Topic stacked list */
.tm-topic-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tm-trow {
  display: grid;
  grid-template-columns: minmax(150px, 230px) 1fr auto;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.tm-trow:hover { background: #f8fafc; border-color: #94a3b8; }
.tm-trow.on { border-color: #2563eb; background: #eff6ff; box-shadow: inset 3px 0 0 #2563eb; }
.tm-tname { font-weight: 700; font-size: 14px; color: #0f172a; line-height: 1.3; }
.tm-tmeta { font-size: 12px; color: #64748b; margin-top: 2px; }
.tm-sbar {
  display: flex;
  height: 18px;
  border-radius: 6px;
  overflow: hidden;
  background: #f1f5f9;
  min-width: 100px;
}
.tm-sseg {
  height: 100%;
  transition: opacity 0.15s;
}
.tm-tnum {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  font-size: 12px;
  white-space: nowrap;
}
.tm-net { font-weight: 800; font-size: 13px; }
.tm-net.good { color: #0f766e; }
.tm-net.bad { color: #be123c; }
.tm-net.mixed { color: #475569; }

.tm-emo-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

/* Detail cards */
.tm-detail-card { margin-top: 14px; }
.tm-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}
.tm-detail-eyebrow { font-size: 11px; font-weight: 700; color: #2563eb; text-transform: uppercase; letter-spacing: 0.04em; }
.tm-detail-head h3 { margin: 2px 0 0; font-size: 18px; color: #0f172a; }
.tm-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 16px;
}
.tm-detail-note { font-size: 12px; color: #64748b; margin-top: 10px; }
.tm-stat-line { font-size: 13px; color: #334155; margin-top: 10px; line-height: 1.5; }

.tm-stock-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tm-schip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid #cbd5e1;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  color: #0f172a;
}
.tm-schip:hover { border-color: #2563eb; background: #eff6ff; }
.tm-schip .tk { font-weight: 800; }
.tm-schip .nt.good { color: #0f766e; font-weight: 700; }
.tm-schip .nt.bad { color: #be123c; font-weight: 700; }

.tm-posts {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tm-posts li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 9px 11px;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #f8fafc;
}
.tm-post-main {
  flex: 1 1 280px;
  min-width: 0;
}
.tm-post-main a {
  color: #0f172a;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  word-break: break-word;
}
.tm-post-main a:hover { color: #2563eb; text-decoration: underline; }
.tm-post-sub {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tm-post-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

/* Mobile edge list (fallback for matrix on narrow screens) */
.tm-edge-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.tm-edge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 12.5px;
}

.tm-corr-notes {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: #334155;
}

.stage-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
}

@media (max-width: 960px) {
  .tm-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tm-two { grid-template-columns: 1fr; }
  .tm-detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tm-trow {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .tm-tnum {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .tm-kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tm-kpi { padding: 11px 12px; }
  .tm-kpi-v { font-size: 20px; }
}

/* CSP-safe emotion & status colors (no inline style attributes) */
.tm-mt16 { margin-top: 16px; }
.tm-muted { color: #64748b; }
.tm-empty { padding: 14px; color: #64748b; font-size: 13px; }
.sw-good { background: #0ea5a4; }
.sw-mixed { background: #94a3b8; }
.sw-bad { background: #dc2626; }
.pill-bad { background: #ffe4e6; color: #9f1239; border: 1px solid #fecdd3; }
.em-anticipation { background: #0ea5a4; }
.em-admiration { background: #2563eb; }
.em-confidence { background: #16a34a; }
.em-disappointment { background: #d97706; }
.em-failure { background: #dc2626; }
.em-anxiety { background: #9333ea; }
.em-anger { background: #e11d48; }
.em-neutral { background: #94a3b8; }
.tm-sbar-svg { display: block; width: 100%; height: 22px !important; border-radius: 6px; overflow: hidden; }
.tm-clickable { cursor: pointer; }

/* Chains, Radar, Forward Returns, Virtual Positioning */
.sw-dir { background: #f59e0b; }
.tm-chain-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.tm-crow {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 11px;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
}
.tm-crow:hover { background: #f8fafc; border-color: #94a3b8; }
.tm-crow.on { border-color: #2563eb; background: #eff6ff; box-shadow: inset 3px 0 0 #2563eb; }
.tm-crow-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.tm-crow-path {
  font-size: 12.5px;
  color: #334155;
  line-height: 1.45;
}
.tm-crow-path b { color: #0f172a; }
.tm-crow-sub {
  font-size: 11.5px;
  color: #64748b;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tm-pos-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.tm-pkpi {
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.tm-pkpi small { display: block; font-size: 11px; color: #64748b; }
.tm-pkpi b { display: block; font-size: 15px; color: #0f172a; margin-top: 2px; }
.tm-pkpi b.good { color: #0f766e; }
.tm-pkpi b.bad { color: #be123c; }

.tm-corr-box {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: #334155;
}
.tm-sub-details {
  margin-top: 12px;
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
}
.tm-sub-details summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  color: #2563eb;
}
.tm-table-scroll {
  overflow-x: auto;
  margin-top: 8px;
}
.tm-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.tm-tbl th, .tm-tbl td {
  padding: 6px 8px;
  border-bottom: 1px solid #e2e8f0;
  text-align: right;
  white-space: nowrap;
}
.tm-tbl th:first-child, .tm-tbl td:first-child { text-align: left; }
.tm-tbl th { color: #475569; font-weight: 700; background: #f8fafc; }

.tm-kind-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
}
.tm-kind-ind { background: #e0f2fe; color: #0369a1; }
.tm-kind-dir { background: #fef3c7; color: #b45309; }

.sw-ind { background: #2563eb; }

.tm-emo-tabs { margin-bottom: 4px; }
.tm-etab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
}
.tm-etab:hover { border-color: #2563eb; background: #f8fafc; }
.tm-etab.on { border-color: #0f172a; background: #0f172a; color: #fff; }
