/* ============================================================
   CarePatrol — Provider Data Explorer
   Clean, minimal, Apple-inspired layout.
   Brand accents inspired by carepatrol.com (navy + burgundy).
   Scoped under #cp-app so it plays nicely with GeneratePress.
   ============================================================ */

#cp-app {
  /* CarePatrol-inspired palette */
  --cp-primary: #0b2545;        /* deep navy */
  --cp-primary-600: #13345f;
  --cp-accent: #8a1b2e;         /* burgundy */
  --cp-accent-600: #a32236;

  --cp-bg: #f5f5f7;             /* apple-like light gray */
  --cp-surface: #ffffff;
  --cp-text: #1d1d1f;
  --cp-text-muted: #6e6e73;
  --cp-border: #e5e5ea;
  --cp-border-strong: #d2d2d7;

  --cp-radius: 16px;
  --cp-radius-sm: 10px;
  --cp-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
  --cp-shadow-lg: 0 10px 30px rgba(0,0,0,0.08);

  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--cp-text);
  background: var(--cp-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#cp-app *, #cp-app *::before, #cp-app *::after { box-sizing: border-box; }

/* ---------- WordPress / GeneratePress neutralizer ----------
   Themes apply their own spacing/typography to p, h1-h3, table, form
   controls and .wp-block-* wrappers. Reset those inside #cp-app so the
   app renders identically whether embedded in WP or served standalone.
   :where() keeps the selector specificity at 0 so the component
   styles (.cp-btn, .cp-select, .cp-table, etc.) still win. */
#cp-app :where(p, h1, h2, h3, h4, ul, ol, li, figure, blockquote, pre,
               table, thead, tbody, tr, th, td) {
  margin: 0;
  padding: 0;
}
#cp-app :where(ul, ol) { list-style: none; }
#cp-app :where(table) { border-collapse: collapse; border-spacing: 0; width: 100%; }

#cp-app :where(button, input, select, textarea, label) {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  line-height: normal;
  box-shadow: none;
  min-height: 0;
}
#cp-app :where(label) { display: inline; cursor: inherit; }
#cp-app :where(button) { cursor: pointer; }
#cp-app :where(select) { appearance: none; -webkit-appearance: none; -moz-appearance: none; }

/* Strip theme wrappers WP adds around Custom HTML blocks */
#cp-app :where(.wp-block-html, .wp-block-group, .wp-block-columns,
               .entry-content, .wp-block) {
  margin: 0; padding: 0; max-width: none;
}

/* Neutralize block-editor gap + theme font-size cascade inside the app */
#cp-app {
  --wp--style--block-gap: 0;
  --wp--preset--spacing--20: 0;
  --wp--preset--spacing--30: 0;
  --wp--preset--spacing--40: 0;
  --wp--preset--spacing--50: 0;
  --wp--preset--spacing--60: 0;
  font-size: 15px;
}
#cp-app :where(> * + *) { margin-top: 0; }

#cp-app :where(a) { color: inherit; text-decoration: none; }
#cp-app :where(img) { max-width: 100%; display: block; }

#cp-app h1, #cp-app h2, #cp-app h3 {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.cp-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Hero ---------- */
.cp-hero {
  position: relative;
  background-color: var(--cp-bg);
  background-image:
    linear-gradient(180deg, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0.25) 45%, var(--cp-bg) 100%),
    url("../images/nature-serenity.png");
  background-repeat: no-repeat, no-repeat;
  background-position: center top, center top;
  background-size: 100% 100%, cover;
  padding: 40px 0 56px;
  border-bottom: 1px solid var(--cp-border);
}

.cp-brand {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  margin-bottom: 40px;
  flex-wrap: wrap;
  text-align: center;
}
.cp-brand-logo {
  height: 48px;
  width: auto;
  display: block;
}
.cp-brand-divider {
  width: 1px;
  align-self: stretch;
  background: var(--cp-border-strong);
  min-height: 36px;
}
.cp-brand-title {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  font-size: clamp(20px, 2.2vw, 28px);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--cp-primary);
  margin: 0;
  line-height: 1.2;
}
@media (max-width: 520px) {
  .cp-brand-divider { display: none; }
  .cp-brand { gap: 12px; }
}

