/* ===========================================
   Core Lens Korea — detail page styles
   styles.css 의 토큰을 그대로 상속받음
   =========================================== */

.detail {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ============ STOCK BAR ============ */
.stock-bar {
  margin-bottom: 24px;
}
.stock-bar__inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 28px 24px;
  background: linear-gradient(180deg, rgba(232,255,92,0.04), transparent 70%), var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.stock-bar__ticker {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.08em;
}
.stock-bar__name {
  margin: 0 0 6px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.stock-bar__exchange {
  margin: 0;
  color: var(--ink-mute);
  font-size: 13px;
}
.stock-bar__price {
  text-align: right;
}
.stock-bar__price-now {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}
.stock-bar__price-krw {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink-mute);
  font-weight: 500;
}
.stock-bar__price-chg {
  margin: 8px 0 0;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
}
.stock-bar__price-chg.up   { color: var(--up); }
.stock-bar__price-chg.down { color: var(--down); }
.stock-bar__updated {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-mute);
}

/* ============ PRICE CHART ============ */
.price-chart-section {
  margin: 0 0 24px;
  padding: 22px 26px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.price-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.price-chart-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.period-tabs {
  display: inline-flex;
  background: var(--bg-elev);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
}
.period-tab {
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--ink-mute);
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: color 100ms ease, background 100ms ease;
}
.period-tab:hover {
  color: var(--ink);
}
.period-tab.is-active {
  background: var(--bg-soft);
  color: var(--accent);
}
.price-chart-svg {
  width: 100%;
  height: 220px;
  display: block;
}
.price-chart-label {
  margin: 6px 0 0;
  font-size: 12px;
  text-align: right;
  color: var(--ink-mute);
}
.price-chart-label .up   { color: var(--up); }
.price-chart-label .down { color: var(--down); }

@media (max-width: 720px) {
  .price-chart-section { padding: 16px 14px; }
  .price-chart-svg { height: 180px; }
  .period-tab { padding: 5px 8px; font-size: 11px; }
  .price-chart-header { gap: 10px; }
}

/* ============ TABS ============ */
.tabs {
  position: sticky;
  top: 64px;
  z-index: 20;
  display: flex;
  gap: 4px;
  padding: 6px;
  margin-bottom: 24px;
  background: rgba(11, 13, 16, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  padding: 10px 18px;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background 120ms ease, color 120ms ease;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); background: var(--bg-elev); }
.tab[aria-selected="true"] {
  color: var(--bg);
  background: var(--accent);
}

/* ============ SECTION BLOCK (single-scroll layout) ============ */
.section-block {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 40px 0 24px;
  border-top: 1px solid var(--line-soft);
  scroll-margin-top: 130px;
}
.section-block:first-of-type {
  padding-top: 8px;
  border-top: none;
}
.section-block__title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

/* legacy alias kept for safety */
.tab-panel { display: flex; flex-direction: column; gap: 20px; }

