:root {
  --bg-cream: #f6f2e8;
  --ink-900: #1f2435;
  --ink-700: #3e4663;
  --mint: #1a7f5a;
  --teal: #2f6f91;
  --amber: #ed8d21;
  --rose: #b93c5d;
  --panel: rgba(255, 255, 255, 0.72);
  --shadow-soft: 0 10px 30px rgba(20, 32, 55, 0.1);
  --chart-panel-height: 230px;
  --chart-panel-wide-height: 260px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink-900);
  background: radial-gradient(circle at 10% 10%, #e8f4ef 0%, transparent 45%),
    radial-gradient(circle at 90% 15%, #ffe2d0 0%, transparent 40%),
    radial-gradient(circle at 25% 85%, #d7e7ff 0%, transparent 42%),
    var(--bg-cream);
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(31, 36, 53, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 36, 53, 0.03) 1px, transparent 1px);
  background-size: 26px 26px;
}

.dashboard-shell {
  width: min(980px, 90vw);
  margin: 2rem auto 3rem;
  position: relative;
  z-index: 1;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.3rem;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.brand-logo-image {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(31, 36, 53, 0.2);
}

.brand-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-logo-text strong {
  font-size: 0.95rem;
}

.brand-logo-text span {
  font-size: 0.74rem;
  color: var(--ink-700);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.eyebrow {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mint);
  margin: 0;
}

h1 {
  margin: 0.25rem 0 0;
  font-family: "Newsreader", serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.05;
}

#dashboardTitle {
  white-space: nowrap;
  font-size: clamp(1.5rem, 3.1vw, 2.6rem);
}

.subtitle {
  margin: 0;
  color: var(--ink-700);
  font-weight: 500;
}

.nav-link {
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
}

.nav-link:hover {
  text-decoration: underline;
}

.nav-link-disabled {
  color: var(--ink-700);
  opacity: 0.75;
  text-decoration: none;
  cursor: default;
}

.dashboard-filters {
  margin-bottom: 1rem;
  padding: 0.75rem;
  border: 1px solid rgba(63, 73, 103, 0.12);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(6px);
  position: relative;
  z-index: 40;
  overflow: visible;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.campaign-kpi-grid {
  margin-top: -0.2rem;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid rgba(63, 73, 103, 0.12);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(6px);
  animation: fadeUp 0.5s ease both;
}

.kpi-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-700);
}

.kpi-card h2 {
  margin: 0.4rem 0 0;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
}

.kpi-card-campaign {
  border-color: rgba(26, 127, 90, 0.22);
}

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

.panel {
  background: var(--panel);
  border: 1px solid rgba(63, 73, 103, 0.12);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: var(--shadow-soft);
  min-height: var(--chart-panel-height);
  animation: fadeUp 0.55s ease both;
}

.panel-wide {
  grid-column: span 2;
  min-height: var(--chart-panel-wide-height);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.panel-head h3 {
  margin: 0;
  font-size: 1.03rem;
}

.panel-head span {
  color: var(--ink-700);
  font-size: 0.85rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.trend-form {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.region-dropdown {
  position: relative;
  z-index: 60;
}

.region-summary {
  min-width: 150px;
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.region-summary::after {
  content: "▾";
  font-size: 0.78rem;
  opacity: 0.75;
}

.region-summary::-webkit-details-marker {
  display: none;
}

.region-dropdown[open] .region-summary::after {
  content: "▴";
}

.region-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 120;
  min-width: 190px;
  max-height: 220px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(63, 73, 103, 0.2);
  border-radius: 12px;
  box-shadow: 0 14px 24px rgba(20, 32, 55, 0.16);
  padding: 0.45rem;
}

.region-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.28rem;
  border-radius: 8px;
  font-size: 0.84rem;
  color: var(--ink-900);
}

.region-option:hover {
  background: rgba(26, 127, 90, 0.1);
}

.region-option input {
  accent-color: var(--mint);
}

.trend-select {
  border: 1px solid rgba(63, 73, 103, 0.28);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-900);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.35rem 0.55rem;
}

.trend-select:focus {
  outline: 2px solid rgba(26, 127, 90, 0.32);
  outline-offset: 2px;
}

.trend-apply,
.trend-reset {
  border: 1px solid rgba(63, 73, 103, 0.28);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-900);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  text-decoration: none;
}

.trend-apply {
  cursor: pointer;
}

.trend-apply:hover,
.trend-reset:hover {
  background: rgba(26, 127, 90, 0.12);
}

.chart-style-note {
  margin: -0.25rem 0 0.45rem;
  font-size: 0.8rem;
  color: var(--ink-700);
}

.panel canvas {
  width: 100% !important;
  height: 170px !important;
}

.table-panel {
  margin-top: 1rem;
  min-height: 0;
}

.config-panel {
  margin-top: 1.2rem;
  min-height: 0;
}

.config-form {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  width: 100%;
  max-width: 100%;
}

.config-form-options {
  margin-top: 1.4rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(63, 73, 103, 0.16);
  width: 100%;
  max-width: 100%;
}

.config-subtitle {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.config-form label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-700);
  display: block;
  margin-bottom: 0.3rem;
}

.config-form input,
.config-form select {
  width: 100%;
  box-sizing: border-box;
}

.save-config-btn {
  border: 0;
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--teal), var(--mint));
  cursor: pointer;
}

.status-badge {
  margin-top: 0.7rem;
  margin-bottom: 0;
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
}

.status-success {
  color: #0d6f4f;
  background: rgba(26, 127, 90, 0.14);
}

.status-error {
  color: #8f2f47;
  background: rgba(185, 60, 93, 0.14);
}

.dashboard-footer {
  margin-top: 1.2rem;
  padding: 0.9rem 0.2rem 0.2rem;
  border-top: 1px solid rgba(63, 73, 103, 0.18);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  color: var(--ink-700);
}

.dashboard-footer p,
.dashboard-footer small {
  margin: 0;
}

.dashboard-footer small {
  font-size: 0.82rem;
}

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

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

thead th {
  text-align: left;
  font-weight: 700;
  color: var(--ink-700);
  border-bottom: 1px solid rgba(63, 73, 103, 0.2);
  padding: 0.65rem 0.5rem;
}

tbody td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid rgba(63, 73, 103, 0.12);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.5);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }

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

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

  .panel-wide {
    grid-column: span 1;
  }

  #dashboardTitle {
    white-space: normal;
  }
}

@media (max-width: 600px) {
  .dashboard-shell {
    width: 94vw;
    margin-top: 1.2rem;
  }

  .region-menu {
    min-width: min(78vw, 240px);
  }

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

  .panel {
    min-height: 210px;
  }

  .panel canvas {
    height: 150px !important;
  }

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