/* todayygg — KRX 신뢰감 + 토스형 카드 레이아웃 · 국내식 상승=빨강 / 하락=파랑 */

:root {
  --navy-900: #0a1f44;
  --navy-800: #12325f;
  --navy-700: #1a4a8c;
  --navy-600: #2563a8;
  --bg-page: #eef1f6;
  --bg-card: #ffffff;
  --bg-muted: #f7f9fc;
  --border: #dce3ed;
  --border-light: #e8edf4;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --up: #d60036;
  --up-bg: #fff5f7;
  --down: #0051c7;
  --down-bg: #f3f8ff;
  --shadow-sm: 0 1px 2px rgba(10, 31, 68, 0.04);
  --shadow-md: 0 4px 16px rgba(10, 31, 68, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.num,
table,
.kpi .value,
.filters button,
.seg button {
  font-variant-numeric: tabular-nums;
}

.date-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.date-toolbar .filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.date-picker-wrap {
  position: relative;
  flex: 0 0 auto;
}

.date-pick-toggle {
  min-width: 4.5rem;
  text-align: center;
}

.trade-calendar-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 200;
  width: 328px;
  box-sizing: border-box;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
}

.trade-calendar-popover.hidden {
  display: none;
}

.trade-calendar {
  width: 100%;
  padding: 16px;
  box-sizing: border-box;
  background: var(--bg-card);
  border-radius: var(--radius);
}

.calendar-empty {
  margin: 0;
  font-size: 0.9rem;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.cal-title {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.trade-calendar .cal-nav {
  width: 2.25rem;
  height: 2.25rem;
  min-width: 2.25rem;
  padding: 0;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-muted);
  color: var(--navy-800);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}

.trade-calendar .cal-nav:hover {
  border-color: var(--navy-600);
  background: #fff;
}

.cal-weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 2.5rem);
  gap: 6px;
  justify-content: center;
  width: 100%;
}

.cal-weekdays {
  margin-bottom: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.cal-weekdays span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 1.25rem;
}

.cal-weekdays span:first-child {
  color: var(--up);
}

.cal-weekdays span:last-child {
  color: var(--down);
}

.cal-grid {
  margin-bottom: 8px;
}

.cal-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 0.875rem;
  box-sizing: border-box;
}

.cal-cell--pad {
  visibility: hidden;
  pointer-events: none;
}

.trade-calendar .cal-day {
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  cursor: pointer;
  box-sizing: border-box;
}

/* manifest에 없는 날·선택 불가: 기본 회색 */
.trade-calendar .cal-day:not([data-ymd]) {
  color: #9ca3af;
  background: #eceff4;
  cursor: not-allowed;
  user-select: none;
  font-weight: 500;
}

.trade-calendar .cal-day.cal-day--no-snapshot:not([data-ymd]) {
  color: #9ca3af;
  background: #eceff4;
}

/* 토·일 휴장: 빨강 */
.trade-calendar .cal-day.cal-day--holiday:not([data-ymd]) {
  color: var(--up);
  background: var(--up-bg);
  font-weight: 600;
}

.trade-calendar .cal-day.cal-day--selected {
  background: var(--navy-800);
  color: #fff;
  font-weight: 600;
}

.trade-calendar .cal-day[data-ymd]:not(.cal-day--selected):hover {
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.cal-hint {
  margin: 0;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
}

.cal-legend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
}

