@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface2: #21262d;
    --border: #30363d;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #58a6ff;
    --green: #3fb950;
    --orange: #d29922;
    --red: #f85149;
    --purple: #bc8cff;
    --pink: #f778ba;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 24px;
  }

  /* ── Header ── */
  .header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
  }
  .logo { font-size: 22px; font-weight: 700; color: var(--accent); letter-spacing: -0.5px; }
  .logo span { color: var(--text); }
  .subtitle { font-size: 13px; color: var(--muted); }
  .header-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

  /* ── Stats row ── */
  .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
  .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
  }
  .stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
  .stat-value { font-size: 28px; font-weight: 700; color: var(--text); margin-top: 4px; }
  .stat-value.green { color: var(--green); }
  .stat-value.blue { color: var(--accent); }
  .stat-value.purple { color: var(--purple); }

  /* ── Controls ── */
  .controls {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
  }
  .search-wrap { position: relative; flex: 1; min-width: 200px; }
  .search-wrap input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 9px 14px 9px 36px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
  }
  .search-wrap input:focus { border-color: var(--accent); }
  .search-wrap .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; }
  .filter-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 9px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
  }
  .filter-btn:hover, .filter-btn.active { border-color: var(--accent); color: var(--accent); }
  .btn-refresh {
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: #fff;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
  }
  .btn-refresh:hover { opacity: 0.85; }

  /* ── Table ── */
  .table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
  }
  table { width: 100%; border-collapse: collapse; }
  thead { background: var(--surface2); }
  thead th {
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    white-space: nowrap;
  }
  tbody tr {
    border-top: 1px solid var(--border);
    transition: background 0.1s;
  }
  tbody tr:hover { background: var(--surface2); }
  tbody td { padding: 11px 16px; font-size: 13px; vertical-align: top; }

  /* Badges */
  .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
  }
  .badge-human { background: #1f6feb30; color: var(--accent); }
  .badge-ai { background: #3fb95030; color: var(--green); }
  .badge-stage { background: #bc8cff20; color: var(--purple); font-family: 'JetBrains Mono', monospace; }

  .conv-id {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--muted);
    cursor: pointer;
  }
  .conv-id:hover { color: var(--accent); }

  .msg-text {
    max-width: 480px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
  }
  .msg-text.expanded { white-space: normal; }

  .product-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--orange);
  }

  .ts { font-size: 11px; color: var(--muted); white-space: nowrap; }

  /* ── Modal ── */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: flex-start;
    padding: 60px 20px;
  }
  .modal-overlay.show { display: flex; }
  .modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 100%;
    max-width: 700px;
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
  }
  .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
  .modal-title { font-size: 15px; font-weight: 600; }
  .modal-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; }
  .modal-close:hover { color: var(--text); }
  .modal-body pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--green);
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.6;
  }

  /* empty + loading */
  .empty-state {
    text-align: center;
    padding: 60px;
    color: var(--muted);
  }
  .empty-state .icon { font-size: 40px; margin-bottom: 12px; }
  .spin { animation: spin 1s linear infinite; display: inline-block; }
  @keyframes spin { to { transform: rotate(360deg); } }