@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500;600&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: #0d0d0f;
  color: #e8e8f0;
  min-height: 100vh;
  padding: 20px;
}

.shell {
  width: min(1280px, 100%);
  margin: 0 auto;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 20px;
}

.title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.6px;
  color: #fff;
}

.subtitle {
  font-size: 12px;
  color: #555;
  font-family: 'DM Mono', monospace;
  margin-top: 4px;
}

.badge {
  background: #1a1a2e;
  border: 1px solid #2a2a45;
  color: #8177ff;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  margin-top: 10px;
  display: inline-block;
}

.header-right {
  text-align: right;
  flex-shrink: 0;
}

.header-label {
  font-size: 10px;
  color: #333;
  font-family: 'DM Mono', monospace;
}

.header-time {
  font-size: 12px;
  color: #555;
  font-family: 'DM Mono', monospace;
  margin-top: 2px;
}

.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.period-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.period-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.period-btn,
.refresh-btn {
  padding: 7px 13px;
  border-radius: 20px;
  border: 1px solid #222;
  background: transparent;
  color: #666;
  cursor: pointer;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
  white-space: nowrap;
}

.period-btn.active {
  background: #29284b;
  border-color: #6c63ff;
  color: #fff;
}

.period-btn:hover:not(.active),
.refresh-btn:hover:hover {
  border-color: #6c63ff55;
  color: #aaa;
}

.refresh-btn {
  color: #777;
  margin-top: 0;
}

.refresh-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.custom-period {
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.custom-period.visible {
  display: flex;
}

.custom-period label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #555;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
}

.custom-period input {
  background: #0a0a0d;
  border: 1px solid #222;
  color: #aaa;
  border-radius: 18px;
  padding: 6px 9px;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  outline: none;
}

.custom-period input:focus {
  border-color: #6c63ff;
  color: #fff;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tab {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid #222;
  background: transparent;
  color: #555;
  cursor: pointer;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
  white-space: nowrap;
  position: relative;
  z-index: 2;
}

.tab.active {
  background: #6c63ff;
  border-color: #6c63ff;
  color: #fff;
}

.tab:hover:not(.active) {
  border-color: #6c63ff33;
  color: #888;
}

.cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.card {
  background: #111116;
  border: 1px solid #1a1a22;
  border-radius: 12px;
  padding: 16px;
  min-height: 110px;
}

.card-label {
  font-size: 10px;
  color: #444;
  font-family: 'DM Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}

.card-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.8px;
}

.card-value.v1 { color: #fff; }
.card-value.v2 { color: #6c63ff; }
.card-value.v3 { color: #4ade80; }
.card-value.v4 { color: #fbbf24; }
.card-value.v5 { color: #a78bfa; }

.card-sub {
  font-size: 11px;
  color: #3f3f48;
  margin-top: 5px;
  line-height: 1.35;
}

.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.chart-card {
  background: #111116;
  border: 1px solid #1a1a22;
  border-radius: 12px;
  padding: 20px;
  min-height: 380px;
}

.chart-title {
  font-size: 14px;
  font-weight: 500;
  color: #bbb;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-title em {
  font-style: normal;
  font-size: 10px;
  color: #333;
  font-family: 'DM Mono', monospace;
}

.funnel,
.avg-chart {
  display: flex;
  flex-direction: column;
}

.funnel {
  gap: 5px;
}

.avg-chart {
  gap: 10px;
}

.funnel-stage,
.avg-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.f-label,
.a-label {
  font-size: 11px;
  color: #666;
  font-family: 'DM Mono', monospace;
  width: 112px;
  flex-shrink: 0;
  text-align: right;
}

.f-track {
  flex: 1;
  height: 30px;
  background: #0a0a0d;
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.f-bar {
  height: 100%;
  border-radius: 5px;
  display: flex;
  align-items: center;
  padding-left: 10px;
  transition: width 0.35s ease;
}

.f-num {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  font-family: 'DM Mono', monospace;
}

.f-pct {
  font-size: 11px;
  width: 42px;
  flex-shrink: 0;
  text-align: right;
  font-family: 'DM Mono', monospace;
  color: #666;
}

.f-arrow {
  font-size: 10px;
  color: #272734;
  padding-left: 123px;
  font-family: 'DM Mono', monospace;
  line-height: 1.2;
}

.a-track {
  flex: 1;
  height: 26px;
  background: #0a0a0d;
  border-radius: 5px;
  overflow: hidden;
}

.a-bar {
  height: 100%;
  background: linear-gradient(90deg, #6c63ff, #a78bfa);
  border-radius: 5px;
  display: flex;
  align-items: center;
  padding-left: 9px;
  transition: width 0.35s ease;
  min-width: 0;
}

.a-val {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0;
  border-bottom: 1px solid #1a1a22;
  color: #777;
  font-size: 12px;
}

.info-row strong {
  color: #ccc;
  font-weight: 500;
}

.footer {
  font-size: 11px;
  color: #2f2f3f;
  font-family: 'DM Mono', monospace;
  text-align: right;
  margin-top: 16px;
}

.waiting {
  animation: pulse 2s ease-in-out infinite;
  color: #6c63ff66;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  text-align: center;
  padding: 18px 4px;
}

.error {
  color: #f87171;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  padding: 18px;
  background: #1c1115;
  border: 1px solid #3c1820;
  border-radius: 12px;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@media (max-width: 1100px) {
  .cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  body { padding: 14px; }

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

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

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

  .header-right {
    text-align: left;
  }

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

  .f-label,
  .a-label {
    width: 92px;
    font-size: 10px;
  }

  .f-arrow {
    padding-left: 103px;
  }

  .custom-period {
    width: 100%;
  }

  .custom-period label {
    width: 100%;
    justify-content: space-between;
  }

  .custom-period input {
    flex: 1;
  }
}
