:root {
  --bg: #eef3fb;
  --surface: #ffffff;
  --surface-strong: #f8fbff;
  --text: #132238;
  --muted: #61758f;
  --border: rgba(19, 34, 56, 0.08);
  --shadow: 0 18px 48px rgba(22, 43, 77, 0.12);
  --blue: #1a73e8;
  --red: #d93025;
  --yellow: #f9ab00;
  --green: #188038;
  --good: #0f9d58;
  --warning: #b06000;
  --stable: #3367d6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Bahnschrift", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(26, 115, 232, 0.12), transparent 26%),
    radial-gradient(circle at left 30%, rgba(24, 128, 56, 0.1), transparent 20%),
    linear-gradient(180deg, #f7faff 0%, #edf3fb 100%);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 5vw, 3.7rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.hero-text {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.control-panel,
.panel {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  border-radius: 24px;
}

.control-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.manage-clients-link {
  justify-self: start;
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
}

.manage-clients-link:hover {
  text-decoration: underline;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field select,
#custom-date-range input,
#reload-button {
  min-height: 48px;
  border: 1px solid rgba(19, 34, 56, 0.1);
  border-radius: 14px;
  font: inherit;
}

.field select {
  padding: 0 14px;
  background: #fff;
  color: var(--text);
}

#custom-date-range input {
  width: 100%;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
}

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

/* The [hidden] attribute must win over the display rule above, otherwise the
   custom date fields show even when the period is not "Personalizado". */
.custom-date-range[hidden] {
  display: none;
}

#reload-button {
  border: none;
  background: linear-gradient(135deg, #173c74 0%, #1a73e8 100%);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

#reload-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(26, 115, 232, 0.24);
}

.dashboard {
  display: grid;
  gap: 24px;
}

.panel {
  padding: 22px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.9rem);
  letter-spacing: -0.03em;
}

.meta-line {
  margin: 0;
  color: var(--muted);
  text-align: right;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border-radius: 20px;
}

.overview-card {
  min-height: 172px;
  padding: 24px 20px 20px;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.overview-card[data-color="blue"] {
  background: var(--blue);
}

.overview-card[data-color="red"] {
  background: var(--red);
}

.overview-card[data-color="yellow"] {
  background: var(--yellow);
  color: #3d2b00;
}

.overview-card[data-color="green"] {
  background: var(--green);
}

.card-label-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-label {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 500;
}

.card-caret {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid currentColor;
  opacity: 0.8;
}

.card-value {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 3.3rem);
  letter-spacing: -0.05em;
}

.card-comparison {
  margin: 0;
  font-size: 0.92rem;
  opacity: 0.92;
}

.schedule-head {
  align-items: center;
}

.schedule-title-wrap h3 {
  margin: 0;
}

.schedule-metric {
  min-width: 132px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(19, 34, 56, 0.08);
  background: #f7faff;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.schedule-metric-select {
  min-width: 150px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(19, 34, 56, 0.12);
  background: #f7faff;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.schedule-subtitle {
  margin: 0 0 18px;
  font-size: 1.35rem;
  line-height: 1.35;
  letter-spacing: -0.03em;
}

.schedule-tabs {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.schedule-tab {
  min-width: 132px;
  padding: 12px 16px;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease;
}

.schedule-tab:hover {
  color: var(--text);
}

.schedule-tab.active {
  color: #1a5ee8;
  border-bottom-color: #2a6bff;
}

.schedule-visual {
  min-height: 290px;
  display: grid;
  align-items: center;
}

.schedule-visual.day-view,
.schedule-visual.hour-view {
  gap: 10px;
}

.schedule-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: center;
}

.schedule-row-label,
.schedule-hour-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.schedule-bar-track {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: rgba(26, 115, 232, 0.08);
  overflow: hidden;
}

.schedule-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(42, 107, 255, 0.25), rgba(42, 107, 255, 0.95));
}

.schedule-row-value {
  color: var(--text);
  font-weight: 700;
  font-size: 0.92rem;
}

