:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #172033; --muted: #6b7489; --line: #e3e6ec;
  --side: #121a2b; --side-ink: #c9d0de; --accent: #ff9f1c; --accent-ink: #1b1300;
  --blue: #2f6fed; --green: #13a26b; --red: #d64545; --amber: #c98a00;
  --radius: 10px; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-family: Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); display: flex; min-height: 100vh; font-size: 14px; }
h1 { font-size: 22px; margin: 0 0 2px; letter-spacing: -0.01em; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
h3:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
p { margin: 0; }

/* sidebar */
.sidebar { width: 230px; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column;
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.logo { font-weight: 700; font-size: 18px; color: #fff; padding: 0 8px 22px; }
.logo .muted { color: #7d879c; font-weight: 500; }
.logo-mark { color: var(--accent); }
nav { display: flex; flex-direction: column; gap: 2px; }
.nav { background: none; border: 0; color: var(--side-ink); text-align: left; padding: 10px 10px; border-radius: 8px;
  font: inherit; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.nav span { width: 18px; text-align: center; color: #7d879c; }
.nav:hover { background: #1c2740; }
.nav.active { background: #22304f; color: #fff; }
.nav.active span { color: var(--accent); }
.side-foot { margin-top: auto; }
.side-foot .lbl { color: #7d879c; }
.side-foot select { width: 100%; background: #1c2740; color: #fff; border-color: #2b3958; }
.provider { margin-top: 10px; font-size: 12px; padding: 8px 10px; border-radius: 8px; background: #1c2740; line-height: 1.4; }
.provider b { color: var(--accent); }

main { flex: 1; padding: 24px 28px; min-width: 0; overflow-x: hidden; }
.view { display: none; }
.view.active { display: block; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* controls */
.lbl { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 10px 0 4px; }
input, select { font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus { outline: 2px solid #ffcf85; border-color: var(--accent); }
.btn { font: inherit; font-weight: 600; border-radius: 7px; padding: 8px 14px; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink); white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(.96); }
.btn.ghost:hover { background: #f0f2f5; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.danger { color: var(--red); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.chip { font: inherit; font-size: 12px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; cursor: pointer; margin: 0 4px 6px 0; }
.chip:hover { border-color: var(--accent); }

/* finder */
.results { min-width: 0; }
.finder { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px; align-items: start; }
.filters { padding: 14px 16px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.presets .lbl { margin-top: 0; }
.fgroup { border-top: 1px solid var(--line); padding-top: 4px; margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.range { grid-column: span 2; }
.range .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.checklist { max-height: 170px; overflow: auto; border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; }
.checklist label, .checks-inline label, .checks label { display: flex; gap: 7px; align-items: center; padding: 2px 0; font-size: 13px; cursor: pointer; }
.checklist input, .checks-inline input, .checks input { width: auto; }
.checks-inline { display: flex; gap: 14px; flex-wrap: wrap; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; position: sticky; bottom: -14px; background: #fff; padding: 10px 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .v { font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }

.table-card { overflow: hidden; }
.table-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table-wrap { overflow: auto; max-height: calc(100vh - 260px); }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th { position: sticky; top: 0; background: #f8f9fb; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; z-index: 1; }
table.data th.num, table.data td.num { text-align: right; }
table.data th.sorted { color: var(--ink); }
table.data td { padding: 8px 10px; border-bottom: 1px solid #eef0f4; white-space: nowrap; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: #fff8ec; }
td.title { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.title small { display: block; color: var(--muted); font-size: 11px; }
.asin { font-family: var(--mono); font-size: 12px; color: var(--blue); }
.pos { color: var(--green); } .neg { color: var(--red); }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: #eef1f6; color: #3c4559; }
.badge.FBA { background: #e7f0ff; color: #1d4fb8; } .badge.FBM { background: #f3eefe; color: #6a3fc0; } .badge.AMZ { background: #fff1db; color: #9a5b00; }
.badge.alert { background: #fdecec; color: var(--red); margin: 1px 2px; }
.pager { display: flex; gap: 6px; align-items: center; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* keywords */
.tabs { display: flex; gap: 4px; background: #e8eaef; padding: 3px; border-radius: 9px; }
.tab { font: inherit; border: 0; background: none; padding: 6px 14px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.ktab { display: none; } .ktab.active { display: block; }
.searchbar { display: flex; gap: 8px; padding: 10px; margin-bottom: 14px; }
.kx-filters { display: grid; grid-template-columns: 2fr 2fr 1fr 1fr 1fr 1fr auto; gap: 10px; padding: 4px 14px 14px; margin-bottom: 14px; align-items: end; }
.kx-btns { display: flex; gap: 6px; }
.two-col { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 14px; }
.table-card > h3 { padding: 12px 14px 0; }
#watch-table td.title { max-width: 260px; }
.score { display: inline-block; min-width: 34px; text-align: center; border-radius: 6px; padding: 2px 6px; font-weight: 700; font-size: 12px; }

/* profit */
.profit { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(320px, 440px); gap: 18px; align-items: start; }
.pform { padding: 18px; }
.dims { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.checks { padding-top: 26px; }
.presult { padding: 18px; position: sticky; top: 16px; }
.big { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 16px; }
.kpis .stat { padding: 10px; }
.kpis .v { font-size: 17px; }
.breakdown { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.breakdown td { padding: 6px 0; border-bottom: 1px solid #eef0f4; }
.breakdown td:last-child { text-align: right; }
.breakdown tr.total td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
.breakdown tr.sub td:first-child { padding-left: 14px; color: var(--muted); }
.note { font-size: 12px; color: var(--muted); margin-top: 12px; background: #fff8ec; padding: 8px 10px; border-radius: 7px; }

/* drawer */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer.hidden { display: none; }
.drawer-bg { position: absolute; inset: 0; background: rgba(15, 20, 35, .35); }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(860px, 96vw); background: var(--bg); overflow: auto; padding: 24px; box-shadow: -10px 0 30px rgba(0,0,0,.15); }
.close { position: absolute; right: 16px; top: 12px; border: 0; background: none; font-size: 28px; cursor: pointer; color: var(--muted); }
.dhead { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 14px; padding-right: 30px; }
.dhead h2 { font-size: 18px; margin: 4px 0; }
.chart-card { padding: 14px; margin-bottom: 14px; }
.chart-card .row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.chart-box { position: relative; height: 230px; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 30; }
.toast.hidden { display: none; }
.loading { opacity: .5; pointer-events: none; }

@media (max-width: 1100px) {
  .finder, .profit, .two-col { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; }
  .kx-filters { grid-template-columns: 1fr 1fr; }
  .facts { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  nav { flex-direction: row; overflow: auto; }
  main { padding: 16px; }
}

.nav-sep { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #5d6780; padding: 14px 10px 4px; }
.arb-filters { grid-template-columns: repeat(4, 1fr); }
.badge.low { background: #e6f6ee; color: #0f7a51; } .badge.medium { background: #fff3d6; color: #8a5d00; } .badge.high { background: #fdecec; color: #b42f2f; }
.verdict { display: grid; grid-template-columns: 140px 1fr; gap: 18px; padding: 16px; margin-bottom: 14px; align-items: center; }
.ring { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; position: relative; }
.ring::after { content: ""; position: absolute; inset: 12px; background: #fff; border-radius: 50%; }
.ring b { position: relative; z-index: 1; font-size: 30px; }
.ring small { position: relative; z-index: 1; display: block; font-size: 11px; color: var(--muted); text-align: center; margin-top: -4px; }
.bars { display: grid; grid-template-columns: 90px 1fr 34px; gap: 4px 10px; font-size: 12px; align-items: center; margin: 8px 0; }
.bar { height: 7px; background: #eef0f4; border-radius: 9px; overflow: hidden; } .bar i { display: block; height: 100%; border-radius: 9px; }
ul.reasons { margin: 6px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.55; }
ul.reasons.pros li::marker { content: "✓  "; color: var(--green); }
ul.reasons.cons li::marker { content: "!  "; color: var(--red); font-weight: 700; }
.risk-list { padding: 4px 14px 14px; }
.risk-item { border-left: 3px solid var(--line); padding: 6px 10px; margin: 8px 0; font-size: 13px; }
.risk-item.high { border-color: var(--red); } .risk-item.medium { border-color: var(--amber); } .risk-item.info { border-color: #b8c0d0; }
.risk-item b { display: block; margin-bottom: 2px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.advice { font-size: 13px; background: #f3f7ff; border-radius: 7px; padding: 8px 10px; margin-top: 10px; }
table.data td.wrap { white-space: normal; min-width: 160px; }
@media (max-width: 1100px) { .verdict, .grid-2 { grid-template-columns: 1fr; } .arb-filters { grid-template-columns: 1fr 1fr; } }

/* ---- SaaS: org box, modal, plans, meters ---- */
.org-box { background: #1c2740; border-radius: 9px; padding: 10px; margin-bottom: 10px; font-size: 12px; }
.org-box .row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.org-box a { color: var(--accent); cursor: pointer; }
.org-box select { margin-bottom: 4px; }
.org-name { color: #fff; font-weight: 600; font-size: 13px; }
.plan-pill { background: #2b3958; color: #fff; border-radius: 999px; padding: 2px 9px; font-weight: 600; font-size: 11px; }
.org-box .meter { margin-top: 6px; } .org-box .meter .muted { color: #7d879c; }
.meter { margin: 10px 0; font-size: 13px; } .meter .row { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.meter small { font-size: 10px; }
.modal { position: fixed; inset: 0; background: rgba(15,20,35,.45); display: grid; place-items: center; z-index: 40; }
.modal.hidden { display: none; }
.modal-card { padding: 22px; max-width: 440px; }
.modal-card h2 { margin: 0 0 6px; font-size: 18px; }
.plans { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 4px; }
.plan { padding: 18px; display: flex; flex-direction: column; }
.plan.current { border: 2px solid var(--accent); }
.plan-name { font-weight: 700; font-size: 15px; }
.plan-price { font-size: 28px; font-weight: 800; margin: 6px 0; } .plan-price small { font-size: 13px; color: var(--muted); font-weight: 500; }
.plan ul { padding-left: 18px; font-size: 13px; line-height: 1.8; flex: 1; }
.badge.sim, .ai-badge.sim { background: #fff3d6; color: #8a5d00; }
.ai-badge { background: #e7f0ff; color: #1d4fb8; vertical-align: middle; font-size: 11px; }

/* ---- Copilot ---- */
.copilot { display: flex; flex-direction: column; height: calc(100vh - 140px); min-height: 480px; }
.cp-log { flex: 1; overflow: auto; padding: 18px; }
.cp-empty { text-align: center; padding: 40px 20px 10px; }
.cp-hello { font-size: 34px; color: var(--accent); }
.cp-suggest { padding: 0 18px 8px; display: flex; flex-wrap: wrap; justify-content: center; }
.cp-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.cp-input textarea { flex: 1; font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; resize: none; }
.msg { display: flex; margin: 10px 0; } .msg.user { justify-content: flex-end; }
.bubble { max-width: 820px; padding: 10px 14px; border-radius: 12px; line-height: 1.55; font-size: 14px; }
.msg.user .bubble { background: var(--side); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.bot .bubble { background: #f6f7f9; border: 1px solid var(--line); border-bottom-left-radius: 4px; width: 100%; }
.bubble p { margin: 4px 0; } .bubble ul, .bubble ol { margin: 4px 0; padding-left: 20px; } .bubble h4 { margin: 10px 0 4px; }
.bubble code { background: #eceef2; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.asin-link { font-family: var(--mono); font-size: 12px; color: var(--blue); cursor: pointer; text-decoration: underline dotted; }
.cp-art { margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.cp-art-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; font-size: 13px; }
.cp-art .data td.title { max-width: 300px; }
.cp-meta { margin-top: 6px; }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; } .typing span { width: 7px; height: 7px; border-radius: 50%; background: #aab2c2; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---- Review Miner ---- */
.rm { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.rm textarea { width: 100%; font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 7px; padding: 8px; }
.rm-list { max-height: 380px; overflow: auto; }
.rm-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 14px; border-top: 1px solid #eef0f4; cursor: pointer; font-size: 13px; }
.rm-item small { display: block; color: var(--muted); font-size: 11px; } .rm-item:hover, .rm-item.active { background: #fff8ec; }
.rm-head { padding: 16px; margin-bottom: 14px; } .rm-head h2 { margin: 4px 0; font-size: 18px; }
.rm-head .row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.rm-summary { font-size: 15px; line-height: 1.55; margin: 8px 0; }
.rm-stats { display: grid; grid-template-columns: repeat(3, 1fr) 1.6fr; gap: 10px; margin-top: 12px; align-items: stretch; }
.dist { display: grid; grid-template-columns: 26px 1fr 34px; gap: 3px 8px; align-items: center; font-size: 11px; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
.rm-themes { padding: 4px 14px 14px; }
.theme { padding: 10px 0; border-bottom: 1px solid #eef0f4; } .theme:last-child { border-bottom: 0; }
.theme .row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.theme .bar { margin-bottom: 4px; }
blockquote { margin: 6px 0 0; padding: 4px 10px; border-left: 3px solid var(--line); color: #4b5468; font-size: 12.5px; font-style: italic; }
@media (max-width: 1100px) { .rm, .plans { grid-template-columns: 1fr; } .rm-stats { grid-template-columns: 1fr 1fr; } }
