/*
  trend-watch.css — 站長管理「趨勢開關」分頁（見 static/trend-watch.js、trend_watch.py）

  只有站長看得到，跟監控清單分頁的清單同一個節奏：一列一檔、列跟列之間一條細線、hover 換底色。
  顏色照 DESIGN.md 的四軸：上升／下跌用紅／綠的字專用色、破底翻用青、開關的「開」用品牌藍
  （互動狀態）。代號、數字用等寬字。token 全部沿用 style.css，亮暗版跟著走。
*/

/* 分頁標題上的「等你決定」數字 */
.tw-tab-badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
}

.tw-industries { margin: -2px 0 10px; font-size: 12.5px; }
.tw-industries summary { width: max-content; color: var(--accent-text); cursor: pointer; }
.tw-industries .hint { margin: 6px 0 0; }

.tw-tools { margin-bottom: 8px; }
.tw-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.tw-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.tw-filter:hover { background: var(--bg-hover); color: var(--text); }
.tw-filter.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tw-filter-n { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 11.5px; opacity: .85; }

.tw-list {
  container: tw-list / inline-size;  /* 一列要排幾欄看清單本身多寬（站長管理是彈窗，跟視窗寬不一定一致） */
  max-height: min(58vh, 620px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.tw-list > .hint { padding: 14px; margin: 0; }

.tw-day + .tw-day { border-top: 1px solid var(--line); }
.tw-day-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin: 0;
  padding: 8px 12px;
  background: var(--bg-raise);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.tw-day-date { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tw-day-counts { font-size: 12px; font-weight: 400; color: var(--text-dim); }

.tw-row {
  display: grid;
  /* 寬度是量過內容的：開關「沒監控」75、均額 78、套牢 66、最長的動作「套牢比 40% 以上，收回」約 131、
     「你打開了」48。加起來（含間距）約 784px，站長管理彈窗的清單寬約 800～813px */
  grid-template-columns: 80px minmax(120px, 1.1fr) 44px minmax(110px, 1.2fr) 84px 70px minmax(140px, auto) minmax(56px, auto);
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 4px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.tw-rows > .tw-row:last-child { border-bottom: none; }
.tw-row:hover { background: var(--bg-hover); }

/* 開關：開＝品牌藍（互動狀態），關＝灰 */
.tw-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.tw-switch:disabled { cursor: progress; opacity: .6; }
.tw-switch-track {
  position: relative;
  flex: none;
  width: 30px;
  height: 17px;
  border-radius: 999px;
  background: var(--line);
  transition: background .15s;
}
.tw-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform .15s, background .15s;
}
.tw-switch[aria-checked="true"] { color: var(--text); }
.tw-switch[aria-checked="true"] .tw-switch-track { background: var(--accent); }
.tw-switch[aria-checked="true"] .tw-switch-knob { transform: translateX(13px); background: var(--accent-ink); }

.tw-stock {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  padding: 2px 0;
  border: none;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.tw-stock:hover .tw-name { text-decoration: underline; text-underline-offset: 3px; }
.tw-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw-code { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-mute); }

.tw-trend {
  justify-self: start;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}
.tw-trend.up { color: var(--up-text); background: var(--up-soft); }
.tw-trend.down { color: var(--down-text); background: var(--down-soft); }

.tw-group { min-width: 0; color: var(--text-dim); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw-theme { color: var(--text-mute); }
.tw-turnover, .tw-supply { font-size: 12px; color: var(--text-mute); white-space: nowrap; }
.tw-turnover b, .tw-supply b { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; color: var(--text-dim); }
.tw-action { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; }
.tw-action.withdrawn { color: var(--text-mute); }
.tw-action.review { color: var(--text); font-weight: 600; }
.tw-action.kept { color: var(--rebound-text); }
.tw-action.held, .tw-action.big, .tw-action.big_open { color: var(--text); }
/* 年線還往下、頭頭低：接在「上升，等你決定」下面一行小字（滑過去有完整說明） */
.tw-why { display: block; font-size: 11.5px; font-weight: 400; color: var(--text-mute); line-height: 1.3; }
.tw-owner { font-size: 12px; color: var(--text-mute); white-space: nowrap; }

/* 清單不夠寬（手機、平板直放）：開關＋股名一行，其他接在下一行。
   一行排完要約 784px（見 .tw-row），不夠就換這個排法，不要擠到字疊在一起或橫向捲動 */
@container tw-list (max-width: 790px) {
  .tw-row {
    grid-template-columns: auto 1fr auto;
    gap: 2px 10px;
    padding: 6px 12px;
  }
  .tw-trend { justify-self: end; }
  .tw-group { grid-column: 2 / 3; grid-row: 2; }
  .tw-turnover { grid-column: 3 / 4; grid-row: 2; justify-self: end; }
  .tw-supply { grid-column: 3 / 4; grid-row: 3; justify-self: end; }
  .tw-owner { grid-column: 2 / 3; grid-row: 4; }
  .tw-action { grid-column: 2 / 3; grid-row: 3; }
  .tw-switch-text { display: none; }
  .tw-switch { min-height: 44px; }
}
