  :root { --bg: #0f1117; --surface: #1a1d2b; --card: #141725; --border: #2a2d3a; --text: #e2e8f0; --text2: #94a3b8; --blue: #3b82f6; --purple: #8b5cf6; --green: #22c55e; --red: #ef4444; --orange: #f59e0b; }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); height: 100vh; height: 100dvh; overflow: hidden; }
  #app { display: flex; height: 100vh; height: 100dvh; }
  #alerts { width: 420px; min-width: 320px; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg); }
  #alerts-header { padding: 14px 16px; border-bottom: 1px solid var(--border); }
  #alerts-header h2 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
  #alerts-filters { display: flex; gap: 6px; flex-wrap: wrap; }
  #alerts-filters select, #alerts-filters input { background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-size: 11px; outline: none; }
  #alerts-filters select:focus, #alerts-filters input:focus { border-color: var(--blue); }
  #alerts-list { flex: 1; overflow-y: auto; padding: 4px; }
  .alert-row { padding: 10px 12px; border-radius: 8px; cursor: pointer; margin: 2px 0; border: 1px solid transparent; display: flex; gap: 8px; align-items: flex-start; }
  .alert-row:hover { background: var(--surface); }
  .alert-row.selected { border-color: var(--blue); background: var(--surface); }
  .alert-sev { font-size: 9px; padding: 2px 6px; border-radius: 3px; font-weight: 600; white-space: nowrap; }
  .alert-info { flex: 1; min-width: 0; }
  .alert-title { font-size: 12px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .alert-meta { font-size: 10px; color: var(--text2); margin-top: 2px; }
  .alert-amount { font-size: 11px; color: var(--purple); font-weight: 600; white-space: nowrap; }
  #chat { flex: 1; display: flex; flex-direction: column; background: var(--bg); min-width: 0; }
  #chat-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; position: relative; }
  #chat-header h2 { font-size: 16px; font-weight: 600; }
  #chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
  .msg { max-width: 88%; padding: 14px 16px; border-radius: 14px; font-size: 13.5px; line-height: 1.7; word-wrap: break-word; }
  .msg.user { align-self: flex-end; background: var(--blue); color: #fff; }
  .msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
  .reasoning { font-size: 12px; color: var(--purple); margin-bottom: 8px; padding: 8px 12px; background: rgba(124,58,237,.06); border-radius: 10px; border-left: 3px solid var(--purple); cursor: pointer; line-height: 1.4; }
  .reasoning br { content: ''; display: block; margin-bottom: 1px; }
  .reasoning br + br { display: none; }
  .reasoning-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: rgba(139,92,246,.6); margin-bottom: 4px; }
  .reasoning :where(code) { background: rgba(139,92,246,.12); padding: 1px 5px; border-radius: 4px; font-size: 11px; }
  .reasoning :where(strong) { color: var(--text); font-weight: 600; }
  .reasoning.collapsed { max-height: 72px; overflow: hidden; position: relative; }
  .reasoning.collapsed::after { content:""; position:absolute; bottom:0; left:0; right:0; height:36px; background:linear-gradient(transparent, rgba(15,17,23,.95)); pointer-events:none; border-radius:0 0 10px 10px; }
  .tool-badge { font-size: 11px; color: var(--blue); margin: 3px 0; padding: 3px 8px; background: rgba(59,130,246,.08); border-radius: 6px; display: flex; align-items: center; gap: 6px; }
  .tool-badge.tool-done { color: var(--text2); background: rgba(255,255,255,.03); }
  .msg.user.pending { opacity: .45; font-style: italic; }
  .msg.user.pending::after { content: ' (排队中)'; font-size: 10px; opacity: .7; }
  .spinner { width: 12px; height: 12px; border: 2px solid var(--blue); border-top-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .chart-container { margin: 10px 0; }
  .chart-container canvas { width: 100%; height: auto; border-radius: 10px; }
  /* Chart.js — interactive charts in chat */
  .chart-interactive-wrap {
    margin: 12px 0;
    max-width: 100%;
    border-radius: 14px;
    padding: 2px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.45), rgba(59, 130, 246, 0.25), rgba(34, 197, 94, 0.15));
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  }
  .chart-interactive-inner {
    position: relative;
    height: 280px;
    width: 100%;
    max-width: 720px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(26, 29, 43, 0.98), rgba(15, 17, 23, 0.99));
    padding: 10px 10px 6px;
    overflow: hidden;
  }
  .chart-interactive-inner canvas {
    max-height: 100%;
  }
  .stream-charts { width: 100%; }
  .addr-link { color: var(--blue); text-decoration: none; font-family: monospace; font-size: 0.92em; }
  .addr-link:hover { text-decoration: underline; }
  .msg .markdown { line-height: 1.7; }
  .msg .markdown h1, .msg .markdown h2, .msg .markdown h3 { color: var(--text); font-weight: 600; margin: 12px 0 4px; line-height: 1.35; }
  .msg .markdown h1 { font-size: 17px; }
  .msg .markdown h2 { font-size: 15px; }
  .msg .markdown h3 { font-size: 14px; }
  .msg .markdown hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
  .msg .markdown .table-wrap { overflow-x: auto; margin: 10px 0; border-radius: 10px; border: 1px solid var(--border); }
  .msg .markdown table { border-collapse: collapse; width: 100%; font-size: 12px; }
  .msg .markdown th, .msg .markdown td { padding: 7px 10px; text-align: left; }
  .msg .markdown th { background: linear-gradient(180deg, rgba(139,92,246,.15), rgba(139,92,246,.06)); color: var(--purple); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 2px solid rgba(139,92,246,.25); white-space: nowrap; }
  .msg .markdown td { border-bottom: 1px solid rgba(255,255,255,.04); color: var(--text2); font-size: 12px; }
  .msg .markdown tr:last-child td { border-bottom: none; }
  .msg .markdown tr:nth-child(even) td { background: rgba(255,255,255,.02); }
  .msg .markdown tr:hover td { background: rgba(139,92,246,.06); color: var(--text); }
  .msg .markdown td:first-child { color: var(--text); font-weight: 500; }
  .msg .markdown code { background: rgba(139,92,246,.12); padding: 2px 6px; border-radius: 4px; font-size: 12px; font-family: 'SF Mono','Fira Code','Cascadia Code',monospace; }
  .msg .markdown pre { background: rgba(0,0,0,.35); padding: 12px 14px; border-radius: 8px; overflow-x: auto; margin: 8px 0; border: 1px solid rgba(255,255,255,.04); }
  .msg .markdown pre code { background: none; padding: 0; font-size: 12px; line-height: 1.6; }
  .msg .markdown h1 { font-size: 17px; font-weight: 700; margin: 14px 0 6px; color: var(--text); }
  .msg .markdown h2 { font-size: 15px; font-weight: 600; margin: 12px 0 5px; }
  .msg .markdown h3 { font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
  .msg .markdown h4,.msg .markdown h5,.msg .markdown h6 { font-size: 13px; font-weight: 600; margin: 8px 0 4px; }
  .msg .markdown ul,.msg .markdown ol { padding-left: 20px; margin: 6px 0; }
  .msg .markdown li { margin: 3px 0; }
  .msg .markdown blockquote { border-left: 3px solid var(--purple); padding: 6px 12px; margin: 8px 0; background: rgba(139,92,246,.06); border-radius: 0 6px 6px 0; color: var(--text2); }
  .msg .markdown a { color: var(--blue); text-decoration: none; }
  .msg .markdown a:hover { text-decoration: underline; }
  .msg .markdown strong { font-weight: 600; color: var(--text); }
  .msg .markdown hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
  .msg .markdown p { margin: 6px 0; }
  .msg .markdown img { max-width: 100%; border-radius: 8px; }
  .msg.assistant .markdown br { content: ''; display: block; margin-bottom: 3px; }
  #chat-box { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
  #chat-box textarea { flex: 1; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 13px; resize: none; min-height: 44px; max-height: 120px; font-family: inherit; outline: none; }
  #chat-box textarea:focus { border-color: var(--blue); }
  #chat-box button { background: var(--blue); color: #fff; border: none; border-radius: 10px; padding: 10px 20px; cursor: pointer; font-size: 13px; font-weight: 500; }
  #chat-box button:disabled { opacity: .5; cursor: default; }
  #chat-drawer-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex-shrink: 0;
    background: none; border: none; color: var(--text2); font-size: 17px; line-height: 1; cursor: pointer; padding: 4px 6px; border-radius: 6px;
  }
  #chat-drawer-btn:hover { color: var(--text); background: var(--surface); }
  #chat-drawer-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
  #mobile-alerts-btn { display: none; background: none; border: none; color: var(--text2); font-size: 18px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
  #mobile-alerts-btn:hover { color: var(--text); background: var(--surface); }
  #mobile-alerts-close { display: none; background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; padding: 2px 6px; border-radius: 6px; position: absolute; right: 12px; top: 12px; }
  #mobile-alerts-close:hover { color: var(--text); background: var(--card); }
  #mobile-market-btn { display: none; background: none; border: none; color: var(--text2); font-size: 18px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
  #mobile-market-btn:hover { color: var(--text); background: var(--surface); }
  #mobile-market-close { display: none; background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
  #mobile-market-close:hover { color: var(--text); background: var(--card); }
  @media (max-width: 768px) {
    #mobile-alerts-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; }
    #mobile-alerts-close { display: block; }
    #alerts-header { position: relative; }
    #mobile-market-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; }
    #chat-header { display: flex; align-items: center; gap: 8px; }
    #chat-header h2 { flex: 1; }
  }
  #drawer-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; }
  #drawer-overlay.open { display: block; }
  #drawer { position: fixed; top: 0; right: -320px; width: 300px; max-width: 85vw; height: 100vh; background: var(--surface); z-index: 100; transition: right .3s; display: flex; flex-direction: column; border-left: 1px solid var(--border); }
  #drawer.open { right: 0; }
  #drawer-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
  #drawer-header h3 { font-size: 15px; font-weight: 600; }
  #drawer-header button { background: none; border: none; color: var(--text2); font-size: 16px; cursor: pointer; border-radius: 6px; }
  #drawer-header button:hover { color: var(--text); background: var(--card); }
  #drawer-actions { padding: 10px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .drawer-new-chat-btn {
    display: block; width: 100%;
    background: var(--blue); color: #fff; border: none; border-radius: 10px;
    padding: 10px 14px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
  }
  .drawer-new-chat-btn:hover { opacity: 0.92; }
  .drawer-new-chat-btn:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
  .drawer-new-chat-btn:disabled { opacity: 0.45; cursor: not-allowed; }
  #drawer-sessions { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }
  .drawer-empty { padding: 16px; color: var(--text2); font-size: 13px; text-align: center; }
  .drawer-error { padding: 14px 12px; margin: 8px; border-radius: 10px; font-size: 12px; line-height: 1.5; color: var(--red); background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.25); }
  .date-group { font-size: 10px; color: var(--text2); letter-spacing: .5px; padding: 8px 8px 4px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
  .date-group-clear {
    background: none; border: 1px solid transparent; color: var(--text2);
    font-size: 9px; cursor: pointer; padding: 1px 6px; border-radius: 3px;
    font-family: inherit; opacity: 0;
    transition: opacity .15s, color .15s, border-color .15s;
  }
  .date-group:hover .date-group-clear { opacity: .7; }
  .date-group-clear:hover { opacity: 1 !important; color: var(--red); border-color: rgba(239,68,68,.3); }
  .session-item-row { display: flex; align-items: stretch; gap: 4px; margin: 2px 0; }
  .session-item-row .session-item { flex: 1; min-width: 0; margin: 0; }
  .session-delete-btn {
    flex-shrink: 0; width: 36px; border: none; background: transparent; color: var(--text2);
    border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    transition: color .15s ease, background .15s ease;
  }
  .session-delete-btn:hover { color: var(--red); background: rgba(239, 68, 68, 0.1); }
  .session-delete-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
  .session-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text2); border: 1px solid transparent; margin: 2px 0; }
  .session-item:hover { background: var(--card); color: var(--text); }
  .session-item:focus { outline: none; }
  .session-item:focus-visible { border-color: var(--blue); background: var(--card); color: var(--text); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35); }
  .session-item.active { border-color: var(--blue); background: rgba(59, 130, 246, 0.08); color: var(--text); }
  .session-item .sess-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .session-item .sess-time { font-size: 10px; color: var(--text2); margin-top: 2px; }
  .presets { padding: 6px 16px 8px; border-top: 1px solid var(--border); }
  .preset-tabs { display: flex; gap: 2px; margin-bottom: 6px; }
  .preset-tab { font-size: 11px; color: var(--text2); padding: 3px 10px; border-radius: 5px; cursor: pointer; font-weight: 500; transition: color .15s, background .15s; }
  .preset-tab:hover { color: var(--text); }
  .preset-tab.active { color: var(--blue); background: rgba(59,130,246,.1); }
  .preset-btns { display: flex; gap: 5px; flex-wrap: wrap; }
  .presets button { background: var(--card); color: var(--text2); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-size: 11px; cursor: pointer; white-space: nowrap; }
  .presets button:hover { color: var(--text); border-color: var(--blue); }
  .chat-export-pdf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    font-family: inherit;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
  }
  .chat-export-pdf-btn:hover {
    opacity: 1 !important;
    color: var(--text) !important;
    background: rgba(148, 163, 184, 0.08);
  }
  .chat-export-pdf-btn:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
    opacity: 1;
  }
  .welcome { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; max-width: 88%; font-size: 13px; line-height: 1.6; }
  .welcome .hi { font-size: 28px; margin-bottom: 4px; }
  .typing { display: flex; gap: 4px; padding: 4px 0; }
  .typing span { width: 5px; height: 5px; background: var(--text2); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out; }
  .typing span:nth-child(2) { animation-delay: .2s; }
  .typing span:nth-child(3) { animation-delay: .4s; }
  @keyframes bounce { 0%,80%,100% { transform: scale(0); } 40% { transform: scale(1); } }
  .modal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:200; justify-content:center; align-items:center; }
  .modal-overlay.open { display:flex; }
  .modal { background:var(--surface); border:1px solid var(--border); border-radius:16px; width:480px; max-width:92vw; max-height:85vh; overflow-y:auto; padding:0; animation: modalIn .2s ease; }
  @keyframes modalIn { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
  .modal-header { padding:16px 20px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; position:sticky; top:0; background:var(--surface); border-radius:16px 16px 0 0; z-index:1; }
  .modal-header h3 { font-size:15px; font-weight:600; color:#e2e8f0; }
  .modal-close { background:none; border:none; color:var(--text2); font-size:18px; cursor:pointer; padding:4px 8px; border-radius:6px; }
  .modal-close:hover { background:var(--card); color:var(--text); }
  .modal-body { padding:20px; }
  .modal .kv { display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px solid var(--border); font-size:13px; }
  .modal .kv:last-child { border-bottom:none; }
  .modal .kl { color:#94a3b8; min-width:80px; }
  .modal .kv span:last-child { color:#e2e8f0; font-weight:500; text-align:right; word-break:break-all; }
  .modal .badge { display:inline-block; padding:2px 8px; border-radius:4px; font-size:10px; font-weight:600; }
  .modal .actions { padding:12px 20px; border-top:1px solid var(--border); display:flex; gap:8px; justify-content:flex-end; }
  .modal .actions button { padding:8px 16px; border-radius:8px; font-size:12px; font-weight:500; cursor:pointer; border:none; }
  .modal .btn-analyze { background:var(--blue); color:#fff; }
  .modal .btn-analyze:hover { opacity:.85; }
  .modal .btn-close { background:var(--card); color:var(--text2); border:1px solid var(--border); }
  ::-webkit-scrollbar { width: 4px; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

  /* ====== Mobile (max-width: 768px) ====== */
  @media (max-width: 768px) {
    #app { flex-direction: column; position: fixed; inset: 0; overflow: hidden; }
    #alerts {
      position: fixed; top: 0; left: -100vw; width: 100vw; max-width: 380px; height: 100vh;
      z-index: 150; transition: left .3s ease; box-shadow: 4px 0 24px rgba(0,0,0,.5);
      background: var(--bg); border-right: 1px solid var(--border);
    }
    #alerts.open { left: 0; }
    #alerts-backdrop { display: none; }
    #alerts-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 149; }
    #chat { flex: 1; width: 100%; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
    #chat-header { padding: 10px 12px; }
    #chat-header h2 { font-size: 14px; }
    #chat-messages { padding: 12px 8px; gap: 8px; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .msg { max-width: 95%; padding: 10px 12px; font-size: 13px; }
    .msg .markdown table { font-size: 10px; }
    .msg .markdown th, .msg .markdown td { padding: 4px 6px; }
    #chat-box { padding: 8px 10px; gap: 6px; }
    #chat-box textarea { font-size: 14px; min-height: 40px; padding: 8px 10px; }
    #chat-box button { padding: 8px 14px; font-size: 13px; }
    .presets { padding: 4px 10px 6px; }
    .preset-tab { font-size: 10px; padding: 2px 8px; }
    .presets button { font-size: 10px; padding: 4px 8px; }
    .welcome { max-width: 96%; font-size: 12px; padding: 14px 16px; }
    .alert-row { padding: 8px 10px; }
    .alert-title { font-size: 11px; }
    .alert-meta { font-size: 9px; }
    .alert-amount { font-size: 10px; }
    .modal { width: 100vw; max-width: 100vw; border-radius: 16px 16px 0 0; max-height: 90vh; margin-top: auto; }
    .modal-body { padding: 14px; }
    .modal .kv { font-size: 12px; padding: 6px 0; }
    .modal .kl { min-width: 60px; }
    .reasoning { font-size: 11px; padding: 6px 10px; }
    .reasoning.collapsed { max-height: 56px; }
    .tool-badge { font-size: 10px; }
    #drawer { width: 280px; max-width: 85vw; }
    /* Report detail on tablet — full width, reduced padding */
    .msg.rpt-content { max-width: 100%; padding: 24px 18px; font-size: 14px; line-height: 1.75; border-radius: 12px; }
    .msg.rpt-content .markdown h1 { font-size: 20px; margin: 24px 0 10px; }
    .msg.rpt-content .markdown h2 { font-size: 17px; margin: 22px 0 8px; }
    .msg.rpt-content .markdown h3 { font-size: 15px; margin: 18px 0 6px; }
    .msg.rpt-content .markdown th, .msg.rpt-content .markdown td { padding: 7px 10px; }
    .msg.rpt-content .markdown table { font-size: 11px; }
  }

  /* ====== Small phone (max-width: 400px) ====== */
  @media (max-width: 400px) {
    #alerts { max-width: 100vw; }
    #market-panel { max-width: 100vw; }
    .msg { max-width: 98%; font-size: 12px; }
    #chat-box textarea { font-size: 14px; }
    #chat-header h2 { font-size: 13px; }
    .chart-container canvas { height: 160px !important; }
    .msg.rpt-content { padding: 16px 12px; font-size: 13px; line-height: 1.7; }
    .msg.rpt-content .markdown h1 { font-size: 18px; }
    .msg.rpt-content .markdown h2 { font-size: 16px; }
    .msg.rpt-content .markdown th, .msg.rpt-content .markdown td { padding: 5px 8px; }
    .msg.rpt-content .markdown table { font-size: 10px; }
  }

/* ---- Reports tab ---- */
.tab-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.tab-btn:hover { background: var(--surface); color: var(--text); }
.tab-btn.active { background: var(--blue); color: #fff; }

.rpt-nav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 5px;
  font-family: inherit;
}
.rpt-nav-btn:hover { background: var(--hover); }
.rpt-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.rpt-nav-btn:focus {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Generate overview report buttons */
.rpt-gen-btn {
  font-family: inherit;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  white-space: nowrap;
  transition: all .15s;
}
.rpt-gen-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.rpt-gen-daily {
  border: 1px solid rgba(139,92,246,.40);
  color: #c4b5fd;
}
.rpt-gen-daily:hover:not(:disabled) { background: rgba(139,92,246,.12); }
.rpt-gen-weekly {
  border: 1px solid rgba(59,130,246,.40);
  color: #93c5fd;
}
.rpt-gen-weekly:hover:not(:disabled) { background: rgba(59,130,246,.12); }

.rpt-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.rpt-item:hover { background: var(--surface); }
.rpt-item-body { flex: 1; min-width: 0; }
.rpt-item-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
}
.rpt-btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: block;
}
.rpt-del-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 6px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 6px;
  font-family: inherit;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: var(--red);
}
.rpt-del-btn:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.65);
  color: #f87171;
}
.rpt-del-btn:focus-visible {
  outline: 2px solid rgba(239, 68, 68, 0.65);
  outline-offset: 2px;
}
.rpt-del-btn--detail { margin-top: 0; margin-bottom: 0; }
.rpt-detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.rpt-detail-actions-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.rpt-export-pdf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 6px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 6px;
  font-family: inherit;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: var(--blue);
}
.rpt-export-pdf-btn:hover {
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(59, 130, 246, 0.5);
  color: #60a5fa;
}
.rpt-export-pdf-btn:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.55);
  outline-offset: 2px;
}
.rpt-time { font-size: 13px; font-weight: 600; color: var(--text); }
.rpt-subject { font-size: 12px; color: var(--text2); margin-top: 2px; }
.rpt-status { font-size: 10px; display: inline-block; padding: 1px 6px; border-radius: 3px; margin-left: 6px; }
.rpt-status-sent { background: #16653433; color: #4ade80; }
.rpt-status-error { background: #991b1b33; color: #f87171; }
.rpt-status-skipped { background: #713f1233; color: #fbbf24; }

/* Report type pill (list item) */
.rpt-type-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}
.rpt-type-4h { background: #47556933; color: #94a3b8; }
.rpt-type-daily { background: rgba(139,92,246,.15); color: #c4b5fd; }
.rpt-type-weekly { background: rgba(59,130,246,.15); color: #93c5fd; }

.rpt-back-btn {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  padding: 4px 0;
  margin-bottom: 12px;
}
.rpt-back-btn:hover { text-decoration: underline; }

.rpt-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text2);
  font-size: 14px;
}
.rpt-loading {
  text-align: center;
  padding: 40px 16px;
  color: var(--text2);
}

/* Report content — relaxed reading typography, overrides cramped chat bubble styles */
.msg.rpt-content {
  max-width: 900px;
  padding: 40px 48px;
  font-size: 15px;
  line-height: 1.85;
  background: linear-gradient(135deg, rgba(124,58,237,.05) 0%, rgba(30,64,175,.03) 100%);
  border: 1px solid rgba(124,58,237,.10);
  border-radius: 16px;
  align-self: auto;
}
.msg.rpt-content .markdown h1 {
  font-size: 24px; margin: 32px 0 14px; padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08); font-weight: 700;
  letter-spacing: -.3px;
}
.msg.rpt-content .markdown h2 {
  font-size: 20px; margin: 30px 0 12px; font-weight: 650;
  letter-spacing: -.2px;
}
.msg.rpt-content .markdown h3 {
  font-size: 17px; margin: 24px 0 10px; font-weight: 600;
}
.msg.rpt-content .markdown h4 {
  font-size: 15px; margin: 20px 0 8px; font-weight: 600;
  color: var(--text);
}
.msg.rpt-content .markdown p { margin: 0 0 14px; }
.msg.rpt-content .markdown hr { margin: 28px 0; opacity: .15; border: none; border-top: 1px solid var(--border); }
.msg.rpt-content .markdown ul, .msg.rpt-content .markdown ol { margin: 10px 0 18px; padding-left: 24px; }
.msg.rpt-content .markdown li { margin-bottom: 8px; }
.msg.rpt-content .markdown code {
  font-size: 13px;
  background: rgba(139,92,246,.12);
  padding: 2px 7px;
  border-radius: 4px;
}
.msg.rpt-content .markdown pre {
  margin: 18px 0;
  padding: 16px 20px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
  background: rgba(0,0,0,.30);
  border: 1px solid rgba(255,255,255,.04);
}
.msg.rpt-content .markdown blockquote {
  border-left: 3px solid var(--purple);
  padding: 10px 16px;
  margin: 16px 0;
  background: rgba(139,92,246,.06);
  border-radius: 0 8px 8px 0;
  color: var(--text2);
}
.msg.rpt-content .markdown .table-wrap {
  overflow-x: auto;
  margin: 24px 0;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.msg.rpt-content .markdown table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
.msg.rpt-content .markdown th {
  background: linear-gradient(180deg, rgba(139,92,246,.18), rgba(139,92,246,.06));
  color: #c4b5fd;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 2px solid rgba(139,92,246,.25);
  white-space: nowrap;
}
.msg.rpt-content .markdown th, .msg.rpt-content .markdown td {
  padding: 11px 16px;
  text-align: left;
}
.msg.rpt-content .markdown td {
  border-bottom: 1px solid rgba(255,255,255,.06);
  color: var(--text2);
}
.msg.rpt-content .markdown tr:last-child td { border-bottom: none; }
.msg.rpt-content .markdown tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.msg.rpt-content .markdown tr:hover td { background: rgba(139,92,246,.05); color: var(--text); }
.msg.rpt-content .markdown td:first-child { color: var(--text); font-weight: 500; }
.msg.rpt-content .markdown strong { font-weight: 600; color: var(--text); }
.msg.rpt-content .markdown img { max-width: 100%; border-radius: 8px; }

/* ---- Market panel (right side) ---- */
#market-panel {
  width: 348px; min-width: 290px;
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  background: radial-gradient(ellipse at 100% 0%, rgba(139,92,246,.03) 0%, transparent 60%),
              var(--bg);
  overflow-y: auto; overflow-x: hidden;
}
#market-header {
  padding: 12px 14px 10px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(255,255,255,.01);
}
#market-tabs {
  display: flex; gap: 4px;
}
.mkt-tab {
  background: none; border: 1px solid transparent; color: var(--text2);
  font-family: inherit; font-size: 11px; font-weight: 600;
  padding: 5px 12px; border-radius: 6px; cursor: pointer;
  transition: all .18s ease;
  letter-spacing: .3px;
}
.mkt-tab:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.mkt-tab.active {
  background: rgba(59,130,246,.12); color: var(--blue);
  border-color: rgba(59,130,246,.3);
}

