/* ============================================================
 * Finance Pro Theme — 4jis.net 통합 디자인 시스템
 * ------------------------------------------------------------
 * 기반: ~/.claude/design-system/designs/05-finance-pro.md
 * 컨벤션: 한국 시장 (상승=빨강, 하락=파랑)
 * 적용: 모든 HTML/PHP 페이지 공통
 * ============================================================ */

:root {
  /* ===== Finance Pro 표준 토큰 ===== */
  /* 배경 계층 */
  --fin-bg-0: #0A0E14;
  --fin-bg-1: #131820;
  --fin-bg-2: #1C2330;
  --fin-bg-3: #252D3D;

  /* 텍스트 */
  --fin-text-primary: #E4E7EB;
  --fin-text-secondary: #9AA0AC;
  --fin-text-tertiary: #6C7280;
  --fin-text-disabled: #4A5160;

  /* 등락 (한국 시장 관례) */
  --fin-up: #E74C3C;
  --fin-up-bg: rgba(231, 76, 60, 0.12);
  --fin-up-border: rgba(231, 76, 60, 0.3);
  --fin-down: #3498DB;
  --fin-down-bg: rgba(52, 152, 219, 0.12);
  --fin-down-border: rgba(52, 152, 219, 0.3);
  --fin-flat: #95A5A6;

  /* 강조/액션 */
  --fin-accent: #4A9EFF;
  --fin-accent-hover: #6BB1FF;
  --fin-warning: #F39C12;
  --fin-danger: #E74C3C;

  /* 차트 시리즈 8색 */
  --fin-chart-1: #4A9EFF;
  --fin-chart-2: #00D4AA;
  --fin-chart-3: #FFB84D;
  --fin-chart-4: #FF6B9D;
  --fin-chart-5: #A78BFA;
  --fin-chart-6: #FFD93D;
  --fin-chart-7: #6EE7B7;
  --fin-chart-8: #FB923C;

  /* 경계선 */
  --fin-border: #2A3441;
  --fin-border-strong: #3A4452;

  /* 그림자 */
  --shadow-panel: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-popover: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-modal: 0 12px 40px rgba(0,0,0,0.6);

  /* 모서리 */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;

  /* 트랜지션 */
  --duration-fast: 100ms;
  --duration: 200ms;

  /* ===== 레거시 변수 호환 매핑 ===== */
  /* 기존 코드(base.css, 인라인 스타일)가 사용 중인 변수명을 Finance Pro 토큰으로 재매핑.
     주의: --green / --red 의 색상값이 한국식으로 뒤집힘 (--green=빨강, --red=파랑).
     변수 이름은 호환을 위해 유지하되, 의미는 한국 시장 관례를 따름. */
  --bg: var(--fin-bg-0);
  --surface: var(--fin-bg-1);
  --surface2: var(--fin-bg-2);
  --border: var(--fin-border);
  --primary: var(--fin-accent);
  --green: var(--fin-up);     /* 상승=빨강 (한국식) */
  --red: var(--fin-down);     /* 하락=파랑 (한국식) */
  --up: var(--fin-up);
  --down: var(--fin-down);
  --flat: var(--fin-flat);
  --yellow: var(--fin-warning);
  --purple: #A78BFA;
  --text: var(--fin-text-primary);
  --text2: var(--fin-text-secondary);
  --text3: var(--fin-text-tertiary);
}

/* ===== 기본 reset & body ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', 'Pretendard', 'Noto Sans KR', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--fin-bg-0);
  color: var(--fin-text-primary);
  overflow-x: hidden;
  word-break: keep-all;
  overflow-wrap: break-word;
  line-height: 1.6;
}

/* 숫자/데이터는 모노스페이스 + tabular-nums */
.number, .data, .price, .amount, .ratio, .percent,
.font-mono, [class*="price"], [class*="num"],
table td.num, table td.price, table td.amount {
  font-family: 'JetBrains Mono', 'IBM Plex Mono', 'D2Coding', 'Consolas', monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* 스크롤바 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--fin-bg-0);
}
::-webkit-scrollbar-thumb {
  background: var(--fin-border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--fin-border-strong);
}