.cal-legend::before {
  content: "";
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.cal-legend--holiday {
  color: var(--up);
}

.cal-legend--holiday::before {
  background: var(--up-bg);
  box-shadow: inset 0 0 0 1.5px var(--up);
}

.cal-legend--no-snapshot {
  color: #6b7280;
}

.cal-legend--no-snapshot::before {
  background: #eceff4;
  box-shadow: inset 0 0 0 1.5px #c5cdd8;
}

.cal-hint-note {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.72rem;
}

@media (max-width: 720px) {
  .filter-toolbar__divider {
    display: none;
  }

  .filter-toolbar {
    gap: 8px;
    padding: 8px;
  }

  .filter-group {
    flex: 1 1 100%;
    justify-content: space-between;
  }

  .investor-nav button {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .trade-calendar-popover {
    left: auto;
    right: 0;
    width: min(328px, calc(100vw - 28px));
  }

  .cal-weekdays,
  .cal-grid {
    grid-template-columns: repeat(7, minmax(2.15rem, 1fr));
    gap: 4px;
  }

  .cal-cell,
  .trade-calendar .cal-day {
    width: 100%;
    height: 2.15rem;
    min-width: 0;
    min-height: 2.15rem;
  }
}

/* 상단 KRX 스타일 헤더 바 */
.site-header {
  background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-800) 100%);
  color: #fff;
  padding: 0;
  margin: 0 0 28px;
  box-shadow: var(--shadow-md);
}

.site-header__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 28px 24px;
}

.site-header__brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.site-header__logo {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.site-header__tag {
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.75;
  letter-spacing: 0.02em;
}

.site-header__subtitle {
  margin: 10px 0 0;
  font-size: 0.9rem;
  font-weight: 400;
  opacity: 0.88;
  line-height: 1.5;
}

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 28px 32px;
}

.site-footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 28px 40px;
  border-top: 1px solid var(--border-light);
}

.site-footer__inner {
  max-width: 720px;
}

.site-footer p {
  margin: 0 0 6px;
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.site-footer p:last-child {
  margin-bottom: 0;
}

/* 상단 툴바 스택 — 레이어별 카드 분리 */
.toolbar-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

/* 1) 투자자 탭 */
.investor-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.investor-nav button {
  flex: 1 1 auto;
  min-width: 5.5rem;
  font-family: var(--font);
  border: 1px solid transparent;
  background: var(--bg-muted);
  color: var(--text-secondary);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.investor-nav button:hover {
  background: #fff;
  color: var(--text-primary);
  border-color: var(--border);
}

.investor-nav button.active {
  background: var(--navy-800);
  color: #fff;
  border-color: var(--navy-800);
  box-shadow: var(--shadow-sm);
}

/* 2) 기준일 · 시장 — 얇은 한 줄 바 */
.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 0;
  padding: 5px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.filter-toolbar__divider {
  width: 1px;
  height: 1.25rem;
  background: var(--border);
  margin: 0 6px;
  flex-shrink: 0;
}

.filter-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
}

.filter-group__label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.filters--compact button,
.filters--compact .date-pick-toggle {
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  min-height: 0;
}

/* 3) 섹션 표시 토글 */
.section-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: #eef2f8;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.section-toggles [data-section].hidden {
  display: none;
}

.section-toggles button {
  font-family: var(--font);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.section-toggles button:hover {
  border-color: var(--navy-600);
  color: var(--text-primary);
}

.section-toggles button.active {
  background: var(--navy-700);
  color: #fff;
  border-color: var(--navy-700);
}

/* 공통 필터 버튼 (달력·스냅샷 등) */
.filters button,
.filters input[type="date"],
.date-pick-toggle {
  font-family: var(--font);
  border: 1px solid var(--border-light);
  background: #fff;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filters button:hover,
.date-pick-toggle:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
  border-color: var(--border);
}

.filters button.active,
.date-pick-toggle.active {
  background: var(--navy-700);
  color: #fff;
  border-color: var(--navy-700);
}

.card-bar.seg {
  display: none;
}

/* 종목 점수 패널 */
.scores-panel {
  padding: 24px;
}

.scores-subnav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  width: 100%;
}

.scores-subnav__btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.scores-subnav__btn:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.scores-subnav__btn.active {
  background: var(--navy-800);
  color: #fff;
  border-color: var(--navy-800);
}

.scores-subnav__spacer {
  flex: 1;
  min-width: 8px;
}

