@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@600;700&family=IBM+Plex+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Noto+Sans+TC:wght@400;500;700&family=Noto+Serif+TC:wght@600;700&display=swap");

:root {
  --bg: #0f1419;
  --surface: #1a212a;
  --surface-2: #151b23;
  --surface-3: #202a35;
  --ink: #e6e9ed;
  --muted: #8b9099;
  --dim: #5f6874;
  --hair: #2a3038;
  --gold: #d4a558;
  --red: #d65a5a;
  --green: #3fa86a;
  --blue: #7aa2f7;
  --shadow: 0 18px 70px rgba(0, 0, 0, .22);
  --sticky-table-top: 78px;
  --sticky-first-col: 56px;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.45;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 0%, rgba(212,165,88,.085), transparent 24rem),
    linear-gradient(180deg, rgba(255,255,255,.026), transparent 34rem),
    var(--bg);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.shell {
  width: min(1220px, calc(100vw - 32px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 20, 25, .91);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hair);
}

.site-header-inner {
  min-height: 76px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  border-top: 1px solid var(--gold);
}

.brand {
  font-family: "Cormorant Garamond", "Noto Serif TC", serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 40px;
  border: 1px solid var(--hair);
  background: rgba(21,27,35,.86);
  color: var(--ink);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
}

.nav-toggle span {
  width: 18px;
  height: 2px;
  background: currentColor;
  display: block;
}

.nav-toggle.open { border-color: rgba(212,165,88,.7); color: var(--gold); }

.nav {
  display: flex;
  justify-content: flex-end;
  gap: 28px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .06em;
}

.nav a {
  padding: 26px 0 24px;
  border-bottom: 2px solid transparent;
}

.nav a.active {
  color: var(--ink);
  border-color: var(--gold);
}

.search-box {
  position: relative;
  width: min(340px, 28vw);
}

.search-input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--hair);
  background: rgba(21, 27, 35, .86);
  color: var(--ink);
  padding: 0 14px 0 42px;
  outline: none;
}

.search-input:focus { border-color: rgba(212,165,88,.7); }
.search-input::placeholder { color: var(--dim); }

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--gold);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 360px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--hair);
  box-shadow: var(--shadow);
  display: none;
}

.search-results.open { display: block; }

.search-result {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 12px;
  border-bottom: 1px solid rgba(42,48,56,.72);
}

.search-result:hover { background: rgba(255,255,255,.045); }
.search-result small { color: var(--muted); }

.main { padding: 34px 0 54px; }

.masthead {
  border-bottom: 1px solid var(--hair);
  padding: 18px 0 26px;
  margin-bottom: 28px;
}

.kicker, .eyebrow, .label {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .15em;
  font-size: 11px;
  font-weight: 700;
}

h1, h2, h3, p { margin: 0; }

.display-title {
  font-family: "Cormorant Garamond", "Noto Serif TC", serif;
  font-size: clamp(46px, 7vw, 74px);
  line-height: .95;
  font-weight: 700;
  letter-spacing: .01em;
  margin-top: 12px;
}

.deck {
  color: var(--muted);
  font-size: 16px;
  max-width: 760px;
  margin-top: 12px;
}

.gold-rule {
  width: 96px;
  height: 2px;
  background: var(--gold);
  margin-top: 18px;
}

.grid-12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.kpi-card, .panel, .card, .callout {
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.018));
  border: 1px solid var(--hair);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}

.kpi-card {
  min-height: 112px;
  padding: 18px;
}

.kpi-value {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 28px;
  font-weight: 600;
  margin-top: 10px;
}

.kpi-caption {
  color: var(--muted);
  font-size: 12px;
  margin-top: 7px;
}

.panel {
  padding: 22px;
  margin-bottom: 24px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--hair);
  padding-bottom: 12px;
  margin-bottom: 18px;
}

.section-title {
  font-family: "Cormorant Garamond", "Noto Serif TC", serif;
  font-size: 34px;
  line-height: 1;
}

.meta-line {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.layout-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
}

