/* ======================================================
   Flomo 月度复盘仪表盘 — Design System
   ====================================================== */

/* --- Tokens / Variables --- */
:root {
  /* Colors — Dark Mode Palette */
  --bg-base: #0f0f14;
  --bg-surface: #16161e;
  --bg-card: #1c1c27;
  --bg-card-hover: #22222f;
  --bg-elevated: #252535;
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(99, 102, 241, 0.3);

  --text-primary: #e8e8ed;
  --text-secondary: #9d9da8;
  --text-muted: #5d5d6d;
  --text-inverse: #0f0f14;

  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --green: #22c55e;
  --green-glow: rgba(34, 197, 94, 0.15);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.15);
  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.15);
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.15);
  --purple: #a855f7;
  --purple-glow: rgba(168, 85, 247, 0.15);

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 24px var(--accent-glow);

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms;
  --dur-normal: 250ms;
  --dur-slow: 400ms;

  /* Font */
  --font:
    "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
}

/* --- Reset / Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hidden {
  display: none !important;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ======================================================
   Landing Screen
   ====================================================== */
.landing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-6);
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}

.landing::before {
  content: "";
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: pulse-bg 6s ease-in-out infinite;
}

@keyframes pulse-bg {
  0%,
  100% {
    opacity: 0.4;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(1.15);
  }
}

.landing-inner {
  text-align: center;
  position: relative;
  z-index: 1;
  max-width: 920px;
  width: 100%;
}

.landing-logo {
  margin-bottom: var(--sp-10);
}

.landing-logo svg {
  margin-bottom: var(--sp-5);
  filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.3));
}

.landing-logo h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--sp-2);
}

.landing-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 400;
}

/* Dropzone */
.dropzone {
  border: 2px dashed rgba(99, 102, 241, 0.3);
  border-radius: var(--r-xl);
  padding: var(--sp-12) var(--sp-8);
  cursor: pointer;
  transition: all var(--dur-normal) var(--ease);
  background: rgba(99, 102, 241, 0.03);
  position: relative;
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.dropzone-icon {
  color: var(--accent-light);
  margin-bottom: var(--sp-5);
  opacity: 0.7;
}

.dropzone-text {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
}

.dropzone-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.landing-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}

.landing-btn {
  appearance: none;
  border: 1px solid var(--border-accent);
  background: rgba(99, 102, 241, 0.12);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 10px 14px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}

.landing-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--accent);
}

.landing-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.landing-btn--ghost {
  background: transparent;
  border-color: var(--border);
}

.landing-btn--ghost:hover {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.history-panel {
  margin-top: var(--sp-8);
  background: rgba(28, 28, 39, 0.75);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  text-align: left;
  backdrop-filter: blur(3px);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.history-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.history-summary {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.timeline-item {
  border: 1px solid var(--border);
  background: rgba(22, 22, 30, 0.9);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  transition: all var(--dur-fast) var(--ease);
}

.timeline-item:hover {
  border-color: var(--border-accent);
  background: rgba(99, 102, 241, 0.07);
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--accent-light), var(--accent));
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.timeline-main {
  min-width: 0;
}

.timeline-month {
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
}

.timeline-meta {
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.timeline-open {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.78rem;
  transition: all var(--dur-fast) var(--ease);
}

.timeline-open:hover {
  border-color: var(--border-accent);
  background: rgba(99, 102, 241, 0.15);
}

.timeline-empty {
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  font-size: 0.85rem;
}

.upload-history-wrap {
  margin-top: var(--sp-5);
}

.upload-history-wrap h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
  font-weight: 500;
}

.upload-history-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.upload-item {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: rgba(22, 22, 30, 0.7);
  padding: var(--sp-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.upload-main {
  min-width: 0;
}

.upload-name {
  font-size: 0.82rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(62vw, 520px);
}

.upload-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.upload-delete {
  appearance: none;
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all var(--dur-fast) var(--ease);
}

.upload-delete:hover {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.14);
}

.landing-footer {
  margin-top: var(--sp-8);
}

.landing-footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ======================================================
   Dashboard
   ====================================================== */
.dashboard {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--sp-6);
  padding-bottom: var(--sp-12);
  animation: fade-in var(--dur-slow) var(--ease);
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) 0;
  margin-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: var(--sp-3);
}

.dash-header-left {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.dash-title {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.dash-header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  flex-wrap: wrap;
}

.month-selector {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-card);
  border-radius: var(--r-md);
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--border);
}

