/* ============================================================
   styles.css — Shared design tokens + components for sponsorgrab
   Source of truth aligned with DESIGN.md
   ============================================================ */

/* --- Tokens --- */
:root {
    --bg: #FAFAF8;
    --surface: #FFFFFF;
    --surface-2: #F3F2EF;
    --surface-3: #E5E3DF;
    --border: #E5E3DF;
    --border-light: #D4CEC6;
    --text: #1A1A1A;
    --text-2: #4A4A4A;
    --text-3: #777777;
    --accent: #D4553A;
    --accent-dim: #B8432C;
    --accent-hover: #B8432C;
    --accent-bg: rgba(212,85,58,0.06);
    --accent-border: rgba(212,85,58,0.18);
    --blue: #2563EB;
    --blue-dim: rgba(37,99,235,0.1);
    --green: #2D7A4F;
    --green-dim: rgba(45,122,79,0.1);
    --red: #D4553A;
    --red-dim: rgba(212,85,58,0.08);
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: var(--font);
    --font-display: 'Plus Jakarta Sans', var(--font);
    --serif: Georgia, 'Times New Roman', serif;
    --mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --radius: 4px;
    --radius-md: 8px;
    --radius-lg: 8px;
    --text-xs: 11px;
    --text-sm: 13px;
    --text-base: 14px;
    --text-md: 15px;
    --text-lg: 16px;
    --text-xl: 20px;
    --text-2xl: 22px;
    --text-3xl: 28px;
    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
    --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;
    --shadow-sm: 0 1px 2px rgba(26,26,26,0.04), 0 1px 3px rgba(26,26,26,0.06);
    --shadow-md: 0 2px 4px rgba(26,26,26,0.04), 0 4px 12px rgba(26,26,26,0.08);
    --shadow-lg: 0 4px 8px rgba(26,26,26,0.04), 0 8px 24px rgba(26,26,26,0.1);
}

/* --- Dark theme --- */
[data-theme="dark"] {
    --bg: #141413;
    --surface: #1E1E1C;
    --surface-2: #2A2A27;
    --surface-3: #3A3835;
    --border: #3A3835;
    --border-light: #4A4745;
    --text: #E8E6E1;
    --text-2: #A3A09A;
    --text-3: #7A7772;
    --accent: #E8694F;
    --accent-dim: #F07D65;
    --accent-hover: #F07D65;
    --accent-bg: rgba(232,105,79,0.1);
    --accent-border: rgba(232,105,79,0.18);
    --blue: #5B8DEF;
    --blue-dim: rgba(91,141,239,0.15);
    --green: #3DA366;
    --green-dim: rgba(61,163,102,0.15);
    --red: #E8694F;
    --red-dim: rgba(232,105,79,0.1);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2), 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 2px 4px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 8px rgba(0,0,0,0.2), 0 8px 24px rgba(0,0,0,0.4);
}

/* --- Reset + Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-font-smoothing: antialiased; }

/* Custom scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    font-size: 15px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout --- */
.shell { max-width: 1360px; margin: 0 auto; padding: 32px 24px 72px; }
.page { max-width: 720px; margin: 0 auto; padding: 60px 24px 80px; }

/* --- Theme toggle --- */
.theme-toggle { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 18px; color: var(--text-2); transition: all 0.15s; }
.theme-toggle:hover { color: var(--text); background: var(--surface-3); }

/* --- Header --- */
.hdr { margin-bottom: 32px; }
.hdr h1 {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.hdr-sub {
    font-size: 13px;
    color: var(--text-3);
    font-family: var(--mono);
    letter-spacing: 0.01em;
}
.hdr-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.hdr-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    margin-top: 4px;
}

/* --- KPI cards --- */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
}
.kpi-val {
    font-size: 28px;
    font-weight: 700;
    font-family: var(--font-display);
    line-height: 1.15;
    color: var(--text);
}
.kpi-label {
    font-size: 11px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 4px;
    font-weight: 500;
}