.signals-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.signal-card, .performer-card {
  background: rgba(15,20,25,.35);
  border: 1px solid var(--hair);
  padding: 14px;
}

.badge {
  display: inline-block;
  border: 1px solid rgba(212,165,88,.55);
  color: var(--gold);
  padding: 2px 7px;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.stock-code {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 600;
}

.signal-code {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 18px;
  font-weight: 600;
  margin-top: 12px;
}

.signal-name {
  color: #cfd5dc;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.signal-foot, .performer-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--hair);
  margin-bottom: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--hair) transparent;
}

.tab-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: "JetBrains Mono", Consolas, monospace;
  padding: 0 0 11px;
  border-bottom: 2px solid transparent;
  flex: 0 0 auto;
}

.tab-btn.active {
  color: var(--ink);
  border-color: var(--gold);
}

.performer-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.callout {
  padding: 22px;
}

.callout strong {
  display: block;
  font-family: "Cormorant Garamond", "Noto Serif TC", serif;
  font-size: 34px;
  line-height: 1.08;
  font-weight: 700;
}

.callout p {
  color: #cfd5dc;
  margin-top: 14px;
}

.mini-stat {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  color: var(--muted);
  border-top: 1px solid var(--hair);
  padding-top: 13px;
  margin-top: 15px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.select, .filter-input {
  width: 100%;
  height: 42px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--hair);
  padding: 0 12px;
  outline: none;
}

.select:focus, .filter-input:focus { border-color: rgba(212,165,88,.7); }

.table-wrap, .table-scroll {
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--hair);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.table-wrap::before {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: var(--table-min, 860px);
}

/* Compact tables (e.g. 三大法人 5 columns) don't need 860px and break phone
   layouts when forced wide. Override the global min-width entirely so they
   shrink to fit any container. */
.stocks-table { --table-min: 920px; }
.signals-table { --table-min: 980px; }
.signals-table-v2 { --table-min: 1580px; }
.volume-table { --table-min: 1500px; }
.intraday-table { --table-min: 1530px; }

/* Intraday page (alos 2026-05-04: 股票 split into 代號 + 名稱). 15 cols:
   # / 時間 / 代號 / 名稱 / 訊號 / 現價 / 量比 / 基期 / 突破MA / MA5..60 / 今累 / 昨日量. */
.intraday-table th:first-child,
.intraday-table td:first-child { width: 48px; }
.intraday-table th:nth-child(2),
.intraday-table td:nth-child(2) { width: 76px; }    /* 時間 HH:MM:SS */
.intraday-table th:nth-child(3),
.intraday-table td:nth-child(3) { width: 88px; }    /* 代號 */
.intraday-table th:nth-child(4),
.intraday-table td:nth-child(4) { width: 140px; }   /* 名稱 */
.intraday-table th:nth-child(5),
.intraday-table td:nth-child(5) { width: 96px; }    /* 訊號 */
.intraday-table th:nth-child(n+6),
.intraday-table td:nth-child(n+6) { width: 110px; }
.intraday-table th:nth-child(8),
.intraday-table td:nth-child(8) { width: 78px; }    /* 基期 */
.intraday-table th:nth-child(9),
.intraday-table td:nth-child(9) { width: 132px; }   /* 突破 MA */

.dir-badge {
  font-weight: 700;
}
/* Taiwan candle convention 紅漲綠跌 for the dir-badge — separate from the
   ma-break ✓/✗ icons (which alos asked to be green-good / red-bad). */
.dir-badge.dir-pos { color: var(--red); border-color: rgba(217, 83, 79, .42); background: rgba(217, 83, 79, .12); }
.dir-badge.dir-neg { color: var(--green); border-color: rgba(60, 180, 75, .42); background: rgba(60, 180, 75, .10); }
.dir-badge.dir-mixed { color: var(--gold); border-color: rgba(212, 175, 55, .42); background: rgba(212, 175, 55, .12); }
.trades-table { --table-min: 760px; }
.three-law-table { --table-min: 520px; }