.scores-investor-toggle {
  display: inline-flex;
  gap: 4px;
}

.scores-investor-toggle__btn {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
}

.scores-investor-toggle__btn.active {
  background: var(--navy-800);
  color: #fff;
  border-color: var(--navy-800);
}

.scores-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
}

.scores-search-toggle {
  width: auto;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  color: var(--text-secondary);
  cursor: pointer;
}

.scores-search-toggle:hover {
  background: #fff;
  color: var(--navy-700);
  border-color: var(--navy-600);
}

.scores-search-toggle.hidden {
  display: none;
}

body.scores-search-open {
  overflow: hidden;
}

.scores-search-popup {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 16px 24px;
}

.scores-search-popup.hidden {
  display: none;
}

.scores-search-popup__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(15, 23, 42, 0.42);
  cursor: pointer;
}

.scores-search-popup__panel {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: min(72vh, 560px);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.scores-search-popup__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-muted);
}

.scores-search-popup__head .scores-search {
  flex: 1;
  min-width: 0;
  margin: 0;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg-card);
  color: var(--text-primary);
}

.scores-search-popup__head .scores-search:focus {
  outline: none;
  border-color: var(--navy-600);
  box-shadow: 0 0 0 2px rgba(37, 99, 168, 0.12);
}

.scores-search-popup__close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.scores-search-popup__close:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.scores-search-popup__empty {
  padding: 14px 16px;
  margin: 0;
  border-bottom: 1px solid var(--border-light);
}

.scores-search-popup__list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  max-height: min(56vh, 480px);
}

.scores-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.scores-explain-title {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.scores-explain-table-wrap {
  margin-top: 12px;
}

.scores-explain-table th,
.scores-explain-table td {
  font-size: 0.85rem;
  vertical-align: top;
  text-align: left;
  white-space: normal;
}

.scores-explain-table th {
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.scores-explain-table td:first-child {
  width: 7rem;
  white-space: nowrap;
  font-weight: 600;
  color: var(--navy-800);
}

.scores-explain-table td:nth-child(2) {
  width: 11rem;
  font-weight: 500;
}

.scores-explain-note {
  margin-top: 12px;
}

.scores-toolbar__link {
  font-size: 0.85rem;
  color: var(--navy-600);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
}

.scores-toolbar__link:hover {
  background: #fff;
}

.scores-meta-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 10px;
}

.scores-meta {
  margin: 0;
  padding: 0;
  text-align: left;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.scores-meta--hint {
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text-secondary);
}

.scores-panel .muted {
  padding: 0;
  text-align: left;
}

.stock-link {
  border: 0;
  padding: 0;
  margin: 0;
  background: none;
  color: var(--navy-700);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.stock-link:hover {
  color: var(--navy-900);
}

.scores-layout {
  display: block;
  margin-top: 4px;
}

.scores-detail {
  min-width: 0;
}

.scores-item {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card);
  padding: 11px 14px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.scores-item[hidden] {
  display: none;
}

.scores-item:hover,
.scores-item.active {
  background: #eef3fb;
}

.scores-item__name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.scores-item__meta {
  margin-top: 4px;
  font-size: 0.78rem;
}

.scores-detail__title {
  margin: 0 0 10px;
  font-size: 1.2rem;
}

.scores-badges {
  margin-bottom: 12px;
}

.score-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--bg-muted);
  color: var(--text-secondary);
  padding: 2px 8px;
  margin: 2px 4px 0 0;
  font-size: 0.72rem;
  border-radius: 6px;
}

.score-badge--strong {
  border-color: #fecaca;
  background: var(--up-bg);
  color: var(--up);
}

.score-badge--avoid {
  border-color: #bfdbfe;
  background: var(--down-bg);
  color: var(--down);
}

.score-badge--missing {
  color: var(--text-muted);
}

.score-badge--ant {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #b45309;
}