.month-label {
  font-weight: 600;
  font-size: 0.95rem;
  min-width: 80px;
  text-align: center;
  color: var(--accent-light);
}

.user-info {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.export-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.export-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.76rem;
  line-height: 1;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}

.export-btn:hover {
  border-color: var(--border-accent);
  background: rgba(99, 102, 241, 0.13);
}

.export-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Buttons */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}

.btn-icon:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-sm {
  width: 28px;
  height: 28px;
}

/* ======================================================
   Modules
   ====================================================== */
.module {
  margin-bottom: var(--sp-8);
  animation: slide-up var(--dur-slow) var(--ease) both;
}

.module:nth-child(2) {
  animation-delay: 0.05s;
}
.module:nth-child(3) {
  animation-delay: 0.1s;
}
.module:nth-child(4) {
  animation-delay: 0.15s;
}
.module:nth-child(5) {
  animation-delay: 0.2s;
}
.module:nth-child(6) {
  animation-delay: 0.25s;
}
.module:nth-child(7) {
  animation-delay: 0.3s;
}
.module:nth-child(8) {
  animation-delay: 0.35s;
}
.module:nth-child(9) {
  animation-delay: 0.4s;
}
.module:nth-child(10) {
  animation-delay: 0.45s;
}
.module:nth-child(11) {
  animation-delay: 0.5s;
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.module-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.module-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: var(--accent-glow);
  color: var(--accent-light);
  font-size: 0.8rem;
  font-weight: 700;
}

/* ======================================================
   Metric Cards Grid
   ====================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-4);
}

.metrics-grid--sm {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-5);
  transition: all var(--dur-normal) var(--ease);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  opacity: 0;
  transition: opacity var(--dur-normal) var(--ease);
}

.metric-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-card:hover::before {
  opacity: 1;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.metric-value .unit {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: var(--sp-1);
}

.metric-sub {
  font-size: 0.78rem;
  margin-top: var(--sp-2);
  color: var(--text-secondary);
}

.metric-change {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: var(--sp-2);
}

.metric-change.up {
  color: var(--green);
  background: var(--green-glow);
}

.metric-change.down {
  color: var(--red);
  background: var(--red-glow);
}

.metric-change.neutral {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
}

/* ======================================================
   Data Tables
   ====================================================== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.table-wrap--compact {
  margin-top: var(--sp-2);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: rgba(99, 102, 241, 0.04);
}

.tag-name {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  color: var(--accent-light);
  font-weight: 500;
}

.tag-name::before {
  content: "#";
  opacity: 0.5;
}

.change-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.78rem;
}

.change-badge.positive {
  color: var(--green);
  background: var(--green-glow);
}
.change-badge.negative {
  color: var(--red);
  background: var(--red-glow);
}
.change-badge.zero {
  color: var(--text-muted);
}

/* ======================================================
   Charts
   ====================================================== */
.time-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

.trend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
}

.chart-card h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: var(--sp-4);
  font-weight: 500;
}

/* Simple bar chart system */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.bar-chart--month .bar-label {
  width: 64px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

/* Time-series line chart */
.line-chart {
  min-height: 190px;
}

.line-chart-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.line-plot {
  position: relative;
  width: 100%;
  height: 150px;
}

.line-chart-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.line-grid {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 0.35;
}

.line-area {
  fill: rgba(99, 102, 241, 0.16);
}

.line-path {
  stroke: var(--accent-light);
  stroke-width: 2.4px;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.line-point {
  fill: var(--accent-light);
  stroke: var(--bg-card);
  stroke-width: 0.9;
}

.line-points-layer {
  position: absolute;
  inset: 0;
}

.line-point-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent-light);
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.2);
}

.line-x-axis {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0;
  min-height: 18px;
}

.line-x-label {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.bar-label {
  width: 32px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
}

.bar-track {
  flex: 1;
  height: 24px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm);
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 0.8s var(--ease);
  min-width: 2px;
  position: relative;
}

