/* =========================================
   1. CSS Variables & Reset
   ========================================= */
:root {
  /* Brand Colors */
  --primary: #4F46E5;       /* 메인 인디고 */
  --primary-dark: #4338ca;  /* 호버/강조 */
  --primary-light: #e0e7ff; /* 연한 배경 */
  
  /* Status Colors */
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --success: #10b981;
  
  /* Backgrounds */
  --bg-body: #F8FAFC;       /* 전체 배경 */
  --bg-card: #FFFFFF;       /* 카드/섹션 배경 */
  --bg-input: #F1F5F9;
  
  /* Text Colors */
  --text-main: #1E293B;     /* 제목/본문 */
  --text-sub: #64748B;      /* 설명/날짜 */
  --text-inverse: #FFFFFF;
  
  /* Borders & Shadows */
  --border: #E2E8F0;
  --radius: 14px;           /* 둥근 모서리 통일 */
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  
  /* Layout */
  --max-width: 1200px;
  --header-height: 60px;
  --header-height-mobile: 54px;
}

/* 다크 모드 (시스템 설정 자동 감지) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-body: #0F172A;
    --bg-card: #1E293B;
    --bg-input: #334155;
    
    --text-main: #F1F5F9;
    --text-sub: #94A3B8;
    
    --border: #334155;
    --primary-light: #1e3a8a; /* 다크모드에서 연한 배경색 조정 */
    --danger-bg: #450a0a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 40px; /* 하단 여백 확보 */
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }

/* =========================================
   2. Layout & Container
   ========================================= */
.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
}

/* 섹션 공통 (카드 형태의 컨테이너) */
.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.sec-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.5); /* 미세한 회색 배경 */
  display: flex; align-items: center; justify-content: space-between;
}
@media (prefers-color-scheme: dark) { .sec-head { background: rgba(15, 23, 42, 0.3); } }

.sec-title { font-size: 16px; font-weight: 700; color: var(--text-main); }
.sec-body { padding: 16px; }

/* =========================================
   3. Navigation (Sticky & Scrollable)
   ========================================= */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  width: 100%;
}
@media (prefers-color-scheme: dark) {
  .nav { background: rgba(15, 23, 42, 0.85); }
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
  height: var(--header-height);
  display: flex;
  align-items: center;

  /* 🔥 드롭다운 허용 */
  overflow: visible;
}

.nav-inner::-webkit-scrollbar { display: none; }

.tabs {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
  width: max-content;

  /* ✅ 가로 스크롤 담당 */
  overflow-x: auto;
  overflow-y: visible;

  -ms-overflow-style: none;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px;
  border-radius: 99px;
  font-size: 14px; font-weight: 600;
  color: var(--text-sub);
  background: var(--bg-card);
  border: 1px solid var(--border);
  white-space: nowrap;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.tab:hover { background: var(--bg-input); color: var(--text-main); }
.tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

/* 관리자/특수 탭 */
.tab.admin { background: #f3e8ff; color: #7e22ce; border-color: #d8b4fe; }
@media (prefers-color-scheme: dark) { .tab.admin { background: #3b0764; color: #d8b4fe; border-color: #6b21a8; } }

/* 모바일 네비게이션 최적화 */
@media (max-width: 768px) {
  .nav-inner { padding: 0 12px; height: var(--header-height-mobile); }
  .tabs { gap: 6px; }
  .tab { padding: 6px 12px; font-size: 13px; }
}
/* [NEW] 테이블 컬럼 너비 제어 (PC 화면용) */
@media (min-width: 769px) {
  .col-checkbox { width: 40px; text-align: center; }
  .col-name     { width: 220px; } /* 종목명/코드 */
  .col-sector   { width: 120px; } /* 섹터 */
  .col-status   { width: 80px; }  /* 상태 */
  .col-price    { width: 130px; } /* 매수/매도 */
  .col-note     { width: auto; }  /* 메모 (나머지 공간 차지) */
  .col-manage   { width: 80px; text-align: right; }
}

/* =========================================
   4. Common Components (Btn, Card, Badge)
   ========================================= */
/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 700; font-size: 14px;
  border: 1px solid transparent;
  transition: opacity 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: var(--bg-card); border-color: var(--primary); color: var(--primary); }
.btn:active { transform: scale(0.98); }

/* 카드 (그리드 내부 아이템) */
.card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
}

/* 뱃지/칩 */
.badge {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text-sub);
}

/* =========================================
   5. Utilities & Helper Classes
   ========================================= */
.d-none { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }

/* Grid Helper */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

/* =========================================
   6. Footer
   ========================================= */
.site-footer {
  margin-top: 40px; padding: 32px 0;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}
.foot-inner { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }
.foot-title { font-size: 14px; font-weight: 800; color: var(--text-main); margin-bottom: 8px; }
.foot-text { font-size: 13px; color: var(--text-sub); line-height: 1.6; }

/* =========================================
   7. Loading Overlay
   ========================================= */
.loading-mask {
  position: fixed; inset: 0; z-index: 9999;
  display: none; /* JS로 제어 */
  align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}
.loading-card {
  background: var(--bg-card); color: var(--text-main);
  border-radius: 16px; padding: 24px;
  box-shadow: var(--shadow-md); text-align: center;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================
   8. Navigation Specifics (Added)
   ========================================= */

/* 네비게이션 구분선 (세로줄) */
.nav-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* 무료 횟수 뱃지 */
.badge-usage {
  background: var(--danger-bg); 
  color: var(--danger); 
  font-size: 11px; font-weight: 700;
  padding: 6px 10px; 
  border-radius: 99px; 
  white-space: nowrap;
  display: inline-flex; 
  align-items: center;
}

/* 모바일 공간 확보를 위한 텍스트 숨김 처리 */
@media (max-width: 480px) {
  .usage-text-full { display: none; }
}

/* =========================================
   9. About / Hero / Steps / FAQ / Disclaimer
   ========================================= */

/* Hero */
.hero.section {
  border-radius: var(--radius);
  overflow: hidden;
}
.hero .sec-body {
  padding: 22px 18px;
  background:
    radial-gradient(900px 260px at 20% 0%, rgba(79,70,229,0.18), transparent 55%),
    radial-gradient(900px 280px at 90% 10%, rgba(16,185,129,0.12), transparent 55%),
    var(--bg-card);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
}

.hero-title {
  margin: 12px 0 8px;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 900;
  color: var(--text-main);
}

.hero-sub {
  margin: 0;
  margin-top: 8px;
  color: var(--text-sub);
  font-size: 14px;
  line-height: 1.65;
}
.hero-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-sub);
}

/* CTA Row */
.cta-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* base.css의 .btn 확장 */
.btn { text-decoration: none; }
.btn-admin {
  background: #f3e8ff;
  color: #7e22ce;
  border-color: #d8b4fe;
}
@media (prefers-color-scheme: dark) {
  .btn-admin { background: #3b0764; color: #d8b4fe; border-color: #6b21a8; }
}

/* 카드 내부 typography */
.card h4 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}
.card p {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-sub);
  line-height: 1.7;
}