.cp-hero-title {
  font-size: clamp(14px, 1.3vw, 18px);
  line-height: 1.45;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--cp-text-muted);
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}
.cp-hero-accent { color: var(--cp-text-muted); font-weight: 400; }

.cp-hero-sub {
  margin-top: 12px;
  font-size: 14px;
  color: var(--cp-text-muted);
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

/* ---------- Sections ---------- */
.cp-section { padding: 28px 0; }
.cp-controls-section { padding-top: 32px; }

.cp-card {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius);
  box-shadow: var(--cp-shadow);
  padding: 22px;
}

/* ---------- Controls ---------- */
.cp-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  align-items: end;
}
.cp-control-actions { grid-column: 1 / -1; justify-content: flex-end; }
@media (min-width: 1100px) {
  .cp-controls {
    grid-template-columns: minmax(160px, 1fr) minmax(200px, 1.3fr) minmax(150px, 1fr) minmax(160px, 1fr) minmax(160px, 1fr) auto;
  }
  .cp-control-actions { grid-column: auto; }
}
.cp-control { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cp-control label {
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--cp-text-muted);
}

.cp-select, .cp-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font: inherit; font-size: 15px;
  color: var(--cp-text);
  background: #fff;
  border: 1px solid var(--cp-border-strong);
  border-radius: var(--cp-radius-sm);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.cp-select:focus, .cp-input:focus {
  border-color: var(--cp-primary);
  box-shadow: 0 0 0 4px rgba(11, 37, 69, 0.12);
}
.cp-select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236e6e73' d='M6 8 0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.cp-control-actions { display: flex; gap: 10px; }

.cp-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 18px;
  font: inherit; font-size: 14px; font-weight: 500;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .05s ease;
  white-space: nowrap;
}
.cp-btn:active { transform: translateY(1px); }
.cp-btn[disabled] { opacity: .45; cursor: not-allowed; }

.cp-btn-primary {
  background: var(--cp-primary); color: #fff;
}
.cp-btn-primary:hover:not([disabled]) { background: var(--cp-primary-600); }

.cp-btn-ghost {
  background: transparent; color: var(--cp-primary);
  border-color: var(--cp-border-strong);
}
.cp-btn-ghost:hover { background: #f0f0f3; }

.cp-btn-accent {
  background: var(--cp-accent); color: #fff;
}
.cp-btn-accent:hover:not([disabled]) { background: var(--cp-accent-600); }

/* ---------- Extraction panel ---------- */
.cp-extract-card { padding: 0; overflow: hidden; }
.cp-extract-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 20px 22px 12px;
  border-bottom: 1px solid var(--cp-border);
}
.cp-extract-header h2 { font-size: 20px; margin-bottom: 2px; }

.cp-progress-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--cp-border);
  background: #fafafa;
}
.cp-progress-bar {
  flex: 1; height: 8px; border-radius: 999px;
  background: var(--cp-border); overflow: hidden;
}
#cp-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--cp-primary), var(--cp-accent));
  transition: width .4s ease;
}
.cp-progress-text {
  font-size: 12.5px; color: var(--cp-text-muted);
  font-variant-numeric: tabular-nums; min-width: 160px; text-align: right;
}

