/* Reset & Base */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; background: #f8fafc; color: #0f172a; overflow-y: scroll; }
h1, h2, h3, .logo { font-family: 'Outfit', sans-serif; }

/* Layout */
#app { max-width: 1400px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 24px; }

/* Navbar */
.navbar { display: flex; align-items: center; justify-content: space-between; background: #ffffff; padding: 16px 24px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.03); border: 1px solid #e2e8f0; }
.logo { font-size: 1.5rem; font-weight: 800; color: #0f172a; }
.nav-controls { display: flex; gap: 16px; align-items: center; }
.nav-controls select, .nav-controls input { padding: 10px 16px; border-radius: 8px; border: 1px solid #e2e8f0; background: #f8fafc; outline: none; font-family: 'Inter'; font-size: 0.9rem; transition: border 0.2s; }
.nav-controls input:focus, .nav-controls select:focus { border-color: #3b82f6; background: #ffffff; }
.btn { padding: 10px 20px; background: #0f172a; color: white; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.btn:hover { background: #1e293b; transform: translateY(-1px); }

/* Funnel stage cards */
.funnel { display: flex; gap: 12px; justify-content: center; margin: 10px 0; }
.stage-card { background: white; border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px; text-align: center; flex: 1; cursor: pointer; transition: all 0.2s; position: relative; }
.stage-card:hover { transform: translateY(-4px); box-shadow: 0 10px 20px rgba(0,0,0,0.05); border-color: #cbd5e1; }
.stage-card.active { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }
.stage-count { font-size: 2rem; font-family: 'Outfit'; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stage-label { font-size: 0.75rem; text-transform: uppercase; font-weight: 700; color: #64748b; letter-spacing: 0.5px; }

/* Stage card hover tooltip */
.tooltip-card { cursor: pointer; position: relative; }
.tooltip-card .ttp-text {
    visibility: hidden; opacity: 0; position: absolute; z-index: 200;
    top: calc(100% + 10px); left: 50%;
    transform: translateX(-50%) translateY(-10px);
    width: max-content; max-width: 320px;
    background: #ffffff; color: #0f172a; padding: 16px; border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1); border: 1px solid #e2e8f0;
    font-size: 0.75rem; transition: all 0.2s ease; pointer-events: auto; text-align: left;
}
.tooltip-card:hover .ttp-text { visibility: visible; opacity: 1; transform: translateX(-50%) translateY(0); }

/* Leads Table — overflow visible so tooltips escape */
.leads-container { background: #ffffff; border-radius: 12px; border: 1px solid #e2e8f0; box-shadow: 0 4px 12px rgba(0,0,0,0.02); overflow: visible; }
.leads-header { display: grid; grid-template-columns: 2.5fr 2fr 1fr 2fr 1fr 1.5fr 1.5fr 1fr 1fr 0.5fr; padding: 12px 16px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; border-radius: 12px 12px 0 0; font-size: 0.7rem; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; }

/* Sortable column headers */
.col-h { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; padding: 2px 5px; border-radius: 4px; transition: background 0.15s; }
.col-h:hover { background: #e2e8f0; color: #0f172a; }
.sort-arrow { font-size: 0.55rem; color: #d1d5db; line-height: 1; }
.sort-arrow.on { color: #3b82f6; }

.lead-row-group { border-bottom: 1px solid #e2e8f0; }
.lead-row-group:last-child { border-bottom: none; }
.lead-row { display: grid; grid-template-columns: 2.5fr 2fr 1fr 2fr 1fr 1.5fr 1.5fr 1fr 1fr 0.5fr; padding: 16px; align-items: center; cursor: pointer; transition: background 0.2s; font-size: 0.85rem; }
.lead-row:hover { background: #f1f5f9; }
.lead-row.active { background: #eff6ff; }

.cell { padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.company { font-weight: 600; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.cell.niche { color: #475569; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-weight: 700; font-size: 0.8rem; background: #e2e8f0; color: #475569; text-align: center; min-width: 30px; }
.pill.high { background: #dcfce7; color: #166534; }
.pill.med { background: #fef08a; color: #854d0e; }
.pill.low { background: #fee2e2; color: #991b1b; }
.owner-pill { background: #dbeafe; color: #1e40af; padding: 2px 8px; border-radius: 4px; font-weight: 600; font-size: 0.75rem; }

/* Funnel progress dots in table */
.fn-dots { display: flex; align-items: center; gap: 4px; overflow: visible; }
.fn-dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid #cbd5e1; background: transparent; flex-shrink: 0; }
.fn-dot.done { background: #22c55e; border-color: #22c55e; }
.fn-dot.active { background: #3b82f6; border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,0.25); }
.fn-dot.rejected { background: #ef4444; border-color: #ef4444; }
.fn-line { width: 6px; height: 1.5px; background: #e2e8f0; flex-shrink: 0; }
.fn-line.done { background: #22c55e; }

/* Detail Accordion */
.detail-panel { display: none; padding: 24px; background: #fafafa; border-top: 1px dashed #cbd5e1; }
.detail-panel.open { display: block; animation: slideDown 0.3s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.section-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: #64748b; font-weight: 700; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #e2e8f0; }

.status-control { display: flex; gap: 8px; margin-bottom: 24px; }
.status-control select { flex: 1; padding: 8px; border-radius: 6px; border: 1px solid #e2e8f0; font-weight: 600; }

.comments-list { display: flex; flex-direction: column; gap: 12px; max-height: 250px; overflow-y: auto; margin-bottom: 16px; }
.comment { background: #ffffff; border: 1px solid #e2e8f0; padding: 12px; border-radius: 8px; font-size: 0.85rem; }
.comment-header { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 0.75rem; color: #64748b; }
.comment-header strong { color: #0f172a; font-weight: 600; }
.add-comment { display: flex; flex-direction: column; gap: 8px; }
.add-comment textarea { padding: 10px; border-radius: 8px; border: 1px solid #e2e8f0; font-family: 'Inter'; resize: vertical; min-height: 60px; font-size: 0.85rem; }

.c-lvl-card { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; margin-bottom: 12px; font-size: 0.85rem; }
.c-lvl-name { font-weight: 700; margin-bottom: 4px; }
.c-lvl-title { color: #64748b; font-size: 0.8rem; margin-bottom: 8px; }
.c-link { display: inline-block; background: #f1f5f9; padding: 2px 8px; border-radius: 4px; text-decoration: none; color: #334155; font-size: 0.75rem; margin: 0 4px 4px 0; }
.info-pill { display: inline-block; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 6px; padding: 4px 8px; font-size: 0.75rem; margin: 0 6px 6px 0; color: #334155; }

/* SEO/Tech metric cards */
.d-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-bottom: 16px; }
.d-card { background: white; border: 1px solid #e2e8f0; padding: 8px 10px; border-radius: 6px; cursor: default; transition: border-color 0.15s; }
.d-card[data-tip] { cursor: help; }
.d-card[data-tip]:hover { border-color: #93c5fd; background: #f0f9ff; }
.d-lbl { font-size: 0.65rem; color: #64748b; text-transform: uppercase; font-weight: 700; margin-bottom: 4px; }
.d-val { font-size: 0.85rem; font-weight: 600; }
.d-val.ok { color: #166534; }
.d-val.warn { color: #ca8a04; }
.d-val.bad { color: #b91c1c; }

/* Global fixed tooltip — escapes any overflow:hidden parent */
#g-tip {
    position: fixed; z-index: 9999;
    background: #1e293b; color: #e2e8f0;
    border-radius: 8px; padding: 9px 13px;
    font-size: 0.77rem; line-height: 1.5;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    max-width: 240px; pointer-events: none;
    opacity: 0; transition: opacity 0.15s;
    white-space: normal;
}
#g-tip strong { color: #ffffff; }
#g-tip.visible { opacity: 1; }

.contact-pill { display: inline-flex; align-items: center; gap: 6px; background: #ffffff; border: 1px solid #cbd5e1; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; margin: 0 6px 6px 0; text-decoration: none; color: #0f172a; transition: all 0.2s; font-weight: 500; }
.contact-pill:hover { background: #f1f5f9; border-color: #94a3b8; }
.growth-hook { background: #f0fdf4; border-left: 4px solid #16a34a; padding: 12px 16px; border-radius: 0 8px 8px 0; font-size: 0.9rem; color: #14532d; font-weight: 500; line-height: 1.5; margin-bottom: 24px; }
.hidden { display: none !important; }

/* Market Toggle */
.market-toggle { display: inline-flex; background: #f1f5f9; border-radius: 8px; padding: 4px; border: 1px solid #e2e8f0; align-items: center; }
.market-btn { padding: 6px 14px; border-radius: 6px; font-size: 0.85rem; font-weight: 600; color: #64748b; cursor: pointer; transition: all 0.2s; user-select: none; }
.market-btn:hover { color: #0f172a; }
.market-btn.active { background: #ffffff; color: #0f172a; box-shadow: 0 2px 4px rgba(0,0,0,0.05); border: 1px solid #e2e8f0; margin: -1px; }
