/* ============================================================
   Casa Competitor Intel Dashboard
   Built on the kumo design tokens (assets/kumo-theme.css).
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary:      var(--color-kumo-canvas, #080a0f);
  --bg-card:         var(--color-kumo-base, #10141d);
  --bg-card-hover:   var(--color-kumo-tint, #171d29);
  --bg-elevated:     var(--color-kumo-elevated, #1d2431);
  --bg-recessed:     var(--color-kumo-recessed, #0f1218);
  --border:          var(--color-kumo-line, #263144);
  --border-soft:     var(--color-kumo-hairline, #1a2230);
  --text-primary:    var(--text-color-kumo-default, #eef2f7);
  --text-secondary:  var(--text-color-kumo-subtle, #a6adba);
  --text-tertiary:   var(--text-color-kumo-inactive, #707887);
  --accent:          var(--text-color-kumo-brand, #f6821f);
  --accent-glow:     rgba(246,130,31,0.16);
  --info:            var(--text-color-kumo-info, #60a5fa);
  --info-glow:       rgba(96,165,250,0.16);
  --success:         var(--text-color-kumo-success, #a7f3d0);
  --warning:         var(--text-color-kumo-warning, #facc15);
  --danger:          var(--text-color-kumo-danger, #f87171);
  --radius-card:     var(--radius-kumo-lg, 8px);
  --radius-btn:      var(--radius-kumo-md, 6px);
  --radius-pill:     9999px;
  --ease:            cubic-bezier(0.4, 0, 0.2, 1);
  --font-display:    'Outfit', sans-serif;
  --font-body:       'Plus Jakarta Sans', sans-serif;
  --font-mono:       'JetBrains Mono', monospace;
  --surface-shadow:   var(--shadow-kumo-surface, 0 16px 48px rgba(0,0,0,0.3));
  --focus-ring:       0 0 0 3px rgba(96,165,250,0.24);
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 5% -5%, rgba(246,130,31,0.06), transparent 40%),
    radial-gradient(circle at 95% 0%, rgba(96,165,250,0.05), transparent 40%),
    var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
}

.hidden { display: none !important; }

/* Animations */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.animate-in { animation: fadeSlideUp 0.5s var(--ease) forwards; opacity: 0; }
.animate-in-delay-1 { animation-delay: 0.05s; }
.animate-in-delay-2 { animation-delay: 0.10s; }
.animate-in-delay-3 { animation-delay: 0.15s; }
.animate-in-delay-4 { animation-delay: 0.20s; }
.animate-in-delay-5 { animation-delay: 0.25s; }
.animate-in-delay-6 { animation-delay: 0.30s; }

/* Layout */
.dashboard {
  max-width: 1640px;
  margin: 0 auto;
  padding: 18px 24px 60px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 10px;
  z-index: 40;
  padding: 12px 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  background: rgba(20, 24, 33, 0.85);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04), 0 18px 42px rgba(0,0,0,0.26);
  backdrop-filter: blur(14px);
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-logo {
  width: 44px; height: 44px;
  background: var(--accent);
  border-radius: var(--radius-card);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: #111;
  font-family: var(--font-display);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25), 0 4px 14px rgba(246,130,31,0.35);
}
.header-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.header-title span { color: var(--accent); }
.header-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
  letter-spacing: 0.01em;
}
.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.live-indicator {
  display: flex; align-items: center; gap: 8px;
  background: var(--color-kumo-success-tint, rgba(0,214,143,0.08));
  border: 1px solid rgba(167,243,208,0.22);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--success);
}
.live-dot {
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
.last-refresh-ts {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.7rem;
}
.header-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-btn);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  font-family: var(--font-body);
}
.header-btn:hover { background: var(--bg-card-hover); border-color: var(--text-tertiary); }
.header-btn-primary {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
  font-weight: 700;
}
.header-btn-primary:hover { filter: brightness(1.08); }

/* Status strip */
.status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  padding: 14px 16px;
}
.status-card-primary {
  background: linear-gradient(135deg, var(--bg-card), rgba(246,130,31,0.06));
  border-color: rgba(246,130,31,0.25);
}
.status-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}
.status-value {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.status-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
  font-family: var(--font-mono);
}
.status-ok { color: var(--success); }

/* KPI hero */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease);
}
.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--text-tertiary);
}
.kpi-card.kpi-accent {
  background: linear-gradient(135deg, var(--bg-card), rgba(246,130,31,0.07));
  border-color: rgba(246,130,31,0.30);
}
.kpi-card.kpi-accent::after {
  content: '';
  position: absolute; right: 0; top: 0; bottom: 0; width: 2px;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}
.kpi-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.kpi-value {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}
.kpi-value.kpi-warn { color: var(--warning); }
.kpi-sub {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 6px;
  font-family: var(--font-mono);
}