/* --- Tabs --- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
}
.tab {
    padding: 12px 22px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-3);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font);
}
.tab:hover { color: var(--text-2); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.tab-panel { display: none; opacity: 0; transition: opacity 180ms ease-out; }
.tab-panel.active { display: block; opacity: 1; }
.tab-panel.fade-out { opacity: 0; transition: opacity 180ms ease-in; }

/* --- Insights --- */
.insights-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 28px;
}
@media (max-width: 700px) { .insights-grid { grid-template-columns: 1fr; } }
.signal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    border-left: 3px solid var(--border);
}
.signal-card.scaling { border-left-color: var(--green); }
.signal-card.returning { border-left-color: var(--blue); }
.signal-card.new-sponsors { border-left-color: var(--accent); }
.signal-card.watching { border-left-color: var(--red); }
.signal-card h3 {
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 10px 0;
}
.signal-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 13px;
}
.signal-item img { border-radius: 2px; flex-shrink: 0; }
.signal-name { color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signal-stat { color: var(--text-3); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.insights-section { margin-bottom: 28px; }
.insights-section h2 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 14px 0;
}

/* --- Market / timing rows --- */
.market-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    font-size: 13px;
}
.market-label { color: var(--text-2); width: 110px; text-align: right; flex-shrink: 0; font-family: var(--mono); font-size: 11px; }
.market-bar-wrap { flex: 1; background: var(--surface-2); border-radius: 3px; height: 16px; overflow: hidden; }
.market-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.market-count { color: var(--text-3); font-family: var(--mono); font-size: 11px; width: 80px; }
.trending-item { font-size: 13px; padding: 3px 0; color: var(--text-2); }
.trending-up { color: var(--green); }
.trending-down { color: var(--red); }
.timing-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.timing-row:last-child { border-bottom: none; }
.timing-date { font-family: var(--mono); font-size: 11px; color: var(--accent); background: var(--accent-bg); border-radius: 4px; padding: 2px 6px; white-space: nowrap; }
.timing-sponsor { color: var(--text); flex: 1; }
.timing-nl { color: var(--text-3); font-size: 11px; }
.timing-type { font-family: var(--mono); font-size: 11px; color: var(--text-3); background: var(--surface-3); border-radius: 3px; padding: 1px 5px; }
.intel-table { width: 100%; }

/* --- Filters --- */
.filters {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.search-box {
    flex: 1;
    min-width: 220px;
    max-width: 340px;
    padding: 9px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-bg); }
