/* ======= Reset & base ======= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #f5f6fa;
  color: #1a1d29;
  line-height: 1.5;
  font-size: 14px;
}
a { color: #6b4eff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ======= Layout ======= */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

header.hero {
  background: linear-gradient(135deg, #5b3fdd 0%, #8a6cff 100%);
  color: white;
  padding: 40px 24px 32px;
  margin-bottom: 24px;
  border-radius: 0 0 18px 18px;
}
header.hero .container { padding: 0 24px; }
header.hero h1 {
  font-size: 28px;
  margin: 0 0 4px;
  letter-spacing: -0.5px;
}
header.hero p {
  margin: 0;
  opacity: 0.85;
  font-size: 15px;
}
header.hero .meta {
  margin-top: 14px;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
  opacity: 0.9;
}
header.hero .meta span { background: rgba(255,255,255,0.15); padding: 4px 10px; border-radius: 999px; }

section.card {
  background: white;
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(16,24,40,0.06), 0 1px 2px rgba(16,24,40,0.04);
}
section.card h2 {
  font-size: 18px;
  margin: 0 0 16px;
  color: #1a1d29;
  letter-spacing: -0.3px;
}
section.card .subtitle {
  margin: -10px 0 16px;
  color: #6a7086;
  font-size: 13px;
}

/* ======= KPI cards ======= */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi {
  background: white;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(16,24,40,0.06);
  border-left: 4px solid #6b4eff;
}
.kpi.red { border-left-color: #e54d4d; }
.kpi.green { border-left-color: #2fb568; }
.kpi.amber { border-left-color: #f39c12; }
.kpi.blue { border-left-color: #3a7bff; }
.kpi .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6a7086;
  margin-bottom: 6px;
  font-weight: 600;
}
.kpi .value {
  font-size: 28px;
  font-weight: 700;
  color: #1a1d29;
  line-height: 1.1;
}
.kpi .sub {
  font-size: 12px;
  color: #6a7086;
  margin-top: 4px;
}

/* ======= Tables ======= */
.table-wrap {
  overflow-x: auto;
  max-height: 620px;
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid #e6e8f0;
}
table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
table.data thead th {
  position: sticky;
  top: 0;
  background: #f1f2f8;
  z-index: 2;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #3f4459;
  border-bottom: 2px solid #dcdfed;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
table.data thead th:hover { background: #e8eaf3; }
table.data thead th.sorted-asc::after { content: ' ▲'; color: #6b4eff; font-size: 10px; }
table.data thead th.sorted-desc::after { content: ' ▼'; color: #6b4eff; font-size: 10px; }
table.data tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid #eceef5;
  vertical-align: middle;
}
table.data tbody tr:hover { background: #fafbff; }
table.data tbody tr.super-gap {
  background: linear-gradient(90deg, #fff7db 0%, transparent 70%);
}
table.data tbody tr.super-gap:hover { background: #fff3c4; }

/* cells */
.kw { font-weight: 500; max-width: 340px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { text-align: center; }
.pos.top3 { color: #2fb568; font-weight: 700; }
.pos.top10 { color: #5b3fdd; font-weight: 600; }
.pos.top20 { color: #3a7bff; }
.pos.low { color: #9aa0b4; }
.pos.none { color: #d0d4e0; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}
.badge.transactional { background: #ffe3e3; color: #c33; }
.badge.commercial { background: #e3f0ff; color: #2867b8; }
.badge.informational { background: #eef0f5; color: #6a7086; }
.badge.navigational { background: #efe3ff; color: #6b3fb3; }
.badge.super { background: linear-gradient(90deg, #ffd54a, #ff9900); color: #5a3a00; }

.score-bar {
  display: inline-block;
  min-width: 48px;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
  background: #6b4eff;
  color: white;
  text-align: center;
}
.score-bar.lower { background: #a9a5c9; }

.kd-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: #e3fbe9;
  color: #1d7a3c;
}
.kd-chip.kd-med { background: #fff4cc; color: #8a6a00; }
.kd-chip.kd-hi { background: #ffe0e0; color: #a62828; }

/* ======= Filters ======= */
.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}
.filters input[type=text], .filters input[type=number], .filters select {
  padding: 8px 12px;
  border: 1px solid #d5d9e8;
  border-radius: 8px;
  font-size: 13px;
  background: white;
  min-width: 120px;
}
.filters input[type=text] { min-width: 220px; }
.filters label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #6a7086;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}
.filters button {
  padding: 8px 14px;
  border: 1px solid #d5d9e8;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #3f4459;
}
.filters button:hover { background: #f6f7fc; }
.filters button.primary {
  background: #6b4eff;
  color: white;
  border-color: #6b4eff;
}
.filters button.primary:hover { background: #5b3fdd; }

/* ======= Chart area ======= */
.chart-container {
  position: relative;
  height: 320px;
  margin-top: 10px;
}

/* ======= Two column ======= */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ======= Tab nav ======= */
nav.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
nav.tabs button {
  padding: 10px 16px;
  background: white;
  border: 1px solid #d5d9e8;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #3f4459;
}
nav.tabs button.active {
  background: #1a1d29;
  color: white;
  border-color: #1a1d29;
}

/* ======= Competitor list ======= */
.comp-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}
.comp-card {
  padding: 12px 14px;
  border: 1px solid #e6e8f0;
  border-radius: 10px;
  background: #fafbff;
}
.comp-card .dom {
  font-weight: 600;
  color: #1a1d29;
  margin-bottom: 4px;
  word-break: break-all;
}
.comp-card .meta {
  font-size: 12px;
  color: #6a7086;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

footer {
  text-align: center;
  color: #9aa0b4;
  font-size: 12px;
  padding: 30px 0;
}

.row-count {
  color: #6a7086;
  font-size: 12px;
  margin-left: auto;
}

/* ======= Clusters grid ======= */
.clusters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
}
.cluster-card {
  border: 1px solid #e6e8f0;
  border-radius: 12px;
  padding: 16px 18px;
  background: #fff;
  position: relative;
  overflow: hidden;
}
.cluster-card.P0 { border-left: 4px solid #e54d4d; background: linear-gradient(180deg, #fff8f8 0%, white 60%); }
.cluster-card.P1 { border-left: 4px solid #f39c12; background: linear-gradient(180deg, #fffaf0 0%, white 60%); }
.cluster-card.P2 { border-left: 4px solid #9aa0b4; }
.cluster-card .head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.cluster-card .title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
}
.cluster-card .tier {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.cluster-card.P0 .tier { background: #ffd6d6; color: #c33; }
.cluster-card.P1 .tier { background: #ffe9c7; color: #8a5e00; }
.cluster-card.P2 .tier { background: #eef0f5; color: #6a7086; }
.cluster-card .descr {
  font-size: 12px;
  color: #6a7086;
  line-height: 1.45;
  margin: 4px 0 10px;
}
.cluster-card .stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  margin-bottom: 10px;
}
.cluster-card .stats span { color: #3f4459; }
.cluster-card .stats b { color: #1a1d29; font-weight: 700; }
.cluster-card .pillar {
  background: #f5f3ff;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 12.5px;
}
.cluster-card .pillar .lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b4eff;
  font-weight: 700;
}
.cluster-card .pillar .kw {
  font-weight: 600;
  color: #1a1d29;
  word-break: break-word;
}
.cluster-card .supp {
  font-size: 12px;
}
.cluster-card .supp .lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6a7086;
  font-weight: 700;
  margin-bottom: 4px;
}
.cluster-card .supp ul {
  margin: 0;
  padding: 0 0 0 16px;
  color: #3f4459;
  max-height: 115px;
  overflow-y: auto;
}
.cluster-card .supp li {
  margin: 1px 0;
  font-size: 12px;
}
.cluster-card .supp li span { color: #9aa0b4; font-size: 11px; margin-left: 6px; }

/* ======= Calendar ======= */
.calendar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.week-card {
  border: 1px solid #e6e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  background: white;
}
.week-card h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #6a7086;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
}
.week-card h3 .date { color: #9aa0b4; font-weight: 500; text-transform: none; font-size: 12px; }
.week-card .article {
  padding: 9px 0;
  border-top: 1px solid #eceef5;
  font-size: 13px;
}
.week-card .article:first-of-type { border-top: 0; padding-top: 2px; }
.week-card .article .t {
  font-weight: 600;
  color: #1a1d29;
  line-height: 1.3;
  margin-bottom: 3px;
}
.week-card .article .k {
  font-size: 11.5px;
  color: #6b4eff;
}
.week-card .article .meta {
  margin-top: 3px;
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: #6a7086;
  flex-wrap: wrap;
}
.week-card .article .meta .pill {
  background: #eef0f5;
  padding: 1px 7px;
  border-radius: 999px;
}
.week-card .article.pillar {
  background: linear-gradient(180deg, #f5f3ff 0%, white 100%);
  margin: 0 -14px;
  padding: 9px 14px;
  border-top: 1px solid #e0dcff;
}
.week-card .article.pillar .t::before {
  content: '📘 Pillar · ';
  font-weight: 700;
  color: #6b4eff;
}

/* ======= Plain-language explanation blocks ======= */
.plain {
  background: linear-gradient(180deg, #f0f7ff 0%, #f7faff 100%);
  border: 1px solid #d6e4f5;
  border-left: 4px solid #2867b8;
  border-radius: 10px;
  padding: 14px 18px;
  margin: 6px 0 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 22px;
  font-size: 13.5px;
  line-height: 1.55;
}
.plain .block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.plain .lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
  color: #2867b8;
}
.plain .txt {
  color: #1a1d29;
}
.plain .txt strong { color: #0f1220; }
.plain .txt code {
  background: #e6edf8;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  color: #2867b8;
}
.plain.single {
  grid-template-columns: 1fr;
}
.plain ul {
  margin: 4px 0 0;
  padding-left: 18px;
}
.plain li { margin: 2px 0; color: #1a1d29; }
@media (max-width: 780px) {
  .plain { grid-template-columns: 1fr; }
}

/* Lead / intro text above KPIs */
.lead {
  background: white;
  border: 1px solid #e6e8f0;
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 18px;
  font-size: 14px;
  line-height: 1.6;
  color: #1a1d29;
}
.lead h3 {
  margin: 0 0 6px;
  font-size: 15px;
  color: #2867b8;
}
.lead p { margin: 0 0 8px; }
.lead p:last-child { margin-bottom: 0; }