/* ===== 등락 컴포넌트 헬퍼 ===== */
.fin-up, .up, [data-trend="up"] {
  color: var(--fin-up);
}
.fin-down, .down, [data-trend="down"] {
  color: var(--fin-down);
}
.fin-flat, .flat, [data-trend="flat"] {
  color: var(--fin-flat);
}

.fin-up-bg { background: var(--fin-up-bg); }
.fin-down-bg { background: var(--fin-down-bg); }

/* 가격 변동 플래시 애니메이션 */
@keyframes flash-up {
  0%, 100% { background: transparent; }
  50% { background: var(--fin-up-bg); }
}
@keyframes flash-down {
  0%, 100% { background: transparent; }
  50% { background: var(--fin-down-bg); }
}
.flash-up { animation: flash-up 200ms ease-out; }
.flash-down { animation: flash-down 200ms ease-out; }

/* ===== 기본 컴포넌트 ===== */
button, .btn {
  font-family: inherit;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: background var(--duration-fast), opacity var(--duration-fast);
}

input, select, textarea {
  background: var(--fin-bg-2);
  border: 1px solid var(--fin-border);
  color: var(--fin-text-primary);
  border-radius: var(--radius-md);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--fin-accent);
}

/* 숫자 입력은 모노스페이스 */
input[type="number"], input.number, input.price {
  font-family: 'JetBrains Mono', 'D2Coding', monospace;
  font-variant-numeric: tabular-nums;
}

/* ===== 카드 / 패널 ===== */
.card, .panel, .widget {
  background: var(--fin-bg-1);
  border: 1px solid var(--fin-border);
  border-radius: var(--radius-lg);
}

/* ===== 데이터 테이블 ===== */
table.data-table, .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--fin-bg-2);
  color: var(--fin-text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--fin-border);
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--fin-border);
  height: 32px;
}
.data-table td.num, .data-table td.price, .data-table td.amount {
  text-align: right;
  font-family: 'JetBrains Mono', 'D2Coding', monospace;
  font-variant-numeric: tabular-nums;
}
.data-table tbody tr:hover {
  background: var(--fin-bg-2);
}

/* ===== 상태 배지 ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid transparent;
}
.badge.up {
  background: var(--fin-up-bg);
  color: var(--fin-up);
  border-color: var(--fin-up-border);
}
.badge.down {
  background: var(--fin-down-bg);
  color: var(--fin-down);
  border-color: var(--fin-down-border);
}

/* ============================================================
 * 자비스 홈 버튼 (전 메뉴 헤더 통일) — 로고 브랜드색(시안/일렉트릭블루)
 * 모든 페이지가 이 CSS 를 로드하므로 .jv-home 한 곳 정의로 통일.
 * 마크업: <a class="jv-home"><img class="jv-home-mark" src="logo.png"><span class="jv-home-txt">자비스 홈</span></a>
 * ============================================================ */