/* Sections */
.board-section, .themes-section, .theme-distribution-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--surface-shadow);
}
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.section-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.005em;
}
.section-title .icon { margin-right: 6px; }
.section-note {
  font-size: 0.74rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border-soft);
  background: var(--bg-recessed);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.data-table thead {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.data-table th {
  text-align: left;
  padding: 11px 14px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.data-table th.num { text-align: right; }
.data-table th.rank-col { width: 50px; text-align: center; }
.data-table th.status-col { width: 90px; }
.data-table.sortable-table th { cursor: pointer; user-select: none; }
.data-table.sortable-table th:hover { color: var(--text-primary); }
.data-table.sortable-table th[data-sort-active]::after {
  content: '▾';
  margin-left: 4px;
  color: var(--accent);
}
.data-table.sortable-table th[data-sort-active="asc"]::after {
  content: '▴';
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.12s var(--ease);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.data-table td {
  padding: 11px 14px;
  white-space: nowrap;
}
.data-table td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.data-table td.rank-col {
  text-align: center;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-weight: 600;
}
.data-table td.name-col, .data-table td.advertiser-cell {
  font-weight: 600;
  color: var(--text-primary);
}
.data-table td.domain-cell {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.data-table td.cmp-cell {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-tertiary);
}

/* Status pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.pill-known { background: rgba(167,243,208,0.10); color: var(--success); border: 1px solid rgba(167,243,208,0.25); }
.pill-new   { background: rgba(248,113,113,0.10); color: var(--danger);  border: 1px solid rgba(248,113,113,0.30); }
.pill-yes   { background: rgba(167,243,208,0.10); color: var(--success); border: 1px solid rgba(167,243,208,0.25); }
.pill-no    { background: rgba(112,120,135,0.10); color: var(--text-tertiary); border: 1px solid var(--border); }

/* Themes grid */
.themes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.theme-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--surface-shadow);
}
.theme-card.theme-whitespace { border-color: rgba(167,243,208,0.20); }
.theme-card.theme-saturated  { border-color: rgba(248,113,113,0.20); }

.theme-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
}
.theme-row {
  display: grid;
  grid-template-columns: 1fr 50px 70px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-btn);
  background: var(--bg-recessed);
  border: 1px solid var(--border-soft);
  font-size: 0.84rem;
}
.theme-row .theme-name {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}
.theme-row .theme-count {
  text-align: right;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: 0.78rem;
}
.theme-row .theme-pct {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 700;
}
.theme-whitespace .theme-pct { color: var(--success); }
.theme-saturated  .theme-pct { color: var(--danger); }

/* Theme distribution bars */
.theme-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bar-row {
  display: grid;
  grid-template-columns: 200px 1fr 72px;
  align-items: center;
  gap: 12px;
  padding: 5px 0;
  font-size: 0.82rem;
}
.bar-row .bar-name {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-row .bar-track {
  height: 8px;
  background: var(--bg-recessed);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}
.bar-row .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--info), var(--accent));
  border-radius: 4px;
  transition: width 0.8s var(--ease);
}
.bar-row .bar-pct {
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: right;
  color: var(--text-secondary);
  font-size: 0.78rem;
}

/* Pager */
.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px 0;
  flex-wrap: wrap;
}
.pager-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 7px 14px;
  border-radius: var(--radius-btn);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.15s var(--ease);
}
.pager-btn:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  color: var(--accent);
}
.pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pager-info {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  flex: 1;
}
.pager-size { padding: 7px 12px; font-size: 0.78rem; }

/* Contact cells */
.data-table td.contact-cell {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table td.contact-cell a {
  color: var(--info);
  text-decoration: none;
}
.data-table td.contact-cell a:hover { text-decoration: underline; }
.data-table td.contact-empty {
  color: var(--text-tertiary);
  font-style: italic;
  font-size: 0.74rem;
}
.platform-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(96,165,250,0.10);
  color: var(--info);
  border: 1px solid rgba(96,165,250,0.25);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Search */
.search-wrap {
  margin-bottom: 12px;
}
.search-input {
  width: 100%;
  background: var(--bg-recessed);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 11px 14px;
  border-radius: var(--radius-btn);
  font-size: 0.92rem;
  font-family: var(--font-body);
  transition: border-color 0.15s var(--ease);
}
.search-input::placeholder { color: var(--text-tertiary); }
.search-input:focus { border-color: var(--accent); }

/* Empty state */
.empty-state {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.92rem;
  font-style: italic;
}

/* Footer */
.dashboard-footer {
  margin-top: 32px;
  padding: 18px 16px;
  border-top: 1px solid var(--border-soft);
  font-size: 0.74rem;
  color: var(--text-tertiary);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-family: var(--font-mono);
}
.dashboard-footer code { color: var(--text-secondary); }

/* Responsive */
@media (max-width: 1280px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 960px) {
  .status-strip { grid-template-columns: 1fr 1fr; }
  .themes-grid  { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .kpi-row     { grid-template-columns: 1fr 1fr; }
  .status-strip { grid-template-columns: 1fr; }
  .header-title { font-size: 1.25rem; }
  .bar-row     { grid-template-columns: 110px 1fr 56px; }
}