/* Links inside content */
.link {
  color: var(--primary);
  font-weight: 800;
  border-bottom: 1px dashed rgba(79,70,229,0.45);
}
.link:hover { opacity: 0.85; }
.link-admin { color: #7e22ce; border-bottom-color: rgba(126,34,206,0.45); }

/* Step List */
.step-list {
  display: grid;
  gap: 10px;
}

.step-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.step-num {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #fff;
  background: var(--primary);
  flex: 0 0 34px;
}

.step-content b {
  display: inline-block;
  margin-bottom: 4px;
  color: var(--text-main);
  font-weight: 900;
  font-size: 14px;
}
.step-content p {
  margin: 0;
  color: var(--text-sub);
  font-size: 13.5px;
  line-height: 1.65;
}

/* highlight variants */
.step-item-highlight {
  border-color: rgba(79,70,229,0.35);
  background: rgba(79,70,229,0.06);
}
.step-num-star { background: var(--primary-dark); }

.step-item-admin {
  border-color: rgba(126,34,206,0.35);
  background: rgba(126,34,206,0.06);
}
.step-num-admin { background: #7e22ce; }

/* FAQ */
.qa {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  padding: 10px 12px;
  margin-bottom: 10px;
}

.qa summary {
  cursor: pointer;
  list-style: none;
  font-weight: 900;
  color: var(--text-main);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.qa summary::-webkit-details-marker { display: none; }

.qa summary::after {
  content: "▾";
  color: var(--text-sub);
  font-weight: 900;
  transition: transform 0.15s ease;
}
.qa[open] summary::after { transform: rotate(180deg); }

.qa-body {
  margin-top: 8px;
  color: var(--text-sub);
  font-size: 13.5px;
  line-height: 1.7;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

/* Disclaimer */
.disclaimer {
  margin-top: 16px;
  background: var(--danger-bg);
  border: 1px solid rgba(239,68,68,0.25);
  color: var(--text-main);
  border-radius: var(--radius);
  padding: 14px 16px;
  line-height: 1.7;
  box-shadow: var(--shadow-sm);
}
.disclaimer b { color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .disclaimer { border-color: rgba(239,68,68,0.35); }
}

/* Mobile typography tweak */
@media (max-width: 480px) {
  .hero-title { font-size: 26px; }
  .cta-row .btn { width: 100%; justify-content: center; }
}

/* =========================================
   10. Shared Forms & Inputs
   ========================================= */

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.form-row.inline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-row label {
  font-size: 13px;
  color: var(--text-sub);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* inputs */
input[type="text"],
input[type="date"],
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  width: min(100%, 440px);
  background: var(--bg-card);
  color: var(--text-main);
  transition: box-shadow .15s ease, border-color .15s ease;
}

textarea {
  width: min(100%, 760px);
  min-height: 108px;
  line-height: 1.5;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

/* buttons: legacy compat (.btn.alt / .btn.icon) */
.btn.alt {
  background: var(--bg-card);
  border: 1px solid var(--primary);
  color: var(--primary);
}
.btn.icon { padding: 11px 13px; }

/* =========================================
   11. Notices / Helpers
   ========================================= */

.notice {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px dashed rgba(79,70,229,0.35);
  background: rgba(79,70,229,0.08);
  border-radius: 12px;
  color: var(--text-main);
  font-size: 13px;
}

/* =========================================
   12. Lists / Result Cards (Discover style)
   ========================================= */

.list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 768px) {
  .list { grid-template-columns: 1fr 1fr; }
  textarea { width: 760px; }
}

/* card 내부 구조 (base의 .card를 그대로 쓰되, 내부만 확장) */
.card .top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.code { font-weight: 900; color: var(--text-main); }
.name { color: var(--text-main); font-weight: 800; opacity: 0.9; }

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.kv {
  font-size: 13px;
  color: var(--text-sub);
  display: grid;
  gap: 4px;
}

/* Pills row */
.pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-main);
}

/* =========================================
   13. Toast (Sticky message)
   ========================================= */

.toast {
  position: sticky;
  top: 8px;
  z-index: 30;
  display: none;
  align-items: flex-start;
  gap: 10px;
  background: rgba(15,23,42,0.92);
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 12px 28px rgba(15,23,42,.25);
  backdrop-filter: blur(8px);
}
.toast.show { display: flex; animation: slideDown .18s ease-out; }
.toast .msg { flex: 1; font-size: 14px; }
.toast .close {
  background: transparent;
  color: #fff;
  border: 0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
@keyframes slideDown {
  from { transform: translateY(-6px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* =========================================
   14. Inline Checks
   ========================================= */

.check-row.inline {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.check-row.inline::-webkit-scrollbar { display: none; }

.check-row.inline .check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.check-row.inline input[type="checkbox"] { margin: 0; }

/* =========================================
   15. Client Controls (Filter & Sort)
   ========================================= */

.control-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-input);
  margin: 0 0 12px 0;
}

.control-bar .group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.control-bar .title { font-size: 13px; color: var(--text-sub); font-weight: 800; }

.control-bar .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  user-select: none;
}
.control-bar .chip input { margin: 0; }

.control-bar select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text-main);
}
.control-bar .spacer { flex: 1; }

.control-bar .group.one-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.control-bar .group.one-line select { min-width: 180px; }

/* =========================================
   16. Badge Variants (Market / Category)
   ========================================= */

/* Market badges */
.badge.mk-kospi  { background: rgba(6,182,212,0.10); border-color: rgba(6,182,212,0.25); color: #0369a1; }
.badge.mk-kosdaq { background: rgba(250,204,21,0.16); border-color: rgba(250,204,21,0.30); color: #92400e; }

@media (prefers-color-scheme: dark){
  .badge.mk-kospi  { background: rgba(6,182,212,0.12); border-color: rgba(6,182,212,0.28); color: #7dd3fc; }
  .badge.mk-kosdaq { background: rgba(250,204,21,0.12); border-color: rgba(250,204,21,0.28); color: #facc15; }
}

/* Condition category badges */
.badge-cat-buy  { background: rgba(239,68,68,0.12);  color: #b00020; border: 1px solid rgba(239,68,68,0.25); }
.badge-cat-sell { background: rgba(59,130,246,0.12); color: #0b5ed7; border: 1px solid rgba(59,130,246,0.25); }
.badge-cat-etc  { background: rgba(148,163,184,0.18); color: var(--text-sub); border: 1px solid var(--border); }

/* =========================================
   17. Range Selector Chips
   ========================================= */

.range-selector { display: flex; gap: 8px; flex-wrap: wrap; }

.range-chip { position: relative; cursor: pointer; }
.range-chip input { position: absolute; opacity: 0; width: 0; height: 0; }

.range-chip span {
  display: inline-block;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-sub);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all 0.2s;
}
.range-chip input:checked + span {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: rgba(79,70,229,0.45);
}
.range-chip:hover span { opacity: 0.9; }

/* =========================================
   18. Multi-hit Highlight
   ========================================= */

.card.multi-hit {
  border: 2px solid rgba(245,158,11,0.75) !important;
  box-shadow: 0 0 15px rgba(245,158,11,0.18);
  background: linear-gradient(to bottom right, var(--bg-card), rgba(245,158,11,0.08));
  position: relative;
  overflow: visible;
}
@media (prefers-color-scheme: dark){
  .card.multi-hit {
    background: linear-gradient(to bottom right, var(--bg-card), rgba(245,158,11,0.12));
    border-color: rgba(217,119,6,0.85) !important;
  }
}

.multi-hit-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(245,158,11,0.18);
  color: #92400e;
  border: 1px solid rgba(245,158,11,0.35);
  font-size: 12px;
  font-weight: 900;
  padding: 6px 10px;
  border-radius: 10px;
  margin-bottom: 10px;
  width: fit-content;
}
@media (prefers-color-scheme: dark){
  .multi-hit-badge { color: #fbbf24; }
}
.multi-hit-badge i { font-style: normal; }

/* =========================================
   19. Empty State
   ========================================= */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-input);
  border-radius: 12px;
  border: 1px dashed var(--border);
  margin: 20px 0;
  color: var(--text-sub);
}
.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.6;
}
.empty-content h3 {
  margin: 0 0 10px 0;
  font-size: 18px;
  color: var(--text-main);
  font-weight: 900;
}
.empty-content p {
  margin: 4px 0;
  font-size: 15px;
  line-height: 1.5;
}
.empty-content .sub-text {
  font-size: 13px;
  color: var(--text-sub);
  margin-top: 8px;
}
/* =========================================
   20. Table Card / Watch UI Pack
   - (원래 template <style>를 base로 이동)
   - base의 .badge/.btn는 재정의하지 않음(중복 제거)
   ========================================= */

/* 카드 컨테이너(테이블을 감싸는 카드) */
.list-card{
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 24px;
}

/* ===== Table (PC 기본) ===== */
.w-table{
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.w-table th{
  background: var(--bg-input);
  color: var(--text-sub);
  font-weight: 700;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.w-table td{
  padding: 14px 16px;
  border-bottom: 1px solid rgba(148,163,184,0.18);
  color: var(--text-main);
  vertical-align: middle;
}

.w-table tr:last-child td{ border-bottom: none; }

/* 상태 배지(기존 .badge를 그대로 쓰고 변형만 추가) */
.badge-buy      { background: rgba(239,68,68,0.12);  color: var(--danger); }
.badge-sell     { background: rgba(59,130,246,0.12); color: #3b82f6; }
.badge-interest { background: rgba(148,163,184,0.18); color: #4b5563; }

/* 아이콘 버튼(공유/삭제 등) */
.btn-icon{
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform .15s;
}
.btn-icon:hover{ background: var(--bg-input); }
.btn-icon:active{ transform: scale(0.98); }

.btn-del{
  color: var(--danger);
  border-color: rgba(239,68,68,0.25);
  margin-left: 4px;
}
.btn-del:hover{ background: rgba(239,68,68,0.10); }

/* ===== Header / Search ===== */
.page-header{
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.header-top{
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.page-title{
  font-size: 22px;
  font-weight: 900;
  color: var(--text-main);
  margin: 0;
}

.page-desc{
  font-size: 13px;
  color: var(--text-sub);
  margin-top: 4px;
}

/* 검색 + 버튼 툴바 */
.header-tools{
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 10px;
}

.search-container{
  position: relative;
  width: 100%;
  max-width: 320px;
  flex-shrink: 0;
}

.search-wrap{
  position: relative;
  width: 100%;
}

/* 아이콘 폭 + 여유만큼 padding-left 증가 */
.search-input{
  width: 100%;
  padding: 10px 12px 10px 42px; /* ← 36px → 42px */
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text-main);
}

/* 아이콘은 클릭/타이핑을 방해하지 않게 */
.search-icon{
  position: absolute;
  left: 14px;                 /* 아이콘 위치 살짝 오른쪽 */
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 14px;
  pointer-events: none;       /* ⭐ 중요 */
}

/* 자동완성 리스트 */
.search-results{
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.10);
  margin-top: 6px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}
.search-item{
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(148,163,184,0.18);
}
.search-item:last-child{ border-bottom: none; }
.search-item:hover{ background: var(--bg-input); color: var(--primary); }

.s-name{ font-weight: 800; font-size: 14px; }
.s-code{ font-size: 12px; color: var(--text-sub); }

/* ===== Share UI (Mobile/PC switch) ===== */
.btn-mobile-share{
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  transition: opacity 0.2s, transform .15s;
  flex-grow: 1;
  justify-content: center;
  white-space: nowrap;
}
.btn-mobile-share:hover{ opacity: .92; }
.btn-mobile-share:active{ transform: scale(.98); }

.pc-share-container{
  display: none; /* PC에서만 보이게 */
  gap: 8px;
  align-items: center;
}

.sns-btn{
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: transform 0.2s, opacity .2s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  text-decoration: none;
}
.sns-btn:hover{ transform: translateY(-3px); opacity: .95; }

.sns-kakao{ background: #FAE100; color: #371D1E; }
.sns-tele { background: #2AABEE; color: #fff; }
.sns-x    { background: #000; color: #fff; }
.sns-copy { background: var(--bg-card); border: 1px solid var(--border); color: #475569; }

/* 체크박스 */
.chk-custom{
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ===== Responsive: 모바일 카드 뷰 ===== */
@media (max-width: 768px){
  .w-table thead{ display:none; }
  .w-table, .w-table tbody, .w-table tr, .w-table td{ display:block; width:100%; }

  .w-table tr{
    position: relative;
    background: var(--bg-card);
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 16px 16px 46px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  }

  /* 체크박스 고정 */
  .w-table td:nth-child(1){
    position:absolute;
    top:16px;
    left:12px;
    width:auto;
    padding:0;
    border:none;
  }

  /* 내용 배치 */
  .w-table td:nth-child(2){ padding:0 0 8px 0; border:none; }
  .w-table td:nth-child(3),
  .w-table td:nth-child(4){
    display:inline-block;
    width:auto;
    padding:0 8px 8px 0;
    border:none;
  }

  /* 목표가 박스 */
  .w-table td:nth-child(5),
  .w-table td:nth-child(6){
    display:inline-block;
    width:48%;
    background: var(--bg-input);
    padding:8px 10px;
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 13px;
    border: 1px solid rgba(148,163,184,0.18);
    box-sizing: border-box;
  }
  .w-table td:nth-child(5)::before{ content:"매수: "; color: var(--text-sub); font-weight: 800; }
  .w-table td:nth-child(6)::before{ content:"매도: "; color: var(--text-sub); font-weight: 800; }

  .w-table td:nth-child(7){
    padding:4px 0 12px 0;
    font-size:13px;
    color: var(--text-sub);
    border:none;
    white-space: normal;
    display:block;
  }

  .w-table td:last-child{
    border-top: 1px solid rgba(148,163,184,0.18);
    padding-top: 10px;
    text-align: right;
  }
}

/* ===== Responsive: PC에서 아이콘 공유 노출 ===== */
@media (min-width: 769px){
  .page-header{
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
  }
  .header-top{ margin-bottom: 0; max-width: 50%; }

  .header-tools{
    width: auto;
    margin-top: 0;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }
  .search-container{ width: 240px; }

  .btn-mobile-share{ display: none !important; }
  .pc-share-container{ display: flex !important; }
}

/* =========================================
   21. Modal (Shared)
   ========================================= */

.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal-content{
  background: var(--bg-card);
  width: 90%;
  max-width: 420px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  animation: popUp 0.2s ease-out;
  border: 1px solid var(--border);
}

@keyframes popUp{
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.modal-header{
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-input);
}
.modal-title{
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  color: var(--text-main);
}
.modal-body{ padding: 20px; }

.modal-footer{
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-input);
}

/* 모달 폼 */
.form-group{ margin-bottom: 14px; }
.form-label{
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-sub);
  margin-bottom: 6px;
}
.form-input{
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  background: var(--bg-card);
  color: var(--text-main);
}
.input-readonly{
  background-color: var(--bg-input);
  color: var(--text-sub);
  cursor: not-allowed;
  border-color: var(--border);
}

/* 모달 버튼(가능하면 base .btn를 쓰는 게 좋지만, 기존 호환을 위해 유지) */
.btn-save{
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 900;
}
.btn-cancel{
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--text-main);
  font-weight: 900;
}
.btn-close{
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: #94a3b8;
}
/* =========================================
   22. Analysis / Chat UI Pack
   - template <style>를 base로 이동
   - 전역 .container / input,textarea 재정의 금지(충돌 방지)
   ========================================= */

/* 레이아웃: 기존 .wrap을 사용 권장
   (혹시 템플릿이 .container를 쓰고 있다면, 아래는 호환용) */
.container {
  max-width: var(--max-width);
  margin: 30px auto;
  padding: 0 15px;
}

/* 입력 줄 */
.input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

/* 자동완성 wrapper */
.autocomplete-wrapper {
  position: relative;
  flex: 1;
}

/* ✅ 전역 input/textarea 대신, 이 페이지 전용 클래스만 제공
   템플릿에서 input에 class="analysis-input" 같이 붙여 쓰는 걸 권장 */
.analysis-input,
.analysis-textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  box-sizing: border-box;
  background: var(--bg-card);
  color: var(--text-main);
}

.analysis-input:focus,
.analysis-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

/* 자동완성 드롭다운 */
#stock-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid rgba(79,70,229,0.45);
  border-top: none;
  border-radius: 0 0 12px 12px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 9999;
  box-shadow: 0 10px 18px rgba(0,0,0,0.12);
}

.dropdown-item {
  padding: 12px 15px;
  border-bottom: 1px solid rgba(148,163,184,0.18);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:active { background-color: rgba(79,70,229,0.08); }

.stock-info { display: flex; flex-direction: column; }
.stock-name { font-weight: 900; font-size: 15px; color: var(--text-main); }
.stock-code-sub { font-size: 12px; color: var(--text-sub); }

.stock-sector-tag {
  font-size: 11px;
  background: var(--bg-input);
  color: var(--text-sub);
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* 질문 템플릿 버튼 */
.template-container {
  margin: 15px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tpl-btn {
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-sub);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}
.tpl-btn:hover {
  border-color: rgba(79,70,229,0.45);
  color: var(--primary);
}

/* 차트/결과 박스: 가능하면 .section/.card 를 쓰는 게 베스트
   (기존 id가 있어서 호환용으로도 스타일 제공) */
#analysis-chart-container,
#analysis-result {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

#analysis-result {
  line-height: 1.8;
  color: var(--text-main);
  min-height: 200px;
  margin-top: 20px;
  font-size: 15px;
  overflow-x: auto;
}

/* 결과 내 테이블(마크다운 렌더링) */
#analysis-result table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
  font-size: 14px;
}
#analysis-result th,
#analysis-result td {
  border: 1px solid rgba(148,163,184,0.35);
  padding: 10px;
  text-align: center;
}
#analysis-result th { background-color: var(--bg-input); }

/* 상태 컬러 */
.status-up { color: var(--danger); font-weight: 900; }
.status-down { color: #005cc5; font-weight: 900; }

.loading {
  color: var(--primary);
  font-weight: 900;
  text-align: center;
  padding: 40px 0;
}

/* 파동 표 컨테이너 */
#cycle-table-container {
  margin-top: 15px;
  display: none;

  max-height: 300px;
  overflow-y: auto;
  overflow-x: auto;

  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  padding: 15px;
}

/* 파동 표 */
.cycle-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.cycle-table th,
.cycle-table td {
  padding: 10px;
  text-align: center;
  border-bottom: 1px solid rgba(148,163,184,0.18);
}

/* 헤더 sticky */
.cycle-table th {
  position: sticky;
  top: 0;
  background: var(--bg-input);
  z-index: 1;
  font-weight: 800;
  color: var(--text-sub);
  border-bottom: 2px solid rgba(148,163,184,0.35);
}

/* 타입 라벨 */
.type-high {
  color: var(--danger);
  font-weight: 900;
  background: rgba(239,68,68,0.10);
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(239,68,68,0.22);
}
.type-low {
  color: #005cc5;
  font-weight: 900;
  background: rgba(0,92,197,0.10);
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(0,92,197,0.22);
}

@media (max-width: 768px) {
  .cycle-table { font-size: 12px; }
  .cycle-table th, .cycle-table td { padding: 8px 4px; }
}
/* =========================================
   23. Cycle Table Header (JS-rendered)
   ========================================= */

.cycle-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 6px 10px;
  border-bottom: 1px solid var(--border);
}

.cycle-head-left h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  color: var(--text-main);
}

.cycle-head-left .code {
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 500;
  margin-left: 4px;
}

.cycle-head-left .ref-date {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-sub);
}

.cycle-head-right {
  text-align: right;
}

.cycle-head-right .label {
  display: block;
  font-size: 11px;
  color: var(--text-sub);
}

.cycle-head-right .price {
  font-size: 18px;
  font-weight: 900;
  color: var(--text-main);
}
/* =========================================
   30. AI Prompt / Analysis Common UI
   ========================================= */

/* --- 카드 --- */
.ai-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

/* --- 가이드 박스 --- */
.guide-box {
  background: linear-gradient(145deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: 20px;
  margin-top: 24px;
}

.guide-title {
  color: #0369a1;
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 12px;
}

.step-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-num {
  background: #0ea5e9;
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11px;
  flex-shrink: 0;
}

.step-text {
  font-size: 14px;
  color: #334155;
  line-height: 1.5;
}

.step-text b {
  color: #0c4a6e;
}

/* --- 폼 --- */
.form-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-body);
  color: var(--text-main);
  font-size: 15px;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
}

/* --- 자동완성 --- */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 999;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 250px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: none;
}

.autocomplete-item {
  padding: 12px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-main);
}

.autocomplete-item:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

/* --- 버튼 --- */
.action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.btn-ai {
  flex: 1;
  min-width: 100px;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  border: none;
  color: #fff;
  transition: opacity 0.2s;
}

.btn-ai:hover {
  opacity: 0.9;
}

.btn-gpt { background: #10a37f; }
.btn-gemini { background: linear-gradient(135deg, #4E79E6 0%, #8B5CF6 100%); }
.btn-claude { background: #da7756; }

.btn-copy {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  flex: 0 0 auto;
}

/* --- 프롬프트 --- */
.prompt-area {
  width: 100%;
  min-height: 300px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-main);
  font-family: monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
}

.prompt-area:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}

.step-badge {
  display: inline-block;
  background: #EFF6FF;
  color: var(--primary);
  font-weight: 800;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 12px;
}
/* =========================================
   31. Page Head / AI Prompt Layout helpers
   ========================================= */

.page-head { margin-bottom: 24px; }
.page-head-title { margin: 0; font-size: 20px; font-weight: 900; color: var(--text-main); }
.page-head-desc { margin-top: 6px; font-size: 15px; color: var(--text-sub); }

/* 2-column responsive grid */
.ai-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
}

.ai-col { min-width: 320px; }
.ai-col-wide { min-width: 320px; }

@media (min-width: 900px) {
  .ai-grid { grid-template-columns: 1fr 1.4fr; }
}

/* small title inside ai-card */
.ai-card-title {
  margin: 0 0 20px 0;
  font-size: 18px;
  font-weight: 900;
  color: var(--text-main);
}

.ai-field { margin-bottom: 24px; }

/* loading */
.ai-loading {
  margin-top: 20px;
  text-align: center;
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
}

/* spinner size */
.spinner-sm {
  width: 24px;
  height: 24px;
  border-width: 3px;
  margin: 0 auto 10px;
}

/* width utility */
.w-100 { width: 100%; }

/* download note */
.download-note {
  background: rgba(16,185,129,0.10);
  border: 1px solid rgba(16,185,129,0.35);
  color: #064e3b;
  padding: 14px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 20px;
}
@media (prefers-color-scheme: dark) {
  .download-note { color: #a7f3d0; }
}

.download-note-sub { margin-left: 6px; }
.download-link {
  text-decoration: underline;
  font-weight: 900;
  color: #047857;
}

/* placeholder */
.ai-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  color: var(--text-sub);
  text-align: center;
  border-style: dashed;
  background: var(--bg-card);
}
.ai-placeholder-icon {
  font-size: 40px;
  margin-bottom: 10px;
  opacity: 0.55;
}
/* =========================================
   32. Chart Page Pack (toolbar / chart / legend / ai result)
   - base의 body/wrap/card/badge/btn/list 중복 제거 버전
   ========================================= */

/* Toolbar (버튼은 base .btn 사용) */
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* 차트 컨테이너 */
#chart {
  width: 100%;
  height: 60vh;
  min-height: 500px;
}

/* code/pre 스타일 */
pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  color: var(--text-main);
}

