/* ── DWH Brand Variables ─────────────────────────────────────────── */
:root {
  --dark:    #0D1B2A;
  --blue:    #2563EB;
  --blue2:   #5BA1D3;
  --blue-lt: #EFF6FF;
  --white:   #fff;
  --muted:   #6B7280;
  --border:  #E2E8F0;
  --bg:      #F8FAFC;
  --tof:     #6366F1;
  --mof:     #0EA5E9;
  --bof:     #10B981;
  --tof-lt:  #EEF2FF;
  --mof-lt:  #E0F7FF;
  --bof-lt:  #D1FAE5;
}

/* ── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif; background: var(--bg); color: var(--dark); font-size: 15px; line-height: 1.6; }
a { color: inherit; }

/* ── Layout ──────────────────────────────────────────────────────── */
.site-header { background: var(--dark); color: white; padding: 13px 32px; display: flex; align-items: center; justify-content: space-between; }
.brand { font-weight: 800; font-size: 1em; letter-spacing: -0.3px; }
.brand span { color: var(--blue2); }
.header-nav a { color: #94A3B8; font-size: 0.85em; text-decoration: none; margin-left: 16px; }
.header-nav a:hover { color: white; }
.powered { font-size: 0.78em; color: #64748B; }
.container { max-width: 1180px; margin: 0 auto; padding: 28px 24px; }
.site-footer { text-align: center; padding: 28px; font-size: 0.82em; color: var(--muted); border-top: 1px solid var(--border); margin-top: 40px; }
.site-footer a { color: var(--blue); text-decoration: none; }

/* ── Cards ───────────────────────────────────────────────────────── */
.card { background: white; border: 1px solid var(--border); border-radius: 12px; padding: 22px 26px; margin-bottom: 18px; }
.card-title { font-size: 1.02em; font-weight: 700; margin-bottom: 3px; }
.card-subtitle { font-size: 0.83em; color: var(--muted); margin-bottom: 18px; }

/* ── Report Header ───────────────────────────────────────────────── */
.report-header { background: white; border: 1px solid var(--border); border-radius: 12px; padding: 22px 26px; margin-bottom: 18px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.report-header h1 { font-size: 1.65em; font-weight: 800; letter-spacing: -0.5px; }
.domain { color: var(--blue); font-size: 0.88em; text-decoration: none; display: block; margin-top: 3px; }
.scanned { color: var(--muted); font-size: 0.8em; margin-top: 6px; }
.score-badge { background: var(--blue); color: white; border-radius: 12px; padding: 16px 22px; text-align: center; min-width: 100px; flex-shrink: 0; }
.score-badge .num { font-size: 2.6em; font-weight: 900; line-height: 1; display: block; }
.score-badge .denom { font-size: 0.9em; opacity: 0.7; }
.score-badge .label { font-size: 0.68em; opacity: 0.85; margin-top: 4px; display: block; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Funnel Stages ───────────────────────────────────────────────── */
.funnel-stages { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 18px; }
.funnel-stage { border-radius: 10px; padding: 16px 18px; }
.stage-tof { background: var(--tof-lt); border: 1.5px solid #A5B4FC; }
.stage-mof { background: var(--mof-lt); border: 1.5px solid #7DD3FC; }
.stage-bof { background: var(--bof-lt); border: 1.5px solid #6EE7B7; }
.funnel-stage-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; }
.funnel-stage-name { font-weight: 700; font-size: 0.88em; line-height: 1.3; }
.funnel-stage-name small { display: block; font-weight: 400; font-size: 0.82em; color: #374151; margin-top: 2px; }
.funnel-pct { font-size: 2em; font-weight: 900; line-height: 1; }
.stage-tof .funnel-pct { color: var(--tof); }
.stage-mof .funnel-pct { color: #0369A1; }
.stage-bof .funnel-pct { color: #065F46; }
.funnel-sub { font-size: 0.76em; color: #374151; margin-top: 2px; }
.funnel-engine-row { display: flex; gap: 6px; margin-top: 10px; }
.eng-chip { flex: 1; background: rgba(255,255,255,0.7); border-radius: 7px; padding: 6px 6px; text-align: center; font-size: 0.74em; }
.eng-name { color: var(--muted); font-size: 0.88em; }
.eng-score { font-weight: 800; font-size: 1.1em; color: var(--dark); }

/* Funnel pills */
.funnel-pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 0.75em; font-weight: 700; letter-spacing: 0.3px; }
.pill-tof { background: var(--tof-lt); color: var(--tof); }
.pill-mof { background: var(--mof-lt); color: #0369A1; }
.pill-bof { background: var(--bof-lt); color: #065F46; }

/* Funnel prompts table */
.funnel-table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
.funnel-table th { background: #F1F5F9; padding: 9px 13px; text-align: left; font-size: 0.76em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); border-bottom: 1px solid var(--border); }
.funnel-table td { padding: 10px 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.funnel-table tr:last-child td { border-bottom: none; }
.funnel-table tr:hover td { background: var(--blue-lt); }
.prompt-text { font-weight: 500; }
.score-chip { display: inline-block; min-width: 32px; text-align: center; padding: 2px 8px; border-radius: 6px; font-weight: 700; font-size: 0.88em; }
.chip-high { background: #DCFCE7; color: #15803D; }
.chip-mid  { background: #FEF9C3; color: #92400E; }
.chip-low  { background: #FEE2E2; color: #DC2626; }
.chip-zero { background: #F1F5F9; color: #94A3B8; }
.chip-none { background: #F8FAFC; color: #CBD5E1; }

/* ── Zone Grid ───────────────────────────────────────────────────── */
.zone-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.zone { border-radius: 10px; padding: 18px 20px; transition: transform 0.15s; }
.zone:hover { transform: translateY(-2px); }
.zone-priority { background: #DCFCE7; border: 1.5px solid #86EFAC; }
.zone-create   { background: #FEF9C3; border: 1.5px solid #FDE047; }
.zone-gap      { background: #FEE2E2; border: 1.5px solid #FCA5A5; }
.zone-monitor  { background: #DBEAFE; border: 1.5px solid #93C5FD; }
.zone-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.zone-label { font-weight: 700; font-size: 0.9em; }
.zone-count { font-size: 2.4em; font-weight: 900; line-height: 1; }
.zone-priority .zone-count { color: #15803D; }
.zone-create   .zone-count { color: #92400E; }
.zone-gap      .zone-count { color: #DC2626; }
.zone-monitor  .zone-count { color: #1D4ED8; }
.zone-desc { font-size: 0.8em; color: #374151; margin-top: 4px; }
.zone-chips { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.zone-chip { font-size: 0.72em; padding: 2px 8px; border-radius: 20px; background: rgba(255,255,255,0.7); color: #374151; font-weight: 500; }

/* ── Recommendations Table ───────────────────────────────────────── */
.rec-table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
.rec-table th { background: var(--dark); color: white; padding: 10px 13px; text-align: left; font-size: 0.76em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.rec-table th:first-child { border-radius: 6px 0 0 6px; }
.rec-table th:last-child  { border-radius: 0 6px 6px 0; }
.rec-table td { padding: 11px 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.rec-table tr:hover td { background: var(--blue-lt); }
.score-cell { display: flex; align-items: center; gap: 6px; }
.mini-bar-wrap { width: 48px; height: 5px; background: var(--border); border-radius: 3px; flex-shrink: 0; }
.mini-bar { height: 100%; border-radius: 3px; background: var(--blue); }
.priority-num { font-size: 1.1em; font-weight: 800; }
.why-text { color: var(--muted); font-size: 0.8em; max-width: 260px; }

/* ── Competitor SOV ──────────────────────────────────────────────── */
.sov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sov-panel { border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; }
.sov-panel h4 { font-size: 0.9em; font-weight: 700; margin-bottom: 3px; }
.sov-sub { font-size: 0.78em; color: var(--muted); margin-bottom: 14px; }
.sov-bars { display: flex; flex-direction: column; gap: 9px; }
.sov-row { display: flex; align-items: center; gap: 10px; font-size: 0.83em; }
.sov-name { width: 170px; flex-shrink: 0; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.sov-track { flex: 1; height: 9px; background: var(--border); border-radius: 5px; }
.sov-fill { height: 100%; border-radius: 5px; }
.fill-you  { background: var(--blue); }
.fill-comp { background: #CBD5E1; }
.sov-pct { width: 40px; text-align: right; font-weight: 700; font-size: 0.88em; color: var(--muted); }
.sov-pct-you { color: var(--blue); }
.you-tag { font-size: 0.7em; background: var(--blue); color: white; padding: 1px 6px; border-radius: 10px; }
.funnel-sov-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.fsov-col { border-radius: 8px; padding: 10px 12px; }
.fsov-tof { background: var(--tof-lt); }
.fsov-mof { background: var(--mof-lt); }
.fsov-bof { background: var(--bof-lt); }
.fsov-label { font-size: 0.7em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 7px; }
.fsov-rows { display: flex; flex-direction: column; gap: 5px; }
.fsov-row { display: flex; justify-content: space-between; font-size: 0.8em; align-items: center; }
.fsov-name { font-weight: 500; }
.fsov-score { font-weight: 700; color: var(--muted); }
.fsov-you .fsov-score { color: var(--blue); }

/* ── Keyword difficulty badges ───────────────────────────────────── */
.kd-badge { display:inline-block;padding:2px 7px;border-radius:5px;font-size:0.78em;font-weight:700; }
.kd-easy   { background:#DCFCE7;color:#15803D; }
.kd-medium { background:#FEF9C3;color:#92400E; }
.kd-hard   { background:#FEE2E2;color:#DC2626; }

/* ── Report Footer ───────────────────────────────────────────────── */
.report-footer { text-align: center; padding: 28px 0 12px; font-size: 0.8em; color: var(--muted); border-top: 1px solid var(--border); margin-top: 4px; }
.report-footer a { color: var(--blue); text-decoration: none; }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 0.76em; font-weight: 700; white-space: nowrap; }
.badge-priority, .badge-complete { background: #DCFCE7; color: #15803D; }
.badge-create                    { background: #FEF9C3; color: #92400E; }
.badge-gap, .badge-failed        { background: #FEE2E2; color: #DC2626; }
.badge-monitor                   { background: #DBEAFE; color: #1D4ED8; }
.badge-pending                   { background: #FEF9C3; color: #92400E; }
.badge-running                   { background: #DBEAFE; color: #1D4ED8; }
.badge-none                      { background: #F1F5F9; color: #94A3B8; }

/* ── Admin ───────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }
.stat-card .stat-num { font-size: 1.9em; font-weight: 900; line-height: 1; }
.stat-card .stat-label { font-size: 0.76em; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.5px; }
.admin-page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.admin-page-header h1 { font-size: 1.35em; font-weight: 800; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86em; background: white; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.data-table th { background: #F1F5F9; padding: 10px 14px; text-align: left; font-size: 0.76em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); border-bottom: 1px solid var(--border); }
.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--blue-lt); }
.scan-score { font-size: 1.2em; font-weight: 900; color: var(--blue); }
.action-row { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }

/* Story tracker */
.story-group { margin-bottom: 24px; }
.story-date-header { font-size: 1em; font-weight: 700; color: var(--muted); padding: 8px 0 10px; border-bottom: 2px solid var(--border); margin-bottom: 8px; }
.status-select { padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border); font-size: 0.82em; font-weight: 600; background: white; cursor: pointer; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 8px 16px; border-radius: 7px; border: 1px solid var(--border); background: white; font-size: 0.86em; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--dark); }
.btn:hover { background: var(--blue-lt); }
.btn-primary { background: var(--blue); color: white; border-color: var(--blue); }
.btn-primary:hover { background: #1D4ED8; }
.btn-sm { padding: 4px 10px; font-size: 0.78em; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Forms ───────────────────────────────────────────────────────── */
label { display: block; font-size: 0.88em; font-weight: 600; margin-bottom: 12px; }
label input, label textarea, label select { display: block; width: 100%; margin-top: 4px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 0.95em; font-family: inherit; }
label textarea { resize: vertical; }

/* ── Login ───────────────────────────────────────────────────────── */
.login-box { max-width: 360px; margin: 60px auto; background: white; padding: 32px; border-radius: 12px; border: 1px solid var(--border); }
.login-box h1 { margin-bottom: 22px; font-size: 1.35em; }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-box { background: white; border-radius: 12px; padding: 28px; width: 440px; max-width: 95vw; }
.modal-box h2 { margin-bottom: 20px; font-size: 1.1em; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 0.88em; margin-bottom: 16px; }
.alert-success { background: #DCFCE7; color: #15803D; }
.alert-error   { background: #FEE2E2; color: #DC2626; }
.alert-notice  { background: #DBEAFE; color: #1D4ED8; }

/* ── Utilities ───────────────────────────────────────────────────── */
.muted    { color: var(--muted); font-size: 0.85em; }
.log-box  { background: #0F172A; color: #E2E8F0; padding: 16px; border-radius: 8px; font-size: 0.8em; line-height: 1.8; white-space: pre-wrap; overflow-x: auto; }

/* ── Settings Page ───────────────────────────────────────────────── */
.settings-notice { background: var(--blue-lt); border: 1px solid #BFDBFE; border-radius: 8px; padding: 12px 16px; font-size: 0.85em; margin-bottom: 20px; color: #1E40AF; }
.settings-notice code { background: #DBEAFE; padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.settings-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.settings-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.settings-field { display: flex; flex-direction: column; }
.settings-field label { font-weight: 600; font-size: 0.88em; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.settings-field input, .settings-field select { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 0.9em; font-family: inherit; background: white; }
.settings-field input:focus, .settings-field select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px #DBEAFE; }
.settings-field-inline { display: flex; align-items: center; gap: 14px; }
.settings-field-inline label { white-space: nowrap; }
.settings-field-inline select { flex: 1; }
.field-hint { font-size: 0.76em; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.field-hint a { color: var(--blue); text-decoration: none; }
.key-set-badge { font-size: 0.72em; background: #DCFCE7; color: #15803D; padding: 2px 7px; border-radius: 20px; font-weight: 700; }
.key-tag-muted { font-size: 0.72em; background: #F1F5F9; color: #94A3B8; padding: 2px 7px; border-radius: 20px; font-weight: 600; }
.settings-subsection { background: #F8FAFC; border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; }
.settings-subsection-label { font-size: 0.78em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.settings-status-card { background: #FAFAFA; }
.settings-status-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; }
.status-check { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; display: flex; align-items: flex-start; gap: 10px; }
.status-check-icon { font-size: 1.1em; flex-shrink: 0; margin-top: 1px; }
.status-check-name { font-size: 0.88em; font-weight: 700; line-height: 1.3; }
.status-check-detail { font-size: 0.76em; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.check-ok { border-color: #BBF7D0; }
.check-missing { border-color: #FCA5A5; }
.settings-actions { display: flex; gap: 10px; align-items: center; padding-top: 4px; }

/* ── Scan review page ────────────────────────────────────────────── */
.review-tab-bar { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.review-tab-btn { background: none; border: none; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: 11px 22px; font-size: 0.88em; font-weight: 600; color: var(--muted); cursor: pointer; display: flex; align-items: center; gap: 8px; transition: color 0.15s, border-color 0.15s; white-space: nowrap; }
.review-tab-btn:hover { color: var(--dark); background: #F8FAFC; }
.review-tab-btn.active { color: var(--dark); font-weight: 700; }
.tab-count-pill { font-size: 0.72em; font-weight: 700; padding: 2px 8px; border-radius: 20px; background: var(--border); color: var(--muted); transition: background 0.15s, color 0.15s; }
.review-subgroup { border-top: 1px solid var(--border); }
.review-subgroup:first-child { border-top: none; }
.review-subgroup-local { background: #F8FAFC; }
.review-subgroup-general { background: white; }
.review-subgroup-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 4px; font-size: 0.78em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.review-subgroup-count { background: var(--border); color: var(--muted); font-size: 0.85em; padding: 1px 7px; border-radius: 20px; }
.review-tab-panel { display: none; }
.review-tab-panel.active { display: block; }
.review-query-row { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; border-bottom: 1px solid #F1F5F9; }
.review-query-row:last-child { border-bottom: none; }
.query-num { flex-shrink: 0; width: 24px; text-align: right; font-size: 0.75em; color: #CBD5E1; font-weight: 600; padding-top: 9px; }
.review-query-input { flex: 1; padding: 7px 10px; border: 1px solid transparent; border-radius: 6px; font-size: 0.88em; font-family: inherit; background: transparent; resize: none; overflow-y: hidden; overflow-x: hidden; line-height: 1.55; min-height: 34px; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; color: var(--dark); box-sizing: border-box; }
.review-query-input:hover { background: #F8FAFC; border-color: var(--border); }
.review-query-input:focus { outline: none; border-color: var(--blue); background: white; box-shadow: 0 0 0 3px #DBEAFE; }
.query-delete-btn { flex-shrink: 0; width: 28px; height: 28px; border: none; background: transparent; color: #CBD5E1; font-size: 1em; cursor: pointer; border-radius: 5px; display: flex; align-items: center; justify-content: center; margin-top: 3px; }
.query-delete-btn:hover { background: #FEE2E2; color: #DC2626; }
.new-query .review-query-input { background: #EFF6FF; border-color: #BFDBFE; }
.badge-awaiting_review { background: #FEF3C7; color: #92400E; }
.badge-approved { background: #DBEAFE; color: #1D4ED8; }

@media (max-width: 900px) {
  .settings-grid-3 { grid-template-columns: 1fr 1fr; }
  .settings-grid-2 { grid-template-columns: 1fr; }
  .settings-status-grid { grid-template-columns: 1fr 1fr; }
  .review-tab-bar { overflow-x: auto; }
}

/* ── Local visibility report card ────────────────────────────────── */
.local-vis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 4px; }
.local-vis-card { border: 1.5px solid transparent; border-radius: 10px; padding: 18px 20px; }
.local-vis-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.local-vis-pct { font-size: 2.8em; font-weight: 900; line-height: 1; }
.local-vis-bar-track { height: 6px; background: rgba(0,0,0,0.08); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.local-vis-bar-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }

@media (max-width: 700px) { .local-vis-grid { grid-template-columns: 1fr; } }

@media (max-width: 600px) {
  .settings-grid-3 { grid-template-columns: 1fr; }
  .review-tab-btn { padding: 8px 12px; font-size: 0.82em; }
}