:root {
  --jv-cyan: #38D6FF;   /* 로고 홀로그램 글로우 */
  --jv-blue: #4A9EFF;   /* Finance Pro 액센트 */
}
.jv-home {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 13px 4px 5px;
  border-radius: 22px;
  text-decoration: none;
  white-space: nowrap;
  color: #EAF6FF;
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  font-family: Inter, Pretendard, system-ui, "Malgun Gothic", sans-serif;
  background: linear-gradient(135deg, rgba(56, 214, 255, 0.16), rgba(74, 158, 255, 0.10));
  border: 1px solid rgba(56, 214, 255, 0.38);
  box-shadow: 0 2px 10px rgba(56, 214, 255, 0.12);
  transition: transform .12s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
.jv-home:hover, .jv-home:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(56, 214, 255, 0.65);
  box-shadow: 0 4px 16px rgba(56, 214, 255, 0.28);
  background: linear-gradient(135deg, rgba(56, 214, 255, 0.24), rgba(74, 158, 255, 0.16));
  outline: none;
}
.jv-home:focus-visible { outline: 2px solid var(--jv-cyan); outline-offset: 2px; }
.jv-home-mark {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 38%;     /* 4명 실루엣/홀로그램이 보이도록 상단부 크롭 */
  border: 1px solid rgba(56, 214, 255, 0.55);
  box-shadow: 0 0 8px rgba(56, 214, 255, 0.35);
  background: #0A1628;
}
.jv-home-txt {
  color: #EAF6FF;
  background: linear-gradient(90deg, #EAF6FF, #9FD8FF);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.01em;
}
@media (max-width: 560px) {
  .jv-home-txt { display: none; }     /* 좁은 화면: 로고 칩만 */
  .jv-home { padding: 4px 6px; }
}

/* ============================================================
 * 라이트 스킨 — 옅은 하늘색 바탕 + 흰색 카드 (네이버페이 증권 톤)
 * ------------------------------------------------------------
 * jarvis-skin.js 가 <html data-skin="light"> 를 부여하면 활성.
 * Finance Pro 토큰을 라이트 값으로 오버라이드 → 변수 기반 화면 일괄 전환.
 * 한국 색상 규칙 유지: 상승=빨강(--fin-up) / 하락=파랑(--fin-down).
 * (html[data-skin] 은 :root 보다 명시도가 높아 안전하게 덮어쓴다.)
 * ============================================================ */
html[data-skin="light"] {
  /* 배경 계층 — 아주 옅은 파란색 바탕 + 흰 카드 (사용자 요청: 살짝 블루 틴트) */
  --fin-bg-0: #EAF1FB;   /* 페이지 최하단 바탕(아주 옅은 파란색) */
  --fin-bg-1: #FFFFFF;   /* 카드/패널(흰색) */
  --fin-bg-2: #EFF5FC;   /* 호버·입력·알약 */
  --fin-bg-3: #E2EBF7;

  /* 텍스트 — 짙은 네이비 슬레이트 */
  --fin-text-primary: #1A1F27;
  --fin-text-secondary: #5C6776;
  --fin-text-tertiary: #98A2AE;
  --fin-text-disabled: #BCC4CE;

  /* 등락(한국식) — 흰 배경 대비 보정 */
  --fin-up: #E74C3C;
  --fin-up-bg: rgba(231, 76, 60, 0.10);
  --fin-up-border: rgba(231, 76, 60, 0.28);
  --fin-down: #2E7DE0;   /* 파랑(흰 배경 가독성 위해 약간 진하게) */
  --fin-down-bg: rgba(46, 125, 224, 0.10);
  --fin-down-border: rgba(46, 125, 224, 0.28);
  --fin-flat: #8A95A1;

  /* 강조/경계/그림자 */
  --fin-accent: #2E7DE0;
  --fin-accent-hover: #1F6AC8;
  --fin-warning: #E08600;
  --fin-danger: #E74C3C;
  --fin-border: #E3E8EF;
  --fin-border-strong: #CFD8E2;
  --shadow-panel: 0 1px 3px rgba(20, 40, 80, 0.06);
  --shadow-popover: 0 4px 14px rgba(20, 40, 80, 0.10);
  --shadow-modal: 0 12px 40px rgba(20, 40, 80, 0.16);

  /* 레거시 변수 호환 매핑(라이트) */
  --bg: #EAF1FB;
  --surface: #FFFFFF;
  --surface2: #EFF5FC;
  --border: #E3E8EF;
  --primary: #2E7DE0;
  --green: #E74C3C;      /* 상승=빨강(한국식) */
  --red: #2E7DE0;        /* 하락=파랑(한국식) */
  --up: #E74C3C;
  --down: #2E7DE0;
  --flat: #8A95A1;
  --yellow: #E08600;
  --purple: #7C5CE0;
  --text: #1A1F27;
  --text2: #5C6776;
  --text3: #98A2AE;

  /* 부가도구·서브 iframe 페이지(블랙박스·감시탑·시장레이더·관제센터·버블·미래비전·정찰대)가
     쓰는 자체 인라인 토큰명도 라이트로. html[data-skin] 이 각 페이지의 :root 보다 명시도가 높아 덮어씀 */
  --bg-0: #EAF1FB; --bg-1: #FFFFFF; --bg-2: #EFF5FC; --bg-3: #E2EBF7;
  --text-dim: rgba(26,31,39,.62);
  --line: #E3E8EF;
  --accent: #2E7DE0; --accent-2: #0E9F8E;
}

/* ============================================================
 * 모바일 라이트 보강(2026-06-10) — 서브메뉴 iframe 페이지들이 쓰는
 * '자체 인라인 토큰명' 까지 라이트로 덮어써 글씨·그래프가 잘 보이게 한다.
 * jarvis-skin.js 가 모바일(≤640px)에서 자동으로 html[data-skin=light] 부여.
 * html[data-skin] 은 각 페이지 :root 보다 명시도가 높아 안전하게 오버라이드.
 * 대상 토큰명(페이지별 상이):
 *   - 시장레이더/미래비전/관제센터/버블: --tx-0/1/2, --text, --pos/neg(±단계), --card-bg
 *   - 정찰대(stock-scout): --bg-900/800/700/600, --text-100/200/300/400, --border(-light), --glass(2)
 *   - 평의회(ai-debate): --bg-900/800/700/600, --text-primary/secondary/muted, --green/red, --glass
 * 한국 색상 규칙 유지: 상승/매수=빨강 #E74C3C, 하락/매도=파랑(#2E7DE0 라이트 보정).
 * ============================================================ */
html[data-skin="light"] {
  /* 시장레이더·미래비전·관제센터·버블 공통 토큰명 */
  --tx-0: #1A1F27; --tx-1: #5C6776; --tx-2: #98A2AE;
  --text: #1A1F27;
  --card-bg: #FFFFFF;
  /* 등락 단계(버블) — 흰 바탕 가독성. 상승=빨강 / 하락=파랑(한국식) */
  --pos: #E74C3C; --neg: #2E7DE0;
  --pos-3: #C0392B; --pos-2: #E74C3C; --pos-1: #E78B82;
  --neg-3: #1F6AC8; --neg-2: #2E7DE0; --neg-1: #7FB2EC;
  --warn: #E08600; --info: #2E7DE0;
  --ai: #7C5CE0; --ai-2: #6A3FD0;

  /* 정찰대(stock-scout) 토큰명 */
  --bg-900: #EAF1FB; --bg-800: #FFFFFF; --bg-700: #EFF5FC; --bg-600: #E2EBF7;
  --text-100: #1A1F27; --text-200: #5C6776; --text-300: #98A2AE; --text-400: #BCC4CE;
  --border-light: #CFD8E2;
  --accent2: #7C5CE0; --accent3: #1F6AC8;
  --buy: #E74C3C; --hold: #8A95A1; --sell: #2E7DE0;
  --glass: rgba(255,255,255,0.92); --glass2: rgba(241,245,250,0.94);

  /* 평의회(ai-debate) 토큰명 */
  --text-primary: #1A1F27; --text-secondary: #5C6776; --text-muted: #98A2AE;
  --accent-light: #1F6AC8;
  --amber: #E08600;
}

/* 라이트에서 인라인 그라디언트/리터럴 body·html 배경을 옅은 파란색 평면으로 강제(가독성).
   대상: 시장레이더/미래비전/관제센터/버블/정찰대/평의회가 html·body에 다크 배경을 직접 지정함. */
html[data-skin="light"],
html[data-skin="light"] body {
  background: #EAF1FB !important;
  background-image: none !important;
}
html[data-skin="light"] body { color: var(--fin-text-primary, #1A1F27) !important; }
/* 일부 페이지는 html/body 양쪽 또는 .wrap 컨테이너에 다크 배경 지정 */
html[data-skin="light"] .wrap { background: transparent !important; }
/* 글래스/반투명 카드 → 흰 카드(인라인 토큰 무시 케이스 대비) */
html[data-skin="light"] .card,
html[data-skin="light"] .panel,
html[data-skin="light"] .widget,
html[data-skin="light"] .glass,
html[data-skin="light"] .card-head {
  background: #FFFFFF !important;
  border-color: #E3E8EF !important;
}
html[data-skin="light"] .card-head { background: #F4F8FE !important; }
/* 표 헤더/호버 톤(라이트) */
html[data-skin="light"] thead th { background: rgba(20,40,80,.04) !important; }
html[data-skin="light"] tbody tr:hover { background: rgba(20,40,80,.05) !important; }
/* 입력요소 */
html[data-skin="light"] input,
html[data-skin="light"] select,
html[data-skin="light"] textarea {
  background: #FFFFFF !important;
  color: #1A1F27 !important;
  border-color: #CFD8E2 !important;
}
/* Tailwind 다크 유틸리티가 박힌 관제센터(0-jarvis-view) 핵심 컨테이너 가독성 보강.
   bg-slate-*/bg-gray-900 등 직접 클래스는 모바일에서만 라이트로(데스크탑은 영향 없음). */
@media (max-width: 640px) {
  html[data-skin="light"] .bg-slate-900,
  html[data-skin="light"] .bg-slate-800,
  html[data-skin="light"] .bg-gray-900,
  html[data-skin="light"] .bg-gray-800,
  html[data-skin="light"] .bg-black { background-color: #FFFFFF !important; }
  html[data-skin="light"] .text-white,
  html[data-skin="light"] .text-slate-100,
  html[data-skin="light"] .text-slate-200,
  html[data-skin="light"] .text-gray-100,
  html[data-skin="light"] .text-gray-200 { color: #1A1F27 !important; }
  html[data-skin="light"] .text-slate-300,
  html[data-skin="light"] .text-slate-400,
  html[data-skin="light"] .text-gray-300,
  html[data-skin="light"] .text-gray-400 { color: #5C6776 !important; }
  html[data-skin="light"] .border-slate-700,
  html[data-skin="light"] .border-slate-800,
  html[data-skin="light"] .border-gray-700 { border-color: #E3E8EF !important; }
}
/* 라이트에서 body 바탕도 즉시 반영(인라인 다크 그라디언트보다 명시도 높아 덮어씀) */
html[data-skin="light"] body { background: var(--fin-bg-0); color: var(--fin-text-primary); }
/* 부가도구 페이지 공통 크롬(.topbar/.card/글래스 버튼) 라이트화 — 클래스명이 부가도구 전용이라 셸/01 영향 없음 */
html[data-skin="light"] .topbar { background: rgba(238,243,249,.90); }
html[data-skin="light"] .card { background: #FFFFFF; }
html[data-skin="light"] .btn.ghost { background: rgba(20,40,80,.05); }
html[data-skin="light"] .conn { background: rgba(20,40,80,.04); }
/* 라이트에서 스크롤바 톤 */
html[data-skin="light"] ::-webkit-scrollbar-track { background: #E7EDF4; }
html[data-skin="light"] ::-webkit-scrollbar-thumb { background: #C2CDDA; }

/* ── 스킨 토글 버튼 (jarvis-skin.js 가 헤더 우측에 주입) ── */
.jv-skin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 16px;
  border: 1px solid var(--fin-border, #2A3441);
  background: var(--fin-bg-2, #1C2330);
  color: var(--fin-text-secondary, #9AA0AC);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  font-family: Inter, Pretendard, system-ui, "Malgun Gothic", sans-serif;
  transition: filter .12s ease, border-color .15s ease, transform .08s ease;
}
.jv-skin-toggle:hover { filter: brightness(1.06); border-color: var(--fin-accent, #4A9EFF); transform: translateY(-1px); }
.jv-skin-toggle:focus-visible { outline: 2px solid var(--fin-accent, #4A9EFF); outline-offset: 2px; }
.jv-skin-toggle .jvst-ico { font-size: 13px; line-height: 1; }
.jv-skin-toggle--float {
  position: fixed; top: 10px; right: 10px; z-index: 9999;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
}
@media (max-width: 560px) {
  .jv-skin-toggle .jvst-txt { display: none; }   /* 좁은 화면: 아이콘만 */
  .jv-skin-toggle { padding: 5px 8px; }
}