.scores-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.scores-summary__box {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--bg-muted);
}

.scores-summary__value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 4px;
  color: var(--navy-800);
}

.scores-decision {
  border: 1px solid var(--border-light);
  background: #fffaf2;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.scores-factor-grid {
  display: grid;
  gap: 16px;
}

.scores-factor-grid--main {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.scores-factor-grid--timing {
  grid-template-columns: 1fr;
  margin-top: 16px;
}

.scores-factor-block h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.scores-factor-block .table-wrap {
  overflow-x: auto;
}

.scores-factor-table {
  width: 100%;
}

.scores-factor-table th,
.scores-factor-table td {
  font-size: 0.82rem;
  white-space: nowrap;
}

.scores-factor-table td:nth-child(2),
.scores-factor-table td:nth-child(3),
.scores-factor-table th:nth-child(2),
.scores-factor-table th:nth-child(3) {
  text-align: right;
}

.flag-up {
  color: #166534;
  font-weight: 700;
}

.flag-down {
  color: var(--up);
  font-weight: 700;
}

.flag-active {
  color: var(--up);
  font-weight: 700;
}

.flag-inactive {
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .scores-subnav {
    gap: 8px;
  }

  .scores-factor-grid--main {
    grid-template-columns: 1fr;
  }

  .scores-search-wrap {
    flex: 1 1 100%;
    order: 10;
    justify-content: flex-end;
  }

  .scores-search-popup {
    padding-top: 48px;
    align-items: stretch;
  }

  .scores-search-popup__panel {
    width: 100%;
    max-height: min(78vh, 640px);
  }

  .scores-search-popup__list {
    max-height: none;
  }
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.date-toolbar {
  display: flex;
  align-items: center;
}

.filters input[type="date"] {
  padding: 9px 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
}

.filter-spacer {
  flex: 1;
  min-width: 8px;
}

/* KPI — 얇은 요약 스트립 */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
}

.kpi {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-height: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  box-shadow: none;
}

.kpi .label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.kpi .value {
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 0;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-align: right;
  line-height: 1.2;
}

/* 국내 주식: 상승·순매수·플러스 = 빨강 */
.positive,
.up {
  color: var(--up) !important;
}

/* 국내 주식: 하락·순매도·마이너스 = 파랑 */
.negative,
.down {
  color: var(--down) !important;
}

.kpi .value.positive {
  color: var(--up);
}

.kpi .value.negative {
  color: var(--down);
}

/* 2열 테이블 카드 */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 960px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  margin: 0 0 18px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy-900);
  letter-spacing: -0.02em;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--navy-800);
}

.grid-2 .panel {
  margin-bottom: 0;
}

.grid-2 .panel-hint {
  margin: 0 0 10px;
  font-size: 0.8rem;
  line-height: 1.35;
}

.panel h2 {
  font-size: 0.98rem;
}

/* 테이블 */
.table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead th {
  background: var(--bg-muted);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

tbody tr:hover {
  background: #fafbfd;
}

.theme-layout {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.theme-layout > .panel {
  margin-bottom: 20px;
}

.theme-layout > .panel:last-child {
  margin-bottom: 0;
}

.panel h2.panel-heading-inline,
.panel h2.theme-chart-heading {
  margin: 0 0 10px;
  font-size: 0.88rem;
  font-weight: 600;
  padding-bottom: 7px;
  border-bottom-width: 1px;
}

.theme-chart-heading,
.panel-heading-inline {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.theme-chart-heading__title,
.panel-heading-inline__title {
  flex-shrink: 0;
}

.theme-chart-heading__hint,
.panel-heading-inline__hint {
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.3;
  margin: 0;
  padding: 0;
  text-align: left;
}

.panel h2.panel-heading-inline--compact {
  margin: 0 0 8px;
  padding: 0 0 4px;
  font-size: 0.84rem;
  line-height: 1.25;
  border-bottom: 1px solid var(--border-light);
}

.panel-heading-inline--compact {
  gap: 3px 8px;
}

.panel-heading-inline--compact .panel-heading-inline__hint {
  font-size: 0.66rem;
  line-height: 1.25;
}

#layer-streak-buy.panel,
#layer-streak-sell.panel {
  padding: 10px 14px 12px;
  margin-bottom: 16px;
}

#layer-streak-buy .table-wrap,
#layer-streak-sell .table-wrap {
  margin-top: 0;
}

#layer-streak-buy .consecutive-pyramid-chart {
  margin-top: 8px;
}