.cp-extract-body {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) 1.3fr;
  gap: 0;
}
.cp-source-list { padding: 16px 22px; border-right: 1px solid var(--cp-border); max-height: 520px; overflow-y: auto; }
.cp-source-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px; align-items: start;
  padding: 10px 0;
  border-bottom: 1px dashed var(--cp-border);
  font-size: 13px;
}
.cp-source-item:last-child { border-bottom: 0; }
.cp-source-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--cp-border-strong);
  margin-top: 6px;
  flex-shrink: 0;
}
.cp-source-item[data-state="loading"] .cp-source-dot {
  background: var(--cp-primary);
  box-shadow: 0 0 0 0 rgba(11,37,69,.6);
  animation: cp-pulse 1.2s infinite;
}
.cp-source-item[data-state="done"]   .cp-source-dot { background: #1a7f37; }
.cp-source-item[data-state="skipped"].cp-source-dot,
.cp-source-item[data-state="skipped"] .cp-source-dot { background: #b76e00; }
.cp-source-item[data-state="error"]  .cp-source-dot { background: #c5283d; }
@keyframes cp-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(11,37,69,.55); }
  70%  { box-shadow: 0 0 0 8px rgba(11,37,69,0); }
  100% { box-shadow: 0 0 0 0 rgba(11,37,69,0); }
}
.cp-source-name { font-weight: 600; color: var(--cp-text); }
.cp-source-sub  { font-size: 11.5px; color: var(--cp-text-muted); margin-top: 2px; line-height: 1.35; }
.cp-source-meta {
  font-size: 11px; color: var(--cp-text-muted);
  text-align: right; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.cp-source-count { display: block; font-weight: 600; color: var(--cp-primary); font-size: 13px; }

.cp-log-panel {
  display: flex; flex-direction: column; min-height: 260px; max-height: 520px;
}
.cp-log-head {
  padding: 10px 22px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--cp-text-muted);
  border-bottom: 1px solid var(--cp-border); background: #fafafa;
}
.cp-log {
  flex: 1; overflow-y: auto;
  padding: 10px 22px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.55;
  color: #3a3a3c;
}
.cp-log-line { padding: 2px 0; white-space: pre-wrap; word-break: break-word; }
.cp-log-ts { color: var(--cp-text-muted); margin-right: 8px; }
.cp-log-src { color: var(--cp-primary); margin-right: 6px; font-weight: 600; }
.cp-log-warn { color: #b76e00; }
.cp-log-error { color: #c5283d; }
.cp-log-ok { color: #1a7f37; }

/* Summary */
.cp-summary {
  padding: 20px 22px 24px;
  border-top: 1px solid var(--cp-border);
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
}
.cp-summary-title { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
.cp-summary-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px;
  margin-bottom: 18px;
}
.cp-summary-tile {
  background: #fff;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-sm);
  padding: 14px;
}
.cp-summary-tile .cp-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--cp-text-muted); font-weight: 600; }
.cp-summary-tile .cp-value { font-size: 22px; font-weight: 600; color: var(--cp-text); margin-top: 4px; }
.cp-summary-tile .cp-value.cp-accent { color: var(--cp-accent); }

.cp-summary-sub { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.cp-summary-sub h3 { font-size: 14px; margin-bottom: 8px; color: var(--cp-text); }
.cp-summary-list { font-size: 12.5px; color: var(--cp-text); }
.cp-summary-list .cp-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--cp-border); }
.cp-summary-list .cp-row:last-child { border-bottom: 0; }
.cp-summary-list .cp-row .cp-muted { color: var(--cp-text-muted); font-size: 11px; }

@media (max-width: 900px) {
  .cp-extract-body { grid-template-columns: 1fr; }
  .cp-source-list { border-right: 0; border-bottom: 1px solid var(--cp-border); max-height: 280px; }
  .cp-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .cp-summary-sub { grid-template-columns: 1fr; }
}

/* ---------- Meta strip ---------- */
.cp-meta {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
}
.cp-meta-item {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-sm);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.cp-meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--cp-text-muted); font-weight: 600; }
.cp-meta-value { font-size: 18px; font-weight: 600; color: var(--cp-text); }

/* ---------- Grid / Table ---------- */
.cp-grid-card { padding: 0; overflow: hidden; }
.cp-grid-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--cp-border);
}
.cp-grid-header h2 { font-size: 20px; }
.cp-grid-info { font-size: 13px; color: var(--cp-text-muted); }

.cp-table-wrap { overflow-x: auto; }
.cp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: auto;
}
.cp-table thead th {
  position: sticky; top: 0;
  background: #fafafa;
  text-align: left;
  font-weight: 600;
  color: var(--cp-text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 10px;
  border-bottom: 1px solid var(--cp-border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.cp-table thead th.cp-num { text-align: right; }
.cp-table thead th .cp-sort { opacity: .4; margin-left: 4px; font-size: 9px; }
.cp-table thead th.cp-sort-asc .cp-sort,
.cp-table thead th.cp-sort-desc .cp-sort { opacity: 1; color: var(--cp-primary); }

.cp-table tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--cp-border);
  vertical-align: top;
  color: var(--cp-text);
}
.cp-table tbody tr:hover td { background: #fafafa; }
.cp-table tbody td.cp-num { text-align: right; font-variant-numeric: tabular-nums; }

.cp-facility-name { font-weight: 600; color: var(--cp-text); font-size: 12.5px; }
.cp-facility-id   { font-size: 10.5px; color: var(--cp-text-muted); margin-top: 2px; }
.cp-facility-meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--cp-text-muted);
  line-height: 1.45;
}
.cp-facility-contact { margin-top: 2px; }
.cp-facility-meta a { color: var(--cp-primary); text-decoration: none; }
.cp-facility-meta a:hover { text-decoration: underline; }

