/* SearchSignal v2 — extends app.css. Reuses its CSS custom properties
   (--bg --card --ink --muted --brand --brand-dark --blue --green --yellow
   --red --purple --line --shadow --radius) with var(--x, #hex) fallbacks so
   this file still renders sanely if loaded standalone. app.css is always
   linked before this file, so identical selectors here win the cascade —
   nothing in app.css is edited or duplicated wholesale, only extended. */

/* ---------- Sidebar nav groups (v2 expanded sidebar) ---------- */
/* views2.js emits .nav-group / .nav-group-label; keep .sidebar-group aliases for safety. */
.sidebar { overflow-x: hidden; overflow-y: auto; }
.sidebar nav { display: flex; flex-direction: column; }
.nav-group, .sidebar-group { display: flex; flex-direction: column; margin-bottom: 14px; }
.nav-group-label, .sidebar-group-label {
  padding: 8px 22px 4px; font-size: 11px; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; color: var(--muted, #6b7a89);
}
.nav-group a, .sidebar-group a { display: block; width: 100%; box-sizing: border-box; }

/* ---------- Page header ---------- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.page-header h2 { margin: 0 0 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card, #fff); border: 1px solid var(--line, #e6eaf0); border-radius: var(--radius, 12px);
  padding: 12px 14px; margin-bottom: 16px;
}
.filter-bar label { font-size: 13px; font-weight: 600; color: var(--muted, #6b7a89); display: flex; align-items: center; gap: 6px; }

/* ---------- Forms (used by JS-injected fields across v2 pages) ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 10px 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink, #1a2733); }
.field input, .field select, .field textarea {
  font-weight: 400; font-family: inherit; font-size: 14.5px; padding: 9px 12px;
  border: 1.5px solid var(--line, #e6eaf0); border-radius: 8px; background: #fff; color: var(--ink, #1a2733);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand, #e8590c); }
.form-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0; }
.chip-check {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 500;
  background: var(--bg, #f7f8fa); border: 1px solid var(--line, #e6eaf0); border-radius: 999px; padding: 5px 12px; cursor: pointer;
}
.chip-check.block { display: flex; width: 100%; border-radius: 8px; }
select.schema-type-select { min-width: 200px; }
textarea.schema-json { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---------- Data-table sortable header affordance ---------- */
.data-table th.sortable { cursor: pointer; user-select: none; position: relative; padding-right: 20px; }
.data-table th.sortable:hover { color: var(--ink, #1a2733); }
.data-table th.sortable::after { content: '⇅'; position: absolute; right: 4px; opacity: .35; font-size: 11px; }
.data-table th.sort-asc::after { content: '↑'; opacity: 1; color: var(--brand, #e8590c); }
.data-table th.sort-desc::after { content: '↓'; opacity: 1; color: var(--brand, #e8590c); }
.empty-row { text-align: center; padding: 22px 12px !important; }

/* ---------- Chips (severity / status) ---------- */
.chip-critical { background: rgba(235, 87, 87, .14); color: #a92a2a; }
.chip-warning { background: rgba(224, 168, 0, .16); color: #7a5c00; }
.chip-notice { background: #eef1f5; color: var(--muted, #6b7a89); }
.chip-good { background: rgba(39, 174, 96, .14); color: #1e7e34; }

/* ---------- Score donut (compact, reuses app.css .donut-num/.donut-label look) ---------- */
.score-donut { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.score-donut svg { width: 56px; height: 56px; display: block; }
.score-donut .donut-num { font-size: 11px; font-weight: 700; fill: var(--ink, #1a2733); }
.score-donut .donut-label { font-size: 12px; font-weight: 600; color: var(--muted, #6b7a89); }

/* ---------- Sparkline ---------- */
.sparkline { width: 120px; height: 32px; display: block; }
.history-inline { display: flex; align-items: center; gap: 12px; padding: 10px 4px; }
.history-row td { background: var(--bg, #f7f8fa); }

/* ---------- Progress (long-running actions) ---------- */
.progress { padding: 18px 4px; }
.progress-bar { height: 8px; border-radius: 4px; background: #eef1f5; overflow: hidden; position: relative; }
.progress-fill.indeterminate {
  position: absolute; inset: 0; width: 40%; border-radius: 4px;
  background: linear-gradient(90deg, var(--brand, #e8590c), #f2925c);
  animation: ss2-indeterminate 1.3s ease-in-out infinite;
}
@keyframes ss2-indeterminate {
  0% { left: -40%; }
  100% { left: 100%; }
}
.progress-note { margin-top: 10px; font-size: 13.5px; }
.progress-timer { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink, #1a2733); }

/* ---------- kv (key/value definition list) ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 8px 0; font-size: 14px; }
.kv dt { color: var(--muted, #6b7a89); font-weight: 600; }
.kv dd { margin: 0; }

/* ---------- Empty state ---------- */
.empty { padding: 26px 16px; text-align: center; }
.empty p { margin: 0; }

/* ---------- Toast (variant not covered by app.css) ---------- */
.toast-success { background: var(--green, #27ae60); }

/* ---------- Grid / stat tiles ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 10px 0; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 10px 0; }
.stat {
  background: var(--card, #fff); border-radius: var(--radius, 12px); box-shadow: var(--shadow, 0 1px 3px rgba(16,30,54,.08));
  padding: 16px; text-align: center;
}
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted, #6b7a89); font-weight: 600; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--ink, #1a2733); }
.stat-change { font-size: 13px; font-weight: 700; color: var(--muted, #6b7a89); }
.stat-change.up { color: var(--green, #27ae60); }
.stat-change.down { color: var(--red, #eb5757); }

/* ---------- Markdown body (AI Writer output) ---------- */
.md-body { white-space: pre-wrap; font-size: 14.5px; line-height: 1.6; margin: 10px 0; }

/* ---------- Code block (generated schema JSON-LD) ---------- */
.code-block {
  background: #10161f; color: #d8e2ee; border-radius: 10px; padding: 14px 16px; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.5; margin: 10px 0;
}

/* ---------- Action cards (opportunities / agent top actions) ---------- */
.action-card {
  background: var(--bg, #f7f8fa); border: 1px solid var(--line, #e6eaf0); border-radius: 10px; padding: 14px;
}
.action-card p { margin: 6px 0 0; font-size: 13.5px; }

/* ---------- Agent steps timeline ---------- */
.steps-timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line, #e6eaf0); }
.steps-timeline li { padding: 8px 0 8px 16px; margin-left: -1px; border-left: 2px solid var(--line, #e6eaf0); font-size: 14px; }
.steps-timeline li.step-ok { border-left-color: var(--green, #27ae60); }
.steps-timeline li.step-fail { border-left-color: var(--red, #eb5757); }

/* ---------- Bars (horizontal bar list) ---------- */
.bars { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 50px; align-items: center; gap: 8px; font-size: 13px; }
.bar-row-label { color: var(--muted, #6b7a89); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row-track { height: 8px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.bar-row-fill { height: 100%; background: linear-gradient(90deg, var(--blue, #2f80ed), #6fb1f2); border-radius: 4px; }
.bar-row-value { text-align: right; font-weight: 600; }

/* ---------- Misc bits used by v2 JS ---------- */
.new-key-banner { border: 1.5px dashed var(--brand, #e8590c); background: #fff7ed; margin-bottom: 14px; }
.new-key-banner code { word-break: break-all; }
.btn-copy { margin-top: 4px; }

/* ---------- Print-only helper ---------- */
.print-only { display: none; }
@media print {
  .print-only { display: block; }
  .sidebar, .topbar, .page-actions, .progress, .form-actions, button { display: none !important; }
}

/* ---------- Responsive: sidebar becomes a horizontal scroll strip under 900px ---------- */
@media (max-width: 900px) {
  .sidebar {
    display: flex; flex-direction: row; position: static; width: auto; height: auto;
    flex-wrap: wrap; overflow: visible;
    padding: 8px 6px; border-right: 0; border-bottom: 1px solid var(--line, #e6eaf0);
  }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; width: 100%; row-gap: 2px; }
  .nav-group, .sidebar-group { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 2px; margin-bottom: 0; }
  .nav-group-label, .sidebar-group-label { padding: 0 8px; }
  .nav-group a, .sidebar-group a, .sidebar nav a {
    display: inline-block; width: auto; border-left: 0; border-bottom: 3px solid transparent;
    padding: 8px 12px; white-space: nowrap;
  }
  .sidebar nav a:hover { border-left-color: transparent; border-bottom-color: var(--brand, #e8590c); }
  .sidebar nav a.active, .sidebar nav a[aria-current] {
    border-left-color: transparent; border-bottom-color: var(--brand, #e8590c);
  }
  main.app, main.dashboard, main.lists { margin-left: 0; }
  main.app ~ footer, main.dashboard ~ footer, main.lists ~ footer { margin-left: 0; }
  .form-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 90px 1fr 40px; }
}

/* ---------- v2 form label/control stacking (app.css only styles .auth label) ---------- */
main.app2 form label,
main.app2 label.field {
  display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; color: var(--ink, #101e36);
}
main.app2 form label > input,
main.app2 form label > select,
main.app2 form label > textarea,
main.app2 label.field > input,
main.app2 label.field > select,
main.app2 label.field > textarea {
  display: block; width: 100%; box-sizing: border-box; margin-top: 6px; font-weight: 400;
}
main.app2 form .grid-2 > label, main.app2 form .grid-3 > label { margin-bottom: 0; }
main.app2 form textarea { resize: vertical; }

/* Wide tables stay readable on small screens */
main.app2 .table-wrap, main.app2 .data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 900px) {
  main.app2 .data-table { min-width: 560px; }
}

/* Sticky footer — pins the footer to the bottom of the viewport on short pages instead of
   leaving a blank slab of background below it. The sidebar is position:fixed, so it is out of
   flow and unaffected. */
body { min-height: 100vh; display: flex; flex-direction: column; }
body > main { flex: 1 0 auto; }
body > footer { flex: 0 0 auto; }
/* Flex items with auto side margins shrink-to-fit; give main a definite width so the
   centered landing page cannot be widened past the viewport by a non-shrinking child. */
body > main { width: 100%; box-sizing: border-box; min-width: 0; }
main.landing .search-form { flex-wrap: wrap; min-width: 0; }
main.landing .search-form input, main.landing .search-form button { min-width: 0; }
.score-explain { margin: 10px 0 0; font-size: 13px; }
.score-explain summary { cursor: pointer; color: var(--muted, #6b7a89); }
.score-explain p { margin: 6px 0 0; }

/* ---------- Real-vs-estimated basis badge ---------- */
/* Reuses the existing .chip-green / .chip-gray tokens from app.css so a "Real"
   badge is always green and an "Estimated"/"Modeled" badge is always grey —
   the same component wherever a `basis` field appears (Domain Overview,
   Authority, Competitor, Bulk Analysis). */
.basis-badge { font-weight: 700; white-space: nowrap; }

/* ---------- KD (keyword difficulty) chip, banded 0-14/15-29/30-49/50-69/70+ ----------
   Colour is a hint only — the band name is always spelled out in the chip text. */
.kd-chip { font-weight: 700; white-space: nowrap; }
.kd-easy { background: rgba(39, 174, 96, .14); color: #1e7e34; }
.kd-easymed { background: rgba(47, 128, 237, .12); color: #1c5fad; }
.kd-med { background: rgba(224, 168, 0, .16); color: #7a5c00; }
.kd-hard { background: rgba(235, 140, 60, .18); color: #a35a10; }
.kd-vhard { background: rgba(235, 87, 87, .16); color: #a92a2a; }

/* ---------- AI Overview SERP-feature chip ---------- */
.ai-overview-chip { white-space: nowrap; }

/* ---------- 12-month volume chart (bar sparkline) ---------- */
.monthly-chart { display: inline-block; vertical-align: middle; }
.monthly-chart-svg { width: 96px; height: 28px; display: block; }
.monthly-chart-svg rect { fill: var(--blue, #2f80ed); }

/* ---------- Domain Overview page ---------- */
main.app2 #overview-out .page-header h2 { margin-bottom: 2px; }

/* ============================================================================
   WAVE 2 (LANE W9) — dashboard command center, backlinks, reports, local SEO
   and the organised lists surface. Everything below is additive: it reuses the
   existing .card / .stat / .chip / .data-table tokens and never restyles them,
   so no existing page changes appearance.
   ============================================================================ */

/* ---------- Tabs (backlinks, local SEO) ---------- */
.tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  border-bottom: 1px solid var(--line, #e6eaf0);
  margin: 0 0 14px;
}
.tabs .tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 9px 12px; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--muted, #6b7a89); cursor: pointer; border-radius: 6px 6px 0 0;
}
.tabs .tab:hover { color: var(--ink, #1a2733); background: var(--bg, #f7f8fa); }
.tabs .tab.active {
  color: var(--brand, #e8590c); border-bottom-color: var(--brand, #e8590c); background: none;
}
.tabs .tab:focus-visible { outline: 2px solid var(--brand, #e8590c); outline-offset: -2px; }

/* ---------- Sub-sections inside a result panel ---------- */
.card-inner { padding: 0 0 18px; }
.card-inner + .card-inner { border-top: 1px solid var(--line, #e6eaf0); padding-top: 18px; }
.card-inner h3 { margin: 0 0 4px; font-size: 17px; }
.card-inner h4 { margin: 16px 0 6px; font-size: 14.5px; color: var(--ink, #1a2733); }

/* ---------- Basis / note lines under a tile or table ---------- */
.basis-line { margin: 4px 0 2px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.note-line { margin: 2px 0 10px; font-size: 13px; line-height: 1.5; }
.notes-list { margin: 8px 0; padding-left: 20px; font-size: 13.5px; line-height: 1.6; color: var(--muted, #6b7a89); }
.notes-list li { margin-bottom: 4px; }

/* ---------- Inline notices ---------- */
.notice {
  margin: 10px 0; padding: 10px 14px; border-radius: 8px; font-size: 13.5px; line-height: 1.55;
  border-left: 3px solid var(--line, #e6eaf0); background: var(--bg, #f7f8fa);
}
.notice-info { border-left-color: var(--blue, #2f80ed); background: rgba(47, 128, 237, .07); }
.notice-warn { border-left-color: var(--yellow, #e0a800); background: rgba(224, 168, 0, .09); }

/* ---------- Sparkline wrapper (dashboard trend, velocity, rank series) ---------- */
.sparkline-wrap {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin: 10px 0; font-size: 13px;
}
.sparkline-wrap .sparkline { width: auto; max-width: 100%; }

/* ---------- Dashboard ---------- */
.metric-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin: 12px 0;
}

/* ---------- Reports ---------- */
.report-frame {
  width: 100%; height: 620px; border: 1px solid var(--line, #e6eaf0);
  border-radius: 8px; background: #fff; margin: 12px 0; display: block;
}

/* ---------- Lists: favourites, inline folder picker, tag form ---------- */
.btn-star {
  appearance: none; background: none; border: 0; cursor: pointer; padding: 2px 4px;
  font-size: 17px; line-height: 1; color: var(--yellow, #e0a800);
}
.btn-star:hover { color: #b98c00; }
.btn-star:focus-visible { outline: 2px solid var(--brand, #e8590c); outline-offset: 2px; border-radius: 4px; }
.inline-select {
  font: inherit; font-size: 13px; padding: 4px 6px;
  border: 1px solid var(--line, #e6eaf0); border-radius: 6px; background: #fff; max-width: 160px;
}
.tag-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 12px 0; }
.tag-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.tag-form input {
  font: inherit; padding: 7px 9px; border: 1px solid var(--line, #e6eaf0); border-radius: 6px;
}
.data-table .chip[data-kaction="untag"] { cursor: pointer; }

/* ---------- Local SEO: honest "unavailable" block ---------- */
main.app2 .card-inner .notes-list b { color: var(--ink, #1a2733); font-weight: 700; }

/* ---------- Long tables stay scrollable rather than pushing the sidebar ---------- */
main.app2 .table-wrap { max-width: 100%; overflow-x: auto; }

@media (max-width: 860px) {
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .tabs .tab { white-space: nowrap; }
  .report-frame { height: 420px; }
}

/* ============================================================================
   WAVE 3 (LANE A6) — AI Access (MCP shop window), context bundles, AEO.
   ========================================================================== */

/* app.css sets `display` on label/div, which beats the UA stylesheet's [hidden]
   rule — so a conditionally-shown field stayed visible. Restore the HTML
   attribute's meaning for every element on these pages. */
[hidden] { display: none !important; }

/* ---------- The pitch block on /ai-access ---------- */
.pitch-card { border-left: 4px solid var(--brand, #e8590c); }
.pitch-card h2 { margin-top: 0; font-size: 26px; line-height: 1.25; }
.pitch-lead { font-size: 16px; line-height: 1.65; margin: 10px 0; max-width: 74ch; }
.pitch-flow {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin: 18px 0 12px;
}
.pitch-step {
  background: var(--bg, #f7f8fa); border: 1px solid var(--line, #e6eaf0);
  border-radius: var(--radius, 12px); padding: 14px 16px;
}
.pitch-step b { display: block; margin: 6px 0 4px; }
.pitch-step p { margin: 0; font-size: 13.5px; line-height: 1.55; }
.pitch-step-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 999px;
  background: var(--brand, #e8590c); color: #fff; font-size: 13px; font-weight: 700;
}

/* ---------- Copy boxes (always-visible clipboard fallback) ---------- */
.copy-box { margin: 12px 0; }
.copy-box-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 6px;
}
.copy-box-label { font-size: 13px; font-weight: 700; color: var(--muted, #6b7a89); }
.copy-box-hint { margin: 0 0 6px; font-size: 12.5px; }
textarea.copy-box-text {
  width: 100%; box-sizing: border-box; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.5;
  padding: 12px 14px; border: 1.5px solid var(--line, #e6eaf0); border-radius: 8px;
  background: var(--bg, #f7f8fa); color: var(--ink, #1a2733); white-space: pre;
}
textarea.copy-box-text:focus { outline: none; border-color: var(--brand, #e8590c); background: #fff; }

pre.code-block {
  margin: 12px 0; padding: 12px 14px; overflow-x: auto;
  background: var(--bg, #f7f8fa); border: 1px solid var(--line, #e6eaf0); border-radius: 8px;
  font-size: 12.5px; line-height: 1.55;
}
pre.code-block code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: none; padding: 0; }

/* ---------- MCP config panel ---------- */
.mcp-summary { margin: 4px 0 12px; }
.mcp-key-cta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.mcp-key-cta p { margin: 0; flex: 1 1 260px; font-size: 13px; }
.mcp-verify h3, .mcp-tryit h3 { margin: 18px 0 6px; }
.mcp-tryit .why-list li { margin-bottom: 6px; }

/* ---------- Tool table ---------- */
.tool-table td { vertical-align: top; }
.tool-table .tool-title { font-size: 12.5px; }
.tool-more { margin-top: 6px; }
.tool-more summary { cursor: pointer; font-size: 12.5px; color: var(--brand, #e8590c); }
.tool-more p { margin: 6px 0 0; font-size: 13px; line-height: 1.55; }

/* ---------- Copy for AI ---------- */
.copy-for-ai { margin-top: 8px; }
.copy-for-ai-out:empty { display: none; }
.copy-for-ai-card h3 { margin-top: 0; }
.btn-copy-ai::before { content: '✦ '; }
.context-meta { margin: 4px 0 8px; font-size: 13px; }

/* ---------- AEO ---------- */
.fix-card {
  border: 1px solid var(--line, #e6eaf0); border-left: 3px solid var(--brand, #e8590c);
  border-radius: 8px; padding: 12px 14px; margin: 10px 0; background: var(--bg, #f7f8fa);
}
.fix-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.fix-card p { margin: 6px 0; font-size: 14px; line-height: 1.6; }
.fix-card h4 { margin: 10px 0 4px; }
/* .chip-gray already exists in app.css — not redefined here. */

/* Long tool descriptions and markdown blocks must never widen the layout
   (a wide child here is what pushes main under the sidebar). */
main.app2 .card { min-width: 0; }
main.app2 pre, main.app2 textarea { max-width: 100%; }

@media (max-width: 860px) {
  .pitch-card h2 { font-size: 21px; }
  .mcp-key-cta { flex-direction: column; align-items: stretch; }
}