/* 목록 박스 (base .list와 충돌 방지 위해 전용 이름으로) */
.scroll-list {
  max-height: 220px;
  overflow: auto;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px;
  background: var(--bg-card);
}

/* Custom Legend */
.legend-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  color: var(--text-main);
  background: var(--bg-card);
}

.legend-item .swatch {
  width: 14px;
  height: 4px;
  border-radius: 2px;
  background: currentColor;
}

.legend-item.off { opacity: .45; }

.legend-item .swatch.star {
  background: none !important;
  width: auto !important;
  height: auto !important;
  font-size: 18px;
  line-height: 1;
  transform: translateY(-1px);
  color: var(--text-main) !important;
}

/* AI 섹션 (섹션은 base .section 써도 되고, 단순 구분선만 제공) */
.ai-section {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

/* tpl-btn는 이미 base에 올려둔 버전이 있다면 삭제 가능
   (없다면 유지: 충돌 없이 동작하도록 변수 기반) */
.tpl-btn {
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.2s;
  color: var(--text-main);
}
.tpl-btn:hover { opacity: 0.9; }

/* AI 결과 표시 영역 */
#ai-result-display {
  background: var(--bg-card);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  min-height: 100px;
  line-height: 1.6;
  color: var(--text-main);
}

#ai-result-display table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
  font-size: 14px;
}