/* ============ CARD ============ */
.card {
  padding: 24px 26px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.card--table { padding: 24px 0 8px; }
.card--table .card__title { padding: 0 26px 16px; }
.card--table > .muted { padding: 12px 26px 16px; }

.card__title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card__body {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
}
.muted {
  color: var(--ink-mute);
  font-size: 13px;
  margin: 12px 0 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 800px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stock-bar__inner { flex-direction: column; align-items: flex-start; }
  .stock-bar__price { text-align: left; }
}

/* ============ KEY-VALUE LIST ============ */
.kv {
  margin: 16px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
}
.kv > div {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.kv dt { color: var(--ink-mute); margin: 0; }
.kv dd { margin: 0; color: var(--ink); }

/* ============ METRICS GRID ============ */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
@media (max-width: 900px) {
  .metrics-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}
.metric-cell {
  padding: 14px 14px;
  background: var(--bg-soft);
}
.metric-cell__label {
  margin: 0 0 4px;
  font-size: 11px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.metric-cell__value {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
}

/* ============ SUB TABS (financials) ============ */
.sub-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.sub-tab {
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--ink-mute);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
}
.sub-tab:hover { color: var(--ink); }
.sub-tab.is-active { color: var(--accent); background: rgba(232,255,92,0.08); }

.period-toggle {
  margin-left: auto;
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.period-btn {
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--ink-mute);
  font-size: 12px;
  border-radius: 6px;
}
.period-btn.is-active { background: var(--bg-soft); color: var(--ink); }

/* ============ TABLE SCROLL WRAPPER (모바일 가로 스크롤) ============ */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-scroll > table {
  min-width: 100%;
}

/* ============ TABLES (shared) ============ */
.fin-table, .ear-table, .ins-table, .ana-table, .fil-table, .hold-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.fin-table th, .ear-table th, .ins-table th, .ana-table th, .fil-table th, .hold-table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 500;
  color: var(--ink-mute);
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
}
.fin-table td, .ear-table td, .ins-table td, .ana-table td, .fil-table td, .hold-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
}
.fin-table .num, .ear-table .num, .ins-table .num, .ana-table .num, .fil-table .num, .hold-table .num,
.fin-table td:not(.fin-row-label), .ear-table td:not(:first-child) {
  text-align: right;
  font-family: var(--font-mono);
}
.financials-table { overflow-x: auto; padding: 0 12px; }
.fin-row-label {
  text-align: left !important;
  font-family: var(--font-sans) !important;
  color: var(--ink-soft);
  white-space: nowrap;
}
.fin-row-label--strong {
  color: var(--ink) !important;
  font-weight: 600;
}

/* ============ EARNINGS NEXT ============ */
.earnings-next {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  padding-top: 8px;
}
@media (max-width: 700px) {
  .earnings-next { grid-template-columns: 1fr 1fr; }
}
.earnings-next__date {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
}
.earnings-next__value {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 500;
  font-family: var(--font-mono);
}

/* ============ INSIDER TRANSACTION TAG ============ */
.ins-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
/* 자기돈 매수 — 가장 강한 매수 신호 */
.ins-tag--strong-buy {
  background: rgba(52, 211, 153, 0.18);
  color: var(--up);
  font-weight: 700;
  border: 1px solid rgba(52, 211, 153, 0.35);
}
/* 시장 매도 */
.ins-tag--sell {
  background: rgba(248, 113, 113, 0.15);
  color: var(--down);
}
/* 세금용 매도 — 약한 신호 */
.ins-tag--forced {
  background: rgba(248, 113, 113, 0.06);
  color: rgba(248, 113, 113, 0.7);
}
/* 보상·증여 — 의미 없음 */
.ins-tag--neutral {
  background: var(--bg-elev);
  color: var(--ink-mute);
}
/* 옵션 행사 등 */
.ins-tag--info {
  background: rgba(232, 255, 92, 0.1);
  color: var(--accent);
}

/* ============ INSIDER ============ */
.ratio-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--line-soft);
  margin: 10px 0 12px;
}
.ratio-bar__buy  { background: var(--up); }
.ratio-bar__sell { background: var(--down); }
.ratio-legend {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-soft);
}
.ratio-legend .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.dot--up { background: var(--up); }
.dot--down { background: var(--down); }
.signal-score {
  margin: 8px 0 4px;
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
}

/* ============ ANALYST ============ */
.target-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  padding-top: 6px;
}
@media (max-width: 700px) {
  .target-row { grid-template-columns: 1fr 1fr; }
}
.target-row__num {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
}
.target-row__num--accent { color: var(--accent); }

.rec-bars { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.rec-row {
  display: grid;
  grid-template-columns: 70px 1fr 30px;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}
.rec-row__label { color: var(--ink-soft); }
.rec-row__bar {
  background: var(--line-soft);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}
.rec-row__bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.rec-row__count {
  font-family: var(--font-mono);
  color: var(--ink-mute);
  text-align: right;
}

/* ============ NEWS ============ */
.news-list { display: flex; flex-direction: column; gap: 12px; }
.news-item {
  padding: 20px 22px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  transition: border-color 120ms ease;
}
.news-item:hover { border-color: rgba(232,255,92,0.3); }
.news-item__meta {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--ink-mute);
}
.news-item__source { color: var(--accent); font-weight: 500; }
.news-item__title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.news-item__summary {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.6;
}