.bar-fill::after {
  content: attr(data-value);
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}

.bar-count {
  width: 36px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: left;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Top days */
.top-days {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.top-day {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-elevated);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  font-size: 0.85rem;
}

.top-day-rank {
  font-weight: 700;
  color: var(--accent-light);
  font-size: 0.9rem;
}

.top-day-date {
  color: var(--text-primary);
  font-weight: 500;
}

.top-day-count {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* Ratio bar */
.ratio-bar-wrap {
  margin-top: var(--sp-4);
}

.ratio-bar {
  height: 28px;
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  background: var(--bg-elevated);
}

.ratio-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  transition: width 0.8s var(--ease);
}

.ratio-seg.action {
  background: linear-gradient(90deg, var(--green), #4ade80);
}

.ratio-seg.thinking {
  background: linear-gradient(90deg, var(--cyan), #22d3ee);
}

.ratio-label-row {
  display: flex;
  justify-content: space-between;
  margin-top: var(--sp-2);
}

.ratio-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.ratio-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.ratio-dot.action {
  background: var(--green);
}
.ratio-dot.thinking {
  background: var(--cyan);
}

.ratio-seg.new-topic {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.ratio-seg.old-topic {
  background: linear-gradient(90deg, #0ea5e9, #38bdf8);
}

.ratio-dot.new-topic {
  background: #f59e0b;
}

.ratio-dot.old-topic {
  background: #0ea5e9;
}

/* Tag Co-occurrence */
.co-matrix-wrap {
  overflow-x: auto;
  padding-bottom: var(--sp-2);
}

.co-matrix {
  border-collapse: separate;
  border-spacing: 4px;
  min-width: 100%;
}

.co-matrix th {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  min-width: 58px;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.co-matrix td {
  width: 34px;
  height: 32px;
  text-align: center;
  border-radius: 6px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(99, 102, 241, var(--co-alpha, 0.06));
  border: 1px solid rgba(99, 102, 241, 0.1);
  font-variant-numeric: tabular-nums;
}

.co-cell--diag {
  color: var(--text-muted) !important;
  background: rgba(255, 255, 255, 0.04) !important;
  border-color: transparent !important;
}

.co-pair-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.co-pair-item {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  padding: var(--sp-2) var(--sp-3);
}

.co-pair-rank {
  color: var(--accent-light);
  font-weight: 700;
  font-size: 0.8rem;
}

.co-pair-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.co-pair-count {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

/* New tags */
.tag-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  border: 1px solid rgba(99, 102, 241, 0.25);
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-light);
  font-size: 0.78rem;
  line-height: 1;
  max-width: 100%;
}

.tag-chip::before {
  content: "#";
  opacity: 0.7;
}

/* ======================================================
   Anomaly Alert
   ====================================================== */
.anomaly-card {
  background: var(--bg-card);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-left: 4px solid var(--amber);
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-3);
}

.anomaly-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--amber);
  background: var(--amber-glow);
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: var(--sp-2);
}

.anomaly-details {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}

.anomaly-detail {
  font-size: 0.82rem;
}

.anomaly-detail .label {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.anomaly-detail .value {
  color: var(--text-primary);
  font-weight: 600;
}

.no-anomaly {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: var(--sp-5);
  text-align: center;
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
}

/* Anomaly type variants */
.anomaly-card.anomaly-surge {
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-left: 4px solid var(--amber);
}

.anomaly-card.anomaly-disappeared {
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-left: 4px solid var(--purple);
}

.anomaly-badge--disappeared {
  color: var(--purple) !important;
  background: var(--purple-glow) !important;
}

/* ======================================================
   Growth Signal Excerpts
   ====================================================== */
.growth-excerpts {
  margin-top: var(--sp-4);
}

.growth-excerpts-header {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-3);
}

.growth-excerpt-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-2);
  transition: all var(--dur-fast) var(--ease);
}

.growth-excerpt-item:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
}

.growth-excerpt-date {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 80px;
}

