:root {
  --ink: #1f2722;
  --muted: #65716a;
  --line: #dfe5df;
  --paper: #fbfbf7;
  --panel: #ffffff;
  --green: #00843d;
  --green-2: #10b66a;
  --blue: #3657c8;
  --coral: #bf4b4b;
  --gold: #d99d28;
  --sidebar: #062f21;
  --shadow: 0 18px 45px rgba(20, 36, 28, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
table {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar);
  color: #fff;
  padding: 28px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  color: var(--green);
  font-weight: 900;
}

.brand p {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.brand span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

nav {
  display: grid;
  gap: 6px;
}

nav a {
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  padding: 12px;
  border-radius: 8px;
  font-weight: 700;
}

nav a.active,
nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

main {
  padding: 34px clamp(22px, 4vw, 58px) 56px;
  min-width: 0;
}

.topbar,
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 900;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1;
}

h2 {
  font-size: 22px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.export-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}

.export-button {
  min-height: 42px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  color: var(--blue);
  font-weight: 800;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status-strip {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.status-strip.needs-setup {
  border-color: rgba(191, 75, 75, 0.35);
  background: #fff8f7;
  color: #8f3434;
}

.status-strip.needs-setup .pulse {
  background: var(--coral);
  box-shadow: 0 0 0 7px rgba(191, 75, 75, 0.14);
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green-2);
  box-shadow: 0 0 0 7px rgba(16, 182, 106, 0.14);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 22px;
}

.metric-card span {
  color: var(--muted);
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 44px;
  line-height: 0.95;
}

.metric-card small {
  color: var(--muted);
  font-size: 14px;
}

.panel {
  padding: 24px;
  margin-bottom: 18px;
}

.compact {
  margin-bottom: 18px;
}

.performance-panel {
  padding-bottom: 18px;
}

.date-range-picker {
  position: relative;
}

.date-range-trigger {
  min-height: 46px;
  min-width: 250px;
  display: grid;
  gap: 3px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.date-range-trigger span,
.range-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.date-range-trigger strong {
  font-size: 15px;
}

.calendar-popover {
  position: absolute;
  z-index: 20;
  right: 0;
  top: calc(100% + 10px);
  width: min(400px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(20, 36, 28, 0.18);
}

.range-fields {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.range-field {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.range-field.active {
  border-color: #1a73e8;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.16);
}

.range-field.active span {
  color: #1a73e8;
}

.range-field strong {
  font-size: 15px;
}

.range-dash {
  color: var(--muted);
  font-size: 18px;
}

.calendar-nav {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 6px;
}

.calendar-nav button,
.calendar-actions button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.calendar-nav button {
  width: 30px;
  min-height: 30px;
  font-size: 18px;
  line-height: 1;
}

.calendar-months {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.calendar-month h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}

.weekday-row {
  margin-bottom: 4px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.calendar-grid {
  align-items: center;
}

.calendar-day,
.calendar-blank {
  min-height: 26px;
}

.calendar-day {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.calendar-day:hover,
.calendar-day.in-range {
  background: #e8f1ff;
}

.calendar-day.range-start,
.calendar-day.range-end {
  border-radius: 999px;
  background: #1a73e8;
  color: #fff;
}

.calendar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.calendar-actions button {
  min-height: 32px;
  padding: 0 12px;
}

#applyRange {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.chart-wrap {
  width: 100%;
  min-height: 320px;
  margin-top: 20px;
}

canvas {
  width: 100%;
  height: 320px;
  display: block;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.star-row,
.source-row {
  display: grid;
  grid-template-columns: 118px 1fr 76px;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--muted);
  font-weight: 750;
}

.bar-track {
  height: 14px;
  overflow: hidden;
  border-radius: 6px;
  background: #edf1ed;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  background: var(--green-2);
}

.source-row .bar-fill {
  background: var(--blue);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.action-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.action-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.action-card strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.keyword-list {
  margin: 0;
  padding-left: 24px;
}

.keyword-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.keyword-list li:last-child {
  border-bottom: 0;
}

.data-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 16px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--ink);
  font-size: 14px;
}

td {
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status-pill::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
}

.review-link {
  color: var(--blue);
  font-weight: 900;
  text-decoration: none;
}

.review-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.review-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.review-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.review-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.stars {
  color: var(--gold);
  white-space: nowrap;
  font-weight: 900;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  nav a {
    text-align: center;
  }

  .metric-grid,
  .two-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  main {
    padding: 24px 14px 40px;
  }

  .topbar,
  .panel-header,
  .review-card {
    align-items: flex-start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .metric-grid,
  .two-column,
  .action-grid {
    grid-template-columns: 1fr;
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card strong {
    font-size: 38px;
  }
}