.search-box::placeholder { color: var(--text-3); }
.filter-sel {
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-2);
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    outline: none;
}
.filter-sel option { background: var(--surface); color: var(--text); }
.filter-lbl {
    font-size: 12px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

/* --- Buttons --- */
.btn-sm {
    padding: 9px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
}
.btn-sm:hover { background: var(--surface-2); border-color: var(--border-light); }
.btn-accent {
    background: var(--accent-bg);
    border-color: var(--accent-border);
    color: var(--accent);
}
.btn-accent:hover { background: var(--accent-bg); border-color: var(--accent); }
.btn-config {
    padding: 8px 14px;
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius);
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.btn-config:hover { background: var(--accent-border); border-color: var(--accent); }
.btn-config.configured {
    background: var(--green-dim);
    border-color: rgba(92,232,148,0.25);
    color: var(--green);
}
.btn-primary {
    padding: 10px 24px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-danger {
    padding: 8px 14px;
    background: var(--red-dim);
    border: 1px solid rgba(248,113,113,0.2);
    border-radius: var(--radius);
    color: var(--red);
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 500;
}
.btn-danger:hover { background: rgba(248,113,113,0.18); }
.results-ct {
    font-size: 13px;
    color: var(--text-3);
    margin-bottom: 14px;
    font-family: var(--mono);
}

/* --- Tables --- */
.tbl {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.tbl thead { background: var(--surface-2); }
.tbl th {
    text-align: left;
    padding: 13px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}
.tbl th.sort { cursor: pointer; user-select: none; }
.tbl th.sort:hover { color: var(--text-2); }
.tbl th .arr { font-size: 10px; margin-left: 3px; opacity: 0.6; }
.tbl td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.tbl tbody tr[data-sid] { cursor: pointer; transition: background 0.1s; }
.tbl tbody tr[data-sid]:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }

/* --- Sponsor names --- */
.s-name { font-weight: 600; }
.s-name-text { color: var(--accent); cursor: pointer; font-size: 14px; }
.s-name-text:hover { text-decoration: underline; }
.s-ext { color: var(--text-3); font-size: 11px; margin-left: 4px; opacity: 0.5; }
.s-ext:hover { opacity: 1; color: var(--accent); text-decoration: none; }

/* --- Feedback buttons --- */
.fb-toggle { display: inline-flex; gap: 2px; margin-left: 6px; }
.fb-btn { background: none; border: 1px solid transparent; border-radius: 4px; cursor: pointer; font-size: 12px; padding: 1px 4px; opacity: 0.3; transition: opacity 0.15s, background 0.15s; }
.fb-btn:hover { opacity: 0.8; }
.fb-btn.active { opacity: 1; border-color: var(--border-2); }
.fb-btn.fb-good.active { background: rgba(34,197,94,0.18); }
.fb-btn.fb-bad.active { background: rgba(239,68,68,0.18); }
tr.feedback-good td:first-child { box-shadow: inset 3px 0 0 #22c55e; }
tr.feedback-bad { opacity: 0.45; }

/* --- Info tips --- */
.info-tip {
    position: relative;
    display: inline-block;
    cursor: help;
    vertical-align: middle;
}
.info-tip:hover { color: var(--accent); }
.info-tip .info-tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 400;
    color: var(--text-2);
    white-space: normal;
    width: 240px;
    line-height: 1.55;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 100;
    text-transform: none;
    letter-spacing: normal;
}
.info-tip .info-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    right: 16px;
    border: 6px solid transparent;
    border-bottom-color: var(--border-light);
}
.info-tip:hover .info-tooltip { display: block; }

/* --- Tags --- */
.tag {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.tag-industry {
    background: var(--blue-dim);
    color: var(--blue);
    border: 1px solid transparent;
}
.tag-nl {
    background: var(--surface-3);
    color: var(--text-2);
    margin: 2px 3px 2px 0;
}
.tags-wrap { display: flex; flex-wrap: wrap; gap: 4px; }

/* --- Counts + sparklines --- */
.ct {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 15px;
    text-align: center;
}
.dt { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.spark { display: inline-block; vertical-align: middle; }
.spark rect { fill: var(--accent); opacity: 0.4; rx: 1.5; }
.spark rect.hi { opacity: 0.9; }

/* --- Detail rows (expanded) --- */
.detail-row { display: none; background: var(--surface-2); }
.detail-row.open { display: table-row; }
.detail-row td { padding: 0; }
.detail-panel {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    border-top: 2px solid var(--accent-border);
}
.detail-sidebar {
    padding: 24px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.detail-main {
    padding: 24px;
    overflow-y: auto;
    max-height: 420px;
}
.detail-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
}
.detail-name a { color: var(--text); }
.detail-name a:hover { color: var(--accent); }
.detail-url {
    font-size: 12px;
    font-family: var(--mono);
    color: var(--text-3);
    word-break: break-all;
    margin-top: 3px;
}
.detail-url a { color: var(--text-3); }
.detail-url a:hover { color: var(--accent); }
.detail-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
    margin-bottom: 6px;
    font-weight: 600;
}
.detail-section { margin: 0; }
.detail-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.detail-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
}
.detail-stat-val {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 16px;
}
.detail-stat-label {
    font-size: 11px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 1px;
}
.detail-contact {
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 14px;
}
.detail-contact-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
}
.detail-contact-email a {
    color: var(--accent);
    font-family: var(--mono);
    font-size: 13px;
}
.detail-notes {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.55;
    font-style: italic;
}
.detail-nl-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.detail-main-hd {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.detail-main-hd .count {
    background: var(--surface-3);
    border-radius: 10px;
    padding: 2px 10px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-3);
}
.sg-list { list-style: none; padding: 0; margin: 0; }
.sg-list li {
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 7px;
    font-size: 14px;
}
.sg-list li:last-child { margin-bottom: 0; }
.sg-meta {
    display: flex; gap: 10px; align-items: center;
    color: var(--text-3);
    font-size: 12px;
    font-family: var(--mono);
    margin-bottom: 5px;
}
.sg-meta .sg-type {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.sg-type-sponsor { background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-border); }
.sg-type-classified { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(91,155,245,0.2); }
.sg-type-partner { background: var(--green-dim); color: var(--green); border: 1px solid rgba(74,222,128,0.2); }
.sg-txt { color: var(--text-2); line-height: 1.45; }
@media (max-width: 768px) {
    .detail-panel { grid-template-columns: 1fr; }
    .detail-sidebar { border-right: none; border-bottom: 1px solid var(--border); }
    .detail-main { max-height: 300px; }
}