/* Connection breathing light */
.conn-light {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0; position: relative;
}
.conn-light::after {
  content: ''; position: absolute; inset: -2px;
  border-radius: 50%; opacity: .3;
}
.conn-light.conn-green {
  background: var(--green);
  box-shadow: 0 0 8px rgba(34,197,94,.5);
  animation: conn-breathe 1.6s ease-in-out infinite;
}
.conn-light.conn-yellow {
  background: var(--orange);
  box-shadow: 0 0 8px rgba(245,158,11,.5);
  animation: conn-breathe .7s ease-in-out infinite;
}
.conn-light.conn-red {
  background: var(--red);
  box-shadow: 0 0 8px rgba(239,68,68,.5);
}
@keyframes conn-breathe {
  0%, 100% { opacity: 0.5; transform: scale(0.82); }
  50% { opacity: 1; transform: scale(1.08); }
}

/* Price display */
#market-price {
  padding: 12px 14px 6px;
  display: flex; align-items: baseline; gap: 10px;
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.015) 0%, transparent 100%);
}
#mkt-price {
  font-size: 24px; font-weight: 800; color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.5px;
}
#mkt-price.tick-up {
  animation: price-flash-up .45s ease-out;
}
#mkt-price.tick-down {
  animation: price-flash-down .45s ease-out;
}
@keyframes price-flash-up {
  0% { color: var(--green); transform: scale(1.04); }
  100% { color: var(--text); transform: scale(1); }
}
@keyframes price-flash-down {
  0% { color: var(--red); transform: scale(.96); }
  100% { color: var(--text); transform: scale(1); }
}
#mkt-change {
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px; border-radius: 4px;
}
#mkt-change.up { color: var(--green); background: rgba(34,197,94,.08); }
#mkt-change.down { color: var(--red); background: rgba(239,68,68,.08); }