.growth-excerpt-text {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.growth-excerpt-kw {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--green);
  background: var(--green-glow);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ======================================================
   Keyword Whitelist Panel
   ====================================================== */
.whitelist-toggle-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--r-full);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  margin-left: auto;
}

.whitelist-toggle-btn:hover {
  border-color: var(--border-accent);
  color: var(--accent-light);
  background: var(--accent-glow);
}

.whitelist-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-4);
  animation: slide-up 0.3s var(--ease) both;
}

.whitelist-panel.hidden {
  display: none;
}

.whitelist-input-row {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
}

.whitelist-textarea {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  padding: var(--sp-3);
  min-height: 60px;
  resize: vertical;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease);
}

.whitelist-textarea:focus {
  border-color: var(--accent);
}

.whitelist-textarea::placeholder {
  color: var(--text-muted);
}

.whitelist-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.whitelist-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
}

.whitelist-btn--save {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
  border-color: transparent;
}

.whitelist-btn--save:hover {
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.whitelist-btn--clear:hover {
  border-color: var(--red);
  color: var(--red);
}

.whitelist-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.whitelist-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  background: var(--accent-glow);
  color: var(--accent-light);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--r-full);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

/* Whitelist row highlight in keyword table */
.whitelist-row td {
  background: rgba(99, 102, 241, 0.04);
}

.whitelist-star {
  margin-right: 4px;
  font-size: 0.72rem;
}

/* ======================================================
   View Mode Tabs
   ====================================================== */
.view-tabs {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 3px;
  margin-bottom: var(--sp-6);
  width: fit-content;
}

.view-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 8px 20px;
  border-radius: var(--r-full);
  cursor: pointer;
  transition: all var(--dur-normal) var(--ease);
  position: relative;
  white-space: nowrap;
}

.view-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.view-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

/* ======================================================
   Macro Range Navigator
   ====================================================== */
.macro-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
  padding: var(--sp-3);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.range-label {
  font-weight: 700;
  font-size: 1.05rem;
  min-width: 140px;
  text-align: center;
  color: var(--accent-light);
  letter-spacing: 0.02em;
}

/* ======================================================
   Footer
   ====================================================== */
.dash-footer {
  text-align: center;
  padding: var(--sp-8) 0;
  border-top: 1px solid var(--border);
  margin-top: var(--sp-8);
}

.dash-footer p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ======================================================
   Loading
   ====================================================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 20, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-elevated);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: var(--sp-4);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ======================================================
   Responsive
   ====================================================== */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
  .dashboard {
    padding: var(--sp-4);
  }
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .time-charts {
    grid-template-columns: 1fr;
  }
  .trend-grid {
    grid-template-columns: 1fr;
  }
  .dash-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .dash-header-right {
    width: 100%;
    gap: var(--sp-3);
  }
  .export-toolbar {
    width: 100%;
  }
  .export-btn {
    flex: 1;
    text-align: center;
    min-width: 88px;
  }
  .metric-value {
    font-size: 1.5rem;
  }
  .landing {
    padding: var(--sp-4);
  }
  .landing-actions {
    flex-direction: column;
  }
  .landing-btn {
    width: 100%;
  }
  .timeline-item {
    grid-template-columns: auto 1fr;
    gap: var(--sp-2);
  }
  .timeline-open {
    grid-column: 2;
    justify-self: start;
    margin-top: var(--sp-1);
  }
  .upload-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .upload-name {
    max-width: 100%;
    white-space: normal;
  }
  .view-tabs {
    width: 100%;
    justify-content: center;
  }
  .view-tab {
    padding: 7px 14px;
    font-size: 0.78rem;
  }
  .macro-nav {
    width: 100%;
    justify-content: center;
  }
  .range-label {
    min-width: 100px;
    font-size: 0.92rem;
  }
  .bar-chart--month .bar-label {
    width: 56px;
  }
  .line-chart {
    min-height: 176px;
  }
  .line-plot {
    height: 140px;
  }
  .line-x-label {
    font-size: 0.64rem;
  }
  .co-matrix th {
    min-width: 46px;
    max-width: 70px;
    font-size: 0.68rem;
  }
  .co-matrix td {
    width: 30px;
    height: 28px;
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .top-days {
    flex-direction: column;
  }
}