/* Google Places enrichment — image, summary, rating row. Each
   block sits inside .cp-facility-meta below the Website link, so
   the contact column reads top-to-bottom: address → phone → email
   → website → photo → blurb → rating. */
.cp-facility-image-wrap {
  margin-top: 8px;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #f1f2f4;
}
.cp-facility-image {
  width: 100%;
  height: 100%;
  /* Desktop: `cover` fills the 16:9 frame edge-to-edge — no grey
     bars around landscape photos. On mobile we relax this to
     `contain` (below) so portrait/odd-ratio photos aren't clipped. */
  object-fit: cover;
  object-position: center;
  display: block;
}
@media (max-width: 520px), (pointer: coarse) {
  .cp-facility-image-wrap {
    /* Free the height so a tall photo doesn't shrink into a sliver,
       and cap the width so the photo never overflows the viewport.
       Drop the placeholder background here — with `contain` + auto
       height, the wrap hugs the image and there's no letterbox to
       fill. Also applies to landscape phones/tablets via
       `pointer: coarse`, where width can exceed 520px but cropping
       still hurts. */
    max-width: min(320px, 100%);
    aspect-ratio: auto;
    height: auto;
    background: transparent;
  }
  .cp-facility-image {
    object-fit: contain;
    height: auto;
    max-height: 220px;
  }
}
.cp-facility-summary {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--cp-text);
  line-height: 1.45;
  max-width: 320px;
  /* Clamp to ~4 lines so long blurbs don't blow up row height. */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cp-facility-ai-summary {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--cp-text);
  line-height: 1.45;
  max-width: 320px;
}
.cp-facility-ai-summary .cp-ai-text {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cp-facility-ai-summary .cp-ai-disclosure {
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--cp-muted, #6b7280);
  font-style: italic;
}
.cp-facility-rating {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
}
.cp-facility-rating .cp-stars {
  color: #f5a623;
  letter-spacing: 1px;
  font-size: 13px;
  line-height: 1;
}
.cp-facility-rating .cp-rating-num { font-weight: 600; color: var(--cp-text); }
.cp-facility-rating .cp-rating-count { color: var(--cp-text-muted); }
.cp-facility-rating .cp-rating-link { margin-left: 2px; }

.cp-badge {
  display: inline-block;
  font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 999px;
  background: rgba(11,37,69,0.08); color: var(--cp-primary);
  white-space: nowrap;
}
.cp-badge.cp-badge-accent { background: rgba(138,27,46,0.08); color: var(--cp-accent); }

.cp-tag-list { display: flex; flex-wrap: wrap; gap: 3px; }
.cp-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f0f0f3;
  color: #3a3a3c;
  white-space: normal;
  word-break: break-word;
}

.cp-contact { font-size: 12.5px; color: var(--cp-text-muted); line-height: 1.45; }
.cp-contact a { color: var(--cp-primary); text-decoration: none; }
.cp-contact a:hover { text-decoration: underline; }

.cp-empty {
  padding: 60px 22px; text-align: center; color: var(--cp-text-muted);
}