/* Kline chart */
#market-chart-wrap {
  height: 270px; margin: 6px 14px 10px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(20,22,33,.95), rgba(14,16,24,.98));
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.02),
              0 2px 12px rgba(0,0,0,.25);
  overflow: hidden; padding: 8px 6px 4px;
  flex-shrink: 0;
  position: relative;
}
#mkt-chart-canvas { width: 100%; height: 100%; }
.mkt-skeleton-chart {
  position: absolute; inset: 0;
  border-radius: 12px;
  animation: mkt-skeleton 1.2s ease-in-out infinite;
  z-index: 2;
}
.mkt-chart-error {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text2);
  z-index: 2;
}
.mkt-chart-loading #mkt-chart-canvas { visibility: hidden; }

/* Section cards */
.mkt-section-card {
  margin: 0 14px 8px;
  padding: 10px 12px;
  background: rgba(255,255,255,.015);
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 10px;
  flex-shrink: 0;
}
.mkt-section-title {
  font-size: 9px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: .8px;
  margin-bottom: 6px;
}
.mkt-section-hint { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: .7; }

/* OI table */
#mkt-oi-table {
  width: 100%; border-collapse: collapse;
  font-size: 10px;
}
#mkt-oi-table thead th {
  color: var(--text2); font-weight: 600; font-size: 9px;
  padding: 4px 6px 5px; text-align: center;
  border-bottom: 1px solid rgba(255,255,255,.06);
  letter-spacing: .3px;
}
#mkt-oi-table thead th:first-child { text-align: left; }
#mkt-oi-table td {
  color: var(--text); padding: 5px 6px; text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
