/* Next Gen Marketing Dashboard — styles
   Accessible, colorblind-friendly palette (Okabe-Ito based) with strong contrast. */

:root {
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-border: #d7dce2;
  --color-text: #1b1f24;
  --color-text-muted: #4a5361;
  --color-accent: #0072b2;      /* blue */
  --color-accent-dark: #00568a;
  --color-success: #009e73;     /* green */
  --color-success-bg: #e6f5ef;
  --color-error: #d55e00;       /* vermillion */
  --color-error-bg: #fdece1;
  --color-warning-bg: #fff3cd;
  --color-warning-text: #6b5300;

  /* Meets the 3:1 non-text contrast requirement for form control boundaries. */
  --color-control-border: #5e6a78;
  --color-focus: #0b3d5c;

  --channel-instagram: #e69f00;
  --channel-tiktok: #56b4e9;
  --channel-google-ads: #009e73;
  --channel-email: #d55e00;
  --channel-default: #7d7d7d;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

@supports not selector(:focus-visible) {
  :focus {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
  }
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  z-index: 100;
  padding: 10px 18px;
  background: var(--color-surface);
  color: var(--color-accent-dark);
  border: 2px solid var(--color-accent-dark);
  border-radius: 0 0 8px 8px;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--color-accent-dark);
}

h1, h2, h3 {
  line-height: 1.25;
  margin-top: 0;
}

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 16px clamp(12px, 4vw, 32px);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  max-width: 1200px;
  margin: 0 auto;
}

.header-title h1 {
  font-size: 1.5rem;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.header-status {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 240px;
  font-size: 0.9rem;
}

.status-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.status-label {
  color: var(--color-text-muted);
}

.status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.82rem;
}

.status-unknown {
  background: #e5e7eb;
  color: #374151;
}

.status-ok {
  background: var(--color-success-bg);
  color: #05543d;
}

.status-error {
  background: var(--color-error-bg);
  color: #8a3600;
}

main#mainContent {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px clamp(12px, 4vw, 32px) 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px clamp(12px, 3vw, 24px);
}

.error-banner {
  background: var(--color-error-bg);
  color: #8a3600;
  border: 1px solid var(--color-error);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-weight: 600;
}

.warning-banner {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  border: 1px solid #d6b800;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 0.92rem;
}

.no-data-message {
  background: #eef1f5;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Filters */

.filters-form {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  align-items: end;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}

.filter-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.filter-field select,
.filter-field input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--color-control-border);
  border-radius: 6px;
  font-size: 0.95rem;
  background: var(--color-surface);
  color: var(--color-text);
  min-height: 40px;
}

.filter-actions {
  align-self: end;
}

.filter-summary {
  margin: 12px 0 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.btn {
  cursor: pointer;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  min-height: 40px;
}

.btn[disabled] {
  cursor: progress;
}

.btn-primary {
  background: var(--color-accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--color-accent-dark);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-accent-dark);
  border: 1px solid var(--color-accent);
}

.btn-secondary:hover {
  background: #eaf3fa;
}

/* KPI Cards */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin: 0;
}

.kpi-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  background: #fafcfe;
}

.kpi-card .kpi-label {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-card .kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 4px 0 0;
  color: var(--color-accent-dark);
}

/* Charts */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.chart-card-wide {
  grid-column: 1 / -1;
}

.chart-card h3 {
  font-size: 1.05rem;
  margin-bottom: 10px;
}

.chart-wrap {
  position: relative;
  height: 320px;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-weight: 600;
  background: #fafcfe;
  border: 1px dashed var(--color-border);
  border-radius: 8px;
}

@media (max-width: 780px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
  .chart-wrap {
    height: 280px;
  }
}

/* Table */

.scroll-hint {
  margin: 0 0 8px;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* Above this width the table fits without scrolling, so the hint would be wrong. Zooming in
   narrows the CSS viewport, which brings the hint back exactly when scrolling returns. */
@media (min-width: 1000px) {
  .scroll-hint {
    display: none;
  }
}

.table-scroll {
  overflow-x: auto;
}

.table-scroll:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 820px;
  font-size: 0.92rem;
}

thead th {
  text-align: left;
  background: #eef2f7;
  color: var(--color-text);
  padding: 10px 10px;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

tbody tr:hover {
  background: #f5f9fc;
}

/* Answers */

.answers-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.answer-card {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fafcfe;
}

.answer-question {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 6px;
}

.answer-body {
  margin: 0;
  color: var(--color-text);
}

.answer-body ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

/* Data Method */

.method-text p {
  margin: 0 0 10px;
}

.method-text ul {
  margin: 0 0 10px;
  padding-left: 22px;
}

.site-footer {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 18px 0 32px;
}

@media (max-width: 560px) {
  .header-inner {
    flex-direction: column;
  }
  .header-status {
    width: 100%;
  }
}