.table-wrap.sticky-first,
.table-wrap.sticky-first-two,
.table-wrap.scroll-affordance {
  box-shadow: inset -18px 0 16px -18px rgba(0, 0, 0, .55);
}

th {
  color: var(--muted);
  background: rgba(15,20,25,.42);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 11px 10px;
  border-bottom: 1px solid var(--hair);
}

td {
  color: #dbe0e6;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(42,48,56,.74);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

tr:nth-child(even) td { background: rgba(255,255,255,.035); }
tr:hover td { background: rgba(212,165,88,.05); }

.sticky-first th:first-child,
.sticky-first td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface-2);
  box-shadow: 1px 0 0 var(--hair);
}

.sticky-first th:first-child {
  z-index: 3;
  background: #111820;
}

.sticky-first-two th:first-child,
.sticky-first-two td:first-child {
  position: sticky;
  left: 0;
  width: var(--sticky-first-col);
  min-width: var(--sticky-first-col);
  max-width: var(--sticky-first-col);
  z-index: 2;
  background: var(--surface-2);
  box-shadow: 1px 0 0 var(--hair);
}

.sticky-first-two th:nth-child(2),
.sticky-first-two td:nth-child(2) {
  position: sticky;
  left: var(--sticky-first-col);
  z-index: 2;
  background: var(--surface-2);
  box-shadow: 1px 0 0 var(--hair);
}

.sticky-first-two th:first-child,
.sticky-first-two th:nth-child(2) {
  z-index: 3;
  background: #111820;
}

/* Volume page (alos 2026-05-04: 股票 col split into 代號 + 名稱). 14 cols:
   # / 代號 / 名稱 / 收盤 / 量比 / 基期 / 突破MA / MA5..60 / 20日均量 / 昨 / 今. */
.volume-table th:first-child,
.volume-table td:first-child { width: 48px; }
.volume-table th:nth-child(2),
.volume-table td:nth-child(2) { width: 88px; }    /* 代號 */
.volume-table th:nth-child(3),
.volume-table td:nth-child(3) { width: 150px; }   /* 名稱 */
.volume-table th:nth-child(n+4),
.volume-table td:nth-child(n+4) { width: 110px; }
.volume-table th:nth-child(6),
.volume-table td:nth-child(6) { width: 78px; }    /* 基期 */
.volume-table th:nth-child(7),
.volume-table td:nth-child(7) { width: 132px; }   /* 突破 MA */

/* Signals page (alos 2026-05-04: 股票 split into 代號 + 名稱). 15 cols:
   # / 代號 / 名稱 / 信號 / 收盤 / 量比 / 基期 / 突破MA / MA5..60 / 均量 / 昨 / 今. */
.signals-table-v2 th:first-child,
.signals-table-v2 td:first-child { width: 48px; }
.signals-table-v2 th:nth-child(2),
.signals-table-v2 td:nth-child(2) { width: 88px; }   /* 代號 */
.signals-table-v2 th:nth-child(3),
.signals-table-v2 td:nth-child(3) { width: 150px; }  /* 名稱 */
.signals-table-v2 th:nth-child(4),
.signals-table-v2 td:nth-child(4) { width: 80px; }   /* 信號 (just numbers) */
.signals-table-v2 th:nth-child(n+5),
.signals-table-v2 td:nth-child(n+5) { width: 110px; }
.signals-table-v2 th:nth-child(7),
.signals-table-v2 td:nth-child(7) { width: 78px; }   /* 基期 */
.signals-table-v2 th:nth-child(8),
.signals-table-v2 td:nth-child(8) { width: 132px; }  /* 突破 MA */

/* alos 2026-05-04: cells use plain ✓/✗ icons in a 4-col grid (order 5/10/20/60).
   Header is just "突破 MA" — no sub-row labels (alos: "我看的懂"). */