#mkt-oi-table .mkt-oi-label {
  text-align: left; color: var(--text2); font-weight: 400;
  font-size: 10px;
}
.mkt-oi-row:nth-child(odd) td { background: rgba(255,255,255,.01); }
.mkt-z-row td { color: var(--text2); font-size: 9px; font-weight: 400; padding-top: 2px; padding-bottom: 2px; }
.mkt-z-row td.z-hot { color: #4ade80; }
.mkt-z-row td.z-cold { color: #f87171; }

/* Fear & Greed */
#fng-main {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 6px;
}
#fng-value {
  font-size: 30px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: color .5s ease;
}
#fng-label {
  font-size: 11px; font-weight: 500; color: var(--text2);
  letter-spacing: .2px;
}
#fng-bar {
  height: 5px;
  background: rgba(255,255,255,.05);
  border-radius: 3px;
  overflow: hidden;
}
#fng-fill {
  height: 100%; border-radius: 3px;
  transition: width .6s ease, background .6s ease;
}

/* F&G history bars */
#fng-history {
  display: flex; align-items: flex-end; gap: 2px;
  height: 36px; margin-top: 8px;
}
.fng-history-bar {
  flex: 1; min-width: 2px; border-radius: 1px 1px 0 0;
  transition: height .4s ease, opacity .3s;
  cursor: default;
}
.fng-history-bar:hover { opacity: .85; }