/* ---------- Pagination ---------- */
.cp-pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 22px;
  border-top: 1px solid var(--cp-border);
  flex-wrap: wrap;
}
.cp-pagination-info { font-size: 13px; color: var(--cp-text-muted); }
.cp-pagination-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.cp-page-btn {
  min-width: 36px; height: 36px; padding: 0 10px;
  font: inherit; font-size: 13px;
  background: #fff; color: var(--cp-text);
  border: 1px solid var(--cp-border-strong);
  border-radius: 10px;
  cursor: pointer;
}
.cp-page-btn:hover:not([disabled]) { background: #f0f0f3; }
.cp-page-btn.cp-page-active {
  background: var(--cp-primary); color: #fff; border-color: var(--cp-primary);
}
.cp-page-btn[disabled] { opacity: .4; cursor: not-allowed; }
.cp-page-ellipsis { padding: 0 6px; color: var(--cp-text-muted); align-self: center; }

/* ---------- Map ---------- */
.cp-map-card { padding: 0; overflow: hidden; }
.cp-map-card .cp-grid-header { border-bottom: 1px solid var(--cp-border); }
.cp-map {
  height: 520px;
  width: 100%;
  background: #eaeaea;
}
.leaflet-container { font-family: inherit; }

.cp-popup {
  font-size: 13px;
  line-height: 1.45;
  min-width: 200px;
}
.cp-popup .cp-popup-title { font-weight: 600; font-size: 14px; color: var(--cp-primary); margin-bottom: 4px; }
.cp-popup .cp-popup-row { color: var(--cp-text); }
.cp-popup .cp-popup-muted { color: var(--cp-text-muted); }

/* Custom marker */
.cp-marker {
  width: 28px; height: 28px;
  background: var(--cp-accent);
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
}
.cp-marker::after {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: #fff;
  transform: rotate(45deg);
}

/* ---------- Footer ---------- */
.cp-footer {
  padding: 40px 0 56px;
  color: var(--cp-text-muted);
  font-size: 13px;
  text-align: center;
}
.cp-footer-sub { margin-top: 4px; font-size: 12px; opacity: .8; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .cp-controls { grid-template-columns: 1fr; }
  .cp-meta { grid-template-columns: repeat(2, 1fr); }
  .cp-hero { padding: 28px 0 36px; }
  .cp-map { height: 380px; }
}

/* ==========================================================================
   WordPress theme specificity booster
   --------------------------------------------------------------------------
   Every rule below re-declares the important component styles under the
   #cp-app scope. This raises their specificity from (0,1,0) to (1,1,0) so
   they win against theme rules like `.entry-content .wp-block-button a`
   or `body.page button` that otherwise override our plain `.cp-*` classes.
   ========================================================================== */

#cp-app .cp-container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

#cp-app .cp-section { padding: 28px 0; }
#cp-app .cp-controls-section { padding-top: 32px; }

#cp-app .cp-card {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius);
  box-shadow: var(--cp-shadow);
  padding: 22px;
}

#cp-app .cp-hero {
  position: relative;
  background-color: var(--cp-bg);
  background-image:
    linear-gradient(180deg, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0.25) 45%, var(--cp-bg) 100%),
    url("../images/nature-serenity.png");
  background-repeat: no-repeat, no-repeat;
  background-position: center top, center top;
  background-size: 100% 100%, cover;
  padding: 40px 0 56px;
  border-bottom: 1px solid var(--cp-border);
}

#cp-app .cp-brand { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 40px; flex-wrap: wrap; text-align: center; }
#cp-app .cp-brand-logo { height: 48px; width: auto; display: block; }
#cp-app .cp-brand-divider { width: 1px; align-self: stretch; background: var(--cp-border-strong); min-height: 36px; }
#cp-app .cp-brand-title {
  font-size: clamp(20px, 2.2vw, 28px);
  font-weight: 600; letter-spacing: -0.015em;
  color: var(--cp-primary); margin: 0; line-height: 1.2;
}

#cp-app .cp-hero-title {
  font-size: clamp(14px, 1.3vw, 18px);
  line-height: 1.45; font-weight: 500;
  color: var(--cp-text-muted); max-width: 900px;
  margin-left: auto; margin-right: auto;
  text-align: center;
}
#cp-app .cp-hero-sub { margin-top: 12px; font-size: 14px; color: var(--cp-text-muted); max-width: 720px; margin-left: auto; margin-right: auto; text-align: center; }