.theme-chart-panel {
  padding: 8px 10px 10px;
}

.theme-chart-panel h2.panel-heading-inline {
  margin: 0 0 4px;
  padding: 0 0 3px;
  font-size: 0.82rem;
  line-height: 1.2;
  border-bottom: 1px solid var(--border-light);
}

.theme-chart-heading,
.theme-chart-panel .theme-chart-heading {
  gap: 2px 8px;
}

.theme-chart-heading__hint {
  font-size: 0.66rem;
  line-height: 1.2;
}

.theme-chart-frame {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.theme-block-title {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--navy-800);
}

.theme-chart {
  width: 100%;
  min-width: 0;
}

.theme-chart--fixed {
  height: 380px;
  min-height: 380px;
  max-height: 380px;
  overflow: hidden;
  touch-action: none;
}

.theme-chart--fixed .js-plotly-plot,
.theme-chart--fixed .plot-container,
.theme-chart--fixed .svg-container {
  width: 100% !important;
  max-width: 100%;
}

.theme-table-panel {
  margin: 0;
}

.theme-members-panel {
  margin: 0;
}

.theme-members-title {
  margin: 0 0 12px;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--navy-900);
  letter-spacing: -0.02em;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--navy-800);
}

.theme-members-body .muted {
  margin: 0;
}

.theme-summary-table--fixed {
  overflow-x: auto;
  overflow-y: visible;
  margin: 0;
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
}

.theme-summary-table--fixed table {
  table-layout: fixed;
  width: 100%;
  min-width: 720px;
  font-size: 0.82rem;
}

.theme-summary-table--fixed thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-muted);
}

.theme-summary-table--fixed th:nth-child(2),
.theme-summary-table--fixed td:nth-child(2) {
  width: 22%;
}

.theme-summary-table--fixed th:nth-child(3),
.theme-summary-table--fixed td:nth-child(3),
.theme-summary-table--fixed th:nth-child(4),
.theme-summary-table--fixed td:nth-child(4),
.theme-summary-table--fixed th:nth-child(5),
.theme-summary-table--fixed td:nth-child(5) {
  width: 12%;
}

@media (max-width: 900px) {
  .theme-chart--fixed {
    height: 320px;
    min-height: 320px;
    max-height: 320px;
  }
}

.theme-summary-table--fixed tbody tr.theme-row {
  cursor: pointer;
}

.theme-summary-table--fixed tbody tr.theme-row:hover,
.theme-summary-table--fixed tbody tr.theme-row.is-selected {
  background: #f3f7fc;
}

.theme-summary-table--fixed tbody tr.theme-row.is-selected td:first-child {
  box-shadow: inset 3px 0 0 var(--navy-700);
}

.pyramid-cell {
  display: inline;
  white-space: nowrap;
  font-size: 0.78rem;
  line-height: 1.2;
}

.pyramid-cell strong {
  font-weight: 600;
}

.pyramid-cell--bull {
  color: var(--up);
}

.pyramid-cell--bull strong {
  color: var(--up);
}

.pyramid-cell--bear {
  color: var(--down);
}

.pyramid-cell--bear strong {
  color: var(--down);
}

.pyramid-cell--flat,
.pyramid-cell--flat strong {
  color: var(--text-secondary);
}

.pyramid-cell--unknown,
.pyramid-cell--unknown strong {
  color: var(--text-muted);
}

