:root { --ink:#172033; --muted:#64748b; --accent:#4f46e5; --line:#e2e8f0; --paper:#fff; }
* { box-sizing:border-box; }
body { margin:0; color:var(--ink); background:linear-gradient(150deg,#eef2ff 0,#f8fafc 42%,#eff6ff 100%); font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; line-height:1.5; min-height:100vh; }
h1 { line-height:1.15; letter-spacing:-.035em; }
.page-shell { max-width:1000px; margin:auto; padding:clamp(24px,5vw,64px) 24px; }
.eyebrow { color:var(--accent); font-size:.75rem; font-weight:750; letter-spacing:.14em; text-transform:uppercase; }
.muted { color:var(--muted); }
.panel { border:1px solid var(--line); border-radius:20px; background:var(--paper); padding:clamp(20px,4vw,36px); box-shadow:0 16px 48px #17203309; }
label { display:block; font-weight:600; font-size:.9rem; }
input,select,textarea { max-width:100%; font:inherit; color:var(--ink); }
input:not([type=hidden]),textarea,select { width:100%; border:1px solid #cbd5e1; border-radius:10px; padding:12px 14px; background:#fff; margin-top:7px; }
input:disabled { background:#f1f5f9; color:#475569; }
button,.button { display:inline-flex; align-items:center; justify-content:center; min-height:44px; padding:11px 18px; border:1px solid var(--accent); border-radius:10px; color:white; background:var(--accent); font:inherit; font-size:.9rem; font-weight:650; cursor:pointer; text-decoration:none; }
button:hover,.button:hover { background:#3730a3; color:white; }
:is(input,select,textarea,button,a,summary):focus-visible { outline:3px solid #6366f1; outline-offset:3px; }
.button.secondary { background:white; color:var(--accent); }
.auth-layout { min-height:100vh; max-width:1180px; margin:auto; padding:48px 28px; display:grid; grid-template-columns:1.25fr 1fr; align-items:center; gap:clamp(36px,7vw,100px); }
.auth-intro h1 { font-size:clamp(2.4rem,4.5vw,4rem); margin:20px 0; max-width:650px; }
.auth-intro p { color:var(--muted); max-width:530px; font-size:1.1rem; }
.brand-mark { width:52px; height:52px; border-radius:16px; background:var(--accent); color:white; display:grid; place-items:center; margin-bottom:30px; box-shadow:0 8px 24px #4f46e52b; }
.auth-form h2 { margin:0 0 6px; font-size:1.5rem; }
.auth-form label { margin-top:22px; }
.auth-form button { width:100%; margin-top:26px; }
.error { background:#fff1f2; border:1px solid #fecdd3; border-radius:10px; padding:12px; color:#9f1239; margin-top:16px; }
.setup-form { margin-top:28px; }
.setup-form > label { margin-bottom:24px; }
.competitor-row { border:1px solid var(--line); background:#f8fafc; padding:16px; border-radius:12px; margin-bottom:12px; }
.competitor-fields { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.25fr) 115px; align-items:end; gap:16px; }
.competitor-fields label { margin:0; min-width:0; }
.competitor-fields .remove-competitor { height:48px; background:white; border-color:#fecaca; color:#b91c1c; }
.setup-actions { display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-top:24px; }
.dashboard .flex { flex-wrap:wrap; align-items:end; }
.dashboard .kpi { min-width:0; overflow:visible; }
.kpi-grid { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:16px; margin:22px 0; }
.kpi-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:.85rem; }
.metric-info { position:relative; display:inline-flex; }
.metric-info button { background:#eef2ff; color:#4338ca; border:1px solid #c7d2fe; border-radius:50%; padding:0; width:24px; height:24px; min-height:24px; font:600 14px Georgia,serif; box-shadow:none; }
.metric-info [role=tooltip] { position:absolute; width:clamp(130px,18vw,260px); max-width:70vw; bottom:100%; right:0; padding:12px; border-radius:10px; background:#172033; color:white; box-shadow:0 8px 24px #17203333; font:400 .8rem/1.5 "Segoe UI",sans-serif; opacity:0; visibility:hidden; z-index:20; }
.metric-info:hover [role=tooltip],.metric-info:focus-within [role=tooltip] { opacity:1; visibility:visible; }
.metric-info.dismissed [role=tooltip] { opacity:0; visibility:hidden; }
.dashboard .kpi strong { overflow-wrap:anywhere; font-size:clamp(1rem,2.2vw,1.85rem); }
.engine-section { padding:20px 0; border-bottom:1px solid var(--line); }
.engine-section h4 { font-size:1.1rem; color:#4338ca; margin:0 0 16px; }
.empty-state { padding:20px; color:var(--muted); background:#f8fafc; border:1px solid var(--line); border-radius:10px; }
.dashboard .tab-content { overflow-x:auto; }
.trends-heading { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:24px; margin-bottom:24px; }
.trends-heading h1 { margin:10px 0; }
.trend-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:24px; }
.trend-card h2 { font-size:1.1rem; margin:0 0 20px; }
.trend-canvas { position:relative; height:300px; }
.trend-card:last-child { grid-column:1/-1; }
.trend-table { width:100%; border-collapse:collapse; font-size:.85rem; }
.trend-table th,.trend-table td { padding:8px; border-bottom:1px solid var(--line); text-align:left; }
@media(max-width:1000px) { .kpi-grid { grid-template-columns:repeat(3,minmax(0,1fr)); } }
@media(max-width:720px) {
  .auth-layout { grid-template-columns:1fr; gap:28px; padding:32px 20px; }
  .brand-mark { margin-bottom:16px; }
  .auth-intro h1 { font-size:2.25rem; }
  .competitor-fields,.trend-grid { grid-template-columns:1fr; }
  .competitor-fields .remove-competitor { justify-self:start; }
  .trend-card:last-child { grid-column:auto; }
  .kpi-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .dashboard { padding:20px 14px; }
}
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { transition:none!important; animation:none!important; } }

[hidden] { display:none!important; }

.metric-info button:hover { transform:none; }

/* Opportunities keep the dashboard palette with distinct engine grouping. */
#opportunities table, #opp2Table, #priorityTable { min-width: 620px; }
#opportunities, #opportunities-optimizer { overflow-x: auto; }
#opportunities thead th, #opp2Table thead th { background: #eef2ff; color: #334155; font-size: .8rem; letter-spacing: .025em; }
#opportunities .engine-heading th, #opp2Table .engine-heading th { background: #312e81; color: white; padding: 14px 18px; font-weight: 700; border-top: 12px solid #fff; text-align: left; }
#opportunities td, #opp2Table td { padding: 14px 18px; line-height: 1.5; vertical-align: top; }
.visibility-score { margin: 24px 0; padding: 24px; }
.score-scale { position: relative; height: 18px; margin: 28px 8px 16px; border-radius: 8px; background: linear-gradient(to right,#7f1d1d 0% 1%,#dc2626 1% 20%,#ea580c 20% 40%,#eab308 40% 60%,#2563eb 60% 80%,#15803d 80% 100%); }
.score-marker { position: absolute; top: -7px; height: 32px; width: 4px; background: #111827; transform: translateX(-50%); border: 1px solid white; }
.score-legend { font-size: .85rem; color: #475569; }
#priorityTable td { vertical-align: top; white-space: normal; overflow-wrap: anywhere; }

.score-heading-row { display: flex; align-items: center; gap: .5rem; }
.score-heading-row h2 { margin: 0; }
.score-info-button { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 1px solid #c7d2fe; border-radius: 50%; background: #eef2ff; color: #3730a3; font-size: 1rem; cursor: pointer; }
.score-info-button:focus-visible, .score-methodology-panel:focus-visible { outline: 3px solid #6366f1; outline-offset: 3px; }
.score-methodology-panel { box-sizing: border-box; width: 100%; max-width: 760px; max-height: min(60vh, 420px); overflow-y: auto; overflow-wrap: anywhere; overscroll-behavior: contain; margin: 12px 0; padding: 16px 20px; border: 1px solid #c7d2fe; border-radius: 10px; background: #f8faff; color: #334155; font-size: .9rem; line-height: 1.6; }
.score-methodology-panel[hidden] { display: none; }
.score-methodology-panel p:first-child { margin-top: 0; }

/* Distinguish eligible-prompt visibility from the unchanged full-base comparison. */
.score-cards { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; margin-top:20px; }
.score-card { min-width:0; padding:24px; border:1px solid #dce4ef; border-radius:16px; background:#fff; }
.score-card.overall-card { background:linear-gradient(145deg,#f0f6ff,#fff 70%); border-color:#bed3f5; }
.score-eyebrow { margin:0 0 12px; text-transform:uppercase; letter-spacing:.09em; font-size:.75rem; font-weight:700; color:#475569; }
.score-value { display:flex; align-items:baseline; gap:7px; font-size:clamp(2.6rem,4vw,4rem); font-weight:750; line-height:1.15; letter-spacing:-.04em; color:#0f172a; }
.score-value small { font-size:1rem; font-weight:500; letter-spacing:0; color:#64748b; }
.score-grade { display:inline-block; margin-top:12px; padding:4px 12px; border:1px solid #e2e8f0; border-radius:999px; font-size:.85rem; font-weight:700; background:#fff; }
.score-coverage { margin:22px 0 12px; line-height:1.6; }
.coverage-chips { display:flex; gap:8px; flex-wrap:wrap; }
.coverage-chips span { padding:6px 10px; border-radius:7px; background:#eaf0f8; color:#334155; font-size:.8rem; }
.comparison-list { display:grid; gap:13px; margin:22px 0; }
.comparison-row { display:grid; grid-template-columns:minmax(80px,1fr) minmax(50px,1.4fr) 42px; align-items:center; gap:12px; font-size:.85rem; }
.comparison-row > span { overflow-wrap:anywhere; }
.comparison-row > strong { text-align:right; }
.comparison-track { height:7px; border-radius:8px; background:#eef2f7; overflow:hidden; }
.comparison-track > div { height:100%; border-radius:8px; }
.comparison-summary { padding-top:15px; border-top:1px solid #e2e8f0; font-size:.88rem; }
.score-details { border-top:1px solid #e2e8f0; padding-top:15px; line-height:1.7; }
.score-details summary { cursor:pointer; font-weight:600; }
.priority-actions { display:flex; gap:10px; flex-wrap:wrap; margin:18px 0; }
#priorityTable { min-width:1100px; }
#priorityTable th { white-space:nowrap; }
#priorityTable td { vertical-align:top; line-height:1.6; overflow-wrap:anywhere; }
#priorityTable td:nth-child(2) { min-width:180px; }
#priorityTable td:nth-child(6) { min-width:280px; }
#priorityTable td:nth-child(4), #priorityTable td:nth-child(5) { min-width:160px; max-width:220px; }
@media (max-width:850px) { .score-cards { grid-template-columns:1fr; } .score-card { padding:18px; } }