#cp-app .cp-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px; align-items: end;
}
@media (min-width: 1100px) {
  #cp-app .cp-controls {
    grid-template-columns: minmax(160px, 1fr) minmax(200px, 1.3fr) minmax(150px, 1fr) minmax(160px, 1fr) minmax(160px, 1fr) auto;
  }
}
#cp-app .cp-control { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
#cp-app .cp-control label {
  display: block;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1 !important;
  min-height: 0 !important;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--cp-text-muted);
}
#cp-app .cp-control label::before,
#cp-app .cp-control label::after { content: none !important; display: none !important; }
/* WP wpautop injects stray <br> between label and field — hide them. */
#cp-app .cp-control > br,
#cp-app .cp-controls br,
#cp-app .cp-controls-row br,
#cp-app .cp-control-actions > br { display: none !important; }
#cp-app .cp-control-actions { display: flex; gap: 10px; grid-column: 1 / -1; justify-content: flex-end; }
@media (min-width: 1100px) { #cp-app .cp-control-actions { grid-column: auto; } }

/* Two-row stacked variant (used on the explorer page) */
#cp-app .cp-controls.cp-controls-stack {
  display: flex;
  flex-direction: column;
  grid-template-columns: none;
  gap: 18px;
  align-items: stretch;
}
#cp-app .cp-controls-row {
  display: grid;
  gap: 18px;
  align-items: end;
}
#cp-app .cp-controls-row-top {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}
#cp-app .cp-controls-row-top .cp-control-search { grid-column: span 1; }
#cp-app .cp-controls-row-bottom {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}
/* Combined "Recently added" + action buttons row: select hugs left,
   Export/Zip buttons hug right on desktop; stacks on mobile. */
#cp-app .cp-controls-row-recent {
  grid-template-columns: minmax(180px, 280px) 1fr;
}
#cp-app .cp-controls-row-recent .cp-control-actions {
  grid-column: auto;
  justify-content: flex-end;
  align-self: end;
}
#cp-app .cp-controls.cp-controls-stack .cp-control-actions {
  grid-column: auto;
  justify-content: flex-end;
}
@media (max-width: 900px) {
  #cp-app .cp-controls-row-top,
  #cp-app .cp-controls-row-bottom { grid-template-columns: 1fr; }
  #cp-app .cp-controls-row-recent { grid-template-columns: 1fr; }
  #cp-app .cp-controls-row-recent .cp-control-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* Visitor Analytics — filters flow on one row (Event type, Details, IP,
   Location, Date range, plus From/To when custom range is selected).
   Action buttons sit inside the filter card on their own row, right-aligned. */
#cp-app .cp-controls-row-vis-top {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  grid-template-columns: none;
}
#cp-app .cp-controls-row-vis-top > .cp-control {
  flex: 1 1 140px;
  min-width: 140px;
}
#cp-app .cp-controls-row-vis-bottom {
  display: flex;
  justify-content: flex-end;
  grid-template-columns: none;
}
#cp-app .cp-controls-row-vis-bottom .cp-control-actions {
  grid-column: auto;
  justify-content: flex-end;
  align-self: end;
}
@media (max-width: 900px) {
  #cp-app .cp-controls-row-vis-top > .cp-control { flex: 1 1 100%; }
  #cp-app .cp-controls-row-vis-bottom {
    justify-content: flex-start;
  }
  #cp-app .cp-controls-row-vis-bottom .cp-control-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

#cp-app .cp-select,
#cp-app .cp-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font: inherit; font-size: 15px;
  color: var(--cp-text);
  background: #fff;
  border: 1px solid var(--cp-border-strong);
  border-radius: var(--cp-radius-sm);
  outline: none;
  box-shadow: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#cp-app .cp-select:focus,
#cp-app .cp-input:focus {
  border-color: var(--cp-primary);
  box-shadow: 0 0 0 4px rgba(11, 37, 69, 0.12);
}
#cp-app .cp-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236e6e73' d='M6 8 0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

