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

:root {
  --burgundy: #6B1D2A;
  --burgundy-dark: #4a1019;
  --burgundy-tint: #fdf6f7;
  --text: #1a1a1b;
  --muted: #737373;
  --light: #f4f4f4;
  --border: #e1e1e1;
  --black: #0f0e0e;
  --gold: #c9a84c;
  --green: #2d7d3a;
  --amber: #d9a441;
  --red: #c53030;
}

body {
  font-family: 'Mulish', Arial, sans-serif;
  background: #fafafa;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── GATE ── */
.gate {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--burgundy) 0%, var(--burgundy-dark) 100%);
  padding: 24px;
}
.gate-card {
  background: #fff;
  border-radius: 12px;
  padding: 56px 48px;
  width: 100%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}
.gate-brand { font-family: 'Marcellus', Georgia, serif; font-size: 20px; letter-spacing: 4px; color: var(--text); }
.gate-tagline { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--burgundy); margin-top: 4px; }
.gate-hr { width: 40px; height: 1px; background: var(--border); margin: 24px auto; }
.gate-title { font-family: 'Marcellus', Georgia, serif; font-size: 28px; font-weight: 400; color: var(--text); margin-bottom: 8px; }
.gate-subtitle { color: var(--muted); font-size: 14px; margin-bottom: 32px; }
.gate-form { display: flex; flex-direction: column; gap: 12px; }
.gate-form input { padding: 14px 16px; font-size: 16px; border: 1px solid var(--border); border-radius: 8px; font-family: 'Mulish', sans-serif; letter-spacing: 1px; text-align: center; text-transform: uppercase; outline: none; transition: border-color .15s; }
.gate-form input:focus { border-color: var(--burgundy); }
.gate-form button { padding: 14px; background: var(--burgundy); color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; letter-spacing: 0.5px; cursor: pointer; transition: background .15s; font-family: 'Mulish', sans-serif; }
.gate-form button:hover { background: var(--burgundy-dark); }
.gate-error { color: #a33; font-size: 13px; margin-top: 12px; min-height: 16px; }
.gate-footer { margin-top: 40px; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }

/* ── APP SHELL ── */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.top { background: var(--black); color: #fff; padding: 20px 0; }
.top-inner { max-width: 1100px; margin: 0 auto; padding: 0 32px; display: flex; justify-content: space-between; align-items: center; }
.top-brand { font-family: 'Marcellus', Georgia, serif; font-size: 17px; letter-spacing: 3px; }
.top-sub { font-size: 12px; color: #d4a0aa; margin-top: 2px; }
.top-right { display: flex; align-items: center; gap: 12px; }
.chip { background: rgba(255,255,255,0.1); padding: 4px 10px; border-radius: 4px; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
.ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.3); padding: 6px 14px; border-radius: 6px; font-size: 12px; cursor: pointer; font-family: 'Mulish', sans-serif; }
.ghost:hover { background: rgba(255,255,255,0.1); }

/* ── HERO ── */
.hero { background: var(--burgundy); color: #fff; padding: 56px 0; }
.hero-inner { max-width: 1100px; margin: 0 auto; padding: 0 32px; }
.hero-small { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: #d4a0aa; margin-bottom: 12px; }
.hero h1 { font-family: 'Marcellus', Georgia, serif; font-size: 44px; font-weight: 400; line-height: 1.1; margin-bottom: 12px; }
.hero-line { font-size: 16px; color: #f0d4d9; max-width: 620px; }

/* ── SECTIONS (uniform width) ── */
.section { max-width: 1100px; margin: 48px auto 0; padding: 0 32px; }
.section-head {
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}
.section-head-left { flex: 1; min-width: 240px; }
.section-head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.section-head h2 { font-size: 26px; color: var(--text); margin-bottom: 4px; font-weight: 400; }
.sans-bold { font-family: 'DM Sans', sans-serif; font-weight: 500; }
.serif-italic { font-family: 'Marcellus', Georgia, serif; font-style: italic; }
.section-sub { color: var(--muted); font-size: 14px; }

.filter-label { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.month-filter {
  padding: 8px 30px 8px 12px;
  font-family: 'Mulish', sans-serif;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%236B1D2A' stroke-width='1.5' fill='none'/></svg>") no-repeat right 10px center;
  appearance: none;
  color: var(--burgundy);
  cursor: pointer;
  min-width: 180px;
}
.month-filter:focus { outline: none; border-color: var(--burgundy); }

.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; position: relative; width: 100%; }
.card.burgundy { background: var(--burgundy); border-color: var(--burgundy); color: #fff; }
.card-body { padding: 28px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; font-size: 14px; }
.empty-inline { color: var(--muted); font-size: 13px; padding: 12px 4px; }

/* ── RANK TABLE (top-5 with page label) ── */
.rank-table { width: 100%; }
.rank-row {
  display: grid;
  grid-template-columns: 2fr 0.6fr 1fr;
  gap: 12px;
  padding: 14px 8px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.rank-row:last-child { border-bottom: none; }
.rank-header {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.rank-kw { font-family: 'Mulish', sans-serif; font-size: 14px; color: var(--text); font-weight: 600; }
.rank-cell-head { text-align: center; }
.rank-cell { text-align: center; font-family: 'Marcellus', Georgia, serif; font-size: 22px; color: var(--burgundy); }
.rank-trend { text-align: center; }

.page-chip {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-family: 'DM Sans', sans-serif;
}
.page-chip.page-1 { background: #e8f5e9; color: var(--green); }
.page-chip.page-2 { background: #fdf4e0; color: #876b1f; }
.page-chip.page-3 { background: #fdece0; color: #a85824; }
.page-chip.page-4plus { background: #f4f4f4; color: var(--muted); }
.page-chip.page-none { color: #ccc; }

/* ── TREND CHART ── */
.trend-wrap {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px dashed var(--border);
}
.trend-head { margin-bottom: 16px; }
.trend-head h3 { font-size: 18px; font-weight: 400; color: var(--text); margin-bottom: 4px; }
.trend-chart { width: 100%; overflow-x: auto; }

/* ── LOCAL RANKING (sleek black) ── */
.local-card { background: var(--black); color: #fff; border-color: var(--black); }
.local-content {
  padding: 44px 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 40px;
  min-height: 200px;
}
.local-left { flex: 1; min-width: 0; }
.local-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #d4a0aa;
  margin-bottom: 14px;
}
.local-keyword {
  font-family: 'Marcellus', Georgia, serif;
  font-size: 38px;
  font-weight: 400;
  color: #fff;
  line-height: 1.15;
  word-break: break-word;
  margin-bottom: 10px;
}
.local-area { font-size: 13px; color: #a8a8a8; letter-spacing: 0.5px; }

.local-right {
  flex-shrink: 0;
  text-align: right;
  padding-left: 32px;
  border-left: 1px solid rgba(255,255,255,0.08);
}
.local-rank-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #d4a0aa;
  margin-bottom: 8px;
}
.local-rank-row {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: flex-end;
}
.local-target { flex-shrink: 0; opacity: 0.85; }
.local-rank-value {
  font-family: 'Marcellus', Georgia, serif;
  font-size: 68px;
  color: #fff;
  line-height: 1;
  font-weight: 400;
}
.local-rank-sub {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #c9a84c;
  margin-top: 8px;
  font-weight: 600;
}

/* ── STATS trio ── */
.stats-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 0;
}
.stats-trio {
  grid-template-columns: 1fr auto 1fr auto 1fr;
}
.stat-pair-item {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 8px 24px;
}
.stat-pair-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: var(--burgundy-tint);
  color: var(--burgundy);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-pair-body { flex: 1; min-width: 0; }
.stat-pair-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.stat-pair-value {
  font-family: 'Marcellus', Georgia, serif;
  font-size: 42px;
  color: var(--text);
  line-height: 1;
}
.stat-pair-delta {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Mulish', sans-serif;
}
.stat-pair-delta.delta-up { color: var(--green); }
.stat-pair-delta.delta-up::before { content: '▲ '; font-size: 10px; }
.stat-pair-delta.delta-flat { color: var(--muted); }
.stat-pair-delta.delta-down { color: var(--red); }
.stat-pair-delta.delta-down::before { content: '▼ '; font-size: 10px; }
.stat-pair-delta.delta-neutral { color: var(--muted); font-weight: 500; }

.stat-pair-divider {
  width: 1px;
  background: var(--border);
  margin: 12px 0;
}

/* ── GBP HEALTH MATRIX ── */
.gbp-matrix { display: flex; flex-direction: column; gap: 8px; }
.gbp-row {
  display: grid;
  grid-template-columns: 180px repeat(6, 1fr);
  gap: 10px;
  align-items: center;
}
.gbp-row-header .gbp-h {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
  font-weight: 600;
}
.gbp-rowlabel {
  font-family: 'Mulish', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding-right: 16px;
}
.gbp-cell {
  height: 64px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Marcellus', Georgia, serif;
  font-size: 22px;
  color: var(--text);
  background: var(--light);
  border: 1px solid var(--border);
}
.gbp-cell.band-strong { background: #e8f5e9; border-color: #bcddc0; color: var(--green); }
.gbp-cell.band-moderate { background: #fdf4e0; border-color: #ead9a8; color: #876b1f; }
.gbp-cell.band-needs { background: #fde8e8; border-color: #ebbebe; color: var(--red); }
.gbp-cell.band-none { color: #bbb; font-size: 18px; }
.gbp-cell.band-none::before { content: '·'; color: #ccc; font-size: 24px; }
.gbp-cell.band-none:has(> *) { color: #bbb; }

.gbp-legend { display: flex; gap: 24px; justify-content: center; margin-top: 24px; font-size: 12px; color: var(--muted); font-weight: 500; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-dot.strong { background: #bcddc0; }
.legend-dot.moderate { background: #ead9a8; }
.legend-dot.needs { background: #ebbebe; }

/* ── MONTHLY NOTE ── */
.latest-month { font-family: 'DM Sans', sans-serif; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: #d4a0aa; margin-bottom: 12px; }
.monthly-note { font-family: 'Mulish', sans-serif; font-size: 16px; line-height: 1.7; color: #f0d4d9; white-space: pre-wrap; }

/* ── HELPER ── */
.helper-card .card-body { padding: 24px; }
.helper-transcript {
  display: flex; flex-direction: column; gap: 10px;
  min-height: 120px;
  max-height: 340px;
  overflow-y: auto;
  padding: 12px 4px;
  margin-bottom: 16px;
}
.helper-msg {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  max-width: 80%;
}
.helper-msg-bot { background: var(--burgundy-tint); color: var(--text); border-bottom-left-radius: 4px; align-self: flex-start; }
.helper-msg-user { background: var(--burgundy); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.helper-msg strong { color: var(--burgundy); font-weight: 700; }
.helper-msg-user strong { color: #fff; }
.helper-thinking { color: var(--muted); font-style: italic; }

.helper-form { display: flex; gap: 10px; margin-bottom: 14px; }
.helper-form input {
  flex: 1; padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: 'Mulish', sans-serif; outline: none;
}
.helper-form input:focus { border-color: var(--burgundy); }
.helper-form button {
  padding: 12px 22px; background: var(--burgundy); color: #fff; border: none; border-radius: 8px;
  font-weight: 600; cursor: pointer; font-family: 'Mulish', sans-serif;
}
.helper-form button:hover { background: var(--burgundy-dark); }
.helper-suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.helper-chip {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  color: var(--burgundy);
  font-family: 'Mulish', sans-serif;
  transition: all .12s;
}
.helper-chip:hover { border-color: var(--burgundy); background: var(--burgundy-tint); }

/* ── THIS MONTH'S ACTIVITY (combined) ── */
.algo-banner {
  background: linear-gradient(90deg, var(--burgundy-tint) 0%, #fff 100%);
  border: 1px solid var(--burgundy);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
}
.algo-banner-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--burgundy);
  font-weight: 700;
  margin-bottom: 4px;
}
.algo-banner-name {
  font-family: 'Marcellus', Georgia, serif;
  font-size: 18px;
  color: var(--text);
}
.algo-banner-meta { font-size: 12px; color: var(--muted); margin-top: 4px; font-family: 'DM Sans', sans-serif; }
.algo-banner-impact { font-size: 13px; color: var(--text); margin-top: 6px; }

.activity-split {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
}
.activity-col-head {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.activity-list { display: flex; flex-direction: column; }
.activity-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { font-size: 16px; color: var(--burgundy); width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: var(--burgundy-tint); border-radius: 10px; font-weight: 700; }
.activity-label { font-weight: 600; font-size: 13px; }
.activity-detail { font-size: 12px; color: var(--muted); margin-top: 2px; }
.activity-time { font-size: 11px; color: var(--muted); letter-spacing: 1px; }

.maint-summary { display: flex; flex-direction: column; gap: 6px; }
.maint-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.maint-row:last-child { border-bottom: none; }
.maint-row span { color: var(--muted); }
.maint-row strong { color: var(--text); font-weight: 700; font-family: 'Marcellus', Georgia, serif; font-size: 18px; }

/* ── FOOTER ── */
.site-footer { background: var(--black); color: #fff; padding: 40px 0 32px; margin-top: 80px; }
.site-footer-inner { max-width: 1100px; margin: 0 auto; padding: 0 32px; text-align: center; }
.footer-brand { font-family: 'Marcellus', Georgia, serif; font-size: 18px; letter-spacing: 3px; margin-bottom: 4px; }
.footer-tagline { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: #d4a0aa; margin-bottom: 12px; }
.footer-line { font-size: 12px; color: #999; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .activity-split { grid-template-columns: 1fr; }
  .gbp-row { grid-template-columns: 120px repeat(6, 1fr); }
  .gbp-rowlabel { font-size: 12px; padding-right: 8px; }
  .gbp-cell { font-size: 16px; height: 52px; }
  .stats-pair, .stats-trio { grid-template-columns: 1fr; }
  .stat-pair-divider { display: none; }
  .local-rank-row { justify-content: flex-start; }
}
@media (max-width: 720px) {
  .hero h1 { font-size: 32px; }
  .top-inner, .hero-inner, .section { padding-left: 20px; padding-right: 20px; }
  .card-body { padding: 20px; }
  .local-content { flex-direction: column; align-items: flex-start; padding: 28px; gap: 20px; }
  .local-right { text-align: left; padding-left: 0; border-left: none; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 20px; width: 100%; }
  .local-rank-value { font-size: 54px; }
  .rank-row { grid-template-columns: 1.6fr 0.6fr 1fr; gap: 8px; }
  .gbp-row { grid-template-columns: 80px repeat(6, 1fr); }
}