/* --- Empty state --- */
.empty {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-3);
    font-size: 14px;
}

/* --- Newsletter cards --- */
.nl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 16px;
}
.nl-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    transition: border-color 0.15s, box-shadow 0.2s;
}
.nl-card:hover { border-color: var(--border-light); box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.nl-hdr {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}
.nl-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
}
.nl-subs {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-2);
    background: var(--surface-3);
    padding: 3px 10px;
    border-radius: 5px;
    font-weight: 500;
}
.nl-desc {
    font-size: 13px;
    color: var(--text-3);
    font-style: italic;
    margin-bottom: 8px;
}
.nl-meta {
    font-size: 13px;
    color: var(--text-3);
    margin-bottom: 14px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.nl-meta span { white-space: nowrap; }
.nl-sponsors-hd {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 8px;
    font-weight: 600;
}
.nl-sp-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.nl-sp-tag {
    font-size: 12px;
    padding: 3px 10px;
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    color: var(--accent);
    border-radius: 5px;
}
.nl-sp-link { cursor: pointer; transition: background 0.15s; }
.nl-sp-link:hover { background: var(--accent-border); text-decoration: underline; }
.nl-ad-link {
    font-size: 11px;
    font-family: var(--mono);
    color: var(--text-3);
    margin-left: 8px;
    padding: 2px 8px;
    background: var(--surface-3);
    border-radius: 5px;
    white-space: nowrap;
}
.nl-ad-link:hover { color: var(--accent); background: var(--accent-bg); text-decoration: none; }
.nl-rates {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-2);
}
.nl-rate-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}
.nl-rate-label { color: var(--text-3); font-weight: 500; }
.nl-rate-val { font-family: var(--mono); font-weight: 500; }
.nl-rates-hd {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 8px;
    font-weight: 600;
}
.nl-rate-block {
    flex-direction: column;
    gap: 2px;
}
.nl-rate-block .nl-rate-val {
    font-family: var(--font);
    font-weight: 400;
    font-size: 13px;
}
.nl-rate-notes {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-3);
    line-height: 1.55;
    font-style: italic;
}
.nl-affinity-3 { background: var(--green-dim); color: var(--green); }
.nl-affinity-2 { background: var(--accent-bg); color: var(--accent); }
.nl-affinity-1 { background: var(--blue-dim); color: var(--blue); }
.nl-affinity-0 { background: var(--surface-3); color: var(--text-3); }

/* --- Market view --- */
.mkt-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}
.mkt-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.mkt-title .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
}
.bar-chart { width: 100%; }
.bar-row {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
}
.bar-label {
    width: 160px;
    flex-shrink: 0;
    color: var(--text-2);
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}
.bar-track {
    flex: 1;
    height: 20px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 10px;
}
.bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}
.bar-val {
    width: 70px;
    text-align: right;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-3);
    flex-shrink: 0;
}
.opp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.opp-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}
.opp-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.opp-detail {
    font-size: 11px;
    color: var(--text-3);
    margin-bottom: 2px;
}
.opp-signal {
    font-size: 11px;
    font-weight: 600;
    margin-top: 6px;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
}
.opp-signal.hot {
    background: var(--green-dim);
    color: var(--green);
}
.opp-signal.warm {
    background: var(--accent-bg);
    color: var(--accent);
}