#cp-app .cp-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 18px;
  font: inherit; font-size: 14px; font-weight: 500;
  line-height: 1;
  border-radius: 999px;
  border: 1px solid transparent;
  background: none;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  box-shadow: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .05s ease;
  white-space: nowrap;
}
#cp-app .cp-btn:active { transform: translateY(1px); }
#cp-app .cp-btn[disabled] { opacity: .45; cursor: not-allowed; }
#cp-app .cp-btn-primary { background: var(--cp-primary); color: #fff; border-color: var(--cp-primary); }
#cp-app .cp-btn-primary:hover:not([disabled]) { background: var(--cp-primary-600); border-color: var(--cp-primary-600); color: #fff; }
#cp-app .cp-btn-ghost { background: transparent; color: var(--cp-primary); border-color: var(--cp-border-strong); }
#cp-app .cp-btn-ghost:hover { background: #f0f0f3; color: var(--cp-primary); }
#cp-app .cp-btn-accent { background: var(--cp-accent); color: #fff; border-color: var(--cp-accent); }
#cp-app .cp-btn-accent:hover:not([disabled]) { background: var(--cp-accent-600); border-color: var(--cp-accent-600); color: #fff; }

#cp-app .cp-meta {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
}
#cp-app .cp-meta-item {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-sm);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
#cp-app .cp-meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--cp-text-muted); font-weight: 600; }
#cp-app .cp-meta-value { font-size: 18px; font-weight: 600; color: var(--cp-text); }

#cp-app .cp-grid-card { padding: 0; overflow: hidden; }
#cp-app .cp-grid-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--cp-border);
}
#cp-app .cp-grid-header h2 { font-size: 20px; margin: 0; }
#cp-app .cp-grid-info { font-size: 13px; color: var(--cp-text-muted); }

#cp-app .cp-table-wrap { overflow-x: auto; }
#cp-app .cp-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 12px;
  table-layout: auto;
}
#cp-app .cp-table thead th {
  position: sticky; top: 0;
  background: #fafafa;
  text-align: left;
  font-weight: 600;
  color: var(--cp-text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 10px;
  border-bottom: 1px solid var(--cp-border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
#cp-app .cp-table thead th.cp-num { text-align: right; }
#cp-app .cp-table thead th .cp-sort { opacity: .4; margin-left: 4px; font-size: 9px; display: inline; }
#cp-app .cp-table thead th.cp-sort-asc .cp-sort,
#cp-app .cp-table thead th.cp-sort-desc .cp-sort { opacity: 1; color: var(--cp-primary); }
#cp-app .cp-table tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--cp-border);
  vertical-align: top;
  color: var(--cp-text);
  background: transparent;
}
#cp-app .cp-table tbody tr:hover td { background: #fafafa; }
#cp-app .cp-table tbody td.cp-num { text-align: right; font-variant-numeric: tabular-nums; }

#cp-app .cp-pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 22px;
  border-top: 1px solid var(--cp-border);
  flex-wrap: wrap;
}
#cp-app .cp-pagination-info { font-size: 13px; color: var(--cp-text-muted); }
#cp-app .cp-pagination-controls { display: flex; gap: 6px; flex-wrap: wrap; }
#cp-app .cp-page-btn {
  min-width: 36px; height: 36px; padding: 0 10px;
  font: inherit; font-size: 13px; line-height: 1;
  background: #fff; color: var(--cp-text);
  border: 1px solid var(--cp-border-strong);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: none;
}
#cp-app .cp-page-btn:hover:not([disabled]) { background: #f0f0f3; }
#cp-app .cp-page-btn.cp-page-active {
  background: var(--cp-primary); color: #fff; border-color: var(--cp-primary);
}
#cp-app .cp-page-btn[disabled] { opacity: .4; cursor: not-allowed; }
#cp-app .cp-page-ellipsis { padding: 0 6px; color: var(--cp-text-muted); align-self: center; }

#cp-app .cp-badge {
  display: inline-block;
  font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 999px;
  background: rgba(11,37,69,0.08); color: var(--cp-primary);
  white-space: nowrap;
}
#cp-app .cp-badge.cp-badge-accent { background: rgba(138,27,46,0.08); color: var(--cp-accent); }
#cp-app .cp-tag-list { display: flex; flex-wrap: wrap; gap: 3px; }
#cp-app .cp-tag {
  font-size: 10px; padding: 1px 6px; border-radius: 999px;
  background: #f0f0f3; color: #3a3a3c;
  white-space: normal; word-break: break-word;
}