.table-wrap--compact {
  margin: 0;
  overflow-x: auto;
}

.table-wrap--compact table.streak-table,
.table-wrap--compact table.compact-table {
  font-size: 0.8rem;
}

.table-wrap--compact table.streak-table {
  table-layout: auto;
  width: 100%;
}

.table-wrap--compact table.streak-table thead th,
.table-wrap--compact table.compact-table thead th {
  padding: 6px 8px;
  font-size: 0.72rem;
  line-height: 1.2;
}

.table-wrap--compact table.streak-table tbody td,
.table-wrap--compact table.compact-table tbody td {
  padding: 4px 8px;
  line-height: 1.2;
  vertical-align: middle;
}

.table-wrap--compact table.streak-table .streak-col-name,
.table-wrap--compact table.streak-table th:nth-child(3) {
  max-width: 6.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap--compact table.streak-table .streak-col-name .stock-link {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.table-wrap--compact table.streak-table .streak-col-days,
.table-wrap--compact table.streak-table th:nth-child(4) {
  white-space: nowrap;
}

.table-wrap--compact table.streak-table .streak-col-range,
.table-wrap--compact table.streak-table th:nth-child(5) {
  white-space: nowrap;
}

.table-wrap--compact table.streak-table .streak-col-pyramid,
.table-wrap--compact table.streak-table th:nth-child(6) {
  white-space: nowrap;
  padding-left: 4px;
  color: var(--text-secondary);
}

.table-wrap--compact table.streak-table .streak-col-amount,
.table-wrap--compact table.streak-table th:nth-child(7) {
  min-width: 5.8rem;
  white-space: nowrap;
  text-align: right;
  padding-left: 10px;
}

.table-wrap--compact table.streak-table th:first-child,
.table-wrap--compact table.streak-table td:first-child,
.table-wrap--compact table.compact-table th:first-child,
.table-wrap--compact table.compact-table td:first-child {
  width: 2rem;
  padding-left: 6px;
  padding-right: 4px;
}

.pyramid-badge {
  display: inline;
  font-weight: 600;
  white-space: nowrap;
}

.pyramid-badge--bull {
  color: var(--up);
}

.pyramid-badge--bear {
  color: var(--down);
}

.pyramid-badge--flat {
  color: var(--text-secondary);
}

.pyramid-badge--unknown {
  color: var(--text-muted);
}

.pyramid-detail {
  display: inline;
  margin: 0;
  font-size: inherit;
  white-space: nowrap;
}

.streak-buy-block .table-wrap {
  overflow-x: auto;
}

.streak-buy-block td:has(.pyramid-cell) {
  white-space: nowrap;
  max-width: 1px;
}

.streak-chart-hint {
  margin: 0;
  font-size: 0.8rem;
}

.consecutive-pyramid-chart {
  width: 100%;
  min-height: 360px;
  overflow: hidden;
  touch-action: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #fafafa;
}

tbody tr:last-child td {
  border-bottom: none;
}

th:first-child,
td:first-child {
  text-align: center;
  width: 2.5rem;
  color: var(--text-muted);
  font-weight: 500;
}

th:nth-child(2),
td:nth-child(2) {
  text-align: left;
  font-weight: 600;
}

th:not(:first-child):not(:nth-child(2)),
td:not(:first-child):not(:nth-child(2)) {
  text-align: right;
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 20px 0;
  text-align: center;
}

.error {
  color: var(--up);
  background: var(--up-bg);
  border: 1px solid #fecdd3;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-top: 16px;
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

#compare-view .grid-2 {
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

#compare-view .panel {
  margin-bottom: 12px;
}

#compare-view .panel--compact {
  padding: 10px 14px 12px;
}

#compare-view .panel--compact:last-child {
  margin-bottom: 0;
}

/* 휴장 배지 */
.badge-holiday {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  vertical-align: middle;
}