#ai-result-display th,
#ai-result-display td {
  border: 1px solid var(--border);
  padding: 10px;
  text-align: center;
}

#ai-result-display th {
  background: var(--bg-input);
  font-weight: 800;
  color: var(--text-main);
}

/* Loading */
.loading {
  color: var(--primary);
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Mobile chart tweak */
@media (max-width: 640px) {
  #chart { height: 94vh; min-height: 560px; }
}
/* =========================================
   33. Chart Detail Template Helpers
   ========================================= */

.page-head-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.page-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chart-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  color: var(--text-main);
}

.chart-code {
  font-weight: 700;
  color: var(--text-sub);
  font-size: 13px;
}

.chart-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--text-sub);
  font-size: 13px;
}

.dot { opacity: 0.55; }

.spacer { flex: 1; }

.muted { color: var(--text-sub); }

/* admin box list: 기존 .list 충돌 방지 */
.simple-ul { margin: 0; padding-left: 18px; }

/* pre scroll helper */
.pre-scroll { max-height: 220px; overflow: auto; }

/* mini chart block */
.chart-mini {
  width: 100%;
  height: 400px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: var(--bg-card);
}

/* Fundamental grid */
.fund-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 768px) {
  .fund-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.fund-label { font-size: 13px; color: var(--text-sub); }
.fund-value { margin-top: 6px; font-size: 22px; font-weight: 900; color: var(--text-main); }
.fund-sub { margin-top: 4px; font-size: 13px; color: var(--text-sub); }
.fund-empty { margin-top: 8px; font-size: 16px; font-weight: 900; color: #94a3b8; }

.fund-danger { color: var(--danger); }
.fund-blue { color: #3b82f6; }
.fund-score { font-size: 14px; color: var(--text-sub); font-weight: 700; }

/* Bottom action bar */
.bottom-actions {
  margin-top: 28px;
  margin-bottom: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-naver {
  background: #03C75A;
  border-color: #03C75A;
  color: #fff;
}
.btn-naver:hover { opacity: 0.92; }
/* =========================================
   34. Table Pack (sector/leader/report)
   - base의 section/sec-head/sec-body/badge/d-none/spinner 중복 제거
   ========================================= */

/* ===== Status badges (기존 badge는 유지하고 변형만 추가) ===== */
.badge-status-buy  { background: rgba(16,185,129,0.10); color: #047857; border: 1px solid rgba(16,185,129,0.30); }
.badge-status-sell { background: rgba(239,68,68,0.10);  color: #b91c1c; border: 1px solid rgba(239,68,68,0.28); }
.badge-status-etc  { background: rgba(245,158,11,0.12); color: #c2410c; border: 1px solid rgba(245,158,11,0.28); }

/* 수급 배지 */
.supply-badge{
  display: inline-block;
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 8px;
  margin-left: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-sub);
}
.supply-buy{
  color: var(--danger);
  background: rgba(239,68,68,0.10);
  border-color: rgba(239,68,68,0.20);
}
.supply-sell{
  color: #2563eb;
  background: rgba(37,99,235,0.10);
  border-color: rgba(37,99,235,0.22);
}

/* ===== Table ===== */
.table-responsive{
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-custom{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 800px;
}

/* sticky header */
.table-custom th{
  background: var(--bg-input);
  color: var(--text-sub);
  font-weight: 800;
  font-size: 13px;
  border-bottom: 2px solid var(--border);
  padding: 12px 10px;
  white-space: nowrap;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.table-custom td{
  vertical-align: middle;
  font-size: 14px;
  color: var(--text-main);
  padding: 12px 10px;
  border-bottom: 1px solid rgba(148,163,184,0.18);
}

th.sortable{
  cursor: pointer;
  user-select: none;
  transition: background 0.2s, color 0.2s;
}
th.sortable:hover{
  background: rgba(148,163,184,0.18);
  color: var(--text-main);
}
th.sortable i{
  font-size: 11px;
  margin-left: 4px;
  color: #94a3b8;
}

/* 숫자 컬러 */
.trend-up{ color: var(--danger); font-weight: 800; }
.trend-down{ color: #2563eb; font-weight: 800; }

/* leader chips */
.leader-container{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.leader-item{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-main);
}
.leader-item b{ font-weight: 800; }
.leader-item .code{ font-size: 11px; color: var(--text-sub); font-weight: 600; }

/* ===== AI Report content (markdown/html 렌더 영역) ===== */
#ai-report-content{
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-main);
}
#ai-report-content h1,
#ai-report-content h2{
  margin-top: 1.2em;
  margin-bottom: 0.6em;
  font-weight: 900;
  color: var(--text-main);
  font-size: 1.25em;
}
#ai-report-content p{ margin-bottom: 1em; }
#ai-report-content strong{
  color: var(--primary);
  background: rgba(79,70,229,0.10);
  padding: 0 4px;
  border-radius: 6px;
  font-weight: 800;
}

/* ===== Loading container (spinner는 base의 .spinner 사용 권장) ===== */
.loading-container{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

/* ===== Mobile ===== */
@media (max-width: 768px){
  .sec-title{ font-size: 15px; }
  .table-custom th,
  .table-custom td{ font-size: 12px; padding: 10px 6px; }

  .col-hide-mobile{ display: none; }

  .td-sector{
    white-space: normal;
    max-width: 90px;
    line-height: 1.4;
  }

  .leader-container{
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
  }
  .leader-item{
    background: transparent;
    border: none;
    padding: 0;
    font-size: 12px;
  }
}
/* =========================================
   35. Sector Analysis Helpers (no inline styles)
   ========================================= */

.page-title-row { display:flex; align-items:center; gap:10px; }
.page-title { margin:0; font-size:20px; font-weight:900; color: var(--text-main); }
.page-desc { margin:6px 0 0; font-size:13px; color: var(--text-sub); }

.input-w-120 { width:120px !important; }
.select-w-160 { width:160px !important; }

.section-danger { border-left: 4px solid var(--danger); }
.text-danger-strong { color: var(--danger); font-weight: 900; }

.loading-title { font-weight: 900; margin-top: 10px; }
.loading-sub { margin-top: 6px; font-size: 13px; color: var(--text-sub); }

/* AI detect row */
.ai-detect-row { display:flex; align-items:center; gap:10px; margin-bottom: 10px; }
.badge-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.ai-detect-title { font-weight: 900; color: var(--text-main); }

/* inverse pairs */
.corr-text { font-size: 12px; color: var(--text-sub); font-weight: 900; }
.move-hint { font-size: 11px; color: var(--text-sub); margin: 8px 0; }
.pair-desc { margin-top: 10px; font-size: 12px; color: var(--text-sub); line-height: 1.5; text-align: center; }

.rank-bar {
  margin-top: 12px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
}
.rank-bar.rank-top { background: var(--danger); }

.badge-winner { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.25); color: var(--danger); }
.badge-loser  { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.25); color: #0b5ed7; }

/* chart block */
.history-chart { width: 100%; height: 550px; }
.help-center { text-align:center; font-size:12px; color: var(--text-sub); margin: 10px 0 0; }
.help-sub { font-size:12px; color: var(--text-sub); }

/* table spacing helpers (bootstrap 제거 대체) */
.sec-body-tight { padding: 0; }
.th-left, .td-left { text-align: left; padding-left: 16px; }
.th-right, .td-right { padding-right: 16px; }
.td-strong { font-weight: 900; }

/* 52w position mini bar */
.pos-bar-row { display:flex; align-items:center; justify-content:center; gap:10px; }
.pos-text { font-size:12px; color: var(--text-sub); }
.pos-bar { width: 50px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.pos-bar-fill { height: 100%; background: var(--primary); }

/* 2w 강조 셀 */
.cell-2w { font-weight: 900; background: rgba(0,0,0,0.02); }

/* start hero */
.start-hero { padding: 44px 16px; text-align: center; }
.start-icon { font-size: 48px; margin-bottom: 14px; }
.start-title { font-size: 18px; font-weight: 900; color: var(--text-main); }
.start-desc { margin: 10px auto 0; max-width: 520px; font-size: 13px; color: var(--text-sub); line-height: 1.65; }

/* bottom actions (이미 chart 템플릿에서 만든게 있으면 중복 추가 X) */
.bottom-actions{
  margin-top: 14px;
  margin-bottom: 8px;
  display:flex;
  justify-content:center;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
/* 자동계산 미니 버튼 스타일 */
  .btn-calc {
    font-size: 11px; padding: 2px 6px; margin-left: 6px;
    border: 1px solid #bae6fd; background: #e0f2fe; color: #0284c7;
    border-radius: 4px; cursor: pointer; transition: 0.2s;
  }
  .btn-calc:hover { background: #bae6fd; }
  /* 종목 리스트 셀 래퍼 */
.stock-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 상단: 이름 + 코드 */
.stock-header-row {
  display: flex;
  align-items: center;
  gap: 6px; /* 이름과 코드 사이 간격 */
}

.stock-name {
  font-weight: 700;
  color: #1E293B;
  font-size: 16px;
}

/* my_watchlist */
.stock-code-link {
  font-size: 13px;
  color: #64748B;
  font-family: monospace;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s;
}

.stock-code-link:hover {
  color: #4F46E5; /* 마우스 올렸을 때 색상 */
}

/* 하단: 가격 정보 */
.price-info {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.rate-text {
  font-size: 11px;
  margin-left: 2px;
}

/* 색상 유틸리티 */
.text-red { color: #ef4444; }
.text-blue { color: #3b82f6; }
.text-gray { color: #64748b; }
/* --- 테이블 내부 요소 스타일 --- */

/* 섹터 텍스트 */
.sector-text {
  font-size: 13px;
  color: #041e4283;
  background: rgba(146, 139, 248, 0.301);
}

/* 목표가(매수/매도) 셀 래퍼 */
.price-cell-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 등락률(%) 텍스트 */
.diff-rate {
  font-size: 11px;
  font-weight: 600;
}

/* 데이터 없음 (-) 표시 */
.empty-dash {
  color: #cbd5e1;
}

/* 메모 셀 (말줄임표 처리) */
.note-cell {
  max-width: 200px;
}
.note-text {
  font-size: 13px;
  color: #64748b;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis; /* 말줄임표 (...) */
  white-space: nowrap;     /* 한 줄로 표시 */
  cursor: help;            /* [NEW] 마우스 올리면 물음표 커서(툴팁 힌트) */
}

/* 관리 버튼 셀 */
.manage-cell {
  text-align: right;
}

/* 색상 유틸리티 (재사용) */
.text-red { color: #ef4444; }
.text-blue { color: #3b82f6; }
.text-gray { color: #64748b; }

/* --- [재사용 가능] 강조/알림 박스 스타일 --- */
.notice-box {
  background-color: #fff8e1;       /* 연한 노랑 배경 */
  border: 1px solid #ffe0b2;       /* 진한 노랑 테두리 */
  color: #e65100;                  /* 텍스트 색상 (가독성 좋은 오렌지 브라운) */
  padding: 16px;                   /* 내부 여백 */
  border-radius: 8px;              /* 둥근 모서리 */
  text-align: center;              /* 텍스트 가운데 정렬 */
  font-size: 13px;                 /* 기본 폰트 크기 */
  line-height: 1.6;                /* 줄 간격 */
  margin-top: 16px;                /* 위쪽 요소와의 간격 */
  margin-bottom: 16px;             /* 아래쪽 요소와의 간격 */
}

/* 알림 박스 제목 */
.notice-title {
  font-size: 15px;
  font-weight: 700;
  display: block;                  /* 줄바꿈 효과 */
  margin-bottom: 4px;
}

/* 네이버 강조용 녹색 텍스트 */
.text-naver {
  color: #03C75A;
  font-weight: 700;
}
/* --- [NEW] 목표가 근접 알림 스타일 (1% 이내) --- */
.near-target {
  border: 2px solid #f59e0b;     /* 진한 노랑(주황) 테두리 */
  background-color: #fffbeb;     /* 연한 노랑 배경 */
  border-radius: 6px;
  padding: 4px 8px !important;   /* 내부 여백 강제 적용 */
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3); /* 은은한 그림자 */
  animation: pulse-border 1.5s infinite; /* 깜빡임 효과 */
}

/* 깜빡임 애니메이션 정의 */
@keyframes pulse-border {
  0% { border-color: #f59e0b; box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  70% { border-color: #fbbf24; box-shadow: 0 0 0 4px rgba(245, 158, 11, 0); }
  100% { border-color: #f59e0b; box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* 근접 시 텍스트 더 진하게 */
.near-target span {
  font-weight: 800 !important;
  color: #b45309 !important; /* 진한 주황색 글자 */
}
/* 정렬 가능한 헤더 스타일 */
.sortable {
  cursor: pointer;
  position: relative;
  user-select: none; /* 드래그 방지 */
}

.sortable:hover {
  background-color: #f1f5f9; /* 호버 시 배경색 변경 */
  color: #4F46E5;
}

/* 정렬 화살표 표시 (가상 요소) */
.sortable::after {
  content: '↕'; /* 기본 아이콘 */
  font-size: 11px;
  color: #cbd5e1;
  position: absolute;
  right: 8px;
  opacity: 0.5;
}

.sortable.asc::after { content: '▲'; color: #4F46E5; opacity: 1; }
.sortable.desc::after { content: '▼'; color: #4F46E5; opacity: 1; }

/* =========================================
   Target Price Page (V4.1T)
   ========================================= */

.tp-ver{
  font-size: 12px;
  font-weight: 900;
  color: var(--primary);
  background: rgba(79,70,229,0.10);
  border: 1px solid rgba(79,70,229,0.18);
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: 8px;
}

.tp-head-hint{
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 700;
}

/* 입력 영역 그리드: 모바일은 1열, 큰 화면은 1행 느낌으로 촘촘히 */
.tp-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.tp-field{ min-width: 0; }

.tp-label{
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 900;
  color: var(--text-sub);
  margin-bottom: 6px;
}

.tp-ico{ font-size: 12px; opacity: .75; }

.tp-input{
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text-main);
  transition: box-shadow .15s ease, border-color .15s ease, transform .05s ease;
}

.tp-input:focus{
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

.tp-range{
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
}

.tp-range-sep{
  color: var(--text-sub);
  font-weight: 900;
  opacity: 0.7;
}

/* 액션 */
.tp-actions{
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.tp-btn{
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 900;
}

/* 조건 텍스트 */
.tp-cond{
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 700;
}

/* 테이블 폭/열 계산 고정 */
.tp-table{
  table-layout: fixed;
  width: 100%;
}

/* ✅ 숨김 열은 "공간 유지"가 아니라 "폭을 0에 가깝게 압축" */
.tp-table col.col-hide-col{
  width: 0.001% !important;  /* 사실상 0 */
}

.tp-table th,
.tp-table td {
  text-align: center;
  vertical-align: middle;
}

/* 숨김 열 셀 자체도 폭/패딩 제거 */
.tp-table th.col-hide,
.tp-table td.col-hide{
  padding: 0 !important;
  border: 0 !important;
  width: 0 !important;
  overflow: hidden !important;
  white-space: nowrap !important;
}

/* 내용은 완전히 안 보이게 */
.tp-table th.col-hide *,
.tp-table td.col-hide *{
  display: none !important;
}
.tp-price{
  font-weight: 900;
  font-size: 16px;
}
.tp-cell-buy{
  background: rgba(79,70,229,0.08);
}
.tp-cell-sell{
  background: rgba(239,68,68,0.08);
}

.tp-num{
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.tp-buy{ color: var(--primary); }
.tp-sell{ color: var(--danger); }

/* 큰 화면에서 “한 줄” 느낌: 6칸 구성 (기간은 2칸 사용) */
@media (min-width: 992px){
  .tp-grid{
    grid-template-columns: 2.1fr 1.4fr 1.0fr 1.0fr 1.0fr; /* 기간/거래대금/점수/괴리/수익 */
    align-items: end;
  }
  .tp-span-2{ grid-column: span 1; } /* PC에서는 기간도 1칸 취급(폭이 넓으니) */
}

/* 중간 화면(태블릿)에서는 2줄로 자연스럽게 */
@media (min-width: 768px) and (max-width: 991px){
  .tp-grid{
    grid-template-columns: 1fr 1fr;
  }
  .tp-span-2{ grid-column: span 2; } /* 태블릿에서는 기간이 두 칸 먹고 위에 크게 */
}

/* 모바일에서 버튼 풀폭 */
@media (max-width: 640px){
  .tp-actions{ justify-content: center; }
  .tp-btn{ width: 100%; justify-content: center; }
  .tp-range{ grid-template-columns: 1fr; }
  .tp-range-sep{ display: none; }
}
/* ===== Target Price: support/resistance 강조 뱃지 ===== */
.tp-subline{
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.tp-chip{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 매수(지지) */
.tp-chip-buy{
  border-color: rgba(79,70,229,0.25);
  background: rgba(79,70,229,0.08);
  color: var(--primary-dark);
}
.tp-chip-buy-hot{
  border-color: rgba(79,70,229,0.55);
  background: rgba(79,70,229,0.16);
  color: var(--primary-dark);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.10);
}

/* 매도(저항) */
.tp-chip-sell{
  border-color: rgba(239,68,68,0.25);
  background: rgba(239,68,68,0.08);
  color: #b91c1c;
}
.tp-chip-sell-hot{
  border-color: rgba(239,68,68,0.55);
  background: rgba(239,68,68,0.16);
  color: #b91c1c;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.10);
}
/* 가이드 박스 스타일 */
.guide-box {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.guide-summary {
    padding: 12px 20px;
    cursor: pointer;
    background-color: #f8fafc;
    font-size: 14px;
    color: #334155;
    font-weight: 600;
    list-style: none; /* 화살표 숨김 (커스텀 가능) */
    transition: background 0.2s;
}
.guide-summary:hover {
    background-color: #f1f5f9;
}
/* details 오픈 시 화살표 회전 등 효과를 주고 싶다면 추가 가능 */

.guide-content {
    padding: 20px;
    border-top: 1px solid #e2e8f0;
}

.guide-card {
    padding: 15px;
    border-radius: 10px;
    height: 100%; /* 높이 맞춤 */
}

/* 예시 UI 박스 (실제 테이블처럼 보이게) */
.example-ui {
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.05);
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.guide-list {
    font-size: 13px;
    padding-left: 20px;
    margin-bottom: 0;
    color: #475569;
}
.guide-list li {
    margin-bottom: 6px;
    line-height: 1.5;
}
/* 1. 툴팁 전체 투명도 제거 (필수) */
.tooltip {
    opacity: 1 !important; /* 부트스트랩 기본 투명도(0.9) 무시하고 완전 불투명하게 */
}

/* 2. 툴팁 내용 박스 디자인 */
.tooltip-inner {
    background-color: #334155 !important; /* 진한 회색 배경 (완전 불투명) */
    color: #ffffff !important;             /* 흰색 글씨 */
    opacity: 1 !important;                 /* 내부도 불투명 */
    
    max-width: 280px !important;           /* 모바일 너비 제한 */
    padding: 12px 14px;                    /* 내부 여백 */
    border-radius: 8px;                    /* 둥근 모서리 */
    font-size: 13px;                       /* 글자 크기 */
    line-height: 1.5;                      /* 줄간격 확보 */
    text-align: left;                      /* 왼쪽 정렬 */
    
    /* [중요] 아래 글씨와 겹쳐 보이지 않게 그림자 추가 */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5) !important; 
    border: 1px solid rgba(255, 255, 255, 0.1); /* 살짝 테두리 */
    z-index: 9999; /* 제일 위에 표시 */
}

/* 3. 툴팁 화살표 색상 맞춤 (배경색과 동일하게) */
.bs-tooltip-top .tooltip-arrow::before, 
.bs-tooltip-auto[data-popper-placement^=top] .tooltip-arrow::before {
    border-top-color: #334155 !important;
}
.bs-tooltip-bottom .tooltip-arrow::before, 
.bs-tooltip-auto[data-popper-placement^=bottom] .tooltip-arrow::before {
    border-bottom-color: #334155 !important;
}
/* 프리셋 그리드 (PC 4열 / 태블릿 3열 / 모바일 2열) */
.preset-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1200px) {
    .preset-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 576px) {
    .preset-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 카드 기본 스타일 */
.preset-card input[type="radio"] { display: none; }

.preset-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 14px 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0; /* 테두리 얇게 */
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.preset-content .icon { font-size: 26px; margin-bottom: 8px; }

.preset-content .title { 
    font-size: 14px; 
    font-weight: 800; 
    color: #1e293b; 
    margin-bottom: 4px; 
}

/* 설명 텍스트 (쉬운 말) */
.preset-content .desc { 
    font-size: 11px; 
    color: #64748b; 
    line-height: 1.35;
    word-break: keep-all; /* 단어 단위 줄바꿈 */
    padding: 0 4px;
}

/* =========================================
   [선택 시 효과] 
   ========================================= */
/* 일반 카드 선택 시 (파랑) */
.preset-card:not(.sell-mode) input[type="radio"]:checked + .preset-content {
    background: #eff6ff;
    border-color: #3b82f6;
    border-width: 2px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    transform: translateY(-2px);
}
.preset-card:not(.sell-mode) input[type="radio"]:checked + .preset-content .title {
    color: #1d4ed8;
}

/* 로그인 */
.auth-container {
    max-width: 400px; margin: 40px auto; background: #fff; padding: 40px 30px;
    border-radius: 20px; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1); text-align: center;
  }
  .auth-title { font-size: 24px; font-weight: 800; margin-bottom: 8px; color: var(--text-main); }
  .auth-subtitle { font-size: 14px; color: var(--text-sub); margin-bottom: 30px; }
  .form-group { margin-bottom: 16px; text-align: left; }
  .form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
  .form-input { width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: #F8FAFC; outline: none; box-sizing: border-box; }
  .form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1); }
  .btn-submit { width: 100%; padding: 16px; margin-top: 10px; background: var(--primary); color: white; font-weight: 700; border: none; border-radius: 12px; cursor: pointer; transition: 0.2s; }
  .btn-submit:hover { background: var(--primary-dark); transform: translateY(-2px); }
  .auth-footer { margin-top: 24px; font-size: 14px; color: var(--text-sub); line-height: 1.8; }
  .auth-link { color: var(--primary); font-weight: 600; text-decoration: none; }
  .flash-msg { padding: 12px; border-radius: 8px; font-size: 14px; margin-bottom: 20px; text-align: left; }
  .flash-error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
  .flash-success { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
  .flash-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }

  /* 비밀번호 찾기 링크 전용 스타일 */
  .forgot-link-container { text-align: right; margin-top: -8px; margin-bottom: 16px; }
  .forgot-link { font-size: 12px; color: var(--text-sub); text-decoration: none; }
  .forgot-link:hover { color: var(--primary); }

  @media (prefers-color-scheme: dark) {
    .auth-container { background: #1E293B; border: 1px solid #334155; }
    .form-input { background: #0F172A; border-color: #334155; color: #fff; }
  }

  /* 로그인 페이지와 동일한 테마 유지 */
  .auth-container {
    max-width: 400px;
    margin: 40px auto;
    background: #fff;
    padding: 40px 30px;
    border-radius: 20px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    text-align: center;
  }

  .auth-title { font-size: 24px; font-weight: 800; margin-bottom: 8px; color: var(--text-main); }
  .auth-subtitle { font-size: 14px; color: var(--text-sub); margin-bottom: 30px; line-height: 1.5; }

  .form-group { margin-bottom: 20px; text-align: left; }
  .form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-main); }
  
  .form-input {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #F8FAFC;
    transition: all 0.2s;
    box-sizing: border-box;
    outline: none;
  }

  .form-input:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
  }

  .btn-submit {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: white;
    font-size: 16px; font-weight: 700;
    border: none; border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .btn-submit:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  }

  .auth-footer { margin-top: 24px; font-size: 14px; color: var(--text-sub); }
  .auth-link { color: var(--primary); font-weight: 600; text-decoration: none; }

  /* 다크모드 대응 */
  @media (prefers-color-scheme: dark) {
    .auth-container { background: #1E293B; border: 1px solid #334155; }
    .form-input { background: #0F172A; border-color: #334155; color: #fff; }
  }
/* ===============================
   자동매매 드롭다운 메뉴
   =============================== */

.nav-group.dropdown {
  position: relative;
}

.nav-group .parent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.nav-group .caret {
  font-size: 10px;
  margin-left: 6px;
  transition: transform 0.2s ease;
}

/* 기본: 닫힘 */
.nav-group .nav-sub {
  display: none;
  flex-direction: column;
  margin-left: 14px;
  margin-top: 6px;
  gap: 4px;
}

/* 열림 상태 */
.nav-group.open .nav-sub {
  display: flex;
}

.nav-group.open .caret {
  transform: rotate(180deg);
}

.sub-tab {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text-sub);
  text-decoration: none;
}

.sub-tab:hover {
  background: var(--bg-input);
  color: var(--primary);
}

.sub-tab.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

/* 자동매매 */
.monitoring-container { max-width: 1100px; margin-top: 2rem; }
.table thead th { background-color: #f8f9fa; border-bottom: 2px solid #dee2e6; color: #495057; font-size: 0.9rem; }
.stock-card { border: none; border-radius: 12px; transition: all 0.3s ease; }

/* 상태 배지 기본 스타일 */
.status-badge { 
    display: inline-block; 
    border-radius: 50px; 
    font-weight: 600; 
    font-size: 0.85rem; 
}

/* 배경색 클래스 정의 */
.bg-wait { background-color: #f8f9fa; color: #6c757d; border: 1px solid #dee2e6; } /* 회색 (대기) */
.bg-target { background-color: #fff3cd; color: #856404; border: 1px solid #ffeeba; } /* 노랑 (분석중) */
.bg-done { background-color: #d1e7dd; color: #0f5132; border: 1px solid #badbcc; } /* 초록 (완료) */

/* 매수/매도 텍스트 컬러 전용 */
.text-danger { color: #dc3545 !important; }  /* 빨강 (매수) */
.text-primary { color: #0d6efd !important; } /* 파랑 (매도) */
.bg-danger { background-color: #dc3545 !important; color: white !important; }
.bg-primary { background-color: #0d6efd !important; color: white !important; }

/* 애니메이션 효과 */
@keyframes pulse-yellow {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(255, 193, 7, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 193, 7, 0); }
}

.price-text { font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.sync-time { font-size: 0.85rem; color: #adb5bd; }
/* 단순 감시 중 (파란색 계열) */
.bg-monitoring { 
    background-color: #cfe2ff; 
    color: #084298; 
    border: 1px solid #b6d4fe; 
}

/* 사정권 진입 시 테이블 행 배경색 살짝 강조 */
.table-warning-light {
    background-color: rgba(255, 243, 205, 0.3);
}

/* 배지 아이콘 간격 */
.status-badge i { margin-right: 5px; }
/* 텍스트 중앙 정렬 및 폰트 설정 */
.table td {
    vertical-align: middle !important; /* 모든 셀 수직 중앙 정렬 */
    white-space: nowrap; /* 줄바꿈 방지 */
}

.price-text {
    font-family: 'Roboto Mono', 'Consolas', monospace; /* 숫자 가독성 폰트 */
    letter-spacing: -0.5px;
}
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.85rem;
    transition: all 0.2s ease-in-out;
}

/* 행에 마우스 올렸을 때 강조 효과 */
.table-hover tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.03) !important;
    cursor: default;
}

/* 목표가 텍스트에 하단 점선 효과 (선택사항) */
.text-primary.price-text {
    border-bottom: 1px dashed rgba(13, 110, 253, 0.3);
    display: inline-block;
}
/* ===== trade_history v2 ===== */

/* 큰 화면에서 더 넓게 쓰고 싶으면 container 대신 이 페이지에서만 풀어줌 */
.container {
  max-width: 1200px; /* 1200~1600 사이 취향 */
}

/* Grid: 화면 폭에 따라 자동으로 여러 카드 배치 */
.trade-grid{
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: stretch;
}

/* 카드 기본 */
.trade-card{
  border: 1px solid #e9ecef;
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  height: 100%;
}

.trade-card:hover{
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.10);
}

/* 매수/매도 구분: 좌측 라인 + 은은한 배경 */
.card-buy{
  border-left: 7px solid #dc3545 !important;
  background: linear-gradient(0deg, rgba(220,53,69,0.03), rgba(220,53,69,0.00));
}
.card-sell{
  border-left: 7px solid #0d6efd !important;
  background: linear-gradient(0deg, rgba(13,110,253,0.03), rgba(13,110,253,0.00));
}

/* 수익률 */
.profit-positive,
.profit-negative{
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.profit-positive{ color: #dc3545; }
.profit-negative{ color: #0d6efd; }

/* 종목명 말줄임 */
.stock-name{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* LOG 영역: 너무 커져서 레이아웃 깨지지 않게 */
.trade-card .log-box{
  font-size: 0.78rem;
  line-height: 1.25;
  max-height: 64px;
  overflow: hidden;
}

/* 버튼: 너무 커지지 않게 */
.trade-card .btn{
  border-radius: 10px;
}

/* (선택) 초대형 모니터에서 카드가 너무 많이 촘촘하면 제한 */
@media (min-width: 1600px){
  .trade-grid{
    grid-template-columns: repeat(5, minmax(260px, 1fr)); /* 5열 고정 예시 */
  }
}