:root {
  --bg: #f5f3ef;
  --card: #fffdf9;
  --sidebar: #1a1d24;
  --sidebar-text: #c8ccd4;
  --text: #2b2d33;
  --muted: #8a8f9a;
  --border: #e8e2d8;
  --green: #4caf6d;
  --green-bg: #e8f5ec;
  --orange: #f5a623;
  --orange-bg: #fef3e2;
  --red: #e05c5c;
  --red-bg: #fdeaea;
  --blue: #5b8dd9;
  --pill-green: #43a047;
  --pill-orange: #fb8c00;
  --pill-blue: #5c9ded;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 210px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 100;
}

.brand { padding: 22px 18px 14px; }
.brand-title { font-size: 19px; font-weight: 700; color: #fff; }
.brand-sub { font-size: 11px; color: #7a7f8a; margin-top: 3px; }

.nav { padding: 6px 10px; flex: 1; }
.nav-label { font-size: 11px; color: #62676f; padding: 12px 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px; margin-bottom: 4px;
  background: transparent; border: none; border-radius: 8px;
  color: var(--sidebar-text); font-size: 14px; cursor: pointer;
  text-align: left;
}
.nav-item:hover { background: #262b36; }
.nav-item.active { background: #333a48; color: #fff; }
.nav-icon { font-size: 16px; }

.sidebar-foot { padding: 14px 18px; font-size: 11px; color: #62676f; border-top: 1px solid #262b36; }
.sidebar-toggle { display: none; }

/* Main */
.main { flex: 1; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 18px; font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.menu-btn { display: none; background: none; border: none; font-size: 20px; cursor: pointer; }

.view { display: none; padding: 18px 22px; }
.view.active { display: block; }

/* Table */
.table-wrap { overflow-x: auto; background: var(--card); border-radius: 12px; border: 1px solid var(--border); }
.kw-table { width: 100%; border-collapse: collapse; min-width: 1080px; }
.kw-table thead th {
  text-align: left; padding: 12px 10px;
  font-size: 12px; color: var(--muted); font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.kw-table tbody td { padding: 14px 10px; border-bottom: 1px solid #f0ece4; vertical-align: top; }
.kw-table tbody tr:last-child td { border-bottom: none; }
.kw-table tbody tr:hover { background: #faf8f4; }

.col-term { min-width: 200px; }
.kw-term { font-weight: 600; font-size: 14px; }
.kw-term-cn { font-size: 12px; color: var(--muted); margin-top: 2px; }

.spark-wrap { display: flex; flex-direction: column; gap: 2px; }
.spark-wrap canvas { display: block; }
.spark-count { font-size: 11px; color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; gap: 5px; max-width: 220px; }
.tag {
  font-size: 11px; padding: 3px 9px; border-radius: 20px; white-space: nowrap;
  color: #fff;
}
.tag.hot { background: var(--pill-green); }
.tag.ok { background: var(--pill-green); opacity: .85; }
.tag.cat { background: var(--pill-green); opacity: .7; }
.tag.warn { background: var(--pill-orange); }

.score-badge {
  display: inline-block; font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 6px; color: #fff; white-space: nowrap;
}
.score-badge.high { background: var(--pill-green); }
.score-badge.mid { background: var(--pill-orange); }
.score-badge.low { background: #b0b5bf; }

.heat-num { font-weight: 600; font-size: 14px; }
.delta { font-size: 13px; font-weight: 600; }
.delta.up { color: var(--pill-green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--muted); }

.vacuum-bar { display: flex; align-items: center; gap: 6px; }
.vacuum-track { width: 56px; height: 6px; background: #eee9de; border-radius: 3px; overflow: hidden; }
.vacuum-fill { height: 100%; border-radius: 3px; }
.vacuum-num { font-size: 12px; font-weight: 600; }

.trends-tag { font-size: 12px; padding: 3px 10px; border-radius: 12px; white-space: nowrap; }
.trends-tag.up { background: var(--green-bg); color: #2e7d43; }
.trends-tag.down { background: var(--red-bg); color: #c04545; }
.trends-tag.flat { background: #eef0f3; color: var(--muted); }

.comp-bars { display: flex; gap: 3px; margin-bottom: 6px; }
.comp-bars span { width: 14px; height: 14px; border-radius: 3px; background: #e8e4da; }
.comp-bars span.f1 { background: #7e57c2; }
.comp-bars span.f2 { background: #5c9ded; }
.comp-bars span.f3 { background: #fb8c00; }
.comp-level {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: var(--green-bg); color: #2e7d43; margin-bottom: 6px;
}
.comp-level.high { background: var(--red-bg); color: #c04545; }
.comp-level.mid { background: var(--orange-bg); color: #b07218; }
.comp-detail { font-size: 11px; color: var(--muted); line-height: 1.6; white-space: pre-line; }

.review-btn {
  background: var(--orange); color: #fff; border: none;
  padding: 8px 14px; border-radius: 8px; font-size: 12px;
  cursor: pointer; white-space: nowrap; font-weight: 600;
}
.review-btn:hover { background: #e0951a; }

/* Coming soon */
.coming-soon { text-align: center; padding: 80px 20px; background: var(--card); border-radius: 12px; border: 1px solid var(--border); }
.cs-icon { font-size: 56px; margin-bottom: 16px; }
.coming-soon h2 { font-size: 20px; margin-bottom: 10px; }
.coming-soon p { color: var(--muted); line-height: 1.8; }

/* Daily */
.daily h2 { margin-bottom: 16px; }
.daily-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.daily-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.daily-card .dc-num { font-size: 30px; font-weight: 800; }
.daily-card .dc-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* Task kanban */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.kanban-col { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; min-height: 180px; }
.kanban-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 14px; padding: 4px 4px 10px; }
.kanban-count { background: #eef0f3; color: var(--muted); border-radius: 10px; padding: 1px 10px; font-size: 12px; font-weight: 600; }
.kanban-list { display: flex; flex-direction: column; gap: 10px; }
.kanban-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 28px 0; }
.task-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.task-type { font-size: 12px; font-weight: 700; color: var(--muted); }
.task-term { font-size: 15px; font-weight: 700; margin-top: 6px; }
.task-term-en { font-size: 12px; color: var(--muted); margin-top: 2px; }
.task-meta { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.task-date { font-size: 11px; color: var(--muted); }
.task-action { font-size: 13px; line-height: 1.65; margin-top: 8px; background: #faf8f4; border-radius: 8px; padding: 8px 10px; }
.task-btns { display: flex; gap: 8px; margin-top: 10px; }
.task-btn { flex: 1; padding: 9px 6px; border: none; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.task-btn.status { background: var(--pill-blue); color: #fff; }
.task-btn.status:hover { background: #4a7fc4; }
.task-btn.draft { background: var(--orange); color: #fff; }
.task-btn.draft:hover { background: #e0951a; }
.task-btn.publish { background: var(--pill-green); color: #fff; }
.kanban-note { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }

/* Modal */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 200;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: 14px; max-width: 560px; width: 100%;
  max-height: 85vh; overflow-y: auto; padding: 24px; position: relative;
}
.modal-close { position: absolute; top: 14px; right: 14px; background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal h3 { margin-bottom: 16px; font-size: 17px; }
.dim-row { margin-bottom: 12px; }
.dim-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.dim-track { height: 8px; background: #f0ece4; border-radius: 4px; overflow: hidden; }
.dim-fill { height: 100%; background: var(--pill-green); border-radius: 4px; }
.dim-note { font-size: 12px; color: var(--muted); margin-top: 3px; }
.verdict { margin-top: 16px; padding: 14px; border-radius: 10px; font-size: 14px; line-height: 1.7; }
.verdict.go { background: var(--green-bg); }
.verdict.wait { background: var(--orange-bg); }
.verdict.skip { background: #f0f1f4; }

/* Mobile */
@media (max-width: 768px) {
  .kanban { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: block; }
  .view { padding: 12px; }
  .topbar { padding: 12px 14px; }
  .topbar-right .live-text { display: none; }
  /* Card layout for table on mobile */
  .kw-table, .kw-table thead, .kw-table tbody, .kw-table th, .kw-table td, .kw-table tr { display: block; }
  .kw-table thead { display: none; }
  .kw-table { min-width: 0; }
  .kw-table tbody tr { border-bottom: 2px solid var(--border); padding: 6px 0; }
  .kw-table tbody td { border: none; padding: 6px 14px; }
  .kw-table tbody td::before {
    content: attr(data-label); display: block;
    font-size: 11px; color: var(--muted); margin-bottom: 3px;
  }
  .kw-table tbody td.col-term::before { display: none; }
  .tags { max-width: none; }
}