/* --- Timeline view --- */
.tl-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.tl-table {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
}
.tl-table th, .tl-table td {
    padding: 6px 8px;
    font-size: 11px;
    text-align: center;
    border: 1px solid var(--border);
}
.tl-table thead th {
    background: var(--surface-2);
    color: var(--text-3);
    font-weight: 500;
    position: sticky;
    top: 0;
    z-index: 2;
}
.tl-table thead th:first-child,
.tl-table tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--surface-2);
    text-align: left;
    min-width: 150px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tl-table tbody td:first-child {
    background: var(--surface);
    font-weight: 500;
    color: var(--text-2);
}
.tl-cell {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    display: inline-block;
}
.tl-cell.has {
    background: var(--accent);
    opacity: 0.7;
}
.tl-cell.has-1 { opacity: 0.4; }
.tl-cell.has-2 { opacity: 0.6; }
.tl-cell.has-3 { opacity: 0.8; }
.tl-cell.has-4 { opacity: 1.0; }

/* --- Score badges --- */
.score-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--mono);
    letter-spacing: 0.03em;
}
.score-A { background: var(--green-dim); color: var(--green); }
.score-B { background: var(--accent-bg); color: var(--accent); }
.score-C { background: var(--blue-dim); color: var(--blue); }
.score-D { background: var(--surface-3); color: var(--text-3); }
.pitch-preview {
    font-size: 11px;
    color: var(--text-3);
    font-family: var(--mono);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pitch-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-2);
    margin-bottom: 10px;
    position: relative;
}
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    font-size: 11px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-2);
    cursor: pointer;
    font-family: var(--font);
}
.copy-btn:hover { background: var(--border); }
.score-breakdown {
    font-size: 11px;
    color: var(--text-3);
    font-family: var(--mono);
    display: flex;
    gap: 14px;
    margin-top: 6px;
}

/* --- One-pager --- */
.op-hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    margin-bottom: 16px;
    text-align: center;
}
.op-hero h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}
.op-hero .op-tagline {
    color: var(--text-3);
    font-size: 13px;
    max-width: 560px;
    margin: 0 auto;
}
.op-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.op-kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.op-kpi-val {
    font-size: 24px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--accent);
}
.op-kpi-label {
    font-size: 11px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}
.testimonial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.testimonial-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 16px;
}
.testimonial-card blockquote {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--text-2);
    font-style: italic;
    line-height: 1.5;
}
.testimonial-card cite {
    font-size: 11px;
    color: var(--text-3);
    font-style: normal;
    font-weight: 600;
}
.cpm-highlight {
    background: var(--green-dim) !important;
}
.cpm-highlight td { color: var(--green) !important; font-weight: 600; }
.value-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.value-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-2);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.value-list li:last-child { border-bottom: none; }
.value-list .vl-icon {
    color: var(--accent);
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* --- Setup banner --- */
.setup-banner {
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-lg);
    padding: 18px 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.setup-banner-text {
    font-size: 14px;
    color: var(--text-2);
}
.setup-banner-text strong { color: var(--text); }
.setup-banner .btn-accent { flex-shrink: 0; }
.setup-banner-dismiss {
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    line-height: 1;
}
.setup-banner-dismiss:hover { color: var(--text-2); }

/* --- Modals --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    overflow-y: auto;
    transition: background 200ms ease-out;
}
.modal-overlay.open { display: flex; background: rgba(0,0,0,0.6); }
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 640px;
    padding: 0;
    box-shadow: var(--shadow-lg);
    transform: translateY(12px);
    opacity: 0;
    transition: transform 200ms ease-out, opacity 200ms ease-out;
}
.modal-overlay.open .modal { transform: translateY(0); opacity: 1; }
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}
.modal-section {
    margin-bottom: 24px;
}
.modal-section:last-child { margin-bottom: 0; }
.modal-section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-section-title .optional {
    font-size: 11px;
    color: var(--text-3);
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
    opacity: 0.7;
}
.modal-field {
    margin-bottom: 12px;
}
.modal-field label {
    display: block;
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 4px;
    font-weight: 500;
}
.modal-field input, .modal-field select, .modal-field textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s;
}
.modal-field input:focus, .modal-field select:focus, .modal-field textarea:focus {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 3px var(--accent-bg);
}
.modal-field textarea { resize: vertical; min-height: 60px; }
.modal-field .field-hint {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 3px;
}
.modal-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.modal-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.modal-footer-left {
    display: flex;
    gap: 8px;
}

/* --- Ad type list in modal --- */
.ad-type-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ad-type-item {
    display: grid;
    grid-template-columns: 1fr 80px 1fr 32px;
    gap: 8px;
    align-items: center;
}
.ad-type-item input {
    padding: 7px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
}
.ad-type-item input:focus {
    border-color: var(--accent-border);
}
.ad-type-remove {
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
}
.ad-type-remove:hover { color: var(--red); }
.ad-type-add {
    font-size: 12px;
    color: var(--accent);
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font);
    font-weight: 500;
    padding: 4px 0;
}
.ad-type-add:hover { text-decoration: underline; }

