* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; font-size: 14px; background: #f5f5f5; color: #222; }

nav { background: #1a1a2e; padding: 0 24px; display: flex; gap: 4px; align-items: center; height: 46px; }
nav a { color: #bbb; text-decoration: none; font-weight: 500; font-size: 13px; padding: 6px 12px; border-radius: 4px; transition: background .15s, color .15s; }
nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
nav a.nav--active { color: #fff; background: rgba(255,255,255,.12); }
nav a.nav-logout { margin-left: auto; color: #f87171; }
nav a.nav-logout:hover { color: #fff; background: rgba(239,68,68,.3); }

.badge { background: #e53e3e; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; margin-left: 4px; }
.badge--empty { background: #555; }
.badge--inbound  { background: #0070f3; color: #fff; }
.badge--refined  { background: #7b2ff7; color: #fff; }
.badge--viewed   { background: #0e7490; color: #fff; cursor: default; }
.badge--followup { background: #d97706; color: #fff; }
.badge--reply    { background: #7c3aed; color: #fff; }
.badge--delivered{ background: #2563eb; color: #fff; }
.meta-tag        { font-size: 12px; color: #666; background: #f0f0f0; border-radius: 4px; padding: 1px 6px; }

.error-banner { background: #e53e3e; color: #fff; padding: 10px 20px; text-align: center; }

main { padding: 20px; max-width: 1200px; margin: 0 auto; }
h1 { margin-bottom: 16px; font-size: 20px; }

.card { background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 16px; margin-bottom: 12px; }
.card__meta { display: flex; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.card__meta strong { font-size: 16px; }
.card__screenshots img { max-width: 100%; border: 1px solid #ddd; border-radius: 4px; }
.card__actions { display: flex; gap: 8px; margin-top: 12px; }

button { padding: 7px 16px; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; }
.card__actions button { background: #2d6a4f; color: #fff; }

.score { font-weight: 600; color: #2d6a4f; }
.subject { font-style: italic; color: #555; }
.email-body { background: #f9f9f9; border: 1px solid #eee; padding: 10px; white-space: pre-wrap; margin: 8px 0; font-size: 13px; }

.empty { color: #888; padding: 20px 0; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th { background: #f0f0f0; padding: 8px; text-align: left; border-bottom: 2px solid #ddd; }
td { padding: 7px 8px; border-bottom: 1px solid #eee; }
.log--error td { color: #c1121f; }
.log--warning td { color: #b7791f; }

/* Score badge variants */
.score--high { color: #2d6a4f; font-weight: 600; }
.score--mid  { color: #b7791f; font-weight: 600; }
.score--low  { color: #c1121f; font-weight: 600; }

/* Screenshots */
.screenshot--desktop { width: 100%; border: 1px solid #ddd; border-radius: 4px; display: block; cursor: pointer; }
.screenshot--mobile  { max-width: 390px; max-height: 700px; object-fit: cover; object-position: top; border: 1px solid #ddd; border-radius: 4px; margin-top: 8px; cursor: pointer; }
.screenshot--desktop { cursor: pointer; }
.mobile-toggle { margin-top: 8px; }
.mobile-toggle summary { cursor: pointer; color: #555; font-size: 13px; }

/* HTML alternative link */
.alt-link { font-size: 12px; color: #4a6fa5; text-decoration: none; }
.alt-link:hover { text-decoration: underline; }

/* Reject button */
.btn--reject { background: #c1121f; color: #fff; }

/* Adjust form */
.adjust-form { display: inline-block; }
.adjust-form summary { list-style: none; }
.adjust-form summary::-webkit-details-marker { display: none; }
.btn--adjust { background: #4a6fa5; color: #fff; padding: 7px 16px; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; }
.adjust-form textarea { display: block; margin-top: 8px; width: 100%; min-width: 300px; padding: 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; resize: vertical; }
.adjust-form button[type="submit"] { margin-top: 6px; background: #4a6fa5; color: #fff; }

/* Confirmation card */
.card--confirm { border-color: #b7791f; background: #fffbeb; }
.card--confirm p { margin-bottom: 12px; }
.btn--cancel { background: #718096; color: #fff; }

/* Gate 2 mockup thumbnail */
.card__thumbnail { margin-bottom: 12px; }
.thumbnail { max-width: 200px; border: 1px solid #ddd; border-radius: 4px; display: block; }

/* Gate 2 inline edit form */
.email-edit-form { margin-top: 8px; }
.field-label { display: block; font-size: 12px; color: #555; margin-top: 8px; margin-bottom: 3px; font-weight: 500; }
.input-subject { width: 100%; padding: 7px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; }
.textarea-body { width: 100%; padding: 7px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; resize: vertical; font-family: inherit; }

/* Drafts page */
.card-header { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.meta { color: #555; font-size: 12px; }
.card-body { margin-bottom: 8px; }
.draft-body { background: #f9f9f9; border: 1px solid #eee; padding: 10px; white-space: pre-wrap; margin-top: 6px; font-size: 13px; font-family: inherit; border-radius: 4px; }
.card-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn { padding: 7px 16px; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; color: #fff; }
.btn--primary { background: #2d6a4f; }
.btn--danger { background: #c1121f; }
.empty-state { color: #888; padding: 20px 0; }

.badge--success { background: #2d6a4f; }
.warning { color: #b7791f; margin-top: 8px; font-size: 13px; }
.card--converted { border-color: #c6f6d5; }

.btn--success { background: #276749; color: #fff; }
.card--success { border-color: #9ae6b4; background: #f0fff4; }
.card--success a { color: #276749; }

/* ---- Global inputs / buttons ---- */
.form-input  { width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 5px; font-size: 13px; outline: none; transition: border-color .15s; }
.form-input:focus  { border-color: #4a6fa5; }
.form-select { width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 5px; font-size: 13px; background: #fff; outline: none; transition: border-color .15s; }
.form-select:focus { border-color: #4a6fa5; }
.form-row  { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.btn--secondary { background: #4a6fa5; color: #fff; }
.btn--ghost     { background: #eee; color: #333; }

/* ---- Toast ---- */
.toast        { padding: 9px 14px; border-radius: 5px; font-size: 13px; }
.toast--success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.toast--error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.badge--warning { background: #b7791f; }
.badge--error   { background: #c1121f; }

/* ---- Page header ---- */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 22px; color: #1a1a2e; }

/* ---- KPI row ---- */
.kpi-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.kpi-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px 22px; min-width: 130px; flex: 0 0 auto; }
.kpi-card--primary { border-left: 4px solid #1a1a2e; }
.kpi-number { font-size: 32px; font-weight: 700; color: #1a1a2e; line-height: 1; }
.kpi-unit   { font-size: 18px; font-weight: 500; }
.kpi-label  { font-size: 11px; color: #888; margin-top: 4px; text-transform: uppercase; letter-spacing: .05em; }

/* ---- Status breakdown strip ---- */
.status-breakdown { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.status-chip { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid #e2e8f0; border-radius: 20px; padding: 4px 10px 4px 8px; }
.status-chip__count { font-size: 13px; font-weight: 700; color: #1a1a2e; min-width: 18px; text-align: center; }

/* ---- Dashboard 2-col grid ---- */
.dash-grid { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 780px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-card { padding: 20px; }
.dash-card--wide { }

/* Card title row */
.card-title { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; color: #1a1a2e; margin-bottom: 16px; }
.card-title svg { color: #4a6fa5; flex-shrink: 0; }

/* ---- Scrape form ---- */
.scrape-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
.spinner-text { color: #888; font-size: 12px; }
.btn[disabled], .btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Activity table ---- */
.activity-table { width: 100%; border-collapse: collapse; }
.activity-table tr { border-bottom: 1px solid #f0f0f0; }
.activity-table tr:last-child { border-bottom: none; }
.activity-table td { padding: 7px 8px; vertical-align: top; }
.activity-time { font-size: 12px; font-weight: 500; color: #333; white-space: nowrap; }
.activity-date { font-size: 10px; color: #aaa; font-weight: 400; }
.activity-msg  { font-size: 13px; }
.stage-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #e2e8f0; color: #4a5568; white-space: nowrap; }
.stage--enrich  { background: #c6f6d5; color: #276749; }
.stage--scrape  { background: #bee3f8; color: #2c5282; }
.stage--score_mockup { background: #e9d8fd; color: #553c9a; }
.stage--generate_mockup { background: #fefcbf; color: #744210; }
.stage--generate_mockup_html { background: #fbd38d; color: #744210; }
.stage--compose_email { background: #bee3f8; color: #2c5282; }
.stage--gate1_approve, .stage--gate1_reject, .stage--gate1_adjust { background: #fed7d7; color: #822727; }
.stage--manual { background: #e2e8f0; color: #4a5568; }

/* ---- Activity log link ---- */
.log-link { color: #4a6fa5; text-decoration: none; }
.log-link:hover { text-decoration: underline; }
.badge--stage { background: #e0e0e0; color: #333; font-size: 11px; }

/* ---- Filter bar ---- */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- Leads table ---- */
.leads-table tbody tr.leads-row { cursor: pointer; }
.leads-table tbody tr.leads-row:hover { background: #f0f4ff; }

/* ---- Status badges ---- */
.status-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; background: #e0e0e0; color: #333; }
.status--raw { background: #e2e8f0; color: #4a5568; }
.status--verified { background: #bee3f8; color: #2c5282; }
.status--enriched { background: #c6f6d5; color: #276749; }
.status--classified { background: #e9d8fd; color: #553c9a; }
.status--mockup_pending { background: #fefcbf; color: #744210; }
.status--mockup_approved { background: #c6f6d5; color: #22543d; }
.status--message_pending { background: #fbd38d; color: #744210; }
.status--message_approved { background: #c6f6d5; color: #22543d; }
.status--sent { background: #bee3f8; color: #2c5282; }
.status--replied { background: #d6bcfa; color: #553c9a; }
.status--converted { background: #9ae6b4; color: #22543d; font-weight: 700; }
.status--rejected { background: #fed7d7; color: #822727; }
.status--suppressed { background: #eee; color: #888; }
.status--pending-approval { background: #fbd38d; color: #744210; }
.status--approved { background: #c6f6d5; color: #276749; }
.status--pending-scoring { background: #e9d8fd; color: #553c9a; }

/* ---- Lead detail ---- */
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.detail-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: 340px 1fr; gap: 16px; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-left, .detail-right { display: flex; flex-direction: column; gap: 12px; }
.card-section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #555; margin-bottom: 10px; }

/* Info list */
.info-list { display: grid; grid-template-columns: 70px 1fr; gap: 4px 10px; font-size: 13px; }
.info-list dt { color: #888; font-weight: 500; }
.info-list dd { color: #222; }
.info-list a { color: #4a6fa5; text-decoration: none; }
.info-list a:hover { text-decoration: underline; }

/* Brand colors */
.color-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.color-swatch { display: inline-block; width: 28px; height: 28px; border-radius: 4px; border: 1px solid #ddd; }

/* Opening hours */
.hours-list { list-style: none; font-size: 13px; line-height: 1.8; }

/* Review tags */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.review-tag { background: #e9d8fd; color: #553c9a; padding: 3px 10px; border-radius: 12px; font-size: 12px; }
.tag-count { background: #553c9a; color: #fff; border-radius: 8px; padding: 0 5px; font-size: 11px; margin-left: 4px; }

/* Review snippets */
.review-snippet { border-left: 3px solid #ddd; padding: 6px 10px; margin-bottom: 8px; font-size: 13px; color: #555; font-style: italic; }

/* Mockup cards inside lead detail */
.mockup-card { border: 1px solid #eee; border-radius: 6px; padding: 12px; margin-bottom: 10px; }
.mockup-card__meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; }

/* Gate 2 send block */
.send-to { color: #4a6fa5; font-size: 13px; }
.section-title { font-size: 16px; font-weight: 600; margin: 20px 0 8px; color: #333; border-bottom: 2px solid #e2e8f0; padding-bottom: 6px; }
.section-hint { font-size: 13px; color: #666; margin-bottom: 12px; }
.card--ready { border-left: 3px solid #2d6a4f; }
.send-block { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.send-field { display: flex; align-items: center; gap: 8px; }
.send-value { font-family: monospace; font-size: 13px; background: #f7f7f7; padding: 3px 8px; border-radius: 4px; flex: 1; }
.btn-copy { background: none; border: 1px solid #ccc; border-radius: 4px; padding: 2px 8px; cursor: pointer; font-size: 13px; color: #555; }
.btn-copy:hover { background: #eee; }
.btn-copy-body { margin-bottom: 6px; background: #eee; border: 1px solid #ccc; border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.email-expand { margin: 8px 0; }
.email-expand summary { cursor: pointer; font-size: 13px; color: #4a6fa5; }
.email-expand summary::-webkit-details-marker { display: none; }
.email-body-block { margin-top: 8px; background: #f9f9f9; border: 1px solid #eee; border-radius: 4px; padding: 10px; }
.email-body-pre { white-space: pre-wrap; font-size: 13px; font-family: inherit; margin: 0; }

/* Gate 2 email preview/editor */
.email-tabs { display: flex; gap: 4px; margin-bottom: 0; border-bottom: 2px solid #e2e8f0; }
.tab-btn { background: none; border: none; padding: 7px 16px; font-size: 13px; cursor: pointer; color: #64748b; border-radius: 4px 4px 0 0; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab-btn--active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; background: #f0f7ff; }
.email-pane { border: 1px solid #e2e8f0; border-top: none; border-radius: 0 0 6px 6px; overflow: hidden; }
.email-iframe { width: 100%; height: 780px; border: none; display: block; background: #fff; }
.email-html-editor { width: 100%; padding: 10px; font-family: monospace; font-size: 12px; line-height: 1.5; border: none; resize: vertical; display: block; background: #1e1e2e; color: #cdd6f4; box-sizing: border-box; }
.editor-hint { margin: 0; padding: 6px 12px; font-size: 11px; color: #94a3b8; background: #f8fafc; border-top: 1px solid #e2e8f0; }

/* Sent page */
.meta-date { font-size: 12px; color: #888; }
.reply-form-wrap { margin-top: 8px; }
.reply-form-wrap > summary { font-size: 13px; }
.reply-form { background: #f9f9f9; border: 1px solid #eee; border-radius: 4px; padding: 10px; }
.action-result { display: block; padding: 8px 12px; border-radius: 4px; font-size: 13px; margin-top: 6px; }
.action-result--ok  { background: #f0fff4; color: #276749; border: 1px solid #9ae6b4; }
.action-result--err { background: #fff5f5; color: #822727; border: 1px solid #fed7d7; }

/* Recommendation badge */
.recommendation { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; margin-left: 6px; font-weight: 600; }
.recommendation--proceed { background: #fed7d7; color: #822727; }
.recommendation--review { background: #fbd38d; color: #744210; }
.recommendation--skip { background: #c6f6d5; color: #276749; }