#cp-app .cp-footer {
  padding: 40px 0 56px;
  color: var(--cp-text-muted);
  font-size: 13px;
  text-align: center;
}
#cp-app .cp-footer-sub { margin-top: 4px; font-size: 12px; opacity: .8; }

/* ==========================================================================
   Button icon + label alignment fix
   --------------------------------------------------------------------------
   The bare text node inside <button> becomes an anonymous flex item whose
   line-box can be taller than the button's 44px content area when a parent
   theme (e.g. GeneratePress) injects its own line-height or padding. That
   pushes the text up/down relative to the SVG icon (which sits on its own
   inline baseline) — the familiar "icon centered, text bottom-aligned"
   look seen in some browsers.

   Fix:
   • Force the SVG to block flow so it has no inline baseline.
   • Pin button line-height and padding with !important to defeat themes.
   • Style an explicit .cp-btn-label span (wrap the text in markup) so the
     label is a real flex item with its own controlled line-height.
   ========================================================================== */
#cp-app .cp-btn {
  line-height: 1 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  align-items: center !important;
}
#cp-app .cp-btn > svg,
#cp-app .cp-btn svg {
  display: block;
  flex: 0 0 auto;
  vertical-align: middle;
  align-self: center;
}
#cp-app .cp-btn .cp-btn-label {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  margin: 0;
  padding: 0;
}

/* ==========================================================================
   Mobile adjustments (desktop unchanged)
   ========================================================================== */
@media (max-width: 640px) {
  #cp-app .cp-container { padding: 0 16px; }

  /* Hero */
  #cp-app .cp-hero { padding: 24px 0 28px; }
  #cp-app .cp-brand { gap: 12px; margin-bottom: 20px; }
  #cp-app .cp-brand-logo { height: 38px; }
  #cp-app .cp-brand-divider { display: none; }
  #cp-app .cp-brand-title { font-size: 18px; }
  #cp-app .cp-hero-title { font-size: 14px; line-height: 1.4; }
  #cp-app .cp-hero-sub { font-size: 13px; margin-top: 8px; }

  /* Sections */
  #cp-app .cp-section { padding: 18px 0; }
  #cp-app .cp-controls-section { padding-top: 20px; }
  #cp-app .cp-card { padding: 16px; border-radius: 12px; }

  /* Controls — already 1 col below 900px. Tighten gaps & control heights. */
  #cp-app .cp-controls-row,
  #cp-app .cp-controls.cp-controls-stack { gap: 12px; }
  #cp-app .cp-select,
  #cp-app .cp-input { height: 42px; font-size: 16px; /* 16px avoids iOS zoom */ }
  #cp-app .cp-control label { font-size: 11px; }

  /* Action buttons — stack full width so they're easy to tap */
  #cp-app .cp-control-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  #cp-app .cp-btn {
    width: 100%;
    justify-content: center;
    height: 46px;
    font-size: 15px;
  }

  /* Meta strip — 2 cols, condensed */
  #cp-app .cp-meta {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 14px;
  }
  #cp-app .cp-meta-item { padding: 10px 12px; }
  #cp-app .cp-meta-label { font-size: 10px; }
  #cp-app .cp-meta-value { font-size: 15px; }

  /* Grid / table card */
  #cp-app .cp-grid-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 16px 10px;
  }
  #cp-app .cp-grid-header h2 { font-size: 18px; }
  #cp-app .cp-grid-info { font-size: 12px; }
  #cp-app .cp-table thead th,
  #cp-app .cp-table tbody td { padding: 8px 8px; }

  /* Pagination */
  #cp-app .cp-pagination {
    padding: 12px 16px;
    justify-content: center;
    gap: 8px;
  }
  #cp-app .cp-pagination-info {
    width: 100%;
    text-align: center;
    font-size: 12px;
  }
  #cp-app .cp-page-btn { min-width: 34px; height: 34px; font-size: 12.5px; }

  /* Map */
  #cp-app .cp-map { height: 320px; }

  /* Extract panel */
  #cp-app .cp-extract-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* Footer */
  #cp-app .cp-footer { padding: 24px 0 32px; }
}

@media (max-width: 400px) {
  #cp-app .cp-meta { grid-template-columns: 1fr; }
  #cp-app .cp-brand-title { font-size: 16px; }
}