/* F&G tooltip */
.fng-tooltip {
  position: fixed; z-index: 10000;
  pointer-events: none; opacity: 0;
  background: rgba(15,17,23,.96);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px; padding: 8px 12px;
  min-width: 100px; text-align: center;
  transition: opacity .12s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
}
.fng-tooltip.show { opacity: 1; }

.mkt-loading { color: var(--text2); font-size: 11px; padding: 12px 0; text-align: center; }

/* ---- Exchange netflow ---- */
.netflow-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0; font-size: 11px;
}
.netflow-label {
  font-weight: 600; color: var(--text);
  min-width: 68px;
}
.netflow-values {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.netflow-values .nf-in { color: var(--green); }
.netflow-values .nf-out { color: var(--red); }
.netflow-values .nf-net { font-weight: 600; }
.netflow-values .nf-net.pos { color: var(--green); }
.netflow-values .nf-net.neg { color: var(--red); }
.netflow-values .nf-empty { color: var(--text2); }

/* ---- Top alerts ---- */
#top-alerts-list { max-height: 160px; overflow-y: auto; }
.ta-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 0; font-size: 11px; border-bottom: 1px solid rgba(255,255,255,.03);
  cursor: pointer; transition: background .1s;
}
.ta-item:hover { background: rgba(255,255,255,.02); }
.ta-sev {
  font-size: 8px; font-weight: 700; padding: 1px 5px; border-radius: 3px;
  white-space: nowrap; min-width: 22px; text-align: center;
}
.ta-token { font-weight: 600; color: var(--text); min-width: 42px; }
.ta-dir { font-size: 10px; min-width: 28px; }
.ta-dir.in { color: var(--green); }
.ta-dir.out { color: var(--red); }
.ta-amount { font-variant-numeric: tabular-nums; text-align: right; flex:1; }
.ta-empty { text-align: center; padding: 16px; color: var(--text2); font-size: 11px; }