/* ============ FILINGS ============ */
.filing-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.filter-chip {
  padding: 8px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 12px;
}
.filter-chip:hover { color: var(--ink); border-color: var(--ink-mute); }
.filter-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.filing-tag {
  display: inline-block;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  color: var(--ink-soft);
}

/* ============ RESPONSIVE — DETAIL PAGE MOBILE ============ */
@media (max-width: 720px) {
  .detail { padding: 20px 12px 60px; }

  /* 종목 가격 바 */
  .stock-bar__inner { padding: 18px 18px 16px; gap: 12px; }
  .stock-bar__name { font-size: 22px; }
  .stock-bar__price-now { font-size: 28px; }
  .stock-bar__price-chg { font-size: 13px; }

  /* 탭 네비게이션 */
  .tabs { padding: 4px; margin-bottom: 16px; }
  .tab { padding: 8px 12px; font-size: 13px; }

  /* 섹션 헤딩 */
  .section-block { padding: 28px 0 16px; gap: 14px; }
  .section-block__title { font-size: 18px; }

  /* 카드 */
  .card { padding: 18px 16px; }
  .card__title { font-size: 14px; }
  .card__body { font-size: 13px; line-height: 1.6; }
  .card--table { padding: 18px 0 6px; }
  .card--table .card__title { padding: 0 16px 14px; }
  .card--table > .muted { padding: 10px 16px 14px; }

  /* 핵심 지표 */
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-cell { padding: 12px 10px; }
  .metric-cell__label { font-size: 10px; }
  .metric-cell__value { font-size: 13px; }

  /* KV 리스트 */
  .kv { grid-template-columns: 1fr; gap: 8px; }

  /* 재무제표 sub-tabs */
  .sub-tabs { flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
  .sub-tab { padding: 6px 10px; font-size: 12px; }
  .period-toggle { margin-left: 0; margin-top: 4px; }
  .period-btn { padding: 5px 10px; font-size: 11px; }

  /* 테이블 폰트만 작게 (스크롤은 .table-scroll wrapper 또는 .financials-table이 처리) */
  .card--table table { font-size: 12px; }
  .card--table th, .card--table td {
    padding: 10px 12px;
    white-space: nowrap;
  }
  .card--table th { font-size: 10px; }
  .financials-table { padding: 0 12px; }

  /* 실적 발표 카드 */
  .earnings-next { grid-template-columns: 1fr 1fr; gap: 14px; }
  .earnings-next__date { font-size: 18px; }
  .earnings-next__value { font-size: 15px; }

  /* 애널리스트 목표가 */
  .target-row { grid-template-columns: 1fr 1fr; gap: 12px; }
  .target-row__num { font-size: 16px; }

  /* 추천 분포 bars */
  .rec-row { grid-template-columns: 60px 1fr 26px; gap: 8px; font-size: 11px; }

  /* 뉴스 */
  .news-item { padding: 16px 14px; }
  .news-item__title { font-size: 14px; line-height: 1.4; }
  .news-item__summary { font-size: 12px; }

  /* 공시 필터 */
  .filing-filter { gap: 6px; }
  .filter-chip { padding: 6px 10px; font-size: 11px; }

  /* 시그널 점수 (내부자) */
  .signal-score { font-size: 26px; }
  .ratio-bar { height: 10px; }
  .ratio-legend { font-size: 11px; flex-direction: column; gap: 4px; }

  /* 헤더 */
  .header__inner { padding: 10px 14px; }
  .brand__name { font-size: 15px; }
}

@media (max-width: 480px) {
  .stock-bar__name { font-size: 20px; line-height: 1.2; }
  .stock-bar__price-now { font-size: 24px; }
  .section-block__title { font-size: 16px; }
  .target-row { grid-template-columns: 1fr; }
  .earnings-next { grid-template-columns: 1fr; }
  .card--table table { min-width: 480px; }
}