.schedule-hour-grid {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 12px;
}

.schedule-hour-column {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.schedule-hour-bar {
  width: 100%;
  min-height: 24px;
  border-radius: 10px 10px 6px 6px;
  background: linear-gradient(180deg, rgba(42, 107, 255, 0.95), rgba(42, 107, 255, 0.18));
  transform-origin: bottom;
}

.schedule-hour-tick {
  color: var(--muted);
  font-size: 0.75rem;
}

.schedule-hour-footnote {
  color: var(--muted);
  font-size: 0.88rem;
}

.schedule-matrix {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px 14px;
  align-items: center;
}

.schedule-matrix-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.schedule-matrix-row {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  gap: 3px;
}

.schedule-matrix-cell {
  aspect-ratio: 1 / 1;
  min-height: 14px;
  border-radius: 3px;
  background: rgba(26, 115, 232, 0.06);
  transition: transform 120ms ease, background-color 120ms ease;
}

.schedule-matrix-cell:hover {
  transform: scale(1.15);
}

/* Cells with no data are left blank instead of showing the faint heat color. */
.schedule-matrix-cell--empty {
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(19, 34, 56, 0.05);
}

.schedule-axis {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  margin-top: 12px;
}

.schedule-axis-track {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.82rem;
}

.schedule-insights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.schedule-insight {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(26, 115, 232, 0.08), rgba(26, 115, 232, 0.03));
  border: 1px solid rgba(19, 34, 56, 0.06);
}

.schedule-insight-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.schedule-insight strong {
  display: block;
  font-size: 1rem;
}

.schedule-insight-value {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.search-term-subtitle {
  margin: 0 0 18px;
  font-size: 1.2rem;
  line-height: 1.45;
  letter-spacing: -0.02em;
}

.search-term-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  min-height: 122px;
}

.search-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(100%, 360px);
  min-width: 0;
  flex: 0 1 auto;
  padding: 10px 14px;
  border-radius: 999px;
  border: 2px solid rgba(42, 107, 255, 0.24);
  background: rgba(255, 255, 255, 0.86);
  color: #2e3a4f;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.search-chip:hover {
  border-color: rgba(42, 107, 255, 0.54);
  box-shadow: 0 12px 24px rgba(42, 107, 255, 0.12);
}

.search-chip-label {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-chip-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(42, 107, 255, 0.12);
  color: #1a5ee8;
  font-size: 0.82rem;
  font-weight: 700;
}

/* Terms that actually drove conversions are highlighted in green. */
.search-chip--converting {
  border-color: #16a34a;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(22, 163, 74, 0.12));
}

.search-chip--converting:hover {
  border-color: #15803d;
  box-shadow: 0 12px 24px rgba(22, 163, 74, 0.16);
}

.search-chip--converting .search-chip-value {
  background: rgba(22, 163, 74, 0.16);
  color: #15803d;
}

.negatives-groups {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.negatives-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.negatives-group-name {
  font-weight: 700;
  color: var(--text);
}

.negatives-group-scope {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.negatives-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.negative-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(220, 38, 38, 0.28);
  background: rgba(220, 38, 38, 0.05);
  color: #b42318;
  font-size: 0.86rem;
}

.negative-chip-match {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.12);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.negative-chip--more {
  border-style: dashed;
  background: transparent;
  font-weight: 700;
}

.search-term-insights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.search-term-insight {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(42, 107, 255, 0.06), rgba(42, 107, 255, 0.02));
  border: 1px solid rgba(19, 34, 56, 0.06);
}

.ads-panel-head {
  align-items: flex-start;
}

.ads-metric-switch {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: #f2f6fd;
  border: 1px solid rgba(19, 34, 56, 0.06);
}

