:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --ink: #17201c;
  --muted: #66716b;
  --line: #d9dfdc;
  --green: #245f43;
  --green-strong: #173c2b;
  --blue: #2f6f9f;
  --amber: #a76a16;
  --red: #a33f46;
  --walnut: #654634;
  --radius: 6px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); min-width: 320px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; }
.brand strong, .brand small { display: block; letter-spacing: 0; }
.brand strong { font-size: 16px; }
.brand small { color: var(--muted); margin-top: 2px; font-size: 12px; }
.brand-mark { width: 34px; aspect-ratio: 1; border-radius: 5px; background: var(--walnut); display: grid; place-items: center; box-shadow: inset 0 0 0 1px #4c3224; }
.brand-mark::before, .brand-mark span { content: ""; border: 1px solid rgba(255,255,255,.45); border-radius: 50%; position: absolute; }
.brand-mark { position: relative; }
.brand-mark::before { width: 19px; height: 13px; transform: rotate(-12deg); }
.brand-mark span { width: 11px; height: 7px; transform: rotate(-12deg); }
.nav { display: grid; gap: 4px; }
.nav-item { width: 100%; height: 42px; padding: 0 11px; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; gap: 11px; border-radius: var(--radius); text-align: left; }
.nav-item svg { width: 18px; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { color: var(--green-strong); background: #e5eee9; font-weight: 600; }
.sidebar-status { margin-top: auto; padding: 12px 10px 2px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #3d9a6a; box-shadow: 0 0 0 3px #e0f2e8; }
.main { min-width: 0; padding: 0 34px 48px; }
.topbar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
h1, h2, p { margin: 0; letter-spacing: 0; }
.topbar h1 { font-size: 22px; line-height: 1.25; }
.topbar p, .section-heading p { color: var(--muted); font-size: 13px; margin-top: 5px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.mobile-search-button { display: none; }
.search-box { height: 38px; width: min(30vw, 320px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; align-items: center; padding: 0 11px; gap: 8px; }
.search-box svg { width: 17px; color: var(--muted); flex: none; }
.search-box input { border: 0; outline: 0; background: transparent; width: 100%; min-width: 0; }
.button, .icon-button, .text-button { border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 7px; text-decoration: none; white-space: nowrap; }
.button { height: 38px; padding: 0 14px; border-radius: var(--radius); font-weight: 600; font-size: 13px; }
.button svg { width: 17px; }
.button.primary { color: #fff; background: var(--green); }
.button.primary:hover { background: var(--green-strong); }
.button.secondary { color: var(--ink); background: var(--surface); border: 1px solid var(--line); }
.icon-button { width: 38px; height: 38px; border-radius: var(--radius); color: var(--muted); background: var(--surface); border: 1px solid var(--line); }
.icon-button svg { width: 18px; }
.text-button { color: var(--green); background: transparent; padding: 6px; font-size: 13px; }
.text-button svg { width: 15px; }
.view { display: none; padding-top: 27px; }
.view.active { display: block; }
.stats-band { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-columns: repeat(4, 1fr); }
.stat { min-width: 0; padding: 22px 24px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat span, .stat small { display: block; color: var(--muted); font-size: 12px; }
.stat strong { display: block; font-size: 30px; margin: 8px 0 5px; line-height: 1; }
.section-heading { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading h2 { font-size: 16px; }
.section-heading.compact { min-height: 48px; }
.lead-table-wrap { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; }
th { color: var(--muted); background: #f8faf9; font-size: 12px; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f5f8f6; }
.company-cell { min-width: 0; }
.company-cell strong, .company-cell span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-cell span { color: var(--muted); font-size: 12px; margin-top: 4px; }
.platform-badge, .state-badge, .score-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.platform-badge { color: #28587c; background: #e6f0f7; }
.platform-badge.douyin { color: #6f314b; background: #f5e8ee; }
.platform-badge.kuaishou { color: #94551a; background: #f8eee3; }
.platform-badge.xiaohongshu { color: #963b3f; background: #fae9ea; }
.platform-badge.alibaba { color: #8f5e0f; background: #fbf1dc; }
.platform-badge.baidu_aicaigou { color: #a33f46; background: #fae9ea; }
.score-badge { width: 42px; justify-content: center; color: var(--green-strong); background: #e3f0e8; }
.score-badge.mid { color: #87590f; background: #f9efd9; }
.score-badge.low { color: var(--muted); background: var(--surface-2); }
.state-badge { color: var(--muted); background: var(--surface-2); }
.state-badge.completed, .state-badge.approved { color: var(--green-strong); background: #e3f0e8; }
.state-badge.failed, .state-badge.rejected { color: var(--red); background: #f8e8ea; }
.state-badge.running, .state-badge.awaiting_browser { color: var(--blue); background: #e6f0f7; }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 30px; margin-bottom: 8px; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 22px; }
.plain-section { min-width: 0; }
.platform-bars, #recent-tasks { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-height: 190px; }
.platform-row { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 10px; margin: 13px 0; font-size: 12px; }
.bar-track { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-track span { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.recent-task { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.recent-task:last-child { border-bottom: 0; }
.recent-task strong, .recent-task span { display: block; font-size: 12px; }
.recent-task span { color: var(--muted); margin-top: 4px; }
.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.data-filter-bar { margin-bottom: 16px; }
.data-search { height: 38px; flex: 1; min-width: 240px; display: flex; align-items: center; gap: 8px; padding: 0 11px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.data-search svg { width: 16px; color: var(--muted); flex: none; }
.data-search input { width: 100%; min-width: 0; height: 34px; padding: 0; border: 0; outline: 0; }
.data-count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.product-cell { display: grid; gap: 6px; line-height: 1.45; }
.product-cell a { color: var(--green); font-size: 12px; text-decoration: none; }
.product-cell a:hover, .contact-link:hover { text-decoration: underline; }
.contact-link { color: var(--green-strong); text-decoration: none; }
.contact-stack { display: grid; gap: 5px; overflow-wrap: anywhere; }
select, input, textarea { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
select, input { height: 38px; padding: 0 10px; }
.score-filter { height: 38px; display: flex; align-items: center; gap: 9px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 10px; color: var(--muted); font-size: 12px; }
.score-filter input { width: 90px; height: auto; padding: 0; border: 0; }
.score-filter output { color: var(--ink); width: 20px; }
.export-button { margin-left: auto; }
.task-list, .keyword-list { display: grid; gap: 8px; }
.task-row, .keyword-row { min-height: 64px; display: grid; align-items: center; gap: 14px; padding: 11px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.task-row { grid-template-columns: 120px minmax(160px, 1fr) minmax(150px, 1.4fr) 120px 90px; }
.keyword-row { grid-template-columns: minmax(180px, 1fr) 130px 80px 52px; }
.task-row small, .keyword-row small { display: block; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-actions { text-align: right; }
.mini-button { width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--green); }
.mini-button svg { width: 15px; }
.toggle { position: relative; width: 38px; height: 22px; border: 0; border-radius: 11px; background: #bdc7c1; }
.toggle::after { content: ""; position: absolute; width: 16px; height: 16px; top: 3px; left: 3px; border-radius: 50%; background: white; transition: transform .15s ease; }
.toggle.on { background: var(--green); }
.toggle.on::after { transform: translateX(16px); }
dialog { width: min(500px, calc(100vw - 30px)); border: 1px solid var(--line); border-radius: 8px; padding: 0; box-shadow: 0 24px 80px rgba(23,32,28,.22); }
dialog::backdrop { background: rgba(23,32,28,.42); }
dialog form { padding: 20px; display: grid; gap: 15px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 3px; }
.dialog-heading h2 { font-size: 18px; }
.dialog-heading p { color: var(--muted); font-size: 12px; margin-top: 5px; }
dialog label { display: grid; gap: 7px; font-size: 13px; font-weight: 600; }
dialog input, dialog select, dialog textarea { width: 100%; font-weight: 400; }
dialog textarea { min-height: 100px; padding: 10px; resize: vertical; }
.check-row { display: flex; grid-template-columns: none; align-items: center; gap: 9px; min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.check-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--green); }
.check-row input:disabled + span { color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 5px; }
.lead-dialog { width: min(620px, calc(100vw - 30px)); }
.lead-detail { padding: 22px; }
.lead-detail-header { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.lead-detail-header h2 { font-size: 19px; margin: 7px 0; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
.detail-field { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.detail-field span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.reason-list { margin: 10px 0 18px; padding: 0; list-style: none; display: grid; gap: 7px; }
.reason-list li { font-size: 13px; color: var(--green-strong); }
.toast { position: fixed; right: 22px; bottom: 22px; transform: translateY(20px); opacity: 0; pointer-events: none; background: var(--ink); color: white; padding: 11px 14px; border-radius: var(--radius); transition: .2s ease; z-index: 20; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 74px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand > span:last-child, .nav-item span, .sidebar-status span:last-child { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .main { padding-inline: 22px; }
  .search-box { width: 220px; }
  .task-row { grid-template-columns: 110px minmax(150px, 1fr) 120px 80px; }
  .task-row > div:nth-child(3) { display: none; }
}

@media (max-width: 680px) {
  .app-shell { display: block; padding-bottom: 66px; }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: 100%; height: 62px; z-index: 10; border-right: 0; border-top: 1px solid var(--line); padding: 7px 10px; }
  .brand, .sidebar-status { display: none; }
  .nav { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
  .nav-item { height: 48px; display: grid; place-items: center; align-content: center; gap: 2px; }
  .nav-item span { display: block; font-size: 10px; }
  .nav-item svg { width: 17px; }
  .main { padding: 0 14px 28px; }
  .topbar { min-height: 78px; gap: 10px; }
  .topbar h1 { font-size: 19px; }
  .topbar p { display: none; }
  .topbar-actions { gap: 6px; }
  .mobile-search-button { display: inline-flex; }
  .topbar.search-open { min-height: 128px; align-items: flex-start; padding-top: 20px; }
  .search-box { position: absolute; top: 82px; left: 14px; right: 14px; width: auto; display: none; }
  .search-box.mobile-open { display: flex; box-shadow: 0 8px 22px rgba(23,32,28,.09); }
  .button { padding-inline: 11px; }
  .topbar .button span { display: none; }
  .view { padding-top: 18px; }
  .stats-band { grid-template-columns: 1fr 1fr; }
  .stat { padding: 17px; border-bottom: 1px solid var(--line); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(3), .stat:nth-child(4) { border-bottom: 0; }
  .stat strong { font-size: 25px; }
  .dashboard-grid { grid-template-columns: 1fr; gap: 14px; }
  .lead-table-wrap { background: transparent; border: 0; overflow: visible; }
  .lead-table-wrap table, .lead-table-wrap thead, .lead-table-wrap tbody, .lead-table-wrap tr, .lead-table-wrap td { display: block; }
  .lead-table-wrap thead { display: none; }
  .lead-table-wrap tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px; margin-bottom: 8px; }
  .lead-table-wrap td { border: 0; padding: 5px 0; }
  .lead-table-wrap td[data-label]::before { content: attr(data-label); display: inline-block; width: 72px; color: var(--muted); font-size: 11px; }
  .company-cell strong, .company-cell span { white-space: normal; }
  .filter-bar { display: grid; grid-template-columns: 1fr 1fr; }
  .filter-bar select { min-width: 0; width: 100%; }
  .score-filter { grid-column: 1 / -1; }
  .export-button { margin: 0; grid-column: 1 / -1; }
  .data-filter-bar { grid-template-columns: 1fr 1fr; }
  .data-search { min-width: 0; grid-column: 1 / -1; }
  .data-count { justify-self: end; align-self: center; }
  .task-row { grid-template-columns: 1fr auto; gap: 8px; }
  .task-row > div:nth-child(3), .task-row > div:nth-child(4) { display: none; }
  .keyword-row { grid-template-columns: 1fr 50px; }
  .keyword-row > div:nth-child(2), .keyword-row > div:nth-child(3) { display: none; }
  .section-heading { min-height: 58px; }
  .detail-grid { grid-template-columns: 1fr; }
  .toast { left: 14px; right: 14px; bottom: 76px; text-align: center; }
}
