:root {
  --ink: #122033;
  --muted: #6d7f92;
  --line: #dce5ee;
  --soft: #f3f7fb;
  --surface: #ffffff;
  --blue: #0059d6;
  --blue-dark: #0049b2;
  --green: #12b76a;
  --orange: #f79009;
  --red: #d92d20;
  --purple: #875bf7;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: #edf2f6;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.topbar-content {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
}
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  text-decoration: none;
  font-size: 18px;
}
.brand-icon,
.project-avatar {
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-weight: 900;
}
.brand-icon {
  width: 33px;
  height: 33px;
  background: #fff;
  color: var(--blue);
  font-size: 13px;
}
.project-switcher {
  display: none;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  font-weight: 700;
}
.project-avatar {
  width: 25px;
  height: 25px;
  background: #20b7ff;
  color: #fff;
  font-size: 13px;
}
.topbar-spacer { flex: 1; }
.user-pill {
  align-items: center;
  gap: 8px;
  max-width: 260px;
  overflow: hidden;
  color: #eaf3ff;
  font-size: 13px;
}
.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.icon-button.light {
  border-color: rgba(255,255,255,.22);
  background: rgba(255,255,255,.12);
  color: #fff;
}

.report-page {
  width: min(100%, 1280px);
  margin: 0 auto;
  padding: 14px;
}
.report-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 8px 0 14px;
}
.control-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(18,32,51,.04);
}
.control-card > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.date-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.date-pair input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
  color: var(--ink);
  font-size: 13px;
}
.template-card strong {
  font-size: 16px;
}
.control-actions {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 8px;
}
.control-actions .btn {
  min-height: 46px;
  border-radius: 8px;
  font-weight: 800;
}
.notice-strip {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
.notice-strip div {
  display: flex;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid #fedf89;
  border-radius: 8px;
  background: #fffaeb;
  color: #93370d;
  font-size: 13px;
}

.report-paper {
  width: min(100%, 980px);
  margin: 0 auto 40px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(18,32,51,.08);
  overflow: hidden;
}
.report-cover {
  text-align: center;
  padding: 34px 18px 26px;
  border-bottom: 1px solid var(--line);
}
.cover-mark {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 999px;
  background: #20b7ff;
  color: #fff;
  font-size: 30px;
  font-weight: 900;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 8px;
  font-size: 27px;
  line-height: 1.12;
}
h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}
h3 {
  margin-bottom: 8px;
  font-size: 16px;
  line-height: 1.2;
}
.cover-subtitle {
  max-width: 620px;
  margin: 0 auto 12px;
  color: var(--muted);
  line-height: 1.45;
}
.cover-period {
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 800;
}
.cover-period span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 500;
}
.integration-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.integration-chips span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.integration-chips .active {
  color: #027a48;
  background: #ecfdf3;
  border-color: #abefc6;
}
.integration-chips .inactive {
  color: var(--muted);
  background: #f8fafc;
}

.report-section {
  padding: 22px 16px;
  border-top: 4px solid var(--line);
}
.section-green { border-top-color: var(--green); }
.section-blue { border-top-color: var(--blue); }
.section-orange { border-top-color: var(--orange); }
.section-ai { border-top-color: var(--purple); background: #fbfaff; }
.section-table { border-top-color: #25a9ff; }
.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.section-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue);
  font-size: 19px;
}
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.kpi-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.kpi-card span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.kpi-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 25px;
  line-height: 1.1;
}
.kpi-card small {
  color: var(--muted);
}
.kpi-card em {
  align-self: start;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}
em.good { color: #027a48; background: #dcfae6; }
em.bad { color: #b42318; background: #fee4e2; }
em.neutral { color: #475467; background: #eef2f6; }

.insight-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.insight-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: #fff;
}
.insight-card p {
  color: var(--muted);
  margin-bottom: 8px;
}
.insight-card strong {
  display: block;
  font-size: 14px;
}
.insight-card.tone-danger { border-left-color: var(--red); }
.insight-card.tone-warning { border-left-color: var(--orange); }
.insight-card.tone-success { border-left-color: var(--green); }
.insight-card.tone-info { border-left-color: var(--blue); }
.ai-text {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid #d9d6fe;
  border-radius: 8px;
  background: #f4f3ff;
  line-height: 1.55;
}
.small-warning {
  display: flex;
  gap: 8px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.platform-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.platform-summary article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.platform-summary strong {
  display: block;
  margin: 10px 0 4px;
  font-size: 26px;
}
.platform-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.platform-badge {
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.platform-badge.google { background: #12b76a; }
.platform-badge.meta { background: #0059d6; }
.chart-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.mini-heading {
  margin-bottom: 12px;
}
.mini-heading h3 { margin-bottom: 0; }
.chart-grid,
.two-column-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}
.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
}
.data-table th,
.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}
.data-table th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.data-table.compact th,
.data-table.compact td {
  padding: 10px;
}
.strong-cell {
  color: var(--ink);
  font-weight: 800;
}
.empty-state {
  color: var(--muted);
  text-align: center;
}

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(0,89,214,.16), transparent 30rem),
    linear-gradient(135deg, #edf4ff, #f8fafc 55%, #f0fdf4);
}
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-panel {
  width: min(100%, 430px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(18,32,51,.12);
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.brand-lockup .brand-mark,
.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
}
.brand-lockup h1 { font-size: 30px; }
.compact-alert {
  padding: 10px 12px;
  font-size: 14px;
}
.login-form .form-control {
  border-radius: 8px;
}

@media (min-width: 760px) {
  .project-switcher { display: inline-flex; }
  .report-page { padding: 18px; }
  .report-controls {
    grid-template-columns: 1.2fr 1.2fr .8fr auto;
    align-items: stretch;
  }
  .control-actions {
    grid-template-columns: auto 48px;
    align-self: stretch;
  }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .platform-summary,
  .chart-grid,
  .two-column-section {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .report-section { padding: 26px 28px; }
}

@media (min-width: 1120px) {
  .topbar-content { padding: 0 24px; }
  .report-controls { grid-template-columns: 1.2fr 1.2fr .75fr auto; }
  .kpi-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .kpi-card {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .kpi-card em { justify-self: start; }
}
