:root {
  --bg: #f3f5fb;
  --surface-alt: #eef2fb;
  --text: #11203e;
  --muted: #7181a4;
  --line: #d9e1f2;
  --primary: #4a67f5;
  --primary-soft: #e8edff;
  --success: #1aa36f;
  --success-soft: #e5f8ee;
  --danger: #df4f64;
  --danger-soft: #ffe9ee;
  --shadow: 0 14px 42px rgba(38, 63, 129, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(134, 211, 196, 0.18), transparent 28%),
    linear-gradient(180deg, #f8faff 0%, var(--bg) 100%);
}
button, input, select { font: inherit; }
button { cursor: pointer; border: 0; }
.app-shell { width: min(1440px, calc(100% - 32px)); margin: 24px auto 40px; }
.topbar, .toolbar, .section-heading {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
}
.topbar { align-items: flex-start; margin-bottom: 18px; }
.title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.title-row h1 { margin: 0; font-size: 1.75rem; line-height: 1.1; }
.status-badge {
  padding: 5px 10px; border-radius: 999px; background: #dff7ee; color: var(--success);
  font-size: 0.76rem; font-weight: 700; text-transform: uppercase;
}
.subtitle {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0;
  color: var(--muted); font-size: 0.95rem;
}
.dot { width: 4px; height: 4px; border-radius: 50%; background: #c0c8dd; }
.topbar-actions, .toolbar-actions { display: flex; gap: 12px; align-items: center; }
.backend-loader {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.backend-loader select {
  min-width: 220px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}
.dashboard-card {
  padding: 18px 20px 24px; border: 1px solid rgba(201, 213, 236, 0.8); border-radius: 30px;
  background: rgba(255, 255, 255, 0.88); box-shadow: var(--shadow); backdrop-filter: blur(10px);
}
.toolbar { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.tab-group { display: flex; gap: 10px; flex-wrap: wrap; }
.tab-btn {
  padding: 12px 18px; border-radius: 14px; background: #f1f4fb; color: #4f618a; font-weight: 700;
}
.tab-btn.active {
  background: linear-gradient(180deg, #1f2d4b 0%, #10192d 100%); color: #fff;
  box-shadow: 0 10px 22px rgba(16, 25, 45, 0.22);
}
.ghost-icon, .ghost-action, .plain-action, .upload-btn, .primary-btn, .secondary-btn, .time-chip__button, .close-btn {
  border-radius: 14px;
}
.ghost-icon, .ghost-action, .plain-action, .secondary-btn, .close-btn {
  background: #fff; border: 1px solid var(--line); color: var(--text);
}
.ghost-icon {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
}
.ghost-action, .plain-action, .secondary-btn { padding: 11px 16px; }
.ghost-action:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}
.ghost-action--busy {
  position: relative;
  color: #3557a8;
  background: linear-gradient(120deg, #eef4ff 0%, #ffffff 50%, #eef4ff 100%);
  background-size: 200% 100%;
  animation: statusShimmer 1.4s linear infinite;
}
.primary-btn, .upload-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px;
  background: linear-gradient(135deg, var(--primary) 0%, #5f7bff 100%); color: #fff;
  box-shadow: 0 10px 24px rgba(74, 103, 245, 0.28);
}
.upload-btn input { display: none; }
.time-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 420px)); gap: 16px; padding: 20px 0; }
.time-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(245,248,255,0.96) 100%);
}
.time-chip__label {
  margin-bottom: 8px; color: var(--muted); font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.inline-range { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.inline-range__field span {
  display: block;
  margin-bottom: 8px;
  color: #607293;
  font-size: 0.88rem;
  font-weight: 700;
}
.inline-range__field input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid #cfd8ec;
  background: #fff;
  color: var(--text);
}
.inline-period-error {
  margin-top: -8px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 14px;
  background: #fff1f3;
  color: #b42339;
  border: 1px solid #ffd0d7;
  font-size: 0.9rem;
  font-weight: 700;
}
.section-heading { align-items: end; padding: 8px 0 18px; }
.eyebrow {
  margin: 0 0 6px; color: #7d8fb3; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; font-weight: 800;
}
.section-heading h2, .popover-header h3 { margin: 0; }
.section-note {
  padding: 8px 12px; border-radius: 999px; background: var(--surface-alt); color: #4c618e; font-size: 0.86rem; font-weight: 700;
}
.section-note--syncing {
  position: relative;
  padding: 10px 16px 10px 42px;
  color: #234a8f;
  background:
    linear-gradient(120deg, rgba(217, 233, 255, 0.92) 0%, rgba(238, 245, 255, 0.98) 45%, rgba(217, 233, 255, 0.92) 100%);
  background-size: 200% 100%;
  border: 1px solid #c9dafd;
  box-shadow: 0 12px 24px rgba(72, 110, 196, 0.14);
  animation: statusShimmer 1.8s linear infinite;
}
.section-note--syncing::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid rgba(76, 108, 179, 0.22);
  border-top-color: #3f63c9;
  animation: statusSpin 0.9s linear infinite;
}
.section-note--syncing::after {
  content: "...";
  display: inline-block;
  width: 1.2em;
  overflow: hidden;
  vertical-align: bottom;
  animation: statusDots 1.2s steps(4, end) infinite;
}
@keyframes statusShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes statusSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@keyframes statusDots {
  0% { width: 0; }
  100% { width: 1.2em; }
}
.message-stack {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
}
.info-banner,
.error-banner {
  padding: 13px 16px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.45;
}
.info-banner {
  background: #eef4ff;
  color: #3d5bb2;
  border: 1px solid #d8e3ff;
}
.error-banner {
  background: #fff1f3;
  color: #b42339;
  border: 1px solid #ffd0d7;
}
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi-card {
  min-height: 170px; padding: 18px; border: 1px solid rgba(211, 220, 239, 0.9); border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(246,249,255,0.98) 100%);
  box-shadow: 0 8px 30px rgba(70, 95, 160, 0.08);
  display: grid;
  grid-template-rows: auto auto 1fr;
  row-gap: 8px;
}
.kpi-label {
  margin: 0; color: #53698f; font-size: 0.98rem; font-weight: 800; text-transform: uppercase;
  line-height: 1.25;
  display: flex;
  align-items: flex-start;
  align-self: start;
}
.kpi-description {
  margin: 0;
  color: #8a9aba;
  line-height: 1.45;
  align-self: start;
}
.kpi-card__footer {
  margin-top: 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  align-self: end;
}
.kpi-value {
  font-size: clamp(1.7rem, 2vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}
.delta-pill {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  flex: 0 0 auto;
  align-self: flex-end;
}
.delta-pill.positive { background: var(--success-soft); color: var(--success); }
.delta-pill.negative { background: var(--danger-soft); color: var(--danger); }
.section-two {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.section-two__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.section-two__controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.section-two__label {
  color: var(--muted);
  font-weight: 700;
}
.mini-tab-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.mini-tab {
  padding: 10px 16px;
  border-radius: 12px;
  background: #f1f4fb;
  color: #51627f;
  font-weight: 700;
}
.mini-tab.active {
  background: #0f1628;
  color: #fff;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #51627f;
  font-weight: 700;
}
.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.toggle-track {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #cad4ed;
  transition: 160ms ease;
}
.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 10px rgba(16, 25, 45, 0.18);
  transition: 160ms ease;
}
.toggle input:checked + .toggle-track {
  background: var(--primary);
}
.toggle input:checked + .toggle-track::after {
  left: 23px;
}
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.chart-card {
  padding: 18px;
  border: 1px solid rgba(211, 220, 239, 0.9);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(246,249,255,0.98) 100%);
  box-shadow: 0 8px 30px rgba(70, 95, 160, 0.08);
}
.chart-card__header,
.chart-card__legend,
.chart-card__bars {
  display: flex;
}
.chart-card__header {
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.chart-card__title {
  margin: 0 0 2px;
  font-size: 1.08rem;
}
.chart-card__subtitle {
  margin: 0;
  color: #7d8fb3;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.chart-card__link {
  display: inline-block;
  margin: 10px 0 14px;
  color: var(--primary);
  font-size: 0.9rem;
  text-decoration: none;
  font-weight: 700;
}
.chart-card__legend {
  flex-wrap: wrap;
  gap: 14px;
  justify-content: flex-end;
  margin-bottom: 10px;
  color: #687a9f;
  font-size: 0.82rem;
  font-weight: 700;
}
.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.chart-plot {
  border: 1px dashed #dbe3f2;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(237,242,255,0.35), rgba(255,255,255,0.25)),
    repeating-linear-gradient(to top, transparent 0 24%, rgba(210,220,241,0.55) 24% 25%);
  padding: 18px 14px 8px;
  min-height: 260px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) #dfe6f7;
  position: relative;
  max-width: 100%;
  min-width: 0;
}
.chart-plot::-webkit-scrollbar { height: 10px; }
.chart-plot::-webkit-scrollbar-track {
  background: #dfe6f7;
  border-radius: 999px;
}
.chart-plot::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, var(--primary) 0%, #6e87ff 100%);
  border-radius: 999px;
}
.chart-card__bars {
  align-items: flex-end;
  justify-content: flex-start;
  gap: 14px;
  min-height: 200px;
  min-width: max-content;
  padding-left: 40px;
}
.bar-group {
  flex: 0 0 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}
