/* ============================================================
 * main.css — 컴포넌트 및 페이지 스타일
 * ------------------------------------------------------------
 * 📦 분리: 2026-05-11
 * 원본 위치: 01-short_trem_stock_investment.html 라인 100-3967
 * ============================================================ */

    .logo {
      font-size: 18px;
      font-weight: 700;
      color: var(--primary);
      margin-right: 32px;
      white-space: nowrap
    }

    .logo span {
      color: var(--green)
    }

    .nav {
      display: flex;
      gap: 4px;
      flex: 1;
      overflow-x: auto
    }

    .nav-btn {
      padding: 8px 16px;
      border: none;
      background: none;
      color: var(--text2);
      cursor: pointer;
      border-radius: 6px;
      font-size: 13px;
      white-space: nowrap;
      transition: .2s
    }

    .nav-btn:hover {
      background: var(--surface2);
      color: var(--text)
    }

    .nav-btn.active {
      background: var(--primary);
      color: #fff
    }

    .clock {
      color: var(--text2);
      font-size: 12px;
      font-family: monospace;
      margin-left: 16px
    }

    .main-layout {
      display: flex;
      gap: 16px;
      padding: 16px;
      max-width: 100%
    }

    .main-content {
      flex: 1;
      min-width: 0;
      max-width: 1600px;
      margin: 0 auto
    }

    .global-ai-panel {
      width: 380px;
      flex-shrink: 0;
      display: flex;
      flex-direction: column;
      gap: 12px;
      height: calc(100vh - 72px);
      max-height: calc(100vh - 72px);
      position: sticky;
      top: 72px;
      overflow: hidden;
      transition: width .3s, opacity .3s
    }

    /* 텔레그램 스타일 통합 채팅 — 플렉스 체인 보장 (chat-box 스크롤 가능) */
    .global-ai-panel .ai-panel-body {
      flex: 1 1 auto;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    .global-ai-panel .ai-panel-body>.card {
      flex: 1 1 auto !important;
      min-height: 0 !important;
      display: flex !important;
      flex-direction: column !important;
      overflow: hidden !important;
    }

    .global-ai-panel.collapsed {
      width: 48px;
      min-width: 48px;
      overflow: hidden
    }

    .global-ai-panel.collapsed .ai-panel-body {
      display: none
    }

    .global-ai-panel .chat-box {
      flex: 1 1 auto;
      height: auto;
      min-height: 0;
      /* ← 핵심: 플렉스 자식이 콘텐츠보다 작아질 수 있도록 */
      max-height: none;
      overflow-y: auto !important;
      overflow-x: hidden;
      scroll-behavior: smooth;
      /* 터치 스크롤 활성화 (iOS Safari + Android) */
      -webkit-overflow-scrolling: touch;
      touch-action: pan-y;
      overscroll-behavior: contain;
      /* 안쪽 끝에서 페이지 스크롤로 넘어가는 것 방지 */
      scrollbar-width: thin;
      scrollbar-color: var(--primary) transparent;
    }

    /* 데스크톱 webkit 스크롤바 — 사용자가 스크롤 가능함을 시각적으로 알림 */
    .global-ai-panel .chat-box::-webkit-scrollbar,
    .tg-input-inline textarea::-webkit-scrollbar {
      width: 8px;
    }

    .global-ai-panel .chat-box::-webkit-scrollbar-track,
    .tg-input-inline textarea::-webkit-scrollbar-track {
      background: transparent;
    }

    .global-ai-panel .chat-box::-webkit-scrollbar-thumb,
    .tg-input-inline textarea::-webkit-scrollbar-thumb {
      background: rgba(59, 130, 246, .35);
      border-radius: 4px;
    }

    .global-ai-panel .chat-box::-webkit-scrollbar-thumb:hover,
    .tg-input-inline textarea::-webkit-scrollbar-thumb:hover {
      background: rgba(59, 130, 246, .6);
    }

    .global-ai-panel .card {
      margin-bottom: 0
    }

    .ai-panel-toggle {
      background: var(--surface2);
      border: 1px solid var(--border);
      color: var(--text2);
      cursor: pointer;
      border-radius: 8px;
      padding: 6px 10px;
      font-size: 14px;
      transition: .2s;
      white-space: nowrap
    }

    .ai-panel-toggle:hover {
      background: var(--primary);
      color: #fff;
      border-color: var(--primary)
    }

    .global-ai-panel.collapsed .ai-panel-toggle {
      width: 40px;
      height: 40px;
      padding: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      font-weight: 700;
      margin: 0 auto;
      background: var(--primary);
      color: #fff;
      border-color: var(--primary);
      border-radius: 8px;
      letter-spacing: 0.5px
    }

    .global-ai-panel.collapsed .ai-panel-toggle:hover {
      background: var(--primary);
      color: #fff;
      filter: brightness(1.15)
    }

    .page {
      display: none;
      padding: 20px
    }

    .page.active {
      display: block
    }

    #page-chart .chart-main {
      flex: 1;
      min-width: 0
    }

    .grid {
      display: grid;
      gap: 16px
    }

    .grid-2 {
      grid-template-columns: 1fr 1fr
    }

    .grid-3 {
      grid-template-columns: 1fr 1fr 1fr
    }

    .grid-4 {
      grid-template-columns: 1fr 1fr 1fr 1fr
    }

    .card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 20px
    }

    .card-title {
      font-size: 14px;
      color: var(--text2);
      margin-bottom: 12px;
      display: flex;
      align-items: center;
      justify-content: space-between
    }

    .card-title .badge {
      font-size: 10px;
      padding: 2px 8px;
      border-radius: 10px;
      background: var(--surface2)
    }

    .stat-value {
      font-size: 28px;
      font-weight: 700
    }

    .stat-change {
      font-size: 12px;
      margin-top: 4px
    }

    /* 한국 주식시장 관습: 이익(상승)=빨강, 손실(하락)=파랑 (Finance Pro 토큰) */
    .up {
      color: var(--fin-up)
    }

    .down {
      color: var(--fin-down)
    }

    .flat {
      color: var(--fin-flat)
    }

    .btn {
      padding: 8px 16px;
      border: none;
      border-radius: 6px;
      cursor: pointer;
      font-size: 13px;
      font-weight: 500;
      transition: .2s
    }

    .btn-primary {
      background: var(--primary);
      color: #fff
    }

    .btn-primary:hover {
      background: #2563eb
    }

    .btn-green {
      background: var(--green);
      color: #fff
    }

    .btn-green:hover {
      background: #059669
    }

    .btn-red {
      background: var(--red);
      color: #fff
    }

    .btn-red:hover {
      background: #dc2626
    }

    .btn-outline {
      background: none;
      border: 1px solid var(--border);
      color: var(--text2)
    }

    .btn-outline:hover {
      border-color: var(--primary);
      color: var(--primary)
    }

    .btn-sm {
      padding: 5px 10px;
      font-size: 11px
    }

    .input-group {
      margin-bottom: 12px
    }

    .input-group label {
      display: block;
      font-size: 12px;
      color: var(--text2);
      margin-bottom: 4px
    }

    input,
    select,
    textarea {
      width: 100%;
      padding: 8px 12px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text);
      font-size: 13px;
      outline: none
    }

    input:focus,
    select:focus,
    textarea:focus {
      border-color: var(--primary)
    }

    textarea {
      resize: vertical;
      min-height: 80px
    }

    .table-wrap {
      overflow-x: auto
    }

    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 13px
    }

    th {
      text-align: left;
      padding: 10px 12px;
      color: var(--text2);
      font-weight: 500;
      border-bottom: 1px solid var(--border);
      font-size: 11px;
      text-transform: uppercase
    }

    td {
      padding: 10px 12px;
      border-bottom: 1px solid var(--border)
    }

    tr:hover td {
      background: var(--surface2)
    }

    .tabs {
      display: flex;
      gap: 4px;
      margin-bottom: 16px;
      border-bottom: 1px solid var(--border);
      padding-bottom: 8px
    }

    .tab {
      padding: 6px 12px;
      border: none;
      background: none;
      color: var(--text2);
      cursor: pointer;
      font-size: 12px;
      border-radius: 4px
    }

    .tab.active {
      color: var(--primary);
      background: rgba(59, 130, 246, .1)
    }

    /* 모바일 전용 페이지 서브 탭바 — 데스크탑에서는 숨김 (@media 블록에서 표시 규칙 정의) */
    .mobile-subtabs {
      display: none;
    }

    /* (레거시) 기존 대시보드 전용 탭바 클래스 — 공통 .mobile-subtabs로 통합되어 사용 안 함 */
    .dash-mobile-tabs {
      display: none;
    }

    .signal {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px 10px;
      border-radius: 20px;
      font-size: 11px;
      font-weight: 600
    }

    .signal-buy {
      background: rgba(16, 185, 129, .15);
      color: var(--green)
    }

    .signal-sell {
      background: rgba(239, 68, 68, .15);
      color: var(--red)
    }

    .signal-hold {
      background: rgba(245, 158, 11, .15);
      color: var(--yellow)
    }

    .chart-container {
      position: relative;
      height: 400px;
      width: 100%
    }

    .chart-container canvas {
      width: 100% !important;
      height: 100% !important
    }

    .mini-chart {
      height: 200px
    }

    .trade-log {
      max-height: 300px;
      overflow-y: auto
    }

    .trade-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 8px 0;
      border-bottom: 1px solid var(--border);
      font-size: 12px
    }

    .trade-icon {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 12px
    }

    .trade-buy .trade-icon {
      background: rgba(16, 185, 129, .15);
      color: var(--green)
    }

    .trade-sell .trade-icon {
      background: rgba(239, 68, 68, .15);
      color: var(--red)
    }

    .chat-box {
      height: 400px;
      overflow-y: auto;
      padding: 12px;
      background: var(--bg);
      border-radius: 8px;
      margin-bottom: 12px
    }

    .chat-msg {
      margin-bottom: 12px;
      display: flex;
      gap: 8px
    }

    .chat-msg.user {
      flex-direction: row-reverse
    }

    .chat-bubble {
      max-width: 80%;
      padding: 10px 14px;
      border-radius: 12px;
      font-size: 13px;
      line-height: 1.5;
      word-break: break-word;
      overflow-wrap: anywhere;
      white-space: pre-wrap;
      /* 단일 답변이 매우 길어도 화면 안에서 보이도록 */
      max-height: none;
      overflow: visible;
    }

    .chat-msg.ai .chat-bubble {
      background: var(--surface2);
      border-top-left-radius: 4px
    }

    .chat-msg.user .chat-bubble {
      background: var(--primary);
      border-top-right-radius: 4px
    }

    .chat-avatar {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 12px;
      flex-shrink: 0
    }

    .chat-msg.ai .chat-avatar {
      background: var(--purple);
      color: #fff
    }

    .chat-msg.user .chat-avatar {
      background: var(--primary);
      color: #fff
    }

    .chat-input-wrap {
      display: flex;
      gap: 8px;
      align-items: flex-end
    }

    .chat-input-wrap textarea {
      flex: 1;
      resize: vertical;
      font-family: inherit;
      font-size: inherit;
      line-height: 1.5;
      padding: 8px 12px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--card);
      color: var(--text)
    }

    /* ───── 카톡 스타일 통합 채팅 (KakaoTalk-style integrated chat) ───── */
    .kakao-chat-shell {
      display: flex;
      flex-direction: column;
      flex: 1;
      overflow: hidden;
      background: var(--bg);
      border-radius: 10px;
      border: 1px solid var(--border);
    }

    .kakao-chat-shell .chat-box {
      background: transparent;
      border-radius: 0;
      margin-bottom: 0;
      border: none;
      flex: 1;
      min-height: 220px;
      padding: 12px;
      scroll-behavior: smooth;
    }

    .kakao-input-bar {
      display: flex;
      align-items: flex-end;
      gap: 6px;
      padding: 8px 8px 8px 10px;
      background: var(--surface2);
      border-top: 1px solid var(--border);
      flex-shrink: 0;
      position: relative;
      z-index: 2;
    }

    /* 카톡 스타일 입력 행 — textarea 알약 스타일 */
    .kakao-input-row textarea#aiInputSide {
      flex: 1 1 auto;
      width: auto;
      min-width: 0;
      resize: none;
      background: var(--card);
      color: var(--text);
      font-size: 14px;
      line-height: 1.4;
      padding: 8px 12px;
      border: 1px solid var(--border);
      border-radius: 18px;
      min-height: 36px;
      max-height: 140px;
      box-sizing: border-box;
      caret-color: var(--primary);
      cursor: text;
      overflow-y: auto;
      outline: none;
    }

    .kakao-input-row textarea#aiInputSide:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 2px rgba(59, 130, 246, .15);
    }

    .kakao-input-row textarea#aiInputSide::placeholder {
      color: var(--text3);
    }

    .kakao-icon-btn:hover {
      transform: scale(1.07);
    }

    .kakao-icon-btn:active {
      transform: scale(.94);
    }

    .kakao-icon-btn {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      border: none;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      font-size: 15px;
      transition: transform .1s ease, opacity .15s, background .15s;
      flex-shrink: 0;
      color: #fff;
      padding: 0;
    }

    .kakao-icon-btn:hover {
      transform: scale(1.07);
    }

    .kakao-icon-btn:active {
      transform: scale(.94);
    }

    .kakao-icon-btn:disabled {
      opacity: .35;
      cursor: not-allowed;
      transform: none;
    }

    .kakao-send-btn {
      background: var(--primary);
      box-shadow: 0 2px 6px rgba(59, 130, 246, .3);
    }

    .kakao-send-btn:hover {
      background: #2563eb;
    }

    .kakao-debate-btn {
      background: #8b5cf6;
      box-shadow: 0 2px 6px rgba(139, 92, 246, .3);
    }

    .kakao-debate-btn:hover {
      background: #7c3aed;
    }

    .strategy-stats {
      display: flex;
      gap: 16px;
      margin-top: 8px;
      font-size: 11px
    }

    .toggle {
      position: relative;
      width: 44px;
      height: 24px;
      background: var(--border);
      border-radius: 12px;
      cursor: pointer;
      transition: .2s
    }

    .toggle.on {
      background: var(--green)
    }

    .toggle::after {
      content: '';
      position: absolute;
      width: 20px;
      height: 20px;
      background: #fff;
      border-radius: 50%;
      top: 2px;
      left: 2px;
      transition: .2s
    }

    .toggle.on::after {
      left: 22px
    }

    .progress {
      height: 6px;
      background: var(--surface2);
      border-radius: 3px;
      overflow: hidden
    }

    .progress-bar {
      height: 100%;
      border-radius: 3px;
      transition: width .3s
    }

    /* ============================================================
       SMARTPHONE PORTRAIT: 프리미엄 앱 스타일 UI
       데스크톱 nav 완전 숨김, 하단 탭바 + 더보기 드로어 전용
       ============================================================ */
    @media (max-width: 900px) and (orientation: portrait) {

      /* ── 헤더: 로고 + DB + 2줄 네비 ── */
      .header {
        height: auto;
        padding: 6px 10px 4px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px 8px;
        position: sticky;
        top: 0;
        z-index: 1000;
        background: rgba(17, 24, 39, 0.95);
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
        border-bottom: 1px solid rgba(42, 52, 68, 0.6);
      }

      /* 로고: 1행 왼쪽 */
      .logo {
        font-size: 13px;
        margin-right: 0;
        white-space: nowrap;
        flex-shrink: 0;
      }

      /* ★ 네비: 2행 풀폭 + 2줄 wrap ── */
      .nav {
        display: flex !important;
        flex: 0 0 100%;
        order: 10;
        flex-wrap: wrap;
        gap: 4px;
        padding: 4px 0 2px;
        justify-content: center;
      }

      .nav-btn {
        font-size: 11px;
        padding: 5px 9px;
        flex-shrink: 0;
        white-space: nowrap;
        background: rgba(26, 35, 50, 0.7);
        border-radius: 6px;
        min-width: auto;
        font-weight: 500;
        letter-spacing: -0.3px;
      }

      .nav-btn.active {
        background: var(--primary);
        color: #fff;
        box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
      }

      /* DB 상태: 1행 우측 */
      .header>div:nth-child(3) {
        margin-left: auto !important;
        flex-shrink: 0;
        gap: 6px !important;
      }

      .clock {
        display: none;
      }

      /* ── Body: 하단 탭바 + safe area 여백 ── */
      body {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
        -webkit-tap-highlight-color: transparent;
        overscroll-behavior-y: contain;
      }

      /* ── 전체 레이아웃: 1열 세로 스택 ── */
      .main-layout {
        flex-direction: column;
        padding: 10px 10px 16px;
        gap: 10px;
      }

      /* ── 본문: 풀너비 ── */
      .main-content {
        width: 100%;
        max-width: 100%;
        margin-bottom: 0;
      }

      /* ── 페이지 전환 애니메이션 ── */
      .page {
        padding: 6px 0;
        animation: mobPageIn 0.28s ease-out;
      }

      @keyframes mobPageIn {
        from {
          opacity: 0;
          transform: translateY(12px);
        }

        to {
          opacity: 1;
          transform: translateY(0);
        }
      }

      /* ── AI 패널 → 하단 배치 + 자연 높이 (chat-box 자체가 스크롤됨) ── */
      .global-ai-panel {
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        /* ★ 패널 자체는 넘침 제한 X (chat-box가 자체 스크롤) */
        position: relative;
        top: 0;
        order: 2;
        flex-shrink: 0;
        overflow: visible !important;
        /* 입력바가 잘리지 않도록 */
      }

      /* 통합 채팅 컨테이너 — 모바일은 chat-box 고정높이 + input 고정높이로 자연 합산 */
      .global-ai-panel .tg-chat-container {
        flex: 0 0 auto !important;
        /* 자연 크기 (chat-box 50vh + 입력바) */
        min-height: 0 !important;
        max-height: none !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: visible !important;
        /* 입력바 보이게 */
      }

      .global-ai-panel .tg-input-inline {
        padding: 6px 8px 8px;
      }

      .global-ai-panel .tg-input-inline textarea {
        font-size: 16px !important;
        /* iOS 자동 줌 방지 — 반드시 16px 이상 */
        min-height: 50px !important;
        max-height: 120px !important;
        /* 입력창 높이 한도 → 넘치면 자체 스크롤 */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
        overscroll-behavior: contain !important;
      }

      .global-ai-panel .tg-btn-row button {
        padding: 9px !important;
        font-size: 13px !important;
        min-height: 40px;
      }

      .global-ai-panel.collapsed {
        width: 100% !important;
        min-width: 100%;
        height: auto;
        min-height: 48px;
      }

      .global-ai-panel.collapsed .ai-panel-toggle {
        width: 100%;
        height: 48px;
        font-size: 14px;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 12px;
        background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.15));
        border: 1px solid rgba(59, 130, 246, 0.3);
      }

      /* ★★★ 모바일: chat-box 고정 높이 강제 — flex 계산 무력화 ★★★
         flex로 자라면 콘텐츠 따라 무한 확장되어 내부 스크롤이 안 생김.
         반드시 명시적 height + flex: 0 0 auto로 못박아야 overflow-y:auto 작동 */
      .global-ai-panel .chat-box {
        height: 50vh !important;
        /* 고정 높이 — viewport 50% */
        max-height: 50vh !important;
        min-height: 250px !important;
        /* 너무 작은 화면도 최소 보장 */
        flex: 0 0 auto !important;
        /* ★ flex 자라기/줄어들기 둘 다 막음 */
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
        overscroll-behavior: contain !important;
        scroll-behavior: smooth;
        display: block !important;
        /* 인라인 style의 flex:1 1 auto / min-height:200px도 위 !important로 덮음 */
      }

      /* 채팅 메시지 거품도 폭/줄바꿈 보장 */
      .global-ai-panel .chat-bubble {
        max-width: 90% !important;
        word-break: break-word !important;
        overflow-wrap: anywhere !important;
        white-space: pre-wrap !important;
      }

      /* ── 그리드: 모바일 적응 ── */
      .grid-2 {
        grid-template-columns: 1fr;
        gap: 10px;
      }

      .grid-3 {
        grid-template-columns: 1fr;
        gap: 10px;
      }

      .grid-4 {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
      }

      /* ── 증시 지수 바: 모바일 2열+1 ── */
      #market-index-bar {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        margin-bottom: 8px !important;
      }

      #market-index-bar>.card:last-child {
        grid-column: 1 / -1;
      }

      /* ── 대시보드 상단 카드: 3열 그리드 ── */
      #page-dashboard>div:nth-child(3) {
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 8px !important;
        margin-bottom: 10px !important;
      }

      /* ── 카드: 프리미엄 앱 스타일 ── */
      .card {
        padding: 14px;
        border-radius: 14px;
        border: 1px solid rgba(42, 52, 68, 0.7);
        background: rgba(17, 24, 39, 0.85);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
      }

      .card-title {
        font-size: 11px;
        font-weight: 600;
        margin-bottom: 8px;
        letter-spacing: 0.3px;
        text-transform: none;
      }

      .stat-value {
        font-size: 22px;
        font-weight: 800;
        letter-spacing: -0.5px;
      }

      .stat-change {
        font-size: 11px;
        margin-top: 2px;
      }

      /* ── 차트: 모바일 높이 ── */
      .chart-container {
        height: 240px;
      }

      .tv-chart-wrap {
        height: 300px;
        border-radius: 12px;
      }

      .mini-chart {
        height: 140px;
      }

      /* ★ 메인 이동평균선 차트 — 모바일에서 인라인 500px 오버라이드 */
      #maChartWrap {
        height: 320px !important;
      }

      /* 차트 서브섹션이 활성일 때 캔버스가 컨테이너 가득 채우도록 */
      #page-chart .page-section[data-subsection="chart"].active #maChartWrap {
        display: block;
        width: 100%;
      }

      /* ── 모바일 차트 컨트롤 바 ── */
      #chartControlBar {
        gap: 4px !important;
      }

      #chartControlBar .btn {
        min-height: 36px !important;
        padding: 6px 12px !important;
        font-size: 13px !important;
      }

      #tooltipToggleLabel {
        font-size: 12px !important;
      }

      #tooltipToggleLabel input {
        width: 20px !important;
        height: 20px !important;
      }

      /* ── 모바일 차트 높이 조정 ── */
      #maChartWrap {
        height: 320px !important;
        touch-action: none;
      }

      /* ── 모바일 매매신호 요약 카드 ── */
      #signal-summary-card {
        padding: 10px 12px !important;
      }

      #signal-summary-card .card-title {
        font-size: 12px !important;
      }

      /* ── 모바일 전략 분석 요약 ── */
      #strategy-analysis-summary {
        padding: 10px 12px !important;
      }

      /* ── 모바일 폰트 가독성 강화 ── */
      .card {
        font-size: 13px;
      }

      /* 차트 근거 요약 카드 모바일 */
      [style*="차트근거"],
      [style*="차트 분석 근거"] {
        font-size: 11px !important;
      }

      /* ── 모바일 이평선 체크박스 영역 ── */
      #chartTabMA>div:first-child {
        flex-direction: column !important;
        gap: 8px !important;
      }

      #chartTabMA>div:first-child>div:first-child {
        flex-wrap: wrap !important;
        gap: 4px !important;
      }

      #chartTabMA>div:first-child>div:first-child label {
        padding: 5px 8px !important;
        font-size: 11px !important;
      }

      /* ── 모바일 전략 토글 버튼 ── */
      #strategyMaToggles {
        gap: 3px !important;
      }

      #strategyMaToggles button {
        font-size: 11px !important;
        padding: 4px 8px !important;
      }

      /* ── 모바일 grid-3 → 1열 ── */
      .grid-3 [style*="grid-column:span 2"] {
        grid-column: span 1 !important;
      }

      /* ── 모바일 실시간시세/기술지표 카드 ── */
      #page-chart .grid-3 {
        grid-template-columns: 1fr !important;
      }

      /* ── 모바일: 매매신호 요약 좌우→세로 전환 ── */
      .signal-summary-layout {
        flex-direction: column !important;
        gap: 8px !important;
        align-items: stretch !important;
      }

      .signal-summary-layout>div:first-child {
        text-align: center !important;
      }

      /* ── 테이블: 터치 스크롤 ── */
      .table-wrap {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        border-radius: 10px;
      }

      table {
        font-size: 12px;
      }

      th {
        padding: 8px 10px;
        font-size: 10px;
        letter-spacing: 0.5px;
      }

      td {
        padding: 10px;
      }

      /* ── 입력: iOS 줌 방지 + 터치 타겟 ── */
      input,
      select,
      textarea {
        font-size: 16px;
        border-radius: 10px;
        padding: 10px 14px;
      }

      .btn {
        min-height: 44px;
        font-size: 14px;
        border-radius: 10px;
        font-weight: 600;
      }

      .btn-sm {
        min-height: 34px;
        font-size: 12px;
        padding: 6px 12px;
        border-radius: 8px;
      }

      .input-group label {
        font-size: 12px;
        font-weight: 500;
      }

      .input-group {
        margin-bottom: 10px;
      }

      /* ── 탭: 터치 최적화 (pill 스타일) ── */
      .tabs {
        gap: 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
        border-bottom: none;
        padding-bottom: 0;
        margin-bottom: 12px;
      }

      .tabs::-webkit-scrollbar {
        display: none;
      }

      .tab {
        padding: 8px 14px;
        font-size: 12px;
        white-space: nowrap;
        flex-shrink: 0;
        border-radius: 20px;
        font-weight: 500;
        background: var(--surface2);
        border: 1px solid transparent;
        transition: all 0.2s;
      }

      .tab.active {
        background: rgba(59, 130, 246, 0.15);
        border-color: rgba(59, 130, 246, 0.4);
        color: var(--primary);
        font-weight: 600;
      }

      /* ── 채팅 ── */
      .chat-bubble {
        font-size: 13px;
        max-width: 85%;
        border-radius: 16px;
      }

      /* ── 모달: iOS 시트 스타일 ── */
      .modal {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh !important;
        border-radius: 20px 20px 0 0 !important;
        height: auto;
        position: fixed !important;
        bottom: 0 !important;
        padding: 20px !important;
        animation: mobSheetUp 0.3s ease-out;
      }

      @keyframes mobSheetUp {
        from {
          transform: translateY(100%);
        }

        to {
          transform: translateY(0);
        }
      }

      /* ── 전략/발굴 ── */
      .strategy-stats {
        gap: 8px;
        font-size: 10px;
        flex-wrap: wrap;
      }

      .signal {
        font-size: 10px;
        padding: 4px 10px;
        border-radius: 16px;
      }

      .signal-badge {
        font-size: 9px;
        border-radius: 6px;
      }

      /* ── 가이드 ── */
      .guide-step {
        gap: 12px;
        padding: 14px 0;
      }

      .guide-num {
        width: 30px;
        height: 30px;
        font-size: 13px;
      }

      .guide-content p {
        font-size: 12px;
        line-height: 1.7;
      }

      /* ── 검색 드롭다운 (모바일 강화) ── */
      .search-dropdown {
        max-height: 250px;
        border-radius: 0 0 12px 12px;
        box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
        z-index: 9999 !important;
        -webkit-overflow-scrolling: touch;
      }

      .search-item {
        padding: 14px 16px;
        font-size: 15px;
        min-height: 44px;
        /* 모바일 터치 최소 영역 */
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
      }

      .search-item:active {
        background: var(--surface2);
      }

      /* ── AI 선택 버튼 ── */
      .ai-sel-wrap {
        gap: 6px;
      }

      .ai-sel-btn {
        padding: 5px 10px;
        font-size: 11px;
        border-radius: 16px;
      }

      /* ── 토글 스위치 ── */
      .toggle {
        width: 44px;
        height: 24px;
      }

      .toggle::after {
        width: 20px;
        height: 20px;
      }

      .toggle.on::after {
        left: 22px;
      }

      /* ── 스크롤바 숨기기 (앱 느낌) ── */
      ::-webkit-scrollbar {
        width: 0;
        height: 0;
      }

      /* ── 터치 하이라이트 제거 ── */
      * {
        -webkit-tap-highlight-color: transparent;
      }

      /* ── 트레이드 로그 ── */
      .trade-log {
        max-height: 240px;
      }

      .trade-item {
        padding: 10px 0;
      }

      /* ── 헤더 DB 영역: 컴팩트 ── */
      .header-db-area {
        margin-left: auto !important;
        gap: 4px !important;
      }

      #logoutBtn {
        display: none !important;
      }

      #userDisplay {
        display: none !important;
      }

      /* ── 현재 페이지 표시 ── */
      .mob-page-title {
        font-size: 13px;
        font-weight: 600;
        color: var(--text);
        margin-left: 4px;
      }

      /* ════════════════════════════════════════════ */
      /* ── 자동매매 페이지 모바일 최적화 ── */
      /* ════════════════════════════════════════════ */

      /* 매매 기간 탭: 모바일 */
      .at-period-tabs {
        border-radius: 10px !important;
      }

      .at-period-tab {
        padding: 8px 4px !important;
        gap: 1px !important;
      }

      .at-period-icon {
        font-size: 14px !important;
      }

      .at-period-label {
        font-size: 11px !important;
      }

      .at-period-sub {
        font-size: 8px !important;
      }

      /* 기간 설명 카드 모바일 */
      #atPeriodDesc {
        padding: 8px 12px !important;
      }

      #atPeriodDesc>div {
        flex-direction: column !important;
        gap: 6px !important;
        align-items: flex-start !important;
      }

      #atPeriodDescTitle {
        font-size: 13px !important;
      }

      #atPeriodDescText {
        font-size: 10px !important;
      }

      #atPeriodBadges {
        margin-left: 0 !important;
      }

      /* 상단 컨트롤 바: 세로 스택 */
      #page-autotrade>.card:first-of-type>div {
        flex-direction: column !important;
        gap: 8px !important;
        align-items: stretch !important;
      }

      /* 시작 버튼 풀너비 */
      .at-start-btn {
        width: 100% !important;
        justify-content: center !important;
        min-height: 48px !important;
        font-size: 15px !important;
      }

      /* 긴급 중지 버튼 풀너비 */
      #atStopBtn {
        width: 100% !important;
        min-height: 44px !important;
        font-size: 14px !important;
      }

      /* API 연결 상태: 풀너비 */
      #page-autotrade .card>div>div[style*="kiwoomConnDot"],
      #page-autotrade .card>div>div:has(#kiwoomConnDot) {
        width: 100% !important;
        justify-content: center !important;
      }

      /* 오늘 성과 미니: 2열+3열 그리드 */
      #page-autotrade .card>div>div[style*="margin-left:auto"] {
        margin-left: 0 !important;
        width: 100% !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 8px !important;
      }

      #page-autotrade .card>div>div[style*="margin-left:auto"]>div {
        text-align: center !important;
        padding: 6px 4px !important;
        background: var(--surface2) !important;
        border-radius: 8px !important;
      }

      #autoTodayPnl {
        font-size: 15px !important;
      }

      #autoTradeCount,
      #autoWinRate,
      #autoAvgReturn,
      #autoMaxDrawdown {
        font-size: 14px !important;
      }

      /* 매매 모드 + 주문 유형: 세로 스택 */
      #page-autotrade>.card:nth-of-type(2)>div {
        flex-direction: column !important;
        gap: 10px !important;
      }

      /* 모드/주문 버튼 풀너비 */
      .at-btn-group {
        width: 100% !important;
        display: flex !important;
      }

      .at-btn-group .at-btn {
        flex: 1 !important;
        text-align: center !important;
        min-height: 40px !important;
        font-size: 12px !important;
      }

      /* 종목선택 그리드: 1열 */
      #page-autotrade .grid-3 {
        grid-template-columns: 1fr !important;
      }

      /* 리스크 관리 카드: 2열 그대로 유지 */
      #page-autotrade .grid-3 .card:last-child .input-group input,
      #page-autotrade .grid-3 .card:last-child .input-group select {
        font-size: 14px !important;
        padding: 8px 10px !important;
      }

      /* ATR 트레일링 설정 */
      #page-autotrade details summary {
        font-size: 13px !important;
        padding: 6px 0 !important;
      }

      #page-autotrade details .input-group {
        margin-bottom: 6px !important;
      }

      /* 감시종목 영역 */
      #autoWatchTags {
        max-height: 80px !important;
        overflow-y: auto !important;
      }

      #autoStockSearch {
        font-size: 14px !important;
        padding: 10px 12px !important;
      }

      /* 감시종목 버튼들: wrap */
      #page-autotrade .card>div[style*="flex-wrap"] {
        gap: 6px !important;
      }

      #page-autotrade .card>div[style*="flex-wrap"] .btn-sm {
        font-size: 11px !important;
        padding: 6px 10px !important;
        min-height: 34px !important;
      }

      /* 전략 선택: 스크롤 */
      #atStratButtons {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 4px !important;
      }

      #atStratButtons .dash-strat-btn {
        flex-shrink: 0 !important;
        font-size: 10px !important;
        padding: 6px 10px !important;
      }

      /* 전략 신호 모니터 + 보유종목: 1열 */
      #page-autotrade .grid-3:has(#signalMonitorBody) {
        grid-template-columns: 1fr !important;
      }

      #page-autotrade .grid-3 .card[style*="grid-column:span 2"] {
        grid-column: span 1 !important;
      }

      /* 신호 모니터 테이블: 핵심 열만 */
      #signalMonitorBody td:nth-child(5),
      #signalMonitorBody td:nth-child(6),
      #signalMonitorBody td:nth-child(7),
      #signalMonitorBody th:nth-child(5),
      #signalMonitorBody th:nth-child(6),
      #signalMonitorBody th:nth-child(7) {
        display: none !important;
      }

      thead:has(+ #signalMonitorBody) th:nth-child(5),
      thead:has(+ #signalMonitorBody) th:nth-child(6),
      thead:has(+ #signalMonitorBody) th:nth-child(7) {
        display: none !important;
      }

      /* 로그 + 체결내역: 1열 */
      #page-autotrade .grid-2 {
        grid-template-columns: 1fr !important;
      }

      /* 실시간 로그 높이 축소 */
      #autoTradeLog {
        height: 200px !important;
        font-size: 10px !important;
      }

      /* ── 자동매매 종목별 차트 모바일 최적화 ── */
      #autoTradeCharts {
        max-height: none !important;
        gap: 8px !important;
      }

      /* 차트 카드 내부 레이아웃 */
      #autoTradeCharts>div {
        padding: 10px !important;
      }

      /* 차트 헤더: 세로 2줄 */
      #autoTradeCharts>div>div:first-child {
        flex-direction: column !important;
        gap: 6px !important;
        align-items: flex-start !important;
      }

      /* 종목명+현재가 줄 */
      #autoTradeCharts>div>div:first-child>div:first-child {
        width: 100% !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
      }

      /* 매수가/수량/스탑 줄 */
      #autoTradeCharts>div>div:first-child>div:last-child {
        width: 100% !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        font-size: 10px !important;
      }

      /* 차트 캔버스 높이 축소 */
      #autoTradeCharts>div>div[style*="height:250px"] {
        height: 180px !important;
      }

      /* 차트 범례 축소 */
      #autoTradeCharts>div>div:last-child {
        gap: 8px !important;
        font-size: 9px !important;
        flex-wrap: wrap !important;
      }

      /* 차트 타입·분봉 선택 드롭다운 (터치 친화) */
      #atChartType,
      #atChartInterval,
      .at-chart-sel {
        font-size: 13px !important;
        padding: 6px 10px !important;
        min-height: 36px !important;
      }

      /* 모바일: 컨트롤 바 가로 스크롤 방지 — 2줄 허용 */
      .at-chart-controls {
        width: 100% !important;
        justify-content: flex-start !important;
        flex-wrap: wrap !important;
      }

      .at-chart-refresh-btn {
        min-height: 36px !important;
        font-size: 12px !important;
      }

      /* 감시종목 차트 헤더의 상태 뱃지 — 좁은 화면에서 줄바꿈 */
      .at-watch-head {
        flex-wrap: wrap !important;
      }

      .at-watch-head>div {
        flex-wrap: wrap !important;
      }

      /* 대시보드 포트폴리오 구성 — 모바일: 세로 적층 */
      .dash-pie-layout {
        flex-direction: column !important;
        min-height: auto !important;
      }

      .dash-pie-layout>#dashPieChartWrap {
        flex: 0 0 auto !important;
        max-width: 100% !important;
        width: 100% !important;
        height: 240px !important;
      }

      .dash-pie-layout>#dashPieDetails {
        flex: 1 1 auto !important;
        max-height: 200px !important;
      }

      /* 수익률 차트 */
      #page-autotrade .mini-chart {
        height: 120px !important;
      }

      /* 추가 거래 설정: 2열 유지 */
      #page-autotrade details .grid-4 {
        grid-template-columns: 1fr 1fr !important;
      }

      /* 체결 내역 테이블: 모바일에서 전략 열 숨기기 (총액 추가로 인덱스 8) */
      #autoTradeHistory td:nth-child(8),
      thead:has(+ #autoTradeHistory) th:nth-child(8) {
        display: none !important;
      }

      /* ── 자동매매 모바일 서브탭 시스템 ── */
      .at-mob-subtabs {
        display: flex !important;
        gap: 0;
        border-radius: 10px;
        overflow: hidden;
        border: 1px solid var(--border);
        background: var(--surface);
        margin-bottom: 12px;
      }

      .at-mob-subtab {
        flex: 1;
        border: none;
        background: none;
        color: var(--text3);
        font-size: 11px;
        font-weight: 600;
        padding: 10px 4px;
        cursor: pointer;
        text-align: center;
        transition: all 0.2s;
        position: relative;
        line-height: 1.3;
      }

      .at-mob-subtab .at-mob-subtab-icon {
        display: block;
        font-size: 16px;
        margin-bottom: 2px;
      }

      .at-mob-subtab.active {
        color: var(--primary);
        background: rgba(59, 130, 246, 0.1);
      }

      .at-mob-subtab.active::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 20%;
        right: 20%;
        height: 2px;
        background: var(--primary);
        border-radius: 2px 2px 0 0;
      }

      .at-mob-subtab:active {
        transform: scale(0.95);
        opacity: 0.7;
      }

      /* 모바일에서 탭으로 제어되는 섹션 숨기기 */
      #page-autotrade .at-mob-section {
        display: none !important;
      }

      #page-autotrade .at-mob-section.at-mob-active {
        display: block !important;
      }

      /* ROW3 grid → 모바일에서 단일 컬럼, 선택된 카드만 표시 */
      #page-autotrade #atRow3Grid.at-mob-section.at-mob-active {
        display: block !important;
        grid-template-columns: 1fr !important;
      }
    }

    /* 자동매매 모바일 서브탭: 데스크톱에서는 숨김 */
    .at-mob-subtabs {
      display: none;
    }

    .modal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, .6);
      z-index: 200;
      align-items: center;
      justify-content: center
    }

    .modal-overlay.show {
      display: flex
    }

    .modal {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 24px;
      width: 90%;
      max-width: 500px;
      max-height: 80vh;
      overflow-y: auto
    }

    .modal h3 {
      margin-bottom: 16px
    }

    .loading {
      display: inline-block;
      width: 16px;
      height: 16px;
      border: 2px solid var(--border);
      border-top-color: var(--primary);
      border-radius: 50%;
      animation: spin .6s linear infinite
    }

    @keyframes spin {
      to {
        transform: rotate(360deg)
      }
    }

    @keyframes fadeIn {
      from {
        opacity: 0;
        transform: translateY(10px)
      }

      to {
        opacity: 1;
        transform: translateY(0)
      }
    }

    @keyframes signalBlink {

      0%,
      100% {
        opacity: 1
      }

      50% {
        opacity: 0.2
      }
    }

    .signal-blink {
      animation: signalBlink 1s ease-in-out infinite
    }

    .signal-badge {
      display: inline-block;
      padding: 2px 8px;
      border-radius: 4px;
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.5px
    }

    /* 매수=상승 매도=하락 → 한국식 색상 (Finance Pro) */
    .signal-badge.buy {
      background: var(--fin-up-bg);
      color: var(--fin-up);
      border: 1px solid var(--fin-up-border)
    }

    .signal-badge.sell {
      background: var(--fin-down-bg);
      color: var(--fin-down);
      border: 1px solid var(--fin-down-border)
    }

    .signal-badge.hold {
      background: rgba(243, 156, 18, 0.15);
      color: var(--fin-warning);
      border: 1px solid rgba(243, 156, 18, 0.3)
    }

    /* ── 매매 기간 탭 ── */
    .at-period-tab {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 2px;
      padding: 12px 8px;
      border: none;
      background: transparent;
      color: var(--text3);
      cursor: pointer;
      transition: all .25s;
      position: relative;
      border-right: 1px solid var(--border);
    }

    .at-period-tab:last-child {
      border-right: none;
    }

    .at-period-tab:hover {
      background: var(--surface2);
      color: var(--text);
    }

    .at-period-tab.active {
      background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.08));
      color: var(--primary);
    }

    .at-period-tab.active::after {
      content: '';
      position: absolute;
      bottom: 0;
      left: 10%;
      width: 80%;
      height: 3px;
      background: var(--primary);
      border-radius: 3px 3px 0 0;
    }

    .at-period-icon {
      font-size: 18px;
    }

    .at-period-label {
      font-size: 14px;
      font-weight: 700;
    }

    .at-period-sub {
      font-size: 10px;
      opacity: 0.7;
      white-space: nowrap;
    }

    /* Dashboard Strategy Selector */
    .dash-strat-row {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 10px 0;
      flex-wrap: wrap;
    }

    .dash-strat-btn {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 6px 12px;
      border-radius: 20px;
      border: 1.5px solid var(--border);
      background: var(--surface);
      color: var(--text2);
      font-size: 11px;
      font-weight: 600;
      cursor: pointer;
      white-space: nowrap;
      flex-shrink: 0;
      transition: all .25s ease;
      user-select: none;
    }

    .dash-strat-btn:hover {
      border-color: var(--primary);
      background: rgba(59, 130, 246, .08);
      color: var(--text);
      transform: translateY(-1px);
    }

    .dash-strat-btn.active {
      border-color: var(--yellow);
      background: rgba(245, 158, 11, .15);
      color: var(--yellow);
      box-shadow: 0 0 10px rgba(245, 158, 11, .2), 0 2px 8px rgba(0, 0, 0, .15);
      font-weight: 700;
    }

    .dash-strat-btn .strat-num {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 18px;
      height: 18px;
      border-radius: 50%;
      background: #4b5563;
      color: #0a0e17;
      font-size: 10px;
      font-weight: 800;
      flex-shrink: 0;
      transition: background .25s;
    }

    .dash-strat-btn.active .strat-num {
      background: var(--yellow);
    }

    .dash-strat-btn-all {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 6px 14px;
      border-radius: 20px;
      border: 1.5px solid var(--primary);
      background: rgba(59, 130, 246, .1);
      color: var(--primary);
      font-size: 11px;
      font-weight: 700;
      cursor: pointer;
      white-space: nowrap;
      flex-shrink: 0;
      transition: all .25s ease;
    }

    .dash-strat-btn-all:hover {
      background: rgba(59, 130, 246, .2);
      transform: translateY(-1px);
    }

    .dash-strat-btn-all.active {
      border-color: var(--green);
      background: rgba(16, 185, 129, .15);
      color: var(--green);
    }

    /* Auto-Trade Mode/Order Button Group */
    .at-btn-group {
      display: flex;
      gap: 4px;
      flex-wrap: wrap;
    }

    .at-btn-group .at-btn {
      padding: 6px 16px;
      border-radius: 20px;
      border: 1.5px solid var(--border);
      background: var(--surface);
      color: var(--text2);
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      white-space: nowrap;
      transition: all .2s;
      user-select: none;
    }

    .at-btn-group .at-btn:hover {
      border-color: var(--primary);
      background: rgba(59, 130, 246, .08);
      color: var(--text);
    }

    .at-btn-group .at-btn.active {
      border-color: var(--primary);
      background: rgba(59, 130, 246, .18);
      color: var(--primary);
      box-shadow: 0 0 8px rgba(59, 130, 246, .15);
      font-weight: 700;
    }

    .at-btn-group .at-btn.danger {
      border-color: var(--red);
      background: rgba(239, 68, 68, .12);
      color: var(--red);
      font-weight: 700;
    }

    /* Auto-Trade Stock Chip */
    /* ───── 실전투자 경고띠 ───── */
    .live-mode-warn {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 14px;
      margin-bottom: 10px;
      background: linear-gradient(90deg, #dc2626, #ef4444, #dc2626);
      background-size: 200% 100%;
      animation: liveStrobe 2.4s ease-in-out infinite;
      border: 1px solid rgba(255, 255, 255, 0.15);
      border-radius: 10px;
      color: #fff;
      font-size: 12px;
      font-weight: 600;
      box-shadow: 0 4px 20px rgba(239, 68, 68, 0.35);
    }

    .live-mode-warn .lmw-ico {
      font-size: 16px;
    }

    .live-mode-warn .lmw-sep {
      opacity: .5;
    }

    .live-mode-warn .lmw-msg {
      font-weight: 500;
      font-size: 11px;
      opacity: .95;
    }

    @keyframes liveStrobe {

      0%,
      100% {
        background-position: 0% 50%;
      }

      50% {
        background-position: 100% 50%;
      }
    }

    /* 실전 모드 전체 페이지 강조 (좌우 붉은 얇은 경계) */
    #page-autotrade.live-mode {
      box-shadow: inset 0 0 0 2px rgba(239, 68, 68, 0.28);
      border-radius: 8px;
    }

    #page-autotrade.live-mode .card#atRow1 {
      border-color: rgba(239, 68, 68, 0.35) !important;
    }

    /* ═════════════ UX 개선 v3.3 (2026-04-24) ═════════════ */
    /* A. 진행 스테퍼 ─ 5단계 시각 가이드 */
    .at-stepper {
      display: flex;
      align-items: center;
      gap: 0;
      margin-bottom: 12px;
      padding: 10px 14px;
      background: linear-gradient(135deg, rgba(59, 130, 246, 0.04), rgba(139, 92, 246, 0.04));
      border: 1px solid var(--border);
      border-radius: 10px;
      overflow-x: auto;
    }

    .at-step {
      display: flex;
      align-items: center;
      gap: 8px;
      flex: 1;
      min-width: 110px;
      position: relative;
    }

    .at-step:not(:last-child)::after {
      content: '';
      position: absolute;
      top: 50%;
      right: -4px;
      height: 2px;
      width: calc(100% - 100px);
      background: var(--border);
      z-index: 0;
    }

    .at-step.done:not(:last-child)::after {
      background: var(--green);
    }

    .at-step-circle {
      flex-shrink: 0;
      width: 28px;
      height: 28px;
      border-radius: 50%;
      background: var(--surface2);
      color: var(--text3);
      border: 2px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 12px;
      font-weight: 700;
      transition: all .25s;
      z-index: 1;
      position: relative;
    }

    .at-step.active .at-step-circle {
      background: var(--primary);
      color: #fff;
      border-color: var(--primary);
      box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    }

    .at-step.done .at-step-circle {
      background: var(--green);
      color: #fff;
      border-color: var(--green);
    }

    .at-step-lbl {
      font-size: 11px;
      font-weight: 600;
      color: var(--text3);
      white-space: nowrap;
    }

    .at-step.active .at-step-lbl {
      color: var(--primary);
    }

    .at-step.done .at-step-lbl {
      color: var(--green);
    }

    /* B. 시작 전 체크리스트 pill */
    .at-checklist {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      align-items: center;
      padding: 4px 0;
    }

    .at-chk {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 3px 9px;
      border-radius: 999px;
      font-size: 11px;
      font-weight: 600;
      background: var(--surface2);
      color: var(--text3);
      border: 1px solid var(--border);
      transition: all .2s;
    }

    .at-chk .at-chk-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--text3);
      transition: background .2s;
    }

    .at-chk.ok {
      background: rgba(16, 185, 129, 0.12);
      border-color: rgba(16, 185, 129, 0.35);
      color: var(--green);
    }

    .at-chk.ok .at-chk-dot {
      background: var(--green);
      box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
    }

    .at-chk.warn {
      background: rgba(239, 68, 68, 0.10);
      border-color: rgba(239, 68, 68, 0.3);
      color: var(--red);
    }

    .at-chk.warn .at-chk-dot {
      background: var(--red);
    }

    /* C. 프리셋 드롭다운 */
    .at-preset-wrap {
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .at-preset-btn {
      padding: 6px 12px;
      background: linear-gradient(135deg, rgba(139, 92, 246, 0.14), rgba(59, 130, 246, 0.10));
      border: 1px solid rgba(139, 92, 246, 0.3);
      color: var(--primary);
      border-radius: 8px;
      font-size: 11px;
      font-weight: 700;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 5px;
      transition: all .2s;
    }

    .at-preset-btn:hover {
      background: linear-gradient(135deg, rgba(139, 92, 246, 0.24), rgba(59, 130, 246, 0.18));
      transform: translateY(-1px);
    }

    .at-preset-menu {
      position: absolute;
      top: 100%;
      right: 0;
      margin-top: 4px;
      min-width: 240px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
      z-index: 100;
      padding: 6px;
      display: none;
    }

    .at-preset-menu.open {
      display: block;
    }

    .at-preset-item {
      display: flex;
      flex-direction: column;
      gap: 2px;
      padding: 8px 10px;
      border-radius: 6px;
      cursor: pointer;
      transition: background .15s;
    }

    .at-preset-item:hover {
      background: var(--surface2);
    }

    .at-preset-item .pn {
      font-size: 12px;
      font-weight: 700;
      color: var(--text);
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .at-preset-item .pd {
      font-size: 10px;
      color: var(--text3);
      line-height: 1.4;
    }

    .at-preset-item .pt {
      font-size: 9px;
      padding: 1px 6px;
      border-radius: 4px;
      font-weight: 600;
    }

    .at-preset-item.safe .pt {
      background: rgba(16, 185, 129, 0.15);
      color: var(--green);
    }

    .at-preset-item.normal .pt {
      background: rgba(59, 130, 246, 0.15);
      color: var(--primary);
    }

    .at-preset-item.aggressive .pt {
      background: rgba(239, 68, 68, 0.15);
      color: var(--red);
    }

    .at-preset-item.daytrade .pt {
      background: rgba(245, 158, 11, 0.15);
      color: var(--yellow);
    }

    .at-preset-item.swing .pt {
      background: rgba(139, 92, 246, 0.15);
      color: #a855f7;
    }

    /* D. 전략 카테고리 그루핑 */
    .at-strat-group {
      margin-bottom: 10px;
    }

    .at-strat-group:last-child {
      margin-bottom: 0;
    }

    .at-strat-group-title {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 10px;
      font-weight: 700;
      color: var(--text3);
      margin-bottom: 4px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    .at-strat-group-title .sg-ico {
      font-size: 12px;
    }

    .at-strat-group-title .sg-hint {
      font-size: 9px;
      font-weight: 500;
      color: var(--text3);
      text-transform: none;
      letter-spacing: 0;
      opacity: .8;
    }

    .at-strat-group-row {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
    }

    .dash-strat-btn .strat-rec {
      display: inline-block;
      font-size: 9px;
      color: #fbbf24;
      margin-left: 3px;
      vertical-align: middle;
    }

    /* F. 초보자 모드 */
    #page-autotrade.beginner-mode details.adv-detail {
      display: none;
    }

    #page-autotrade.beginner-mode .adv-only {
      display: none !important;
    }

    .at-beginner-toggle {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 5px 10px;
      border-radius: 8px;
      background: var(--surface2);
      border: 1px solid var(--border);
      font-size: 11px;
      cursor: pointer;
      color: var(--text2);
      transition: all .2s;
    }

    .at-beginner-toggle:hover {
      border-color: var(--primary);
    }

    .at-beginner-toggle.active {
      background: rgba(16, 185, 129, 0.12);
      border-color: var(--green);
      color: var(--green);
    }

    .at-beginner-toggle .bt-ico {
      font-size: 13px;
    }

    /* G. 저장 상태 뱃지 */
    .at-save-badge {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 3px 8px;
      border-radius: 999px;
      font-size: 10px;
      font-weight: 600;
      background: var(--surface2);
      color: var(--text3);
      border: 1px solid var(--border);
    }

    .at-save-badge.saved {
      background: rgba(16, 185, 129, 0.10);
      color: var(--green);
      border-color: rgba(16, 185, 129, 0.25);
    }

    .at-save-badge.dirty {
      background: rgba(245, 158, 11, 0.12);
      color: var(--yellow);
      border-color: rgba(245, 158, 11, 0.3);
      animation: saveDirtyPulse 2s ease-in-out infinite;
    }

    @keyframes saveDirtyPulse {

      0%,
      100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.3);
      }

      50% {
        box-shadow: 0 0 0 3px rgba(245, 158, 11, 0);
      }
    }

    .at-save-badge .dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: currentColor;
    }

    /* H. 섹션 접기/펼치기 */
    .at-collapsible .card-title {
      cursor: pointer;
      user-select: none;
    }

    .at-collapsible .card-title::after {
      content: '▾';
      margin-left: auto;
      font-size: 14px;
      color: var(--text3);
      transition: transform .2s;
    }

    .at-collapsible.collapsed .card-title::after {
      transform: rotate(-90deg);
    }

    .at-collapsible.collapsed>*:not(.card-title) {
      display: none !important;
    }

    /* E. 실전모드 강화 - 고정 상단 배지 + 전체 빨간 그라데이션 테두리 */
    #page-autotrade.live-mode {
      box-shadow: inset 0 0 0 3px rgba(239, 68, 68, 0.5), 0 0 24px rgba(239, 68, 68, 0.08);
    }

    #page-autotrade.live-mode::before {
      content: '🔴 LIVE 모드 — 실제 자금으로 주문이 전송됩니다';
      display: block;
      position: sticky;
      top: 0;
      z-index: 50;
      background: linear-gradient(90deg, #ef4444, #dc2626, #ef4444);
      background-size: 200% 100%;
      animation: liveStrobe 3s linear infinite;
      color: #fff;
      text-align: center;
      padding: 6px 12px;
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.5px;
      border-radius: 6px;
      margin-bottom: 8px;
      box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    }

    #page-autotrade.live-mode .at-start-btn {
      box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.4), 0 0 16px rgba(239, 68, 68, 0.2);
    }

    /* 시작 컨트롤 행: 체크리스트와 버튼 정렬 개선 */
    .at-control-bar-grid {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      align-items: center;
    }

    /* 반응형: 모바일에서 스테퍼 간결하게 */
    @media (max-width: 768px) {
      .at-step {
        min-width: 80px;
      }

      .at-step:not(:last-child)::after {
        width: calc(100% - 70px);
      }

      .at-step-lbl {
        font-size: 10px;
      }

      .at-step-circle {
        width: 24px;
        height: 24px;
        font-size: 11px;
      }

      .at-preset-menu {
        right: auto;
        left: 0;
        min-width: 220px;
      }
    }

    /* ───── 실시간 스캔 상태등 ───── */
    .rt-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      display: inline-block;
      transition: background .3s, box-shadow .3s;
    }

    .rt-dot.rt-idle {
      background: var(--text3);
    }

    .rt-dot.rt-active {
      background: var(--green);
      box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
      animation: rtPulse 1.2s ease-out infinite;
    }

    .rt-dot.rt-warn {
      background: var(--yellow);
    }

    .rt-dot.rt-err {
      background: var(--red);
    }

    @keyframes rtPulse {
      0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
      }

      70% {
        box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
      }

      100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
      }
    }

    /* ───── 자금 칩 (상단 상태바) ───── */
    .funds-chip {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px 10px;
      border-radius: 999px;
      background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(59, 130, 246, 0.10));
      border: 1px solid rgba(16, 185, 129, 0.25);
      font-size: 11px;
      line-height: 1;
    }

    .funds-chip .fund-ico {
      font-style: normal;
      font-size: 12px;
    }

    .funds-chip .fund-label {
      color: var(--text3);
      font-weight: 500;
    }

    .funds-chip b {
      color: var(--text);
      font-weight: 700;
      font-size: 12px;
    }

    .funds-chip .fund-sep {
      color: var(--text3);
      opacity: .6;
      margin: 0 2px;
    }

    .funds-chip .fund-refresh {
      background: transparent;
      border: 1px solid var(--border);
      color: var(--text2);
      width: 20px;
      height: 20px;
      border-radius: 50%;
      cursor: pointer;
      font-size: 12px;
      padding: 0;
      margin-left: 4px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: transform .3s;
    }

    .funds-chip .fund-refresh:hover {
      background: var(--surface2);
      color: var(--primary);
      transform: rotate(180deg);
    }

    /* ───── 자금 요약 스트립 (리스크관리 상단) ───── */
    .funds-summary {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr auto;
      gap: 10px;
      align-items: center;
      padding: 10px 12px;
      margin-bottom: 12px;
      border-radius: 10px;
      background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(59, 130, 246, 0.06));
      border: 1px solid rgba(16, 185, 129, 0.18);
    }

    .funds-summary .fs-item {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
    }

    .funds-summary .fs-lbl {
      font-size: 10px;
      color: var(--text3);
      font-weight: 500;
    }

    .funds-summary .fs-val {
      font-size: 15px;
      font-weight: 700;
      color: var(--text);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .funds-summary .fs-val.fs-warn {
      color: var(--yellow);
    }

    .funds-summary .fs-val.fs-ok {
      color: var(--green);
    }

    .funds-summary .fs-sub {
      font-size: 10px;
      color: var(--text3);
    }

    /* ───── 종목별 매도 규칙 카드 ───── */
    .perstock-row {
      display: grid;
      grid-template-columns: minmax(120px, 1fr) auto auto auto;
      gap: 8px;
      align-items: center;
      padding: 8px 10px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 8px;
    }

    .perstock-row .ps-name {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
    }

    .perstock-row .ps-nm {
      font-weight: 700;
      font-size: 12px;
      color: var(--text);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .perstock-row .ps-cd {
      font-size: 10px;
      color: var(--text3);
    }

    .perstock-row .ps-hold {
      font-size: 11px;
      color: var(--text2);
      min-width: 110px;
    }

    .perstock-row .ps-hold b {
      color: var(--green);
      font-weight: 700;
    }

    .perstock-row .ps-hold.none b {
      color: var(--text3);
      font-weight: 500;
    }

    .perstock-row .ps-mode {
      display: flex;
      gap: 4px;
      align-items: center;
    }

    .perstock-row .ps-mode label {
      display: inline-flex;
      align-items: center;
      gap: 3px;
      font-size: 10px;
      color: var(--text2);
      cursor: pointer;
      padding: 3px 6px;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: var(--surface);
    }

    .perstock-row .ps-mode label.active {
      background: rgba(59, 130, 246, .15);
      border-color: var(--primary);
      color: var(--primary);
      font-weight: 600;
    }

    .perstock-row .ps-mode input[type=radio] {
      display: none;
    }

    .perstock-row .ps-val {
      display: flex;
      gap: 4px;
      align-items: center;
    }

    .perstock-row .ps-val input {
      width: 68px;
      padding: 4px 6px;
      font-size: 11px;
      text-align: right;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text);
    }

    .perstock-row .ps-val .unit {
      font-size: 10px;
      color: var(--text3);
    }

    .perstock-row.ps-default .ps-nm {
      color: var(--text2);
    }

    .perstock-row.ps-nohold {
      opacity: .75;
    }

    /* ───── 좌측 스택 (보유/관심 세로 배치) ───── */
    .at-stock-stack {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .at-stock-stack .card {
      margin-bottom: 0;
    }

    /* 그리드-2 반응형 비율 조정 (좌: 1, 우:1.3 — 리스크 관리 넉넉히) */
    .at-row3-grid {
      grid-template-columns: 1fr 1.3fr !important;
    }

    @media (max-width:900px) {
      .at-row3-grid {
        grid-template-columns: 1fr !important;
      }

      .funds-summary {
        grid-template-columns: 1fr 1fr;
      }
    }

    .at-stock-chip {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 10px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--surface);
      font-size: 11px;
      cursor: pointer;
      transition: all .2s;
      user-select: none;
      min-width: 120px;
    }

    .at-stock-chip:hover {
      border-color: var(--primary);
      background: rgba(59, 130, 246, .06);
    }

    .at-stock-chip.selected {
      border-color: var(--green);
      background: rgba(16, 185, 129, .1);
      box-shadow: 0 0 6px rgba(16, 185, 129, .15);
    }

    .at-stock-chip .chip-name {
      font-weight: 600;
      color: var(--text);
      max-width: 80px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .at-stock-chip .chip-code {
      color: var(--text3);
      font-size: 10px;
    }

    .at-stock-chip .chip-price {
      margin-left: auto;
      font-weight: 600;
    }

    .at-stock-chip .chip-chg {
      font-size: 10px;
    }

    .at-stock-chip .chip-chk {
      width: 14px;
      height: 14px;
      border-radius: 50%;
      border: 1.5px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 9px;
      flex-shrink: 0;
    }

    .at-stock-chip.selected .chip-chk {
      border-color: var(--green);
      background: var(--green);
      color: #fff;
    }

    /* Auto-Trade Section Headers */
    .at-section-header {
      font-size: 13px;
      font-weight: 700;
      color: var(--text);
      margin-bottom: 6px;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .at-section-header .at-badge {
      font-size: 10px;
      font-weight: 600;
      padding: 2px 8px;
      border-radius: 10px;
    }

    /* Auto-Trade Start Button */
    .at-start-btn {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 24px;
      border-radius: 12px;
      border: 2px solid var(--green);
      background: rgba(16, 185, 129, .08);
      color: var(--green);
      cursor: pointer;
      transition: all .3s;
      font-size: 15px;
      font-weight: 700;
      user-select: none;
    }

    .at-start-btn:hover {
      background: rgba(16, 185, 129, .18);
      box-shadow: 0 0 16px rgba(16, 185, 129, .2);
      transform: translateY(-1px);
    }

    .at-start-btn.running {
      border-color: var(--red);
      background: rgba(239, 68, 68, .08);
      color: var(--red);
      animation: at-pulse 2s infinite;
    }

    .at-start-btn .at-start-icon {
      font-size: 18px;
    }

    @keyframes at-pulse {

      0%,
      100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, .3)
      }

      50% {
        box-shadow: 0 0 16px 4px rgba(239, 68, 68, .15)
      }
    }

    .ai-sel-wrap {
      display: flex;
      gap: 5px;
      flex-wrap: wrap;
      margin: 6px 0 8px
    }

    /* 세로 단일선택 (한 줄에 하나씩) — AI 자문 패널 */
    .ai-sel-wrap.vertical {
      display: flex;
      flex-direction: column;
      gap: 4px;
      flex-wrap: nowrap;
      margin: 6px 0 8px;
    }

    .ai-sel-wrap.vertical .ai-sel-btn {
      width: 100%;
      padding: 8px 12px;
      border-radius: 8px;
      font-size: 12px;
      display: flex;
      align-items: center;
      gap: 8px;
      text-align: left;
      white-space: nowrap;
    }

    .ai-sel-wrap.vertical .ai-sel-btn .ai-brand {
      font-weight: 700;
      min-width: 64px;
      flex-shrink: 0;
    }

    .ai-sel-wrap.vertical .ai-sel-btn .ai-model {
      font-size: 10px;
      opacity: .75;
      margin-left: auto;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 200px;
    }

    .ai-sel-btn {
      padding: 3px 10px;
      border-radius: 14px;
      border: 1.5px solid var(--border);
      background: var(--bg);
      color: var(--text3);
      font-size: 11px;
      font-weight: 600;
      cursor: pointer;
      transition: all .2s;
      user-select: none;
      white-space: nowrap
    }

    /* ── AI 액션 버튼 (질문 / AI Agent 토론) ───────────────────────
       Flex 레이아웃 + 아이콘 분리 + 명확한 계층 그라데이션.
       두 버튼은 한 컨테이너 안에서 동일한 높이·기본폭 구조를 공유해
       시각적으로 페어를 이룸. 토론 버튼이 주 액션이므로 flex:1.3 으로
       약간 넓게 잡아 우선순위를 암시. */
    .ai-action-btn {
      flex: 1 1 0;
      min-height: 44px;
      padding: 10px 14px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      border: none;
      border-radius: 10px;
      font-family: inherit;
      font-size: 13px;
      font-weight: 700;
      letter-spacing: 0.2px;
      color: #fff;
      cursor: pointer;
      user-select: none;
      white-space: nowrap;
      transition: transform .15s ease, box-shadow .2s ease, filter .15s ease;
    }

    .ai-action-btn .ai-action-icon {
      font-size: 16px;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .ai-action-btn .ai-action-label {
      line-height: 1;
    }

    .ai-action-btn:hover {
      transform: translateY(-1px);
      filter: brightness(1.05);
    }

    .ai-action-btn:active {
      transform: translateY(0);
      filter: brightness(0.95);
    }

    .ai-action-btn:focus-visible {
      outline: 2px solid #fff;
      outline-offset: 2px;
    }

    /* 질문(보조 액션): 블루 그라데이션 */
    .ai-action-ask {
      background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
      box-shadow: 0 2px 6px rgba(59, 130, 246, .35), inset 0 1px 0 rgba(255, 255, 255, .15);
    }

    .ai-action-ask:hover {
      box-shadow: 0 6px 14px rgba(59, 130, 246, .55), inset 0 1px 0 rgba(255, 255, 255, .18);
    }

    /* AI Agent 토론(주 액션): 보라 그라데이션 + 살짝 큰 flex 비율 */
    .ai-action-debate {
      flex: 1.3 1 0;
      background: linear-gradient(135deg, #a855f7 0%, #6d28d9 100%);
      box-shadow: 0 2px 8px rgba(168, 85, 247, .45), inset 0 1px 0 rgba(255, 255, 255, .18);
    }

    .ai-action-debate:hover {
      box-shadow: 0 6px 16px rgba(168, 85, 247, .65), inset 0 1px 0 rgba(255, 255, 255, .22);
    }

    /* 좁은 폭에서는 두 버튼을 동일 비율로 (텍스트가 줄바꿈 없이 들어가도록) */
    @media (max-width: 420px) {
      .ai-action-btn {
        font-size: 12px;
        padding: 10px 10px;
        gap: 6px;
      }

      .ai-action-debate {
        flex: 1 1 0;
      }
    }

    .ai-sel-btn:hover {
      border-color: var(--primary);
      color: var(--text)
    }

    .ai-sel-btn.sel-kimi.selected {
      background: rgba(139, 92, 246, .2);
      color: #8b5cf6;
      border-color: #8b5cf6;
      box-shadow: 0 0 8px rgba(139, 92, 246, .35)
    }

    .ai-sel-btn.sel-openai.selected {
      background: rgba(16, 163, 127, .2);
      color: #10a37f;
      border-color: #10a37f;
      box-shadow: 0 0 8px rgba(16, 163, 127, .35)
    }

    .ai-sel-btn.sel-claude.selected {
      background: rgba(217, 119, 6, .2);
      color: #d97706;
      border-color: #d97706;
      box-shadow: 0 0 8px rgba(217, 119, 6, .35)
    }

    .ai-sel-btn.sel-gemini.selected {
      background: rgba(66, 133, 244, .2);
      color: #4285f4;
      border-color: #4285f4;
      box-shadow: 0 0 8px rgba(66, 133, 244, .35)
    }

    .ai-sel-btn.sel-grok.selected {
      background: rgba(29, 155, 240, .2);
      color: #1d9bf0;
      border-color: #1d9bf0;
      box-shadow: 0 0 8px rgba(29, 155, 240, .35)
    }

    .ai-resp-label {
      display: inline-block;
      padding: 1px 7px;
      border-radius: 8px;
      font-size: 10px;
      font-weight: 700;
      margin-bottom: 4px
    }

    .ai-resp-label.lbl-kimi {
      background: rgba(139, 92, 246, .15);
      color: #8b5cf6
    }

    .ai-resp-label.lbl-openai {
      background: rgba(16, 163, 127, .15);
      color: #10a37f
    }

    .ai-resp-label.lbl-claude {
      background: rgba(217, 119, 6, .15);
      color: #d97706
    }

    .ai-resp-label.lbl-gemini {
      background: rgba(66, 133, 244, .15);
      color: #4285f4
    }

    .ai-resp-label.lbl-grok {
      background: rgba(29, 155, 240, .15);
      color: #1d9bf0
    }

    .fade-in {
      animation: fadeIn .3s ease
    }

    .tv-chart-wrap {
      width: 100%;
      height: 500px;
      border-radius: 8px;
      overflow: hidden;
      background: var(--fin-bg-1, #131820)
    }

    .tv-chart-wrap .tradingview-widget-copyright,
    .tv-chart-wrap iframe+div {
      display: none !important
    }

    .chart-stock-active {
      background: var(--yellow) !important;
      color: #0a0e17 !important;
      border-color: var(--yellow) !important;
      font-weight: 700 !important
    }

    .guide-step {
      display: flex;
      gap: 16px;
      padding: 16px 0;
      border-bottom: 1px solid var(--border)
    }

    .guide-num {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background: var(--primary);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 700;
      flex-shrink: 0
    }

    .guide-content h4 {
      margin-bottom: 4px
    }

    .guide-content p {
      font-size: 13px;
      color: var(--text2);
      line-height: 1.6
    }

    .data-src {
      font-size: 11px;
      color: var(--text3);
      padding: 4px 8px;
      background: var(--bg);
      border-radius: 4px;
      display: inline-block
    }

    .search-dropdown {
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 0 0 8px 8px;
      max-height: 250px;
      overflow-y: auto;
      z-index: 50;
      box-shadow: 0 8px 24px rgba(0, 0, 0, .4)
    }

    .search-item {
      padding: 8px 12px;
      cursor: pointer;
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 12px;
      border-bottom: 1px solid var(--border)
    }

    .search-item:hover {
      background: var(--surface2)
    }

    .search-item .s-name {
      font-weight: 600
    }

    .search-item .s-code {
      color: var(--text3);
      font-size: 11px
    }

    .search-item .s-market {
      font-size: 10px;
      color: var(--primary);
      padding: 1px 6px;
      background: rgba(59, 130, 246, .1);
      border-radius: 3px
    }

    .ai-provider-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 0;
      border-bottom: 1px solid var(--border)
    }

    .ai-provider-item:last-child {
      border-bottom: none
    }

    .ai-provider-info {
      display: flex;
      align-items: center;
      gap: 10px
    }

    .ai-provider-icon {
      width: 32px;
      height: 32px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 700;
      font-size: 12px;
      color: #fff;
      flex-shrink: 0
    }

    .ai-provider-name {
      font-size: 13px;
      font-weight: 600
    }

    .ai-provider-status {
      font-size: 10px;
      padding: 2px 6px;
      border-radius: 8px;
      margin-left: 6px
    }

    .ai-provider-status.set {
      background: rgba(16, 185, 129, .15);
      color: var(--green)
    }

    .ai-provider-status.unset {
      background: rgba(107, 114, 128, .15);
      color: var(--text3)
    }

    .api-key-section {
      padding: 14px;
      background: var(--bg);
      border-radius: 8px;
      margin-bottom: 10px
    }

    .api-key-section .provider-label {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 12px;
      color: var(--text2);
      margin-bottom: 6px
    }

    .api-key-section .provider-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      display: inline-block
    }

    .drop-zone {
      border: 2px dashed var(--border);
      border-radius: 8px;
      padding: 20px;
      text-align: center;
      cursor: pointer;
      transition: .2s;
      color: var(--text3);
      font-size: 13px;
      margin-bottom: 16px
    }

    .drop-zone:hover {
      border-color: var(--primary);
      color: var(--primary)
    }

    .drop-zone.dragover {
      border-color: var(--green);
      background: rgba(16, 185, 129, .05);
      color: var(--green)
    }

    .test-result {
      font-size: 11px;
      margin-top: 4px;
      padding: 2px 0
    }

    .test-result.success {
      color: var(--green)
    }

    .test-result.fail {
      color: var(--red)
    }

    /* ============================================================
       MOBILE PORTRAIT: 프리미엄 앱 하단 탭바 + 더보기 + AI FAB (v2.0 재작성)
       ============================================================ */

    /* ── 하단 탭 네비게이션 ── */
    .mobile-bottom-nav {
      display: none;
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      height: 60px;
      background: rgba(17, 24, 39, 0.95);
      -webkit-backdrop-filter: saturate(180%) blur(20px);
      backdrop-filter: saturate(180%) blur(20px);
      border-top: 1px solid rgba(42, 52, 68, 0.5);
      z-index: 1000;
      align-items: stretch;
      justify-content: space-around;
      padding: 0 4px env(safe-area-inset-bottom) 4px;
    }

    .mob-tab {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      flex: 1;
      border: none;
      background: none;
      color: var(--text3);
      font-size: 10px;
      font-weight: 500;
      cursor: pointer;
      gap: 2px;
      padding: 4px 0 2px;
      transition: color 0.2s, transform 0.15s;
      position: relative;
      -webkit-tap-highlight-color: transparent;
    }

    .mob-tab .mob-icon {
      font-size: 22px;
      line-height: 1;
      transition: transform 0.2s;
    }

    .mob-tab.active {
      color: var(--primary);
    }

    .mob-tab.active .mob-icon {
      transform: scale(1.1);
    }

    .mob-tab.active::before {
      content: '';
      position: absolute;
      top: -1px;
      left: 50%;
      transform: translateX(-50%);
      width: 24px;
      height: 3px;
      background: var(--primary);
      border-radius: 0 0 3px 3px;
      box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
    }

    .mob-tab:active {
      transform: scale(0.9);
      opacity: 0.7;
    }

    /* ── 더보기 슬라이드업 메뉴 ── */
    .mobile-more-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0);
      z-index: 1100;
      -webkit-tap-highlight-color: transparent;
      transition: background 0.3s;
    }

    .mobile-more-overlay.show {
      display: block;
      background: rgba(0, 0, 0, 0.55);
    }

    .mobile-more-menu {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      background: rgba(17, 24, 39, 0.97);
      -webkit-backdrop-filter: saturate(180%) blur(24px);
      backdrop-filter: saturate(180%) blur(24px);
      border-top: 1px solid rgba(42, 52, 68, 0.6);
      border-radius: 20px 20px 0 0;
      padding: 6px 0 calc(12px + env(safe-area-inset-bottom)) 0;
      z-index: 1101;
      transform: translateY(100%);
      transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .mobile-more-menu.show {
      transform: translateY(0);
    }

    .mobile-more-handle {
      width: 40px;
      height: 5px;
      background: rgba(107, 114, 128, 0.5);
      border-radius: 3px;
      margin: 6px auto 12px;
    }

    .mobile-more-menu .more-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 6px;
      padding: 4px 16px 12px;
    }

    .mobile-more-menu .more-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 6px;
      padding: 16px 8px;
      border: none;
      background: rgba(26, 35, 50, 0.6);
      color: var(--text);
      font-size: 12px;
      font-weight: 500;
      cursor: pointer;
      border-radius: 14px;
      -webkit-tap-highlight-color: transparent;
      transition: background 0.15s, transform 0.15s;
    }

    .mobile-more-menu .more-item:active {
      background: rgba(59, 130, 246, 0.15);
      transform: scale(0.95);
    }

    .mobile-more-menu .more-item .more-icon {
      font-size: 26px;
      width: 44px;
      height: 44px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(42, 52, 68, 0.5);
      border-radius: 12px;
    }

    /* ── Portrait 전용 표시 제어 ── */
    @media (max-width: 900px) and (orientation: portrait) {
      .mobile-bottom-nav {
        display: flex;
      }

      /* ── 공통 페이지 서브탭바 (모바일 전용) — 메인메뉴 아래 sticky, 각 페이지별로 하나씩 ── */
      .mobile-subtabs {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        padding: 6px;
        margin: 6px 0 10px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 10px;
        position: sticky;
        top: 78px;
        /* 헤더 2줄 네비 아래 — 기존 sticky 헤더 높이에 맞춤 */
        z-index: 40;
      }

      /* 기본: 한 줄에 4개 (25%) — 탭 수가 적으면 자동으로 더 넓어짐 */
      .mobile-subtabs .subtab {
        flex: 1 1 calc(25% - 4px);
        min-width: 0;
        padding: 8px 6px;
        font-size: 11px;
        font-weight: 600;
        border: 1px solid var(--border);
        border-radius: 7px;
        background: rgba(26, 35, 50, 0.7);
        color: var(--text2);
        cursor: pointer;
        white-space: nowrap;
        transition: background .15s, color .15s, border-color .15s;
        min-height: 36px;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .mobile-subtabs .subtab.active {
        background: rgba(59, 130, 246, 0.18);
        border-color: rgba(59, 130, 246, 0.55);
        color: var(--primary);
      }

      /* 모바일에서 섹션 토글: data-subsection 속성을 가진 .page-section 요소만 표시 제어 */
      .page .page-section {
        display: none !important;
      }

      .page .page-section.active {
        display: block !important;
      }

      /* 섹션 내부의 grid-2 구조는 모바일에서 자동 풀림 (grid가 1열로 떨어지도록) */
      .page-section .grid-2 {
        grid-template-columns: 1fr !important;
      }

      /* ── (레거시) 대시보드 전용 4탭 시스템: 공통 .mobile-subtabs로 교체되어 CSS 규칙만 남김 ── */
      .dash-mobile-tabs {
        display: none !important;
      }

      #page-dashboard .dash-section-grid {
        display: block !important;
        margin-top: 0 !important;
      }

      #page-dashboard .dash-section {
        display: none !important;
      }

      #page-dashboard .dash-section.active {
        display: block !important;
      }

      /* 🆕 자동매매 보유종목/차트 그리드 → 1열 스택 */
      .at-pos-chart-grid {
        grid-template-columns: 1fr !important;
      }

      .at-pos-panel #atPositionTable {
        max-height: 360px !important;
      }
    }

    /* 🆕 보유 종목 카드 hover 강조 (데스크탑) */
    .at-pos-card {
      transition: transform 0.12s ease, box-shadow 0.12s ease;
    }

    .at-pos-card:hover {
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    }
