/* Seller University Research — one stylesheet, no framework. */

:root {
  --su-orange: #fc5d01;
  --su-orange-600: #e05200;
  --su-orange-50: #fff3eb;
  --su-ink: #151517;
  --su-ink-2: #232327;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --border: #e4e6ea;
  --border-strong: #d0d4da;
  --text: #1c1f24;
  --muted: #6a7280;
  --faint: #9aa1ab;
  --good: #137a3a;
  --good-bg: #e8f6ee;
  --warn: #a35a00;
  --warn-bg: #fff4e0;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --info: #1d4ed8;
  --info-bg: #eaf0ff;
  --c1: #fc5d01;
  --c2: #2563eb;
  --c3: #0f9488;
  --c4: #7c3aed;
  --c5: #64748b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --display: 'Oswald', 'Arial Narrow', sans-serif;
  --sidebar: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font: 600 24px/1.2 var(--display); letter-spacing: .3px; text-transform: uppercase; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Components set display (flex, grid) on classes, which would beat the UA's [hidden] rule. */
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--su-orange); outline-offset: 2px; }

/* boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-msg { display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--muted); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--su-ink); color: #e8e8ea; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.brand img { width: 36px; height: 36px; }
.brand-name { font: 600 16px/1.1 var(--display); letter-spacing: .5px; text-transform: uppercase; color: #fff; }
.brand-sub { font-size: 11px; color: #a1a1aa; letter-spacing: .3px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #d4d4d8; font-weight: 500; }
.nav a:hover { background: var(--su-ink-2); text-decoration: none; color: #fff; }
.nav a.active { background: var(--su-orange); color: #fff; }
.nav a .tag { margin-left: auto; font-size: 10px; padding: 1px 6px; border-radius: 99px; background: #3f3f46; color: #d4d4d8; font-weight: 600; }
.nav .ico { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-sep { height: 1px; background: #2f2f35; margin: 8px 12px; }
.sidebar-foot { margin-top: auto; padding: 12px 16px 16px; font-size: 12px; color: #a1a1aa; border-top: 1px solid #2a2a30; }
.sidebar-foot .who { color: #e4e4e7; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot button { margin-top: 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar .menu-btn { display: none; }
.topbar .spacer { flex: 1; }
.usage-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--border); border-radius: 99px; padding: 4px 10px; }
.usage-pill b { color: var(--text); font-weight: 600; }
.content { padding: 24px; max-width: 1480px; width: 100%; margin: 0 auto; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  /* visibility, not just the transform: a closed menu must leave the tab order
     and the accessibility tree. It switches after the slide-out finishes. */
  .sidebar { position: fixed; z-index: 50; width: 260px; left: 0; top: 0; transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility 0s linear .2s; }
  .shell.nav-open .sidebar { transform: none; visibility: visible; transition: transform .2s; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { padding: 10px 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
}

/* ---------- primitives ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--panel); font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--su-orange); border-color: var(--su-orange); color: #fff; }
.btn.primary:hover { background: var(--su-orange-600); }
.btn.dark { background: var(--su-ink); border-color: var(--su-ink); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.xs { height: 24px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn.danger { color: var(--bad); }
.sidebar .btn { background: transparent; color: #e4e4e7; border-color: #3f3f46; }
.sidebar .btn:hover { background: var(--su-ink-2); }
.icon-btn { width: 36px; padding: 0; }

.input, .select, textarea.input { height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; min-width: 0; }
textarea.input { height: auto; padding: 8px 12px; }
.input:focus, .select:focus, textarea.input:focus { outline: 2px solid rgba(252, 93, 1, .35); border-color: var(--su-orange); }
.input.lg { height: 46px; font-size: 16px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.check input { accent-color: var(--su-orange); width: 16px; height: 16px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-h .sub { color: var(--muted); font-size: 12px; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-b { padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; white-space: nowrap; background: #f1f2f4; color: #3f4651; border: 1px solid transparent; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.orange { background: var(--su-orange-50); color: var(--su-orange-600); }
.badge.outline { background: transparent; border-color: var(--border-strong); }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 8px; background: var(--info-bg); color: #1e3a8a; font-size: 13px; }
.notice.warn { background: var(--warn-bg); color: #7a4300; }
.notice.bad { background: var(--bad-bg); color: #7a1a12; }
.notice.good { background: var(--good-bg); color: #0d5a2b; }
.notice.scope { background: #fff; border: 1px dashed var(--border-strong); color: var(--text); }
.notice b { font-weight: 650; }

.tabs { display: inline-flex; background: #eef0f3; border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 16px; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(0,0,0,.12); border-top-color: var(--su-orange); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, #eef0f3 25%, #f7f8fa 50%, #eef0f3 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.toast-wrap { position: fixed; bottom: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--su-ink); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 13px; }
.toast.bad { background: var(--bad); }

/* ---------- page header ---------- */
.page-h { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-h .meta { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; gap: 6px 14px; flex-wrap: wrap; }
.page-h .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.page-h .actions .why { flex-basis: 100%; text-align: right; }
@media (max-width: 640px) { .page-h .actions { margin-left: 0; justify-content: flex-start; } .page-h .actions .why { text-align: left; } }

/* ---------- dashboard ---------- */
.hero { background: var(--su-ink); color: #fff; border-radius: 14px; padding: 28px; position: relative; overflow: hidden; }
.hero h1 { font-size: 30px; }
.hero p { color: #c4c4cc; max-width: 640px; margin-top: 8px; }
.hero::after { content: ''; position: absolute; right: -80px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: var(--su-orange); opacity: .9; }
.hero > * { position: relative; z-index: 1; }
.tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1000px) { .tools { grid-template-columns: 1fr; } }
.tool { display: flex; flex-direction: column; gap: 10px; padding: 20px; }
.tool .tool-h { display: flex; align-items: center; gap: 10px; }
.tool .tool-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--su-orange-50); color: var(--su-orange); flex: none; }
.tool .tool-name { font: 600 18px var(--display); text-transform: uppercase; letter-spacing: .4px; }
.tool .tool-tag { color: var(--muted); font-size: 13px; }
.tool form { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.tool form .input { flex: 1 1 180px; }

/* ---------- product research form ---------- */
.search-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.search-bar .grow { flex: 1 1 280px; }
.search-bar .grow .input { width: 100%; }
.search-opts .mk-select .select { height: 36px; max-width: 340px; }
@media (max-width: 640px) { .search-opts .mk-select { flex: 1 1 100%; } .search-opts .mk-select .select { max-width: none; width: 100%; } }
.tool form .select { flex: 0 0 auto; }
.search-opts { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 0 12px; height: 36px; cursor: pointer; font-weight: 600; color: var(--muted); border-left: 1px solid var(--border); }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--su-ink); color: #fff; }
.cost-line { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; min-height: 18px; }
.progress-steps { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.progress-steps .st { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.progress-steps .st.on { color: var(--text); font-weight: 600; }
.progress-steps .st.done { color: var(--good); }
.dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; }
.st.done .dot { background: var(--good); border-color: var(--good); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1300px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { padding: 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; gap: 4px; align-items: center; }
.kpi .k-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi .k-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
/* "Insufficient data" has to fit a half-width phone tile without being cut off. */
.kpi .k-value.insufficient { font-size: 16px; font-weight: 650; color: var(--muted); white-space: normal; letter-spacing: 0; padding: 3px 0; }
.kpi.hl { border-color: var(--su-orange); background: linear-gradient(180deg, #fff, var(--su-orange-50)); }
.tip-wrap { display: inline-flex; flex: none; }
.info-i { position: relative; display: inline-grid; place-items: center; width: 15px; height: 15px; padding: 0; border: 0; border-radius: 50%; background: #e5e7eb; color: #374151; font: 700 10px/1 var(--font); cursor: pointer; flex: none; }
.info-i::after { content: ''; position: absolute; inset: -8px; } /* ~31px touch target without moving the layout */
.info-i:hover, .info-i[aria-expanded="true"] { background: #d1d5db; }
/* Fixed, so a scrolling table or the drawer can't clip it; ui.js keeps it inside the viewport. */
.tip-pop { position: fixed; z-index: 200; display: none; width: max-content; max-width: min(300px, calc(100vw - 16px)); padding: 8px 10px; border-radius: 6px; background: var(--su-ink); color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.2);
  font: 400 12px/1.45 var(--font); letter-spacing: normal; text-transform: none; text-align: left; white-space: normal; }
.tip-pop.show { display: block; }

/* score ring */
.score-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.score-ring { position: relative; width: 120px; height: 120px; flex: none; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .val { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.score-ring .val b { display: block; font-size: 32px; font-weight: 750; line-height: 1; }
.score-ring .val span { font-size: 11px; color: var(--muted); }
.comp-list { flex: 1 1 320px; display: flex; flex-direction: column; gap: 10px; }
.comp { display: grid; grid-template-columns: 150px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }
@media (max-width: 600px) { .comp { grid-template-columns: 110px 1fr 56px; } }
.bar { height: 8px; background: #eef0f3; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--su-orange); border-radius: 99px; }
.bar.prov > i { background: repeating-linear-gradient(45deg, var(--su-orange), var(--su-orange) 6px, #ffa36b 6px, #ffa36b 12px); }
.bar.skipped { background: repeating-linear-gradient(45deg, #eef0f3, #eef0f3 4px, #f8f9fb 4px, #f8f9fb 8px); }
.comp.brand-row { grid-template-columns: 140px 1fr 90px; }
@media (max-width: 600px) { .comp.brand-row { grid-template-columns: 96px 1fr 84px; } }
details.explain { font-size: 12px; color: var(--muted); }
details.explain summary { cursor: pointer; color: var(--info); font-weight: 600; }
details.explain ul { padding-left: 18px; margin: 6px 0; }

/* market panel */
.mkt { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
@media (max-width: 760px) { .mkt { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mkt > div { padding: 12px 16px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.mkt b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.mkt span { font-size: 12px; color: var(--muted); }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { font-size: 11px; fill: var(--muted); }
.chart .grid line { stroke: #eceef1; }
/* Wraps and never exceeds the chart's width; chart.js keeps its centre inside the chart. */
.chart .tip { position: absolute; pointer-events: none; background: var(--su-ink); color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 6px; width: max-content; max-width: min(320px, 100%); white-space: normal; overflow-wrap: anywhere; transform: translate(-50%, -100%); margin-top: -8px; display: none; z-index: 5; }
.chart .tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.chart-empty { display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 24px; border: 1px dashed var(--border); border-radius: 8px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.season { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; align-items: end; height: 90px; }
.season .m { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; font-size: 11px; color: var(--muted); }
.season .m i { display: block; width: 100%; border-radius: 4px 4px 0 0; background: #cbd5e1; min-height: 2px; }
.season .m.peak i { background: var(--su-orange); }
.season .m.trough i { background: #93c5fd; }

/* summary */
.summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .summary { grid-template-columns: 1fr; } }
.summary section h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.summary ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.summary .plus h3 { color: var(--good); }
.summary .minus h3 { color: var(--bad); }

/* ---------- table ---------- */
.table-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table-tools .input, .table-tools .select { height: 32px; font-size: 13px; }
/* position: relative makes this the containing block of absolutely positioned
   cell content (.sr-only text), so it is clipped here instead of widening the page. */
.table-scroll { overflow: auto; max-height: 75vh; position: relative; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data th { position: sticky; top: 0; z-index: 2; background: #f8f9fb; text-align: left; font-weight: 650; font-size: 12px; color: #4b5563; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--text); }
table.data th .arrow { font-size: 10px; margin-left: 3px; color: var(--su-orange); }
table.data td { padding: 8px 10px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
table.data td.r, table.data th.r { text-align: right; }
table.data tr:hover td { background: #fcfcfd; }
table.data tr.excluded td { opacity: .45; }
table.data tr.excluded td:first-child { opacity: 1; }
table.data tr.clickable { cursor: pointer; }
table.data .thumb { width: 44px; height: 44px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 6px; display: block; }
table.data .title-cell { min-width: 260px; max-width: 380px; }
table.data .title-cell .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--text); font-weight: 500; }
.link-btn { display: block; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; font: inherit; color: inherit; border-radius: 4px; }
.link-btn:hover .t { color: var(--info); text-decoration: underline; }
table.data th .tip-wrap { margin-left: 4px; vertical-align: -2px; }
table.data .title-cell .s { font-size: 11px; color: var(--muted); display: flex; gap: 8px; margin-top: 2px; flex-wrap: wrap; }
table.data th:first-child, table.data td:first-child { position: sticky; left: 0; z-index: 1; background: inherit; }
table.data th:first-child { z-index: 3; background: #f8f9fb; }
table.data td:first-child { background: #fff; }
.trend-up { color: var(--good); font-weight: 600; }
.trend-down { color: var(--bad); font-weight: 600; }
.trend-flat { color: var(--muted); }
.conf { font-size: 10px; text-transform: uppercase; letter-spacing: .3px; font-weight: 700; }
.conf.high { color: var(--good); } .conf.medium { color: var(--warn); } .conf.low { color: var(--bad); }
/* --muted, not --faint: "insufficient" is information, and --faint is 2.6:1 on white. */
.na { color: var(--muted); font-style: italic; font-size: 12px; }

/* drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(15, 18, 24, .45); z-index: 60; display: flex; justify-content: flex-end; }
.drawer { width: min(880px, 100vw); height: 100vh; height: 100dvh; background: var(--bg); overflow: auto; box-shadow: -8px 0 32px rgba(0,0,0,.2); display: flex; flex-direction: column; }
.drawer:focus { outline: none; }
.drawer-h { display: flex; gap: 14px; padding: 16px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 3; align-items: flex-start; }
.drawer-id { display: flex; gap: 14px; flex: 1 1 auto; min-width: 0; align-items: flex-start; }
.drawer-id img { width: 72px; height: 72px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: #fff; flex: none; }
.drawer-title { font-size: 15px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.drawer-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex: none; }
.drawer-b { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
/* Phones (and short landscape screens): a header holding a long title would be
   taller than the screen and, being sticky, hide everything under it. Only a
   slim bar with the actions (and the close button) stays pinned; the image and
   title scroll away with the content. */
@media (max-width: 640px), (max-height: 500px) {
  .drawer-h { display: contents; }
  .drawer-actions { position: sticky; top: 0; z-index: 3; order: -1; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--border); }
  .drawer-id { padding: 14px 16px; background: var(--panel); border-bottom: 1px solid var(--border); gap: 12px; }
  .drawer-id img { width: 48px; height: 48px; }
  .drawer-b { padding: 12px; }
}
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 700px) { .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.facts > div { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.facts b { display: block; font-size: 16px; }
.facts span { font-size: 11px; color: var(--muted); }

/* auth pages */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--su-ink); }
.auth-card { width: min(420px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.auth-card .logo img { width: 44px; height: 44px; }

/* admin */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.spark i { flex: 1; background: var(--su-orange); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.spark i.saved { background: #93c5fd; }
.spark > div { max-width: 28px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.link-box { display: flex; gap: 8px; align-items: center; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; word-break: break-all; }

@media print {
  .sidebar, .topbar, .table-tools, .actions, .no-print { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .table-scroll { max-height: none; overflow: visible; }
}

/* ---------- competitor research ---------- */
.cr-form-body { display: flex; flex-direction: column; gap: 14px; }
.cr-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cr-label, .kd-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.cr-label label, .kd-label label { cursor: pointer; }
textarea.cr-asins { width: 100%; min-height: 96px; resize: vertical; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.cr-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .cr-form-grid { grid-template-columns: 1fr; } }
.cr-form-grid .input, .cr-form-grid .select, .cr-form-grid .mk-select .select { width: 100%; max-width: none; }
.cr-submit { gap: 12px; }
.cr-err { color: var(--bad); }
.cr-err:empty, .cr-chips:empty, .cr-ai-slot:empty { display: none; }
.cr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cr-chip { display: inline-flex; align-items: center; max-width: 100%; padding: 1px 8px; border-radius: 6px; border: 1px solid transparent; background: var(--good-bg); color: var(--good); font: 600 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-chip.bad { background: var(--bad-bg); color: var(--bad); text-decoration: line-through; }
.cr-chip.over { background: var(--warn-bg); color: var(--warn); border: 1px dashed var(--warn); }
.cr-chip.kw { background: var(--panel-2); color: var(--text); border-color: var(--border); font: 500 12px/1.6 var(--font); white-space: normal; }
.cr-collapsed { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; }
.cr-collapsed .btn { margin-left: auto; }
@media (max-width: 640px) { .cr-collapsed .btn { margin-left: 0; } }
.cr-title { overflow-wrap: anywhere; }
.cr-notices { gap: 10px; }
.cr-headline { font-size: 15px; font-weight: 600; }
.cr-points { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.cr-legend { display: grid; gap: 6px; }
.cr-legend-item { display: flex; gap: 10px; align-items: flex-start; }
.cr-legend-item .badge { flex: none; min-width: 104px; justify-content: center; }

/* Provenance: colour AND shape differ (solid, tinted, dashed), so they read without colour too. */
.badge.prov { gap: 5px; }
.badge.prov-verified { background: var(--good-bg); color: var(--good); border-color: var(--good); }
.badge.prov-listing { background: var(--info-bg); color: var(--info); }
.badge.prov-ai { background: transparent; color: var(--c4); border: 1px dashed var(--c4); }
.badge.prov .info-i { width: 13px; height: 13px; font-size: 9px; background: rgba(255, 255, 255, .75); color: inherit; }
.cr-provs { display: inline-flex; gap: 4px; flex-wrap: wrap; }

.cr-vnotice { padding: 12px 16px 0; }
.cr-selbar { background: var(--panel-2); }
.cr-selcount { font-weight: 600; }
.cr-verifybox { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.cr-verifybox .notice { align-items: center; flex-wrap: wrap; }
.cr-more { display: flex; justify-content: center; padding: 12px 16px; border-top: 1px solid var(--border); }
table.data .cr-kwcell { min-width: 220px; max-width: 320px; }
@media (max-width: 640px) { table.data .cr-kwcell { min-width: 150px; max-width: 180px; } }
.cr-kwwrap { display: flex; gap: 8px; align-items: flex-start; }
.cr-check { flex: none; }
table.data th .cr-check { margin-right: 8px; vertical-align: -3px; }
table.data .thumb { flex: none; }
.cr-kwbtn { display: inline-flex; gap: 6px; align-items: baseline; font-weight: 600; min-width: 0; }
.cr-kwbtn .t { color: var(--text); overflow-wrap: anywhere; }
.cr-kwbtn:hover .t { color: var(--info); text-decoration: underline; }
.cr-caret { flex: none; width: 10px; font-size: 13px; color: var(--muted); }
.cr-rel { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; font-variant-numeric: tabular-nums; }
.cr-rel .bar { width: 44px; height: 6px; }
.cr-via { margin-left: 4px; padding: 0 5px; font-weight: 500; }
.cr-yes { color: var(--good); font-weight: 600; }
.cr-no { color: var(--bad); font-weight: 600; }
.cr-src { display: block; min-width: 170px; max-width: 260px; }
.cr-units { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
table.data tr.selected td { background: var(--su-orange-50); }
table.data tr.cr-mine td { background: var(--su-orange-50); }
/* The details row spans the table: not sticky like other first cells, and its
   content sticks to the left edge so it stays in view when the table scrolls sideways. */
table.data tr.cr-detail-row td, table.data tr.cr-detail-row:hover td { position: static; padding: 0; background: var(--panel-2); }
.cr-detail { position: sticky; left: 0; max-width: min(1000px, var(--cr-visible, calc(100vw - 48px))); padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.cr-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 20px; }
.cr-detail h3 { margin-bottom: 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.cr-list { margin: 0; padding-left: 16px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; }

.cr-angles, .cr-pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 12px; }
.cr-angle, .cr-pos { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.cr-pos { gap: 10px; }
.cr-pos.mine { border-color: var(--su-orange); background: linear-gradient(180deg, var(--panel), var(--su-orange-50)); }
.cr-angle-h, .cr-pos-h { display: flex; gap: 10px; align-items: center; min-width: 0; }
.cr-angle .thumb, .cr-pos .thumb { width: 40px; height: 40px; flex: none; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 6px; }
.cr-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.cr-fact { min-width: 0; padding: 6px 8px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; }
.cr-fact b { display: block; font-size: 14px; overflow-wrap: anywhere; }
.cr-fact span { font-size: 11px; color: var(--muted); }
.cr-checks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.cr-checks li { display: flex; gap: 6px; align-items: flex-start; }
.cr-checks .mark { flex: none; width: 14px; font-weight: 700; }
.cr-checks li.ok .mark { color: var(--good); }
.cr-checks li.no .mark { color: var(--bad); }

/* admin: keyword data */
.kd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 10px 14px; }
.kd-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kd-field .input, .kd-field .select, .kd-field .mk-select .select { width: 100%; max-width: none; }
.kd-field input[type="file"] { height: auto; padding: 6px 8px; }

/* ---------- keyword research ----------
   The keyword table, notices and detail rows reuse the cr-* rules above. */
.kr-opt { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kr-opt .select { height: 36px; }
.kr-seedline { overflow-wrap: anywhere; }
.kr-intents { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px 0; }
.kr-intent { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 99px; background: var(--panel); font-size: 12px; font-weight: 600; color: var(--text); cursor: pointer; white-space: nowrap; }
.kr-intent:hover { border-color: var(--su-orange); }
.kr-intent .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.kr-intent.on { background: var(--su-ink); border-color: var(--su-ink); color: #fff; }
.kr-intent.on .n { color: #d4d4d8; }
.kr-intent-desc { padding: 8px 16px 0; }
/* Phones: twelve groups would push the table a screen down; they scroll sideways instead. */
@media (max-width: 640px) { .kr-intents { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; } }
.kr-intent-cell { display: flex; flex-direction: column; gap: 1px; }
.kr-sample { font-variant-numeric: tabular-nums; }
.kr-links { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.kr-listings { max-height: 560px; }

@media print {
  .cr-selbar, .cr-more, .cr-verifybox, .cr-collapsed .btn, .kr-intents { display: none !important; }
}

/* ---------- Copy for AI ----------
   The panel shown only when the browser won't copy: the text, selected, to copy by hand. */
.copy-panel-bg { position: fixed; inset: 0; z-index: 80; background: rgba(15, 18, 24, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.copy-panel { width: min(760px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.copy-panel-b { display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; min-height: 0; }
textarea.input.copy-panel-text { width: 100%; max-width: none; height: auto; min-height: 45vh; flex: 1 1 auto; padding: 10px 12px; resize: vertical; white-space: pre; overflow: auto; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
@media (max-width: 640px) {
  .copy-panel-bg { padding: 8px; align-items: stretch; }
  .copy-panel { max-height: none; }
  /* 16px: iOS zooms the page into smaller text when it is focused. */
  textarea.input.copy-panel-text { font-size: 16px; min-height: 0; white-space: pre-wrap; }
}
@media print { .copy-panel-bg { display: none !important; } }

/* ---------- What customers say (Amazon review topics) ----------
   Amazon's topics, figures and quotes, labelled and dated. Quotes are
   customers' words: shown as plain text inside <q>, which adds the marks. */
.ri-progress { display: flex; flex-direction: column; gap: 8px; }
.ri-bar { height: 6px; background: #eef0f3; border-radius: 99px; overflow: hidden; }
.ri-bar > i { display: block; height: 100%; background: var(--su-orange); border-radius: 99px; transition: width .4s ease; }
.ri-prov { display: flex; flex-direction: column; gap: 4px; padding-top: 10px; border-top: 1px solid var(--border); }
.ri-admin { font-weight: 600; color: var(--warn); }
.ri-quotes { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; font-size: 12px; color: #3f4651; overflow-wrap: anywhere; }
.ri-q { font-style: italic; }
.ri-agg, .ri-topics, .ri-returns { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.ri-topics { gap: 6px; font-size: 13px; }
.ri-figs { color: var(--muted); font-size: 12px; }
.ri-product { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ri-product > p { grid-column: 1 / -1; }
@media (max-width: 640px) { .ri-product { grid-template-columns: 1fr; } }
.ri-side h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.ri-side.minus h4 { color: var(--bad); }
.ri-side.plus h4 { color: var(--good); }
.ri-ideas ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.ri-ideas h3 { display: flex; align-items: center; gap: 6px; }
.ri-category h3 { display: flex; align-items: center; gap: 6px; }
/* In a positioning card: one column, the card is narrow. */
.ri-pos { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px dashed var(--border-strong); }
.ri-pos .ri-product { grid-template-columns: 1fr; gap: 6px; }
.ri-pos-summary { padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.ri-pos-summary .ri-category { grid-template-columns: 1fr; }
.ri-admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 12px 16px; }
.ri-admin-grid > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
