/* ============================================================
   FormSignal — Application Stylesheet  (Light Mode)
   ============================================================ */

/* ── Tokens ──────────────────────────────────────────────────── */
:root {
  --bg:           #F8FAFC;
  --surface:      #FFFFFF;
  --surface-2:    #F1F5F9;
  --border:       #E2E8F0;
  --border-2:     #CBD5E1;
  --ink:          #1E293B;
  --ink-2:        #475569;
  --ink-3:        #94A3B8;
  --blue:         #2563EB;
  --blue-lt:      #EFF6FF;
  --green:        #16A34A;
  --green-lt:     #F0FDF4;
  --red:          #DC2626;
  --red-lt:       #FEF2F2;
  --amber:        #D97706;
  --amber-lt:     #FFFBEB;
  --purple:       #7C3AED;
  --purple-lt:    #F5F3FF;
  --sidebar-w:    240px;
  --topbar-h:     64px;
  --r:            10px;
  --r-sm:         7px;
  --shadow:       0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --shadow-md:    0 4px 12px rgba(0,0,0,.08), 0 12px 32px rgba(0,0,0,.06);
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
img { max-width: 100%; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }

/* ── App shell ────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.logo-link { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--blue), #1D4ED8);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(37,99,235,.3);
}
.logo-icon svg { width: 17px; height: 17px; stroke: #fff; fill: none; stroke-width: 2.5; }
.logo-text { font-size: 1rem; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }

.sidebar-nav { padding: 12px 10px; flex-shrink: 0; }
.nav-section-label { font-size: .65rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding: 0 8px; margin: 12px 0 5px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: .83rem; font-weight: 500; color: var(--ink-2);
  transition: all .15s; white-space: nowrap;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--blue-lt); color: var(--blue); font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; }
.nav-badge { margin-left: auto; background: var(--surface-2); color: var(--ink-3); font-size: .65rem; font-weight: 700; padding: 1px 6px; border-radius: 99px; }
.nav-item.active .nav-badge { background: rgba(37,99,235,.12); color: var(--blue); }

.sidebar-sites-section { padding: 0 10px 10px; flex-shrink: 0; }
.sidebar-section-label { font-size: .65rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding: 0 8px; margin: 12px 0 5px; font-weight: 600; display: block; }
.sidebar-site {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--r-sm);
  font-size: .8rem; color: var(--ink-2);
  transition: all .15s;
}
.sidebar-site:hover { background: var(--surface-2); color: var(--ink); }
.sidebar-add-site { color: var(--blue); font-size: .8rem; }
.sidebar-add-site svg { width: 14px; height: 14px; }
.site-bullet { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-uname { display: block; font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-urole { display: block; font-size: .7rem; color: var(--ink-3); }
.btn-logout { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--r-sm); color: var(--ink-3); transition: all .15s; flex-shrink: 0; }
.btn-logout:hover { background: var(--red-lt); color: var(--red); }
.btn-logout svg { width: 15px; height: 15px; }

/* ── Main area ────────────────────────────────────────────────── */
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 0 var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.page-title-wrap h1 { font-size: 1.1rem; font-weight: 700; color: var(--ink); line-height: 1.2; }
.page-sub { font-size: .78rem; color: var(--ink-3); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ── Page body ────────────────────────────────────────────────── */
.page-body { padding: 24px 28px 60px; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--r-sm);
  font-size: .82rem; font-weight: 600;
  border: 1px solid var(--border-2);
  background: var(--surface); color: var(--ink-2);
  cursor: pointer; transition: all .15s; line-height: 1;
}
.btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--border-2); }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: #1D4ED8; border-color: #1D4ED8; box-shadow: 0 3px 12px rgba(37,99,235,.3); }
.btn-sm { padding: 5px 12px; font-size: .77rem; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-danger { background: var(--red-lt); color: var(--red); border-color: #FECACA; }
.btn-danger:hover { background: #FEE2E2; }
.btn-copy { background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2); border-radius: var(--r-sm); padding: 4px 10px; font-size: .75rem; font-weight: 600; cursor: pointer; transition: all .15s; font-family: inherit; }
.btn-copy:hover { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-copy-code { display: inline-flex; align-items: center; gap: 5px; background: var(--surface-2); border: 1px solid var(--border-2); color: var(--ink-2); border-radius: var(--r-sm); padding: 4px 10px; font-size: .75rem; cursor: pointer; transition: all .15s; font-family: inherit; }
.btn-copy-code svg { width: 13px; height: 13px; }
.btn-copy-code:hover { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ── Cards ────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: .88rem; font-weight: 700; color: var(--ink); }
.card-body { padding: 20px; }

/* ── Grid layouts ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.two-col    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col  { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ── Stat card ────────────────────────────────────────────────── */
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px 20px; display: flex; align-items: flex-start; gap: 14px; box-shadow: var(--shadow); transition: all .2s; }
.stat-card:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 18px; height: 18px; }
.stat-label { font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin-bottom: 4px; }
.stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat-sub { font-size: .75rem; color: var(--ink-3); }

/* ── Flash messages ───────────────────────────────────────────── */
.flash { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r-sm); margin-bottom: 16px; font-size: .85rem; font-weight: 500; border: 1px solid; }
.flash svg { width: 16px; height: 16px; flex-shrink: 0; }
.flash-success { background: var(--green-lt); border-color: #86EFAC; color: #166534; }
.flash-error   { background: var(--red-lt);   border-color: #FECACA; color: #991B1B; }
.flash-warning { background: var(--amber-lt); border-color: #FDE68A; color: #92400E; }
.flash-info    { background: var(--blue-lt);  border-color: #BFDBFE; color: #1E40AF; }

/* ── Tables ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.data-table th { padding: 10px 16px; text-align: left; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); border-bottom: 2px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.data-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tr.row-worst { background: #FFF5F5; }
.data-table tr.row-worst:hover { background: #FEE2E2; }
.data-table tr.row-worst td:first-child { border-left: 3px solid var(--red); }
.data-table tr.row-submit { background: var(--green-lt); }
.data-table tr.row-submit td:first-child { border-left: 3px solid var(--green); }

/* ── Drop-off bar ─────────────────────────────────────────────── */
.dropoff-cell { display: flex; align-items: center; gap: 8px; }
.bar-wrap { width: 70px; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; flex-shrink: 0; }
.bar-fill { height: 100%; border-radius: 99px; transition: width .5s ease; }
.bar-success { background: var(--green); }
.bar-warning { background: var(--amber); }
.bar-danger  { background: var(--red); }
.pct-success { font-size: .8rem; font-weight: 700; color: var(--green); min-width: 42px; }
.pct-warning { font-size: .8rem; font-weight: 700; color: var(--amber); min-width: 42px; }
.pct-danger  { font-size: .8rem; font-weight: 700; color: var(--red);   min-width: 42px; }

/* ── Badges ───────────────────────────────────────────────────── */
.badge-red   { font-size: .7rem; font-weight: 600; background: var(--red-lt);    color: var(--red);   border: 1px solid #FECACA; padding: 2px 8px; border-radius: 99px; }
.badge-green { font-size: .7rem; font-weight: 600; background: var(--green-lt);  color: var(--green); border: 1px solid #86EFAC; padding: 2px 8px; border-radius: 99px; }
.badge-blue  { font-size: .7rem; font-weight: 600; background: var(--blue-lt);   color: var(--blue);  border: 1px solid #BFDBFE; padding: 2px 8px; border-radius: 99px; }
.cr-badge    { font-size: .8rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.site-tag    { font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; border: 1px solid; display: inline-block; }
.pill        { font-size: .72rem; font-weight: 500; padding: 3px 9px; border-radius: 99px; display: inline-flex; align-items: center; }
.pill-blue   { background: var(--blue-lt);  color: var(--blue);   }
.pill-green  { background: var(--green-lt); color: var(--green);  }
.pill-red    { background: var(--red-lt);   color: var(--red);    }
.pill-purple { background: var(--purple-lt);color: var(--purple); }
.pill-gray   { background: var(--surface-2);color: var(--ink-3);  }
.category-tag{ font-size: .7rem; font-weight: 500; background: var(--surface-2); color: var(--ink-3); padding: 2px 8px; border-radius: 99px; }
.worst-badge { font-size: .67rem; font-weight: 700; background: var(--red-lt); color: var(--red); border: 1px solid #FECACA; padding: 2px 7px; border-radius: 99px; margin-left: 6px; }
.field-type-badge { font-size: .62rem; font-weight: 700; background: var(--surface-2); color: var(--ink-3); padding: 2px 6px; border-radius: 4px; font-family: monospace; }

/* ── Status indicators ────────────────────────────────────────── */
.status-live { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; color: var(--green); font-weight: 500; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1}50%{opacity:.4} }

/* ── Sites grid ───────────────────────────────────────────────── */
.sites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; padding: 20px; }
.site-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; transition: all .2s; display: block; }
.site-card:hover { border-color: var(--blue); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.site-card-bar { height: 4px; }
.site-card-body { padding: 16px; }
.site-card-name { font-size: .9rem; font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.site-card-domain { font-size: .75rem; color: var(--ink-3); margin-bottom: 12px; }
.site-card-stats { display: flex; gap: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.scn { font-size: 1rem; font-weight: 700; }
.scl { font-size: .68rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin-top: 1px; }
.site-card-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 120px; border: 2px dashed var(--border-2); color: var(--ink-3); cursor: pointer; font-size: .83rem; font-weight: 500; }
.site-card-add:hover { border-color: var(--blue); color: var(--blue); transform: none; box-shadow: none; }
.site-card-add svg { width: 22px; height: 22px; }

/* ── Site list rows ───────────────────────────────────────────── */
.sites-list { display: flex; flex-direction: column; gap: 14px; }
.site-row-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); display: flex; align-items: stretch; overflow: hidden; box-shadow: var(--shadow); transition: all .2s; }
.site-row-card:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); }
.src-colour { width: 5px; flex-shrink: 0; }
.src-main { flex: 1; padding: 16px 20px; min-width: 0; }
.src-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.src-name { font-size: .95rem; font-weight: 700; color: var(--ink); }
.src-name:hover { color: var(--blue); }
.src-domain { font-size: .78rem; color: var(--ink-3); }
.src-stats { display: flex; gap: 24px; margin-bottom: 10px; }
.src-stat { display: flex; flex-direction: column; }
.src-stat-val { font-size: 1rem; font-weight: 700; }
.src-stat-l { font-size: .68rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.src-key { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.key-label { font-size: .73rem; color: var(--ink-3); font-weight: 600; }
.key-label-sm { font-size: .7rem; color: var(--ink-3); font-weight: 600; margin-bottom: 6px; }
.api-key-display { font-family: monospace; font-size: .75rem; background: var(--surface-2); padding: 4px 8px; border-radius: var(--r-sm); color: var(--ink-2); word-break: break-all; }
.api-key-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.src-actions { padding: 16px; display: flex; flex-direction: column; gap: 6px; justify-content: center; border-left: 1px solid var(--border); }

/* ── Forms (inputs) ───────────────────────────────────────────── */
.fg { margin-bottom: 16px; }
.fg label { display: block; font-size: .81rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.fg input, .fg select, .fg textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: .88rem; color: var(--ink); background: var(--surface-2);
  outline: none; transition: all .15s;
}
.fg input:focus, .fg select:focus, .fg textarea:focus { border-color: var(--blue); background: var(--surface); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.fg input:disabled { opacity: .55; cursor: not-allowed; }
.fg-hint { font-size: .75rem; color: var(--ink-3); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── Colour picker ────────────────────────────────────────────── */
.colour-picker { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.colour-opt input { display: none; }
.colour-opt span { display: block; width: 28px; height: 28px; border-radius: 7px; cursor: pointer; border: 2px solid transparent; transition: all .15s; }
.colour-opt input:checked + span { border-color: var(--ink); transform: scale(1.15); box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.colour-opt span:hover { transform: scale(1.1); }

/* ── Modals ───────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(15,23,42,.5); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; padding: 24px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.2); overflow: hidden; animation: modalIn .2s ease; }
@keyframes modalIn { from{opacity:0;transform:scale(.96) translateY(8px)} to{opacity:1;transform:scale(1) translateY(0)} }
.modal-header { padding: 20px 22px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 1rem; font-weight: 700; }
.modal-close { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: none; background: var(--surface-2); border-radius: var(--r-sm); cursor: pointer; transition: all .15s; }
.modal-close:hover { background: var(--red-lt); color: var(--red); }
.modal-close svg { width: 15px; height: 15px; }
.modal-form { padding: 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }

/* ── Empty states ─────────────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; color: var(--ink-3); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 14px; opacity: .4; }
.empty-state h3 { font-size: 1rem; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.empty-state p { font-size: .85rem; max-width: 360px; line-height: 1.6; }

/* ── Section header ───────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-size: .88rem; font-weight: 700; color: var(--ink); }

/* ── Form analysis card ───────────────────────────────────────── */
.form-analysis-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 16px; overflow: hidden; box-shadow: var(--shadow); }
.fac-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.fac-title-block { flex: 1; min-width: 0; }
.fac-title { font-size: .95rem; font-weight: 700; color: var(--ink); margin-bottom: 3px; }
.fac-url { font-size: .75rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 8px; }
.fac-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.fac-cr { text-align: right; flex-shrink: 0; }
.fac-cr-val { font-size: 2rem; font-weight: 800; line-height: 1; }
.fac-cr-label { font-size: .7rem; color: var(--ink-3); margin-top: 2px; }

/* ── Insight banner ───────────────────────────────────────────── */
.insight-banner { margin: 0 0 0; padding: 12px 20px; background: #FFFBEB; border-bottom: 1px solid #FDE68A; display: flex; align-items: flex-start; gap: 10px; font-size: .83rem; color: #92400E; }
.insight-banner svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; stroke: var(--amber); }

/* ── Funnel ───────────────────────────────────────────────────── */
.funnel-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.funnel-label { font-size: .7rem; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin-bottom: 10px; }
.funnel-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.funnel-field-name { font-size: .76rem; color: var(--ink-2); width: 120px; flex-shrink: 0; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.funnel-bar-track { flex: 1; height: 26px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.funnel-bar-fill { height: 100%; border-radius: 6px; display: flex; align-items: center; padding-left: 10px; font-size: .72rem; font-weight: 600; color: #fff; transition: width .8s cubic-bezier(.16,1,.3,1); min-width: 40px; }
.funnel-success { background: linear-gradient(90deg, #16A34A, #22C55E); }
.funnel-warning { background: linear-gradient(90deg, #D97706, #F59E0B); }
.funnel-danger  { background: linear-gradient(90deg, #DC2626, #EF4444); }
.funnel-drop { width: 60px; text-align: right; font-size: .75rem; font-weight: 600; flex-shrink: 0; }
.drop-success { color: var(--green); }
.drop-warning { color: var(--amber); }
.drop-danger  { color: var(--red); }

/* ── Legend ───────────────────────────────────────────────────── */
.legend-row { display: flex; align-items: center; gap: 4px; font-size: .75rem; color: var(--ink-3); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ── Device chart legend ──────────────────────────────────────── */
.device-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.dev-item { display: flex; align-items: center; gap: 5px; font-size: .75rem; color: var(--ink-2); }
.dev-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dev-desktop { background: var(--blue); }
.dev-mobile  { background: var(--green); }
.dev-tablet  { background: var(--purple); }
.dev-unknown { background: var(--ink-3); }

/* ── Code blocks ──────────────────────────────────────────────── */
.code-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; }
.code-block-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 8px; background: var(--surface); border-bottom: 1px solid var(--border); }
.code-lang { font-size: .7rem; font-weight: 600; color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase; }
.code-block pre { padding: 16px 18px; overflow-x: auto; }
.code-block pre code { font-size: .82rem; line-height: 1.8; color: var(--ink); }
.c-tag  { color: #0369A1; }
.c-attr { color: #B45309; }
.c-str  { color: #166534; }
.c-cm   { color: var(--ink-3); }

/* ── Install page ─────────────────────────────────────────────── */
.site-selector-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.site-selector-tab { display: flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: var(--r-sm); border: 1.5px solid var(--border); font-size: .82rem; font-weight: 500; color: var(--ink-2); transition: all .15s; cursor: pointer; }
.site-selector-tab:hover { background: var(--surface-2); }
.site-selector-tab.active { background: var(--blue-lt); font-weight: 600; }
.step-num-badge { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--blue); color: #fff; font-size: .72rem; font-weight: 700; margin-right: 4px; }
.install-key-row { margin-top: 16px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--r-sm); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.install-key-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.iki-label { font-size: .75rem; font-weight: 600; color: var(--ink-3); }
.iki-val { font-family: monospace; font-size: .78rem; color: var(--ink-2); word-break: break-all; }
.how-it-works-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hiw-item { padding: 16px; background: var(--surface-2); border-radius: var(--r-sm); }
.hiw-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.hiw-icon svg { width: 18px; height: 18px; }
.hiw-title { font-size: .83rem; font-weight: 700; margin-bottom: 5px; }
.hiw-desc { font-size: .78rem; color: var(--ink-3); line-height: 1.6; }
.verify-steps { display: flex; flex-direction: column; gap: 10px; }
.vs-step { display: flex; align-items: flex-start; gap: 12px; font-size: .85rem; }
.vs-num { width: 24px; height: 24px; border-radius: 50%; background: var(--blue-lt); color: var(--blue); font-size: .75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: 1px solid #BFDBFE; }

/* ── Analytics ────────────────────────────────────────────────── */
.range-tabs { display: flex; background: var(--surface-2); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.range-tab { padding: 5px 12px; border-radius: 5px; font-size: .78rem; font-weight: 600; color: var(--ink-3); transition: all .15s; }
.range-tab:hover { color: var(--ink); }
.range-tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.site-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sbr-name { width: 120px; flex-shrink: 0; font-size: .8rem; font-weight: 500; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sbr-bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.sbr-fill { height: 100%; border-radius: 99px; transition: width .6s ease; }
.sbr-pct { font-size: .78rem; font-weight: 700; width: 42px; text-align: right; flex-shrink: 0; }

/* ── Settings ─────────────────────────────────────────────────── */
.info-grid { display: flex; flex-direction: column; gap: 0; }
.ig-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: .85rem; }
.ig-row:last-child { border-bottom: none; }
.ig-label { color: var(--ink-3); font-weight: 500; }
.ig-val { font-weight: 600; }

/* ── Toast ────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 8px; padding: 11px 16px; border-radius: var(--r-sm); font-size: .82rem; font-weight: 500; box-shadow: var(--shadow-md); border: 1px solid; opacity: 0; transform: translateX(16px); transition: all .25s; min-width: 220px; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(0); pointer-events: all; }
.toast-success { background: var(--green-lt); border-color: #86EFAC; color: #166534; }
.toast-error   { background: var(--red-lt);   border-color: #FECACA; color: #991B1B; }
.toast-info    { background: var(--blue-lt);   border-color: #BFDBFE; color: #1E40AF; }

/* ── Utilities ────────────────────────────────────────────────── */
.text-muted { color: var(--ink-3); }
.text-sm    { font-size: .8rem; }
code { font-family: monospace; font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: var(--ink-2); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col    { grid-template-columns: 1fr; }
  .how-it-works-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .page-body { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row   { grid-template-columns: 1fr; }
  .src-actions { flex-direction: row; border-left: none; border-top: 1px solid var(--border); }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Conversion Blocker cards ─────────────────────────────── */
.blockers-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.blocker-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
  transition: box-shadow .2s;
}
.blocker-card:hover { box-shadow: var(--shadow-md); }
.blocker-stripe-high   { height: 4px; background: var(--red); }
.blocker-stripe-medium { height: 4px; background: var(--amber); }
.blocker-stripe-low    { height: 4px; background: var(--green); }
.blocker-card-top { padding: 18px 20px 0; flex: 1; }
.blocker-rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface-2); color: var(--ink-3);
  font-size: .68rem; font-weight: 700; margin-right: 6px; vertical-align: middle;
}
.blocker-impact {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 99px; vertical-align: middle;
}
.impact-high   { background: var(--red-lt);   color: var(--red);   border: 1px solid #FECACA; }
.impact-medium { background: var(--amber-lt); color: var(--amber); border: 1px solid #FDE68A; }
.impact-low    { background: var(--green-lt); color: var(--green); border: 1px solid #86EFAC; }
.blocker-title { font-size: .92rem; font-weight: 700; color: var(--ink); margin: 10px 0 8px; line-height: 1.3; }
.blocker-explanation { font-size: .81rem; color: var(--ink-2); line-height: 1.65; margin-bottom: 14px; }
.blocker-fix {
  margin: 0 20px 18px; padding: 11px 13px; border-radius: var(--r-sm);
  background: var(--blue-lt); border: 1px solid #BFDBFE;
}
.blocker-fix-label { font-size: .62rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); margin-bottom: 4px; }
.blocker-fix-text  { font-size: .79rem; color: #1E40AF; line-height: 1.55; }

/* ── Page list (sidebar within page) ─────────────────────── */
.page-list { display: flex; flex-direction: column; gap: 1px; }
.page-list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: .81rem; color: var(--ink-2); transition: all .15s;
}
.page-list-item:hover { background: var(--surface-2); color: var(--ink); }
.page-list-item.active { background: var(--blue-lt); color: var(--blue); font-weight: 600; }
.page-list-item-url { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-list-item-views { font-size: .72rem; color: var(--ink-3); flex-shrink: 0; }
.page-list-item.active .page-list-item-views { color: rgba(37,99,235,.55); }

/* ── Scroll depth bars ────────────────────────────────────── */
.scroll-depth-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.scroll-depth-label { font-size: .75rem; color: var(--ink-3); width: 34px; flex-shrink: 0; text-align: right; }
.scroll-depth-bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.scroll-depth-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--blue), #60A5FA); transition: width .6s ease; }
.scroll-depth-pct { font-size: .76rem; font-weight: 700; color: var(--ink-2); width: 36px; text-align: right; flex-shrink: 0; }

@media (max-width: 1024px) {
  .blockers-grid { grid-template-columns: 1fr; }
}

/* ── Animations ───────────────────────────────────────────────── */
@keyframes fadeUp { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
.form-analysis-card { animation: fadeUp .3s ease both; }
.form-analysis-card:nth-child(2) { animation-delay: .05s; }
.form-analysis-card:nth-child(3) { animation-delay: .10s; }

/* ── Chart.js fixes ──────────────────────────────────────────── */
/* Canvas must sit inside a position:relative div with a fixed height.
   Chart.js responsive mode reads the parent height, not the canvas attr. */
canvas {
    display: block;
    max-width: 100%;
}
/* Prevent charts from collapsing in flex/grid containers */
.card-body canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100% !important;
    height: 100% !important;
}