.ma-break-cell {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  text-align: center;
}
.ma-break {
  font-size: 14px;
  font-weight: 700;
  font-family: "JetBrains Mono", Consolas, monospace;
  text-align: center;
}
/* alos override: green ✓ = breakthrough (good), red ✗ = no breakthrough (bad).
   Taiwan candle convention is 紅漲綠跌 but for status icons alos asked the
   opposite — green check / red cross — matches Western "success/fail" UI. */
.ma-break.ok { color: #22c55e; }       /* green ✓ */
.ma-break.no { color: #ef4444; }       /* red ✗ */
.signal-badge {
  background: rgba(212, 175, 55, .14);
  border-color: rgba(212, 175, 55, .42);
  color: var(--gold);
  font-weight: 700;
}

.chg-pct {
  font-size: 11px;
  margin-top: 2px;
}
/* Taiwan convention 紅漲綠跌 — same as candle colors. */
.chg-pct.pos { color: var(--red); }
.chg-pct.neg { color: var(--green); }

@media (max-width: 480px) {
  /* All three tables now use split 代號/名稱 cols (alos 2026-05-04). */
  .volume-table th:first-child,
  .volume-table td:first-child { width: 36px; }
  .volume-table th:nth-child(2),
  .volume-table td:nth-child(2) { width: 70px; }    /* 代號 */
  .volume-table th:nth-child(3),
  .volume-table td:nth-child(3) { width: 110px; }   /* 名稱 */
  .volume-table th:nth-child(n+4),
  .volume-table td:nth-child(n+4) { width: 90px; }
  .volume-table th:nth-child(6),
  .volume-table td:nth-child(6) { width: 64px; }    /* 基期 */
  .volume-table th:nth-child(7),
  .volume-table td:nth-child(7) { width: 116px; }   /* 突破 MA */
  .volume-table { --table-min: 1230px; }

  .signals-table-v2 th:first-child,
  .signals-table-v2 td:first-child { width: 36px; }
  .signals-table-v2 th:nth-child(2),
  .signals-table-v2 td:nth-child(2) { width: 70px; }   /* 代號 */
  .signals-table-v2 th:nth-child(3),
  .signals-table-v2 td:nth-child(3) { width: 110px; }  /* 名稱 */
  .signals-table-v2 th:nth-child(4),
  .signals-table-v2 td:nth-child(4) { width: 64px; }   /* 信號 */
  .signals-table-v2 th:nth-child(n+5),
  .signals-table-v2 td:nth-child(n+5) { width: 90px; }
  .signals-table-v2 th:nth-child(7),
  .signals-table-v2 td:nth-child(7) { width: 64px; }   /* 基期 */
  .signals-table-v2 th:nth-child(8),
  .signals-table-v2 td:nth-child(8) { width: 116px; }  /* 突破 MA */
  .signals-table-v2 { --table-min: 1280px; }

  .intraday-table th:first-child,
  .intraday-table td:first-child { width: 36px; }
  .intraday-table th:nth-child(2),
  .intraday-table td:nth-child(2) { width: 64px; }    /* 時間 */
  .intraday-table th:nth-child(3),
  .intraday-table td:nth-child(3) { width: 70px; }    /* 代號 */
  .intraday-table th:nth-child(4),
  .intraday-table td:nth-child(4) { width: 110px; }   /* 名稱 */
  .intraday-table th:nth-child(5),
  .intraday-table td:nth-child(5) { width: 80px; }    /* 訊號 */
  .intraday-table th:nth-child(n+6),
  .intraday-table td:nth-child(n+6) { width: 90px; }
  .intraday-table th:nth-child(8),
  .intraday-table td:nth-child(8) { width: 64px; }    /* 基期 */
  .intraday-table th:nth-child(9),
  .intraday-table td:nth-child(9) { width: 116px; }   /* 突破 MA */
  .intraday-table { --table-min: 1280px; }
}

/* sticky-head disabled — caused row 2 to vanish on phone scroll because the
   header overlapped the first data row. Vertical sticky headers add too much
   complexity for this UX (interaction with sticky site-header). Class is kept
   in HTML for future use but the CSS rule is a no-op. */
.sticky-head thead th {
  background: #111820;
}

.sticky-head.sticky-first th:first-child,
.sticky-head.sticky-first-two th:first-child,
.sticky-head.sticky-first-two th:nth-child(2) {
  z-index: 5;
}

.num, .money, .pct, .price {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.pos { color: var(--green) !important; font-weight: 700; }
.neg { color: var(--red) !important; font-weight: 700; }
.muted { color: var(--muted) !important; }
.gold { color: var(--gold) !important; }

.stock-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: end;
  border-bottom: 1px solid var(--hair);
  padding-bottom: 24px;
  margin-bottom: 20px;
}

.market-header {
  align-items: center;
  background: rgba(15,20,25,.72);
  border: 1px solid var(--hair);
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(180px, .35fr) minmax(0, 1fr);
  margin: 0 0 14px;
  padding: 10px 12px;
}

.market-header span,
.market-header .market-stats span {
  color: var(--muted);
  display: block;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.market-header strong {
  color: var(--ink);
  display: block;
  font-size: 20px;
  margin-top: 2px;
}

.market-stats {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.market-stats > div {
  border-left: 1px solid rgba(42,48,56,.86);
  min-width: 0;
  padding-left: 10px;
}

.market-stats b {
  color: var(--ink);
  display: block;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-dashboard-grid {
  align-items: start;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr);
  max-width: 100%;
}

.dashboard-left,
.dashboard-right {
  display: grid;
  gap: 14px;
  min-width: 0;
}

/* Force panels and tables to honor parent column width on phones — table
   min-width was bleeding through grid auto sizing and pushing the whole
   dashboard wider than the viewport. */
.dashboard-left .panel,
.dashboard-right .panel {
  min-width: 0;
  max-width: 100%;
}

.dashboard-left .table-wrap,
.dashboard-right .table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dashboard-right .panel,
.dashboard-left .panel {
  margin: 0;
}

.dashboard-right .panel {
  padding: 14px;
}

.dashboard-right .section-title {
  font-size: 21px;
}

.dashboard-fullspan {
  grid-column: 1 / -1;
  margin: 0;
}

.detail-code {
  font-family: "Cormorant Garamond", "Noto Serif TC", serif;
  font-size: clamp(68px, 12vw, 112px);
  line-height: .88;
}

.detail-name {
  font-size: 26px;
  color: #cfd5dc;
  margin-top: 8px;
}

.detail-meta {
  color: var(--muted);
  font-size: 15px;
  margin-top: 8px;
}

.detail-kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.detail-kpis .kpi-card {
  min-height: 100px;
  padding: 15px;
}

.detail-kpis .kpi-value { font-size: 22px; }

.chart-section {
  background: #0f1419 !important;
}

.chart-panel {
  width: 100%;
  height: 560px;
  border: 1px solid var(--hair);
  background: transparent !important;
  padding: 0 !important;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.chart-panel,
.chart-panel * {
  -webkit-tap-highlight-color: transparent !important;
}

.chart-panel .chart-legend {
  pointer-events: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

.tv-lightweight-charts a,
.tv-lightweight-charts a[href*="tradingview"],
.chart-panel a,
.chart-panel a[href*="tradingview"],
#tv-attr-logo,
a[id^="tv-attr"],
div[class*="tv-lightweight-charts"] a {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

.evolution-chart {
  height: 280px;
  border: 1px solid var(--hair);
  background:
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,.035) 1px, transparent 1px),
    rgba(15,20,25,.28);
  background-size: 120px 100%, 100% 70px, auto;
}

.chart-note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}

.summary-list {
  display: grid;
  gap: 8px;
}

.summary-row {
  align-items: center;
  border-bottom: 1px solid rgba(42,48,56,.68);
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 12px;
  padding: 5px 0;
}

.summary-row > *:last-child {
  text-align: right;
  justify-self: end;
}

/* Phone: stack label/value vertically to avoid horizontal overflow when the
   right column gets pushed off-screen by sibling tables/min-width rules. */
@media (max-width: 480px) {
  .summary-row {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 7px 0;
  }
  .summary-row > *:last-child {
    text-align: left;
    justify-self: start;
  }
}

.summary-row span {
  color: var(--muted);
  font-size: 12px;
}

.summary-row b,
.summary-row .summary-value {
  color: var(--ink);
  font-family: "IBM Plex Sans", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
}

.summary-verdict,
.risk-note {
  border: 1px solid rgba(212,165,88,.42);
  color: var(--gold);
  font-size: 12px;
  margin-top: 6px;
  padding: 8px 10px;
}

.score-line {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
}

.score-line b {
  color: var(--gold);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 34px;
}

.score-line span {
  color: var(--muted);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
}

.score-bar,
.prob-bar {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(42,48,56,.86);
  height: 9px;
  overflow: hidden;
}

.score-bar span,
.prob-bar i {
  background: var(--gold);
  display: block;
  height: 100%;
}

.prob-list {
  display: grid;
  gap: 10px;
}

.prob-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
}

.prob-row span,
.prob-row b {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
}

.prob-row b {
  color: var(--ink);
  text-align: right;
}

.prob-bar.pos i { background: var(--green); }
.prob-bar.neg i { background: var(--red); }
.prob-bar.gold i { background: var(--gold); }

.multi-period-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.multi-period-grid > div {
  height: 200px;
  border: 1px solid var(--hair);
  position: relative;
  overflow: hidden;
  background: #0f1419;
}

.mini-placeholder {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  height: 100%;
  place-items: center;
}

.mini-chart-label {
  background: rgba(15,20,25,.78);
  border: 1px solid rgba(42,48,56,.8);
  color: var(--ink);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11px;
  left: 8px;
  padding: 3px 7px;
  pointer-events: none;
  position: absolute;
  top: 8px;
  z-index: 5;
}

.key-levels, .patterns {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-family: "JetBrains Mono", Consolas, monospace;
}

.kl-pressure, .kl-retrace, .kl-support, .patterns > div {
  padding: 8px 12px;
  border: 1px solid var(--hair);
}

.kl-pressure { color: var(--red); }
.kl-support { color: var(--green); }
.kl-retrace { color: var(--gold); }

.three-law-table {
  --table-min: 520px;
}

.error-box, .loading {
  color: var(--muted);
  padding: 26px;
  border: 1px solid var(--hair);
  background: var(--surface);
}

.footer {
  color: var(--muted);
  border-top: 1px solid var(--hair);
  padding: 18px 0 28px;
  margin-top: 28px;
  font-size: 12px;
}

.footer .shell {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

@media (max-width: 900px) {
  :root {
    --sticky-table-top: 120px;
  }
  .market-header,
  .stock-dashboard-grid {
    grid-template-columns: 1fr;
  }
  .market-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .site-header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 14px 0;
  }
  .brand { font-size: 24px; }
  .nav-toggle { display: flex; justify-self: end; }
  .search-box {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
  }
  .nav {
    display: none;
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 4px;
  }
  .nav.open { display: flex; }
  .nav a {
    padding: 9px 12px;
    border: 1px solid var(--hair);
    background: rgba(21,27,35,.52);
  }
  .nav a.active { border-color: var(--gold); }
}

@media (max-width: 768px) {
  .shell {
    width: min(100% - 24px, 1220px);
  }
  .main { padding: 24px 0 42px; }
  .masthead {
    padding: 12px 0 20px;
    margin-bottom: 20px;
  }
  .display-title {
    font-size: clamp(40px, 11vw, 58px);
  }
  .deck { font-size: 15px; }
  .panel {
    padding: 16px;
    margin-bottom: 18px;
  }
  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
  .section-title { font-size: 30px; }
  .kpi-grid, .signals-grid, .performer-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filters-secondary {
    grid-template-columns: minmax(0, 1fr) minmax(180px, .65fr) !important;
  }
  .layout-main, .stock-hero {
    grid-template-columns: 1fr;
  }
  .detail-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .detail-code {
    font-size: clamp(58px, 18vw, 86px);
  }
  .detail-name { font-size: 22px; }
  .tabs {
    gap: 16px;
    padding-bottom: 2px;
  }
  .layout-main, .stock-hero {
    grid-template-columns: 1fr;
  }
  .chart-panel { height: 460px; }
  .multi-period-grid { grid-template-columns: 1fr; }
  .market-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .evolution-chart { height: 250px; }
  table { --table-min: 760px; }
  .stocks-table { --table-min: 1100px; }
  .signals-table { --table-min: 1300px; }
  .signals-table-v2 { --table-min: 1900px; }
  .intraday-table { --table-min: 1900px; }
  .volume-table { --table-min: 1900px; }
  .trades-table { --table-min: 920px; }
  .footer .shell { flex-direction: column; }
}

@media (max-width: 480px) {
  :root {
    --sticky-table-top: 104px;
    /* Match phone col 1 width so sticky col 2's left offset doesn't leave
       a 20px gap that exposes col 3 underneath. */
    --sticky-first-col: 36px;
  }
  .shell {
    width: min(100% - 20px, 1220px);
  }
  .site-header-inner {
    min-height: auto;
    padding: 12px 0;
  }
  .brand {
    font-size: 20px;
    white-space: normal;
    line-height: 1.05;
  }
  .nav a {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
  }
  .search-input { height: 38px; }
  .main { padding: 18px 0 34px; }
  .masthead {
    padding: 8px 0 16px;
    margin-bottom: 16px;
  }
  .display-title {
    font-size: clamp(34px, 14vw, 48px);
    line-height: 1;
  }
  .deck { font-size: 14px; }
  .gold-rule { margin-top: 14px; }
  .kpi-grid, .signals-grid, .performer-list, .filters {
    grid-template-columns: 1fr;
  }
  .filters-secondary {
    grid-template-columns: 1fr !important;
  }
  .kpi-card {
    min-height: auto;
    padding: 14px;
  }
  .kpi-value { font-size: 23px; }
  .panel {
    padding: 12px;
  }
  .section-title { font-size: 26px; }
  .signal-card, .performer-card, .callout {
    padding: 12px;
  }
  .callout strong { font-size: 28px; }
  .detail-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .detail-kpis .kpi-card {
    min-height: 86px;
    padding: 12px;
  }
  .detail-kpis .kpi-value { font-size: 18px; }
  .detail-code {
    font-size: clamp(50px, 23vw, 72px);
  }
  .detail-name { font-size: 20px; }
  .detail-meta { font-size: 13px; }
  .tabs {
    gap: 18px;
    margin-left: -2px;
    margin-right: -2px;
  }
  .tab-btn {
    padding-bottom: 10px;
    min-width: 54px;
  }
  .chart-panel {
    height: 380px;
  }
  .evolution-chart {
    height: 220px;
  }
  [data-kbar-controls] {
    align-items: flex-start !important;
    flex-direction: column !important;
    gap: 8px !important;
    font-size: 10px !important;
    padding: 8px !important;
  }
  .hide-on-phone {
    display: none !important;
  }
  .table-wrap.sticky-first::before,
  .table-wrap.sticky-first-two::before,
  .table-wrap.scroll-affordance::before {
    /* CSS ::before with CJK content can fall back to an icon-only font on
       some Edge/iOS combos. Use ASCII so the hint is always readable. */
    content: "← swipe to see more cols →";
    display: block;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .04em;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(42,48,56,.74);
    background: rgba(15,20,25,.42);
    text-align: center;
  }
  table {
    --table-min: 620px;
  }
  .stocks-table {
    --table-min: 1100px;
  }
  .signals-table {
    --table-min: 1300px;
  }
  .volume-table {
    --table-min: 1130px;
  }
  .trades-table {
    --table-min: 920px;
  }
  th, td {
    padding: 10px 8px;
    font-size: 12px;
  }
  .badge {
    padding: 2px 5px;
  }
  .chart-note {
    font-size: 11px;
  }
  .footer {
    padding-bottom: 22px;
  }
}