/* ---- Meta row (gas + btc.d) ---- */
.mkt-meta-row {
  display: flex; gap: 12px;
}
.mkt-meta-item {
  flex: 1;
  text-align: center;
}
.mkt-meta-item .mkt-section-title { margin-bottom: 4px; }
.mkt-meta-item .mkt-meta-val {
  font-size: 16px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.mkt-meta-item .mkt-meta-sub {
  font-size: 10px; color: var(--text2); margin-top: 2px;
}

/* Skeleton pulse for loading states */
@keyframes mkt-skeleton {
  0%, 100% { opacity: .3; }
  50% { opacity: .6; }
}
.mkt-skeleton {
  background: var(--border);
  border-radius: 4px;
  animation: mkt-skeleton 1.2s ease-in-out infinite;
}
.mkt-skeleton-text {
  height: 10px; margin: 4px 0;
}
.mkt-skeleton-cell {
  height: 12px; width: 70%; margin: 2px auto;
}
#mkt-price.loading, #mkt-change.loading {
  color: transparent;
  background: var(--border);
  border-radius: 4px;
  animation: mkt-skeleton 1.2s ease-in-out infinite;
}
#mkt-price.loading { width: 120px; }
#mkt-change.loading { width: 50px; }

/* Market panel responsive */
@media (max-width: 1200px) {
  #market-panel { width: 280px; min-width: 240px; }
  #mkt-price { font-size: 18px; }
  #market-chart-wrap { height: 200px; }
}