.bar-stack {
  width: 100%;
  height: 180px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  position: relative;
}
.bar {
  position: relative;
  width: min(34px, 30%);
  min-width: 22px;
  border-radius: 10px 10px 4px 4px;
  transition: transform 140ms ease, filter 140ms ease;
}
.bar:hover {
  transform: translateY(-2px);
  filter: brightness(1.03);
}
.bar::after {
  content: attr(data-value);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #10192d;
  color: #fff;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 2;
}
.bar:hover::after {
  opacity: 1;
}
.x-label {
  color: #6d7e9f;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.25;
  min-height: 42px;
  max-width: 120px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-wrap: balance;
  word-break: break-word;
}
.y-axis {
  position: absolute;
  left: 8px;
  top: 18px;
  bottom: 18px;
  width: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  color: #7a8bad;
  font-size: 0.72rem;
  font-weight: 700;
  pointer-events: none;
}
.y-axis span {
  transform: translateY(50%);
}
.chart-footer-line { display: none; }
.overlay {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(18, 29, 55, 0.24);
  backdrop-filter: blur(8px); z-index: 20;
  overflow-y: auto;
}
.hidden { display: none; }
.popover {
  width: min(760px, 100%); border-radius: 28px; background: #fff; box-shadow: 0 30px 90px rgba(15, 28, 58, 0.22);
}
.popover-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 22px 22px 14px;
}
.close-btn { width: 40px; height: 40px; font-size: 1.25rem; }
.filter-grid { display: grid; gap: 16px; }
.filter-group {
  padding: 18px; border-radius: 20px; background: #f7f9fe; border: 1px solid var(--line);
}
.filter-field span {
  display: block; margin-bottom: 10px; color: #607293; font-weight: 700;
}
.filter-options {
  width: 100%;
  min-height: 124px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #cfd8ec;
  background: #fff;
  color: var(--text);
  display: grid;
  gap: 8px;
}
.filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-radius: 10px;
  color: #44587f;
  font-size: 0.92rem;
  cursor: pointer;
}
.filter-option:hover {
  background: #f4f7ff;
}
.filter-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}
.filter-options__empty {
  color: #8ea0c2;
  font-size: 0.9rem;
  padding: 6px 4px;
}
.filters-popover { width: min(980px, 100%); }
.filters-popover {
  max-height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
}
.drilldown-popover {
  width: min(1100px, 100%);
  max-height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drilldown-body {
  padding: 0 22px 22px;
  display: grid;
  gap: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}
.drilldown-toolbar {
  display: grid;
  gap: 18px;
}
.drilldown-toolbar__group {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.drilldown-toolbar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.drilldown-toolbar__group--timeline {
  margin-left: auto;
  align-items: center;
  justify-content: flex-end;
}
.drilldown-select {
  min-width: 280px;
  max-width: 360px;
  display: inline-grid;
  align-items: center;
  gap: 8px;
}
.drilldown-select span {
  display: block;
  margin-bottom: 0;
  color: #607293;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}
.drilldown-select select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #cfd8ec;
  background: #fff;
  color: var(--text);
}
.drilldown-chart {
  border: 1px solid rgba(211, 220, 239, 0.9);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(246,249,255,0.98) 100%);
  box-shadow: 0 8px 30px rgba(70, 95, 160, 0.08);
  padding: 18px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.drilldown-chart__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.drilldown-chart__title {
  margin: 0;
  font-size: 1.06rem;
}
.drilldown-chart__subtitle {
  margin: 4px 0 0;
  color: #7d8fb3;
  font-size: 0.82rem;
  font-weight: 700;
}
.mini-tab.disabled {
  background: #eef2fb;
  color: #9cabc8;
  cursor: not-allowed;
  opacity: 0.95;
}
.mini-tab.disabled:hover {
  transform: none;
  filter: none;
}
.filters-groups {
  padding: 0 22px 22px;
  display: grid;
  gap: 16px;
  overflow-y: auto;
  min-height: 0;
}
.filter-group h4 { margin: 0 0 16px; }
.filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.filter-grid.single { grid-template-columns: minmax(240px, 1fr); }
.popover-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 0 22px 22px; }
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .topbar, .toolbar, .section-heading { flex-direction: column; align-items: stretch; }
  .toolbar-actions, .topbar-actions, .backend-loader { justify-content: flex-start; flex-wrap: wrap; }
  .time-controls { grid-template-columns: 1fr; }
  .kpi-grid, .filter-grid, .inline-range { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-two__header { flex-direction: column; align-items: stretch; }
  .chart-grid { grid-template-columns: 1fr; }
  .drilldown-toolbar { flex-direction: column; align-items: stretch; }
  .drilldown-toolbar__row { align-items: stretch; }
  .drilldown-toolbar__group--timeline { margin-left: 0; align-items: stretch; justify-content: flex-start; }
  .drilldown-select { min-width: 0; max-width: none; }
}
@media (max-width: 640px) {
  .app-shell { width: min(100% - 20px, 100%); margin: 14px auto 28px; }
  .dashboard-card { padding: 16px; border-radius: 24px; }
  .kpi-grid, .filter-grid, .inline-range, .time-controls { grid-template-columns: 1fr; }
  .chart-card__legend { justify-content: flex-start; }
  .bar-stack { gap: 4px; }
  .backend-loader select { min-width: 100%; }
}

