/* === 리포트 트래커 — 기본 스타일 (원본 톤 유지) === */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "맑은 고딕", "Malgun Gothic", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  color: #1f2937;
  background: #f4f6f8;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid #e2e6ea;
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-size: 16px;
  font-weight: 700;
  color: #1f3a8a;
}
.nav a {
  margin-left: 18px;
  text-decoration: none;
  color: #4b5563;
  font-weight: 500;
  white-space: nowrap;
}
.nav a.active {
  color: #1f3a8a;
  border-bottom: 2px solid #1f3a8a;
  padding-bottom: 4px;
}

.container {
  max-width: 1500px;
  margin: 0 auto;
  padding: 20px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.page-header h1 {
  font-size: 18px;
  margin: 0;
  color: #111827;
}
.page-meta {
  font-size: 12px;
  color: #6b7280;
}
.page-meta strong { color: #1f3a8a; font-size: 14px; }

/* 날짜 선택 */
.date-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
  font-size: 12px;
  color: #4b5563;
}
.date-picker select {
  padding: 4px 8px;
  border: 1px solid #c7d2fe;
  border-radius: 4px;
  font-size: 12px;
  background: #fff;
  color: #1f3a8a;
  font-weight: 600;
  cursor: pointer;
}

/* 자동 새로고침 상태 표시 */
.auto-refresh-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #6b7280;
  margin-left: 12px;
  padding: 2px 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
}
.auto-refresh-status .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #059669;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.btn-ghost {
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 4px 10px;
  margin-left: 10px;
  cursor: pointer;
  font-size: 12px;
  color: #374151;
}
.btn-ghost:hover { background: #f9fafb; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.search {
  flex: 0 0 320px;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 13px;
}
.search:focus { outline: none; border-color: #1f3a8a; }
.hint { color: #9ca3af; font-size: 12px; }

.table-wrap {
  background: #fff;
  border: 1px solid #e2e6ea;
  border-radius: 4px;
  overflow: auto;
  max-height: calc(100vh - 180px);
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.report-table thead th {
  position: sticky;
  top: 0;
  background: #eef2f7;
  border-bottom: 1px solid #cbd5e1;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}
.report-table thead th.sortable { cursor: pointer; user-select: none; }
.report-table thead th.sortable:hover { background: #e2e8f0; }
.report-table thead th.sortable::after { content: " ⇅"; color: #94a3b8; font-size: 10px; }
.report-table thead th.sortable.desc::after { content: " ↓"; color: #1f3a8a; }

.report-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f3f5;
  vertical-align: top;
}
.report-table tbody tr:hover { background: #fafbfc; }

.col-check { width: 36px; text-align: center; }

/* 읽음 상태 변경 시 부드러운 색상 전환 (Gmail 스타일) */
.report-table tbody tr {
  transition: background-color 0.2s, color 0.2s;
}

/* === 읽음 마킹 — 행 전체가 클릭/호버 영역 === */
#report-table tbody tr { cursor: pointer; }

/* 안 읽음 — 굵은 제목·종목명 + 호버 시 푸른 톤 */
tr.is-unread .title-line,
tr.is-unread .company-name { font-weight: 700; }
#report-table tbody tr.is-unread:hover {
  background: rgba(37, 99, 235, 0.06);
}

/* 읽음 — 회색 톤 + 취소선 + 호버 시 흐린 회색 */
tr.is-read .company-name,
tr.is-read .broker-name,
tr.is-read .title-line {
  color: #94a3b8;
  font-weight: 400;
  text-decoration: line-through;
  text-decoration-color: #94a3b8;
  text-decoration-thickness: 1px;
}
tr.is-read .summary-body {
  color: #94a3b8;
  opacity: 0.7;
  text-decoration: line-through;
  text-decoration-color: #cbd5e1;
  text-decoration-thickness: 1px;
}
tr.is-read .opinion-badge { opacity: 0.5; text-decoration: line-through; }
#report-table tbody tr.is-read:hover {
  background: rgba(0, 0, 0, 0.035);
}

/* 기존 .checked 행 노란 배경은 호버보다 우선 */
#report-table tbody tr.checked { background: #fffbeb; }
#report-table tbody tr.checked:hover { background: #fef3c7; }

/* Wisereport 원문 버튼 (기본 hidden — JS 가 켬) */
a.btn-original {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 500;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  vertical-align: middle;
}
a.btn-original:hover { background: #dbeafe; border-color: #93c5fd; }
tr.is-read a.btn-original { opacity: 0.5; text-decoration: none; }

/* 원문 옆 다운로드(⬇) 버튼 — 모든 페이지 공용 (JS injectDownloadBtn 으로 주입) */
a.btn-download {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 500;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  vertical-align: middle;
}
a.btn-download:hover { background: #d1fae5; border-color: #6ee7b7; }
tr.is-read a.btn-download { opacity: 0.5; }

/* 산업별 전체 ZIP 다운로드 버튼 (산업명 옆) */
.btn-bulk-dl {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  font-size: 10.5px;
  font-weight: 500;
  padding: 1px 7px;
  margin-left: 8px;
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
  white-space: nowrap;
}
.btn-bulk-dl:hover { background: #fde68a; border-color: #f59e0b; }
.btn-bulk-dl:disabled { opacity: 0.5; cursor: wait; }

/* 읽음 토글 바 (행 왼쪽) */
.report-table th.col-read,
.report-table td.col-read {
  width: 14px;
  min-width: 14px;
  max-width: 14px;
  padding: 0;
  border-right: 0;
}
button.read-toggle {
  display: block;
  width: 6px;
  min-height: 32px;
  height: 100%;
  margin: 0 auto;
  border: 0;
  padding: 0;
  border-radius: 3px;
  cursor: pointer;
  background: #2563eb;        /* 안 읽음 = 파랑 막대 */
  transition: background 0.15s ease, transform 0.1s ease;
}
button.read-toggle:hover { transform: scaleX(1.6); }
tr.is-read button.read-toggle {
  background: #d1d5db;        /* 읽음 = 회색 막대 */
}
button.read-toggle:disabled { opacity: 0.5; cursor: wait; }

/* 리포트 페이지수 (분량) — 좁고 가운데 정렬 */
.report-table th.col-pages,
.report-table td.col-pages,
table .page-count {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  text-align: center !important;
  font-size: 11px;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
  padding-left: 4px;
  padding-right: 4px;
}

/* 실시간 상태 표시줄 (헤더) */
.live-status {
  margin-left: 8px;
  font-size: 12px;
  color: #4b5563;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.live-status .dot.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: #9ca3af;
  margin-right: 2px;
}
.live-status .dot.live-dot.open       { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.live-status .dot.live-dot.connecting { background: #f59e0b; animation: pulse 1s infinite; }
.live-status .dot.live-dot.closed     { background: #ef4444; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
.live-tick { color: #9ca3af; font-size: 11px; }

/* 실시간 등락률 (메인 페이지 기업명 옆) */
.live-rate {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
  min-width: 50px;
}
.live-rate.pos  { color: #dc2626; }
.live-rate.neg  { color: #2563eb; }
.live-rate.flat { color: #6b7280; }

/* 알림 활성 종목 배너 */
.alerts-banner {
  margin: 0 0 12px 0;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  overflow: hidden;
}
.alerts-toggle {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.alerts-toggle .caret { margin-left: auto; color: #b45309; font-size: 12px; }
#alerts-count {
  display: inline-block;
  background: #f59e0b;
  color: #fff;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 12px;
  margin: 0 2px;
}
.alerts-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
  padding: 8px 12px 12px;
  background: #fffdf5;
  border-top: 1px solid #fde68a;
}
.alert-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  gap: 4px 12px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 12px;
}
.ai-name { grid-column: 1 / 2; font-weight: 600; color: #111827; }
.ai-name .stock-link { color: #1e3a8a; cursor: pointer; }
.ai-name .stock-link:hover { text-decoration: underline; }
.ai-code { color: #9ca3af; font-weight: 400; margin-left: 4px; font-size: 11px; }
.ai-price { grid-column: 2 / 3; text-align: right; }
.ai-cur { font-weight: 600; }
.ai-pct { margin-left: 4px; font-size: 11px; }
.ai-pct.pos { color: #dc2626; }
.ai-pct.neg { color: #2563eb; }
.ai-bar {
  grid-column: 1 / 3;
  position: relative;
  height: 10px;
  background: #fef3c7;
  border-radius: 5px;
  overflow: hidden;
}
.ai-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  transition: width 0.3s;
}
.ai-bar-fill.up   { background: linear-gradient(90deg, #fca5a5, #ef4444); }
.ai-bar-fill.down { background: linear-gradient(90deg, #93c5fd, #3b82f6); }
.ai-bar-label {
  position: absolute;
  right: 6px;
  top: -1px;
  font-size: 10px;
  color: #6b7280;
  line-height: 12px;
}
.ai-foot {
  grid-column: 1 / 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ai-base { font-size: 11px; color: #9ca3af; }
.ai-status { margin-right: 2px; font-size: 11px; }

/* 상태별 카드 색 */
.alert-item.status-reached { border-color: #fca5a5; background: #fef2f2; }
.alert-item.status-near    { border-color: #fcd34d; background: #fffbeb; }
.alert-item.status-stable  { border-color: #bbf7d0; background: #f0fdf4; }
.alert-item.status-unknown { border-color: #e5e7eb; background: #f9fafb; }

/* 인라인 액션 버튼 */
.ai-actions { display: flex; gap: 4px; }
.ai-action {
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
  color: #374151;
  line-height: 1.2;
}
.ai-action:hover { background: #f3f4f6; border-color: #9ca3af; }
.ai-action.danger { color: #b91c1c; border-color: #fca5a5; }
.ai-action.danger:hover { background: #fee2e2; }
.ai-action:disabled { opacity: 0.5; cursor: wait; }

/* 헤더 요약 카운트 */
.ac-sum { font-size: 11px; font-weight: 400; margin-left: 4px; color: #6b7280; }
.ac-r { color: #dc2626; font-weight: 600; }
.ac-n { color: #d97706; font-weight: 600; }
.ac-s { color: #16a34a; font-weight: 600; }

/* 읽음 필터 칩 */
.read-filter {
  display: inline-flex;
  gap: 4px;
  margin-left: 8px;
}
.read-filter .filter-btn {
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 11.5px;
  cursor: pointer;
  color: #4b5563;
}
.read-filter .filter-btn:hover { background: #f9fafb; }
.read-filter .filter-btn.active {
  background: #1f3a8a;
  border-color: #1f3a8a;
  color: #fff;
}
.read-filter .count {
  display: inline-block;
  min-width: 16px;
  padding: 0 5px;
  margin-left: 3px;
  background: rgba(0,0,0,0.08);
  border-radius: 9px;
  font-size: 10.5px;
  font-weight: 600;
}
.read-filter .filter-btn.active .count { background: rgba(255,255,255,0.25); }
.col-company { width: 150px; }
.col-broker { width: 170px; }
.col-opinion { width: 90px; }
.col-num { width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
.col-title { min-width: 380px; }

.company-name { font-weight: 600; color: #111827; }
.company-code { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.posted-time {
  font-size: 10.5px;
  color: #6b7280;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}

.broker-name { color: #1f2937; }
.analyst-name { font-size: 11px; color: #9ca3af; margin-top: 2px; }

.opinion-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  background: #eff6ff;
  color: #1f3a8a;
  border: 1px solid #c7d2fe;
}

/* === Wisereport 변경 배지 (신규/상향/하향/변동없음) === */
.badge-change {
  display: inline-block;
  min-width: 14px;
  padding: 0 4px;
  height: 14px;
  line-height: 14px;
  text-align: center;
  font-size: 9.5px;
  font-weight: 700;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
  letter-spacing: 0;
}
.badge-change.badge-new  { background: #dc2626; color: #fff; }   /* N — 빨간 사각형 */
.badge-change.badge-up   { background: transparent; color: #dc2626; border: none; padding: 0; min-width: 12px; font-size: 10px; }
.badge-change.badge-down { background: transparent; color: #2563eb; border: none; padding: 0; min-width: 12px; font-size: 10px; }
.badge-change.badge-same { background: transparent; color: #cbd5e1; border: none; padding: 0; min-width: 12px; font-size: 11px; }

.title-line {
  font-weight: 600;
  color: #111827;
  margin-bottom: 4px;
  /* 형광펜 효과 — 글자 아랫쪽 40% 만 연한 빨강 */
  background-image: linear-gradient(transparent 55%, rgba(254, 202, 202, 0.85) 55%);
  display: inline;
  padding: 0 2px;
}
.summary-body {
  margin-top: 6px;
  padding: 8px 10px;
  background: #f8fafc;
  border-left: 3px solid #c7d2fe;
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 11.5px;
  color: #4b5563;
}

.row-check { cursor: pointer; width: 16px; height: 16px; accent-color: #1f3a8a; }
.row-check:disabled { cursor: wait; opacity: 0.4; }

/* 체크된 행 — 연한 노란 강조 */
.report-table tbody tr.checked {
  background: #fffbeb;
}
.report-table tbody tr.checked:hover {
  background: #fef3c7;
}
.report-table tbody tr.checked .company-name {
  color: #92400e;
}

/* 토스트 */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  animation: slide-in 0.2s ease-out;
}
.toast-ok   { background: #059669; color: #fff; }
.toast-warn { background: #d97706; color: #fff; }
.toast-err  { background: #dc2626; color: #fff; }
@keyframes slide-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* 대시보드 자리표시자 (빈 상태) */
.placeholder {
  padding: 60px 40px;
  text-align: center;
  background: #fff;
  border: 1px dashed #d1d5db;
  border-radius: 6px;
  color: #9ca3af;
}
.placeholder strong { color: #6b7280; font-size: 15px; display: block; margin-bottom: 8px; }
.placeholder a { color: #1f3a8a; }

/* === 대시보드 === */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.filter-btn {
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  color: #4b5563;
  transition: all 0.15s;
}
.filter-btn:hover { background: #f9fafb; border-color: #9ca3af; }
.filter-btn.active {
  background: #1f3a8a;
  border-color: #1f3a8a;
  color: #fff;
}
.filter-btn .count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  background: rgba(0,0,0,0.08);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.filter-btn.active .count { background: rgba(255,255,255,0.25); }

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.dashboard-table thead th {
  position: sticky;
  top: 0;
  background: #eef2f7;
  border-bottom: 1px solid #cbd5e1;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}
.dashboard-table thead th.sortable { cursor: pointer; user-select: none; }
.dashboard-table thead th.sortable:hover { background: #e2e8f0; }
.dashboard-table thead th.sortable.desc::after { content: " ↓"; color: #1f3a8a; }

.dashboard-table tbody td {
  padding: 10px;
  border-bottom: 1px solid #f1f3f5;
  vertical-align: top;
}
.dashboard-table tbody tr:hover { background: #fafbfc; }

.col-date { width: 90px; }
.checked-date { font-weight: 600; color: #374151; }
.checked-time { font-size: 11px; color: #9ca3af; margin-top: 2px; }

.col-status { width: 90px; }
.col-buy, .col-sell { width: 110px; }
.col-memo { min-width: 160px; max-width: 240px; }
.col-title { min-width: 320px; }

.target-price { font-size: 11px; color: #6b7280; margin-top: 4px; }

.trade-line { font-variant-numeric: tabular-nums; color: #1f2937; }
.trade-line strong { font-weight: 600; }
.trade-meta { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.memo-text {
  white-space: pre-wrap;
  font-size: 12px;
  color: #4b5563;
  line-height: 1.5;
}
.muted { color: #cbd5e1; }

/* === 상태 배지 (4단계) === */
.status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge.status-관심종목 { background: #dbeafe; color: #1e40af; }
.status-badge.status-매수대기 { background: #fef3c7; color: #92400e; }
.status-badge.status-매수함   { background: #d1fae5; color: #065f46; }
.status-badge.status-매도함   { background: #e5e7eb; color: #4b5563; }

/* 필터 버튼 색 힌트 */
.filter-btn.status-관심종목:not(.active) { color: #1e40af; }
.filter-btn.status-매수대기:not(.active) { color: #92400e; }
.filter-btn.status-매수함:not(.active)   { color: #065f46; }
.filter-btn.status-매도함:not(.active)   { color: #4b5563; }

/* === 인라인 상태 드롭다운 === */
.status-select {
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background-position: right 6px center;
}
.status-select:hover { border-color: rgba(0,0,0,0.15); }
.status-select.status-관심종목 { background-color: #dbeafe; color: #1e40af; }
.status-select.status-매수대기 { background-color: #fef3c7; color: #92400e; }
.status-select.status-매수함   { background-color: #d1fae5; color: #065f46; }
.status-select.status-매도함   { background-color: #e5e7eb; color: #4b5563; }
.status-select:disabled { opacity: 0.5; cursor: wait; }

.col-action { width: 36px; }
.btn-edit {
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: #6b7280;
}
.btn-edit:hover { background: #eef2f7; color: #1f3a8a; border-color: #c7d2fe; }

/* === 펼치기 (종목 → 리포트 N건) === */
.col-expand { width: 28px; text-align: center; }
.btn-expand {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: #6b7280;
  padding: 4px 6px;
  border-radius: 3px;
}
.btn-expand:hover { background: #eef2f7; color: #1f3a8a; }

.stock-row.expanded {
  background: #f8fafc;
}
.stock-row.expanded:hover { background: #f1f5f9; }

.col-reports-summary {
  min-width: 320px;
  max-width: 480px;
}
.reports-toggle {
  background: #eef2f7;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 12px;
  color: #1f2937;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.reports-toggle:hover { background: #dbeafe; }
.reports-toggle strong {
  color: #1f3a8a;
  font-weight: 700;
}
.reports-toggle .toggle-arrow {
  color: #6b7280;
  font-size: 10px;
}
.reports-latest-meta {
  font-size: 11.5px;
  color: #6b7280;
  margin-top: 6px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.reports-latest-meta .broker-name {
  color: #374151;
  font-weight: 500;
}
.reports-latest-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #111827;
  margin-top: 6px;
  /* 형광펜 효과 */
  background-image: linear-gradient(transparent 55%, rgba(254, 202, 202, 0.85) 55%);
  display: inline;
  padding: 0 2px;
  line-height: 1.7;
}
.reports-latest-summary {
  font-size: 11.5px;
  color: #4b5563;
  margin-top: 4px;
  padding: 6px 9px;
  background: #f8fafc;
  border-left: 3px solid #c7d2fe;
  line-height: 1.55;
  white-space: pre-wrap;
}

.filter-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 펼친 행 (sub-table) */
.reports-expand-row > td {
  padding: 0 !important;
  background: #f8fafc;
  border-bottom: 2px solid #cbd5e1 !important;
}
.reports-list {
  padding: 10px 20px 14px 60px;   /* 종목 컬럼과 시각적으로 들여쓰기 */
}
.reports-inner-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}
.reports-inner-table thead th {
  background: #f1f5f9;
  border-bottom: 1px solid #cbd5e1;
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.reports-inner-table thead th.num,
.reports-inner-table tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.reports-inner-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f3f5;
  vertical-align: top;
}
.reports-inner-table tbody tr:last-child td { border-bottom: none; }
.reports-inner-table .report-date {
  font-variant-numeric: tabular-nums;
  color: #6b7280;
  font-size: 11.5px;
  white-space: nowrap;
}

/* 펼친 영역 — 개별 리포트 제거 버튼 */
.reports-inner-table th.col-row-action,
.reports-inner-table td.col-row-action {
  width: 32px;
  padding: 4px 6px;
  text-align: center;
}
.btn-report-remove {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  opacity: 0.35;
  padding: 4px 6px;
  border-radius: 4px;
  transition: opacity 0.15s, background 0.15s, transform 0.1s;
  line-height: 1;
}
.reports-inner-table tbody tr:hover .btn-report-remove { opacity: 0.7; }
.btn-report-remove:hover {
  opacity: 1 !important;
  background: #fef2f2;
  transform: scale(1.1);
}
.btn-report-remove:disabled {
  opacity: 0.3;
  cursor: wait;
}

/* === 편집 패널 (우측 슬라이드) === */
.panel-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 50;
}
.panel-overlay.open { opacity: 1; }

.edit-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  max-width: 90vw;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 51;
  display: flex;
  flex-direction: column;
}
.edit-panel.open { transform: translateX(0); }

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid #e5e7eb;
}
.panel-title { font-size: 16px; font-weight: 700; color: #111827; }
.panel-subtitle { font-size: 11.5px; color: #6b7280; margin-top: 3px; }
.btn-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 18px; color: #9ca3af; padding: 0 4px;
}
.btn-close:hover { color: #374151; }

.panel-body {
  flex: 1; overflow-y: auto;
  padding: 16px 20px;
}
.panel-section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f3f5;
}
.panel-section:last-of-type { border-bottom: none; }
.panel-section h3 {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  margin: 0 0 10px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.panel-section > label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.panel-section select,
.panel-section input,
.panel-section textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #1f2937;
}
.panel-section select:focus,
.panel-section input:focus,
.panel-section textarea:focus {
  outline: none;
  border-color: #1f3a8a;
  box-shadow: 0 0 0 3px rgba(31, 58, 138, 0.1);
}
.panel-section textarea { resize: vertical; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.field label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: #9ca3af;
  margin-bottom: 4px;
}

.pnl-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
}
.pnl-plus { color: #dc2626; font-weight: 700; }
.pnl-minus { color: #2563eb; font-weight: 700; }

.panel-footer {
  display: flex;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}
.btn-primary {
  background: #1f3a8a;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: #1e3577; }
.btn-danger {
  background: #fff;
  color: #dc2626;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  padding: 8px 14px;
  font-size: 12.5px;
  cursor: pointer;
}
.btn-danger:hover { background: #fef2f2; }

/* === 알림 (가격 변동) === */
.alert-bell {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  vertical-align: middle;
}
.last-known-price {
  font-size: 11px;
  color: #6b7280;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 10px;
  cursor: pointer;
}
.checkbox-row input { width: auto; }
.alert-current-info {
  font-size: 11.5px;
  color: #6b7280;
  margin-top: 6px;
  padding: 8px 10px;
  background: #f8fafc;
  border-left: 3px solid #cbd5e1;
}
.alert-direction-header {
  font-size: 12px;
  font-weight: 600;
  margin: 12px 0 6px 0;
  letter-spacing: 0.3px;
}
.alert-help {
  margin-top: 10px;
  padding: 6px 10px;
  background: #f8fafc;
  border-radius: 4px;
  font-size: 11px;
  color: #6b7280;
  line-height: 1.5;
}

/* === 종목 상세 모달 === */
.stock-link {
  color: #1f3a8a;
  cursor: pointer;
  text-decoration: none;
}
.stock-link:hover { text-decoration: underline; }

.stock-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 60;
}
.stock-modal-overlay.open { opacity: 1; }
/* 안전장치: hidden 시 무조건 화면에서 제거 (display:none) */
.stock-modal-overlay[hidden],
.stock-modal[hidden],
.panel-overlay[hidden],
.edit-panel[hidden] {
  display: none !important;
}

.stock-modal {
  position: fixed;
  top: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  width: 1100px;
  max-width: 95vw;
  max-height: calc(100vh - 48px);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 61;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.stock-modal.open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.stock-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
  gap: 20px;
}
.sm-name { font-size: 18px; font-weight: 700; color: #111827; }
.sm-meta { font-size: 11.5px; color: #9ca3af; margin-top: 3px; }
.sm-price-block { text-align: right; }
.sm-current-price {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  font-variant-numeric: tabular-nums;
}
.sm-change {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* 실시간 틱 도착 시 깜빡임 효과 */
.tick-flash {
  animation: tick-pulse 0.6s ease-out;
}
@keyframes tick-pulse {
  0%   { background: rgba(254, 240, 138, 0.6); }
  100% { background: transparent; }
}

.stock-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px;
}
.sm-section { margin-bottom: 20px; }
.sm-section h3 {
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
  margin: 0 0 10px 0;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* KPI grid */
.sm-kpi {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 10px;
}
.sm-stat {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 8px 10px;
}
.sm-stat label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}
.sm-stat > div {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  font-variant-numeric: tabular-nums;
}

/* 차트 + 호가창 가로 배치 */
.sm-chart-row {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 16px;
}
.sm-chart-wrap { position: relative; }
.sm-chart { width: 100%; height: 380px; background: #fff; border: 1px solid #e5e7eb; border-radius: 4px; }
.sm-chart-loading {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: #9ca3af;
}
.sm-chart-legend {
  font-size: 11px;
  font-weight: 500;
  margin-left: 10px;
  text-transform: none;
  letter-spacing: 0;
}
.sm-chart-legend .legend-item { margin-right: 8px; }

/* 차트 기간 토글 */
.sm-chart-period {
  display: inline-flex;
  gap: 2px;
  margin-left: 8px;
  vertical-align: middle;
}
.sm-chart-period button {
  background: #fff;
  border: 1px solid #d1d5db;
  color: #4b5563;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 0.2px;
  text-transform: none;
}
.sm-chart-period button:hover { background: #f9fafb; border-color: #9ca3af; }
.sm-chart-period button.active {
  background: #1f3a8a;
  border-color: #1f3a8a;
  color: #fff;
}
.sm-chart-tooltip {
  display: none;
  position: absolute;
  top: 40px; left: 10px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.5;
  color: #1f2937;
  pointer-events: none;
  z-index: 5;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.sm-chart-tooltip .tt-row { white-space: nowrap; }

/* 호가창 */
.sm-orderbook-wrap {}
.sm-orderbook {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.sm-orderbook td {
  padding: 3px 8px;
  border-bottom: 1px solid #f1f3f5;
}
/* 등락 방향 기준 색 — +면 빨강, -면 파랑 (한국 차트 관례) */
.sm-orderbook tr.row-up td   { background: #fef2f2; }
.sm-orderbook tr.row-up td.price   { color: #dc2626; font-weight: 600; }
.sm-orderbook tr.row-down td { background: #eff6ff; }
.sm-orderbook tr.row-down td.price { color: #2563eb; font-weight: 600; }
.sm-orderbook tr.row-flat td { background: #f8fafc; }
.sm-orderbook tr.row-flat td.price { color: #6b7280; font-weight: 600; }
/* 매도/매수 구분은 separator 로만 표시 */
.sm-orderbook tr.separator td { background: #1f2937; height: 1px; padding: 0; }
/* hoga-pct 색은 row 색을 그대로 따라감 */
.sm-orderbook tr.row-up .hoga-pct   { color: #dc2626; }
.sm-orderbook tr.row-down .hoga-pct { color: #2563eb; }
.sm-orderbook tr.row-flat .hoga-pct { color: #9ca3af; }
.sm-orderbook td.qty { text-align: right; color: #6b7280; }
.sm-orderbook td.price { text-align: center; }
.hoga-pct {
  font-size: 9.5px;
  font-weight: 500;
  margin-left: 3px;
  opacity: 0.85;
}

/* 수급 + 공매도 */
.sm-flow-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
}
.sm-flow-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.sm-flow-table thead th {
  background: #f1f5f9;
  padding: 6px 8px;
  font-weight: 600;
  color: #475569;
  text-align: left;
  border-bottom: 1px solid #cbd5e1;
}
.sm-flow-table tbody td {
  padding: 6px 8px;
  border-bottom: 1px solid #f1f3f5;
}
.sm-flow-table th.num, .sm-flow-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sm-short-info {
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font-size: 13px;
}

/* 컨센서스 */
.sm-consensus { font-size: 12.5px; }
.consensus-summary {
  padding: 10px 12px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 4px;
  margin-bottom: 10px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.consensus-upside { margin-left: auto; font-weight: 700; }
.consensus-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.consensus-table thead th {
  background: #f1f5f9;
  padding: 5px 8px;
  font-weight: 600;
  color: #475569;
  text-align: left;
  border-bottom: 1px solid #cbd5e1;
}
.consensus-table tbody td {
  padding: 5px 8px;
  border-bottom: 1px solid #f1f3f5;
}
.consensus-table th.num, .consensus-table td.num { text-align: right; }

/* 외부 링크 */
.sm-links {
  display: flex;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
}
.sm-links a {
  color: #1f3a8a;
  text-decoration: none;
}
.sm-links a:hover { text-decoration: underline; }

/* === 상단 백업 버튼 === */
.topbar-actions { display: flex; gap: 6px; }

/* === 통계 페이지 === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.kpi-card {
  background: #fff;
  border: 1px solid #e2e6ea;
  border-radius: 6px;
  padding: 18px 20px;
}
.kpi-card.kpi-plus  { border-left: 4px solid #dc2626; }
.kpi-card.kpi-minus { border-left: 4px solid #2563eb; }
.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  font-variant-numeric: tabular-nums;
}
.kpi-card.kpi-plus  .kpi-value { color: #dc2626; }
.kpi-card.kpi-minus .kpi-value { color: #2563eb; }
.kpi-sub {
  font-size: 11.5px;
  color: #9ca3af;
  margin-top: 6px;
}

.stats-section {
  background: #fff;
  border: 1px solid #e2e6ea;
  border-radius: 6px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.stats-section h2 {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  margin: 0 0 14px 0;
}

.status-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.status-bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 130px;
  align-items: center;
  gap: 12px;
}
.status-bar-track {
  height: 14px;
  background: #f1f3f5;
  border-radius: 7px;
  overflow: hidden;
}
.status-bar-fill {
  height: 100%;
  border-radius: 7px;
  transition: width 0.3s;
}
.status-관심종목-bg { background: #93c5fd; }
.status-매수대기-bg { background: #fcd34d; }
.status-매수함-bg   { background: #6ee7b7; }
.status-매도함-bg   { background: #cbd5e1; }
.status-bar-num {
  font-size: 12px;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.stats-table thead th {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: #475569;
}
.stats-table thead th.num,
.stats-table tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.stats-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f3f5;
}
.stats-table tbody tr:hover { background: #fafbfc; }

/* ============================================================
   모바일 반응형 — 휴대폰/태블릿 최적화 (데스크톱 영향 없음)
   ============================================================ */

/* 태블릿 이하: 종목 상세 모달 KPI 8열 → 4열 */
@media (max-width: 900px) {
  .sm-kpi { grid-template-columns: repeat(4, 1fr); }
  .stock-modal { width: 96vw; }
}

/* 휴대폰 (≤640px) */
@media (max-width: 640px) {
  /* 상단바 — 줄바꿈 허용 + 네비는 가로 스크롤 띠 */
  .topbar {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 6px;
  }
  .brand { font-size: 15px; }
  .nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    display: flex;
    gap: 2px;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .nav a {
    margin-left: 0;
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 6px;
  }
  .nav a.active {
    border-bottom: 0;
    background: #eef2ff;
    padding-bottom: 6px;
  }
  .topbar-actions { margin-left: auto; }

  /* 본문 여백 축소 */
  .container { padding: 10px; }

  /* 페이지 헤더 — 제목/메타 줄바꿈 */
  .page-header { flex-wrap: wrap; gap: 4px; }
  .page-header h1 { font-size: 16px; }

  /* 툴바 / 필터바 — 세로로 쌓고 검색창 전체 폭 */
  .toolbar,
  .filter-bar {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
  }
  .filter-right {
    width: 100%;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  .search {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    font-size: 16px;            /* iOS 자동 확대 방지 (16px 이상) */
  }
  .hint { display: none; }      /* 좁은 화면에선 안내 문구 숨김 */

  /* 읽음 필터 버튼 줄바꿈 */
  .read-filter { flex-wrap: wrap; }

  /* 기타 리포트 카테고리 탭 — 가로 스크롤 */
  .misc-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .misc-tab { flex: 0 0 auto; }

  /* 표 — 가로 스크롤 유지 + 화면 더 활용 + 셀 컴팩트 */
  .table-wrap {
    max-height: calc(100vh - 140px);
    -webkit-overflow-scrolling: touch;
  }
  .report-table,
  .dashboard-table { font-size: 12px; }
  .report-table tbody td,
  .report-table thead th,
  .dashboard-table tbody td,
  .dashboard-table thead th { padding: 7px 8px; }
  /* 제목 열 최소폭 완화 — 과도한 가로 스크롤 줄임 */
  .col-title { min-width: 220px; }
  .col-broker { width: auto; }
  .col-memo { min-width: 120px; max-width: 160px; }

  /* 터치 타깃 키우기 — 체크박스/읽음 토글 */
  .row-check { transform: scale(1.25); }

  /* 편집 패널 — 전체 폭 */
  .edit-panel { width: 100%; max-width: 100%; }

  /* 종목 상세 모달 — 전체 화면 */
  .stock-modal {
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
    transform: translateY(16px);
  }
  .stock-modal.open { transform: translateY(0); }
  .stock-modal-body { padding: 14px 14px; }
  .sm-kpi { grid-template-columns: repeat(2, 1fr); }
  .sm-chart-row { grid-template-columns: 1fr; }   /* 차트/호가 세로 적층 */
  .sm-chart { height: 260px; }
}