.ads-metric-button {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.ads-metric-button.active {
  background: linear-gradient(135deg, #1d5fd0, #1a73e8);
  color: #fff;
}

.ads-subtitle {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.5;
}

.ads-sections {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.ads-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.ads-section-title {
  margin: 0;
  font-size: 1rem;
}

.ads-section-count {
  color: var(--muted);
  font-size: 0.82rem;
}

.ads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.ad-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(19, 34, 56, 0.1);
  background: #fff;
}

.ad-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ad-card-type {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.ad-card-status {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.ad-card-status.is-active {
  color: #15803d;
}

.ad-card-title {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.35;
  color: #1a3aa8;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ad-card-domain {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.ad-card-domain .ad-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.14);
  color: #15803d;
  font-size: 0.68rem;
  font-weight: 700;
}

.ad-card-desc {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ad-card-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: auto;
  padding-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.ad-card-metrics strong {
  color: var(--text);
}

.ads-context-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.ads-context-item {
  color: #1d5fd0;
  font-weight: 700;
}

.ads-context-item::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: #20a464;
}

.ads-preview {
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(19, 34, 56, 0.08);
  background: linear-gradient(180deg, rgba(245, 249, 255, 0.92), rgba(255, 255, 255, 0.98));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.ad-device-shell {
  max-width: 470px;
  margin: 0 auto;
  padding: 18px 16px;
  border-radius: 36px;
  border: 4px solid #d8dde7;
  background: #ffffff;
}

.ad-card-shell {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid #d8dde7;
  background: #fff;
}

.ad-headline {
  margin: 0 0 8px;
  color: #1a0dab;
  font-size: 1.9rem;
  line-height: 1.18;
  letter-spacing: -0.03em;
}

.ad-domain-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  color: #137333;
  font-size: 0.95rem;
}

.ad-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(19, 115, 51, 0.12);
  color: #137333;
  font-weight: 700;
}

.ad-description {
  margin: 0 0 12px;
  color: #4d5156;
  line-height: 1.6;
}

.ad-sitelinks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.ad-sitelink {
  color: #1a0dab;
  font-weight: 500;
}

.ads-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.ads-stat-card {
  padding: 16px;
  border-radius: 18px;
  background: #f8fbff;
  border: 1px solid rgba(19, 34, 56, 0.06);
}

.ads-stat-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ads-stat-card strong {
  display: block;
  font-size: 1.55rem;
  letter-spacing: -0.04em;
}

.ads-stat-value {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.ads-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
}

.ads-footer-copy strong {
  display: block;
  font-size: 1rem;
}

.ads-pagination {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.ads-nav-button {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(19, 34, 56, 0.1);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
}

.ads-nav-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.auction-subtitle {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

.auction-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.auction-metric {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(19, 34, 56, 0.08);
  background: linear-gradient(180deg, #ffffff, #f7faff);
}

.auction-metric-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.auction-metric-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
}

@media (max-width: 720px) {
  .auction-metrics {
    grid-template-columns: 1fr;
  }
}

.loading-state,
.error-state {
  padding: 28px;
  border-radius: 18px;
  text-align: center;
  color: var(--muted);
  background: rgba(26, 115, 232, 0.06);
}

.error-state {
  color: #8d1d17;
  background: rgba(217, 48, 37, 0.08);
}

@media (max-width: 980px) {
  .hero,
  .ads-stats-grid,
  .schedule-insights,
  .search-term-insights {
    grid-template-columns: 1fr;
  }

  .overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px;
    background: rgba(255, 255, 255, 0.08);
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding: 16px 0 28px;
  }

  .panel,
  .control-panel {
    padding: 16px;
    border-radius: 20px;
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }

  .overview-card {
    min-height: 148px;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .ads-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .meta-line {
    text-align: left;
  }

  .schedule-tabs {
    justify-content: flex-start;
  }

  .schedule-tab {
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .search-chip {
    width: 100%;
    justify-content: space-between;
    max-width: 100%;
  }

  .custom-date-range {
    grid-template-columns: 1fr;
  }

  .schedule-hour-grid,
  .schedule-matrix-row {
    gap: 2px;
  }
}
