  :root {
    --bg:       #0F1117;
    --surface:  #161B27;
    --surface2: #1E2535;
    --border:   #2A3347;
    --accent:   #00D4FF;
    --accent2:  #7B61FF;
    --green:    #00E676;
    --yellow:   #FFD740;
    --red:      #FF5252;
    --text:     #E8EAF0;
    --muted:    #6B7A99;
    --radius:   10px;
  }

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

  html, body {
    height: 100vh;
    overflow: hidden;
  }
  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    display: flex;
    flex-direction: column;
  }

  /* HEADER */
  header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
  }
  .logo span { color: var(--accent); }
  .logo-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
  }
  .header-meta {
    display: flex; align-items: center; gap: 16px;
  }
  #api-status {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--muted);
  }
  .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
  .dot.ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
  .dot.err { background: var(--red); }

  /* LAYOUT */
  .app {
    display: grid;
    grid-template-columns: 300px 1fr;
    flex: 1;
    min-height: 0;
  }

  /* SIDEBAR */
  aside {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
  }
  .section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
  }
  .field { display: flex; flex-direction: column; gap: 6px; }
  .field label { font-size: 12px; color: var(--muted); font-weight: 500; }
  .field input, .field select {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    transition: border-color .2s;
    width: 100%;
  }
  .field input:focus, .field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,212,255,.08);
  }
  .field input::placeholder { color: var(--muted); }

  .api-key-wrap {
    position: relative;
  }
  .api-key-wrap input { padding-right: 36px; font-family: 'JetBrains Mono', monospace; font-size: 11px; }
  .toggle-key {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--muted); cursor: pointer;
    font-size: 14px; padding: 2px;
  }
  .toggle-key:hover { color: var(--text); }

  .radius-row {
    display: flex; gap: 8px; align-items: center;
  }
  .radius-row input[type=range] {
    flex: 1; accent-color: var(--accent);
    padding: 0; border: none; background: none;
    cursor: pointer;
  }
  .radius-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px; color: var(--accent);
    min-width: 42px; text-align: right;
  }

  .btn-search {
    background: linear-gradient(135deg, var(--accent), #0099BB);
    color: #000;
    border: none;
    padding: 12px;
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: opacity .2s, transform .1s;
    letter-spacing: 0.3px;
  }
  .btn-search:hover { opacity: .9; }
  .btn-search:active { transform: scale(.98); }
  .btn-search:disabled { opacity: .4; cursor: not-allowed; transform: none; }

  .divider { height: 1px; background: var(--border); }

  /* Stats sidebar */
  .stats-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  }
  .stat-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
  }
  .stat-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 20px; font-weight: 600;
    color: var(--accent);
  }
  .stat-lbl { font-size: 10px; color: var(--muted); margin-top: 2px; }

  /* MAIN */
  main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
  }
  .toolbar-left { display: flex; align-items: center; gap: 10px; }
  .result-count {
    font-size: 13px; color: var(--muted);
  }
  .result-count b { color: var(--text); }

  .filter-chips { display: flex; gap: 6px; }
  .chip {
    padding: 4px 10px; border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface2);
    font-size: 11px; cursor: pointer;
    transition: all .15s;
    color: var(--muted);
  }
  .chip.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(0,212,255,.08);
  }

  .toolbar-right { display: flex; gap: 8px; }
  .btn-icon {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 7px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 12px;
    display: flex; align-items: center; gap: 6px;
    transition: all .15s;
    font-family: 'Inter', sans-serif;
  }
  .btn-icon:hover { border-color: var(--accent); color: var(--accent); }

  /* RESULTS */
  .results-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
  }

  /* EMPTY / LOADING STATE */
  .state-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; gap: 16px; color: var(--muted);
    text-align: center; padding: 40px;
  }
  .state-empty .big-icon { font-size: 48px; opacity: .3; }
  .state-empty h3 { font-size: 16px; color: var(--text); font-weight: 600; }
  .state-empty p { font-size: 13px; line-height: 1.6; max-width: 360px; }

  /* PROGRESS */
  .progress-wrap {
    display: none;
    flex-direction: column; gap: 8px;
    padding: 20px 24px;
  }
  .progress-wrap.active { display: flex; }
  .progress-bar-bg {
    height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden;
  }
  .progress-bar-fill {
    height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 2px;
    transition: width .3s ease;
    width: 0%;
  }
  .progress-text { font-size: 12px; color: var(--muted); }

  /* CARDS GRID */
  .leads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 14px;
  }

  .lead-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
    transition: border-color .2s, transform .15s;
    position: relative;
    overflow: hidden;
  }
  .lead-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
  }
  .lead-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
  }
  .lead-card.score-high::before { background: var(--green); }
  .lead-card.score-mid::before { background: var(--yellow); }
  .lead-card.score-low::before { background: var(--red); }

  .card-header {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  }
  .card-name {
    font-weight: 600; font-size: 14px; line-height: 1.3;
    flex: 1;
  }
  .card-category {
    font-size: 10px; color: var(--muted); margin-top: 3px;
    text-transform: uppercase; letter-spacing: 0.8px;
  }

  /* Score gauge */
  .score-gauge {
    flex-shrink: 0;
    width: 52px; height: 52px;
    position: relative;
  }
  .score-gauge svg { transform: rotate(-90deg); }
  .score-gauge .track { fill: none; stroke: var(--surface2); stroke-width: 5; }
  .score-gauge .fill {
    fill: none; stroke-width: 5;
    stroke-linecap: round;
    transition: stroke-dasharray .6s ease;
  }
  .score-num {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px; font-weight: 600;
  }

  .card-meta {
    display: flex; flex-direction: column; gap: 5px;
  }
  .meta-row {
    display: flex; align-items: center; gap: 7px;
    font-size: 12px; color: var(--muted);
  }
  .meta-row .icon { font-size: 13px; width: 16px; text-align: center; }
  .meta-row a { color: var(--muted); text-decoration: none; }
  .meta-row a:hover { color: var(--accent); }

  /* Badges */
  .badges { display: flex; flex-wrap: wrap; gap: 5px; }
  .badge {
    padding: 3px 8px; border-radius: 4px;
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.5px; text-transform: uppercase;
  }
  .badge.no-site { background: rgba(255,82,82,.12); color: var(--red); border: 1px solid rgba(255,82,82,.25); }
  .badge.slow { background: rgba(255,215,64,.1); color: var(--yellow); border: 1px solid rgba(255,215,64,.25); }
  .badge.old-site { background: rgba(123,97,255,.12); color: #9C85FF; border: 1px solid rgba(123,97,255,.25); }
  .badge.no-mobile { background: rgba(255,152,0,.12); color: #FFA040; border: 1px solid rgba(255,152,0,.25); }
  .badge.social-only { background: rgba(255,82,82,.12); color: #FF7070; border: 1px solid rgba(255,82,82,.25); }
  .badge.low-reviews { background: rgba(107,122,153,.12); color: var(--muted); border: 1px solid var(--border); }
  .badge.ok-site { background: rgba(0,230,118,.08); color: var(--green); border: 1px solid rgba(0,230,118,.2); }
  .badge.gdpr-issue { background: rgba(255,152,0,.15); color: #FF9800; border: 1px solid rgba(255,152,0,.35); font-weight:700; }

  /* Cuoricino preferiti */
  .fav-btn {
    position: absolute; top: 10px; right: 10px;
    background: none; border: none;
    font-size: 18px; cursor: pointer;
    opacity: .4; transition: all .15s;
    line-height: 1; padding: 2px;
    z-index: 2;
  }
  .fav-btn:hover { opacity: 1; transform: scale(1.2); }
  .fav-btn.active { opacity: 1; }

  .card-actions {
    display: flex; gap: 7px; margin-top: 4px;
  }
  .btn-action {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--muted);
    font-size: 11px; font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all .15s;
    display: flex; align-items: center; justify-content: center; gap: 5px;
    font-family: 'Inter', sans-serif;
    text-decoration: none;
  }
  .btn-action:hover { border-color: var(--accent); color: var(--accent); }
  .btn-action.primary {
    background: rgba(0,212,255,.08);
    border-color: rgba(0,212,255,.3);
    color: var(--accent);
  }
  .btn-action.primary:hover { background: rgba(0,212,255,.15); }

  /* Stars rating */
  .stars { color: var(--yellow); font-size: 11px; letter-spacing: 1px; }

  /* PAGE SPEED inline */
  .ps-bar-wrap { display: flex; align-items: center; gap: 8px; flex: 1; }
  .ps-bar-bg { flex: 1; height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; }
  .ps-bar-fill { height: 100%; border-radius: 2px; transition: width .5s; }

  /* MODAL */
  .modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 200;
    align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    max-width: 520px; width: 90%;
    max-height: 80vh; overflow-y: auto;
  }
  .modal h2 { font-size: 18px; margin-bottom: 4px; }
  .modal .modal-sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
  .modal-close {
    float: right; background: none; border: none;
    color: var(--muted); cursor: pointer; font-size: 20px;
    margin-top: -4px;
  }
  .modal-close:hover { color: var(--text); }

  .email-box {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    color: var(--text);
    min-height: 200px;
  }
  .email-loading {
    display: flex; align-items: center; gap: 10px;
    color: var(--muted); font-size: 13px; padding: 20px 0;
  }
  .spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .btn-copy {
    margin-top: 12px; width: 100%;
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); padding: 10px;
    border-radius: var(--radius); cursor: pointer;
    font-family: 'Inter', sans-serif; font-size: 13px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all .15s;
  }
  .btn-copy:hover { border-color: var(--accent); color: var(--accent); }

  /* GDPR Modal rows */
  .gdpr-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--surface2);
    margin-bottom: 8px;
    font-size: 13px;
  }
  .gdpr-row .gdpr-label { color: var(--muted); }
  .gdpr-row .gdpr-val { font-weight: 600; }
  .gdpr-row .gdpr-val.ok  { color: var(--green); }
  .gdpr-row .gdpr-val.err { color: var(--red); }
  .gdpr-issues {
    margin-top: 14px;
    padding: 12px 14px;
    background: rgba(255,82,82,.08);
    border: 1px solid rgba(255,82,82,.2);
    border-radius: 8px;
    font-size: 12px;
    color: var(--red);
    line-height: 1.8;
  }
  .gdpr-ok-box {
    margin-top: 14px;
    padding: 12px 14px;
    background: rgba(0,230,118,.08);
    border: 1px solid rgba(0,230,118,.2);
    border-radius: 8px;
    font-size: 12px;
    color: var(--green);
  }

  /* Toast */
  .toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 12px 18px;
    font-size: 13px;
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
    z-index: 300;
    transform: translateY(80px); opacity: 0;
    transition: all .3s ease;
  }
  .toast.show { transform: translateY(0); opacity: 1; }

  /* Tabella Scraping */
  #scrape-table tr { border-bottom: 1px solid var(--border); transition: background .1s; }
  #scrape-table tr:hover { background: var(--surface2); }
  #scrape-table td { padding: 9px 12px; vertical-align: middle; }
  .scrape-status {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600;
  }
  .scrape-status.found     { background: rgba(0,230,118,.1);  color: var(--green); }
  .scrape-status.not_found { background: rgba(107,122,153,.1); color: var(--muted); }
  .scrape-status.offline   { background: rgba(255,82,82,.1);  color: var(--red); }
  .scrape-status.cached    { background: rgba(123,97,255,.1); color: #9C85FF; }
  .scrape-status.scanning  { background: rgba(0,212,255,.1);  color: var(--accent); }

  /* Tab Navigation */
  .header-nav {
    display: flex; gap: 4px;
    background: var(--surface2);
    border-radius: 8px;
    padding: 3px;
    overflow-x: auto;
    flex-shrink: 1;
    min-width: 0;
    scrollbar-width: none;
  }
  .header-nav::-webkit-scrollbar { display: none; }
  .tab-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all .15s;
  }
  .tab-btn.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
  }
  .tab-btn:hover:not(.active) { color: var(--text); }

  /* Pannello Excel */
  .excel-panel {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }
  .excel-panel.active { display: flex; }
  .agency-panel-layout { flex-direction: row !important; }
  .lead-card.contacted {
    border-color: var(--green) !important;
    opacity: .75;
  }
  .lead-card.contacted::before { background: var(--green) !important; }
  .maps-panel {
    display: grid;
    grid-template-columns: 300px 1fr;
    flex: 1;
    min-height: 0;
    width: 100%;
  }
  .maps-panel.hidden { display: none; }

  /* Drop zone */
  .drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    margin: 24px;
  }
  .drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(0,212,255,.04);
  }
  .drop-zone .dz-icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
  .drop-zone h3 { font-size: 16px; margin-bottom: 8px; }
  .drop-zone p { color: var(--muted); font-size: 13px; }
  .drop-zone input[type=file] { display: none; }

  /* Tabella preview Excel */
  .excel-main {
    flex: 1; display: flex; flex-direction: column; overflow: hidden;
  }
  .excel-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px; border-bottom: 1px solid var(--border);
    flex-wrap: wrap; gap: 10px;
  }
  .excel-results {
    flex: 1; overflow-y: auto; padding: 20px 24px;
  }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--muted); }

  /* Outreach checklist */
  #outreach-checklist {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  .outreach-check-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border-radius: 6px;
    cursor: pointer; transition: background .1s;
    font-size: 12px;
  }
  .outreach-check-row:hover { background: var(--surface2); }
  .outreach-check-row input[type=checkbox] { accent-color: var(--accent); flex-shrink:0; cursor:pointer; }
  .outreach-check-row .ocr-name { color: var(--text); font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .outreach-check-row .ocr-site { color: var(--muted); font-size:10px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