/* Market panel backdrop (mobile) */
#market-backdrop { display: none; }
#market-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 149; }

@media (max-width: 768px) {
  #market-panel {
    position: fixed; top: 0; right: -100vw; width: 100vw; max-width: 380px; height: 100vh;
    z-index: 150; transition: right .3s ease; box-shadow: -4px 0 24px rgba(0,0,0,.5);
    background: var(--bg); border-left: 1px solid var(--border);
  }
  #market-panel.open { right: 0; }
  #mobile-market-close { display: block; position: absolute; right: 12px; top: 12px; z-index: 2; }
  #market-header { padding-right: 36px; position: relative; }
}

/* ---- Bot tab ---- */
.bot-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  min-width: 110px;
  flex: 1;
}
.bot-stat-label { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.bot-stat-value { font-size: 18px; font-weight: 700; color: var(--text); }
.bot-stat-value.up { color: var(--green); }
.bot-stat-value.down { color: var(--red); }
.bot-signal-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; background: var(--surface); border-radius: 8px;
  margin-bottom: 6px; font-size: 13px;
}
.bot-signal-dir { font-weight: 700; padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.bot-signal-dir.long { background: #16653440; color: var(--green); }
.bot-signal-dir.short { background: #991b1b40; color: var(--red); }
.bot-trade-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; background: var(--surface); border-radius: 8px;
  margin-bottom: 4px; font-size: 12px; font-family: monospace;
}
.bot-empty { text-align: center; padding: 32px; color: var(--text2); font-size: 13px; }

/* ---- News tab ---- */
.news-ch-btn {
  font-size: 11px; padding: 2px 10px; border-radius: 12px; border: 1px solid var(--border);
  background: transparent; color: var(--text2); cursor: pointer; font-family: inherit;
}
.news-ch-btn.active, .news-ch-btn:hover { background: var(--blue); color: #fff; border-color: var(--blue); }
.news-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 10px;
  background: var(--surface); transition: border-color .15s;
}
.news-card:hover { border-color: rgba(255,255,255,.08); }
.news-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.news-channel-badge { font-size: 11px; padding: 2px 8px; border-radius: 12px; background: var(--blue); color: #fff; }
.news-card-time { font-size: 11px; color: var(--text2); }
.news-card-content { font-size: 13px; line-height: 1.65; color: var(--text); word-break: break-word; }
.news-card-content.truncated { max-height: 130px; overflow: hidden; position: relative; }
.news-card-content.truncated::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 40px;
  background: linear-gradient(transparent, var(--surface));
}
.news-card-expand {
  font-size: 11px; color: var(--blue); cursor: pointer; margin-top: 4px; background: none; border: none;
  padding: 0; font-family: inherit;
}
.news-card-media { margin-top: 8px; font-size: 11px; color: var(--text2); }
.news-card-footer { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.news-card-stat { font-size: 11px; color: var(--text2); }
