:root {
      --bg: #0d1117;
      --surface: #161b22;
      --surface2: #21262d;
      --border: #30363d;
      --text: #e6edf3;
      --text-muted: #8b949e;
      --green: #3fb950;
      --red: #f85149;
      --yellow: #d29922;
      --blue: #58a6ff;
      --purple: #bc8cff;
      --our-brand: #2ea043;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: 'Inter', sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
    }

    /* HEADER */
    header {
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      position: sticky;
      top: 0;
      z-index: 100;
    }
    .header-inner {
      max-width: 1200px;
      margin: 0 auto;
      padding: 16px 16px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .logo { display: flex; align-items: center; gap: 12px; }
    .logo-dot {
      width: 10px; height: 10px; border-radius: 50%;
      background: var(--green);
      box-shadow: 0 0 8px var(--green);
      animation: pulse 2s infinite;
    }
    @keyframes pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.4; }
    }
    .logo h1 { font-size: 16px; font-weight: 600; }
    .logo p { font-size: 12px; color: var(--text-muted); }
    .actions { display: flex; align-items: center; gap: 16px; }
    .last-update { font-size: 12px; color: var(--text-muted); text-align: right; display: flex; flex-direction: column; align-items: flex-end;}
    .last-update strong { color: var(--blue); }

    /* MAIN */
    main { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }

    /* SUMMARY CARDS */
    .summary-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
      gap: 12px;
      margin-bottom: 28px;
    }
    .card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 16px;
      transition: border-color 0.2s, transform 0.2s;
    }
    .card:hover { border-color: var(--blue); transform: translateY(-2px); }
    .card.our-brand {
      border-color: var(--our-brand);
      background: linear-gradient(135deg, #0d2b1a, #161b22);
    }
    .card-name { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .card-count { font-size: 28px; font-weight: 700; color: var(--text); }
    .card-trend {
      font-size: 12px;
      margin-top: 6px;
      font-weight: 500;
    }
    .trend-up { color: var(--green); }
    .trend-down { color: var(--red); }
    .trend-same { color: var(--text-muted); }
    .card-label { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

    /* CHART */
    .section { margin-bottom: 28px; }
    .section-title {
      font-size: 14px;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-bottom: 14px;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .section-title::after {
      content: '';
      flex: 1;
      height: 1px;
      background: var(--border);
    }
    .chart-wrap {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 20px;
    }
    .chart-inner {
      position: relative;
      height: 350px;
      width: 100%;
    }

    /* HISTORY TABLE */
    .table-wrap {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      overflow: hidden;
    }
    table { width: 100%; border-collapse: collapse; font-size: 13px; }
    thead { background: var(--surface2); }
    th {
      padding: 10px 14px;
      text-align: left;
      color: var(--text-muted);
      font-weight: 500;
      font-size: 12px;
      white-space: nowrap;
    }
    td {
      padding: 10px 14px;
      border-top: 1px solid var(--border);
      white-space: nowrap;
    }
    tr:hover td { background: var(--surface2); }
    .badge {
      display: inline-block;
      padding: 2px 8px;
      border-radius: 20px;
      font-size: 11px;
      font-weight: 600;
    }
    .badge-up { background: #1a3a1f; color: var(--green); }
    .badge-down { background: #3a1a1a; color: var(--red); }
    .badge-same { background: var(--surface2); color: var(--text-muted); }

    /* TOP ADS */
    .top-ads-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
      gap: 12px;
    }
    .top-ads-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 16px;
    }
    .top-ads-card h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
    .ad-item {
      padding: 8px 0;
      border-top: 1px solid var(--border);
      font-size: 12px;
    }
    .ad-item a { color: var(--blue); text-decoration: none; }
    .ad-item a:hover { text-decoration: underline; }
    .ad-meta { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
    .score-badge {
      display: inline-block;
      background: var(--surface2);
      color: var(--yellow);
      padding: 1px 6px;
      border-radius: 4px;
      font-size: 10px;
      font-weight: 600;
    }

    /* LOADING */
    .loading {
      text-align: center;
      padding: 80px 20px;
      color: var(--text-muted);
    }
    .spinner {
      width: 40px; height: 40px;
      border: 3px solid var(--border);
      border-top-color: var(--blue);
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
      margin: 0 auto 16px;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    /* EMPTY */
    .empty-state {
      text-align: center;
      padding: 60px 20px;
      color: var(--text-muted);
    }
    .empty-state h2 { font-size: 18px; margin-bottom: 8px; color: var(--text); }

    /* DIFF STATS */
    .diff-bar {
      display: flex;
      gap: 16px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 16px 20px;
      margin-bottom: 28px;
    }
    .diff-stat { display: flex; flex-direction: column; gap: 2px; }
    .diff-stat .val { font-size: 22px; font-weight: 700; }
    .diff-stat .lbl { font-size: 11px; color: var(--text-muted); }
    .diff-divider { width: 1px; background: var(--border); }

    @media (max-width: 600px) {
      .summary-grid { grid-template-columns: repeat(2, 1fr); }
      .top-ads-grid { grid-template-columns: 1fr; }
      .diff-bar { flex-wrap: wrap; }
      
      .header-inner {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px 16px;
        gap: 12px;
      }
      .actions {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
      }
      .btn-scan {
        width: 100%;
        justify-content: center;
      }
      
      .table-wrap {
        overflow-x: auto;
      }
      
      .chart-wrap {
        overflow-x: auto;
        padding: 5px;
      }
      .chart-inner {
        position: relative;
        height: 250px;
        min-width: 600px; /* forces horizontal scroll */
        padding-right: 15px; /* breathability */
      }
    }

    /* NOILE BUTOANE */
    .btn-scan {
      background: var(--our-brand);
      color: white;
      border: none;
      padding: 8px 16px;
      border-radius: 6px;
      font-weight: 600;
      font-size: 13px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      transition: opacity 0.2s;
    }
    .btn-scan:hover { opacity: 0.8; }
    .btn-scan:disabled { opacity: 0.5; cursor: not-allowed; }
    .dl-btn {
      color: var(--blue);
      text-decoration: none;
      font-size: 16px;
      cursor: pointer;
    }
    .dl-btn:hover { opacity: 0.7; }

    @keyframes pulse-btn {
      0% { opacity: 1; border-color: transparent; box-shadow: 0 0 0px var(--our-brand); }
      50% { opacity: 0.8; box-shadow: 0 0 10px var(--our-brand); }
      100% { opacity: 1; box-shadow: 0 0 0px var(--our-brand); }
    }
    .btn-scanning {
      animation: pulse-btn 2s infinite;
      cursor: wait !important;
      background: var(--surface) !important;
      color: var(--our-brand) !important;
      border: 1px solid var(--our-brand) !important;
    }
    
    /* MODAL */
    .modal-overlay {
      display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
      background: rgba(0,0,0,0.8); z-index: 1000; justify-content: center; align-items: center;
      padding: 16px;
    }
    .modal-content {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: 12px; width: 100%; max-width: 900px; max-height: 90vh;
      display: flex; flex-direction: column;
    }
    .modal-header {
      padding: 16px 20px; border-bottom: 1px solid var(--border);
      display: flex; justify-content: space-between; align-items: center;
    }
    .modal-body {
      padding: 16px 20px; overflow-y: auto; flex: 1;
    }
    .btn-close {
      background: none; border: none; color: white; cursor: pointer; font-size: 20px;
    }
    
    /* DATA BADGES */
    .metric-bar { font-size: 11px; padding: 6px; background: var(--bg); border-radius: 6px; margin: 8px 0; color: var(--text-muted); }
    .keyword-pill { background: #21262d; border-radius: 12px; padding: 2px 8px; font-size: 11px; border: 1px solid #30363d; display: inline-block; margin: 2px; }
    .btn-expand { 
        background: transparent; color: var(--our-brand); border: 1px dotted var(--our-brand); 
        padding: 6px 12px; border-radius: 6px; cursor: pointer; width: 100%; margin-top: 10px; transition: 0.2s;
    }
    .btn-expand:hover { background: var(--our-brand); color: white; }
    
    .alert-box {
        background: rgba(46, 160, 67, 0.1);
        border: 1px solid var(--green);
        color: #e6edf3;
        padding: 12px;
        border-radius: 8px;
        margin-top: 16px;
        display: none;
        font-size: 14px;
    }

    /* MODAL FILTERS */
    .modal-filters {
      display: flex;
      gap: 8px;
      padding: 12px 20px;
      border-bottom: 1px solid var(--border);
      flex-wrap: wrap;
      background: var(--surface2);
    }
    .filter-btn {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text-muted);
      padding: 5px 13px;
      border-radius: 20px;
      font-size: 12px;
      font-family: 'Inter', sans-serif;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.15s;
      white-space: nowrap;
    }
    .filter-btn:hover {
      border-color: var(--blue);
      color: var(--text);
    }
    .filter-btn.active {
      background: var(--blue);
      border-color: var(--blue);
      color: white;
    }
    .filter-btn.active-red {
      background: var(--red);
      border-color: var(--red);
      color: white;
    }
    .modal-results-count {
      font-size: 11px;
      color: var(--text-muted);
      padding: 8px 20px 0;
    }