/* --- Similar newsletters grid --- */
.similar-nl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 6px;
}
.similar-nl-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
}
.similar-nl-item label {
    flex: 1;
    margin: 0;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
}
.similar-nl-item select {
    width: 70px;
    padding: 3px 6px;
    font-size: 11px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-2);
}

/* --- Industry fit grid --- */
.industry-fit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 6px;
}
.industry-fit-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
}
.industry-fit-item label {
    flex: 1;
    margin: 0;
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
}
.industry-fit-item select {
    width: 80px;
    padding: 3px 6px;
    font-size: 11px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-2);
}

/* --- Print styles --- */
@media print {
    body { background: #fff; color: #000; font-size: 12px; }
    .shell { padding: 0; max-width: 100%; }
    .hdr, .kpi-row, .tabs, .setup-banner,
    .tab-panel:not(#panel-onepager),
    .modal-overlay, .pending-bar { display: none !important; }
    #panel-onepager { display: block !important; }
    .mkt-section {
        background: #fff;
        border-color: #ddd;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .op-hero { background: #fff; border-color: #ddd; }
    .op-kpi { background: #f9f9f9; border-color: #ddd; }
    .op-kpi-val { color: #b85d00; }
    .bar-track { background: #eee; }
    .testimonial-card { background: #fff; border-color: #ddd; border-left-color: #b85d00; }
    .tbl { border-color: #ddd; }
    .tbl thead { background: #f5f5f5; }
    .tbl th { color: #666; border-color: #ddd; }
    .tbl td { border-color: #ddd; color: #333; }
    .cpm-highlight { background: rgba(15,122,52,0.08) !important; }
    .cpm-highlight td { color: #0f7a34 !important; }
    .value-list li { border-color: #ddd; color: #333; }
    a { color: #b87a00; }
    :root {
        --text: #1a1a1e;
        --text-2: #3d3d4a;
        --text-3: #6e6e80;
        --accent: #b87a00;
        --green: #0f7a34;
    }
}

/* --- Admin panel --- */
.admin-sub-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
}
.admin-sub-tab {
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
}
.admin-sub-tab:hover { background: var(--surface-2); border-color: var(--border-light); }
.admin-sub-tab.active { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent); }
.admin-sub-panel { display: none; }
.admin-sub-panel.active { display: block; }
.admin-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
    align-items: center;
}
.admin-tbl {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    font-size: 13px;
}
.admin-tbl thead { background: var(--surface-2); }
.admin-tbl th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
}
.admin-tbl th:hover { color: var(--text-2); }
.admin-tbl td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-tbl tbody tr:last-child td { border-bottom: none; }
.admin-tbl tbody tr:hover { background: var(--surface-2); }
.admin-tbl .act-btns { white-space: nowrap; }
.admin-btn-edit, .admin-btn-del {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 500;
    border: 1px solid;
    margin-right: 4px;
}
.admin-btn-edit { background: var(--blue-dim); color: var(--blue); border-color: rgba(94,158,245,0.2); }
.admin-btn-edit:hover { border-color: var(--blue); }
.admin-btn-del { background: var(--red-dim); color: var(--red); border-color: rgba(245,101,101,0.2); }
.admin-btn-del:hover { border-color: var(--red); }
.quality-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.dot-yellow { background: #eab308; }
.dot-orange { background: #f97316; }
.dot-gray { background: var(--text-3); opacity: 0.5; }
.admin-row-warn { background: rgba(234,179,8,0.05); }

/* --- Pending changes bar --- */
.pending-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 2px solid var(--accent);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 999;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.15);
}
.pending-bar .pending-info {
    font-size: 13px;
    color: var(--text-2);
    font-family: var(--mono);
}
.pending-bar .pending-actions { display: flex; gap: 8px; }

/* --- Merge UI --- */
.merge-pair {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: start;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
}
.merge-card {
    padding: 12px;
    background: var(--surface-2);
    border-radius: var(--radius);
}
.merge-card h4 { font-size: 14px; margin-bottom: 6px; }
.merge-card .meta { font-size: 12px; color: var(--text-3); line-height: 1.6; }
.merge-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-top: 20px;
}

/* --- Footer (static pages) --- */
footer { border-top: 1px solid var(--border); margin-top: 60px; padding: 24px 0; text-align: center; font-size: 12px; color: var(--text-3); }
footer a { color: var(--text-3); }
footer a:hover { color: var(--accent); }
footer .footer-links { margin-bottom: 8px; }
footer .footer-links a { margin: 0 10px; }

/* --- Mobile --- */
@media (max-width: 768px) {
    .shell { padding: 14px 12px 40px; }
    .hdr h1 { font-size: 20px; }
    .hdr-row { flex-direction: column; gap: 8px; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .filters { flex-direction: column; align-items: stretch; }
    .search-box { max-width: 100%; }
    .tbl { display: block; overflow-x: auto; }
    .nl-grid { grid-template-columns: 1fr; }
    .bar-label { width: 100px; font-size: 11px; }
    .opp-grid { grid-template-columns: 1fr; }
    .setup-banner { flex-direction: column; text-align: center; }
    .modal { max-width: 100%; }
    .modal-row, .modal-row-3 { grid-template-columns: 1fr; }
    .ad-type-item { grid-template-columns: 1fr 70px 1fr 28px; }
    .similar-nl-grid { grid-template-columns: 1fr; }
    .industry-fit-grid { grid-template-columns: 1fr; }
}

/* --- Skeleton loaders --- */
@keyframes skeleton-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.8; } }
.skeleton { background: var(--surface-2); border-radius: var(--radius); animation: skeleton-pulse 1.5s ease-in-out infinite; }
.skeleton-card { height: 80px; margin-bottom: 12px; border-radius: var(--radius-lg); }
.skeleton-text { height: 14px; margin-bottom: 8px; border-radius: 4px; }
.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 65%; }

/* --- Touch targets --- */
.fb-btn { min-width: 36px; min-height: 36px; padding: 6px 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; }
.modal-close { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.copy-btn { min-height: 36px; padding: 8px 12px; }
.tab { min-height: 44px; }

/* --- Layered shadows --- */
.kpi { box-shadow: var(--shadow-sm); }
.nl-card { box-shadow: var(--shadow-sm); }
.nl-card:hover { box-shadow: var(--shadow-md); }
.opp-card { box-shadow: var(--shadow-sm); }
.signal-card { box-shadow: var(--shadow-sm); }
.modal { box-shadow: var(--shadow-lg); }

/* --- Button active states --- */
.btn-sm:active, .tab:active, .fb-btn:active, .btn-primary:active, .btn-config:active { transform: scale(0.97); }
.btn-sm, .fb-btn, .btn-primary, .btn-config {
    transition: transform 150ms ease, background 150ms ease, color 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

/* --- Detail row expand --- */
.detail-panel-wrap { max-height: 0; overflow: hidden; transition: max-height 220ms ease-out; }
.detail-row.open .detail-panel-wrap { max-height: 600px; }

/* --- Tabular figures --- */
.bar-val, .detail-stat-val, .op-kpi-val { font-variant-numeric: tabular-nums; }

/* --- Accessibility --- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
